Darker
2025-02-27 2633facbfec13267389edde5c29d6e66645c2356
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#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) {
            return -1;
        }
 
        unsigned int unitId = (unsigned int)CToolUnits::toInt16(&szBuffer[0]);
        if (unitId >= STATUS_MAX) {
            return -2;
        }
 
        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]);
        }
 
        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;
    }
}