chenluhua1980
2025-12-10 edf3800e843780e0c6684a6b78f6bf93b4bbcde6
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
#include "stdafx.h"
#include "CEqCassetteTransferStateStep.h"
#include "Log.h"
#include "Common.h"
 
 
namespace SERVO {
    CEqCassetteTransferStateStep::CEqCassetteTransferStateStep()
    {
        m_nPortStatusDev = 0;
        m_nPortStatus = 0;
        m_nCassetteSequenceNo = 0;
        m_nLoadingCassetteType = 0;
        m_nQTimeFlag = 0;
        m_nCassetteMappingState = 0;
        m_nCassetteStatus = 0;
    }
 
    CEqCassetteTransferStateStep::~CEqCassetteTransferStateStep()
    {
 
    }
 
    void CEqCassetteTransferStateStep::getAttributeVector(CAttributeVector& attrubutes)
    {
        CReadStep::getAttributeVector(attrubutes);
 
        unsigned int weight = 31;
        std::string strTemp;
        attrubutes.addAttribute(new CAttribute("Dev",
            ("W" + CToolUnits::toHexString(m_nPortStatusDev, strTemp)).c_str(), "", weight++));
        attrubutes.addAttribute(new CAttribute("Port Status",
            getPortStatusDescription(strTemp).c_str(), "", weight++));
        attrubutes.addAttribute(new CAttribute("CassetteSequenceNo",
            std::to_string(m_nCassetteSequenceNo).c_str(), "", weight++));
        attrubutes.addAttribute(new CAttribute("CassetteID",
            m_strCassetteID.c_str(), "", weight++));
        attrubutes.addAttribute(new CAttribute("LoadingCassetteType",
            getLoadingCassetteTypeDescription(strTemp).c_str(), "", weight++));
        attrubutes.addAttribute(new CAttribute("Q-Time Flag",
            getQTimeFlagDescription(strTemp).c_str(), "", weight++));
        attrubutes.addAttribute(new CAttribute("CassetteMappingState",
            getCassetteMappingStateDescription(strTemp).c_str(), "", weight++));
        attrubutes.addAttribute(new CAttribute("CassetteStatus",
            getCassetteStatusDescription(strTemp).c_str(), "", weight++));
    }
 
    int CEqCassetteTransferStateStep::onReadData()
    {
        CReadStep::onReadData();
 
 
        char szBuffer[64];
        int nRet = m_pCclink->ReadData2(m_station, DeviceType::W, m_nPortStatusDev,
            64, szBuffer);
        if (0 != nRet) {
            return -1;
        }
 
 
        // Port status£¬
        // ×¢£ºÒ²¿ÉÒÔ¸ù¾Ým_nSignalTypeµÄÖµÀ´ÅжÏ״ֵ̬
        m_nPortStatus = (unsigned int)CToolUnits::toInt16(&szBuffer[0]);
 
 
        // CassetteÐòºÅ¡¢ID
        m_nCassetteSequenceNo = (unsigned int)CToolUnits::toInt16(&szBuffer[2]);
        convertString(&szBuffer[4], 20, m_strCassetteID);
 
 
        // Job Existence Slot
        if (PORT_INUSE == m_nPortStatus) {
 
        }
 
 
        // Q-Time
        if (PORT_UNLOAD_READY == m_nPortStatus) {
            m_nQTimeFlag = (unsigned int)CToolUnits::toInt16(&szBuffer[50]);
        }
 
        // ÆäËü
        m_nCassetteMappingState = (unsigned int)CToolUnits::toInt16(&szBuffer[52]);
        m_nCassetteStatus = (unsigned int)CToolUnits::toInt16(&szBuffer[54]);
        if (m_nCassetteStatus > 1) {
            m_nLoadingCassetteType = (unsigned int)CToolUnits::toInt16(&szBuffer[48]);
        }
 
 
        LOGI("<CCassetteTranserStateStep>Port status changed<Dev:%d, Status:%d, CassetteSequenceNo:%d>",
            m_nPortStatusDev, m_nPortStatus, m_nCassetteSequenceNo);
 
        return 0;
    }
 
    int CEqCassetteTransferStateStep::onComplete()
    {
        CReadStep::onComplete();
        LOGI("<CCassetteTranserStateStep> onComplete.");
 
        return 0;
    }
 
    int CEqCassetteTransferStateStep::onTimeout()
    {
        CReadStep::onTimeout();
        LOGI("<CCassetteTranserStateStep> onTimeout.");
 
        return 0;
    }
 
    void CEqCassetteTransferStateStep::setPortStatusDev(int nDev)
    {
        m_nPortStatusDev = nDev;
    }
 
    int CEqCassetteTransferStateStep::getPortStatus()
    {
        return m_nPortStatus;
    }
 
    int CEqCassetteTransferStateStep::getCassetteSequenceNo()
    {
        return m_nCassetteSequenceNo;
    }
 
    std::string& CEqCassetteTransferStateStep::getCassetteID()
    {
        return m_strCassetteID;
    }
 
    int CEqCassetteTransferStateStep::getLoadingCassetteType()
    {
        return m_nLoadingCassetteType;
    }
 
    int CEqCassetteTransferStateStep::getQTimeFlag()
    {
        return m_nQTimeFlag;
    }
 
    int CEqCassetteTransferStateStep::getCassetteMappingState()
    {
        return m_nCassetteMappingState;
    }
 
    int CEqCassetteTransferStateStep::getCassetteStatus()
    {
        return m_nCassetteStatus;
    }
 
    /*
     1: Load Ready(Load Request)
     2: Loaded
     3: In Use (Load Complete)
     4: Unload Ready (Unload Request)
     5: Empty (Unload Complete)
     6: Blocked
     */
    std::string& CEqCassetteTransferStateStep::getPortStatusDescription(std::string& strDescription)
    {
        switch (m_nPortStatus) {
        case PORT_LOAD_READY:
            strDescription = _T("Load Ready(Load Request)");
            break;
        case PORT_LOADED:
            strDescription = _T("Loaded");
            break;
        case PORT_INUSE:
            strDescription = _T("In Use (Load Complete)");
            break;
        case PORT_UNLOAD_READY:
            strDescription = _T("Unload Ready (Unload Request)");
            break;
        case PORT_EMPTY:
            strDescription = _T("Empty (Unload Complete)");
            break;
        case PORT_BLOCKED:
            strDescription = _T("Blocked");
            break;
        default:
            strDescription = _T("");
            break;
        }
 
        return strDescription;
    }
 
    /*
     1: Actual Cassette
     2: Empty Cassette
        *Include this item only when cassette exists
     */
    std::string& CEqCassetteTransferStateStep::getLoadingCassetteTypeDescription(std::string& strDescription)
    {
        switch (m_nLoadingCassetteType) {
        case PORT_LOADING_CASSETTE_ACTUAL:
            strDescription = _T("Actual Cassette");
            break;
        case PORT_LOADING_CASSETTE_EMPTY:
            strDescription = _T("Empty Cassette");
            break;
        default:
            strDescription = _T("");
            break;
        }
 
        return strDescription;
    }
 
    /*
     1: Normal Un-loading
     2: Q-Time Over & Un-loading
       * Include this item only when Port Status is 'Unload Ready'
     */
    std::string& CEqCassetteTransferStateStep::getQTimeFlagDescription(std::string& strDescription)
    {
        switch (m_nQTimeFlag) {
        case Q_TIME_NORMAL:
            strDescription = _T("Normal Un-loading");
            break;
        case Q_TIME_OVER:
            strDescription = _T("Q-Time Over & Un-loading");
            break;
        default:
            strDescription = _T("");
            break;
        }
 
        return strDescription;
    }
 
    /*
     1: mapping use
     2: mapping not use
     */
    std::string& CEqCassetteTransferStateStep::getCassetteMappingStateDescription(std::string& strDescription)
    {
        switch (m_nCassetteMappingState) {
        case CASSETTE_MAPPING_USE:
            strDescription = _T("mapping use");
            break;
        case CASSETTE_MAPPING_NOT_USE:
            strDescription = _T("mapping not use");
            break;
        default:
            strDescription = _T("");
            break;
        }
 
        return strDescription;
    }
 
    /*
     1: No Cassette Exist
     2: Waiting for Cassette Data
     3: Waiting for Start Command
     4: Waiting for Processing
     5: In Processing
     6: Process Paused
     7: Process Completed
     */
    std::string& CEqCassetteTransferStateStep::getCassetteStatusDescription(std::string& strDescription)
    {
        switch (m_nCassetteStatus) {
        case CASSETTE_NO_EXIST:
            strDescription = _T("No Cassette Exist");
            break;
        case CASSETTE_WAITING_DATA:
            strDescription = _T("Waiting for Cassette Data");
            break;
        case CASSETTE_WAITING_START:
            strDescription = _T("Waiting for Start Command");
            break;
        case CASSETTE_WAITING_PROCCESSING:
            strDescription = _T("Waiting for Processing");
            break;
        case CASSETTE_IN_PROCCESSING:
            strDescription = _T("In Processing");
            break;
        case CASSETTE_PROCCESS_PAUSED:
            strDescription = _T("Process Paused");
            break;
        case CASSETTE_PROCCESS_COMPLETED:
            strDescription = _T("Process Completed");
            break;
        default:
            strDescription = _T("");
            break;
        }
 
        return strDescription;
    }
}