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.

62 lines
1.2 KiB
C++

#include "StdAfx.h"
#include "DeviceState.h"
#include "MsgBox.h"
#include "LogMgr.h"
CDeviceState CDeviceState::m_Instance;
CDeviceState::CDeviceState(void)
{
m_State = _STATE_WAIT;
m_bIsIni = false;//是否初始化
}
CDeviceState::~CDeviceState(void)
{
}
bool CDeviceState::CheckState(DEVICE_STATE state,bool flg)
{
bool ret;
if(flg)
ret = (m_State == state);
else
ret = (m_State != state);
if(!ret)
{
CString str(_T("error : 设备"));
gLogMgr->WriteDebugLog(str+GetStateStr());
}
return ret;
}
CString CDeviceState::GetStateStr()
{
if(!m_bIsIni)
return _T("未初始化");
CString str;
switch(m_State)
{
case _STATE_WAIT:
str = _T("待机中");
break;
case _STATE_WORKING:
str = _T("工作中");
break;
default:
break;
}
return str;
}
void CDeviceState::SetIniState(bool b)
{
m_bIsIni = b;
}
//检查初始化状态
bool CDeviceState::CheckInitState()
{
if(!m_bIsIni)
{
CMsgBox MsgBox;
CString str(_T("error : 设备未初始化"));
MsgBox.Show(str);
}
return m_bIsIni;
}