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.

102 lines
3.0 KiB
C++

#include "StdAfx.h"
#include "OffsetTable.h"
#include "FileMgr.h"
#include "CStringFuc.h"
COffsetTable::COffsetTable()
{
InitOffsetTable();
}
COffsetTable::~COffsetTable(void)
{
}
void COffsetTable::InitOffsetTable()
{
{
COffsetTablePar TablePar;
TablePar.m_ParName = RECIPE_OFFSET_PAR_LASER1_EDI;
TablePar.m_ParShowName = "Laser1 Edi Offset";
TablePar.m_ParUnit = "J/cm2";
m_OffsetTableParVec.push_back(TablePar);
}
{
COffsetTablePar TablePar;
TablePar.m_ParName = RECIPE_OFFSET_PAR_LASER2_EDI;
TablePar.m_ParShowName = "Laser2 Edi Offset";
TablePar.m_ParUnit = "J/cm2";
m_OffsetTableParVec.push_back(TablePar);
}
{
COffsetTablePar TablePar;
TablePar.m_ParName = RECIPE_OFFSET_PAR_LASER1_CURR;
TablePar.m_ParShowName = "Laser1 Current Offset";
TablePar.m_ParUnit = "A";
m_OffsetTableParVec.push_back(TablePar);
}
{
COffsetTablePar TablePar;
TablePar.m_ParName = RECIPE_OFFSET_PAR_LASER2_CURR;
TablePar.m_ParShowName = "Laser2 Current Offset";
TablePar.m_ParUnit = "A";
m_OffsetTableParVec.push_back(TablePar);
}
}
bool COffsetTable::ReadOffsetTableFile(CString FilePath)
{
//ÏȰѲÎÊý¹éÁã
int size = m_OffsetTableParVec.size();
for(int k=0;k<size;k++)
{
COffsetTablePar &TablePar = m_OffsetTableParVec[k];
TablePar.m_ParVal = 0;
}
CFileMgr FileMgr;
if(!FileMgr.IsFileExist(FilePath))
return false;
vector<vector<CString>> StrVec;
FileMgr.ReadFileToStrVec(FilePath,StrVec);
size = StrVec.size();
for(int k=0;k<size;k++)
{
if(StrVec[k].size() == 2)
{
CString ParName = (StrVec[k][0]);
int size1 = m_OffsetTableParVec.size();
for(int i=0;i<size1;i++)
{
COffsetTablePar &TablePar = m_OffsetTableParVec[i];
if(TablePar.m_ParName==ParName)
{
TablePar.m_ParVal = CStringToDouble(StrVec[k][1]);
break;
}
}
}
}
return true;
}
void COffsetTable::SaveOffsetTableFile(CString FilePath)
{
ofstream FileStream;
FileStream.open(FilePath);
int size = m_OffsetTableParVec.size();
for(int k=0;k<size;k++)
{
COffsetTablePar &TablePar = m_OffsetTableParVec[k];
FileStream<<TablePar.m_ParName<<","<<TablePar.m_ParVal<<"\n";
}
}
double COffsetTable::GetOffsetParVal(CString ParName)
{
int size = m_OffsetTableParVec.size();
for(int k=0;k<size;k++)
{
COffsetTablePar &TablePar = m_OffsetTableParVec[k];
if(TablePar.m_ParName==ParName)
return TablePar.m_ParVal;
}
return 0;
}