SDC C-Project CF Review 프로그램
LYW
2022-05-31 f1a543772246f59b8b52a8857270b38ee38f3588
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
 
 
#include "StdAfx.h"
#include "PathScheduler_Dual_Flying_Random.h"
 
 
CPathScheduler_Dual_Flying_Random::CPathScheduler_Dual_Flying_Random(void)
{
    m_vecPathData_Random.clear();
}
 
 
CPathScheduler_Dual_Flying_Random::~CPathScheduler_Dual_Flying_Random(void)
{
    m_vecPathData_Random.clear();
}
 
int CPathScheduler_Dual_Flying_Random::PathScheduling( const VectorPathData& vecPathData, const VectorPathData& vecStartPath )
{
    // random data
    CreatePathData_Random((int)vecPathData.size());
 
    m_vecRangeRect.clear();
    m_vecScanRangeData.clear();
    m_vecPathSchedulerResult.clear();
 
    int nGantryCount = 2;
 
    int nRangeCount = CalculateRangeRect(
        nGantryCount, 
        m_PathSchedulerParam.GetModuleCount(), 
        m_PathSchedulerParam.GetScanCount(), 
        m_PathSchedulerParam.GetGlassSizeX(),
        m_PathSchedulerParam.GetGlassSizeY(),
        m_PathSchedulerParam.GetScanMargin(),
        m_PathSchedulerParam.GetOriginDir(),
        m_PathSchedulerParam.GetBaseModuleDir(),
        m_vecScanRangeData);
 
    if (nRangeCount<1) return 0;
 
    int nTotalCount = 0;
    SPathData sStartPath; // ¸ðµâº° ½ºÄµ ½ÃÀÛÀ§Ä¡ ÀúÀå.
    for (int nModuleIdx=0; nModuleIdx<m_PathSchedulerParam.GetModuleCount(); nModuleIdx++)
    {
        for (int nScanIdx = 0; nScanIdx<m_PathSchedulerParam.GetScanCount(); nScanIdx++)
        {
            SRangeData* pRangeData = GetScanRangeData(nModuleIdx, nScanIdx);
 
            if (pRangeData==NULL) continue;
 
            // add range rect
            m_vecRangeRect.push_back(CRect(pRangeData->nLeft, pRangeData->nTop, pRangeData->nRight, pRangeData->nBottom));
 
            if (nScanIdx==0) // first scan ÀÇ ½ÃÀÛÀ§Ä¡´Â ÇöÀç ¸ðµâÀÇ À§Ä¡ÀÌ´Ù.
            {
                sStartPath = vecStartPath[nModuleIdx];
            }
 
            // ¿µ¿ªº° ½ºÄÉÁ층 ¼öÇà.
            CPathSchedulerResult schedulerResult(nModuleIdx, nScanIdx);
            int nCount = CalculatePath(nModuleIdx, nScanIdx, sStartPath, m_vecPathData_Random, *pRangeData, schedulerResult);
            nTotalCount += nCount;
            if (nCount>1)
            {
                // ´ÙÀ½ ½ºÄµÀÇ ½ÃÀÛÀ§Ä¡´Â ÀÌÀü ½ºÄµÀÇ Á¾·á À§Ä¡ÀÌ´Ù.
                const SSchedulerResult* pNode = schedulerResult.GetPathSchedulerResult(schedulerResult.GetPathSchedulerResultCount() - 1);
                if (pNode)
                {
                    sStartPath.nPosX = (pRangeData->nScanEndX);
                    sStartPath.nPosY = int(pNode->dPositionY * 1000);
                }
                m_vecPathSchedulerResult.push_back(schedulerResult);
            }
            else // ´ë»ó °áÇÔÀÌ ¾øÀ»¶§ xÃà À§Ä¡¸¸ º¯°æÇÑ´Ù.
            {
                sStartPath.nPosX = (pRangeData->nScanEndX); // 
            }
        }
    }
 
    return int(m_vecPathSchedulerResult.size());
}
 
void CPathScheduler_Dual_Flying_Random::CreatePathData_Random( int nCount )
{
    int nCreateCount = (int)(nCount * m_PathSchedulerParam.GetRandomScale() + 0.5);
 
    m_vecPathData_Random.reserve(nCreateCount);
 
    srand((unsigned)time(NULL));
 
    SPathData pathData;
    for (int nIdx=0; nIdx<nCreateCount; nIdx++)
    {
        pathData.nIndex = nIdx;
 
        pathData.nPosX = (rand()*1000) % int(m_PathSchedulerParam.GetGlassSizeX());// * 1000;
        pathData.nPosY = (rand()*1000) % int(m_PathSchedulerParam.GetGlassSizeY());// * 1000;
 
        pathData.nPosX += rand() % 1000;
        pathData.nPosY += rand() % 1000;
 
        m_vecPathData_Random.push_back(pathData);
    }
}