|
|
#include "StdAfx.h"
|
|
|
#include "WorkFileMgr.h"
|
|
|
#include "GlobalDefine.h"
|
|
|
#include "TemplateMgr.h"
|
|
|
#include "WorkFileLable.h"
|
|
|
#include "LogMgr.h"
|
|
|
#include "ModuleDeviceMgr.h"
|
|
|
#include "ModuleDrawMgr.h"
|
|
|
#include "ObjComponentMgr.h"
|
|
|
#include "MsgBox.h"
|
|
|
#include "ProductMgr.h"
|
|
|
#include "GlobalFunction.h"
|
|
|
#include "LaserDeviceMgr.h"
|
|
|
#include "MarkAreaMgr.h"
|
|
|
#include "FileMgr.h"
|
|
|
#include "OptoWaveLaserMgr.h"
|
|
|
#include "Laser.h"
|
|
|
#include "PlatformXY.h"
|
|
|
#include "CommonFlowMgr.h"
|
|
|
#include "GlobalDrawMgr.h"
|
|
|
#include "ProgramCspMarkMgr.h"
|
|
|
#include "SemiSecsCommMgr.h"
|
|
|
#include "ExceptionMsg.h"
|
|
|
#include "ProgressMgr.h"
|
|
|
#include "DlgProgress.h"
|
|
|
#include "PIWaveLaserMgr.h"
|
|
|
#include "DeviceState.h"
|
|
|
|
|
|
CString CWorkFileMgr::m_CurOpenFile;
|
|
|
bool CWorkFileMgr::m_bManualOpr = false;
|
|
|
CWorkFileMgr::CWorkFileMgr(void)
|
|
|
{
|
|
|
}
|
|
|
CWorkFileMgr::~CWorkFileMgr(void)
|
|
|
{
|
|
|
}
|
|
|
#if 1
|
|
|
//是否打开文件
|
|
|
bool CWorkFileMgr::IsOpenFile()
|
|
|
{
|
|
|
if(m_CurOpenFile == "")
|
|
|
{
|
|
|
CMsgBox MsgBox;
|
|
|
MsgBox.Show("未打开文件!");
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
void CWorkFileMgr::OnOpenFile()
|
|
|
{
|
|
|
TCHAR szFilters[]=("MAK 文件(*.mak)|*.mak");
|
|
|
CFileDialog dlg(TRUE,("mak"),("MarkFile"),OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilters);
|
|
|
CString Path = gCommonFlowMgr->GetWorkFileDefualtPath();
|
|
|
dlg.m_ofn.lpstrInitialDir = Path;
|
|
|
if(dlg.DoModal()==IDOK)
|
|
|
{
|
|
|
OpenFileByPath(dlg.GetPathName());
|
|
|
}
|
|
|
}
|
|
|
bool CWorkFileMgr::OpenFileByPath(CString Path)
|
|
|
{
|
|
|
CString s = "OpenFile: ";
|
|
|
s += Path;
|
|
|
CString sMapFileName = gProgramCspMarkMgr->GetCurCspWaferParRef().m_sMapFileName;
|
|
|
gLogMgr->WriteDebugLog(s);
|
|
|
gProgressMgr.SetCurProgress(static_cast<int>(1), 3);
|
|
|
bool ReadRes= ReadWorkFile(Path);
|
|
|
if (!ReadRes)
|
|
|
{
|
|
|
AfxMessageBox("打开文件失败!");
|
|
|
gProgressMgr.SetCurProgress(static_cast<int>(3), 3);
|
|
|
return false;
|
|
|
}
|
|
|
//记录当前打开的文件名------------------------------------------
|
|
|
SaveFileName(Path);
|
|
|
gProgressMgr.SetCurProgress(static_cast<int>(2), 3);
|
|
|
gSemiSecsCommMgr->SetCurOpenRecipe(Path);
|
|
|
gProgramCspMarkMgr->GetCurCspWaferParRef().m_sMapFileName = sMapFileName;
|
|
|
if (!gProgramCspMarkMgr->GetCurCspWaferParRef().m_sMapFileName.IsEmpty())
|
|
|
{
|
|
|
OnOpenMapFile(gProgramCspMarkMgr->GetCurCspWaferParRef().m_sMapFileName);
|
|
|
}
|
|
|
gProgramCspMarkMgr->SetCurMakFilePath(Path);
|
|
|
CLayer &Layer = GetLayerInstance();
|
|
|
Layer.ResetMapDieModeTXT();
|
|
|
//重置选择打标状态
|
|
|
gProgramCspMarkMgr->ResetCurSelMarkEnd();
|
|
|
gProgressMgr.SetCurProgress(static_cast<int>(3), 3);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
void CWorkFileMgr::OpenFileByPathEAP(CString Path)
|
|
|
{
|
|
|
CString s = "OpenFile: ";
|
|
|
s += Path;
|
|
|
gLogMgr->WriteDebugLog(s);
|
|
|
|
|
|
ReadWorkFile(Path);
|
|
|
#ifdef NEW_SCP
|
|
|
#else
|
|
|
GetFrame()->m_DlgDeviceState.m_CurOpenRecipe = Path;
|
|
|
#endif
|
|
|
gSemiSecsCommMgr->SetCurOpenRecipe(Path);
|
|
|
|
|
|
CLayer &Layer = GetLayerInstance();
|
|
|
Layer.ResetMapDieModeTXT();
|
|
|
//重置选择打标状态
|
|
|
gProgramCspMarkMgr->ResetCurSelMarkEnd();
|
|
|
}
|
|
|
void CWorkFileMgr::OnOpenMapFile()
|
|
|
{
|
|
|
TCHAR szFilters[] = ("TXT 文件(*.txt)|*.txt|All Files (*.*)|*.*||");
|
|
|
CFileDialog dlg(TRUE, ("txt"), ("MarkFile"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilters);
|
|
|
CString Path = gCommonFlowMgr->GetWorkFileDefualtPath();
|
|
|
dlg.m_ofn.lpstrInitialDir = Path;
|
|
|
if (dlg.DoModal() == IDOK)
|
|
|
{
|
|
|
int type = 0;
|
|
|
CFileMgr FileMgr;
|
|
|
CString filepath;
|
|
|
if (!gProgramCspMarkMgr->GetCurMakFilePath().IsEmpty())
|
|
|
filepath = gProgramCspMarkMgr->GetCurMakFilePath();
|
|
|
else
|
|
|
FileMgr.GetFullFilePath(filepath, MAK_FILE_PATH);//获取完整路径
|
|
|
|
|
|
if (dlg.GetPathName().Find(".txt") >= 0
|
|
|
|| dlg.GetPathName().Find(".TXT") >= 0)
|
|
|
{
|
|
|
FILE* fp;
|
|
|
fp = fopen(dlg.GetPathName(), "r");
|
|
|
if (!fp)
|
|
|
return;
|
|
|
char buffer[1024];
|
|
|
CString str;
|
|
|
if (fgets(buffer, sizeof(buffer), fp) != nullptr)
|
|
|
{
|
|
|
str = buffer;
|
|
|
if (str.Find("DEVICE:") != -1)
|
|
|
type = 1;
|
|
|
else if (str.Find("ID :") != -1)
|
|
|
type = 0;
|
|
|
else
|
|
|
{
|
|
|
fclose(fp);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
fclose(fp);
|
|
|
}
|
|
|
else if (dlg.GetPathName().Find(".req") >= 0)
|
|
|
{
|
|
|
CMsgBox MsgBox;
|
|
|
MsgBox.Show("打开文件类型错误!");
|
|
|
return;
|
|
|
}
|
|
|
else if (dlg.GetPathName().Find(".mak") >= 0)
|
|
|
{
|
|
|
CString name = dlg.GetPathName();
|
|
|
//CDlgProgress dlg;
|
|
|
///gProgressMgr.SetWorkProgress(&dlg.GetProgress());
|
|
|
//std::thread t = std::thread([this, name]()
|
|
|
//{
|
|
|
OpenFileByPath(name);
|
|
|
//});
|
|
|
//dlg.DoModal();
|
|
|
//t.join();
|
|
|
//gProgressMgr.SetWorkProgress(NULL);
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
type = 2;
|
|
|
}
|
|
|
|
|
|
OpenMapFileByPath(filepath,
|
|
|
dlg.GetPathName(), type);
|
|
|
}
|
|
|
}
|
|
|
bool CWorkFileMgr::OnOpenMapFile(CString mapFile)
|
|
|
{
|
|
|
if (!mapFile.IsEmpty())
|
|
|
{
|
|
|
int type = 0;
|
|
|
CFileMgr FileMgr;
|
|
|
CString filepath;
|
|
|
if (!gProgramCspMarkMgr->GetCurMakFilePath().IsEmpty())
|
|
|
filepath = gProgramCspMarkMgr->GetCurMakFilePath();
|
|
|
else
|
|
|
FileMgr.GetFullFilePath(filepath, MAK_FILE_PATH);//获取完整路径
|
|
|
if (mapFile.Find(".txt") >= 0
|
|
|
|| mapFile.Find(".TXT") >= 0)
|
|
|
{
|
|
|
FILE* fp;
|
|
|
fp = fopen(mapFile, "r");
|
|
|
if (!fp)
|
|
|
return false;
|
|
|
char buffer[1024];
|
|
|
CString str;
|
|
|
if (fgets(buffer, sizeof(buffer), fp) != nullptr)
|
|
|
{
|
|
|
str = buffer;
|
|
|
if (str.Find("DEVICE:") != -1)
|
|
|
type = 1;
|
|
|
else if (str.Find("ID :") != -1)
|
|
|
type = 0;
|
|
|
else
|
|
|
{
|
|
|
fclose(fp);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
fclose(fp);
|
|
|
}
|
|
|
else if (mapFile.Find(".mak") >= 0)
|
|
|
{
|
|
|
return OpenFileByPath(mapFile);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
type = 2;
|
|
|
}
|
|
|
|
|
|
return OpenMapFileByPath(filepath,
|
|
|
mapFile, type);
|
|
|
}
|
|
|
}
|
|
|
bool CWorkFileMgr::OpenMapFileByPath(CString Path, CString mapFile, int type)
|
|
|
{
|
|
|
CString s = "OpenFile: ";
|
|
|
s += Path;
|
|
|
gLogMgr->WriteDebugLog(s);
|
|
|
|
|
|
bool ReadRes = ReadWorkMapFile(Path, mapFile, type);
|
|
|
if (!ReadRes)
|
|
|
{
|
|
|
//AfxMessageBox("打开文件失败!");
|
|
|
return false;
|
|
|
}
|
|
|
//记录当前打开的文件名------------------------------------------
|
|
|
SaveMapFileName(Path);
|
|
|
|
|
|
gSemiSecsCommMgr->SetCurOpenRecipe(Path);
|
|
|
|
|
|
CLayer &Layer = GetLayerInstance();
|
|
|
Layer.ResetMapDieModeTXT();
|
|
|
//重置选择打标状态
|
|
|
gProgramCspMarkMgr->ResetCurSelMarkEnd();
|
|
|
|
|
|
gObjComponentMgr->SetMapFileOpened(true);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
bool CWorkFileMgr::ReadWorkMapFile(CString FilePath, CString mapFile, int type, bool bCreatCspWaferData)
|
|
|
{
|
|
|
//读取所有内容----------------------------------------------------------
|
|
|
vector<CLab> LabVec;
|
|
|
bool ReadRes = ReadWorkFileExt(FilePath, LabVec);
|
|
|
if (!ReadRes)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
if (LabVec.empty())
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("读取文件为空!", _LOG_ERROR);
|
|
|
return false;
|
|
|
}
|
|
|
//分离每个模块------------------------------------------------------------
|
|
|
CLabVecRang LabVecRang(LabVec, 0, LabVec.size() - 1);
|
|
|
vector<CLabVecRang> LabVecRangVec;
|
|
|
|
|
|
SeparateStrVec(LabVecRang, LabVecRangVec, LAB_MODULE_START, LAB_MODULE_END);
|
|
|
|
|
|
//依次处理每个模块---------------------------------------------------
|
|
|
vector<CLabVecRang>::iterator iter = LabVecRangVec.begin();
|
|
|
vector<CLabVecRang>::iterator iter_end = LabVecRangVec.end();
|
|
|
for (; iter != iter_end; iter++)
|
|
|
{
|
|
|
if (gModuleDrawMgr.ReadWorkFile(*iter))
|
|
|
continue;//避免重复读取
|
|
|
gModuleDeviceMgr.ReadWorkFile(*iter);
|
|
|
}
|
|
|
//GetMainDlgPtr()->PostMessageA(WM_PROCESS_OPENFILE, 0, 0);
|
|
|
//CDlgProgress dlg;
|
|
|
//gProgressMgr.SetWorkProgress(&dlg.GetProgress());
|
|
|
//std::thread t = std::thread([this, mapFile, type, bCreatCspWaferData]()
|
|
|
//{
|
|
|
//读完了再生成数据
|
|
|
return OpenMapExtern(mapFile, type, bCreatCspWaferData);
|
|
|
//});
|
|
|
//dlg.DoModal();
|
|
|
//t.join();
|
|
|
//gProgressMgr.SetWorkProgress(NULL);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
bool CWorkFileMgr::OpenMapExtern(CString mapFile, int type, bool bCreatCspWaferData)
|
|
|
{
|
|
|
if (bCreatCspWaferData)
|
|
|
{
|
|
|
gProgressMgr.SetCurProgress(static_cast<int>(1), 3);
|
|
|
|
|
|
CCspWaferPar waferPar = gProgramCspMarkMgr->GetCurCspWaferPar();
|
|
|
CString name = waferPar.m_FontName;
|
|
|
CCspWaferPar wPar;
|
|
|
MapData vData;
|
|
|
if (type == 0)
|
|
|
ResolvingTxtFile(mapFile, wPar, vData);
|
|
|
else if (type == 1)
|
|
|
ResolvingSinfFile(mapFile, wPar, vData);
|
|
|
else if (type == 2)
|
|
|
ResolvingTskFile(mapFile, wPar, vData);
|
|
|
|
|
|
if (wPar != waferPar
|
|
|
&& !gProgramCspMarkMgr->GetCurMakFilePath().IsEmpty())
|
|
|
{
|
|
|
gProgressMgr.SetCurProgress(static_cast<int>(3), 3);
|
|
|
CMsgBox MsgBox;
|
|
|
CString str;
|
|
|
str.Format("size.w %f==%f size.h %f=%f row %d==%d col %d==%d file:%s",
|
|
|
wPar.m_DieSize.w, waferPar.m_DieSize.w, wPar.m_DieSize.h, waferPar.m_DieSize.h,
|
|
|
wPar.m_ArrayXcnt, waferPar.m_ArrayXcnt, wPar.m_ArrayYcnt, waferPar.m_ArrayYcnt, mapFile);
|
|
|
MsgBox.Show("Map文件与Recipe对比失败", str);
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
waferPar.m_sMapFileName = mapFile;
|
|
|
waferPar.m_nTotalDieSize = wPar.m_nTotalDieSize;
|
|
|
waferPar.m_nBin1DieSize = wPar.m_nBin1DieSize;
|
|
|
waferPar.m_nBinFailSize = wPar.m_nBinFailSize;
|
|
|
waferPar.m_ArrayXcnt = wPar.m_ArrayXcnt;
|
|
|
waferPar.m_ArrayYcnt = wPar.m_ArrayYcnt;
|
|
|
waferPar.m_DieSize = wPar.m_DieSize;
|
|
|
waferPar.m_WaferDia = wPar.m_WaferDia;
|
|
|
waferPar.m_DieAngle = wPar.m_DieAngle;
|
|
|
waferPar.m_FirstDieCoord = wPar.m_FirstDieCoord;
|
|
|
waferPar.m_mapBinCode = wPar.m_mapBinCode;
|
|
|
}
|
|
|
|
|
|
//waferPar.m_WaferDia = max((int)(waferPar.m_ArrayYcnt*waferPar.m_DieSize.h), (int)(waferPar.m_ArrayXcnt*waferPar.m_DieSize.w));
|
|
|
gProgressMgr.SetCurProgress(static_cast<int>(2), 3);
|
|
|
gProgramCspMarkMgr->SetCurCspWaferPar(waferPar);
|
|
|
gProgramCspMarkMgr->CreatCspWaferData(vData);
|
|
|
gProgressMgr.SetCurProgress(static_cast<int>(3), 3);
|
|
|
//OnSaveFile();
|
|
|
}
|
|
|
if (gProgramCspMarkMgr->IsbOldFileVersion20200714())
|
|
|
{
|
|
|
CLayer &layer = GetLayerInstance();
|
|
|
//更新Txt BasePt 为中心点
|
|
|
layer.UpdateObjTxtBasePt();
|
|
|
}
|
|
|
gProgramCspMarkMgr->SetbOldFileVersion20200714(false);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
bool CWorkFileMgr::ResolvingSinfFile(CString FilePath,CCspWaferPar& waferPar,MapData& mapData)
|
|
|
{
|
|
|
FILE* fp;
|
|
|
fp = fopen(FilePath, "r");
|
|
|
if (!fp)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
char buffer[1024]; // 假设每行不超过1024字节
|
|
|
CString str;
|
|
|
int startY = 0;
|
|
|
int startX = 0;
|
|
|
bool bForReverseX = false;//true 从右到左
|
|
|
bool bForReverseY = false;//true 从下到上
|
|
|
int i = 0;
|
|
|
int j = 0;
|
|
|
|
|
|
while (fgets(buffer, sizeof(buffer), fp) != nullptr) {
|
|
|
// 处理读取的行
|
|
|
str = buffer;
|
|
|
str.Replace("\n", "");
|
|
|
int CommaPosPer = str.Find("REFPX:", 0);
|
|
|
if (str.Find("REFPX:", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("REFPX:") + 1);
|
|
|
//waferPar.m_FirstDieCoord.x = atof(str);
|
|
|
}
|
|
|
else if (str.Find("REFPY:", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("REFPY:") + 1);
|
|
|
//waferPar.m_FirstDieCoord.y = atof(str);
|
|
|
}
|
|
|
else if (str.Find("FNLOC:", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("FNLOC:") + 1);
|
|
|
waferPar.m_DieAngle = atoi(str);
|
|
|
}
|
|
|
else if (str.Find("XDIES:", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("XDIES:") + 1);
|
|
|
waferPar.m_DieSize.w = atof(str);
|
|
|
}
|
|
|
else if (str.Find("YDIES:", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("YDIES:") + 1);
|
|
|
waferPar.m_DieSize.h = atof(str);
|
|
|
}
|
|
|
else if (str.Find("ROWCT:", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("ROWCT:") + 1);
|
|
|
waferPar.m_ArrayYcnt = atoi(str);
|
|
|
}
|
|
|
else if (str.Find("COLCT:", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("COLCT:") + 1);
|
|
|
waferPar.m_ArrayXcnt = atoi(str);
|
|
|
//如果是90度,交换行列
|
|
|
if ((waferPar.m_DieAngle / 90) % 2)
|
|
|
{
|
|
|
int t = waferPar.m_ArrayXcnt;
|
|
|
waferPar.m_ArrayXcnt = waferPar.m_ArrayYcnt;
|
|
|
waferPar.m_ArrayYcnt = t;
|
|
|
|
|
|
bForReverseX = false;//从左到右
|
|
|
bForReverseY = true; //从下到上
|
|
|
}
|
|
|
i = (waferPar.m_ArrayYcnt / 2 + waferPar.m_ArrayYcnt % 2);
|
|
|
|
|
|
startY = -waferPar.m_ArrayYcnt / 2;
|
|
|
startX = -waferPar.m_ArrayXcnt / 2;
|
|
|
if (waferPar.m_ArrayYcnt % 2 == 0) startY += 1;
|
|
|
if (waferPar.m_ArrayXcnt % 2 == 0) startX += 1;
|
|
|
//i = info.iFirstY - info.iCenterY;
|
|
|
//j = info.iFirstX - info.iCenterX;
|
|
|
if (bForReverseY) startY *= -1;
|
|
|
if (bForReverseX) startX *= -1;
|
|
|
i = startY;
|
|
|
j = startX;
|
|
|
}
|
|
|
else if (str.Find("RowData:", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("RowData:") + 1);
|
|
|
j = startX;
|
|
|
int CommaPosPer = 0;
|
|
|
do {
|
|
|
CommaPosPer = str.Find(" ", CommaPosPer);
|
|
|
CString sTemp = str.Left(CommaPosPer);
|
|
|
str = str.Right(str.GetLength() - CommaPosPer - 1);
|
|
|
if (sTemp != "___"
|
|
|
&& !sTemp.IsEmpty())
|
|
|
{
|
|
|
if (sTemp == "@@@")
|
|
|
{
|
|
|
DieData data(i, j, false, 0, "");
|
|
|
mapData.vDies.push_back(data);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
DieData data(i, j, true, 0, sTemp.GetBuffer(0));
|
|
|
mapData.vDies.push_back(data);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!bForReverseX)//从左到右
|
|
|
++j;
|
|
|
else //从右到左
|
|
|
--j;
|
|
|
} while (CommaPosPer >= 0);
|
|
|
|
|
|
if (bForReverseY) //从下到上
|
|
|
--i;
|
|
|
else //从上到下
|
|
|
++i;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
fclose(fp);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
double scientificToDecimal(std::string scientificStr)
|
|
|
{
|
|
|
size_t ePos = scientificStr.find('e');
|
|
|
if (ePos == std::string::npos)
|
|
|
{
|
|
|
throw std::invalid_argument("String is not in scientific notation");
|
|
|
}
|
|
|
|
|
|
double coefficient = std::stod(scientificStr.substr(0, ePos));
|
|
|
int exponent = std::stoi(scientificStr.substr(ePos + 1));
|
|
|
return coefficient * std::pow(10.0, exponent);
|
|
|
}
|
|
|
bool CWorkFileMgr::ResolvingTxtFile(CString FilePath, CCspWaferPar& waferPar, MapData& mapData)
|
|
|
{
|
|
|
FILE* fp;
|
|
|
fp = fopen(FilePath, "r");
|
|
|
if (!fp)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
char buffer[1024]; // 假设每行不超过1024字节
|
|
|
CString str;
|
|
|
int startY = 0;
|
|
|
int startX = 0;
|
|
|
int i = 0;
|
|
|
int j = 0;
|
|
|
bool bForReverseX = false;//true 从右到左
|
|
|
bool bForReverseY = false;//true 从下到上
|
|
|
|
|
|
while (fgets(buffer, sizeof(buffer), fp) != nullptr) {
|
|
|
// 处理读取的行
|
|
|
str = buffer;
|
|
|
str.Replace("\n", "");
|
|
|
int CommaPosPer = str.Find("Ref Points :", 0);
|
|
|
if (str.Find("Ref Points :", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("Ref Points :") - 1);
|
|
|
CommaPosPer = str.Find("_", 0);
|
|
|
if (CommaPosPer != -1)
|
|
|
{
|
|
|
int nPos = str.Find(",", 0);
|
|
|
if (nPos != -1)
|
|
|
{
|
|
|
CString value = str.Mid(CommaPosPer + 1, nPos - CommaPosPer - 1);
|
|
|
//waferPar.m_FirstDieCoord.x = atof(value);
|
|
|
str = str.Right(str.GetLength() - nPos - 1);
|
|
|
}
|
|
|
CommaPosPer = str.Find("_", 0);
|
|
|
if (CommaPosPer != -1)
|
|
|
{
|
|
|
//waferPar.m_FirstDieCoord.y = atof(str.Right(str.GetLength() - CommaPosPer - 1));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (str.Find("X_step=", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("X_step=") - 1);
|
|
|
int CommaPosPer = str.Find("*", 0);
|
|
|
if (CommaPosPer != -1)
|
|
|
{
|
|
|
CString value = str.Left(CommaPosPer);
|
|
|
waferPar.m_DieSize.w = atof(value);
|
|
|
str = str.Right(str.GetLength() - CommaPosPer - 1);
|
|
|
int posL = str.Find("(", 0);
|
|
|
int posR = str.Find(")", 0);
|
|
|
if (posL != -1
|
|
|
&& posR != -1)
|
|
|
{
|
|
|
value = str.Mid(posL + 1, posR - posL - 1);
|
|
|
value.Replace("^", "e");
|
|
|
waferPar.m_DieSize.w *= scientificToDecimal(value.GetBuffer(0));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (str.Find("Y_step=", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("Y_step=") - 1);
|
|
|
int CommaPosPer = str.Find("*", 0);
|
|
|
if (CommaPosPer != -1)
|
|
|
{
|
|
|
CString value = str.Left(CommaPosPer);
|
|
|
waferPar.m_DieSize.h = atof(value);
|
|
|
str = str.Right(str.GetLength() - CommaPosPer - 1);
|
|
|
int posL = str.Find("(", 0);
|
|
|
int posR = str.Find(")", 0);
|
|
|
if (posL != -1
|
|
|
&& posR != -1)
|
|
|
{
|
|
|
value = str.Mid(posL + 1, posR - posL - 1);
|
|
|
value.Replace("^", "e");
|
|
|
waferPar.m_DieSize.h *= scientificToDecimal(value.GetBuffer(0));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (str.Find("Flat(degree) :", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("Flat(degree) :") - 1);
|
|
|
waferPar.m_DieAngle =atoi(str);
|
|
|
}
|
|
|
else if (str.Find("_Row Count :", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("_Row Count :") - 1);
|
|
|
waferPar.m_ArrayYcnt = atoi(str);
|
|
|
}
|
|
|
else if (str.Find("_Column count :", 0) != -1)
|
|
|
{
|
|
|
str = str.Right(str.GetLength() - sizeof("_Column count :") - 1);
|
|
|
waferPar.m_ArrayXcnt = atoi(str);
|
|
|
//如果是90度,交换行列
|
|
|
if ((waferPar.m_DieAngle / 90) % 2)
|
|
|
{
|
|
|
int t = waferPar.m_ArrayXcnt;
|
|
|
waferPar.m_ArrayXcnt = waferPar.m_ArrayYcnt;
|
|
|
waferPar.m_ArrayYcnt = t;
|
|
|
|
|
|
bForReverseX = false;//从左到右
|
|
|
bForReverseY = true; //从下到上
|
|
|
}
|
|
|
i = (waferPar.m_ArrayYcnt / 2 + waferPar.m_ArrayYcnt % 2);
|
|
|
|
|
|
startY = -waferPar.m_ArrayYcnt / 2;
|
|
|
startX = -waferPar.m_ArrayXcnt / 2;
|
|
|
if (waferPar.m_ArrayYcnt % 2 == 0) startY += 1;
|
|
|
if (waferPar.m_ArrayXcnt % 2 == 0) startX += 1;
|
|
|
//i = info.iFirstY - info.iCenterY;
|
|
|
//j = info.iFirstX - info.iCenterX;
|
|
|
if (bForReverseY) startY *= -1;
|
|
|
if (bForReverseX) startX *= -1;
|
|
|
i = startY;
|
|
|
j = startX;
|
|
|
}
|
|
|
else if (str.GetAt(0)!='/')
|
|
|
{
|
|
|
j = startX;
|
|
|
while (!str.IsEmpty())
|
|
|
{
|
|
|
if (str.GetAt(0) == 'x')
|
|
|
{
|
|
|
DieData data(i, j, false, 0, "");
|
|
|
mapData.vDies.push_back(data);
|
|
|
}
|
|
|
else if (str.GetAt(0) != '.')
|
|
|
{
|
|
|
DieData data(i, j, true, 0, str.Left(1).GetBuffer(0));
|
|
|
mapData.vDies.push_back(data);
|
|
|
}
|
|
|
str.Delete(0, 1);
|
|
|
|
|
|
if (!bForReverseX)//从左到右
|
|
|
++j;
|
|
|
else //从右到左
|
|
|
--j;
|
|
|
}
|
|
|
|
|
|
if (bForReverseY) //从下到上
|
|
|
--i;
|
|
|
else //从上到下
|
|
|
++i;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
fclose(fp);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
char getBit(char ch, int position)
|
|
|
{
|
|
|
if (position < 0 || position > 7) {
|
|
|
std::cerr << "Position must be between 0 and 7." << std::endl;
|
|
|
return -1;
|
|
|
}
|
|
|
// 将位置转换为移位位数
|
|
|
int shift = 7 - position;
|
|
|
// 使用位掩码和移位操作获取位值
|
|
|
return (ch >> shift) & 1;
|
|
|
}
|
|
|
bool CWorkFileMgr::ResolvingTskFile(CString FilePath, CCspWaferPar& waferPar, MapData& mapData)
|
|
|
{
|
|
|
FILE* fp;
|
|
|
fp = fopen(FilePath, "rb");
|
|
|
if (!fp)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
unsigned char buffer[1024]; // 假设每行不超过1024字节
|
|
|
CString str;
|
|
|
TskMapHeadInfo info;
|
|
|
TskDie1Byte die1;
|
|
|
TskDie2Byte die2;
|
|
|
TskDie3Byte die3;
|
|
|
bool bForReverseX = false;//true 从右到左
|
|
|
bool bForReverseY = false;//true 从下到上
|
|
|
int i = 0;
|
|
|
int j = 0;
|
|
|
//while (fgets(buffer, sizeof(buffer), fp) != nullptr)
|
|
|
{
|
|
|
// 处理读取的行
|
|
|
str = buffer;
|
|
|
int n = fread(buffer, 1, sizeof(TskMapHeadInfo), fp);
|
|
|
info = *(TskMapHeadInfo*)buffer;
|
|
|
info.SwapInt();
|
|
|
|
|
|
waferPar.m_DieSize.h = info.iSizeY * 1.0 / 100000.0;
|
|
|
waferPar.m_DieSize.w = info.iSizeX * 1.0 / 100000.0;
|
|
|
waferPar.m_ArrayXcnt = info.iCols;
|
|
|
waferPar.m_ArrayYcnt = info.iRows;
|
|
|
waferPar.m_WaferDia = max((int)(waferPar.m_ArrayYcnt*waferPar.m_DieSize.h), (int)(waferPar.m_ArrayXcnt*waferPar.m_DieSize.w));
|
|
|
waferPar.m_FirstDieCoord.x = info.iOffsetCenterX * 1.0 / 100000.0;
|
|
|
waferPar.m_FirstDieCoord.y = info.iOffsetCenterY * 1.0 / 100000.0;
|
|
|
waferPar.m_DieAngle = info.iAngle;
|
|
|
if (info.iSize == 60)
|
|
|
{
|
|
|
waferPar.m_WaferDia = 150;
|
|
|
gProgramCspMarkMgr->SetCspWaferType(_CspWaferType_6);
|
|
|
}
|
|
|
else if (info.iSize == 80)
|
|
|
{
|
|
|
waferPar.m_WaferDia = 200;
|
|
|
gProgramCspMarkMgr->SetCspWaferType(_CspWaferType_8);
|
|
|
}
|
|
|
//如果是90度,交换行列
|
|
|
if ((waferPar.m_DieAngle / 90) % 2)
|
|
|
{
|
|
|
int t = waferPar.m_ArrayXcnt;
|
|
|
waferPar.m_ArrayXcnt = waferPar.m_ArrayYcnt;
|
|
|
waferPar.m_ArrayYcnt = t;
|
|
|
info.iRows = waferPar.m_ArrayYcnt;
|
|
|
info.iCols = waferPar.m_ArrayXcnt;
|
|
|
}
|
|
|
//根据角度,确定正负方向
|
|
|
if (waferPar.m_DieAngle == 180)
|
|
|
{
|
|
|
bForReverseX = false; //从左到右
|
|
|
bForReverseY = true; //从下到上
|
|
|
}
|
|
|
|
|
|
////X方向 1:left 2:right
|
|
|
//if (info.cXDirect == 1)
|
|
|
// bForReverseX = false;
|
|
|
//else
|
|
|
// bForReverseX = true;
|
|
|
////Y方向 1:forward 2:backward
|
|
|
//if (info.cYDirect == 1)
|
|
|
// bForReverseY = false;
|
|
|
//else
|
|
|
// bForReverseY = true;
|
|
|
//以原点第一个DIE向四周延申
|
|
|
int startY = -info.iRows / 2;
|
|
|
int startX = -info.iCols / 2;
|
|
|
if (info.iRows % 2 == 0) startY += 1;
|
|
|
if (info.iCols % 2 == 0) startX += 1;
|
|
|
//i = info.iFirstY - info.iCenterY;
|
|
|
//j = info.iFirstX - info.iCenterX;
|
|
|
if (bForReverseY) startY *= -1;
|
|
|
if (bForReverseX) startX *= -1;
|
|
|
i = startY;
|
|
|
j = startX;
|
|
|
|
|
|
int count = info.iCols * info.iRows;
|
|
|
|
|
|
while (count--)
|
|
|
{
|
|
|
n = fread(buffer, 1, 2, fp);
|
|
|
die1.Conver(*(unsigned short*)buffer);
|
|
|
n = fread(buffer, 1, 2, fp);
|
|
|
die2.Conver(*(unsigned short*)buffer);
|
|
|
n = fread(buffer, 1, 2, fp);
|
|
|
die3.Conver(*(unsigned short*)buffer);
|
|
|
|
|
|
//char szFilePath[MAX_PATH + 1] = { 0 };
|
|
|
//sprintf(szFilePath, "x:%d,y:%d,format:%d %d\n", die1.iCoordX, die2.iCoordY, die2.iValueX, die2.iValueY);
|
|
|
//OutputDebugStringA(szFilePath);
|
|
|
//正常DIE
|
|
|
//根据mapping数据索引
|
|
|
int iRowIndex = die2.iValueY == 0 ? die2.iCoordY : -die2.iCoordY;
|
|
|
int iColIndex = die2.iValueX == 0 ? die1.iCoordX : -die1.iCoordX;
|
|
|
iColIndex -= info.iCenterX;
|
|
|
iRowIndex -= info.iCenterY;
|
|
|
|
|
|
if (info.cXDirect == 1) iColIndex = -iColIndex;
|
|
|
if (info.cYDirect == 1) iRowIndex = -iRowIndex;
|
|
|
//iRowIndex = i;
|
|
|
//iColIndex = j;
|
|
|
|
|
|
if (die1.iTestRes == 1)
|
|
|
{
|
|
|
DieData data(iRowIndex, iColIndex, 1, 0, std::to_string(die3.iBinCode));
|
|
|
data.iMark = die1.iMark;
|
|
|
mapData.vDies.push_back(data);
|
|
|
waferPar.m_nBin1DieSize++;
|
|
|
}
|
|
|
else if (die1.iTestRes == 0)//测试DIE
|
|
|
{
|
|
|
DieData data(iRowIndex, iColIndex, 0, 0, std::to_string(die3.iBinCode));
|
|
|
data.iMark = die1.iMark;
|
|
|
mapData.vDies.push_back(data);
|
|
|
waferPar.m_nBin1DieSize++;
|
|
|
}
|
|
|
else//故障DIE
|
|
|
{
|
|
|
DieData data(iRowIndex, iColIndex, 2, 0, std::to_string(die3.iBinCode));
|
|
|
data.iMark = die1.iMark;
|
|
|
mapData.vDies.push_back(data);
|
|
|
waferPar.m_nBinFailSize++;
|
|
|
}
|
|
|
|
|
|
waferPar.m_mapBinCode[die3.iBinCode]++;
|
|
|
|
|
|
//序满一行的列就序下一行
|
|
|
if (!bForReverseX)
|
|
|
{
|
|
|
if (++j > info.iCols / 2)
|
|
|
{
|
|
|
if (!bForReverseY)
|
|
|
++i;
|
|
|
else
|
|
|
--i;
|
|
|
j = startX;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (--j < -info.iCols / 2)
|
|
|
{
|
|
|
if (!bForReverseY)
|
|
|
++i;
|
|
|
else
|
|
|
--i;
|
|
|
j = startX;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
fclose(fp);
|
|
|
//总DIE数量=BIN1+故障
|
|
|
auto it = waferPar.m_mapBinCode.find(1);
|
|
|
if (it != waferPar.m_mapBinCode.end())
|
|
|
{
|
|
|
waferPar.m_nTotalDieSize = it->second + waferPar.m_nBinFailSize;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
//记录打开文件的名字,并显示到标题
|
|
|
void CWorkFileMgr::SaveFileName(CString FileName)
|
|
|
{
|
|
|
m_CurOpenFile = FileName;
|
|
|
gProgramCspMarkMgr->SetCurMakFilePath(m_CurOpenFile);
|
|
|
#ifndef NEW_SCP
|
|
|
GetCurDocPtr()->SetTitle(m_CurOpenFile);
|
|
|
#else
|
|
|
string path = m_CurOpenFile;
|
|
|
string::size_type iPos = path.find_last_of('\\') + 1;
|
|
|
string filename = path.substr(iPos, path.length() - iPos);
|
|
|
GetMainDlgPtr()->SetTitleRecipeFile(filename.c_str());
|
|
|
#endif
|
|
|
}
|
|
|
void CWorkFileMgr::SaveMapFileName(CString FileName)
|
|
|
{
|
|
|
m_CurOpenFile = FileName;
|
|
|
gProgramCspMarkMgr->SetCurMakFilePath(m_CurOpenFile);
|
|
|
}
|
|
|
//保存当前打开的文档
|
|
|
bool CWorkFileMgr::OnSaveFile()
|
|
|
{
|
|
|
if(m_CurOpenFile == "")//新的文件
|
|
|
{
|
|
|
//另存为
|
|
|
if (OnSaveFileAs())
|
|
|
return true;
|
|
|
}
|
|
|
else//保存当前打开的文件
|
|
|
{
|
|
|
SaveFile(m_CurOpenFile);
|
|
|
CMsgBox MsgBox;
|
|
|
MsgBox.Show(m_CurOpenFile+" 保存成功!");
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
//另存为
|
|
|
bool CWorkFileMgr::OnSaveFileAs()
|
|
|
{
|
|
|
TCHAR szFilters[]=("MAK 文件(*.mak)|*.mak");
|
|
|
CFileDialog dlg(FALSE,("mak"),("MarkFile"),OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilters);
|
|
|
CString Path = gCommonFlowMgr->GetWorkFileDefualtPath();
|
|
|
dlg.m_ofn.lpstrInitialDir = Path;
|
|
|
if(dlg.DoModal()==IDOK)
|
|
|
{
|
|
|
SaveFile(dlg.GetPathName());
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
void CWorkFileMgr::SaveFile(CString FileName)
|
|
|
{
|
|
|
SaveWorkFile(FileName);
|
|
|
SaveFileName(FileName);
|
|
|
}
|
|
|
#endif
|
|
|
#if 1
|
|
|
|
|
|
void CWorkFileMgr::SaveWorkFile(CString FilePath)
|
|
|
{
|
|
|
vector<CLab> LabVec;//存储所有标签的容器
|
|
|
//在这里指定需要存储的模块
|
|
|
//搜集所有标签
|
|
|
gProgramCspMarkMgr->SaveWorkFile(LabVec);//CSP参数
|
|
|
gTemplateMgr->SaveWorkFile(LabVec);//图形参数
|
|
|
gObjComponentMgr->SaveWorkFile(LabVec);//obj 对象坐标
|
|
|
|
|
|
SaveWorkFileExt(FilePath,LabVec);
|
|
|
}
|
|
|
|
|
|
//所有标签写入文件
|
|
|
void CWorkFileMgr::SaveWorkFileExt(CString FilePath,vector<CLab> &LabVec)
|
|
|
{
|
|
|
CFile file(FilePath,CFile::modeReadWrite|CFile::modeCreate);
|
|
|
CArchive ar(&file,CArchive::store);
|
|
|
|
|
|
size_t LabCnt = LabVec.size();
|
|
|
|
|
|
ar<<LabCnt;//标签的个数
|
|
|
vector<CLab>::iterator iter = LabVec.begin();
|
|
|
vector<CLab>::iterator iter_end = LabVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
(*iter).Serialize(ar);
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
#if 1
|
|
|
//打开obj 文件
|
|
|
void CWorkFileMgr::OpenObjFile()
|
|
|
{
|
|
|
TCHAR szFilters[]=("OBJ 文件(*.obj)|*.obj");
|
|
|
CFileDialog dlg(TRUE,("obj"),("ObjFile"),OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilters);
|
|
|
if(dlg.DoModal()==IDOK)
|
|
|
{
|
|
|
//gDraw->SetbDelOldObj(false);//不要删除原来的obj
|
|
|
ReadObjTemplateFile(dlg.GetPathName());
|
|
|
CLayer &layer = GetLayerInstance();
|
|
|
layer.NotSelAllObj();
|
|
|
GetCurViewPtr()->RefreshView();
|
|
|
//gDraw->SetbDelOldObj(true);
|
|
|
}
|
|
|
}
|
|
|
//保存obj 文件
|
|
|
void CWorkFileMgr::SaveObjFile()
|
|
|
{
|
|
|
TCHAR szFilters[]=("OBJ 文件(*.obj)|*.obj");
|
|
|
CFileDialog dlg(FALSE,("obj"),("ObjFile"),OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilters);
|
|
|
if(dlg.DoModal()==IDOK)
|
|
|
{
|
|
|
SaveObjTemplateFile(dlg.GetPathName());
|
|
|
}
|
|
|
}
|
|
|
//通过文件名打开obj 文件(相对路径)
|
|
|
void CWorkFileMgr::ReadObjFileByName(CString FileName)
|
|
|
{
|
|
|
CFileMgr FileMgr;
|
|
|
CString FilePath;//完整路径
|
|
|
FileMgr.GetFullFilePath(FilePath,FileName);
|
|
|
ReadObjTemplateFile(FilePath);
|
|
|
}
|
|
|
//通过文件名打开obj 文件(绝对路径)
|
|
|
void CWorkFileMgr::ReadObjTemplateFile(CString FilePath)
|
|
|
{
|
|
|
ReadWorkFile(FilePath);
|
|
|
}
|
|
|
//只保存obj 模板数据
|
|
|
void CWorkFileMgr::SaveObjTemplateFile(CString FilePath)
|
|
|
{
|
|
|
vector<CLab> LabVec;//存储所有标签的容器
|
|
|
//搜集所有标签
|
|
|
gTemplateMgr->SaveWorkFile(LabVec);
|
|
|
//所有标签写入文件
|
|
|
SaveWorkFileExt(FilePath,LabVec);
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
#if 1
|
|
|
bool CWorkFileMgr::ReadWorkFile(CString FilePath,bool bCreatCspWaferData)
|
|
|
{
|
|
|
//读取所有内容----------------------------------------------------------
|
|
|
vector<CLab> LabVec;
|
|
|
bool ReadRes=ReadWorkFileExt(FilePath,LabVec);
|
|
|
if (!ReadRes)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
if (LabVec.empty())
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("读取文件为空!", _LOG_ERROR);
|
|
|
return false;
|
|
|
}
|
|
|
//分离每个模块------------------------------------------------------------
|
|
|
CLabVecRang LabVecRang(LabVec,0,LabVec.size()-1);
|
|
|
vector<CLabVecRang> LabVecRangVec;
|
|
|
|
|
|
SeparateStrVec(LabVecRang,LabVecRangVec,LAB_MODULE_START,LAB_MODULE_END);
|
|
|
|
|
|
//依次处理每个模块---------------------------------------------------
|
|
|
vector<CLabVecRang>::iterator iter = LabVecRangVec.begin();
|
|
|
vector<CLabVecRang>::iterator iter_end = LabVecRangVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if(gModuleDrawMgr.ReadWorkFile(*iter))
|
|
|
continue;//避免重复读取
|
|
|
gModuleDeviceMgr.ReadWorkFile(*iter);
|
|
|
}
|
|
|
//读完了再生成数据
|
|
|
if(bCreatCspWaferData)
|
|
|
{
|
|
|
gProgramCspMarkMgr->CreatCspWaferData();
|
|
|
}
|
|
|
if(gProgramCspMarkMgr->IsbOldFileVersion20200714())
|
|
|
{
|
|
|
CLayer &layer = GetLayerInstance();
|
|
|
//更新Txt BasePt 为中心点
|
|
|
layer.UpdateObjTxtBasePt();
|
|
|
}
|
|
|
gProgramCspMarkMgr->SetbOldFileVersion20200714(false);
|
|
|
return true;
|
|
|
}
|
|
|
bool CWorkFileMgr::ReadWorkFileExt(CString FilePath,vector<CLab> &LabVec)
|
|
|
{
|
|
|
CFile file;
|
|
|
if(file.Open(FilePath,CFile::modeRead))
|
|
|
{
|
|
|
CArchive ar(&file,CArchive::load);
|
|
|
size_t LabCnt;
|
|
|
ar>>LabCnt;//先读取标签的个数
|
|
|
|
|
|
for(size_t i=0;i<LabCnt;i++)
|
|
|
{
|
|
|
CLab Lab;
|
|
|
Lab.Serialize(ar);
|
|
|
LabVec.push_back(Lab);
|
|
|
}
|
|
|
file.Close();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("文件读取失败", _LOG_ERROR);
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
//从LabVecRang 中根据StrLabStart 和StrLabEnd 标签提取连续的str 保存到LabVecRangVec
|
|
|
void CWorkFileMgr::SeparateStrVec(CLabVecRang &LabVecRang,vector<CLabVecRang> &LabVecRangVec,LAB_TYPE StrLabStart,LAB_TYPE StrLabEnd)
|
|
|
{
|
|
|
size_t StartCnt = 0;//避免嵌套的情况
|
|
|
size_t StartIdx = 0;
|
|
|
size_t EndIdx = 0;
|
|
|
|
|
|
size_t Start = LabVecRang.GetStart();
|
|
|
size_t End = LabVecRang.GetEnd()+1;
|
|
|
for(size_t i=Start;i<End;i++)
|
|
|
{
|
|
|
if(LabVecRang.GetLabType(i)==StrLabStart)
|
|
|
{
|
|
|
if(StartCnt==0)//只有第一个才记录
|
|
|
{
|
|
|
StartIdx = i+1;//记录分离开始位置
|
|
|
}
|
|
|
StartCnt++;
|
|
|
}
|
|
|
if(LabVecRang.GetLabType(i)==StrLabEnd)
|
|
|
{
|
|
|
if(StartCnt==1)
|
|
|
{
|
|
|
EndIdx = i-1;//目的是去掉判断的两个标签
|
|
|
//if(EndIdx>StartIdx)//不要搜集空的范围
|
|
|
{
|
|
|
CLabVecRang Rang(LabVecRang.GetVec(),StartIdx,EndIdx);
|
|
|
LabVecRangVec.push_back(Rang);
|
|
|
}
|
|
|
}
|
|
|
StartCnt--;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//在StrVec 查找和标签LabStr 匹配的字符串,并且提取标签的值,没有值返回""
|
|
|
CLab CWorkFileMgr::FindLab(CLabVecRang &LabVecRang,LAB_TYPE LabStr)
|
|
|
{
|
|
|
CLab ret;
|
|
|
size_t Start = LabVecRang.GetStart();
|
|
|
size_t End = LabVecRang.GetEnd()+1;
|
|
|
for(size_t i=Start;i<End;i++)
|
|
|
{
|
|
|
if(LabVecRang.GetLabType(i)==LabStr)
|
|
|
{
|
|
|
ret = LabVecRang.GetLab(i);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
#endif
|