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.

122 lines
3.6 KiB
C++

#include "StdAfx.h"
#include "MarkCtrl.h"
#include "LaipuVbDllMgr.h"
#include "WorkDataMgr.h"
#include "LogMgr.h"
#include "MarkParMgr.h"
#include "GlobalFunction.h"
#include "Mirror.h"
#include "ProductMgr.h"
#include "PciCh365Mgr.h"
#include "WorkCmdContainer.h"
#include "WorkCmdMarkArea.h"
#include "WorkCmdInvoker.h"
#include "MarkArea.h"
#include "WorkTime.h"
#include "ExceptionMsg.h"
#include "CommonFlowMgr.h"
CMarkCtrl::CMarkCtrl(void)
{
}
CMarkCtrl::~CMarkCtrl(void)
{
}
#if 1
void CMarkCtrl::StartMarkPci(vector<vector<Dbxy>> &DateVec,vector<vector<Dbxy>> &SpecialDateVec,int AreaCycleCnt)
{
gLogMgr->WriteDebugLog("StartMarkPci",_LOG_FUNC);
#ifdef NoPCI_MarkData2Txt // #if 1 //
int dataCnt = 0;
CStdioFile sf;
CString str;
if (sf.Open("MarkData.txt", CFile::modeCreate | CFile::modeReadWrite))
{
auto iter = DateVec.begin();
auto iter_end = DateVec.end();
for (; iter != iter_end; iter++)
{
for (auto ii:(*iter))
{
str.Format("MarkData: X=%f;Y=%f \n", (ii).x, (ii).y);
sf.SeekToEnd();
sf.WriteString(str);
dataCnt++;
}
}
sf.Close();
gServer->m_curAreaDataCnt = dataCnt;
str.Format("Area_DataCnt[%d]", dataCnt);
gServer->BroadCast(str);
}
#else
if(gPciCh365Mgr->IsInitialize()==false)
{
CString LogStr("Func : StartMarkPci ---->Pci Card Not Init");
AfxMessageBox(LogStr);
CExceptionMsg Msg;
Msg.SetMsg(LogStr);
throw Msg;
}
//CLaipuVbDllMgr &LaipuVbDll = *gLaipuVbDllMgr;
CLaipuVbDllMgr LaipuVbDll;
long low = gPciCh365Mgr->GetOutPortState(true);
long high = gPciCh365Mgr->GetOutPortState(false);
LaipuVbDll.VbIniCard(low,high);//初始化
SetMarkParam(LaipuVbDll);//设置参数
LaipuVbDll.MarkingStart();//准备
gLogMgr->WriteDebugLog("finc->MarkingStart,finished! Prepare OK!");
for(int i=0;i<AreaCycleCnt;i++)
{
LaipuVbDll.CallMarkingData(DateVec);//加工
}
if(!SpecialDateVec.empty())//特殊对象只加工一次
{
LaipuVbDll.CallMarkingData(SpecialDateVec);//加工
}
//结束---------------------------------------------------------------------
long fileno = -1;
long fileAll = 1;
long MarkM = 8;//标刻模式(多模板,多位置)
long m_sel = 1;//文件选择方式
long head = 0;
//模板编号及位置偏移
LaipuVbDll.CallMarkingEnd(fileno,fileAll,MarkM,m_sel,head,NULL);//结束
#endif // NoPCI_MarkData2Txt
}
//设置标刻参数
void CMarkCtrl::SetMarkParam(CLaipuVbDllMgr &LaipuVbDll)
{
gMarkParMgr->SetCurPenNum(0);//只使用0 号笔的参数
CMarkPar &MarkPar = gMarkParMgr->GetCurPen();
//振镜参数--------------------------------------------------------------
//float ms = MarkPar.ms;//标刻速度mm/s
float ms = (float)gCommonFlowMgr->GetCutSpeed();
float mms = MarkPar.mms;//空移速度mm/s
long tcf = MarkPar.tcf;//关激光前延时us
long tch = MarkPar.tch;//关激光后延时us
long tof = MarkPar.tof;//开激光前延时us
long toh = MarkPar.toh;//开激光后延时us
long dr_time = MarkPar.dr_time;//拐点延时 us
double su = gMirror->GetMirrorStep();//振镜步长um
float laserfre = MarkPar.laserfre;//激光频率
float laserpower = MarkPar.laserpower;//激光功率
float maxlaserpower = MarkPar.maxlaserpower;//激光最大功率
CString LogStr;
LogStr.Format(_T("Fuc:SetMarkParam : [CutSpeed] = [%f] "),ms);
gLogMgr->WriteDebugLog(LogStr);
LogStr.Format(_T("Fuc:SetMarkParam : [laserfre] = [%f] ,[laserpower] = [%f] ,[maxlaserpower] = [%f]"),laserfre,laserpower,maxlaserpower);
gLogMgr->WriteDebugLog(LogStr);
LaipuVbDll.GetCom()->Marking_para(&ms,&mms,&tcf,&tch,&tof,&toh,&su,&laserpower,&laserfre,&maxlaserpower,&dr_time);
}
#endif