SDC C-Project CF Review 프로그램
LYW
2021-07-08 630eb072cca33a7c633f6429a0b5a531d1b83268
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
#pragma once
 
#include <math.h>
#include <vector>
 
enum CurveType                { Curve_Line=0, Curve_SLine };
enum MotionType                { Motion_MaxAxisTime=0, Motion_XAxisTime, Motion_YAxisTime, Motion_XYAxisTime };
enum SchedulePathType        { SchedulePathType_Nomal=0, SchedulePathType_Tsp, SchedulePathType_Sorting_XWay };
enum ScheduleDirType        { SchedulerDir_LeftTop=0, SchedulerDir_RightTop, SchedulerDir_LeftBottom, SchedulerDir_RightBottom };
 
struct SMotionInfo
{
    SMotionInfo() 
    {
        Reset();
    }
 
    void Reset()
    {
        dDistanceStart    = 0.0;    // mm
        dDistanceEnd    = 0.0;    // mm
        dMoveSpeed        = 0.0;    // mm/sec
        dAccelTime        = 0.0;    // ms 
        dDecelTime        = 0.0;    // ms 
        dInpositionTime    = 0.0;    // ms
    }
 
    double GetDurationTime(int nCurve, double dDistance) const
    {
        if (dDistance<=0.0) return 0.0;
 
        double dAccelDist = 0.0;
        double dDecelDist = 0.0;
        double dTotalDistance = 0.0;
 
        double dTime = 0.0;
 
        switch(nCurve)
        {
        case Curve_Line:
            dAccelDist = (dMoveSpeed * (dAccelTime/1000.0)) / 2.0;
            dDecelDist = (dMoveSpeed * (dDecelTime/1000.0)) / 2.0;
 
            dTotalDistance = dDistance - (dAccelDist+dDecelDist);
 
            if (dAccelDist+dDecelDist > dDistance)
            {
                //                 double dTempDist = dDistance * (dAccelTime / (dAccelTime+dDecelTime));
                //                 double dTimeAccel = (dMoveSpeed / (dAccelTime/1000.0)) / 2.0;
                //                 dTimeAccel = sqrt(dTempDist/dTimeAccel) * 1000.0;
                //                 dTempDist = dDistance * (dDecelTime / (dAccelTime+dDecelTime));
                //                 double dTimeDecel = (dMoveSpeed / (dDecelTime/1000.0)) / 2.0;
                //                 dTimeDecel = sqrt(dTempDist/dTimeDecel) * 1000.0;
                //                 dTime = dTimeAccel + dTimeAccel;
 
                dTime = dAccelTime + dDecelTime;
            }
            else
            {
                dTime = dAccelTime + dDecelTime + (dTotalDistance/dMoveSpeed)*1000.0;
            }
            break;
 
        case Curve_SLine:
            dTime = 0.0;
            break;
        }
 
 
        return dTime + dInpositionTime;
    }
 
    double    dDistanceStart;
    double    dDistanceEnd;
 
    double    dMoveSpeed;
    double    dAccelTime;
    double    dDecelTime;
 
    double    dInpositionTime;
};
 
class AFX_EXT_CLASS CMotionParm
{
public:
    CMotionParm(void);
    CMotionParm(const CMotionParm& rhs);
    CMotionParm& operator=(const CMotionParm& rhs);
    virtual ~CMotionParm(void);
    void Reset();
 
    // getter
    int                GetMoveType();
    int                GetCurveType();
    double            GetAutoFocusTime();
    double            GetImageGrabTime();
    double            GetMotionDelayTime();
 
    int                GetMotionInfoCountX();
    int                GetMotionInfoCountY();
    SMotionInfo*    GetMotionInfoX(double dDistance);
    SMotionInfo*    GetMotionInfoY(double dDistance); 
    SMotionInfo*    GetMotionInfoX(int nIndex);
    SMotionInfo*    GetMotionInfoY(int nIndex);
 
    // setter
    void SetMoveType(int nType);
    void SetCurveType(int nType);
    void SetAutoFocusTime(double dTime);
    void SetImageGrabTime(double dTime);
    void SetMotionDelayTime(double dTime);
 
    void SetMotionInfoCountX(int nCount);
    void SetMotionInfoCountY(int nCount);
    bool SetMotionInfoX(int nIndex, const SMotionInfo& motionInfo);
    bool SetMotionInfoY(int nIndex, const SMotionInfo& motionInfo);
 
