#include "stdafx.h"
|
#include "CEqReadIntStep.h"
|
#include "Log.h"
|
|
|
namespace SERVO {
|
CEqReadIntStep::CEqReadIntStep() : CReadStep()
|
{
|
m_nDataType = __INT16;
|
m_nValueDev = 0;
|
m_nValue = 0;
|
}
|
|
CEqReadIntStep::CEqReadIntStep(int dataType, int dev)
|
{
|
m_nDataType = dataType;
|
m_nValueDev = dev;
|
m_nValue = 0;
|
}
|
|
CEqReadIntStep::~CEqReadIntStep()
|
{
|
|
}
|
|
void CEqReadIntStep::getAttributeVector(CAttributeVector& attrubutes)
|
{
|
CReadStep::getAttributeVector(attrubutes);
|
|
unsigned int weight = 31;
|
std::string strTemp;
|
attrubutes.addAttribute(new CAttribute("Dev",
|
("W" + CToolUnits::toHexString(m_nValueDev, strTemp)).c_str(), "", weight++));
|
attrubutes.addAttribute(new CAttribute("Value",
|
std::to_string(m_nValue).c_str(), "", weight++));
|
}
|
|
int CEqReadIntStep::onReadData()
|
{
|
CReadStep::onReadData();
|
|
|
char szBuffer[32];
|
int nRet = m_pCclink->ReadData2(m_station, DeviceType::W, m_nValueDev,
|
m_nDataType == __INT16 ? 2 : 4, szBuffer);
|
if (0 != nRet) {
|
return -1;
|
}
|
|
if (m_nDataType == __INT16) {
|
m_nValue = (unsigned int)CToolUnits::toInt16(&szBuffer[0]);
|
}
|
else {
|
m_nValue = (unsigned int)CToolUnits::toInt32(&szBuffer[0]);
|
}
|
|
LOGI("<CEqReadIntStep-%s>Value Changed<Dev:%d, Value:%d>\n",
|
m_strName.c_str(), m_nValueDev, m_nValue);
|
|
return 0;
|
}
|
|
int CEqReadIntStep::onComplete()
|
{
|
CReadStep::onComplete();
|
LOGI("<CEqReadIntStep> onComplete.");
|
|
return 0;
|
}
|
|
int CEqReadIntStep::onTimeout()
|
{
|
CReadStep::onTimeout();
|
LOGE("<CEqReadIntStep> onTimeout.");
|
|
return 0;
|
}
|
|
int CEqReadIntStep::getValue()
|
{
|
return m_nValue;
|
}
|
}
|