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.
66 lines
1.5 KiB
C++
66 lines
1.5 KiB
C++
#include "StdAfx.h"
|
|
#include "WorkCmdPciPortCheck.h"
|
|
#include "ExceptionMsg.h"
|
|
#include "LogMgr.h"
|
|
#include "PciPortMgr.h"
|
|
#include "PciCh365Mgr.h"
|
|
|
|
|
|
#define PER_CHECK_DELAY 50 //每隔多少时间检测一次(ms)
|
|
|
|
CWorkCmdPciPortCheck::CWorkCmdPciPortCheck(CString &CtrlContent,bool NeedState)
|
|
:m_CtrlContent(CtrlContent),m_NeedState(NeedState)
|
|
{
|
|
m_MaxCheckDelay = 0;
|
|
}
|
|
CWorkCmdPciPortCheck::~CWorkCmdPciPortCheck(void)
|
|
{
|
|
}
|
|
//检查指定pci 端口,如果不满足要求的状态则抛出异常
|
|
bool CWorkCmdPciPortCheck::Excute()
|
|
{
|
|
if(gLogMgr->IsDebuging())//调试状态只延时
|
|
{
|
|
//Sleep(gLogMgr->GetDebugCmdDelay());
|
|
//return true;
|
|
}
|
|
bool ret;
|
|
if(m_MaxCheckDelay>0)//持续检测
|
|
{
|
|
int CurDelay = 0;//当前延时时间
|
|
while(CurDelay<m_MaxCheckDelay)
|
|
{
|
|
ret = ReadPortState();
|
|
if(ret == m_NeedState)//满足
|
|
break;
|
|
Sleep(PER_CHECK_DELAY);
|
|
CurDelay += PER_CHECK_DELAY;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ret = ReadPortState();
|
|
}
|
|
if(ret != m_NeedState)
|
|
{
|
|
CString str(m_CtrlContent+_T("端口检查ERR"));
|
|
CExceptionMsg Msg;
|
|
Msg.SetMsg(str);
|
|
throw Msg;
|
|
}
|
|
return true;
|
|
}
|
|
void CWorkCmdPciPortCheck::WirteLog()
|
|
{
|
|
CString str = "[WorkCmd]";
|
|
str += _T("[检查端口][")+m_CtrlContent+"]";
|
|
gLogMgr->WriteDebugLog(str);
|
|
}
|
|
|
|
bool CWorkCmdPciPortCheck::ReadPortState()
|
|
{
|
|
bool ret;
|
|
ret = gPciCh365Mgr->ReadPortState(gPciPortMgr->GetCtrlPort(m_CtrlContent));
|
|
return ret;
|
|
}
|