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++

#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;//<2F><>ǰ<EFBFBD>ıʺ<C4B1>
m_PenPlatMoveSpeed = 99;//ƽ̨<C6BD><CCA8><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>(<28>˶<EFBFBD><CBB6><EFBFBD><EFBFBD>ƿ<EFBFBD>)
m_PenOffsetObj = 98;//<2F><><EFBFBD><EFBFBD>S <20><><EFBFBD>ƶ<EFBFBD>ʱƽ<CAB1><C6BD>obj <20><><EFBFBD><EFBFBD><EFBFBD>ıʺ<C4B1>
m_PenFindOrignXY = 97;//XY ƽ̨<C6BD><CCA8>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
m_PenManualMoveX = 95;//<2F>ֶ<EFBFBD><D6B6>ƶ<EFBFBD>ƽ̨X <20>ٶ<EFBFBD>
m_PenManualMoveY = 96;//<2F>ֶ<EFBFBD><D6B6>ƶ<EFBFBD>ƽ̨Y <20>ٶ<EFBFBD>
m_CurWorkPen = 0;//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ıʺ<C4B1>
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
IniParVec();
InitRecipeParVec();
}
CPenParMgr::~CPenParMgr(void)
{
}
//<2F><><EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD>
void CPenParMgr::Copy(CPenParMgr &rls)
{
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(int k=0;k<SPECIAL_PEN_START;k++)
{
m_ParVec[k] = rls.m_ParVec[k];
}
m_CurPen = rls.m_CurPen;//<2F><>ǰ<EFBFBD>ıʺ<C4B1>
m_CurWorkPen = rls.m_CurWorkPen;//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ıʺ<C4B1>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<EFBFBD>ʺ<EFBFBD>
m_PenPlatMoveSpeed = rls.m_PenPlatMoveSpeed;//ƽ̨<C6BD><CCA8><EFBFBD><EFBFBD><EFBFBD>ٶȵıʺ<C4B1>(<28>˶<EFBFBD><CBB6><EFBFBD><EFBFBD>ƿ<EFBFBD>)
m_PenOffsetObj = rls.m_PenOffsetObj;//<2F><><EFBFBD><EFBFBD>S <20><><EFBFBD>ƶ<EFBFBD>ʱƽ<CAB1><C6BD>obj <20><><EFBFBD><EFBFBD><EFBFBD>ıʺ<C4B1>
m_PenFindOrignXY = rls.m_PenFindOrignXY;//XY ƽ̨<C6BD><CCA8>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
m_PenManualMoveX = rls.m_PenManualMoveX;//<2F>ֶ<EFBFBD><D6B6>ƶ<EFBFBD>ƽ̨X <20>ٶ<EFBFBD>
m_PenManualMoveY = rls.m_PenManualMoveY;//<2F>ֶ<EFBFBD><D6B6>ƶ<EFBFBD>ƽ̨Y <20>ٶ<EFBFBD>
}
void CPenParMgr::OnAppInitialize()
{
}
#if 1
void CPenParMgr::WriteWorkFileExt(vector<CLab> &LabVec)
{
}
void CPenParMgr::ReadWorkFile(CLabVecRang &LabVecRang)
{
}
#endif
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void CPenParMgr::IniParVec()
{
for(int i=0;i<PEN_CNT;i++)
{
CPenPar PenPar;
m_ParVec.push_back(PenPar);
}
//<2F><><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϱʵ<CFB1><CAB5><EFBFBD>ɫ
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);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʺ<EFBFBD><CABA><EFBFBD>ɫ
for(int i=90;i<PEN_CNT;i++)
{
m_ParVec[i].SetColor(RGB_PURPLE);
}
}
void CPenParMgr::InitRecipeParVec()
{
{
CRecipePar RecipePar;
RecipePar.m_RecipeParName = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>(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 = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 = "˫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ(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 = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 = "ɨ<EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>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<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD>%";
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<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD>%";
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 = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>΢<EFBFBD><EFBFBD>ֵmm";
RecipePar.m_PenCtrlType = _PAR_FOCUS_ADJUST_VAL;
RecipePar.m_MinVal = -5;
RecipePar.m_MaxVal = 5;
m_PenParVec.push_back(RecipePar);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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," ");//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
List.SetItemText(i,idx++,Int2CString(i));//<2F>ʺ<EFBFBD>
}
}
//<2F><>ȡ<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>ɫ
COLORREF CPenParMgr::GetPenColor(int pen)
{
return m_ParVec[pen].GetColor();
}
//<2F><><EFBFBD>浱ǰ<E6B5B1>ʵIJ<CAB5><C4B2><EFBFBD>
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);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
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;
}
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>(PenNum <20>ʺ<EFBFBD>,PenCtrlPar <20><><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD>)
double CPenParMgr::GetPar(int PenNum,PEN_CTRL_PAR PenCtrlPar)
{
double val = 0;//<2F><><EFBFBD><EFBFBD>ֵ
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);//<2F><><EFBFBD><EFBFBD>
}
//<2F>жϱʺ<CFB1><CABA>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ʺ<EFBFBD>
bool CPenParMgr::IsSpecialPen(int n)
{
return (n>=SPECIAL_PEN_START)&&(n<PEN_CNT);
}
//<2F><><EFBFBD><EFBFBD>par <20><>ѡ<EFBFBD><D1A1>״̬
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];
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>бʵ<D0B1>ѡ<EFBFBD><D1A1>״̬
void CPenParMgr::ResetAllSelState()
{
int size = m_ParVec.size();
for(int k=0;(k<size);k++)
{
if(k==0)//Ĭ<><C4AC>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
m_ParVec[k].m_bSelected = true;
else
m_ParVec[k].m_bSelected = false;
}
}
//<2F><><EFBFBD>õ<EFBFBD>һ<EFBFBD><D2BB>ѡ<EFBFBD><D1A1><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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;
}
}
}