#include "BaseCtrl.h" #include #include "../DataManage/ClientInfo.h" BaseCtrl::PrintState BaseCtrl::m_print_state = STANDBY; BaseCtrl::PreRunState BaseCtrl::m_PreRunState = NonePre; vector BaseCtrl::m_InitErrorInfos; BaseCtrl::PauseState BaseCtrl::m_PauseState = ManualPause; CRITICAL_SECTION BaseCtrl::m_CS; BaseCtrl::BaseCtrl() { } BaseCtrl::~BaseCtrl() { } void BaseCtrl::SInit() { InitializeCriticalSection(&m_CS); } void BaseCtrl::SUninit() { DeleteCriticalSection(&m_CS); } void BaseCtrl::SetJobController(JobController* job_controller) { this->m_job_controller = job_controller; } bool BaseCtrl::IsStart() { bool rel = false; EnterCriticalSection(&BaseCtrl::m_CS); if (m_print_state == PRINTING) { rel = true; } else rel = false; LeaveCriticalSection(&BaseCtrl::m_CS); return rel; } bool BaseCtrl::IsStandBy() { bool rel = false; EnterCriticalSection(&BaseCtrl::m_CS); if (m_print_state == STANDBY || m_print_state == STANDBY_PAUSE || m_print_state == STANDBY_STOP) { rel = true; } else rel = false; LeaveCriticalSection(&BaseCtrl::m_CS); return rel; } bool BaseCtrl::IsPauseStanBy() { bool rel = false; EnterCriticalSection(&BaseCtrl::m_CS); if (m_print_state == STANDBY_PAUSE)rel = true; else rel = false; LeaveCriticalSection(&BaseCtrl::m_CS); return rel; } bool BaseCtrl::IsPause() { bool rel = false; EnterCriticalSection(&BaseCtrl::m_CS); if (m_print_state == PAUSE) { rel = true; } else rel = false; LeaveCriticalSection(&BaseCtrl::m_CS); return rel; } bool BaseCtrl::IsStop() { bool rel = false; EnterCriticalSection(&BaseCtrl::m_CS); if (m_print_state == STOP) { rel = true; } else rel = false; LeaveCriticalSection(&BaseCtrl::m_CS); return rel; } bool BaseCtrl::IsPrePrint() { bool rel = false; EnterCriticalSection(&BaseCtrl::m_CS); if (m_print_state == PREPRINT) { rel = true; } else rel = false; LeaveCriticalSection(&BaseCtrl::m_CS); return rel; } bool BaseCtrl::IsFinish() { bool rel = false; EnterCriticalSection(&BaseCtrl::m_CS); if (m_print_state == FINISH) { rel = true; } else rel = false; LeaveCriticalSection(&BaseCtrl::m_CS); return rel; } void BaseCtrl::SetFinish() { EnterCriticalSection(&BaseCtrl::m_CS); m_print_state = FINISH; LeaveCriticalSection(&BaseCtrl::m_CS); SendToClients(); } void BaseCtrl::SetStandBy() { EnterCriticalSection(&BaseCtrl::m_CS); m_print_state = STANDBY; LeaveCriticalSection(&BaseCtrl::m_CS); SendToClients(); } void BaseCtrl::SetPauseState(BaseCtrl::PauseState ps) { EnterCriticalSection(&BaseCtrl::m_CS); m_PauseState = ps; LeaveCriticalSection(&BaseCtrl::m_CS); SendToClients(); } void BaseCtrl::SetState(PrintState ps) { EnterCriticalSection(&BaseCtrl::m_CS); m_print_state = ps; LeaveCriticalSection(&BaseCtrl::m_CS); SendToClients(); } void BaseCtrl::SetPreState(BaseCtrl::PreRunState rs) { EnterCriticalSection(&BaseCtrl::m_CS); m_PreRunState = rs; LeaveCriticalSection(&BaseCtrl::m_CS); SendToClients(); } BaseCtrl::PrintState BaseCtrl::GetState() { PrintState ps; EnterCriticalSection(&BaseCtrl::m_CS); ps = m_print_state; LeaveCriticalSection(&BaseCtrl::m_CS); return ps; } BaseCtrl::PreRunState BaseCtrl::GetPreState() { PreRunState ps; EnterCriticalSection(&BaseCtrl::m_CS); ps = m_PreRunState; LeaveCriticalSection(&BaseCtrl::m_CS); return ps; } BaseCtrl::PauseState BaseCtrl::GetPauseState() { PauseState ps; EnterCriticalSection(&BaseCtrl::m_CS); ps = m_PauseState; LeaveCriticalSection(&BaseCtrl::m_CS); return ps; } bool BaseCtrl::IsHeatingScanner() { if (m_print_state == PREPRINT && m_PreRunState == AutoHeatingScanner) { return true; } else return false; } void BaseCtrl::SendToClients() { list its; its.emplace_back(Item{"IsStart",to_string(IsStart()), iBOOL}); its.emplace_back(Item{"IsPause",to_string(IsPause()), iBOOL}); its.emplace_back(Item{"IsStop",to_string(IsStop()), iBOOL}); its.emplace_back(Item{"IsStandBy",to_string(IsStandBy()), iBOOL}); its.emplace_back(Item{"IsFinish",to_string(IsFinish()), iBOOL}); its.emplace_back(Item{"IsPrePrint",to_string(IsPrePrint()), iBOOL}); its.emplace_back(Item{"IsPauseStanBy",to_string(IsPauseStanBy()), iBOOL}); its.emplace_back(Item{"IsHeatingScanner",to_string(IsHeatingScanner()), iBOOL}); its.emplace_back(Item{"State",to_string(GetState()), iBOOL}); its.emplace_back(Item{"PreState",to_string(GetPreState()), iBOOL}); its.emplace_back(Item{"PauseState",to_string(GetPauseState()), iBOOL}); ClientWrapper::Instance()->PushAllClient(WriteData(SCANCTRLSTATE, its)); }