#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;
|
}
|