You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
3.5 KiB
C++
129 lines
3.5 KiB
C++
#include "StdAfx.h"
|
|
#include "WorkCmdWaitMotorStop.h"
|
|
#include "MotionCard_PCI1245.h"
|
|
#include "GlobalFunction.h"
|
|
#include "PlatformXY.h"
|
|
#include "DeviceState.h"
|
|
#include "Program_SZ_XL.h"
|
|
#include "ExceptionMsg.h"
|
|
|
|
CWorkCmdWaitMotorStop::CWorkCmdWaitMotorStop()
|
|
{
|
|
m_bWaitMotorX = false;//检查轴是否运动停止
|
|
m_bWaitMotorX2 = false;//
|
|
m_bWaitMotorY = false;//
|
|
m_bWaitMotorZ = false;//
|
|
m_bCheckActCoord = false;//是否检测实际光栅尺的坐标
|
|
}
|
|
CWorkCmdWaitMotorStop::~CWorkCmdWaitMotorStop(void)
|
|
{
|
|
}
|
|
bool CWorkCmdWaitMotorStop::Excute()
|
|
{
|
|
if(gLogMgr->IsDebuging())//调试状态只延时
|
|
{
|
|
Sleep(gLogMgr->GetDebugCmdDelay());
|
|
return true;
|
|
}
|
|
|
|
Sleep(300);
|
|
|
|
bool bMotorXMoveStop = true;//轴是否运动停止
|
|
bool bMotorX2MoveStop = true;
|
|
bool bMotorYMoveStop = true;
|
|
bool bMotorZMoveStop = true;
|
|
|
|
while(1)
|
|
{
|
|
if(m_bWaitMotorX)
|
|
{
|
|
bMotorXMoveStop = gMotionCard_PCI1245->IsbMotorXMoveStop();
|
|
}
|
|
if(m_bWaitMotorX2)
|
|
{
|
|
bMotorX2MoveStop = gMotionCard_PCI1245->IsbMotorX2MoveStop();
|
|
}
|
|
if(m_bWaitMotorY)
|
|
{
|
|
bMotorYMoveStop = gMotionCard_PCI1245->IsbMotorYMoveStop();
|
|
}
|
|
if(m_bWaitMotorZ)
|
|
{
|
|
bMotorZMoveStop = gMotionCard_PCI1245->IsbMotorZMoveStop();
|
|
}
|
|
//全部满足时退出
|
|
if(bMotorXMoveStop && bMotorX2MoveStop && bMotorYMoveStop && bMotorZMoveStop)
|
|
break;
|
|
Sleep(100);
|
|
}
|
|
|
|
|
|
//更新电机的坐标
|
|
if(m_bWaitMotorX)
|
|
{
|
|
CMotor &MotorX = *(CMotor::GetMotor(MOTOR_X));
|
|
MotorX.SetCoord(gMotionCard_PCI1245->GetMotorCoord(MotorX));
|
|
}
|
|
if(m_bWaitMotorX2)
|
|
{
|
|
CMotor &MotorX2 = *(CMotor::GetMotor(MOTOR_X2));
|
|
MotorX2.SetCoord(gMotionCard_PCI1245->GetMotorCoord(MotorX2));
|
|
}
|
|
if(m_bWaitMotorY)
|
|
{
|
|
CMotor &MotorY = *(CMotor::GetMotor(MOTOR_Y));
|
|
MotorY.SetCoord(gMotionCard_PCI1245->GetMotorCoord(MotorY));
|
|
}
|
|
if(m_bWaitMotorZ)
|
|
{
|
|
CMotor &MotorZ = *(CMotor::GetMotor(MOTOR_Z));
|
|
MotorZ.SetCoord(gMotionCard_PCI1245->GetMotorCoord(MotorZ));
|
|
}
|
|
|
|
CPlatformXY &PlatformXY = *gPlatformXY;
|
|
PlatformXY.NotifyObservers();
|
|
|
|
Sleep(300);
|
|
#if 1
|
|
if(gMotionCard_PCI1245->m_bCheckActCoord)//检查光栅尺坐标和命令坐标是否匹配
|
|
{
|
|
bool bRet = true;
|
|
if(m_bWaitMotorX)
|
|
{
|
|
CMotor &MotorX = *(CMotor::GetMotor(MOTOR_X));
|
|
bRet = gMotionCard_PCI1245->CheckMotorActCoord(MotorX);
|
|
}
|
|
if(m_bWaitMotorX2)
|
|
{
|
|
CMotor &MotorX2 = *(CMotor::GetMotor(MOTOR_X2));
|
|
bRet = gMotionCard_PCI1245->CheckMotorActCoord(MotorX2);
|
|
}
|
|
if(m_bWaitMotorY)
|
|
{
|
|
CMotor &MotorY = *(CMotor::GetMotor(MOTOR_Y));
|
|
bRet = gMotionCard_PCI1245->CheckMotorActCoord(MotorY);
|
|
}
|
|
if(!bRet)
|
|
{
|
|
//停止加工
|
|
gProgram_SZ_XL->StopAutoWork();
|
|
//取消初始化状态
|
|
CDeviceState &DeviceState = CDeviceState::GetInstance();
|
|
DeviceState.SetIniState(false);
|
|
|
|
CString str = _T("光栅尺坐标反馈异常!");
|
|
AfxMessageBox(str);
|
|
// CExceptionMsg Msg;
|
|
//Msg.SetMsg(str);
|
|
//throw Msg;
|
|
}
|
|
}
|
|
#endif
|
|
return true;
|
|
}
|
|
|
|
void CWorkCmdWaitMotorStop::WirteLog()
|
|
{
|
|
CString str1 = "[WorkCmd][WaitMotorStop]";
|
|
gLogMgr->WriteDebugLog(str1);
|
|
} |