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.
215 lines
7.7 KiB
C++
215 lines
7.7 KiB
C++
#include "StdAfx.h"
|
|
#include "Mirror.h"
|
|
#include "Propertie.h"
|
|
#include "PropertieMgr.h"
|
|
#include "AuthorityMgr.h"
|
|
#include "GlobalFunction.h"
|
|
#include "LogMgr.h"
|
|
#include "LaipuVbDllMgr.h"
|
|
#include "PciCh365Mgr.h"
|
|
#include "PenParMgr.h"
|
|
#include "WorkTime.h"
|
|
#include "ExceptionMsg.h"
|
|
#include "CStringFuc.h"
|
|
|
|
CMirror *gMirror = new CMirror;
|
|
CMirror::CMirror(void)
|
|
{
|
|
m_MirrorStep = 1;
|
|
m_CheckDataArea = false;//是否检查数据范围
|
|
}
|
|
CMirror::~CMirror(void)
|
|
{
|
|
}
|
|
#if 1//复写module 的函数
|
|
CMFCPropertyGridProperty *CMirror::CreatGridProperty()
|
|
{
|
|
CString PropertyName;//属性名称
|
|
CString Description;//描述
|
|
CString Path = _T("Mirror");//存储路径
|
|
CString Name;
|
|
//-------------------------------------------------------------------------------//
|
|
PropertyName = _T("振镜");
|
|
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
|
|
//-------------------------------------------------------------------------------//
|
|
{
|
|
{
|
|
//添加属性变量映射
|
|
Name = _T("m_MirrorRange_w");//变量名字
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_MirrorRange.w);
|
|
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_MirrorRange.w, Description);
|
|
pGroup->AddSubItem(p);
|
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
}
|
|
{
|
|
//添加属性变量映射
|
|
Name = _T("m_MirrorRange_h");//变量名字
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_MirrorRange.h);
|
|
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_MirrorRange.h, Description);
|
|
pGroup->AddSubItem(p);
|
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
}
|
|
{
|
|
//添加属性变量映射
|
|
Name = _T("m_MirrorStep");//变量名字
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_MirrorStep);
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
pPropertie->SetpModule(this);
|
|
pPropertie->SetPath(Path);
|
|
pPropertie->SetName(Name);
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
|
//添加属性显示
|
|
PropertyName = _T("振镜步长");
|
|
Description = _T("用于控制振镜数据尺寸的比例值");
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_MirrorStep, Description);
|
|
pGroup->AddSubItem(p);
|
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
}
|
|
{
|
|
//添加属性变量映射
|
|
Name = _T("m_CheckDataArea");//变量名字
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_CheckDataArea);
|
|
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_CheckDataArea, Description);
|
|
pGroup->AddSubItem(p);
|
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
}
|
|
}
|
|
return pGroup;
|
|
}
|
|
//检查数据是否在振镜范围内
|
|
bool CMirror::CheckDataInMirrorArea(CWorkData &WorkData)
|
|
{
|
|
if(!m_CheckDataArea)
|
|
return true;
|
|
vector<vector<Dbxy>>& m_DataVec = WorkData.GetDataVec();
|
|
|
|
DbRect rect(Dbxy(0,0),m_MirrorRange);
|
|
vector<vector<Dbxy>>::iterator iter = m_DataVec.begin();
|
|
vector<vector<Dbxy>>::iterator iter_end = m_DataVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
vector<Dbxy>::iterator iter1 = (*iter).begin();
|
|
vector<Dbxy>::iterator iter1_end = (*iter).end();
|
|
for(;iter1!=iter1_end;iter1++)
|
|
{
|
|
if(!IsPointInRect((*iter1),rect))
|
|
{
|
|
CString LogStr;
|
|
LogStr.Format(_T("[ptX] = [%f] ,[ptY] = [%f]"),(*iter1).x,(*iter1).y);
|
|
//gLogMgr->WriteDebugLog(LogStr);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
#endif
|
|
#if 1
|
|
void CMirror::StartMark(CWorkData &WorkData)
|
|
{
|
|
//检查数据是否在area 内
|
|
if(!gMirror->CheckDataInMirrorArea(WorkData))
|
|
{
|
|
CString str = _T("CheckDataInMirrorArea---->Error");
|
|
CExceptionMsg Msg;
|
|
Msg.SetMsg(str);
|
|
throw Msg;
|
|
}
|
|
|
|
//获取当前系统时间
|
|
CTime StartTime,CurTime;
|
|
CTimeSpan TimeSpan;//时间差
|
|
StartTime=CTime::GetCurrentTime();
|
|
|
|
CWorkTime WorkTime;
|
|
WorkTime.StartExactTime();//开始精确计时
|
|
|
|
StartMark_LaipuPci(WorkData);
|
|
|
|
//输出mark 时间到log
|
|
CurTime=CTime::GetCurrentTime();
|
|
TimeSpan = CurTime - StartTime;
|
|
CString Time = Int2Str_LeftZero(TimeSpan.GetHours())+":"+Int2Str_LeftZero(TimeSpan.GetMinutes())+":"+Int2Str_LeftZero(TimeSpan.GetSeconds());
|
|
int ExactSpanTime = WorkTime.GetExactTime();//结束计时
|
|
CString LogStr;
|
|
LogStr.Format(_T("[ExactSpanTime] = [%d]"),ExactSpanTime);
|
|
}
|
|
|
|
//开始mark by 莱普pci 卡
|
|
void CMirror::StartMark_LaipuPci(CWorkData &WorkData)
|
|
{
|
|
if(gPciCh365Mgr->IsInitialize()==false)
|
|
{
|
|
CString LogStr;
|
|
LogStr.Format("Err ---->Pci365 Card Not Init");
|
|
CExceptionMsg Msg;
|
|
Msg.SetMsg(LogStr);
|
|
throw Msg;
|
|
}
|
|
|
|
//CLaipuVbDllMgr &LaipuVbDll = *gLaipuVbDllMgr;
|
|
CLaipuVbDllMgr LaipuVbDll;//在新的线程中使用
|
|
long low = gPciCh365Mgr->GetOutPortState(true);
|
|
long high = gPciCh365Mgr->GetOutPortState(false);
|
|
LaipuVbDll.VbIniCardExt(low,high,0);//初始化
|
|
CPenPar &PenPar = gPenParMgr->GetCurPen();
|
|
LaipuVbDll.SetMarkParam(PenPar);//设置参数
|
|
LaipuVbDll.MarkingStart();//准备
|
|
int cnt = 1;//一个工作区域的循环加工次数
|
|
for(int i=0;i<cnt;i++)
|
|
{
|
|
LaipuVbDll.CallMarkingData(WorkData.GetDataVec());//加工
|
|
}
|
|
//结束---------------------------------------------------------------------
|
|
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);//结束
|
|
}
|
|
//通过Scanlab 的RTC5 振镜控制卡来控制
|
|
void CMirror::StartMark_ScanlabRTC5(CWorkData &WorkData)
|
|
{
|
|
|
|
}
|
|
#endif
|
|
|