LAPTOP-SNT8I5JK\Boounion
2025-08-21 ba50ece48a4b95563031f1dacffd3e04f89d952f
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
#include "stdafx.h"
#include "CGlass.h"
 
 
namespace SERVO {
    CGlass::CGlass()
    {
        m_pPath = nullptr;
        m_type = MaterialsType::G1;
        m_pBuddy = nullptr;
        m_nOriginPort = 0;
        m_nOriginSlot = 0;
        m_bScheduledForProcessing = FALSE;
    }
 
    CGlass::~CGlass()
    {
 
    }
 
    void CGlass::reset()
    {
        CPath* pPath = m_pPath;
        while (pPath != nullptr) {
            CPath* pTemp = pPath->getNext();
            delete pPath;
            pPath = pTemp;
        }
        m_pPath = nullptr;
 
        if (m_pBuddy != nullptr) {
            m_pBuddy->release();
        }
    }
 
    std::string& CGlass::getClassName()
    {
        static std::string strName = "CGlass";
        return strName;
    }
 
    std::string CGlass::toString()
    {
        std::string strText;
        strText += "CGlass[";
        strText += ("ID:" + m_strID + ";");
        strText += "]";
 
        return strText;
    }
 
    MaterialsType CGlass::getType()
    {
        return m_type;
    }
 
    void CGlass::setType(MaterialsType type)
    {
        m_type = type;
    }
 
    void CGlass::setID(const char* pszID)
    {
        m_strID = pszID;
    }
 
    std::string& CGlass::getID()
    {
        return m_strID;
    }
 
    void CGlass::setOriginPort(int port, int slot)
    {
        m_nOriginPort = port;
        m_nOriginSlot = slot;
    }
 
    void CGlass::getOrginPort(int& port, int& slot)
    {
        port = m_nOriginPort;
        slot = m_nOriginSlot;
    }
 
    BOOL CGlass::isScheduledForProcessing()
    {
        return m_bScheduledForProcessing;
    }
    
    void CGlass::setScheduledForProcessing(BOOL bProcessing)
    {
        m_bScheduledForProcessing = bProcessing;
    }
 
    CPath* CGlass::getPath()
    {
        return m_pPath;
    }
 
    CPath* CGlass::getPathWithEq(unsigned int nEqId, unsigned int nUnit)
    {
        CPath* pTemp = m_pPath;
        while (pTemp != nullptr) {
            if (pTemp->getEqID() == nEqId && pTemp->getUnit() == nUnit) {
                return pTemp;
            }
 
            pTemp = pTemp->getNext();
        }
 
        return nullptr;
    }
 
    void CGlass::addPath(unsigned int nEqId, unsigned int nUnit)
    {
        CPath* pPath = new CPath(nEqId, nUnit);
        if (m_pPath == nullptr) {
            m_pPath = pPath;
        }
        else {
            m_pPath->addPath(pPath);
        }
    }
 
    void CGlass::serialize(CArchive& ar)
    {
        if (ar.IsStoring())
        {
            Lock();
            ar << (int)m_type;
            WriteString(ar, m_strID);
            ar << m_nOriginPort;
            ar << m_nOriginSlot;
            ar << m_bScheduledForProcessing;
            ar << (ULONGLONG)m_pPath;
            if (m_pPath != nullptr) {
                m_pPath->serialize(ar);
            }
            char temp[JOBDATAS_SIZE] = { 0 };
            m_jobDataS.serialize(temp, JOBDATAS_SIZE);
            ar.Write(temp, JOBDATAS_SIZE);
            ar << (ULONGLONG)m_pBuddy;
            WriteString(ar, m_strBuddyId);
            Unlock();
        }
        else
        {
            ULONGLONG ullPath;
            int type;
 
            Lock();
            ar >> type;
            m_type = (MaterialsType)type;
            ReadString(ar, m_strID);
            ar >> m_nOriginPort;
            ar >> m_nOriginSlot;
            ar >> m_bScheduledForProcessing;
            ar >> ullPath;
            if (ullPath != 0) {
                m_pPath = new CPath();
                m_pPath->serialize(ar);
            }
            char temp[JOBDATAS_SIZE];
            ar.Read(temp, JOBDATAS_SIZE);
            m_jobDataS.unserialize(temp, JOBDATAS_SIZE);
            ar >> ullPath;    m_pBuddy = (CGlass*)ullPath;
            ReadString(ar, m_strBuddyId);
            Unlock();
        }
    }
 
    void CGlass::setJobDataS(CJobDataS* pJobDataS)
    {
        m_jobDataS.copy(pJobDataS);
    }
 
    void CGlass::updateJobDataS(CJobDataS* pJobDataS)
    {
        m_jobDataS.update(pJobDataS);
    }
 
    CJobDataS* CGlass::getJobDataS()
    {
        return &m_jobDataS;
    }
 
    BOOL CGlass::setBuddy(CGlass* pGlass)
    {
        if (m_pBuddy != nullptr) return FALSE;
        if (pGlass->getType() == this->getType()) return FALSE;
        m_pBuddy = pGlass;
        m_pBuddy->addRef();
        m_strBuddyId = m_pBuddy->getID();
 
        return TRUE;
    }
 
    BOOL CGlass::forceSetBuddy(CGlass* pGlass)
    {
        m_pBuddy = pGlass;
        m_pBuddy->addRef();
        m_strBuddyId = m_pBuddy->getID();
 
        return TRUE;
    }
 
    CGlass* CGlass::getBuddy()
    {
        return m_pBuddy;
    }
 
    std::string& CGlass::getBuddyId()
    {
        return m_strBuddyId;
    }
 
    int CGlass::processEnd(unsigned int nEqId, unsigned int nUnit)
    {
        CPath* pPath = getPathWithEq(nEqId, nUnit);
        if (pPath == nullptr) return -1;
 
        pPath->processEnd();
        return 0;
    }
 
    BOOL CGlass::isProcessed(unsigned int nEqId, unsigned int nUnit)
    {
        CPath* pPath = getPathWithEq(nEqId, nUnit);
        if (pPath == nullptr) return FALSE;
 
        return pPath->isProcessEnd();
    }
 
    int CGlass::setInspResult(unsigned int nEqId, unsigned int nUnit, InspResult result)
    {
        CPath* pPath = getPathWithEq(nEqId, nUnit);
        if (pPath == nullptr) return -1;
            
        pPath->setInspResult(result);
        return 0;
    }
 
    InspResult CGlass::getInspResult(unsigned int nEqId, unsigned int nUnit)
    {
        CPath* pPath = getPathWithEq(nEqId, nUnit);
        if (pPath == nullptr) return InspResult::NotInspected;
 
        return pPath->getInspResult();
    }
}