|
|
|
|
|
// TestDlg.cpp : 实现文件
|
|
|
//
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
#include "LaiPuLaser.h"
|
|
|
#include "DlgPlatformCtrl.h"
|
|
|
#include "afxdialogex.h"
|
|
|
#include "WorkCmdMovePlatformXY.h"
|
|
|
#include "MsgBox.h"
|
|
|
#include "AuthorityMgr.h"
|
|
|
#include "WorkCmdInvoker.h"
|
|
|
#include "WorkCmdMoveMotor.h"
|
|
|
#include "ExceptionMsg.h"
|
|
|
#include "WorkCmdMotorToMachineOrigin.h"
|
|
|
#include "WorkCmdMotorToOffsetPos.h"
|
|
|
#include "PropertieMgr.h"
|
|
|
#include "DeviceState.h"
|
|
|
#include "Laser.h"
|
|
|
#include "ObjComponentMgr.h"
|
|
|
#include "MotionCard_PCI1245.h"
|
|
|
#include "WorkCmdSetMotorSpeed.h"
|
|
|
#include "WorkCmdWaitMotorStop.h"
|
|
|
|
|
|
|
|
|
#define MAX_MOVE_DIS 100//平台一次最大移动距离
|
|
|
#define MAX_Z_MOVE_DIS 10//Z轴最大移动距离
|
|
|
|
|
|
#define WORK_TIMER1 1
|
|
|
#define WORK_TIME_DELAY1 200
|
|
|
|
|
|
#define WORK_TIMER2 2
|
|
|
#define WORK_TIME_DELAY2 50
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC(DlgPlatformCtrl, CDialogEx)
|
|
|
BEGIN_MESSAGE_MAP(DlgPlatformCtrl, CDialogEx)
|
|
|
ON_WM_TIMER()
|
|
|
ON_BN_CLICKED(IDC_UP_BTN, &DlgPlatformCtrl::OnBnClickedUpBtn)
|
|
|
ON_BN_CLICKED(IDC_DOWN_BTN, &DlgPlatformCtrl::OnBnClickedDownBtn)
|
|
|
ON_BN_CLICKED(IDC_LEFT_BTN, &DlgPlatformCtrl::OnBnClickedLeftBtn)
|
|
|
ON_BN_CLICKED(IDC_RIGHT_BTN, &DlgPlatformCtrl::OnBnClickedRightBtn)
|
|
|
ON_BN_CLICKED(IDC_TO_ORIGIN, &DlgPlatformCtrl::OnBnClickedToOrigin)
|
|
|
ON_BN_CLICKED(IDC_BY_DIS, &DlgPlatformCtrl::OnBnClickedByDis)
|
|
|
ON_BN_CLICKED(IDC_BY_PULSE, &DlgPlatformCtrl::OnBnClickedByPulse)
|
|
|
ON_BN_CLICKED(IDC_MOTOR_Z_UP, &DlgPlatformCtrl::OnBnClickedMotorZUp)
|
|
|
ON_BN_CLICKED(IDC_MOTOR_Z_DOWN, &DlgPlatformCtrl::OnBnClickedMotorZDown)
|
|
|
ON_BN_CLICKED(IDC_SET_XY_ORIGIN, &DlgPlatformCtrl::OnBnClickedSetOrigin)
|
|
|
ON_BN_CLICKED(IDC_TO_WORK_PT, &DlgPlatformCtrl::OnBnClickedToWorkPt)
|
|
|
ON_BN_CLICKED(IDC_INI_PLAT, &DlgPlatformCtrl::OnBnClickedIniPlat)
|
|
|
ON_BN_CLICKED(IDC_SET_Z_FOCUS, &DlgPlatformCtrl::OnBnClickedSetZFocus)
|
|
|
ON_BN_CLICKED(IDC_RESET_XY_ORIGIN, &DlgPlatformCtrl::OnBnClickedResetXyOrigin)
|
|
|
ON_BN_CLICKED(IDC_ADJUST_PLAT_SPEED, &DlgPlatformCtrl::OnBnClickedAdjustPlatSpeed)
|
|
|
ON_BN_CLICKED(IDC_TEST_Z_FOCUS, &DlgPlatformCtrl::OnBnClickedTestZFocus)
|
|
|
ON_EN_CHANGE(IDC_MOVE_RANGE, &DlgPlatformCtrl::OnEnChangeMoveRange)
|
|
|
ON_EN_CHANGE(IDC_MOVE_DIS_Z, &DlgPlatformCtrl::OnEnChangeMoveDisZ)
|
|
|
ON_BN_CLICKED(IDC_MOVE_TO_PT, &DlgPlatformCtrl::OnBnClickedMoveToPt)
|
|
|
ON_BN_CLICKED(IDC_INI_MOTOR_Z, &DlgPlatformCtrl::OnBnClickedIniMotorZ)
|
|
|
ON_BN_CLICKED(IDC_SET_PRODUCT_POS, &DlgPlatformCtrl::OnBnClickedSetProductPos)
|
|
|
ON_BN_CLICKED(IDC_USE_MOTOR_X2_CHECK, &DlgPlatformCtrl::OnBnClickedUseMotorX2Check)
|
|
|
ON_BN_CLICKED(IDC_RESET_ERR, &DlgPlatformCtrl::OnBnClickedResetErr)
|
|
|
ON_BN_CLICKED(IDC_SEVON_BTN, &DlgPlatformCtrl::OnBnClickedSevonBtn)
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
DlgPlatformCtrl::DlgPlatformCtrl(CWnd* pParent /*=NULL*/)
|
|
|
{
|
|
|
bMoveByDis = true;//是否按距离移动(false 为按脉冲个数移动)
|
|
|
m_MoveRange = 10;//移动距离或者脉冲个数
|
|
|
m_ZMotorMoveDis = 0.1;
|
|
|
m_CoordZ = 0;
|
|
|
m_CoordZ2 = 0;
|
|
|
m_ZMotorMoveDis = 1;
|
|
|
m_MovePtX = 0;
|
|
|
m_MovePtY = 0;
|
|
|
m_bMotorInit = false;//Z轴是否初始化
|
|
|
}
|
|
|
DlgPlatformCtrl::~DlgPlatformCtrl()
|
|
|
{
|
|
|
}
|
|
|
void DlgPlatformCtrl::DoDataExchange(CDataExchange* pDX)
|
|
|
{
|
|
|
CDialogEx::DoDataExchange(pDX);
|
|
|
DDX_Control(pDX, IDC_LEFT_BTN, m_XLeftBtn);
|
|
|
DDX_Control(pDX, IDC_RIGHT_BTN, m_XRightBtn);
|
|
|
DDX_Control(pDX, IDC_UP_BTN, m_XTopBtn);
|
|
|
DDX_Control(pDX, IDC_DOWN_BTN, m_XDownBtn);
|
|
|
DDX_Control(pDX, IDC_MOTOR_Z_UP, m_ZUpBtn);
|
|
|
DDX_Control(pDX, IDC_MOTOR_Z_DOWN, m_ZDownBtn);
|
|
|
DDX_Text(pDX, IDC_MOVE_RANGE, m_MoveRange);
|
|
|
DDX_Text(pDX, IDC_COORD_X, m_PlatformCoord.x);
|
|
|
DDX_Text(pDX, IDC_COORD_Y, m_PlatformCoord.y);
|
|
|
DDX_Text(pDX, IDC_COORD_Z, m_CoordZ);
|
|
|
DDX_Text(pDX, IDC_COORD_Z2, m_CoordZ2);
|
|
|
DDX_Text(pDX, IDC_MOVE_DIS_Z, m_ZMotorMoveDis);
|
|
|
DDX_Text(pDX, IDC_MOVE_PT_X, m_MovePtX);
|
|
|
DDX_Text(pDX, IDC_MOVE_PT_Y, m_MovePtY);
|
|
|
DDX_Control(pDX, IDC_INI_PLAT, m_InitPlatBtn);
|
|
|
DDX_Control(pDX, IDC_TO_ORIGIN, m_ToOriginPtBtn);
|
|
|
DDX_Control(pDX, IDC_TO_WORK_PT, m_ToProductPtBtn);
|
|
|
DDX_Control(pDX, IDC_RESET_XY_ORIGIN, m_PlatCoordZeroBtn);
|
|
|
DDX_Control(pDX, IDC_SET_XY_ORIGIN, m_SetOriginPtBtn);
|
|
|
DDX_Control(pDX, IDC_SET_PRODUCT_POS, m_SetProductPtBtn);
|
|
|
DDX_Control(pDX, IDC_MOVE_TO_PT, m_MovePlatToPtBtn);
|
|
|
DDX_Control(pDX, IDC_INI_MOTOR_Z, m_InitZMotorBtn);
|
|
|
DDX_Control(pDX, IDC_SET_Z_FOCUS, m_SetZMotorOriginBtn);
|
|
|
DDX_Control(pDX, IDC_TEST_Z_FOCUS, m_ReadZMotorOriginBtn);
|
|
|
DDX_Control(pDX, IDC_RESET_ERR, m_ResetMotorErrBtn);
|
|
|
|
|
|
}
|
|
|
BOOL DlgPlatformCtrl::OnInitDialog()
|
|
|
{
|
|
|
CDialogEx::OnInitDialog();
|
|
|
|
|
|
m_XLeftBtn.LoadBitmaps(IDB_LEFT_BTN,IDB_LEFT_DOWN_BTN,IDB_LEFT_BTN,IDB_LEFT_BTN);
|
|
|
m_XRightBtn.LoadBitmaps(IDB_RIGHT_BTN,IDB_RIGHT_BTN_DOWN,IDB_RIGHT_BTN,IDB_RIGHT_BTN);
|
|
|
m_XTopBtn.LoadBitmaps(IDB_TOP_BTN,IDB_TOP_DOWN_BTN,IDB_TOP_BTN,IDB_TOP_BTN);
|
|
|
m_XDownBtn.LoadBitmaps(IDB_DOWN_BTN,IDB_DOWN_DOWN_BTN,IDB_DOWN_BTN,IDB_DOWN_BTN);
|
|
|
m_ZUpBtn.LoadBitmaps(IDB_TOP_BTN,IDB_TOP_DOWN_BTN,IDB_TOP_BTN,IDB_TOP_BTN);
|
|
|
m_ZDownBtn.LoadBitmaps(IDB_DOWN_BTN,IDB_DOWN_DOWN_BTN,IDB_DOWN_BTN,IDB_DOWN_BTN);
|
|
|
|
|
|
//默认按距离移动
|
|
|
((CButton *)GetDlgItem(IDC_BY_DIS))->SetCheck(TRUE);
|
|
|
|
|
|
m_SetOriginPtBtn.SetUpColor(RGB_RED);
|
|
|
m_SetProductPtBtn.SetUpColor(RGB_RED);
|
|
|
m_SetZMotorOriginBtn.SetUpColor(RGB_RED);
|
|
|
|
|
|
UpdateData(FALSE);
|
|
|
return TRUE;
|
|
|
}
|
|
|
//观察平台坐标的变化
|
|
|
void DlgPlatformCtrl::UpdateInfo()
|
|
|
{
|
|
|
m_PlatformCoord = gPlatformXY->GetCoord();
|
|
|
//不要科学计数显示
|
|
|
if(IsDbEqualZero(m_PlatformCoord.x))
|
|
|
m_PlatformCoord.x = 0;
|
|
|
if(IsDbEqualZero(m_PlatformCoord.y))
|
|
|
m_PlatformCoord.y = 0;
|
|
|
|
|
|
CMotor *pMotorZ = CMotor::GetMotor(MOTOR_Z);
|
|
|
m_CoordZ = pMotorZ->GetCoord();
|
|
|
m_CoordZ2 = pMotorZ->GetCoord2();
|
|
|
//不要科学计数显示
|
|
|
if(IsDbEqualZero(m_CoordZ))
|
|
|
m_CoordZ = 0;
|
|
|
UpdateData(FALSE);
|
|
|
}
|
|
|
void DlgPlatformCtrl::Update()
|
|
|
{
|
|
|
SetTimer(WORK_TIMER1,WORK_TIME_DELAY1,NULL);//用timer来更新,否则会报错
|
|
|
}
|
|
|
void DlgPlatformCtrl::OnTimer(UINT nIDEvent)
|
|
|
{
|
|
|
if(nIDEvent == WORK_TIMER1)
|
|
|
{
|
|
|
UpdateInfo();
|
|
|
KillTimer(WORK_TIMER1);
|
|
|
}
|
|
|
if(nIDEvent == WORK_TIMER2)
|
|
|
{
|
|
|
gMotionCard_PCI1245->ResetAllAsixErr();
|
|
|
KillTimer(WORK_TIMER2);
|
|
|
}
|
|
|
CDialog::OnTimer(nIDEvent);
|
|
|
}
|
|
|
|
|
|
void DlgPlatformCtrl::SetAllBtnState(bool b)
|
|
|
{
|
|
|
GetDlgItem(IDC_TO_ORIGIN)->EnableWindow(b);
|
|
|
GetDlgItem(IDC_TO_WORK_PT)->EnableWindow(b);
|
|
|
GetDlgItem(IDC_INI_PLAT)->EnableWindow(b);
|
|
|
GetDlgItem(IDC_RESET_XY_ORIGIN)->EnableWindow(b);
|
|
|
GetDlgItem(IDC_ADJUST_PLAT_SPEED)->EnableWindow(b);
|
|
|
}
|
|
|
#if 1
|
|
|
//按距离移动(前提条件是电机分辨率是正确的)
|
|
|
void DlgPlatformCtrl::OnBnClickedByDis()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
bMoveByDis = true;
|
|
|
}
|
|
|
//按脉冲个数移动
|
|
|
void DlgPlatformCtrl::OnBnClickedByPulse()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
bMoveByDis = false;
|
|
|
}
|
|
|
void DlgPlatformCtrl::OnBnClickedUpBtn()
|
|
|
{
|
|
|
UpdateData(TRUE);
|
|
|
gPlatformXY->ManualMovePlatForm(bMoveByDis,m_MoveRange,_DIR_U);
|
|
|
}
|
|
|
void DlgPlatformCtrl::OnBnClickedDownBtn()
|
|
|
{
|
|
|
UpdateData(TRUE);
|
|
|
gPlatformXY->ManualMovePlatForm(bMoveByDis,m_MoveRange,_DIR_D);
|
|
|
}
|
|
|
void DlgPlatformCtrl::OnBnClickedLeftBtn()
|
|
|
{
|
|
|
UpdateData(TRUE);
|
|
|
gPlatformXY->ManualMovePlatForm(bMoveByDis,m_MoveRange,_DIR_L);
|
|
|
}
|
|
|
void DlgPlatformCtrl::OnBnClickedRightBtn()
|
|
|
{
|
|
|
UpdateData(TRUE);
|
|
|
gPlatformXY->ManualMovePlatForm(bMoveByDis,m_MoveRange,_DIR_R);
|
|
|
}
|
|
|
#endif
|
|
|
#if 1
|
|
|
//平台坐标归零
|
|
|
void DlgPlatformCtrl::OnBnClickedResetXyOrigin()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
if(MsgBox.ConfirmOkCancel(_T("平台坐标归零?"))==false)
|
|
|
return;
|
|
|
|
|
|
vector<CString> CmdVec;
|
|
|
CmdVec.push_back(_T("CmdName[CMD_DEVICE_PAR_RESET]"));
|
|
|
CWorkCmdInvoker Invoker;
|
|
|
Invoker.ExcuteCmd(CmdVec);
|
|
|
}
|
|
|
|
|
|
|
|
|
//初始化平台
|
|
|
void DlgPlatformCtrl::OnBnClickedIniPlat()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
gPlatformXY->IniPlat();
|
|
|
}
|
|
|
|
|
|
//返回工作原点
|
|
|
void DlgPlatformCtrl::OnBnClickedToOrigin()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
gPlatformXY->MoveToOriginPt();
|
|
|
}
|
|
|
//设置当前位置为平台原点(测试用)
|
|
|
void DlgPlatformCtrl::OnBnClickedSetOrigin()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
if(MsgBox.ConfirmOkCancel(_T("设置当前位置为平台原点\n 重启软件后生效"))==false)
|
|
|
return;
|
|
|
|
|
|
CMotor &MotorX = *(CMotor::GetMotor(MOTOR_X));
|
|
|
CMotor &MotorY = *(CMotor::GetMotor(MOTOR_Y));
|
|
|
|
|
|
//查找原点,记录距离
|
|
|
{
|
|
|
CWorkCmdMotorToMachineOrigin *pCmd = new CWorkCmdMotorToMachineOrigin(MotorX);
|
|
|
pCmd->SetPar(true);
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.ExcuteOneCmd(pCmd);
|
|
|
}
|
|
|
//查找原点,记录距离
|
|
|
{
|
|
|
CWorkCmdMotorToMachineOrigin *pCmd = new CWorkCmdMotorToMachineOrigin(MotorY);
|
|
|
pCmd->SetPar(true);
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.ExcuteOneCmd(pCmd);
|
|
|
}
|
|
|
//返回
|
|
|
{
|
|
|
CWorkCmdMotorToOffsetPos *pCmd = new CWorkCmdMotorToOffsetPos(MotorY);
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.ExcuteOneCmd(pCmd);
|
|
|
}
|
|
|
//返回
|
|
|
{
|
|
|
CWorkCmdMotorToOffsetPos *pCmd = new CWorkCmdMotorToOffsetPos(MotorX);
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.ExcuteOneCmd(pCmd);
|
|
|
}
|
|
|
gDevicePropertieMgr.SaveAllPropertie();
|
|
|
}
|
|
|
//取料点
|
|
|
void DlgPlatformCtrl::OnBnClickedToWorkPt()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
gPlatformXY->MoveToWorkPt();
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
#if 1
|
|
|
void DlgPlatformCtrl::MoveMotorZ(bool bDirZ)
|
|
|
{
|
|
|
//自动运行中禁止移动
|
|
|
if(gProgram_SZ_XL->IsbAutoWorking())
|
|
|
return;
|
|
|
//非厂家权限限制移动
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,false)==false)
|
|
|
return;
|
|
|
CMotor &Motor = *(CMotor::GetMotor(MOTOR_Z));
|
|
|
unsigned int PulseCnt = 0;
|
|
|
if(bMoveByDis)
|
|
|
{
|
|
|
PulseCnt = (unsigned int)(m_ZMotorMoveDis/Motor.GetOnePulseDis());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
PulseCnt = (unsigned int)m_ZMotorMoveDis;
|
|
|
}
|
|
|
double dis = bDirZ?m_ZMotorMoveDis:m_ZMotorMoveDis*(-1);
|
|
|
CWorkCmdContainer CmdContainer;
|
|
|
//设置电机速度
|
|
|
{
|
|
|
CWorkCmdSetMotorSpeed *pCmd = new CWorkCmdSetMotorSpeed();
|
|
|
pCmd->SetbSetMotorZ();
|
|
|
pCmd->SetSpeedType(_SpeedType_Move);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//移动
|
|
|
{
|
|
|
CWorkCmdMoveMotor *pCmd = new CWorkCmdMoveMotor(Motor,dis);
|
|
|
pCmd->SetMoveFlg(true);//按距离移动
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//等待移动结束
|
|
|
{
|
|
|
CWorkCmdWaitMotorStop *pCmd = new CWorkCmdWaitMotorStop();
|
|
|
pCmd->SetbWaitMotorZ();
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.Excute(CmdContainer);
|
|
|
|
|
|
Motor.NotifyObservers();
|
|
|
}
|
|
|
bool DlgPlatformCtrl::CheckZMoveDis()
|
|
|
{
|
|
|
UpdateData(TRUE);
|
|
|
if(m_ZMotorMoveDis>MAX_Z_MOVE_DIS)
|
|
|
{
|
|
|
CMsgBox MsgBox;
|
|
|
MsgBox.Show("Z 轴每次最多移动(mm)!");
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
void DlgPlatformCtrl::OnBnClickedMotorZUp()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
if(CheckZMoveDis())
|
|
|
{
|
|
|
MoveMotorZ(true);
|
|
|
}
|
|
|
}
|
|
|
void DlgPlatformCtrl::OnBnClickedMotorZDown()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
if(CheckZMoveDis())
|
|
|
{
|
|
|
MoveMotorZ(false);
|
|
|
}
|
|
|
}
|
|
|
//设置当前点为Z 轴原点
|
|
|
void DlgPlatformCtrl::OnBnClickedSetZFocus()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
CMsgBox MsgBox;
|
|
|
if(MsgBox.ConfirmOkCancel(_T("设置当前点为Z 轴的焦点?"))==false)
|
|
|
return;
|
|
|
|
|
|
CMotor &Motor = *(CMotor::GetMotor(MOTOR_Z));
|
|
|
|
|
|
if(gMotionCard_PCI1245->IsbUsed())
|
|
|
{
|
|
|
if(!m_bMotorInit)
|
|
|
{
|
|
|
CMsgBox MsgBox;
|
|
|
MsgBox.Show("请先初始化Z 轴");
|
|
|
return;
|
|
|
}
|
|
|
//设置当前的焦点位置为原点偏移位置
|
|
|
Motor.SetOriginOffsetDis(Motor.GetCoord2());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//查找原点,记录距离
|
|
|
{
|
|
|
CWorkCmdMotorToMachineOrigin *pCmd = new CWorkCmdMotorToMachineOrigin(Motor);
|
|
|
pCmd->SetPar(true);
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.ExcuteOneCmd(pCmd);
|
|
|
}
|
|
|
//返回焦点
|
|
|
{
|
|
|
CWorkCmdMotorToOffsetPos *pCmd = new CWorkCmdMotorToOffsetPos(Motor);
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.ExcuteOneCmd(pCmd);
|
|
|
}
|
|
|
//通知观察者平台坐标变化了
|
|
|
gPlatformXY->NotifyObservers();
|
|
|
}
|
|
|
gDevicePropertieMgr.SaveAllPropertie();
|
|
|
}
|
|
|
void DlgPlatformCtrl::OnBnClickedTestZFocus()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
CMsgBox MsgBox;
|
|
|
if(MsgBox.ConfirmOkCancel(_T("测试Z 轴脉冲个数?"))==false)
|
|
|
return;
|
|
|
|
|
|
CMotor &Motor = *(CMotor::GetMotor(MOTOR_Z));
|
|
|
|
|
|
//查找原点,不要记录距离
|
|
|
{
|
|
|
CWorkCmdMotorToMachineOrigin *pCmd = new CWorkCmdMotorToMachineOrigin(Motor);
|
|
|
pCmd->SetPar(false);
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.ExcuteOneCmd(pCmd);
|
|
|
}
|
|
|
//返回焦点
|
|
|
{
|
|
|
CWorkCmdMotorToOffsetPos *pCmd = new CWorkCmdMotorToOffsetPos(Motor);
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.ExcuteOneCmd(pCmd);
|
|
|
}
|
|
|
|
|
|
gDevicePropertieMgr.SaveAllPropertie();
|
|
|
|
|
|
//通知观察者平台坐标变化了
|
|
|
gPlatformXY->NotifyObservers();
|
|
|
}
|
|
|
//初始化Z 轴
|
|
|
void DlgPlatformCtrl::OnBnClickedIniMotorZ()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
CMsgBox MsgBox;
|
|
|
if(MsgBox.ConfirmOkCancel(_T("初始化Z 轴?"))==false)
|
|
|
return;
|
|
|
|
|
|
CMotor &Motor = *(CMotor::GetMotor(MOTOR_Z));
|
|
|
|
|
|
//查找原点,记录距离
|
|
|
{
|
|
|
CWorkCmdMotorToMachineOrigin *pCmd = new CWorkCmdMotorToMachineOrigin(Motor);
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.ExcuteOneCmd(pCmd);
|
|
|
}
|
|
|
//返回焦点
|
|
|
{
|
|
|
CWorkCmdMotorToOffsetPos *pCmd = new CWorkCmdMotorToOffsetPos(Motor);
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.ExcuteOneCmd(pCmd);
|
|
|
}
|
|
|
m_bMotorInit = true;//Z轴是否初始化
|
|
|
//通知观察者平台坐标变化了
|
|
|
gPlatformXY->NotifyObservers();
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
void DlgPlatformCtrl::OnBnClickedAdjustPlatSpeed()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
|
|
|
return;
|
|
|
CMsgBox MsgBox;
|
|
|
if(MsgBox.ConfirmOkCancel(_T("校准平台的运动速度?"))==false)
|
|
|
return;
|
|
|
gPlatformXY->AdjustPlatformSpeed();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DlgPlatformCtrl::OnEnChangeMoveRange()
|
|
|
{
|
|
|
// TODO: 如果该控件是 RICHEDIT 控件,它将不
|
|
|
// 发送此通知,除非重写 __super::OnInitDialog()
|
|
|
// 函数并调用 CRichEditCtrl().SetEventMask(),
|
|
|
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
|
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
|
//UpdateData(TRUE);
|
|
|
}
|
|
|
|
|
|
|
|
|
void DlgPlatformCtrl::OnEnChangeMoveDisZ()
|
|
|
{
|
|
|
// TODO: 如果该控件是 RICHEDIT 控件,它将不
|
|
|
// 发送此通知,除非重写 __super::OnInitDialog()
|
|
|
// 函数并调用 CRichEditCtrl().SetEventMask(),
|
|
|
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
|
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
//UpdateData(TRUE);
|
|
|
}
|
|
|
//移动到指定坐标
|
|
|
void DlgPlatformCtrl::OnBnClickedMoveToPt()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
UpdateData(TRUE);
|
|
|
Dbxy TargetPt(m_MovePtX,m_MovePtY);
|
|
|
gPlatformXY->MoveToPt(Dbxy(0,0),TargetPt);
|
|
|
}
|
|
|
//当前点设置为取料点
|
|
|
void DlgPlatformCtrl::OnBnClickedSetProductPos()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
gPlatformXY->SetCurPosAsProductPt();
|
|
|
//保存到属性
|
|
|
gDevicePropertieMgr.SaveAllPropertie();
|
|
|
}
|
|
|
//切换X2 轴控制
|
|
|
void DlgPlatformCtrl::OnBnClickedUseMotorX2Check()
|
|
|
{
|
|
|
int idx = (((CButton *)GetDlgItem(IDC_USE_MOTOR_X2_CHECK))->GetCheck())?1:0;
|
|
|
gMotionCard_PCI1245->SetCurGpIdx(idx);
|
|
|
}
|
|
|
|
|
|
void DlgPlatformCtrl::ResetAllMotorErr()
|
|
|
{
|
|
|
SetTimer(WORK_TIMER2,WORK_TIME_DELAY2,NULL);
|
|
|
}
|
|
|
|
|
|
void DlgPlatformCtrl::OnBnClickedResetErr()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
CMsgBox MsgBox;
|
|
|
if(MsgBox.ConfirmOkCancel(_T("重置所有轴错误?"))==false)
|
|
|
return;
|
|
|
gMotionCard_PCI1245->ResetAllAsixErr();
|
|
|
//重新激磁
|
|
|
gMotionCard_PCI1245->SetSvOn(false);
|
|
|
Sleep(500);
|
|
|
gMotionCard_PCI1245->SetSvOn(true);
|
|
|
//需要重新初始化设备
|
|
|
CDeviceState &DeviceState = CDeviceState::GetInstance();
|
|
|
DeviceState.SetIniState(false);
|
|
|
}
|
|
|
void DlgPlatformCtrl::OnBnClickedSevonBtn()
|
|
|
{
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY,true)==false)
|
|
|
return;
|
|
|
gMotionCard_PCI1245->SetSvOn(false);
|
|
|
Sleep(500);
|
|
|
gMotionCard_PCI1245->SetSvOn(true);
|
|
|
//需要重新初始化设备
|
|
|
CDeviceState &DeviceState = CDeviceState::GetInstance();
|
|
|
DeviceState.SetIniState(false);
|
|
|
}
|