69 lines
1.3 KiB
C++
69 lines
1.3 KiB
C++
|
#include "BasePurifier.h"
|
|||
|
#include "../config/ConfigManager.h"
|
|||
|
#include "../SystemInfo.h"
|
|||
|
#include <atlbase.h>
|
|||
|
#include "../ScannerCtrl/BaseCtrl.h"
|
|||
|
|
|||
|
|
|||
|
BasePurifier::BasePurifier()
|
|||
|
:m_Thread(INVALID_HANDLE_VALUE)
|
|||
|
, m_RunFlag(false)
|
|||
|
, m_PurifierWinShow(false)
|
|||
|
{
|
|||
|
m_ExtCfg = ConfigManager::GetInstance()->GetExtCfg();
|
|||
|
m_IOCfgWrapper = ConfigManager::GetInstance()->GetIoCfgWrapper();
|
|||
|
m_AlarmCfgWrapper = ConfigManager::GetInstance()->GetAlarmCfg();
|
|||
|
m_CycleTick = 80;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
BasePurifier::~BasePurifier()
|
|||
|
{
|
|||
|
m_RunFlag = false;
|
|||
|
if (m_Thread != INVALID_HANDLE_VALUE)
|
|||
|
{
|
|||
|
if (WaitForSingleObject(m_Thread, 500) == WAIT_TIMEOUT)
|
|||
|
{
|
|||
|
TerminateThread(m_Thread, 1);
|
|||
|
}
|
|||
|
CloseHandle(m_Thread);
|
|||
|
m_Thread = INVALID_HANDLE_VALUE;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void BasePurifier::Startup()
|
|||
|
{
|
|||
|
m_RunFlag = true;
|
|||
|
m_Thread = AtlCreateThread(WorkProc, this);
|
|||
|
}
|
|||
|
|
|||
|
DWORD WINAPI BasePurifier::WorkProc(BasePurifier* _this)
|
|||
|
{
|
|||
|
if (_this)
|
|||
|
{
|
|||
|
_this->WorkRun();
|
|||
|
}
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
void BasePurifier::WorkRun()
|
|||
|
{
|
|||
|
while (m_RunFlag) {
|
|||
|
UpdateShowStat();
|
|||
|
if (BaseCtrl::IsStart() || BaseCtrl::IsPause()) {
|
|||
|
AutoCtrlWhenPrint();
|
|||
|
}
|
|||
|
else if (BaseCtrl::IsStandBy())
|
|||
|
{
|
|||
|
AutoCtrlWhenStanby();
|
|||
|
}
|
|||
|
UpdateShowStat();
|
|||
|
AutoCtrl();
|
|||
|
|
|||
|
if (!m_IOCfgWrapper->m_PrintDoorLock->IsActive() && m_AlarmCfgWrapper->m_PrintCabinDoorOpenAlarm->m_IsEnable) {
|
|||
|
AutoCtrlWhenDoorOpen();
|
|||
|
}
|
|||
|
|
|||
|
Sleep(m_CycleTick);
|
|||
|
}
|
|||
|
}
|