chenluhua1980
2 天以前 b099ab8b7c83dc957bd9777a0bb90c1d8202056b
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
#include "stdafx.h"
#include "CArm.h"
 
 
namespace SERVO {
    CArm::CArm() : CEquipment()
    {
    }
 
    CArm::~CArm()
    {
 
    }
 
    const char* CArm::getClassName()
    {
        static char* pszName = "CArm";
        return pszName;
    }
 
    void CArm::init()
    {
        CEquipment::init();
    }
 
    void CArm::term()
    {
        CEquipment::term();
    }
 
    // ±ØÐëҪʵÏÖµÄÐ麯Êý£¬Ôڴ˳õʼ»¯PinÁбí
    void CArm::initPins()
    {
 
    }
 
    // ±ØÐëҪʵÏÖµÄÐ麯Êý£¬Ôڴ˳õʼ»¯SlotÐÅÏ¢
    void CArm::initSlots()
    {
        m_slot[0].enable();
        m_slot[0].setPosition(m_nID);
        m_slot[0].setNo(1);
        m_slot[0].setName("Slot 1(Temp)");
    }
 
    void CArm::onTimer(UINT nTimerid)
    {
        CEquipment::onTimer(nTimerid);
    }
 
    void CArm::serialize(CArchive& ar)
    {
        CEquipment::serialize(ar);
    }
 
    void CArm::getAttributeVector(CAttributeVector& attrubutes)
    {
        __super::getAttributeVector(attrubutes);
    }
 
    int CArm::recvIntent(CPin* pPin, CIntent* pIntent)
    {
        return __super::recvIntent(pPin, pIntent);
    }
 
    int CArm::tempStore(CGlass* pGlass)
    {
        // Ô­£º±£Ö¤ÁбíÖÐÖ»´æ´¢Ò»¸öÎïÁÏ
        // ÐÞ¸ÄΪ£ºÏÈÇå¿Õ֮ǰµÄ£¬ÔÙÌí¼Óµ±Ç°pGlass
        Lock();
        CGlass* pPreviousGlass;
        pPreviousGlass = (CGlass*)m_slot[0].getContext();
        if (pPreviousGlass != nullptr) {
            LOGE("<CArm>tempStore, overwrite previous glass: %s (%d,%d)",
                pPreviousGlass->getID().c_str(),
                pPreviousGlass->getCassetteSequenceNo(),
                pPreviousGlass->getJobSequenceNo());
            pPreviousGlass->release();
        }
        m_slot[0].setContext(pGlass);
        Unlock();
 
        if (pGlass != nullptr) {
            LOGI("<CArm>tempStore: GlassId:%s, Cassette:%d, Job:%d",
                pGlass->getID().c_str(),
                pGlass->getCassetteSequenceNo(),
                pGlass->getJobSequenceNo());
        }
 
        if (m_listener.onDataChanged != nullptr) {
            m_listener.onDataChanged(this, 0);
        }
 
        return 0;
    }
 
    int CArm::tempFetchOut(OUT CGlass*& pGlass)
    {
        Lock();
        CGlass* pPreviousGlass = (CGlass*)m_slot[0].getContext();
        if (pPreviousGlass == nullptr) {
            Unlock();
            LOGE("<CArm>tempFetchOut failed: arm slot empty.");
            return -1;
        }
        pGlass = pPreviousGlass;
        pGlass->addRef();
        m_slot[0].setContext(nullptr);
        Unlock();
 
        LOGI("<CArm>tempFetchOut: GlassId:%s, Cassette:%d, Job:%d",
            pGlass->getID().c_str(),
            pGlass->getCassetteSequenceNo(),
            pGlass->getJobSequenceNo());
 
        if (m_listener.onDataChanged != nullptr) {
            m_listener.onDataChanged(this, 0);
        }
 
        return 0;
    }
 
    int CArm::glassUpdateJobDataS(CJobDataS* pJobDataS)
    {
        ASSERT(pJobDataS);
 
        Lock();
        CGlass* pGlass = (CGlass*)m_slot[0].getContext();
        if (pGlass == nullptr) {
            Unlock();
            LOGE("<CArm>glassUpdateJobDataSʧ°Ü£¬ÕÒ²»µ½¶ÔÓ¦µÄGlass");
            return -1;
        }
 
        CJobDataS* pSrcJs = pGlass->getJobDataS();
        if (pSrcJs->getCassetteSequenceNo() != pJobDataS->getCassetteSequenceNo()
            || pSrcJs->getJobSequenceNo() != pJobDataS->getJobSequenceNo()) {
            Unlock();
            LOGE("<CArm>glassUpdateJobDataSʧ°Ü£¬CassetteNo²»Æ¥Åä([%d,%d] != [%d,%d])",
                pSrcJs->getCassetteSequenceNo(),
                pJobDataS->getCassetteSequenceNo(),
                pSrcJs->getJobSequenceNo(),
                pJobDataS->getJobSequenceNo());
            return -2;
        }
 
        pGlass->updateJobDataS(pJobDataS);
        Unlock();
        return 0;
    }
}