#include "StdAfx.h" #include "PathSchedulerData.h" CMotionParm::CMotionParm(void) { pMotionInfoX = NULL; pMotionInfoY = NULL; Reset(); } CMotionParm::~CMotionParm(void) { Reset(); } void CMotionParm::Reset() { nMoveType = Motion_MaxAxisTime; nCurveType = Curve_Line; dAutoFocusTime = 50.0; //ms dImageGrabTime = 1.0; //ms dMotionDelayTime = 40.0; if (pMotionInfoX!=NULL) { delete [] pMotionInfoX; } pMotionInfoX = NULL; nMotionInfoCountX = 0; if (pMotionInfoY!=NULL) { delete [] pMotionInfoY; } pMotionInfoY = NULL; nMotionInfoCountY = 0; } BOOL CMotionParm::LoadParm(const CString& strFilename, CMotionParm& scheduleParam) { FILE *fp = NULL; _tfopen_s(&fp, strFilename, _T("r")); if (fp==NULL) return FALSE; int nValue = 0; TCHAR strValue[200]; double dValue = 0.0; _ftscanf_s(fp, _T("%s,"), strValue, 10); _ftscanf_s(fp, _T("%d\n"), &nValue); scheduleParam.SetMoveType(nValue); _ftscanf_s(fp, _T("%s,"), strValue, 11); _ftscanf_s(fp, _T("%d\n"), &nValue); scheduleParam.SetCurveType(nValue); _ftscanf_s(fp, _T("%s,"), strValue, 16); _ftscanf_s(fp, _T("%lf\n"), &dValue); scheduleParam.SetAutoFocusTime(dValue); _ftscanf_s(fp, _T("%s,"), strValue, 16); _ftscanf_s(fp, _T("%lf\n"), &dValue); scheduleParam.SetImageGrabTime(dValue); _ftscanf_s(fp, _T("%s,"), strValue, 18); _ftscanf_s(fp, _T("%lf\n"), &dValue); scheduleParam.SetMotionDelayTime(dValue); _ftscanf_s(fp, _T("%s,"), strValue, 20); _ftscanf_s(fp, _T("%d\n"), &nValue); scheduleParam.SetMotionInfoCountX(nValue); for (int i=0; idDistanceStart, &pNode->dDistanceEnd, &pNode->dMoveSpeed, &pNode->dAccelTime, &pNode->dDecelTime, &pNode->dInpositionTime); dValue = pNode->dDistanceStart; dValue = pNode->dDistanceEnd; dValue = pNode->dMoveSpeed; dValue = pNode->dAccelTime; dValue = pNode->dDecelTime; dValue = pNode->dInpositionTime; } _ftscanf_s(fp, _T("%s,"), strValue, 20); _ftscanf_s(fp, _T("%d\n"), &nValue); scheduleParam.SetMotionInfoCountY(nValue); for (int i=0; idDistanceStart, &pNode->dDistanceEnd, &pNode->dMoveSpeed, &pNode->dAccelTime, &pNode->dDecelTime, &pNode->dInpositionTime); dValue = pNode->dDistanceStart; dValue = pNode->dDistanceEnd; dValue = pNode->dMoveSpeed; dValue = pNode->dAccelTime; dValue = pNode->dDecelTime; dValue = pNode->dInpositionTime; } fclose(fp); return TRUE; } BOOL CMotionParm::SaveParm(const CString& strFilename, CMotionParm& scheduleParam) { FILE *fp = NULL; _tfopen_s(&fp, strFilename, _T("w")); if (fp==NULL) return FALSE; _ftprintf_s(fp, _T("MOVE_TYPE,%d\n"), scheduleParam.nMoveType); _ftprintf_s(fp, _T("CURVE_TYPE,%d\n"), scheduleParam.nCurveType); _ftprintf_s(fp, _T("AUTO_FOCUS_TIME,%lf\n"), scheduleParam.dAutoFocusTime); _ftprintf_s(fp, _T("IMAGE_GRAB_TIME,%lf\n"), scheduleParam.dImageGrabTime); _ftprintf_s(fp, _T("MOTION_DELAY_TIME,%lf\n"), scheduleParam.dMotionDelayTime); _ftprintf_s(fp, _T("MOTION_INFO_COUNT_X,%d\n"), scheduleParam.nMotionInfoCountX); for (int i=0; idDistanceStart, pNode->dDistanceEnd, pNode->dMoveSpeed, pNode->dAccelTime, pNode->dDecelTime, pNode->dInpositionTime); } _ftprintf_s(fp, _T("MOTION_INFO_COUNT_Y,%d\n"), scheduleParam.nMotionInfoCountY); for (int i=0; idDistanceStart, pNode->dDistanceEnd, pNode->dMoveSpeed, pNode->dAccelTime, pNode->dDecelTime, pNode->dInpositionTime); } fclose(fp); return TRUE; } CMotionParm::CMotionParm(const CMotionParm& rhs) { pMotionInfoX = NULL; pMotionInfoY = NULL; Reset(); if (this != &rhs) { nMoveType = rhs.nMoveType; nCurveType = rhs.nMoveType; dAutoFocusTime = rhs.dAutoFocusTime; dImageGrabTime = rhs.dImageGrabTime; nMotionInfoCountX = rhs.nMotionInfoCountX; if (nMotionInfoCountX>0) { pMotionInfoX = new SMotionInfo[nMotionInfoCountX]; memcpy(pMotionInfoX, rhs.pMotionInfoX, sizeof(SMotionInfo)*nMotionInfoCountX); } nMotionInfoCountY = rhs.nMotionInfoCountY; if (nMotionInfoCountY>0) { pMotionInfoY = new SMotionInfo[nMotionInfoCountY]; memcpy(pMotionInfoY, rhs.pMotionInfoY, sizeof(SMotionInfo)*nMotionInfoCountY); } } } CMotionParm& CMotionParm::operator=(const CMotionParm& rhs) { if (this != &rhs) { Reset(); nMoveType = rhs.nMoveType; nCurveType = rhs.nMoveType; dAutoFocusTime = rhs.dAutoFocusTime; dImageGrabTime = rhs.dImageGrabTime; dMotionDelayTime = rhs.dMotionDelayTime; nMotionInfoCountX = rhs.nMotionInfoCountX; if (nMotionInfoCountX>0) { pMotionInfoX = new SMotionInfo[nMotionInfoCountX]; memcpy(pMotionInfoX, rhs.pMotionInfoX, sizeof(SMotionInfo)*nMotionInfoCountX); } nMotionInfoCountY = rhs.nMotionInfoCountY; if (nMotionInfoCountY>0) { pMotionInfoY = new SMotionInfo[nMotionInfoCountY]; memcpy(pMotionInfoY, rhs.pMotionInfoY, sizeof(SMotionInfo)*nMotionInfoCountY); } } return *this; } CPathSchedulerParm::CPathSchedulerParm(void) { Reset(); } CPathSchedulerParm::CPathSchedulerParm(const CPathSchedulerParm& rhs) { pMotionInfoX = NULL; pMotionInfoY = NULL; Reset(); if (this != &rhs) { // motion info nMoveType = rhs.nMoveType; nCurveType = rhs.nMoveType; dAutoFocusTime = rhs.dAutoFocusTime; dImageGrabTime = rhs.dImageGrabTime; dMotionDelayTime = rhs.dMotionDelayTime;; nMotionInfoCountX = rhs.nMotionInfoCountX; if (nMotionInfoCountX>0) { pMotionInfoX = new SMotionInfo[nMotionInfoCountX]; memcpy(pMotionInfoX, rhs.pMotionInfoX, sizeof(SMotionInfo)*nMotionInfoCountX); } nMotionInfoCountY = rhs.nMotionInfoCountY; if (nMotionInfoCountY>0) { pMotionInfoY = new SMotionInfo[nMotionInfoCountY]; memcpy(pMotionInfoY, rhs.pMotionInfoY, sizeof(SMotionInfo)*nMotionInfoCountY); } //1)ÁÂÇ¥°è Á¤º¸ bCenterCoord = rhs.bCenterCoord; nOriginDir = rhs.nOriginDir; nGlassSizeX = rhs.nGlassSizeX; nGlassSizeY = rhs.nGlassSizeY; nBaseModuleDir = rhs.nBaseModuleDir; //2)¸ðµâ/Ãæµ¹ Á¤º¸ nModuleCount = rhs.nModuleCount; nCollisionDistX = rhs.nCollisionDistX; nCollisionDistY = rhs.nCollisionDistY; //3)ÇöóÀ× ¸®ºä nScanCount = rhs.nScanCount; nScanMargin = rhs.nScanMargin; sScanMotionInfo = rhs.sScanMotionInfo; sModuleMotionInfo = rhs.sModuleMotionInfo; //4)Ãà ¼ÒÆÃÁ¤º¸ nSortAxisType = rhs.nSortAxisType; nSortOrderType = rhs.nSortOrderType; //5)·£´ý ÇöóÀÌ Á¤º¸ dRandomScale = rhs.dRandomScale; } } CPathSchedulerParm& CPathSchedulerParm::operator=(const CPathSchedulerParm& rhs) { if (this != &rhs) { Reset(); // motion info nMoveType = rhs.nMoveType; nCurveType = rhs.nMoveType; dAutoFocusTime = rhs.dAutoFocusTime; dImageGrabTime = rhs.dImageGrabTime; dMotionDelayTime = rhs.dMotionDelayTime; nMotionInfoCountX = rhs.nMotionInfoCountX; if (nMotionInfoCountX>0) { pMotionInfoX = new SMotionInfo[nMotionInfoCountX]; memcpy(pMotionInfoX, rhs.pMotionInfoX, sizeof(SMotionInfo)*nMotionInfoCountX); } nMotionInfoCountY = rhs.nMotionInfoCountY; if (nMotionInfoCountY>0) { pMotionInfoY = new SMotionInfo[nMotionInfoCountY]; memcpy(pMotionInfoY, rhs.pMotionInfoY, sizeof(SMotionInfo)*nMotionInfoCountY); } //1)ÁÂÇ¥°è Á¤º¸ bCenterCoord = rhs.bCenterCoord; nOriginDir = rhs.nOriginDir; nGlassSizeX = rhs.nGlassSizeX; nGlassSizeY = rhs.nGlassSizeY; nBaseModuleDir = rhs.nBaseModuleDir; //2)¸ðµâ/Ãæµ¹ Á¤º¸ nModuleCount = rhs.nModuleCount; nCollisionDistX = rhs.nCollisionDistX; nCollisionDistY = rhs.nCollisionDistY; //3)ÇöóÀ× ¸®ºä nScanCount = rhs.nScanCount; nScanMargin = rhs.nScanMargin; sScanMotionInfo = rhs.sScanMotionInfo; sModuleMotionInfo = rhs.sModuleMotionInfo; //4)Ãà ¼ÒÆÃÁ¤º¸ nSortAxisType = rhs.nSortAxisType; nSortOrderType = rhs.nSortOrderType; //5)·£´ý ÇöóÀÌ Á¤º¸ dRandomScale = rhs.dRandomScale; } return *this; } CPathSchedulerParm::~CPathSchedulerParm(void) { Reset(); } BOOL CPathSchedulerParm::LoadParm(const CString& strFilename, CPathSchedulerParm& scheduleParam) { if (CMotionParm::LoadParm(strFilename, scheduleParam)==FALSE) { return FALSE; } return TRUE; } BOOL CPathSchedulerParm::SaveParm(const CString& strFilename, CPathSchedulerParm& scheduleParam) { if (CMotionParm::SaveParm(strFilename, scheduleParam)==FALSE) { return FALSE; } return TRUE; } SMotionInfo* CMotionParm::GetMotionInfoX(double dDistance) { for (int i=0; i=pMotionInfoX[i].dDistanceStart && dDistance<=pMotionInfoX[i].dDistanceEnd) { return &pMotionInfoX[i]; } } return NULL; } SMotionInfo* CMotionParm::GetMotionInfoY(double dDistance) { for (int i=0; i=pMotionInfoY[i].dDistanceStart && dDistance<=pMotionInfoY[i].dDistanceEnd) { return &pMotionInfoY[i]; } } return NULL; } bool CMotionParm::SetMotionInfoX(int nIndex, const SMotionInfo& motionInfo) { if (nIndex<0 || nIndex>=nMotionInfoCountX) { return false; } pMotionInfoX[nIndex] = motionInfo; return true; } bool CMotionParm::SetMotionInfoY(int nIndex, const SMotionInfo& motionInfo) { if (nIndex<0 || nIndex>=nMotionInfoCountY) { return false; } pMotionInfoY[nIndex] = motionInfo; return true; } SMotionInfo* CMotionParm::GetMotionInfoX(int nIndex) { if (nIndex<0 || nIndex>=nMotionInfoCountX) { return NULL; } return &pMotionInfoX[nIndex]; } SMotionInfo* CMotionParm::GetMotionInfoY(int nIndex) { if (nIndex<0 || nIndex>=nMotionInfoCountY) { return NULL; } return &pMotionInfoY[nIndex]; } void CMotionParm::SetMotionInfoCountX(int nCount) { if (nCount==0) { if (pMotionInfoX) delete [] pMotionInfoX; pMotionInfoX = NULL; nMotionInfoCountX = 0; return; } if (nCount<1) return; if (nCount!=nMotionInfoCountX) { if (pMotionInfoX) delete [] pMotionInfoX; nMotionInfoCountX = nCount; pMotionInfoX = new SMotionInfo[nMotionInfoCountX]; } for (int i=0; i