SDC C-Project CF Review 프로그램
LYW
2021-07-29 bd13fa3f9396f1f681759f4623c55d5f91d74a9c
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
#pragma once
 
#include "MotorControlInfo.h"
#include "CHThreadPools/TimerThreadPools.h"
#include "MotionThread.h"
 
#include <vector>
typedef std::vector<long>                VectorLong;
typedef std::vector<long>::iterator        VectorLongIt;
typedef std::vector<int>                VectorInteger;
typedef std::vector<int>::iterator        VectorIntegerIt;
// typedef std::vector<double>                VectorDouble;
// typedef std::vector<double>::iterator    VectorDoubleIt;
 
 
class AFX_EXT_CLASS  CMotorControl : public CTimerThreadPools, public IMotionThread2Parent
{
public:
    CMotorControl(int nIndex, DWORD dwPeriod=100,int nThreadCount = 1);
    virtual ~CMotorControl(void);
    void SetMC2P(IMotorControl2Parent* pMC2P)                        { m_pMC2P = pMC2P; }
    BOOL GetConnected()    const                                        { return m_bConnected; }
    const CMotorControlInfo* GetControlInfo()                        { return &m_ControlInfo; }
 
    virtual BOOL StartThread();
    virtual void StopThread();
    virtual void TimerThreadProcess(PVOID pParameter);
 
public:
    // CMotorControl
    virtual int        Connect(const CMotorControlInfo* pControlInfo) = 0;
    virtual void    Disconnect() = 0;
    virtual BOOL    ReadAddressValue(int nAddress, long &nValue) = 0;
    virtual BOOL    WriteAddressValue(int nAddress, long nValue) = 0;
    virtual BOOL    ReadAddressValue(int nAddress, float &fValue) = 0;
    virtual BOOL    WriteAddressValue(int nAddress, float fValue) = 0;
    virtual BOOL    ReadAddressValue(int nAddress, double &dValue) = 0;
    virtual BOOL    WriteAddressValue(int nAddress, double dValue) = 0;
 
protected:
    virtual BOOL    ReadAddressValue(long nAddress, long *pArrayData, int nArrayCount) = 0;
    virtual BOOL    WriteAddressValue(long nAddress, long *pArrayData, int nArrayCount) = 0;
    virtual BOOL    ReadAddressValue(long nAddress, float *pArrayData, int nArrayCount) = 0;
    virtual BOOL    WriteAddressValue(long nAddress, float *pArrayData, int nArrayCount) = 0;
 
protected:
    virtual BOOL    ReadAxisPosition(float *pAxisPos, int nAxisCount);
    virtual BOOL    ReadAxisStatus(long *pAxisStatus, int nAxisCount);
    virtual BOOL    ReadThetaAxisPosition( float& fAxisPos);
    virtual BOOL    ReadThetaAxisStatus(long& nAxisStatus);
 
public:
    // common
    virtual BOOL    CommonSetAutoStop();
 
    // axis
    virtual BOOL    AxisManualGo(int nAxisIdx, double dPosition);
    virtual BOOL    AxisJogPlus(int nAxisIdx);
    virtual BOOL    AxisJogMinus(int nAxisIdx);
    virtual BOOL    AxisJogStop(int nAxisIdx);
    virtual BOOL    AxisManualGoSpeed(int nAxisIdx, double dSpeed);
    virtual BOOL    AxisJogSpeed(int nAxisIdx, double dSpeed);
    virtual BOOL    AxisManualGoAccel(int nAxisIdx, int nAccel);
 
    // gantry
    virtual BOOL    GantryManualGo(int nGantryIdx, const VectorDouble& vectorPos);
    virtual BOOL    GantryManualGo(int nGantryIdx, const VectorDouble& vectorPos, int nMoveType);
    virtual BOOL    GantryManualGo(int nGantryIdx, double dPosX, double dPosY);
 
    // review
    virtual BOOL    GantryAutoGo(int nGantryIdx, const VectorDouble& vectorPosX, const VectorDouble& vectorPosY, BOOL bCommand=FALSE);
    
    //Wsi
    virtual BOOL    GantryWsiAutoGo(int nGantryIdx, const VectorDouble& vectorPosX, const VectorDouble& vectorPosY, BOOL bCommand=FALSE);
    
    // get status
    virtual int        GetStatus( int& nStatusCode, CString& strStatusMessage );
 
 
public:
    // common
    BOOL    CommonSetAfDelayTime(long nTime = 0);
    BOOL    CommonSetImageDelayTime(long nTime = 0);
    BOOL    CommonSetWsiDelayTime(long nTime = 0);
    BOOL    CommonSetAutoGoAll();
    BOOL    CommonSetAutoMeasureGoAll();
    BOOL    CommonSetAutoWsiGoAll();
    
