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.
105 lines
3.6 KiB
C++
105 lines
3.6 KiB
C++
#include "StdAfx.h"
|
|
#include "CreaterMarkFlow.h"
|
|
#include "GlobalFunction.h"
|
|
#include "MarkAreaMgr.h"
|
|
#include "WorkCmdMovePlatformXY.h"
|
|
#include "Laser.h"
|
|
#include "WorkCmdMarkArea.h"
|
|
#include "ProductMgr.h"
|
|
#include "Motor.h"
|
|
#include "WorkCmdMoveMotor.h"
|
|
|
|
#define MARK_ALL "ALL"
|
|
#define MARK_SEL "SEL"
|
|
|
|
CCreaterMarkFlow::CCreaterMarkFlow(const CString &str)
|
|
:CCreaterWorkCmd(str)
|
|
{
|
|
}
|
|
CCreaterMarkFlow::~CCreaterMarkFlow(void)
|
|
{
|
|
}
|
|
//根据工作区域的数据来创建
|
|
void CCreaterMarkFlow::Creat()
|
|
{
|
|
//参数1 表示是否全部加工
|
|
CString MarkType = GetPar(1);
|
|
bool bMarkSel = (MarkType == MARK_SEL);
|
|
|
|
vector<CProduct> &ProductVec = gProductMgr->GetProductVec();
|
|
vector<CProduct>::iterator iter = ProductVec.begin();
|
|
vector<CProduct>::iterator iter_end = ProductVec.end();
|
|
for(int i=0;iter!=iter_end;i++,iter++)
|
|
{
|
|
if((*iter).IsUsed())
|
|
{
|
|
//设置当前的工件,用来计算偏移旋转
|
|
gProductMgr->SetCurProductIdx(i);
|
|
CreatExt(bMarkSel);
|
|
}
|
|
#if 0
|
|
if(iter!=iter_end-1)//加工完一个先移动回原点
|
|
{
|
|
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
|
|
Dbxy MovePt;
|
|
Dbxy TargetPt;
|
|
pCmd->MoveToTargetPt(MovePt,TargetPt);
|
|
AddCmd(pCmd);
|
|
}
|
|
#endif
|
|
}
|
|
}
|
|
void CCreaterMarkFlow::CreatExt(bool bMarkSel)
|
|
{
|
|
//搜集工作数据-------------------------------------------------
|
|
CollectWorkData(bMarkSel);
|
|
|
|
//以area 的中心点转换数据-------------------------------
|
|
CMarkAreaMgr *MarkAreaMgr = gMarkAreaMgr;
|
|
//使用数据来创建工作流程----------------------------
|
|
vector<CMarkArea> &AreaVec = MarkAreaMgr->GetAreaVec();
|
|
vector<CMarkArea>::iterator iter = AreaVec.begin();
|
|
vector<CMarkArea>::iterator iter_end = AreaVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
if((*iter).HasWorkData())
|
|
{
|
|
//移动area 实际中心点到振镜中心
|
|
{
|
|
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
|
|
// pCmd->MoveToTargetPt((*iter).GetRealBasePt(),gLaser->GetCoord());
|
|
pCmd->InWorkState();//工作速度
|
|
AddCmd(pCmd);
|
|
}
|
|
//变焦次数
|
|
int FocalAdjustCnt = gProductMgr->GetFocalAdjustCnt();
|
|
double FocalAdjustDis = gProductMgr->GetFocalAdjustDis();
|
|
|
|
for(int i=0;i<FocalAdjustCnt+1;++i)
|
|
{
|
|
//标刻当前area
|
|
{
|
|
CWorkCmdMarkArea *pCmd = new CWorkCmdMarkArea((*iter));
|
|
AddCmd(pCmd);
|
|
}
|
|
//变焦
|
|
if(FocalAdjustCnt>0 && !IsDbEqualZero(FocalAdjustDis) && i<FocalAdjustCnt)
|
|
{
|
|
CMotor &Motor = *(CMotor::GetMotor(MOTOR_Z));
|
|
CWorkCmdMoveMotor *pCmd = new CWorkCmdMoveMotor(Motor,FocalAdjustDis);
|
|
AddCmd(pCmd);
|
|
}
|
|
}
|
|
//焦距回调
|
|
if(FocalAdjustCnt>0 && !IsDbEqualZero(FocalAdjustDis))
|
|
{
|
|
for(int i=0;i<FocalAdjustCnt;i++)
|
|
{
|
|
CMotor &Motor = *(CMotor::GetMotor(MOTOR_Z));
|
|
CWorkCmdMoveMotor *pCmd = new CWorkCmdMoveMotor(Motor,FocalAdjustDis*(-1));
|
|
AddCmd(pCmd);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |