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.
344 lines
9.6 KiB
C++
344 lines
9.6 KiB
C++
#include "StdAfx.h"
|
|
#include "PenParMgr.h"
|
|
#include "CStringFuc.h"
|
|
#include "GlobalDefine.h"
|
|
#include "FileMgr.h"
|
|
#include "WorkFileLable.h"
|
|
#include "WorkFileMgr.h"
|
|
#include "GlobalFunction.h"
|
|
#include "PropertieMgr.h"
|
|
#include "LogMgr.h"
|
|
#include "PenParMgr.h"
|
|
#include "Propertie.h"
|
|
#include "PropertieMgr.h"
|
|
#include "AuthorityMgr.h"
|
|
|
|
#define FILE_PATH _T("\\Parameter\\CPenParMgr\\PenPar.par")
|
|
|
|
CPenParMgr *gPenParMgr = new CPenParMgr;
|
|
CPenParMgr::CPenParMgr(void)
|
|
{
|
|
m_CurPen = 0;//当前的笔号
|
|
m_PenPlatMoveSpeed = 99;//平台空移速度(运动控制卡)
|
|
m_PenOffsetObj = 98;//用于S 形移动时平移obj 对象的笔号
|
|
m_PenFindOrignXY = 97;//XY 平台找远点的速度
|
|
m_PenManualMoveX = 95;//手动移动平台X 速度
|
|
m_PenManualMoveY = 96;//手动移动平台Y 速度
|
|
m_CurWorkPen = 0;//当前工作的笔号
|
|
//初始化笔容器
|
|
IniParVec();
|
|
InitRecipeParVec();
|
|
}
|
|
CPenParMgr::~CPenParMgr(void)
|
|
{
|
|
}
|
|
//复制函数
|
|
void CPenParMgr::Copy(CPenParMgr &rls)
|
|
{
|
|
//不要复制特殊笔
|
|
for(int k=0;k<SPECIAL_PEN_START;k++)
|
|
{
|
|
m_ParVec[k] = rls.m_ParVec[k];
|
|
}
|
|
m_CurPen = rls.m_CurPen;//当前的笔号
|
|
m_CurWorkPen = rls.m_CurWorkPen;//当前工作的笔号
|
|
//特殊用途笔号
|
|
m_PenPlatMoveSpeed = rls.m_PenPlatMoveSpeed;//平台空移速度的笔号(运动控制卡)
|
|
m_PenOffsetObj = rls.m_PenOffsetObj;//用于S 形移动时平移obj 对象的笔号
|
|
m_PenFindOrignXY = rls.m_PenFindOrignXY;//XY 平台找远点的速度
|
|
m_PenManualMoveX = rls.m_PenManualMoveX;//手动移动平台X 速度
|
|
m_PenManualMoveY = rls.m_PenManualMoveY;//手动移动平台Y 速度
|
|
}
|
|
void CPenParMgr::OnAppInitialize()
|
|
{
|
|
|
|
}
|
|
#if 1
|
|
void CPenParMgr::WriteWorkFileExt(vector<CLab> &LabVec)
|
|
{
|
|
|
|
}
|
|
void CPenParMgr::ReadWorkFile(CLabVecRang &LabVecRang)
|
|
{
|
|
|
|
}
|
|
#endif
|
|
//初始化笔容器
|
|
void CPenParMgr::IniParVec()
|
|
{
|
|
for(int i=0;i<PEN_CNT;i++)
|
|
{
|
|
CPenPar PenPar;
|
|
m_ParVec.push_back(PenPar);
|
|
}
|
|
//设置默认笔的颜色
|
|
int idx = 0;
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_1);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_2);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_3);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_4);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_5);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_6);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_7);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_8);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_9);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_11);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_12);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_13);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_14);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_15);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_16);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_17);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_18);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_19);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_20);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_0);
|
|
m_ParVec[idx++].SetColor(PEN_COLOR_10);
|
|
//设置特殊笔号颜色
|
|
for(int i=90;i<PEN_CNT;i++)
|
|
{
|
|
m_ParVec[i].SetColor(RGB_PURPLE);
|
|
}
|
|
}
|
|
void CPenParMgr::InitRecipeParVec()
|
|
{
|
|
{
|
|
CRecipePar RecipePar;
|
|
RecipePar.m_RecipeParName = "激光频率(Hz)";
|
|
RecipePar.m_PenCtrlType = _PAR_LASER_PRF;
|
|
#ifdef __LASER_DEVICE_PHOTONICS__
|
|
RecipePar.m_MinVal = 500;
|
|
RecipePar.m_MaxVal = 5000;
|
|
#endif
|
|
#ifdef __LASER_DEVICE_BEAMTECH__
|
|
RecipePar.m_MinVal = 200;
|
|
RecipePar.m_MaxVal = 3000;
|
|
#endif
|
|
m_PenParVec.push_back(RecipePar);
|
|
}
|
|
{
|
|
CRecipePar RecipePar;
|
|
RecipePar.m_RecipeParName = "激光电流1(A)";
|
|
RecipePar.m_PenCtrlType = _PAR_LASER_CURR_1;
|
|
#ifdef __LASER_DEVICE_PHOTONICS__
|
|
RecipePar.m_MinVal = 0;
|
|
RecipePar.m_MaxVal = 50;
|
|
#endif
|
|
#ifdef __LASER_DEVICE_BEAMTECH__
|
|
RecipePar.m_MinVal = 0;
|
|
RecipePar.m_MaxVal = 18.2;
|
|
#endif
|
|
m_PenParVec.push_back(RecipePar);
|
|
}
|
|
#ifdef __LASER_PHOTONICS_TWO_PULSE__
|
|
{
|
|
CRecipePar RecipePar;
|
|
RecipePar.m_RecipeParName = "激光电流2(A)";
|
|
RecipePar.m_PenCtrlType = _PAR_LASER_CURR_2;
|
|
RecipePar.m_MinVal = 0;
|
|
RecipePar.m_MaxVal = 50;
|
|
m_PenParVec.push_back(RecipePar);
|
|
}
|
|
{
|
|
CRecipePar RecipePar;
|
|
RecipePar.m_RecipeParName = "双脉冲延时(ns)";
|
|
RecipePar.m_PenCtrlType = _PAR_LASER_PRF2_DELAY;
|
|
RecipePar.m_MinVal = 0;
|
|
RecipePar.m_MaxVal = 2000;
|
|
m_PenParVec.push_back(RecipePar);
|
|
}
|
|
#endif
|
|
{
|
|
CRecipePar RecipePar;
|
|
RecipePar.m_RecipeParName = "红光电流A";
|
|
RecipePar.m_PenCtrlType = _PAR_RED_LASER_CURR;
|
|
RecipePar.m_MinVal = 0;
|
|
RecipePar.m_MaxVal = 20;
|
|
m_PenParVec.push_back(RecipePar);
|
|
}
|
|
{
|
|
CRecipePar RecipePar;
|
|
RecipePar.m_RecipeParName = "红光脉宽us";
|
|
RecipePar.m_PenCtrlType = _PAR_RED_LASER_PULSE_W;
|
|
RecipePar.m_MinVal = 100;
|
|
RecipePar.m_MaxVal = 300;
|
|
m_PenParVec.push_back(RecipePar);
|
|
}
|
|
{
|
|
CRecipePar RecipePar;
|
|
RecipePar.m_RecipeParName = "扫描速度mm/s";
|
|
RecipePar.m_PenCtrlType = _PAR_PLAT_SCAN_SPEED;
|
|
RecipePar.m_MinVal = 5;
|
|
RecipePar.m_MaxVal = 1000;
|
|
m_PenParVec.push_back(RecipePar);
|
|
}
|
|
{
|
|
CRecipePar RecipePar;
|
|
RecipePar.m_RecipeParName = "X方向重叠率%";
|
|
RecipePar.m_PenCtrlType = _PAR_SCAN_OVERLAP_RATIO_X;
|
|
RecipePar.m_MinVal = 0;
|
|
RecipePar.m_MaxVal = 99;
|
|
m_PenParVec.push_back(RecipePar);
|
|
}
|
|
{
|
|
CRecipePar RecipePar;
|
|
RecipePar.m_RecipeParName = "Y方向重叠率%";
|
|
RecipePar.m_PenCtrlType = _PAR_SCAN_OVERLAP_RATIO_Y;
|
|
RecipePar.m_MinVal = 0;
|
|
RecipePar.m_MaxVal = 99;
|
|
m_PenParVec.push_back(RecipePar);
|
|
}
|
|
{
|
|
CRecipePar RecipePar;
|
|
RecipePar.m_RecipeParName = "焦距微调值mm";
|
|
RecipePar.m_PenCtrlType = _PAR_FOCUS_ADJUST_VAL;
|
|
RecipePar.m_MinVal = -5;
|
|
RecipePar.m_MaxVal = 5;
|
|
m_PenParVec.push_back(RecipePar);
|
|
}
|
|
|
|
//限制最大的参数个数
|
|
int size = m_PenParVec.size();
|
|
while(size>MAX_RECIPE_PAR_CNT)
|
|
{
|
|
m_PenParVec.pop_back();
|
|
size = m_PenParVec.size();
|
|
}
|
|
}
|
|
void CPenParMgr::InsertToList(CListCtrl &List)
|
|
{
|
|
int size = m_ParVec.size();
|
|
for(int i=0;i<size;i++)
|
|
{
|
|
int idx = 0;
|
|
List.InsertItem(i," ");//插入一行
|
|
List.SetItemText(i,idx++,Int2CString(i));//笔号
|
|
}
|
|
}
|
|
//获取笔的颜色
|
|
COLORREF CPenParMgr::GetPenColor(int pen)
|
|
{
|
|
return m_ParVec[pen].GetColor();
|
|
}
|
|
//保存当前笔的参数
|
|
void CPenParMgr::SaveCurPen(int pen,CPenPar CurPar)
|
|
{
|
|
m_ParVec[pen] = CurPar;
|
|
SaveOrLoad(true);
|
|
}
|
|
void CPenParMgr::SaveCurPen(CPenPar CurPar)
|
|
{
|
|
m_ParVec[m_CurPen] = CurPar;
|
|
SaveOrLoad(true);
|
|
}
|
|
void CPenParMgr::SaveOrLoad(bool bSave)
|
|
{
|
|
CFileMgr FileMgr;
|
|
char filepath[1024];
|
|
FileMgr.GetFullFilePath(filepath,FILE_PATH);//获取完整路径
|
|
|
|
if(bSave)
|
|
{
|
|
CFile file(filepath,CFile::modeReadWrite|CFile::modeCreate);
|
|
CArchive ar(&file,CArchive::store);
|
|
SaveOrLoadExt(ar);
|
|
}
|
|
else
|
|
{
|
|
CFile file;
|
|
if(file.Open(filepath,CFile::modeRead))
|
|
{
|
|
CArchive ar(&file,CArchive::load);
|
|
SaveOrLoadExt(ar);
|
|
}
|
|
}
|
|
}
|
|
void CPenParMgr::SaveOrLoadExt(CArchive &ar)
|
|
{
|
|
vector<CPenPar>::iterator iter = m_ParVec.begin();
|
|
vector<CPenPar>::iterator iter_end = m_ParVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
(*iter).Serialize(ar);
|
|
}
|
|
}
|
|
CPenPar CPenParMgr::GetPen(int pen)
|
|
{
|
|
if(pen>=0 && pen<PEN_CNT)
|
|
return m_ParVec[pen];
|
|
CPenPar PenPar;
|
|
return PenPar;
|
|
}
|
|
void CPenParMgr::SetCurPenNum(int num)
|
|
{
|
|
if(num>=0 && num<PEN_CNT)
|
|
m_CurPen = num;
|
|
}
|
|
//查询参数(PenNum 笔号,PenCtrlPar 控制的内容)
|
|
double CPenParMgr::GetPar(int PenNum,PEN_CTRL_PAR PenCtrlPar)
|
|
{
|
|
double val = 0;//参数值
|
|
if(PenNum>=0 && PenNum<PEN_CNT)
|
|
{
|
|
CPenPar &PenPar = m_ParVec[PenNum];
|
|
val = GetPar(PenPar,PenCtrlPar);
|
|
}
|
|
return val;
|
|
}
|
|
double CPenParMgr::GetPar(CPenPar &PenPar,PEN_CTRL_PAR EnumParType)
|
|
{
|
|
double val = 0;
|
|
int ParIdx = 0;
|
|
val = PenPar.GetParByIdx(EnumParType);
|
|
return val;
|
|
}
|
|
void CPenParMgr::SetPar(int PenNum,PEN_CTRL_PAR PenCtrlPar,double val)
|
|
{
|
|
if(PenNum>=0 && PenNum<PEN_CNT)
|
|
{
|
|
CPenPar &PenPar = m_ParVec[PenNum];
|
|
int ParIdx = 0;
|
|
PenPar.SetParByIdx(PenCtrlPar,val);
|
|
}
|
|
SaveOrLoad(true);//保存
|
|
}
|
|
//判断笔号是否为特殊笔号
|
|
bool CPenParMgr::IsSpecialPen(int n)
|
|
{
|
|
return (n>=SPECIAL_PEN_START)&&(n<PEN_CNT);
|
|
}
|
|
//设置par 的选择状态
|
|
void CPenParMgr::SetParSelectState(vector<bool> &vec)
|
|
{
|
|
int size = vec.size();
|
|
for(int k=0;(k<size)&&(k<PEN_CNT);k++)
|
|
{
|
|
m_ParVec[k].m_bSelected = vec[k];
|
|
}
|
|
}
|
|
//重置所有笔的选择状态
|
|
void CPenParMgr::ResetAllSelState()
|
|
{
|
|
int size = m_ParVec.size();
|
|
for(int k=0;(k<size);k++)
|
|
{
|
|
if(k==0)//默认选择第一个
|
|
m_ParVec[k].m_bSelected = true;
|
|
else
|
|
m_ParVec[k].m_bSelected = false;
|
|
}
|
|
}
|
|
//设置第一个选择的笔作为工作笔
|
|
void CPenParMgr::SetFirstSelPenAsWorkPen()
|
|
{
|
|
int size = m_ParVec.size();
|
|
for(int k=0;(k<size);k++)
|
|
{
|
|
if(m_ParVec[k].m_bSelected)
|
|
{
|
|
m_CurWorkPen = k;
|
|
break;
|
|
}
|
|
}
|
|
}
|