|
|
#include "StdAfx.h"
|
|
|
#include "WorkCmdMoveAsixXY.h"
|
|
|
#include "ExceptionMsg.h"
|
|
|
#include "DeviceStateMgr.h"
|
|
|
#include "MsgBox.h"
|
|
|
#include "MotionCtrl.h"
|
|
|
#include "PlcCommunicationMgr.h"
|
|
|
#include "ProgramLaserTuiHuo.h"
|
|
|
#include "PenParMgr.h"
|
|
|
#include "Laser.h"
|
|
|
#include "IO_CtrlMgr.h"
|
|
|
#include "ManualTestMgr.h"
|
|
|
#include "CommonFlowMgr.h"
|
|
|
#include "LaserBeamMeterMgr.h"
|
|
|
#include "LaserDevice.h"
|
|
|
#include "EncryptionMgr.h"
|
|
|
#include "Motor.h"
|
|
|
#include "PlatSpecialPosMgr.h"
|
|
|
|
|
|
CWorkCmdAsixXYMove::CWorkCmdAsixXYMove()
|
|
|
{
|
|
|
m_bMoveByDir = false;//是否通过方向来移动平台
|
|
|
m_MoveDis = 0;//移动距离
|
|
|
m_bCheckIniState = false;//是否检查初始化状态
|
|
|
m_CurMoveDis = 0;//当前的移动距离
|
|
|
|
|
|
m_bMoveToMultiFirstPoint = false;//是否为移动到多点运动的第一个点
|
|
|
}
|
|
|
CWorkCmdAsixXYMove::~CWorkCmdAsixXYMove(void)
|
|
|
{
|
|
|
}
|
|
|
/*MovePt 是数据在平台上映射的实际坐标,
|
|
|
TargetPt 是将MovePt 移动到TargetPt 的位置*/
|
|
|
void CWorkCmdAsixXYMove::MoveToTargetPt(Dbxy MovePt,Dbxy TargetPt)
|
|
|
{
|
|
|
m_MovePt = MovePt;
|
|
|
m_TargetPt = TargetPt;
|
|
|
}
|
|
|
//如果设置了移动距离和方向,则按照这种方式来移动
|
|
|
void CWorkCmdAsixXYMove::MoveByDis(double MoveDis,DIRECTION MoveDir)
|
|
|
{
|
|
|
m_bMoveByDir = true;
|
|
|
m_MoveDis = MoveDis;
|
|
|
m_MoveDir = MoveDir;
|
|
|
}
|
|
|
//将平台移动到指定点
|
|
|
bool CWorkCmdAsixXYMove::Excute()
|
|
|
{
|
|
|
if(gEncryptionMgr->IsbRunAtNoteBook())
|
|
|
return true;
|
|
|
CLogInfo LogInfo;
|
|
|
LogInfo.m_ClassName = "CWorkCmdAsixXYMove";
|
|
|
LogInfo.m_FuncName = "Excute";
|
|
|
//如果本来就在这个位置上,不要执行
|
|
|
Dbxy TargetCoord = gMotionCtrl->CalTargetCoord(m_MovePt,m_TargetPt);
|
|
|
Dbxy CurCmdCoordXY = gMotionCtrl->GetCurCmdCoordXY();
|
|
|
if(IsTwoPtEqual(TargetCoord,CurCmdCoordXY,0.0005))
|
|
|
{
|
|
|
LogInfo.m_LogMsg.Format("Not Need Move TargetX = %lf,TargetY = %lf,CurCmdX = %lf,CurCmdY = %lf",TargetCoord.x,TargetCoord.y,CurCmdCoordXY.x,CurCmdCoordXY.y);
|
|
|
gLogMgr->WriteLogInfo(LogInfo);
|
|
|
return true;
|
|
|
}
|
|
|
//移动前检查顶针气缸
|
|
|
#ifdef __THIMBLE_DISC__
|
|
|
if(gTransferArmMgr->CheckPlatThimbleState(true))
|
|
|
{
|
|
|
{
|
|
|
COperateAlarmPar OperateAlarmPar;
|
|
|
OperateAlarmPar.m_OperateAlarmType = _OperateAlarmType_SetAlarmOn;
|
|
|
OperateAlarmPar.m_AlarmType = _AlarmType_IO_ThimbleSignal1Err;
|
|
|
OperateAlarmPar.m_AlarmAddInfo = "顶针弹起时不能移动平台";
|
|
|
OperateAlarmPar.m_bThowException = THOW_EXCEPTION;
|
|
|
gWarningMgr->OperateAlarmState(OperateAlarmPar);
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
#if 0
|
|
|
if(!gIO_CtrlMgr->ReadIOItemState(_IO_R_Plat_CDA_Signal))
|
|
|
{
|
|
|
{
|
|
|
COperateAlarmPar OperateAlarmPar;
|
|
|
OperateAlarmPar.m_OperateAlarmType = _OperateAlarmType_SetAlarmOn;
|
|
|
OperateAlarmPar.m_AlarmType = _AlarmType_Stage_CDA_Signal;
|
|
|
OperateAlarmPar.m_AlarmAddInfo = "Stage CDA Signal Err";
|
|
|
OperateAlarmPar.m_bThowException = THOW_EXCEPTION;
|
|
|
gWarningMgr->OperateAlarmState(OperateAlarmPar);
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
//Z轴坐标小于m_MotorZSafeCoord的时候,自动把Z轴移动到安全坐标
|
|
|
if(gPlatSpecialPosMgr->IsbUseSafeCoordZ())
|
|
|
{
|
|
|
CMotor *pMotorZ = CMotor::GetMotor(MOTOR_Z);
|
|
|
double AsixCmdCoordZ = gMotionCtrl->AsixGetCmdCoord(*pMotorZ);//当前cmd坐标mm
|
|
|
double MotorZSafeCoord = gPlatSpecialPosMgr->GetMotorZSafeCoord();
|
|
|
if(AsixCmdCoordZ<MotorZSafeCoord)
|
|
|
{
|
|
|
LogInfo.m_LogMsg.Format("MoveZ -->CoordZ = %lf,SafeCoordZ = %lf",AsixCmdCoordZ,MotorZSafeCoord);
|
|
|
gLogMgr->WriteLogInfo(LogInfo);
|
|
|
gMotionCtrl->MoveAsix(*pMotorZ,MotorZSafeCoord,true);
|
|
|
}
|
|
|
}
|
|
|
//单点运动
|
|
|
PTPMove();
|
|
|
return true;
|
|
|
}
|
|
|
//单点运动
|
|
|
void CWorkCmdAsixXYMove::PTPMove()
|
|
|
{
|
|
|
//移动到多点运动的第一个点
|
|
|
if(m_bMoveToMultiFirstPoint)
|
|
|
{
|
|
|
//执行的时候再获取当前的第一个点坐标
|
|
|
vector<CMultiPoint> &MultiPointVec = gMotionCtrl->GetMultiPointVec();
|
|
|
if(MultiPointVec.empty())
|
|
|
{
|
|
|
CString str = _T("多点运动数据为空!");
|
|
|
CExceptionMsg Msg;
|
|
|
Msg.SetMsg(str);
|
|
|
throw Msg;
|
|
|
}
|
|
|
int size = MultiPointVec.size();
|
|
|
for(int k=0;k<size;k++)
|
|
|
{
|
|
|
CMultiPoint &MultiPoint = MultiPointVec[k];
|
|
|
if(MultiPoint.m_bNeedScan)//取第一个需要扫描的点
|
|
|
{
|
|
|
m_MovePt = MultiPoint.m_PtCoord;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
Dbxy OldCoord = gMotionCtrl->GetCurCmdCoordXY();//移动前坐标
|
|
|
if(m_bMoveByDir)//按距离移动
|
|
|
{
|
|
|
m_TargetPt = OldCoord;
|
|
|
m_MovePt.x = m_MovePt.y = 0;
|
|
|
//获取当前坐标
|
|
|
switch(m_MoveDir)
|
|
|
{
|
|
|
case _DIR_L:
|
|
|
m_TargetPt.x -= m_MoveDis;
|
|
|
break;
|
|
|
case _DIR_R:
|
|
|
m_TargetPt.x += m_MoveDis;
|
|
|
break;
|
|
|
case _DIR_U:
|
|
|
m_TargetPt.y += m_MoveDis;
|
|
|
break;
|
|
|
case _DIR_D:
|
|
|
m_TargetPt.y -= m_MoveDis;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
else//点到点移动
|
|
|
{
|
|
|
if(m_bCheckIniState)
|
|
|
{
|
|
|
|
|
|
if(!gDeviceStateMgr->IsDeviceInitialize())
|
|
|
{
|
|
|
CString str = _T("异常,平台未初始化!");
|
|
|
CExceptionMsg Msg;
|
|
|
Msg.SetMsg(str);
|
|
|
throw Msg;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//检查XY 移动后目标坐标
|
|
|
Dbxy TargetCoord = gMotionCtrl->CalTargetCoord(m_MovePt,m_TargetPt);
|
|
|
//如果目标坐标是光束分析仪,先打开气缸衰减器
|
|
|
ECurPlatXyPos CurPlatXyPos = gPlatSpecialPosMgr->GetCurPlatXyPos(TargetCoord);
|
|
|
if(CurPlatXyPos==_PlatXyPos_SpotAnalys)
|
|
|
{
|
|
|
gIO_CtrlMgr->AirDimmerCtrl(true);
|
|
|
}
|
|
|
//调试界面激光安全范围外自动关闭光闸
|
|
|
if(gManualTestMgr->IsbTestMode())
|
|
|
{
|
|
|
if(!gCommonFlowMgr->AtLaserSafePlace(TargetCoord))
|
|
|
{
|
|
|
CLogInfo LogInfo;
|
|
|
LogInfo.m_ClassName = "CWorkCmdAsixXYMove";
|
|
|
LogInfo.m_FuncName = "Excute";
|
|
|
LogInfo.m_LogMsg = "not safe place close machine gate";
|
|
|
gLogMgr->WriteLogInfo(LogInfo);
|
|
|
|
|
|
gLaser->SetbMachineGateOpen(bCLOSE);
|
|
|
gIO_CtrlMgr->WriteIOItemState(_IO_W_Machine_Gate,bCLOSE);
|
|
|
}
|
|
|
}
|
|
|
//移动
|
|
|
gMotionCtrl->AsixXYMove(m_MovePt,m_TargetPt);
|
|
|
|
|
|
}
|
|
|
void CWorkCmdAsixXYMove::WirteLog()
|
|
|
{
|
|
|
CString Log;
|
|
|
if(m_bMoveByDir)
|
|
|
{
|
|
|
Log.Format("MovePlatform :Dis[%.3f]",m_MoveDis);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Log.Format("MovePlatform :[%.3f][%.3f]---->[%.3f][%.3f]",m_MovePt.x,m_MovePt.y,m_TargetPt.x,m_TargetPt.y);
|
|
|
}
|
|
|
CLogInfo LogInfo;
|
|
|
LogInfo.m_ClassName = "CWorkCmdAsixXYMove";
|
|
|
LogInfo.m_FuncName = "WirteLog";
|
|
|
LogInfo.m_LogMsg = Log;
|
|
|
gLogMgr->WriteLogInfo(LogInfo);
|
|
|
} |