    void    SetUseWsi(BOOL bUse)        { m_bUseWsi = bUse; }        
 
    // all axis 
    BOOL    AxisJogStop();
    BOOL    AxisManualGoSpeed(double dSpeed);
    BOOL    AxisJogSpeed(double dSpeed);
    BOOL    AxisManualGoAccel(int nAccel);
    BOOL    IsAxisMotionEnd();
 
    BOOL    AxisManualGoEnd(int nAxisIdx, double dPosition);
    BOOL    AxisManualGo(const VectorInteger& vectorAxis, const VectorDouble& vectorPosition);
    BOOL    IsAxisMotionEnd(int nAxisIdx);
 
    // axis theta
    virtual BOOL    AxisThetaManualGo(double dPosition);
    virtual BOOL    AxisThetaJogPlus();
    virtual BOOL    AxisThetaJogMinus();
    virtual BOOL    AxisThetaJogStop();
 
    BOOL    AxisThetaManualGoEnd(double dPosition);
    BOOL    AxisThetaManualGoSpeed(double dSpeed);
    BOOL    AxisThetaJogSpeed(double dSpeed);
    BOOL    AxisThetaManualGoAccel(int nAccel);
    BOOL    IsAxisThetaMotionEnd();
 
    // gantry
    BOOL    GantryManualGoEnd(int nGantryIdx, const VectorDouble& vectorPos);
    BOOL    GantryManualGoEnd(int nGantryIdx, const VectorDouble& vectorPos, int nMoveType);
    BOOL    GantryManualGoEnd(int nGantryIdx, double dPosX, double dPosY);
    BOOL    GantrySetCollisionPosition(int nGantryIdx, double dPosX, double dPosY,int nFirstIn=1);
    const int    GetGantryCollisionXAddr(int nGantryIdx);
    BOOL    GantrySetTwoGantrySyncModeSend(bool bUse);
 
    // review 
    BOOL    GantryAutoGo(int nGantryIdx);
    BOOL    GantrySetMoveCount(int nGantryIdx, long nCount);
    BOOL    GantryGetMoveCount(int nGantryIdx, long& nCount);
    BOOL    GantryGetTriggerCount(int nGantryIdx, long& nCount);
 
    // measure
    BOOL    GantryMeasureAutoGo(int nGantryIdx, const VectorDouble& vectorPosData, BOOL bCommand=FALSE);
    BOOL    GantryMeasureAutoGo(int nGantryIdx);
    BOOL    GantrySetMeasureMoveCount(int nGantryIdx, long nCount);
    BOOL    GantryGetMeasureMoveCount(int nGantryIdx, long& nCount);
    BOOL    GantryGetMeasureTriggerCount(int nGantryIdx, long& nCount);
 
    // wsi 
    BOOL    GantryWsiAutoGo(int nGantryIdx);
    BOOL    GantrySetWsiMoveCount(int nGantryIdx, long nCount);
    BOOL    GantryGetWsiMoveCount(int nGantryIdx, long& nCount);
    BOOL    GantryGetWsiTriggerCount(int nGantryIdx, long& nCount);
    BOOL    GantryWsiNextPosMove(int nGantryIdx, long nNextIdx);
 
    // Software Trigger Command
    BOOL    SoftWareTriggerCmd(int nGantryIdx, long lCmd);
 
    // Command Ack 
    BOOL    AxisThetaManualGoAck(long &lAck); 
    BOOL    AxisThetaManualGoAck(long &lAck, DWORD nWaitTime);
    BOOL    GantryManualGoAck(int nGantryIdx, long &lAck); 
    BOOL    GantryManualGoAck(int nGantryIdx, long &lAck, DWORD nWaitTime); 
    BOOL    GantryAutoGoAck(int nGantryIdx, long& lAck);
    BOOL    GantryAutoGoAck(int nGantryIdx, long& lAck, DWORD nWaitTime);    
    BOOL    GantryMeasureAutoGoAck(int nGantryIdx, long &lAck); 
    BOOL    GantryMeasureAutoGoAck(int nGantryIdx, long &lAck, DWORD nWaitTime);
    BOOL    GantryWsiAutoGoAck(int nGantryIdx, long &lAck);    
    BOOL    GantryWsiAutoGoAck(int nGantryIdx, long &lAck, DWORD nWaitTime);
 
    BOOL    IsGantryMotionEnd(int nGantryIdx);
    BOOL    IsMotionEnd();
 
    BOOL    RemoveAllAutoGoCount(int nGantryIdx);
 
