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.

1041 lines
40 KiB
C++

#include "StdAfx.h"
#include "Laser.h"
#include "Propertie.h"
#include "PropertieMgr.h"
#include "AuthorityMgr.h"
#include "MsgBox.h"
#include "ExceptionMsg.h"
#include "WorkCmdContainer.h"
#include "DrawSimpleShape.h"
#include "GlobalDrawMgr.h"
#include "PenParMgr.h"
#include "CStringFuc.h"
#include "WorkCmdInvoker.h"
#include "ObjFillMgr.h"
#include "AllThreadMgr.h"
#include "ProgramLaserTuiHuo.h"
#include "RecipeMgr.h"
#include "CStringFuc.h"
#include "WarningMgr.h"
#include "FileMgr.h"
#include "LaserPowCheckMgr.h"
#define EDI_PARA_FILE _T("\\CommPar\\EnergyDensityPara.bin")
//激光器休眠线程
UINT LaserSleepThread(LPVOID pParam)
{
CLaser *p = (CLaser *)pParam;
p->LaserSleepTimeExt();
return 0;
}
CLaser *gLaser = new CLaser;
CLaser::CLaser(void)
{
m_bAdaptThickness = false;
m_bInited = false;//是否初始化成功
m_BaseThickness = 0;//用来调试焦距的基准产品厚度mm
m_WorkThickness = 0;//当前加工的产品厚度mm
m_MaxThickness = 1;//最大产品厚度mm
m_MinThickness = 1;//最小产品厚度mm
m_LaserSwitch = false;//激光是否反向
m_bScanByDirX = true;//X方向扫描
m_LaserType = 3;//激光器类型
m_OpenLaserDelay = 0;//开激光后延时ms
m_OpenLaserDelayShort = 0;//开激光后延时ms (短延时)
m_bSetGateFre = false;//是否设置了关闸的频率(只用设置一次)
m_ScanOverlapRatio = 30;//扫描重叠率,用来计算扫描间隔(0~100%)
m_GateOpDelay = 100;//操作关闸后的延时ms(因为关闸偏转需要时间)
m_GateFre = 30;//光闸的频率
m_FocusZMoveUpVal = 20;//电机Z 的激光焦距位置(测距仪基准向上移动的值)
m_bAutoCalCurr = false;//根据功率密度自动计算电流(保存值)
m_bCloseAppCloseLaser = true;
m_SpotSize.w = m_SpotSize.h = 1;//激光光斑的尺寸(比如退火设备可能是方形的).h = 1;//激光光斑的尺寸(比如退火设备可能是方形的)
m_bLaserGateOpen = false;
m_bRedLaserGateOpen = false;//激光2 gate 是否为打开状态(辅助激光)
m_bMachineGateOpen = true;//光闸是否打开
m_bAutoCalSpeedX = true;//根据重叠率自动计算扫描速度
m_bCtrLaserDimmerRev = false;//光闸控制反向
m_CurWorkFoucsZcoord = 0;//当前加工晶圆Z 轴坐标(绝对坐标)
m_EnergyParChangeScal = 1;//用于判断点检后功率密度参数变化的范围比例%(保存值)
m_RedLaserDelayAdjust = 0;//红光延时补偿值(用于调整脉冲发生器的相位)
m_RedLaserPowCheckPluseW = 100;//红光点检时使用的脉宽us
m_bPowRecordWriteCalPow = false;//导出功率点检记录时输出计算功率P = Po+K*I;
m_LaserCurrDigitsCnt = 1;//激光电流小数点的位数
}
CLaser::~CLaser(void)
{
}
CMFCPropertyGridProperty *CLaser::CreatGridProperty()
{
CPropertieMgr *pPropertieMgr = &gDevicePropertieMgr;
CString PropertyName;//属性名称
CString Description;//描述
CString Path = _T("Laser");//存储路径
CString Name;
CString GroupName;
CString ModuleName;
//-------------------------------------------------------------------------------//
PropertyName = _T("激光");
ModuleName = PropertyName;
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
//-------------------------------------------------------------------------------//
if(gAuthorityMgr->CheckAuthority(_Authority_Factory))
{
{
{
//添加属性变量映射
Name = _T("m_LaserSwitch");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_LaserSwitch);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("激光反向");
Description = _T("激光控制端口是否反向");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
pPropertie->SetModuleName(ModuleName);
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_LaserSwitch, Description);
pGroup->AddSubItem(p);
pPropertieMgr->Insert(p, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_LaserCurrDigitsCnt");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_LaserCurrDigitsCnt);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("电流精度位数");
Description = _T("激光器电流的控制位数(1 or 2)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_LaserCurrDigitsCnt, Description);
pGroup->AddSubItem(p);
pPropertieMgr->Insert(p, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_OpenLaserDelay");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_OpenLaserDelay);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("开光后延时(长)");
Description = _T("打开激光后的延时时间(激光休眠状态启动)(ms)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_OpenLaserDelay, Description);
pGroup->AddSubItem(p);
pPropertieMgr->Insert(p, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_OpenLaserDelayShort");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_OpenLaserDelayShort);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("开光后延时(短)");
Description = _T("打开激光后的延时时间(ms)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_OpenLaserDelayShort, Description);
pGroup->AddSubItem(p);
pPropertieMgr->Insert(p, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_GateOpDelay");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_GateOpDelay);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("光闸延时");
Description = _T("操作光闸后的延时ms(因为光闸偏转需要时间)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_GateOpDelay, Description);
pGroup->AddSubItem(p);
pPropertieMgr->Insert(p, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bCloseAppCloseLaser");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bCloseAppCloseLaser);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("软件退出时需要关闭LD");
Description = _T("在退出软件时需要关闭激光LD");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bCloseAppCloseLaser, Description);
pGroup->AddSubItem(p);
pPropertieMgr->Insert(p, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_GateFre");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_GateFre);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("光闸频率");
Description = _T("控制关闸偏转的速度(值却小越慢)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_GateFre, Description);
pGroup->AddSubItem(p);
pPropertieMgr->Insert(p, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_LaserType");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_LaserType);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("Type");
Description = _T("Type");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_LaserType, Description);
pGroup->AddSubItem(p);
pPropertieMgr->Insert(p, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_FocusZMoveUpVal");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_FocusZMoveUpVal);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("激光焦距");
Description = _T("Z轴焦点到晶圆面的距离mm");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_FocusZMoveUpVal, Description);
p1->AllowEdit(FALSE);//不可修改
pGroup->AddSubItem(p1);
pPropertieMgr->Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bScanByDirX");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bScanByDirX);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("X方向扫描");
Description = _T("true: X方向扫描,false: Y方向扫描");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bScanByDirX, Description);
pGroup->AddSubItem(p);
pPropertieMgr->Insert(p, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bAutoCalSpeedX");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bAutoCalSpeedX);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("自动计算扫描速度");
Description = _T("是否根据重叠率自动计算扫描速度");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_bAutoCalSpeedX, Description);
pGroup->AddSubItem(p1);
pPropertieMgr->Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bAutoCalCurr");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bAutoCalCurr);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("自动计算电流");
Description = _T("是否根据功率密度自动计算电流");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_bAutoCalCurr, Description);
pGroup->AddSubItem(p1);
pPropertieMgr->Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bPowRecordWriteCalPow");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bPowRecordWriteCalPow);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("导出拟合功率");
Description = _T("导出功率点检记录时输出计算功率");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bPowRecordWriteCalPow, Description);
pGroup->AddSubItem(p);
pPropertieMgr->Insert(p, pPropertie);
}
}
{
GroupName = ("主激光参数");
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(GroupName);
{
{
//添加属性变量映射
Name = _T("m_SpotSize_w");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_SpotSize.w);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("光斑尺寸X(mm)");
Description = _T("激光光斑X 方向的长度(mm)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_SpotSize.w, Description);
pGroup1->AddSubItem(p1);
pPropertieMgr->Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_SpotSize_h");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_SpotSize.h);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("光斑尺寸Y(mm)");
Description = _T("激光光斑Y 方向的长度(mm)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_SpotSize.h, Description);
pGroup1->AddSubItem(p1);
pPropertieMgr->Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_EnergyParChangeScal");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_EnergyParChangeScal);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("点检保护比例%");
Description = _T("功率点检得到的K和Po 和当前值的变化比例超出这个值会报警");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_EnergyParChangeScal, Description);
pGroup1->AddSubItem(p1);
pPropertieMgr->Insert(p1, pPropertie);
}
pGroup->AddSubItem(pGroup1);
}
}
{
GroupName = ("辅助激光参数");
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(GroupName);
{
{
//添加属性变量映射
Name = _T("m_RedSpotSize_w");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_RedSpotSize.w);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("光斑尺寸X(mm)");
Description = _T("激光光斑X 方向的长度(mm)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_RedSpotSize.w, Description);
pGroup1->AddSubItem(p1);
pPropertieMgr->Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_RedSpotSize_h");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_RedSpotSize.h);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("光斑尺寸Y(mm)");
Description = _T("激光光斑Y 方向的长度(mm)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_RedSpotSize.h, Description);
pGroup1->AddSubItem(p1);
pPropertieMgr->Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_RedLaserDelayAdjust");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_RedLaserDelayAdjust);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("脉冲延时补偿(us)");
Description = _T("用于补偿绿光和红光脉冲延时(us)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_RedLaserDelayAdjust, Description);
pGroup1->AddSubItem(p1);
pPropertieMgr->Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_RedLaserPowCheckPluseW");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_RedLaserPowCheckPluseW);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("功率点检脉宽(us)");
Description = _T("红光点检时使用的脉宽us");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_RedLaserPowCheckPluseW, Description);
pGroup1->AddSubItem(p1);
pPropertieMgr->Insert(p1, pPropertie);
}
pGroup->AddSubItem(pGroup1);
}
}
}
//-------------------------------------------------------------------------------//
return pGroup;
}
void CLaser::Draw(CDC* pDC)
{
}
#if 1
void CLaser::OnAppInitialize()
{
//从文件中读取功率密度的参数
ReadEnergyDensityParFile();
}
void CLaser::OnExitApp()
{
}
//工作文件另存为
void CLaser::WriteWorkFileExt(vector<CLab> &LabVec)
{
LabVec.push_back(CLab(LAB_NULL,m_WorkThickness));//产品厚度
}
void CLaser::ReadWorkFile(CLabVecRang &LabVecRang)
{
int idx = LabVecRang.GetStart()+1;
m_WorkThickness = LabVecRang.GetDouble(idx++);
}
//获取开激光后延时
int CLaser::GetOpenLaserDelay()
{
if(m_bLaserGateOpen)//激光打开时用短延时
return m_OpenLaserDelayShort;
return m_OpenLaserDelay;
}
int CLaser::GetShortOpenLaserDelay()
{
return m_OpenLaserDelayShort;
}
//设置光闸的频率
void CLaser::SetGateFre()
{
}
//获取激光焦距(这个值是测距仪的基准Z 坐标向上移动的值)
double CLaser::GetFocusZMoveUpVal()
{
return m_FocusZMoveUpVal;
}
//返回加上测距仪标准距离的焦距值(显示用)
double CLaser::GetLaserFocusDis()
{
return m_FocusZMoveUpVal;
}
void CLaser::ResetCurWorkFoucsZcoord()
{
m_CurWorkFoucsZcoord = 0;
gLogMgr->WriteDebugLog("Func---->ResetCurWorkFoucsZcoord");
}
//设置当前wafer 的焦距Z 轴坐标(FindFoucsCoordZ 是测距仪找到焦距的Z 轴坐标(负值))
void CLaser::SetCurWorkFoucsZcoord(double FindFoucsCoordZ)
{
//焦距= 测距仪测量Z 坐标加上固定上移坐标(这个坐标是调试界面设置的)
m_CurWorkFoucsZcoord = FindFoucsCoordZ+m_FocusZMoveUpVal;
CString s;
s.Format("FindFoucsCoordZ=%.f,FocusZMoveUpVal=%.f,WorkFoucsZcoord=%.f",FindFoucsCoordZ,m_FocusZMoveUpVal,m_CurWorkFoucsZcoord);
gLogMgr->WriteDebugLog(s);
}
#endif
#if 1//扫描相关
//计算能量密度(通过I 电流/F 频率)
void CLaser::CalEnergyDensity(eLaserDeviceType LaserDeviceType,double F,double I,double &Edi)
{
double EnergyDensityPo = 0;
double EnergyDensityK = 0;
GetEnergyDensityPar(LaserDeviceType,F,EnergyDensityK,EnergyDensityPo);
Edi = CalEnergyDensityExt(LaserDeviceType,F,I,EnergyDensityK,EnergyDensityPo);
}
double CLaser::CalEnergyDensityExt(eLaserDeviceType LaserDeviceType,double F,double I,double K,double Po)
{
if(F==0 || I==0)
return 0;
//计算红光时取频率= 1
if(LaserDeviceType == _LaserDeviceType_RedLaser)
F = 1;
DbSize SpotSize = GetSpotSize(LaserDeviceType);
double Pi = Po + K*I;//拟合功率值
double Ei = Pi/F;//单脉冲能量
double Edi = 0.1*Ei/(SpotSize.w*SpotSize.h);
if(LaserDeviceType != _LaserDeviceType_RedLaser)
Edi *= 1000;
CString s;
s.Format("%.3f",Edi);//保留两位小数
Edi = CStringToDouble(s);
return Edi;
}
//通过功率计算功率密度
double CLaser::CalEnergyDensityByPow(eLaserDeviceType LaserDeviceType,double F,double P)
{
if(F==0)
return 0;
//测量绿光且光闸没有打开的时候
if(LaserDeviceType != _LaserDeviceType_RedLaser && !IsMachineGateOpen())
return 0;
//测量红光且红光gate没有打开的时候
if(LaserDeviceType == _LaserDeviceType_RedLaser && !IsbRedLaserGateOpen())
return 0;
//计算红光时取频率= 1
if(LaserDeviceType == _LaserDeviceType_RedLaser)
F = 1;
DbSize SpotSize = GetSpotSize(LaserDeviceType);
double Ei = P/F;//单脉冲能量
double Edi = 0.1*Ei/(SpotSize.w*SpotSize.h);
if(LaserDeviceType != _LaserDeviceType_RedLaser)
Edi *= 1000;
CString s;
s.Format("%.3f",Edi);//保留两位小数
Edi = CStringToDouble(s);
return Edi;
}
//根据功率密度和频率计算电流值
void CLaser::CalCurrByEdi(eLaserDeviceType LaserDeviceType,double F,double &I,double Edi)
{
double EnergyDensityPo = 0;
double EnergyDensityK = 0;
GetEnergyDensityPar(LaserDeviceType,F,EnergyDensityK,EnergyDensityPo);
I = CalCurrByEdiExt(LaserDeviceType,F,Edi,EnergyDensityK,EnergyDensityPo);
}
//F频率Edi功率密度P0截距K斜率
double CLaser::CalCurrByEdiExt(eLaserDeviceType LaserDeviceType,double F,double Edi,double K,double Po)
{
if(F==0 || Edi==0)
return 0;
//光斑尺寸
DbSize SpotSize = GetSpotSize(LaserDeviceType);
//计算红光时取频率= 1
if(LaserDeviceType == _LaserDeviceType_RedLaser)
F = 1;
if(LaserDeviceType != _LaserDeviceType_RedLaser)
Edi /= 1000;
double Ei = Edi*(SpotSize.w*SpotSize.h)/0.1;//单脉冲能量
double Pi = Ei*F;//拟合功率值
double I = (Pi-Po)/K;
CString s;
if(m_LaserCurrDigitsCnt>=2)
s.Format("%.2f",I);//保留2 位小数
else
s.Format("%.1f",I);//保留1 位小数
I = CStringToDouble(s);
s.Format("Po=[%.3f] K=[%.3f] I=[%.3f] F=[%.3f] L=[%.3f] W=[%.3f]Pi=[%.3f] Ei=[%.3f] Edi=[%.3f]",Po,K,I,F,SpotSize.w,SpotSize.h,Pi,Ei,Edi);
//gLogMgr->WriteDebugLog(s);
return I;
}
//计算recipe 中对应的功率值(P = P0 + K*I)
double CLaser::CalPowerByRecipePar(eLaserDeviceType LaserDeviceType,double Fre,double I)
{
double P = 0;
//找到频率Fre 对应的K和Po
double Po = 0;
double K = 0;
if(GetEnergyDensityPar(LaserDeviceType,Fre,K,Po))
{
P = CalPowerByDensityPar(Po,K,I);
}
return P;
}
double CLaser::CalPowerByDensityPar(double Po,double K,double I)
{
double P = 0;
P = Po + K*I;
if(P<0)
P=0;
return P;
}
#endif
#if 1
//获取光斑尺寸
DbSize CLaser::GetSpotSize(eLaserDeviceType LaserDeviceType)
{
DbSize SpotSize = m_SpotSize;
//计算红光时取频率= 1
if(LaserDeviceType == _LaserDeviceType_RedLaser)
{
SpotSize = m_RedSpotSize;
}
return SpotSize;
}
CString CLaser::GetLaserDeviceName(eLaserDeviceType LaserDeviceType)
{
CString s;
if(LaserDeviceType == _LaserDeviceType_MainLaser1)
s = ("绿光1");
if(LaserDeviceType == _LaserDeviceType_MainLaser2)
s = ("绿光2");
if(LaserDeviceType == _LaserDeviceType_RedLaser)
s = ("红光");
return s;
}
//检查功率密度参数是否在限定范围内(不满足则发出WarningMsg)
bool CLaser::CheckEnergyDensityPar(eLaserDeviceType LaserDeviceType,double Fre,double K,double Po)
{
gLogMgr->WriteDebugLog("Func---->CheckEnergyDensityPar");
double CurK,CurPo;//当前值
GetEnergyDensityPar(LaserDeviceType,Fre,CurK,CurPo);
CString Log = GetLaserDeviceName(LaserDeviceType);
Log += "\n";
CString s;
s.Format("参数值K[%lf] Po[%lf]",CurK,CurPo);
Log += s;
Log += "\n";
s.Format("点检值K[%lf] Po[%lf]",K,Po);
Log += s;
Log += "\n";
gLogMgr->WriteDebugLog(Log);
//避免报错
if(CurK==0 || CurPo==0)
return false;
bool Ret = true;
double ChangeScal = (fabs(K-CurK)/CurK)*100;
if(ChangeScal >(m_EnergyParChangeScal))
{
s.Format("K 变化比例%lf%% 超出限定范围",ChangeScal);
Log += s;
Log += "\n";
Ret = false;
}
ChangeScal = (fabs(Po-CurPo)/CurPo)*100;
if(ChangeScal >(m_EnergyParChangeScal))
{
s.Format("Po 变化比例%lf%% 超出限定范围",ChangeScal);
Log += s;
Log += "\n";
Ret = false;
}
if(Ret)//点检正常
{
Log += "在限定范围内";
}
else//点检失败,发送报警消息
{
CString AddInfo;
AddInfo = Log;
if(LaserDeviceType == _LaserDeviceType_MainLaser1)
gWarningMgr->SendWarningMsg(_Warning_Code_41,AddInfo);
if(LaserDeviceType == _LaserDeviceType_MainLaser2)
gWarningMgr->SendWarningMsg(_Warning_Code_42,AddInfo);
if(LaserDeviceType == _LaserDeviceType_RedLaser)
gWarningMgr->SendWarningMsg(_Warning_Code_43,AddInfo);
}
return Ret;
}
//通过重叠率和光斑直径来计算扫描间隔mm (bhorizontal 是否横向)
double CLaser::GetScanIntervals(double ScanOverlapRatio,bool bhorizontal)
{
double ScanIntervals = 1;
double SpotSize;
if(gLaser->IsbScanByDirX())
SpotSize = m_SpotSize.h;
else
SpotSize = m_SpotSize.w;
if(ScanOverlapRatio>0&&ScanOverlapRatio<100)
{
ScanIntervals = SpotSize-(SpotSize*ScanOverlapRatio)/100;
}
return ScanIntervals;
}
#endif
#if 1
void CLaser::IniEdiParList(CListCtrl &list)
{
//设置风格
list.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
//设置列
int idx = 0;
list.InsertColumn(idx,"Idx",LVCFMT_LEFT,35,-1);
idx++;
list.InsertColumn(idx,"Laser",LVCFMT_LEFT,55,-1);
idx++;
list.InsertColumn(idx,"Fre",LVCFMT_LEFT,55,-1);
idx++;
list.InsertColumn(idx,"K",LVCFMT_LEFT,70,-1);
idx++;
list.InsertColumn(idx,"Po",LVCFMT_LEFT,70,-1);
idx++;
}
void CLaser::UpdateEdiParList(CListCtrl &List)
{
List.DeleteAllItems();
int size = m_EnergyDensityParVec.size();
for(int k=0;k<size;k++)
{
CEnergyDensityPar &Par = m_EnergyDensityParVec[k];
int idx = 0;
List.InsertItem(k," ");//插入一行
List.SetItemText(k,idx++,Int2CString(k+1));//序号
List.SetItemText(k,idx++,GetLaserDeviceName((eLaserDeviceType)Par.m_LaserDeviceType));
List.SetItemText(k,idx++,Db2CString(Par.m_LaserFre,1));
List.SetItemText(k,idx++,Db2CString(Par.m_EdiK,4));
List.SetItemText(k,idx++,Db2CString(Par.m_EdiPo,4));
}
}
//将功率密度参数写入到文件
void CLaser::WriteEnergyDensityParFile()
{
gLogMgr->WriteDebugLog("Func--->WriteEnergyDensityParFile");
CFileMgr FileMgr;
CString FilePath;
FileMgr.GetFullFilePath(FilePath,EDI_PARA_FILE);
ofstream fileStream;
fileStream.open(FilePath);//覆盖的方式
int size = m_EnergyDensityParVec.size();
for(int k=0;k<size;k++)
{
CEnergyDensityPar &Par = m_EnergyDensityParVec[k];
fileStream<<Par.m_LaserDeviceType<<",";
fileStream<<Par.m_LaserFre<<",";
fileStream<<Par.m_EdiK<<",";
fileStream<<Par.m_EdiPo<<endl;
}
}
//从文件中读取功率密度的参数
void CLaser::ReadEnergyDensityParFile()
{
gLogMgr->WriteDebugLog("Func--->ReadEnergyDensityParFile");
CFileMgr FileMgr;
CString FilePath;
FileMgr.GetFullFilePath(FilePath,EDI_PARA_FILE);
vector<vector<CString>> StrVec;
FileMgr.ReadFileToStrVec(FilePath,StrVec);
m_EnergyDensityParVec.clear();
int size = StrVec.size();
for(int k=0;k<size;k++)
{
if(StrVec[k].size() == 4)
{
CEnergyDensityPar Par;
Par.m_LaserDeviceType = CStringToInt(StrVec[k][0]);//激光的类型
Par.m_LaserFre = CStringToDouble(StrVec[k][1]);//激光的频率
Par.m_EdiK = CStringToDouble(StrVec[k][2]);//功率密度的斜率
Par.m_EdiPo = CStringToDouble(StrVec[k][3]);//功率密度的截距
m_EnergyDensityParVec.push_back(Par);
CString log;
log.Format(" F : [%.1f] K : [%lf] Po : [%lf]",Par.m_LaserFre,Par.m_EdiK,Par.m_EdiPo);
log = GetLaserDeviceName((eLaserDeviceType)Par.m_LaserDeviceType) + log;
gLogMgr->WriteDebugLog(log);
}
}
}
//将功率点检计算的值设置为保存值(手动)
void CLaser::SetEnergyDensityPar(eLaserDeviceType LaserDeviceType,double Fre,double K,double Po)
{
}
//获取功率密度的参数(返回是否存在)
bool CLaser::GetEnergyDensityPar(eLaserDeviceType LaserDeviceType,double Fre,double &K,double &Po)
{
int LaserType = (int)LaserDeviceType;
int size = m_EnergyDensityParVec.size();
for(int k=0;k<size;k++)
{
CEnergyDensityPar &Par = m_EnergyDensityParVec[k];
if(Par.m_LaserDeviceType == LaserType && IsTwoDbEqual(Fre,Par.m_LaserFre))
{
K = Par.m_EdiK;
Po = Par.m_EdiPo;
return true;
}
}
K =0;
Po = 0;
return false;
}
#endif
#if 1//激光衰减器操作
//操作激光衰减器的气缸(失败时抛出异常)
void CLaser::IOSwitchLaserDimmer(bool bOpen)
{
}
//通过XY 移动后目标坐标TargetCoord 来控制衰减器(可以抛出异常)
void CLaser::IOSwitchLaserDimmerByTargetCoord(Dbxy TargetCoord)
{
}
#endif
#if 1//激光器休眠控制
//开始激光器休眠倒计时
void CLaser::StartLaserSleepTime()
{
}
//结束激光器休眠倒计时
void CLaser::StopLaserSleepTime()
{
m_bStopLaserSleepTime = true;
gLogMgr->WriteDebugLog("Func---->StopSleepLaserTime");
}
//获取当前休眠剩余时间
CString CLaser::GetCurSleepLeftTimes()
{
CString LeftTimes;
if(m_bStopLaserSleepTime)
LeftTimes = "00:00:00";
else
LeftTimes = m_LaserSleepTime.GetLeftTimes();
return LeftTimes;
}
void CLaser::LaserSleepTimeExt()
{
}
//立即激光器休眠
void CLaser::LaserSleepImmediately()
{
gLogMgr->WriteDebugLog("Func---->Laser Sleep Immediately");
m_bStopLaserSleepTime = false;
m_LaserSleepTime.StopRecordTime();
}
#endif
#if 1
//更新激光的系统参数
void CLaser::UpdateLaserProp()
{
gLogMgr->WriteDebugLog("Func---->UpdateLaserProp");
{
//添加属性变量映射
CString Path = "Laser";
CString Name = _T("m_SpotSize_w");//变量名字
CPropertie Propertie;
Propertie.SetpVal((void*)&m_SpotSize.w);
Propertie.SetType(_PROP_TYPE_DOUBLE);
Propertie.SetPath(Path);
Propertie.SetName(Name);
Propertie.WriteRead(true);//读取属性
}
{
//添加属性变量映射
CString Path = "Laser";
CString Name = _T("m_SpotSize_h");//变量名字
CPropertie Propertie;
Propertie.SetpVal((void*)&m_SpotSize.h);
Propertie.SetType(_PROP_TYPE_DOUBLE);
Propertie.SetPath(Path);
Propertie.SetName(Name);
Propertie.WriteRead(true);//读取属性
}
CString log;
log.Format("SpotSize.w=%f,SpotSize.h=%f",m_SpotSize.w,m_SpotSize.h);
gLogMgr->WriteDebugLog(log);
}
//读取参数中当前设置的电流值
double CLaser::ReadCurSetLddCurrent(eLaserDeviceType LaserDeviceType)
{
bool bTwoLaserLddMode = false;
{
//添加属性变量映射
CString Path = "PhotonicsLaserMgr";
CString Name = _T("m_bTwoLaserLddMode");//变量名字
CPropertie Propertie;
Propertie.SetpVal((void*)&bTwoLaserLddMode);
Propertie.SetType(_PROP_TYPE_BOOL);
Propertie.SetPath(Path);
Propertie.SetName(Name);
Propertie.WriteRead(true);//读取属性
}
if(LaserDeviceType==_LaserDeviceType_MainLaser2 && !bTwoLaserLddMode)
return 0;
double Laser1LddOpenCurr = 0;
{
//添加属性变量映射
CString Path = "AnnealMonitoringMgr";
CString Name = _T("m_Laser1LddOpenCurr");//变量名字
CPropertie Propertie;
Propertie.SetpVal((void*)&Laser1LddOpenCurr);
Propertie.SetType(_PROP_TYPE_DOUBLE);
Propertie.SetPath(Path);
Propertie.SetName(Name);
Propertie.WriteRead(true);//读取属性
}
return Laser1LddOpenCurr;
}
//获取电流FixCurr 对应的功率FixPow
void CLaser::GetLaserFixedCurrentPow(eLaserDeviceType LaserDeviceType,double Fre,double FixCurr,double &FixPow)
{
//固定电流是参数设定值(激光预热完成时的电流)
//FixCurr = ReadCurSetLddCurrent(LaserDeviceType);
vector<CPowCheckPt> PowCheckPtPowCheckPVec;
gLaserPowCheckMgr->ReadLaserFixedCurrentPowFile(PowCheckPtPowCheckPVec);
int size = PowCheckPtPowCheckPVec.size();
for(int k=0;k<size;k++)
{
CPowCheckPt &PowCheckPt = PowCheckPtPowCheckPVec[k];
if(PowCheckPt.m_LaserType==LaserDeviceType && IsTwoDbEqual(PowCheckPt.m_LaserFre,Fre)&& IsTwoDbEqual(PowCheckPt.m_SetCurr,FixCurr))
{
FixPow = PowCheckPt.m_SurfacePow;
break;
}
}
}
#endif