#include "stdafx.h"
|
#include "CEqStatusStep.h"
|
#include "Log.h"
|
#include "ToolUnits.h"
|
|
|
namespace SERVO {
|
CEqStatusStep::CEqStatusStep() : CStep()
|
{
|
m_nStatusDev = 0;
|
for (int i = 0; i < STATUS_MAX; i++) {
|
m_nStatus[i] = 7;
|
m_nReasonCode[i] = 0;
|
}
|
|
|
}
|
|
CEqStatusStep::~CEqStatusStep()
|
{
|
|
}
|
|
int CEqStatusStep::onReadData()
|
{
|
CStep::onReadData();
|
|
char szBuffer[64];
|
int nRet = m_pCclink->ReadData2(m_station, DeviceType::W,
|
m_nStatusDev, 64, szBuffer);
|
if (0 == nRet) {
|
unsigned int unitId = (unsigned int)CToolUnits::toInt16(&szBuffer[0]);
|
if (unitId < STATUS_MAX) {
|
if (unitId == 0) {
|
m_nStatus[unitId] = CToolUnits::toInt16(&szBuffer[2 + unitId * 4]);
|
m_nReasonCode[unitId] = CToolUnits::toInt16(&szBuffer[2 + unitId * 4 + 2]);
|
}
|
else {
|
m_nStatus[unitId] = CToolUnits::toInt16(&szBuffer[2 + 3 * 2 + unitId * 4]);
|
m_nReasonCode[unitId] = CToolUnits::toInt16(&szBuffer[2 + 3 * 2 + unitId * 4 + 2]);
|
}
|
|
for (int i = 0; i < 64; i++) {
|
TRACE("bbb %d, %x\n", i, szBuffer[i]);
|
}
|
TRACE("cccc %d %d %d\n", unitId, m_nStatus[unitId], m_nReasonCode[unitId]);
|
std::string strTemp;
|
LOGI("<CEqStatusStep> Equipment Status Changed<Unit:%d, %s, ReasonCode=%d>\n",
|
unitId, getStatusDescription(unitId, strTemp).c_str(), m_nReasonCode[unitId]);
|
}
|
}
|
|
|
return 0;
|
}
|
|
int CEqStatusStep::onComplete()
|
{
|
CStep::onComplete();
|
LOGI("<CEqStatusStep> onComplete.");
|
|
return 0;
|
}
|
|
int CEqStatusStep::onTimeout()
|
{
|
CStep::onTimeout();
|
LOGI("<CEqStatusStep> onTimeout.");
|
|
return 0;
|
}
|
|
void CEqStatusStep::setStatusDev(int nDev)
|
{
|
m_nStatusDev = nDev;
|
}
|
|
/*
|
Lower (1byte, 0~7) : Status
|
1 : PM
|
2 : Down(BM)
|
3 : Pause
|
4 : Idle
|
5: Run
|
6: Job Change
|
7 : ETC
|
*/
|
std::string& CEqStatusStep::getStatusDescription(unsigned int unid, std::string& strDescription)
|
{
|
if (unid < STATUS_MAX) {
|
switch (m_nStatus[unid]) {
|
case 1:
|
strDescription = _T("PM");
|
break;
|
case 2:
|
strDescription = _T("Down(BM)");
|
break;
|
case 3:
|
strDescription = _T("Pause");
|
break;
|
case 4:
|
strDescription = _T("Idle");
|
break;
|
case 5:
|
strDescription = _T("Run");
|
break;
|
case 6:
|
strDescription = _T("Job Change");
|
break;
|
case 7:
|
strDescription = _T("ETC");
|
break;
|
default:
|
strDescription = _T("");
|
break;
|
}
|
}
|
|
|
return strDescription;
|
}
|
}
|