    BOOL    GetAxisLimitPosition(int nAxisIdx, double& dPlusLimit, double& dMinusLimit);
 
 
protected:
    virtual void    Process_AxisMotionEnd(const CMotionData& motionData);
    virtual void    Process_GantryMotionEnd(const CMotionData& motionData);
    virtual void    Process_ThetaMotionEnd(const CMotionData& motionData);
 
    // axis
    int        GetAxisGantryIndex(int nAxisIdx);
    int        GetAxisPositionAddr(int nAxisIdx);
    int        GetAxisStatusAddr(int nAxisIdx);
    int        GetAxisGoPositionAddr(int nAxisIdx);
    int        GetAxisGoPositionCommonAddr(int nAxisIdx);
    int        GetAxisJogCommandAddr(int nAxisIdx);
    int        GetAxisManualGoSpeedAddr(int nAxisIdx);
    int        GetAxisManualGoAccelAddr(int nAxisIdx);
    int        GetAxisJogSpeedAddr(int nAxisIdx);
 
    // theta axis
    int        GetAxisThetaPositionAddr();
    int        GetAxisThetaStatusAddr();
    int        GetAxisThetaGoPositionAddr();
    int        GetAxisThetaJogCommandAddr();
    int        GetAxisThetaManualGoAddr();
    int        GetAxisThetaManualGoAckAddr();
    int        GetAxisThetaManualGoSpeedAddr();
    int        GetAxisThetaManualGoAccelAddr();
    int        GetAxisThetaJogSpeedAddr();
    int        GetAxisThetaJogAccelAddr();
 
    // gantry
    int        GetGantryAxisCount(int nGantryIdx);
    int        GetGantryManualGoAddr(int nGantryIdx);
    int        GetGantryManualGoAckAddr(int nGantryIdx);
    int        GetGantryCollisionPositionXAddr(int nGantryIdx);
    int        GetGantryCollisionPositionYAddr(int nGantryIdx);
 
 
    int        GetGantryAutoGoAddr(int nGantryIdx);
    int        GetGantryAutoGoAckAddr(int nGantryIdx);
    int        GetGantryMoveCountAddr(int nGantryIdx);
    int        GetGantryTriggerCountAddr(int nGantryIdx);
 
    int        GetGantryMeasureAutoGoAddr(int nGantryIdx);
    int        GetGantryMeasureAutoGoAckAddr(int nGantryIdx);
    int        GetGantryMeasureMoveCountAddr(int nGantryIdx);
    int        GetGantryMeasureTriggerCountAddr(int nGantryIdx);
 
    int        GetGantryWsiAutoGoAddr(int nGantryIdx);
    int        GetGantryWsiAutoGoAckAddr(int nGantryIdx);
    int        GetGantryWsiMoveCountAddr(int nGantryIdx);
    int        GetGantryWsiTriggerCountAddr(int nGantryIdx);
    int        GetGantryWsiMotionEndAddr(int nGantryIdx);
    int        GetGantryWsiNextPosMoveAddr(int nGantryIdx);
 
    // Software Trigger Address
    int        GetSoftwareTriggerAddr(int nGantryIdx);
    int        GetSoftwareTriggerCmdAddr(int nGantryIdx);
    int        GetImageSnapCompleteAddr(int nGantryIdx);
 
    static BOOL    TransformIP_CStringToDWORD(const CString& strServerIP, DWORD& dwServerIP);
 
    BOOL    GetUseWsi()        { return m_bUseWsi; }
    
public:
    virtual void IMT2P_RunThreadProcess(const CMotionData& motionData);
 
protected:
 
 
protected:
    IMotorControl2Parent*    m_pMC2P;
    CMotorControlInfo        m_ControlInfo;
    CMotionThread*            m_pMotionThread;
 
protected:
    int                        m_nIndex;
    DWORD                    m_dwPeriod;
    BOOL                    m_bConnected;
 
    // var
    int                        m_nAxisCount;
 
    long                    *m_pAxisStatus;
    float                    *m_pAxisPosition;
    long                    *m_pAxisStatusPrev;
    float                    *m_pAxisPositionPrev;
 
    long                    *m_pAxisStatusAddr;
    long                    *m_pAxisPositionAddr;
 
    //  axis theta
    long                    m_axisThetaStatus;
    long                    m_axisThetaStatusPrev;
    float                    m_axisThetaPosition;
    float                    m_axisThetaPositionPrev;
 
    // review enable
    long                    m_nAutoEnable;
    long                    m_nAutoEnablePrev;
 
    // wsi signal
    long                    m_nWsiMotionEndPrev;
    BOOL                    m_bUseWsi;
    bool                    m_nWsiMotionEndPrev2;
};