LAPTOP-SNT8I5JK\Boounion
2025-06-16 fd1333fbf52e00ff8f0b0d51ec0d707a66cc9141
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#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();
        LOGI("<CEqReadIntStep> onTimeout.");
 
        return 0;
    }
 
    int CEqReadIntStep::getValue()
    {
        return m_nValue;
    }
}