You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
#include "StdAfx.h"
|
|
#include "WorkCmd.h"
|
|
#include "GlobalFunction.h"
|
|
#include "TimingProgressMgr.h"
|
|
|
|
|
|
CWorkCmd::CWorkCmd(void)
|
|
{
|
|
m_FrontDelay = 0;//指令执行之前的延时(单位: 毫秒)
|
|
m_AfterDelay = 0;//指令执行之后的延时(单位: 毫秒)
|
|
m_bCancel = true;
|
|
m_bShowLog = true;//是否输出日志
|
|
m_bUseSleepDelay = false;//使用sleep 进行延时
|
|
m_bExcuted = false;//是否已经被执行
|
|
m_bExcuting = false;//正在被执行
|
|
}
|
|
CWorkCmd::~CWorkCmd(void)
|
|
{
|
|
}
|
|
//返回是否终止
|
|
bool CWorkCmd::Work(bool Cancel)
|
|
{
|
|
if(Cancel && m_bCancel)//指令被取消
|
|
{
|
|
return true;
|
|
}
|
|
if(m_bExcuted)
|
|
return false;//已经被执行过了
|
|
//执行前延时
|
|
if(m_FrontDelay>0)
|
|
{
|
|
if(m_bUseSleepDelay)
|
|
Sleep(m_FrontDelay);
|
|
else
|
|
ExactDelay(Ms2Us(m_FrontDelay));
|
|
}
|
|
//写日志
|
|
if(m_bShowLog)
|
|
WirteLog();
|
|
|
|
//执行
|
|
bool Ret = !Excute();
|
|
//执行后延时
|
|
if(m_AfterDelay>0)
|
|
{
|
|
if(m_bUseSleepDelay)
|
|
Sleep(m_AfterDelay);
|
|
else
|
|
ExactDelay(Ms2Us(m_AfterDelay));
|
|
}
|
|
if(Cancel)//保持Cancel 的状态
|
|
return true;
|
|
m_bExcuted = true;
|
|
return Ret;
|
|
} |