|
|
#include "StdAfx.h"
|
|
|
#include "CommonFlowMgr.h"
|
|
|
#include "WorkCmdMovePlatformXY.h"
|
|
|
#include "MsgBox.h"
|
|
|
#include "WorkCmdInvoker.h"
|
|
|
#include "Propertie.h"
|
|
|
#include "PropertieMgr.h"
|
|
|
#include "AuthorityMgr.h"
|
|
|
#include "LogMgr.h"
|
|
|
#include "Camera.h"
|
|
|
#include "Product.h"
|
|
|
#include "WorkCmdCameraCatch.h"
|
|
|
#include "CStringFuc.h"
|
|
|
#include "PlatformXY.h"
|
|
|
#include "Laser.h"
|
|
|
#include "MarkAreaMgr.h"
|
|
|
#include "WorkCmdMarkArea.h"
|
|
|
#include "WorkCmdMoveMotor.h"
|
|
|
#include "ObjComponentMgr.h"
|
|
|
#include "WorkCmdPciPortSwitch.h"
|
|
|
#include "PciPortMgr.h"
|
|
|
#include "MeasureMgr.h"
|
|
|
#include "ExceptionMsg.h"
|
|
|
#include "FileMgr.h"
|
|
|
#include "CameraHawkvis.h"
|
|
|
#include "WorkCmdMotorToOffsetPos.h"
|
|
|
#include "WorkCmdMotorToMachineOrigin.h"
|
|
|
#include "Motor.h"
|
|
|
#include "WorkCmdDeviceParReset.h"
|
|
|
#include "WorkCmdWorkStart.h"
|
|
|
#include "WorkCmdWorkEnd.h"
|
|
|
#include "ProductMgr.h"
|
|
|
#include "DeviceState.h"
|
|
|
#include "WorkFileMgr.h"
|
|
|
#include "CommPortMgr.h"
|
|
|
#include "PlcIOMgr.h"
|
|
|
#include "PciCh365Mgr.h"
|
|
|
#include "WorkCmdResetAllMotorErr.h"
|
|
|
#include "WorkCmdWaitMotorStop.h"
|
|
|
#include "WorkCmdSetMotorSpeed.h"
|
|
|
|
|
|
|
|
|
|
|
|
CCommonFlowMgr *gCommonFlowMgr = new CCommonFlowMgr;
|
|
|
CCommonFlowMgr::CCommonFlowMgr(void)
|
|
|
{
|
|
|
m_bIniPlatfrom = true;//是否初始化电机平台
|
|
|
m_bIniConfirmMsgBox = true;//是否弹出初始化确认对话框
|
|
|
m_bIniMotorX = true;//是否初始化电机X
|
|
|
m_bIniMotorY = true;//是否初始化电机Y
|
|
|
m_bIniMotorZ = false;//是否初始化电机Z
|
|
|
m_bInitedToProductPt = false;//初始化完成后是否返回上料点
|
|
|
|
|
|
m_bFocalAdjust = false;//加工的时候是否实时调整焦距
|
|
|
m_FocalAdjustDis = 0;//变焦距离mm
|
|
|
m_FocalAdjustCnt = 0;//变焦次数(每变焦一次按照下面的参数加工一遍)
|
|
|
m_AreaCycleCnt = 1;//每次一个workarea 的循环加工次数
|
|
|
m_OneObjMarkCnt = 1;//单个元件加工次数
|
|
|
m_SpecialOneObjMarkCnt = 1;//特殊切割次数
|
|
|
m_CutSpeed = 800;//切割速度
|
|
|
m_bBackToProductPt = false;//加工完成后是否返回取料点
|
|
|
m_bSetLightState = false;//是否设置警示灯状态
|
|
|
|
|
|
|
|
|
m_bUseLaser = false;//是否开关激光
|
|
|
|
|
|
m_CalibrationPointGap = 2;//打点之间的间隔mm
|
|
|
m_CalibrationRange = 50;//振镜校准范围mm
|
|
|
|
|
|
m_AlamDelay = 1000;//报警延时(ms)
|
|
|
|
|
|
m_bConnectObj = true;//是否连接多个obj 数据
|
|
|
|
|
|
m_bVacuum = false;//是否使用真空吸附(加工前吸附,结束后放开)
|
|
|
|
|
|
m_ConcentricCnt = 0;//同心数据的数量
|
|
|
m_FirstGap = 0;//第一个拉伸尺寸
|
|
|
m_ConcentricGap = 0.05;//同心数据的间隔mm(大于0 向外)(小于0 向内)
|
|
|
|
|
|
m_RotatoAdjust = 0;//旋转调整mm
|
|
|
m_NoMarkCanWork = true;//没有定位点时也可以加工
|
|
|
m_bCheckObjDataConsistency = true;//是否检查数据的一致性(避免obj 数据不相等的情况)
|
|
|
|
|
|
m_bWorkStop = false;//工作是否停止
|
|
|
|
|
|
m_FindOriginTimes = 5;//自动回原点的加工次数(大于0 时生效)
|
|
|
m_CurWorktimes = 1;//当前的加工次数
|
|
|
|
|
|
m_bStartWorkMsg = true;//加工前提示
|
|
|
m_AllWorkExecTimes = 1;//重复执行次数(用来拷机)
|
|
|
m_CurWorkExecTimes = 0;//当前执行次数(用来拷机)
|
|
|
|
|
|
m_bCollectSpecialObj = false;//是否正在收集特殊对象数据
|
|
|
m_bStretchDataToRealSize = false;//根据抓取结果拉伸数据
|
|
|
}
|
|
|
CCommonFlowMgr::~CCommonFlowMgr(void)
|
|
|
{
|
|
|
}
|
|
|
CMFCPropertyGridProperty * CCommonFlowMgr::CreatGridProperty()
|
|
|
{
|
|
|
CString PropertyName;//属性名称
|
|
|
CString Description;//描述
|
|
|
CString Path = _T("CommonFlowMgr");;//存储路径
|
|
|
CString Name;
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
PropertyName = _T("常用流程");
|
|
|
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
|
|
|
if (gAuthorityMgr->CheckAuthority(_FACTORY))
|
|
|
{
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bSetLightState");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bSetLightState);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("状态灯");
|
|
|
Description = _T("是否设置警示灯状态");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bSetLightState, Description);
|
|
|
pGroup->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bStartWorkMsg");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bStartWorkMsg);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("加工前提示");
|
|
|
Description = _T("加工前是否需要对话框确认");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bStartWorkMsg, Description);
|
|
|
pGroup->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_AllWorkExecTimes");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_AllWorkExecTimes);
|
|
|
pPropertie->SetType(_PROP_TYPE_INT);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("拷机次数");
|
|
|
Description = _T("启动加工时重复执行的次数,用来拷机");
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_AllWorkExecTimes, Description);
|
|
|
pGroup->AddSubItem(p1);
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_FindOriginTimes");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_FindOriginTimes);
|
|
|
pPropertie->SetType(_PROP_TYPE_INT);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("回原点次数");
|
|
|
Description = _T("每加工多少次回一次原点(大于0 时生效)");
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_FindOriginTimes, Description);
|
|
|
pGroup->AddSubItem(p1);
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_AlamDelay");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_AlamDelay);
|
|
|
pPropertie->SetType(_PROP_TYPE_INT);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("蜂鸣器延时");
|
|
|
Description = _T("蜂鸣器提示的延时时间(ms)");
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_AlamDelay, Description);
|
|
|
pGroup->AddSubItem(p1);
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bCheckObjDataConsistency");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bCheckObjDataConsistency);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("检查数据一致");
|
|
|
Description = _T("是否检查数据的一致性(避免obj 数据不相等的情况)");
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bCheckObjDataConsistency, Description);
|
|
|
pGroup->AddSubItem(p1);
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_NoMarkCanWork");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_NoMarkCanWork);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("无定位加工");
|
|
|
Description = _T("没有定位点时也可以加工");
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_NoMarkCanWork, Description);
|
|
|
pGroup->AddSubItem(p1);
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
}
|
|
|
}
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
{
|
|
|
{
|
|
|
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("设备初始化"));
|
|
|
if (gAuthorityMgr->CheckAuthority(_FACTORY))
|
|
|
{
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bIniConfirmMsgBox");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bIniConfirmMsgBox);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("初始化msgbox");
|
|
|
Description = _T("是否弹出对话框确认");
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bIniConfirmMsgBox, Description);
|
|
|
pGroup1->AddSubItem(p1);
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bIniPlatfrom");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bIniPlatfrom);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("初始化平台");
|
|
|
Description = _T("是否初始化XY 电机平台");
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bIniPlatfrom, Description);
|
|
|
pGroup1->AddSubItem(p1);
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bIniMotorX");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bIniMotorX);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("初始化电机X");
|
|
|
Description = _T("是否初始化电机X");
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bIniMotorX, Description);
|
|
|
pGroup1->AddSubItem(p1);
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bIniMotorY");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bIniMotorY);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("初始化电机Y");
|
|
|
Description = _T("是否初始化电机Y");
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bIniMotorY, Description);
|
|
|
pGroup1->AddSubItem(p1);
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bIniMotorZ");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bIniMotorZ);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("初始化电机Z");
|
|
|
Description = _T("是否初始化电机Z");
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bIniMotorZ, Description);
|
|
|
pGroup1->AddSubItem(p1);
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bInitedToProductPt");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bInitedToProductPt);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("回上料点");
|
|
|
Description = _T("初始化完成后是否返回上料点");
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bInitedToProductPt, Description);
|
|
|
pGroup1->AddSubItem(p1);
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
}
|
|
|
pGroup->AddSubItem(pGroup1);
|
|
|
}
|
|
|
}
|
|
|
{
|
|
|
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("大幅面加工"));
|
|
|
if (gAuthorityMgr->CheckAuthority(_FACTORY))
|
|
|
{
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bStretchDataToRealSize");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bStretchDataToRealSize);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("自动拉伸");
|
|
|
Description = _T("是否根据抓取mark 结果自动拉伸产品尺寸");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bStretchDataToRealSize, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_AdjustOffset_X");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_AdjustOffset.x);
|
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("偏移微调X");
|
|
|
Description = _T("整体数据偏移微调X (mm)");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_AdjustOffset.x, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_AdjustOffset_Y");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_AdjustOffset.y);
|
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("偏移微调Y");
|
|
|
Description = _T("整体数据偏移微调Y(mm)");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_AdjustOffset.y, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_SizeAdjust_X");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_SizeAdjust.x);
|
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("尺寸微调X");
|
|
|
Description = _T("产品尺寸微调X (mm)");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_SizeAdjust.x, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_SizeAdjust_Y");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_SizeAdjust.y);
|
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("尺寸微调Y");
|
|
|
Description = _T("产品尺寸微调Y(mm)");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_SizeAdjust.y, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
#if 0
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_RotatoAdjust");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_RotatoAdjust);
|
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("旋转调整");
|
|
|
Description = _T("旋转调整(mm)");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_RotatoAdjust, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
#endif
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bFocalAdjust");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bFocalAdjust);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("实时变焦");
|
|
|
Description = _T("加工的时候是否实时调整焦距,用于加工比较厚的产品(并且Z 轴电动)");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bFocalAdjust, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_FocalAdjustCnt");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_FocalAdjustCnt);
|
|
|
pPropertie->SetType(_PROP_TYPE_INT);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("变焦次数");
|
|
|
Description = _T("用于比较厚的产品,加工一次调整焦距,再次加工");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_FocalAdjustCnt, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_FocalAdjustDis");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_FocalAdjustDis);
|
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("变焦距离");
|
|
|
Description = _T("对应变焦次数每次焦距调整的距离,向上为正,向下为负(单位:mm)");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_FocalAdjustDis, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bConnectObj");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bConnectObj);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("连接obj 数据");
|
|
|
Description = _T("是否连接多个obj 的数据");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bConnectObj, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_ConcentricCnt");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_ConcentricCnt);
|
|
|
pPropertie->SetType(_PROP_TYPE_INT);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("同心数量");
|
|
|
Description = _T("创建同心数据的数量,等于1 的时候只有一个圆,间隔就可以调整obj 数据的尺寸");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_ConcentricCnt, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_FirstGap");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_FirstGap);
|
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("Frist 拉伸间隔");
|
|
|
Description = _T("改变原件尺寸的间隔");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_FirstGap, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_ConcentricGap");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_ConcentricGap);
|
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("同心间隔");
|
|
|
Description = _T("创建同心数据的间隔mm(大于0 向外)");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_ConcentricGap, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bBackToProductPt");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bBackToProductPt);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("回上料点");
|
|
|
Description = _T("加工完成后平台是否返回上料点");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bBackToProductPt, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
pGroup->AddSubItem(pGroup1);
|
|
|
}
|
|
|
}
|
|
|
{
|
|
|
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("平台切割"));
|
|
|
if (gAuthorityMgr->CheckAuthority(_FACTORY))
|
|
|
{
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_bUseLaser");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_bUseLaser);
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("开关激光");
|
|
|
Description = _T("为FALSE 的时候只移动平台");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bUseLaser, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
pGroup->AddSubItem(pGroup1);
|
|
|
}
|
|
|
}
|
|
|
{
|
|
|
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("振镜校准"));
|
|
|
if (gAuthorityMgr->CheckAuthority(_FACTORY))
|
|
|
{
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_CalibrationRange");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_CalibrationRange);
|
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("校准范围");
|
|
|
Description = _T("振镜校准的范围(mm)");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_CalibrationRange, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
{
|
|
|
//添加属性变量映射
|
|
|
Name = _T("m_CalibrationPointGap");//变量名字
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
pPropertie->SetpVal((void*)&m_CalibrationPointGap);
|
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
|
pPropertie->SetpModule(this);
|
|
|
pPropertie->SetPath(Path);
|
|
|
pPropertie->SetName(Name);
|
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
|
|
|
//添加属性显示
|
|
|
PropertyName = _T("点间距");
|
|
|
Description = _T("测量打点之间的间隔(mm)");
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_CalibrationPointGap, Description);
|
|
|
pGroup1->AddSubItem(p);
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
}
|
|
|
pGroup->AddSubItem(pGroup1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return pGroup;
|
|
|
}
|
|
|
void CCommonFlowMgr::Ini()
|
|
|
{
|
|
|
m_CurCamera = gCameraHawkvis;//绑定当前使用的相机
|
|
|
}
|
|
|
#if 1
|
|
|
void CCommonFlowMgr::WriteWorkFileExt(vector<CLab> &LabVec)
|
|
|
{
|
|
|
LabVec.push_back(CLab(LAB_ONE_OBJ_CUT_TIMES, m_OneObjMarkCnt));
|
|
|
LabVec.push_back(CLab(LAB_SPECIAL_ONE_OBJ_CUT_TIMES, m_SpecialOneObjMarkCnt));
|
|
|
LabVec.push_back(CLab(LAB_ONE_AREA_CUT_TIMES, m_AreaCycleCnt));
|
|
|
LabVec.push_back(CLab(LAB_ONE_CUT_SPEED, m_CutSpeed));
|
|
|
LabVec.push_back(CLab(LAB_ADJUST_OFFSET_X, m_Jig2PrtOft.x));
|
|
|
LabVec.push_back(CLab(LAB_ADJUST_OFFSET_Y, m_Jig2PrtOft.y));
|
|
|
}
|
|
|
void CCommonFlowMgr::ReadWorkFile(CLabVecRang &LabVecRang)
|
|
|
{
|
|
|
CWorkFileMgr WorkFileMgr;
|
|
|
{
|
|
|
CLab Lab = WorkFileMgr.FindLab(LabVecRang, LAB_ONE_OBJ_CUT_TIMES);
|
|
|
if (Lab.m_ValType != _TYPE_NULL)
|
|
|
{
|
|
|
m_OneObjMarkCnt = Lab.m_Int;
|
|
|
}
|
|
|
}
|
|
|
{
|
|
|
CLab Lab = WorkFileMgr.FindLab(LabVecRang, LAB_SPECIAL_ONE_OBJ_CUT_TIMES);
|
|
|
if (Lab.m_ValType != _TYPE_NULL)
|
|
|
{
|
|
|
m_SpecialOneObjMarkCnt = Lab.m_Int;
|
|
|
}
|
|
|
}
|
|
|
{
|
|
|
CLab Lab = WorkFileMgr.FindLab(LabVecRang, LAB_ONE_AREA_CUT_TIMES);
|
|
|
if (Lab.m_ValType != _TYPE_NULL)
|
|
|
{
|
|
|
m_AreaCycleCnt = Lab.m_Int;
|
|
|
}
|
|
|
}
|
|
|
{
|
|
|
CLab Lab = WorkFileMgr.FindLab(LabVecRang, LAB_ONE_CUT_SPEED);
|
|
|
if (Lab.m_ValType != _TYPE_NULL)
|
|
|
{
|
|
|
m_CutSpeed = Lab.m_Int;
|
|
|
}
|
|
|
}
|
|
|
{
|
|
|
CLab Lab = WorkFileMgr.FindLab(LabVecRang, LAB_ADJUST_OFFSET_X);
|
|
|
if (Lab.m_ValType != _TYPE_NULL)
|
|
|
{
|
|
|
m_Jig2PrtOft.x = Lab.m_Double;
|
|
|
}
|
|
|
}
|
|
|
{
|
|
|
CLab Lab = WorkFileMgr.FindLab(LabVecRang, LAB_ADJUST_OFFSET_Y);
|
|
|
if (Lab.m_ValType != _TYPE_NULL)
|
|
|
{
|
|
|
m_Jig2PrtOft.y = Lab.m_Double;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
#if 1
|
|
|
bool CCommonFlowMgr::StartWorkConfirm(bool bSelMark)
|
|
|
{
|
|
|
if (!m_bStartWorkMsg)
|
|
|
return true;
|
|
|
|
|
|
CString str;
|
|
|
if (bSelMark)
|
|
|
str = "开始选择切割?";
|
|
|
else
|
|
|
str = "开始全部切割?";
|
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
return MsgBox.ConfirmOkCancel(str);
|
|
|
}
|
|
|
//是否需要再次执行
|
|
|
bool CCommonFlowMgr::IsNeedExecAgain()
|
|
|
{
|
|
|
//查询的是否累加当前次数
|
|
|
m_CurWorkExecTimes++;
|
|
|
if (m_CurWorkExecTimes >= m_AllWorkExecTimes)
|
|
|
{
|
|
|
m_CurWorkExecTimes = 0;//重置
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
//设置警示灯
|
|
|
void CCommonFlowMgr::SetLightStateCmd(CWorkCmdContainer &CmdContainer, bool bStart)
|
|
|
{
|
|
|
if (!m_bSetLightState)
|
|
|
return;
|
|
|
#if 1
|
|
|
if (bStart)
|
|
|
{
|
|
|
//关闭所有灯和蜂鸣器
|
|
|
{
|
|
|
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_LIGHT_R, false);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
{
|
|
|
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_LIGHT_Y, false);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
{
|
|
|
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_LIGHT_G, false);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
{
|
|
|
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_ALARM, false);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
}
|
|
|
else//结束
|
|
|
{
|
|
|
//亮黄灯------------------------------------
|
|
|
{
|
|
|
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_LIGHT_Y, true);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
{
|
|
|
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_LIGHT_R, false);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
{
|
|
|
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_LIGHT_G, false);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//蜂鸣器提示-----------------------------
|
|
|
{
|
|
|
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_ALARM, true);
|
|
|
pCmd->SetAfterDelay(m_AlamDelay);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
{
|
|
|
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_ALARM, false);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
|
|
|
}
|
|
|
//设置警示灯
|
|
|
void CCommonFlowMgr::SetLightStateCmd(bool bStart)
|
|
|
{
|
|
|
if (!m_bSetLightState)
|
|
|
return;
|
|
|
|
|
|
CCommPortMgr com;
|
|
|
//打开串口
|
|
|
if (com.Open(gPlcIOMgr->GetComPort(), 115200) == false)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
CString strY = "$(KQ1)#";//黄灯
|
|
|
CString strG = "$(KQ2)#";//绿灯
|
|
|
CString strR = "$(KQ3)#";//红灯
|
|
|
|
|
|
CString str;
|
|
|
com.Write(str);
|
|
|
if (bStart)
|
|
|
{
|
|
|
str = strG + char(13) + char(10);
|
|
|
com.Write(str);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = strR + char(13) + char(10);
|
|
|
com.Write(str);
|
|
|
Sleep(m_AlamDelay);
|
|
|
str = strY + char(13) + char(10);
|
|
|
com.Write(str);
|
|
|
}
|
|
|
com.Close();
|
|
|
}
|
|
|
|
|
|
//初始化设备(平台,Z 轴)
|
|
|
bool CCommonFlowMgr::InitDevice()
|
|
|
{
|
|
|
CMsgBox MsgBox;
|
|
|
if (m_bIniConfirmMsgBox)
|
|
|
{
|
|
|
if (MsgBox.ConfirmOkCancel(_T("初始化设备?")) == false)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
CDeviceState &DeviceState = CDeviceState::GetInstance();
|
|
|
DeviceState.SetIniState(false);
|
|
|
|
|
|
//初始化的时候不检查平台范围
|
|
|
bool OldbUseMoveRange = gPlatformXY->GetbUseMoveRange();
|
|
|
gPlatformXY->SetbUseMoveRange(false);
|
|
|
|
|
|
//关闭激光端口
|
|
|
gPciCh365Mgr->CloseLaserPort();
|
|
|
|
|
|
gLogMgr->WriteDebugLog("Fuc---->InitDevice");
|
|
|
|
|
|
CWorkCmdInvoker Invoker;
|
|
|
CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();//指令集
|
|
|
CmdContainer.Clear();
|
|
|
|
|
|
//设置电机速度
|
|
|
{
|
|
|
CWorkCmdSetMotorSpeed *pCmd = new CWorkCmdSetMotorSpeed();
|
|
|
pCmd->SetbSetMotorX();
|
|
|
pCmd->SetbSetMotorX2();
|
|
|
pCmd->SetbSetMotorY();
|
|
|
pCmd->SetbSetMotorZ();
|
|
|
pCmd->SetSpeedType(_SpeedType_Org);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//反向移动一段距离
|
|
|
if (m_bIniMotorZ)
|
|
|
{
|
|
|
CMotor *pMotorZ = CMotor::GetMotor(MOTOR_Z);
|
|
|
double Dis = pMotorZ->GetReverseMoveDis();
|
|
|
CWorkCmdMoveMotor *pCmd = new CWorkCmdMoveMotor(*pMotorZ, Dis);
|
|
|
pCmd->SetMoveFlg(true);//移动一段距离
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
if (m_bIniMotorZ)//等待移动结束
|
|
|
{
|
|
|
CWorkCmdWaitMotorStop *pCmd = new CWorkCmdWaitMotorStop();
|
|
|
pCmd->SetbWaitMotorZ();
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
if (m_bIniMotorZ)
|
|
|
{
|
|
|
CWorkCmdMotorToMachineOrigin *pCmd = new CWorkCmdMotorToMachineOrigin(*(CMotor::GetMotor("Z")));
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//等待运动结束
|
|
|
if (m_bIniMotorZ)
|
|
|
{
|
|
|
CWorkCmdWaitMotorStop *pCmd = new CWorkCmdWaitMotorStop();
|
|
|
pCmd->SetbWaitMotorZ();
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//XY 平台相关------------------------------------------------------------
|
|
|
if (m_bIniPlatfrom)
|
|
|
{
|
|
|
if (m_bIniMotorX)
|
|
|
{
|
|
|
CWorkCmdMotorToMachineOrigin *pCmd = new CWorkCmdMotorToMachineOrigin(*(CMotor::GetMotor("X")));
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
if (m_bIniMotorX)
|
|
|
{
|
|
|
CWorkCmdMotorToMachineOrigin *pCmd = new CWorkCmdMotorToMachineOrigin(*(CMotor::GetMotor("X2")));
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
if (m_bIniMotorY)
|
|
|
{
|
|
|
CWorkCmdMotorToMachineOrigin *pCmd = new CWorkCmdMotorToMachineOrigin(*(CMotor::GetMotor("Y")));
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//等待运动结束
|
|
|
{
|
|
|
CWorkCmdWaitMotorStop *pCmd = new CWorkCmdWaitMotorStop();
|
|
|
pCmd->SetbWaitMotorX();
|
|
|
pCmd->SetbWaitMotorX2();
|
|
|
pCmd->SetbWaitMotorY();
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//重置所有轴的错误状态
|
|
|
{
|
|
|
CWorkCmdResetAllMotorErr *pCmd = new CWorkCmdResetAllMotorErr();
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
|
|
|
//设置电机速度
|
|
|
{
|
|
|
CWorkCmdSetMotorSpeed *pCmd = new CWorkCmdSetMotorSpeed();
|
|
|
pCmd->SetbSetMotorX();
|
|
|
pCmd->SetbSetMotorX2();
|
|
|
pCmd->SetbSetMotorY();
|
|
|
pCmd->SetbSetMotorZ();
|
|
|
pCmd->SetSpeedType(_SpeedType_Move);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//移动到原点偏移位置
|
|
|
if (m_bIniMotorY)
|
|
|
{
|
|
|
CWorkCmdMotorToOffsetPos *pCmd = new CWorkCmdMotorToOffsetPos(*(CMotor::GetMotor("Y")));
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
if (m_bIniMotorX)
|
|
|
{
|
|
|
CWorkCmdMotorToOffsetPos *pCmd = new CWorkCmdMotorToOffsetPos(*(CMotor::GetMotor("X")));
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
if (m_bIniMotorX)
|
|
|
{
|
|
|
CWorkCmdMotorToOffsetPos *pCmd = new CWorkCmdMotorToOffsetPos(*(CMotor::GetMotor("X2")));
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//等待运动结束
|
|
|
{
|
|
|
CWorkCmdWaitMotorStop *pCmd = new CWorkCmdWaitMotorStop();
|
|
|
pCmd->SetbWaitMotorX();
|
|
|
pCmd->SetbWaitMotorX2();
|
|
|
pCmd->SetbWaitMotorY();
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
}
|
|
|
if (m_bIniMotorZ)
|
|
|
{
|
|
|
CWorkCmdMotorToOffsetPos *pCmd = new CWorkCmdMotorToOffsetPos(*(CMotor::GetMotor("Z")));
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//等待运动结束
|
|
|
if (m_bIniMotorZ)
|
|
|
{
|
|
|
CWorkCmdWaitMotorStop *pCmd = new CWorkCmdWaitMotorStop();
|
|
|
pCmd->SetbWaitMotorZ();
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//重置设备状态(设置当前点为原点)
|
|
|
{
|
|
|
CWorkCmdDeviceParReset *pCmd = new CWorkCmdDeviceParReset;
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
|
|
|
//执行指令-----------------------------------------------------
|
|
|
Invoker.ExcuteAllCmd();
|
|
|
//恢复
|
|
|
gPlatformXY->SetbUseMoveRange(OldbUseMoveRange);
|
|
|
|
|
|
bool Ret = !Invoker.IsCancel();
|
|
|
if (Ret)
|
|
|
{
|
|
|
gCameraHawkvis->OpenCamera();
|
|
|
}
|
|
|
return Ret;
|
|
|
}
|
|
|
//普通的振镜打标功能(layer 中的图形数据,平台不移动)
|
|
|
//使用pci 卡(times 加工次数) (CyclicTimes 循环次数)
|
|
|
bool CCommonFlowMgr::NormalMarkByPciCard(bool bSel, int times, int CyclicTimes)
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("Fuc---->NormalMarkByPciCard : bSel = " + Bool2Str(bSel));
|
|
|
//临时Product
|
|
|
CProduct Product;
|
|
|
Product.m_bManualMark = true;
|
|
|
//创建一个临时的area
|
|
|
CMarkArea MarkArea(Dbxy(0, 0), DbSize(100, 100));
|
|
|
//收集加工数据
|
|
|
MarkArea.CollectOrgWorkData(bSel, Product);
|
|
|
MarkArea.CollectWorkData(bSel, Product);
|
|
|
|
|
|
if (MarkArea.HasWorkData())
|
|
|
{
|
|
|
for (int k = 0;k < CyclicTimes;k++)
|
|
|
{
|
|
|
CWorkCmdInvoker Invoker;
|
|
|
CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();//指令集
|
|
|
CmdContainer.Clear();
|
|
|
CWorkCmdMarkArea *pCmd = new CWorkCmdMarkArea(MarkArea);
|
|
|
pCmd->CreatWorkDataByTimes(times);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
//执行指令-----------------------------------------------------
|
|
|
Invoker.ExcuteAllCmd(false);//不要在新线程中执行
|
|
|
if (Invoker.IsCancel())
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
gLogMgr->WriteDebugLog("Error---->Not Have Wrok Data");
|
|
|
return false;
|
|
|
}
|
|
|
//移动到第一个area (不等待移动结束)
|
|
|
void CCommonFlowMgr::MoveToFirstArea()
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("Fuc---->MoveToFirstArea");
|
|
|
CWorkCmdContainer CmdContainer;
|
|
|
//第一个area 用空移速度
|
|
|
{
|
|
|
CWorkCmdSetMotorSpeed *pCmd = new CWorkCmdSetMotorSpeed();
|
|
|
if (gMotionCard_PCI1245->GetCurGpIdx() == 0)
|
|
|
pCmd->SetbSetMotorX();
|
|
|
else
|
|
|
pCmd->SetbSetMotorX2();
|
|
|
|
|
|
pCmd->SetbSetMotorY();
|
|
|
pCmd->SetSpeedType(_SpeedType_Move);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
vector<CMarkArea> &AreaVec = gMarkAreaMgr->GetAreaVec();
|
|
|
if (AreaVec.empty())
|
|
|
return;
|
|
|
|
|
|
Dbxy TargetPt = gLaser->GetCoord();//加工中心点
|
|
|
//移动area 中心点到振镜中心
|
|
|
{
|
|
|
Dbxy AreaRealBasePt = AreaVec[0].GetRealBasePt();//移动到实际位置
|
|
|
Dbxy MovePt;//移动点= area 的理论点
|
|
|
MovePt.x = AreaRealBasePt.x;
|
|
|
MovePt.y = AreaRealBasePt.y;
|
|
|
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
|
|
|
pCmd->MoveToTargetPt(MovePt, TargetPt);
|
|
|
pCmd->InWorkState();
|
|
|
pCmd->SetAfterDelay(500);//执行后强制等待
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
|
|
|
CWorkCmdInvoker Invoker;
|
|
|
Invoker.Excute(CmdContainer);
|
|
|
}
|
|
|
//大幅面拼接打标(平台移动,振镜拼接,数据为obj 对象) (bSel ==true 的时候为选择打标)
|
|
|
bool CCommonFlowMgr::MultipleAreaMark(CProduct &Product, bool bSel)
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("Fuc---->MultipleAreaMark : bSel = " + Bool2Str(bSel));
|
|
|
|
|
|
//搜集加工数据(这里比较耗费时间)
|
|
|
gMarkAreaMgr->CollectWorkData(bSel, Product);
|
|
|
if (!gMarkAreaMgr->HasWorkData())
|
|
|
return false;
|
|
|
|
|
|
gProductMgr->WorkTimesInc();
|
|
|
return true;//全部加工一次才返回true
|
|
|
}
|
|
|
//通过平台走位来切割layer 中的图形(激光不动,只动平台)
|
|
|
bool CCommonFlowMgr::CutShapeByPlatform(CProduct &Product, bool bSel)
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("Fuc---->CutShapeByPlatform : bSel = " + Bool2Str(bSel));
|
|
|
//搜集加工数据----------------------------
|
|
|
gMarkAreaMgr->CollectWorkData(bSel, Product);
|
|
|
if (!gMarkAreaMgr->HasWorkData())
|
|
|
return false;
|
|
|
|
|
|
CWorkCmdInvoker Invoker;
|
|
|
CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();//指令集
|
|
|
CmdContainer.Clear();
|
|
|
|
|
|
Dbxy TargetPt = gLaser->GetCoord();//加工中心点
|
|
|
//使用数据来创建工作流程
|
|
|
vector<CMarkArea> &AreaVec = gMarkAreaMgr->GetAreaVec();
|
|
|
vector<CMarkArea>::iterator iter = AreaVec.begin();
|
|
|
vector<CMarkArea>::iterator iter_end = AreaVec.end();
|
|
|
for (;iter != iter_end;iter++)
|
|
|
{
|
|
|
vector<vector<Dbxy>> &Vec = (*iter).GetDataVec();
|
|
|
vector<vector<Dbxy>>::iterator iter1 = Vec.begin();
|
|
|
vector<vector<Dbxy>>::iterator iter1_end = Vec.end();
|
|
|
for (int i = 0;iter1 != iter1_end;i++, iter1++)
|
|
|
{
|
|
|
vector<Dbxy>::iterator iter2 = (*iter1).begin();
|
|
|
vector<Dbxy>::iterator iter2_end = (*iter1).end();
|
|
|
for (;iter2 != iter2_end;iter2++)
|
|
|
{
|
|
|
//移动平台---------------------------------------------
|
|
|
{
|
|
|
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
|
|
|
pCmd->MoveToTargetPt((*iter2), TargetPt);
|
|
|
if (iter2 != (*iter1).begin())//移动到第一个点是空移
|
|
|
{
|
|
|
pCmd->InWorkState();//其他点是工作点
|
|
|
}
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
if (m_bUseLaser)
|
|
|
{
|
|
|
if (iter2 == (*iter1).begin())//开激光
|
|
|
{
|
|
|
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_LASER, true);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (m_bUseLaser)//关激光
|
|
|
{
|
|
|
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_LASER, false);
|
|
|
pCmd->CanNotCancel();//不能取消
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//执行指令-----------------------------------------------------
|
|
|
Invoker.ExcuteAllCmd();
|
|
|
return !Invoker.IsCancel();
|
|
|
}
|
|
|
#endif
|
|
|
#if 1
|
|
|
//CCD 识别触发,并计算连续两个点的距离
|
|
|
bool CCommonFlowMgr::CameraCatch()
|
|
|
{
|
|
|
CCamera &Camera = *m_CurCamera;
|
|
|
CWorkCmdInvoker Invoker;
|
|
|
CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();//指令集
|
|
|
CmdContainer.Clear();
|
|
|
|
|
|
vector<Dbxy> ResultVec;
|
|
|
//抓取--------------------------------------------------------
|
|
|
{
|
|
|
CWorkCmdCameraCatch *pCmd = new CWorkCmdCameraCatch(Camera);
|
|
|
pCmd->SetResultVec(ResultVec);//绑定结果容器
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//执行指令-----------------------------------------------------
|
|
|
Invoker.ExcuteAllCmd(false);//不要在新线程中执行
|
|
|
|
|
|
if (!ResultVec.empty())
|
|
|
{
|
|
|
gMeasureMgr.SetNewPt(ResultVec[0]);//设置测量点
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
//抓取两个mark 点,计算产品的偏移和旋转(结果保存在Product )
|
|
|
bool CCommonFlowMgr::CameraCatchTwoMark()
|
|
|
{
|
|
|
CDeviceState &DeviceState = CDeviceState::GetInstance();
|
|
|
if (!DeviceState.CheckInitState())
|
|
|
return false;
|
|
|
|
|
|
bool ret = true;
|
|
|
vector<CProduct> &ProductVec = gProductMgr->GetProductVec();
|
|
|
int size = ProductVec.size();
|
|
|
for (int i = 0;i < size;i++)
|
|
|
{
|
|
|
CProduct &Product = ProductVec[i];
|
|
|
Dbxy MarkPt1;
|
|
|
Dbxy MarkPt2;
|
|
|
if (gObjComponentMgr->GetTwoMarkPt(MarkPt1, MarkPt2))//获取定位点
|
|
|
{
|
|
|
Product.SetTheoryMarkPt(MarkPt1, MarkPt2);//设置定位点
|
|
|
CameraCatchMarkExt(Product);
|
|
|
}
|
|
|
else//没有两个定位点
|
|
|
{
|
|
|
ret = false;
|
|
|
//设置默认偏移
|
|
|
Product.UseDefualtOffset();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
void CCommonFlowMgr::CameraCatchTwoMark(CProduct &Product)
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("CCommonFlowMgr::CameraCatchTwoMark");
|
|
|
Dbxy MarkPt1;
|
|
|
Dbxy MarkPt2;
|
|
|
if (gObjComponentMgr->GetTwoMarkPt(MarkPt1, MarkPt2))//从ObjComponent 中获取定位点
|
|
|
{
|
|
|
Product.SetTheoryMarkPt(MarkPt1, MarkPt2);//设置定位点
|
|
|
CameraCatchMarkExt(Product);
|
|
|
}
|
|
|
else//没有两个定位点
|
|
|
{
|
|
|
//设置默认偏移
|
|
|
Product.UseDefualtOffset();
|
|
|
}
|
|
|
}
|
|
|
//识别定位点3
|
|
|
bool CCommonFlowMgr::CameraCatchMark3(CProduct &Product)
|
|
|
{
|
|
|
CCamera &Camera = *m_CurCamera;
|
|
|
gLogMgr->WriteDebugLog("Fuc---->CameraCatchMark3");
|
|
|
//获取mark 坐标的大致位置
|
|
|
Dbxy MarkPt3;
|
|
|
//移动目标点(ccd 的中心)
|
|
|
Dbxy CameraPt = Camera.GetCenterPt();
|
|
|
|
|
|
CWorkCmdInvoker Invoker;
|
|
|
CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();//指令集
|
|
|
CmdContainer.Clear();
|
|
|
//设置电机移动速度
|
|
|
{
|
|
|
CWorkCmdSetMotorSpeed *pCmd = new CWorkCmdSetMotorSpeed();
|
|
|
if (gMotionCard_PCI1245->GetCurGpIdx() == 0)
|
|
|
pCmd->SetbSetMotorX();
|
|
|
else
|
|
|
pCmd->SetbSetMotorX2();
|
|
|
pCmd->SetbSetMotorY();
|
|
|
pCmd->SetSpeedType(_SpeedType_Move);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//如果有mark3 先识别mark3
|
|
|
Product.SetbHasMarkPt3(false);
|
|
|
if (gObjComponentMgr->GetMark3Pt(MarkPt3))
|
|
|
{
|
|
|
Product.SetbHasMarkPt3(true);
|
|
|
Product.SetTheoryMark3Pt(MarkPt3);
|
|
|
//移动mark 1 到CCD 中心
|
|
|
{
|
|
|
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
|
|
|
pCmd->MoveToTargetPt(MarkPt3, CameraPt);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//等待运动结束
|
|
|
{
|
|
|
CWorkCmdWaitMotorStop *pCmd = new CWorkCmdWaitMotorStop();
|
|
|
if (gMotionCard_PCI1245->GetCurGpIdx() == 0)
|
|
|
pCmd->SetbWaitMotorX();
|
|
|
else
|
|
|
pCmd->SetbWaitMotorX2();
|
|
|
pCmd->SetbWaitMotorY();
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//抓取mark 点3
|
|
|
{
|
|
|
CWorkCmdCameraCatch *pCmd = new CWorkCmdCameraCatch(Camera);
|
|
|
pCmd->SetFrontDelay(Camera.GetCatchFrontDelay());
|
|
|
pCmd->SetProduct(Product);
|
|
|
pCmd->SetbCatchMark3(true);//标识抓取mark3
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
}
|
|
|
//执行指令-----------------------------------------------------
|
|
|
Invoker.ExcuteAllCmd(false);//不要在新线程中执行
|
|
|
if (Invoker.IsCancel())//中断的时候重置
|
|
|
{
|
|
|
Product.ResetRealMarkPt();
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
void CCommonFlowMgr::MarkAreaByIdx(int AreaIndex)
|
|
|
{
|
|
|
vector<CMarkArea> &AreaVec = gMarkAreaMgr->GetAreaVec();
|
|
|
if (AreaVec.size() == 0)
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("No Mark Data.");
|
|
|
return;
|
|
|
}
|
|
|
if (AreaVec[AreaIndex].HasWorkData())//只加工有数据的area
|
|
|
{
|
|
|
CWorkCmdInvoker Invoker;
|
|
|
CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();//指令集
|
|
|
CmdContainer.Clear();
|
|
|
CWorkCmdMarkArea *pCmd = new CWorkCmdMarkArea(AreaVec[AreaIndex]);
|
|
|
//pCmd->SetbSelMark(bSel);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
Invoker.ExcuteAllCmd();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
bool CCommonFlowMgr::CameraCatchMarkExt(CProduct &Product)
|
|
|
{
|
|
|
CCamera &Camera = *m_CurCamera;
|
|
|
gLogMgr->WriteDebugLog("Fuc---->CameraCatchTwoMark");
|
|
|
//获取mark 坐标的大致位置
|
|
|
Dbxy MarkPt1, MarkPt2, MarkPt3;
|
|
|
Product.GetMarkCoord(MarkPt1, MarkPt2);
|
|
|
//移动目标点(ccd 的中心)
|
|
|
Dbxy CameraPt = Camera.GetCenterPt();
|
|
|
|
|
|
CWorkCmdInvoker Invoker;
|
|
|
CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();//指令集
|
|
|
CmdContainer.Clear();
|
|
|
//设置电机移动速度
|
|
|
{
|
|
|
CWorkCmdSetMotorSpeed *pCmd = new CWorkCmdSetMotorSpeed();
|
|
|
if (gMotionCard_PCI1245->GetCurGpIdx() == 0)
|
|
|
pCmd->SetbSetMotorX();
|
|
|
else
|
|
|
pCmd->SetbSetMotorX2();
|
|
|
pCmd->SetbSetMotorY();
|
|
|
pCmd->SetSpeedType(_SpeedType_Move);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//识别mark1 和mark2
|
|
|
if (!Product.IsSetRealMarkPt1() || (Product.IsSetRealMarkPt1() && Product.IsSetRealMarkPt2()))
|
|
|
{
|
|
|
//移动mark 1 到CCD 中心
|
|
|
{
|
|
|
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
|
|
|
pCmd->MoveToTargetPt(MarkPt1, CameraPt);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//等待运动结束
|
|
|
{
|
|
|
CWorkCmdWaitMotorStop *pCmd = new CWorkCmdWaitMotorStop();
|
|
|
if (gMotionCard_PCI1245->GetCurGpIdx() == 0)
|
|
|
pCmd->SetbWaitMotorX();
|
|
|
else
|
|
|
pCmd->SetbWaitMotorX2();
|
|
|
pCmd->SetbWaitMotorY();
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//抓取mark 点1
|
|
|
{
|
|
|
CWorkCmdCameraCatch *pCmd = new CWorkCmdCameraCatch(Camera);
|
|
|
pCmd->SetFrontDelay(Camera.GetCatchFrontDelay());
|
|
|
pCmd->SetProduct(Product);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//移动mark 2 到CCD 中心
|
|
|
{
|
|
|
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
|
|
|
pCmd->MoveToTargetPt(MarkPt2, CameraPt);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//等待运动结束
|
|
|
{
|
|
|
CWorkCmdWaitMotorStop *pCmd = new CWorkCmdWaitMotorStop();
|
|
|
if (gMotionCard_PCI1245->GetCurGpIdx() == 0)
|
|
|
pCmd->SetbWaitMotorX();
|
|
|
else
|
|
|
pCmd->SetbWaitMotorX2();
|
|
|
pCmd->SetbWaitMotorY();
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//抓取mark 点2
|
|
|
{
|
|
|
CWorkCmdCameraCatch *pCmd = new CWorkCmdCameraCatch(Camera);
|
|
|
pCmd->SetProduct(Product);
|
|
|
pCmd->SetFrontDelay(Camera.GetCatchFrontDelay());
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
}
|
|
|
//执行指令-----------------------------------------------------
|
|
|
Invoker.ExcuteAllCmd(false);//不要在新线程中执行
|
|
|
if (Invoker.IsCancel())//中断的时候重置
|
|
|
{
|
|
|
Product.ResetRealMarkPt();
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/*测量校准用的vision.data
|
|
|
这个功能就是在marking_pci 不能测量时使用
|
|
|
1.先用marking_pci 软件打出校准点
|
|
|
2.用我的软件移动到第一个测量点(左下角)
|
|
|
3.开始测量即可得到vision.dat
|
|
|
4.再用marking_pci 去生成校准文件
|
|
|
*/
|
|
|
bool CCommonFlowMgr::AutoMeasureVisionData()
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("func---->AutoMeasureVisionData");
|
|
|
//创建移动点坐标序列
|
|
|
vector<Dbxy> PtVec;
|
|
|
Dbxy CurPlatCoord = gPlatformXY->GetCoord();//当前平台坐标
|
|
|
int PtCnt = m_CalibrationRange / m_CalibrationPointGap + 1;//一个方向的移动点数
|
|
|
|
|
|
CString LogStr;
|
|
|
LogStr.Format(_T("[振镜范围] = [%f] ,[点间隔] = [%f]"), m_CalibrationRange, m_CalibrationPointGap);
|
|
|
gLogMgr->WriteDebugLog(LogStr);
|
|
|
LogStr.Format(_T("[点数] = [%d]"), PtCnt*PtCnt);
|
|
|
gLogMgr->WriteDebugLog(LogStr);
|
|
|
|
|
|
for (int i = 0;i < PtCnt;i++)//列
|
|
|
{
|
|
|
for (int k = 0;k < PtCnt;k++)//行
|
|
|
{
|
|
|
Dbxy pt;
|
|
|
pt.x = CurPlatCoord.x - m_CalibrationPointGap*k;
|
|
|
pt.y = CurPlatCoord.y - m_CalibrationPointGap*i;
|
|
|
PtVec.push_back(pt);
|
|
|
}
|
|
|
}
|
|
|
//依次移动平台观察-----------------------------------
|
|
|
vector<Dbxy> ResultVec;//结果
|
|
|
MovePtToCamera(PtVec, ResultVec, true);
|
|
|
//结果输出到vision.dat 文件-----------------------------
|
|
|
if (!ResultVec.empty())
|
|
|
{
|
|
|
CString FilePath;
|
|
|
CFileMgr FileMgr;
|
|
|
FileMgr.GetFullFilePath(FilePath, "\\vision_data.dat");
|
|
|
|
|
|
ofstream file;
|
|
|
file.open(FilePath);
|
|
|
//输出范围和间隔
|
|
|
file << m_CalibrationRange << "," << m_CalibrationRange << "," << m_CalibrationPointGap << "," << m_CalibrationPointGap << endl;
|
|
|
FileMgr.WriteDbxyVecToFile(ResultVec, &file);
|
|
|
file.close();
|
|
|
//复制到打标软件目录
|
|
|
CString DestPath = "C:\\Program Files\\Laipu Soft\\Marking System\\vision_data.dat";
|
|
|
if (!CopyFile(FilePath, DestPath, false))
|
|
|
{
|
|
|
AfxMessageBox("自动复制vision_data.dat到打标软件目录失败!\r\n请手动复制!!!");
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//连续移动平台到一系列坐标,ResultVec保存抓取的结果
|
|
|
void CCommonFlowMgr::MovePtToCamera(vector<Dbxy> &PtVec, vector<Dbxy> &ResultVec, bool bCatch)
|
|
|
{
|
|
|
CCamera &Camera = *m_CurCamera;
|
|
|
|
|
|
CWorkCmdInvoker Invoker;
|
|
|
CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();//指令集
|
|
|
CmdContainer.Clear();
|
|
|
|
|
|
vector<Dbxy>::iterator iter = PtVec.begin();
|
|
|
vector<Dbxy>::iterator iter_end = PtVec.end();
|
|
|
for (;iter != iter_end;iter++)
|
|
|
{
|
|
|
//移动平台-------------------------------------------------
|
|
|
{
|
|
|
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
|
|
|
pCmd->MoveToTargetPt(Dbxy(0, 0), (*iter));
|
|
|
pCmd->InWorkState();//工作速度
|
|
|
pCmd->SetAfterDelay(300);//移动后延时
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//抓取--------------------------------------------------------
|
|
|
if (bCatch)
|
|
|
{
|
|
|
CWorkCmdCameraCatch *pCmd = new CWorkCmdCameraCatch(Camera);
|
|
|
pCmd->SetResultVec(ResultVec);//绑定结果容器
|
|
|
pCmd->SetFrontDelay(Camera.GetCatchFrontDelay());//抓取前延时
|
|
|
pCmd->SetAfterDelay(300);//移动后延时
|
|
|
pCmd->SetbAlam(false);//不要蜂鸣器提示
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
}
|
|
|
//执行指令-----------------------------------------------------
|
|
|
Invoker.ExcuteAllCmd(true);//在新线程中执行
|
|
|
|
|
|
}
|
|
|
//移动一个点到ccd 中心
|
|
|
void CCommonFlowMgr::MovePtToCamera(Dbxy pt)
|
|
|
{
|
|
|
CCamera &Camera = *m_CurCamera;
|
|
|
CWorkCmdInvoker Invoker;
|
|
|
CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();//指令集
|
|
|
CmdContainer.Clear();
|
|
|
//移动平台-------------------------------------------------
|
|
|
{
|
|
|
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
|
|
|
pCmd->MoveToTargetPt(Camera.GetCenterPt(), pt);
|
|
|
pCmd->InWorkState();//工作速度
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//抓取--------------------------------------------------------
|
|
|
{
|
|
|
CWorkCmdCameraCatch *pCmd = new CWorkCmdCameraCatch(Camera);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//执行指令-----------------------------------------------------
|
|
|
Invoker.ExcuteAllCmd(false);
|
|
|
}
|
|
|
//移动一颗obj 到CCD 观察(观察结束后将obj 设置为已观察)
|
|
|
void CCommonFlowMgr::MoveSelObjToCamera(CProduct &Product)
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("Fuc---->MoveSelObjToCamera");
|
|
|
CCamera &Camera = *m_CurCamera;
|
|
|
|
|
|
bool flg = false;
|
|
|
vector<CObjComponent>&ComponentVec = gObjComponentMgr->GetComponentVec();
|
|
|
vector<CObjComponent>::iterator iter = ComponentVec.begin();
|
|
|
vector<CObjComponent>::iterator iter_end = ComponentVec.end();
|
|
|
for (;iter != iter_end;iter++)
|
|
|
{
|
|
|
if ((*iter).IsSelected())
|
|
|
{
|
|
|
Dbxy pt = (*iter).GetBasePt();
|
|
|
pt = Product.TheoryPtToRealPt(pt);//计算实际位置
|
|
|
MovePtToCamera(pt);//移动观察
|
|
|
(*iter).SetSelected(false);
|
|
|
flg = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (flg)
|
|
|
GetCurViewPtr()->RefreshView();
|
|
|
}
|
|
|
#endif
|
|
|
void CCommonFlowMgr::SetAdjustOffsetAll(Dbxy Offset)
|
|
|
{
|
|
|
auto JigOft = m_Jig2PrtOft;
|
|
|
if (gServer->m_RcvCurTrackIndex != 0)
|
|
|
JigOft = m_Jig4PrtOft;
|
|
|
m_AdjustOffsetAll= Offset + JigOft;
|
|
|
}
|
|
|
void CCommonFlowMgr::ResetProductOffset()
|
|
|
{
|
|
|
m_Jig2PrtOft.x = m_Jig2PrtOft.y = 0;
|
|
|
}
|