    static BOOL LoadParm(const CString& strFilename, CMotionParm& scheduleParam);
    static BOOL SaveParm(const CString& strFilename, CMotionParm& scheduleParam);
 
protected:
    int                nMoveType;
    int                nCurveType;
 
    double            dAutoFocusTime;
    double            dImageGrabTime;
    double            dMotionDelayTime;
 
    int                nMotionInfoCountX;
    SMotionInfo*    pMotionInfoX;
 
    int                nMotionInfoCountY;
    SMotionInfo*    pMotionInfoY;
};
 
class AFX_EXT_CLASS CPathSchedulerParm : public CMotionParm
{
public:
    CPathSchedulerParm(void);
    CPathSchedulerParm(const CPathSchedulerParm& rhs);
    CPathSchedulerParm& operator=(const CPathSchedulerParm& rhs);
    virtual ~CPathSchedulerParm(void);
    void Reset()
    {
        CMotionParm::Reset();
        Reset_Glass();
        Reset_Module();
        Reset_Flying();
        Reset_Sorting();
        Reset_Random();
    }
 
    static BOOL LoadParm(const CString& strFilename, CPathSchedulerParm& scheduleParam);
    static BOOL SaveParm(const CString& strFilename, CPathSchedulerParm& scheduleParam);
 
public: //1)ÁÂÇ¥°è Á¤º¸
    void    Reset_Glass()
    {
        bCenterCoord    = 0;    
        nOriginDir        = SchedulerDir_LeftBottom;    
        nGlassSizeX        = 0;    
        nGlassSizeY        = 0;
        nBaseModuleDir    = SchedulerDir_LeftBottom;
    }
    int        GetCenterCoord() const            { return bCenterCoord; }
    int        GetOriginDir() const            { return nOriginDir; }
    int        GetGlassSizeX() const            { return nGlassSizeX; }
    int        GetGlassSizeY() const            { return nGlassSizeY; }
    int        GetBaseModuleDir() const        { return nBaseModuleDir; }
    void    SetCenterCoord(int bValue)        { bCenterCoord = bValue; }
    void    SetOriginDir(int nDir)            { nOriginDir = nDir; }
    void    SetGlassSizeX(int nSize)        { nGlassSizeX = nSize; }
    void    SetGlassSizeY(int nSize)        { nGlassSizeY = nSize; }
    void    SetBaseModuleDir(int nDir)        { nBaseModuleDir = nDir; }
 
protected: //1)ÁÂÇ¥°è Á¤º¸
    int        bCenterCoord;        // ¼¾ÅÍ ÁÂÇ¥°è À¯¹«
    int        nOriginDir;            // ¿øÁ¡¹æÇâ
    int        nGlassSizeX;        // ±Û¶ó½º Å©±â X
    int        nGlassSizeY;        // ±Û¶ó½º Å©±â Y
    int        nBaseModuleDir;        // ±âÁØ ¸ðµâ ¹æÇâ
 
public: //2)¸ðµâ/Ãæµ¹ Á¤º¸
    void    Reset_Module()
    {
        nSelectModuleType = 0;
        nModuleCount    = 4;    
        nCollisionDistX    = 0;    
        nCollisionDistY    = 0;    
        nUseShortPath = 1;
    }
    int        GetModuleCount() const            { return nModuleCount; }
    int        GetCollisionDistX() const        { return nCollisionDistX; }
    int        GetCollisionDistY() const        { return nCollisionDistY; }
    void    SetModuleCount(int nCount)        { nModuleCount = nCount; }
    void    SetCollisionDistX(int nDist)    { nCollisionDistX = nDist; }
    void    SetCollisionDistY(int nDist)    { nCollisionDistY = nDist; }
    int        GetSelectModuleType( ) { return nSelectModuleType;  }
    void    SetSelectModuleType(int nIndex) { nSelectModuleType = nIndex; }
    bool    GetUseShortPath() { return nUseShortPath; }
    void    SetUseShortPath(bool nIndex) { nUseShortPath = nIndex; }
 
protected: //2)¸ðµâ/Ãæµ¹ Á¤º¸
    int        nModuleCount;        // Çì´õÀÇ °³¼ö
    int        nCollisionDistX;    // XÃà Ãæµ¹°Å¸®
    int        nCollisionDistY;    // YÃà Ãæµ¹°Å¸®
    int        nSelectModuleType; //Ãà Çϳª¸¸ ÁøÇàÇÒ¶§
    bool        nUseShortPath;
 
 
public: //3)ÇöóÀ× ¸®ºä
    void                Reset_Flying()
    {
        // for flying 
        nScanCount                            = 2;
        nScanMargin                            = 5000;
        sScanMotionInfo.dMoveSpeed            = 19.0;
        sScanMotionInfo.dAccelTime            = 0;
        sScanMotionInfo.dDecelTime            = 0;
 
        sModuleMotionInfo.dMoveSpeed        = 1000;
        sModuleMotionInfo.dAccelTime        = 0.068;
        sModuleMotionInfo.dDecelTime        = 0.068;
        sModuleMotionInfo.dInpositionTime    = 0.1;
    }
    int                    GetScanCount() const                            { return nScanCount; }
    int                    GetScanMargin() const                            { return nScanMargin; }
    SMotionInfo*        GetScanMotionInfo()                                { return &sScanMotionInfo; }
    SMotionInfo*        GetModuleMotionInfo()                            { return &sModuleMotionInfo; }
    const SMotionInfo*    GetScanMotionInfo() const                        { return &sScanMotionInfo; }
    const SMotionInfo*    GetModuleMotionInfo() const                        { return &sModuleMotionInfo; }
    void                SetScanCount(int nCount)                        { nScanCount = nCount; }
    void                SetScanMargin(int nMargin)                        { nScanMargin = nMargin; }
    void                SetScanMotionInfo(const SMotionInfo& sInfo)        { sScanMotionInfo = sInfo; }
    void                SetModuleMotionInfo(const SMotionInfo& sInfo)    { sModuleMotionInfo = sInfo; }
 
protected: //3)ÇöóÀ× ¸®ºä
    int                nScanCount;            // ½ºÄµ ¼ö
    int                nScanMargin;        // ½ºÄµ ¸¶Áø
    SMotionInfo        sScanMotionInfo;    // ½ºÄµ ¸ðÅÍ »ç¾ç
    SMotionInfo        sModuleMotionInfo;    // ¸ðµâ ¸ðÅÍ »ç¾ç
 
public: //4)Ãà ¼ÒÆÃ Á¤º¸
    void    Reset_Sorting()
    {
        nSortAxisType = 0;
        nSortOrderType = 0;
    }
    int        GetSortAxisType() const            { return nSortAxisType; }
    int        GetSortOrderType() const        { return nSortOrderType; }
    void    SetSortAxisType(int nType)        { nSortAxisType = nType; }
    void    SetSortOrderType(int nType)        { nSortOrderType = nType; }
 
protected: //4)Ãà ¼ÒÆÃÁ¤º¸
    int        nSortAxisType;
    int        nSortOrderType;
 
public:        //5)·£´ý ÇöóÀÌ Á¤º¸
    void    Reset_Random()
    {
        dRandomScale = 5.0;
    }
    double    GetRandomScale() const            { return dRandomScale; }
    void    SetRandomScale(double dScale)    { dRandomScale = dScale; }
 
protected:    //5)·£´ý ÇöóÀÌ Á¤º¸
    double    dRandomScale;
 
};
 
 
struct SRangeData
{
    SRangeData()
    {
        nModuleIdx        = 0;
        nScanIdx        = 0;
        nScanDir        = 1;
        nScanStartX        = 0;
        nScanEndX        = 0;
 
        nLeft        = 0;
        nTop        = 0;
        nRight        = 0;
        nBottom        = 0;
 
        nColliPosX    = -1;
        nColliPosY    = -1;
    }
 
    int nModuleIdx;        // module index
    int nScanIdx;        // scan index
    int nScanDir;        // scan dir 0/1
 
    int nScanStartX;    // scan start x
    int nScanEndX;        // scan end x
 
    int nLeft;            // range left
    int nTop;            // range top
    int nRight;            // range right
    int nBottom;        // range bottom
 
    int nColliPosX;
    int nColliPosY;
};
 
typedef std::vector<SRangeData>                    VectorRangeData;
typedef std::vector<SRangeData>::iterator        VectorRangeDataIt;
typedef std::vector<SRangeData>::const_iterator    constVectorRangeDataIt;
 
 
inline void swap_value(int& nValue1, int& nValue2)
{
    int nTmp = nValue1;
    nValue1 = nValue2;
    nValue2 = nTmp;
}