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.

660 lines
21 KiB
C++

#include "StdAfx.h"
#include "WorkRecord.h"
#include "Propertie.h"
#include "PropertieMgr.h"
#include "AuthorityMgr.h"
#include "WorkTime.h"
#include "FileMgr.h"
#include "LogMgr.h"
#include "GlobalFunction.h"
#include "WorkFileMgr.h"
#include "CStringFuc.h"
#include "ProgramLaserTuiHuo.h"
#include "AllThreadMgr.h"
#include "WaferRecipeDataMgr.h"
#include "RecipeMgr.h"
#include "Layer.h"
#include "Laser.h"
#include "MsgBox.h"
#include "MyDlgView.h"
#include "TimingProgressMgr.h"
#include "ObjFillMgr.h"
#define RECORD_FILE_PATH _T("\\WorkRecord")
#define RECOR_JOB_ID "Job ID"
#define RECOR_LOT_ID "Lot ID"
#define RECOR_RECIPE "Recipe"
#define RECOR_LAYER_IDX "<22><><EFBFBD><EFBFBD>"
#define RECOR_START_TIME "<22><>ʼʱ<CABC><CAB1>"
#define RECOR_SPAN_TIME "<22>ӹ<EFBFBD>ʱ<EFBFBD><CAB1>"
#define RECOR_SPAN_TIME_S "<22>ӹ<EFBFBD>ʱ<EFBFBD><CAB1>(<28><>)"
#define RECOR_SPAN_USER_NAME "<22>û<EFBFBD><C3BB><EFBFBD>"
#define RECOR_SPAN_USER_TYPE "<22>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>"
#define RECOR_SPAN_START_SCAN_IDX "<22><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ֵ"
#define RECOR_SPAN_END_SCAN_IDX "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ"
#define RECOR_SPAN_TOTAL_SCAN_IDX "ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
#define RECOR_FOCUS_Z_COORD "<22><><EFBFBD><EFBFBD><E2BDB9>λ<EFBFBD><CEBB>" //<2F>˻<EFBFBD>ʱZ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ(ÿƬwafer <20><><EFBFBD>ܻ<EFBFBD><DCBB>еһ<E3B2BB><D2BB>)
#define RECOR_DISMETER_OFFSET "<22><><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>ֵ"//<2F><>¼<EFBFBD>˵<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define RECOR_LASER_SPOT_W "<22><><EFBFBD>߿<EFBFBD><DFBF><EFBFBD>"
#define RECOR_LASER_SPOT_H "<22><><EFBFBD>߸߶<DFB8>"
#define RECOR_SET_LASER1_CURR "<22><EFBFBD><E8B6A8><EFBFBD><EFBFBD>1 <20><><EFBFBD><EFBFBD>"
#define RECOR_SET_LASER2_CURR "<22><EFBFBD><E8B6A8><EFBFBD><EFBFBD>2 <20><><EFBFBD><EFBFBD>"
//<2F><>ʱ<EFBFBD>߳<EFBFBD>(<28><><EFBFBD><EFBFBD>֪ͨ<CDA8>۲<EFBFBD><DBB2><EFBFBD>ʱ<EFBFBD><EFBFBD><E4B7A2><EFBFBD>仯)
UINT RecordTimeThread(LPVOID pParam)
{
CWorkRecordMgr *p = (CWorkRecordMgr *)pParam;
p->UpdateCurRecordTime();
return 0;
}
CWorkRecordMgr *gWorkRecordMgr = new CWorkRecordMgr;
CWorkRecordMgr::CWorkRecordMgr(void)
{
m_CurProcessingTime = "00:00:00";
m_CurTotalWorkTime = "00:00:00";//<2F><>ǰ<EFBFBD>ܵļӹ<C4BC>ʱ<EFBFBD><CAB1>
m_bSelWorkInfoRecord = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ѡ<EFBFBD>еļ<D0B5>¼
}
CWorkRecordMgr::~CWorkRecordMgr(void)
{
}
void CWorkRecordMgr::OnAppInitialize()
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>ӹ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
CWinThread* pThread;
pThread = AfxBeginThread(RecordTimeThread,this);
gAllThreadMgr.BindingThreadAdr(_EThreadType_RecordTimeThread,pThread);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼Ŀ¼<C4BF>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
#if 0
CString RecordPath;
CFileMgr FileMgr;
FileMgr.GetFullFilePath(RecordPath,RECORD_FILE_PATH);
if(!FileMgr.IsFileExist(RecordPath))
{
FileMgr.CreatDir(RecordPath);
}
#endif
}
//ˢ<>µ<EFBFBD>ǰʱ<C7B0><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void CWorkRecordMgr::UpdateCurRecordTime()
{
while(1)
{
if(gAllThreadMgr.IsbStopAllThread())
break;
gAllThreadMgr.SetThreadInfoState(_EThreadType_RecordTimeThread,true);
CString SpanStr = m_WorkTime.GetTimeSpanStr();
if(SpanStr !="")
{
m_CurProcessingTime = SpanStr;//<2F><>ǰ<EFBFBD>ӹ<EFBFBD>ʱ<EFBFBD><CAB1>
}
Sleep(500);
}
gAllThreadMgr.SetThreadInfoState(_EThreadType_RecordTimeThread,false);
}
#if 1
//<2F><>ʼ<EFBFBD><CABC>¼
void CWorkRecordMgr::StartRecord()
{
gLogMgr->WriteDebugLog("Func---->RecordMgr Start Record");
//<2F><>¼<EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD>ʼʱ<CABC><CAB1>
m_WorkStartTime = m_WorkTime.GetCurTime(":");
m_WorkTime.StartRecordTime();
//<2F><>¼<EFBFBD><C2BC>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
CObjContainer &ObjContainer = gLayer.GetObjContainer();
if(_ScanStateType_AllScanned == GetCurScanStateType())
{
//<2F><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8>״̬
ResetScanState();
gLayer.ResetAllObjScaned();
}
//<2F><>¼<EFBFBD><C2BC>ǰɨ<C7B0><C9A8><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>
m_CurScanState.m_TotalScanLineCnt = ObjContainer.GetScanLineCnt();
//<2F><>¼ɨ<C2BC>ʼ<E8BFAA><CABC>idx
m_CurScanState.m_StartScanLineIdx = m_CurScanState.m_EndScanLineIdx;
m_CurScanState.m_ScanedLineCnt = 0;
GetCurScanStateType();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
void CWorkRecordMgr::EndRecord()
{
m_CurScanState.m_EndScanLineIdx = m_CurScanState.m_StartScanLineIdx + m_CurScanState.m_ScanedLineCnt;
GetCurScanStateType();
//<2F><><EFBFBD><EFBFBD>obj <20><>ɨ<EFBFBD><C9A8>״̬
CObjContainer &ObjContainer = gLayer.GetObjContainer();
ObjContainer.SetObjScanState(m_CurScanState.m_EndScanLineIdx);
//<2F><><EFBFBD><EFBFBD>Ҫɨ<D2AA><C9A8>һ<EFBFBD><D2BB><EFBFBD>߶βż<CEB2>¼
if(m_CurScanState.m_ScanedLineCnt>1)
{
//<2F><><EFBFBD>浱ǰ<E6B5B1>ļӹ<C4BC><D3B9><EFBFBD>¼
SaveCurWorkRecord();
}
}
//ֹͣ<CDA3><D6B9>¼ʱ<C2BC><CAB1>
void CWorkRecordMgr::EndRecordTime()
{
m_WorkTime.StopRecordTime();
double SpanSecond = m_WorkTime.GetTimeSpanSecond();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>OEE
m_CurRecordTimeSecond = Db2CString(SpanSecond);
}
#endif
#if 1
//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>ɨ<EFBFBD><C9A8>״̬
EScanStateType CWorkRecordMgr::GetCurScanStateType()
{
CString str;
EScanStateType ScanState;
int EndScanLineIdx = m_CurScanState.m_EndScanLineIdx;
int TotalScanLineCnt = m_CurScanState.m_TotalScanLineCnt;
str.Format("Par---->StartIdx[%ld]Scaned[%ld]EndIdx[%ld]Total[%ld]",m_CurScanState.m_StartScanLineIdx,m_CurScanState.m_ScanedLineCnt,EndScanLineIdx,TotalScanLineCnt);
gLogMgr->WriteDebugLog(str);
if(EndScanLineIdx==0)
{
ScanState = _ScanStateType_NotScanned;
str = ("CurScanState: _NotScanned");
}
else if(EndScanLineIdx>0 && (EndScanLineIdx < (TotalScanLineCnt)))
{
ScanState = _ScanStateType_PartiallyScanned;
str = ("CurScanState: _PartiallyScanned");
}
else if(EndScanLineIdx >= (TotalScanLineCnt))
{
ScanState = _ScanStateType_AllScanned;
str = ("CurScanState: _AllScanned");
}
else
{
ScanState = _ScanStateType_Null;
str = ("CurScanState: _Type_Null");
}
gLogMgr->WriteDebugLog(str);
return ScanState;
}
//<2F><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8>״̬
void CWorkRecordMgr::ResetScanState()
{
gLogMgr->WriteDebugLog("Func---->ResetScanState");
m_CurScanState.m_EndScanLineIdx = 0;
m_CurScanState.m_ScanedLineCnt = 0;
}
#endif
#if 1
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ΪFileName <20>ļ<EFBFBD>¼·<C2BC><C2B7>
CString CWorkRecordMgr::GetRecordFilePath(CString FileName)
{
CString FullFilePath;
CString WorkRecordFilePath = gProgramLaserTuiHuo->GetWorkRecordFilePath();
if(WorkRecordFilePath=="")
{
CString FilePath = RECORD_FILE_PATH;
FilePath += "\\" + FileName + ".rcd";
CFileMgr FileMgr;
FileMgr.GetFullFilePath(FullFilePath,FilePath);
}
else
{
FullFilePath = WorkRecordFilePath+"\\" + FileName + ".rcd";
}
return FullFilePath;
}
//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>¼<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(0<>㵽24<32><34><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>)
CString CWorkRecordMgr::GetCurRecordFileName()
{
return m_WorkTime.GetCurDate("_");
}
#endif
#if 1
//<2F><><EFBFBD>浱ǰ<E6B5B1>ļӹ<C4BC><D3B9><EFBFBD>¼
void CWorkRecordMgr::SaveCurWorkRecord()
{
gLogMgr->WriteDebugLog("Func---->SaveCurWorkRecord");
CWorkRecord WorkRecord;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ļӹ<C4BC><D3B9><EFBFBD>¼
CreatCurWorkRecord(WorkRecord);
//<2F>ӹ<EFBFBD><D3B9><EFBFBD>¼д<C2BC><EFBFBD>ļ<EFBFBD>
WriteWorkRecordToFile(WorkRecord);
//<2F>ۼ<EFBFBD>CyclicWafer <20><><EFBFBD><EFBFBD>
gProgramLaserTuiHuo->CyclicWaferInc();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ļӹ<C4BC><D3B9><EFBFBD>¼
void CWorkRecordMgr::CreatCurWorkRecord(CWorkRecord &WorkRecord)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
CreatBaseInfoRecord(WorkRecord);
//<2F><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
CreatScanDataRecord(WorkRecord);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰRecipe <20><>Ϣ
CreatRecipeRecord(WorkRecord);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϢRecord
void CWorkRecordMgr::CreatBaseInfoRecord(CWorkRecord &WorkRecord)
{
}
//<2F><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϢRecord (<28><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ϸ<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
void CWorkRecordMgr::CreatScanDataRecord(CWorkRecord &WorkRecord)
{
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰRecipe <20><>ϢRecord
void CWorkRecordMgr::CreatRecipeRecord(CWorkRecord &WorkRecord)
{
CRecipe Recipe = gRecipeMgr->GetCurWorkRecipe();
vector<CRecipeParameter> &RecipeParVec = Recipe.GetRecipeParVec();
int size = RecipeParVec.size();
for(int i=0;i<size;i++)
{
CRecipeParameter &RecipePar = RecipeParVec[i];
}
}
void CWorkRecordMgr::SetRecipeRecordReport(CString ParName,CString ParVal)
{
}
#endif
#if 1
//<2F>ӹ<EFBFBD><D3B9><EFBFBD>¼д<C2BC><EFBFBD>ļ<EFBFBD>
void CWorkRecordMgr::WriteWorkRecordToFile(CWorkRecord &WorkRecord)
{
//<2F><>ȡ<EFBFBD><C8A1>ǰRecord <20>ļ<EFBFBD>·<EFBFBD><C2B7>
CString RecordFileName = GetCurRecordFileName();
CString RecordFilePath = GetRecordFilePath(RecordFileName);
CFileMgr FileMgr;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ж<EFBFBD>ȡ<EFBFBD><C8A1>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int RecordCnt = 0;
bool bFileExist = FileMgr.IsFileExist(RecordFilePath);//<2F><>¼<EFBFBD>Ƿ<EFBFBD><C7B7>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>
if(bFileExist)
{
CFile file;
if(file.Open(RecordFilePath,CFile::modeRead))
{
CArchive ar(&file,CArchive::load);
(ar)>>RecordCnt;
}
}
RecordCnt++;//<2F><><EFBFBD>Ӽ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><>׷<EFBFBD>ӵķ<D3B5>ʽд<CABD><D0B4><EFBFBD>ļ<EFBFBD>
{
CFile file(RecordFilePath,CFile::modeWrite|CFile::modeNoTruncate|CFile::modeCreate);
file.SeekToEnd();
CArchive ar(&file,CArchive::store);
if(!bFileExist)//<2F><>һ<EFBFBD><D2BB>д<EFBFBD><D0B4>
ar<<RecordCnt;//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
vector<CRecordPar>&RecordParVec = WorkRecord.m_RecordParVec;
int ParCnt = RecordParVec.size();
ar<<ParCnt;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(int k=0;k<ParCnt;k++)
{
CRecordPar &RecordPar = RecordParVec[k];
ar<<RecordPar.m_ParName;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ar<<RecordPar.m_ParVal;//<2F><><EFBFBD><EFBFBD>ֵ
}
}
if(bFileExist)//<2F>޸ļ<DEB8>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
CFile file(RecordFilePath,CFile::modeWrite|CFile::modeNoTruncate|CFile::modeCreate);
file.Seek(0,CFile::begin);//<2F><>λ<EFBFBD><CEBB><EFBFBD>ļ<EFBFBD>ͷ
CArchive ar(&file,CArchive::store);
ar<<RecordCnt;//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
}
//<2F><>ȡ·<C8A1><C2B7>ΪRecordFilePath <20>ļ<EFBFBD>¼<EFBFBD>ļ<EFBFBD>
void CWorkRecordMgr::ReadWorkRecord(CString RecordFilePath)
{
CFileMgr FileMgr;
if(!FileMgr.IsFileExist(RecordFilePath))
return;
CWorkRecord WorkRecord;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>WorkRecord
CreatListShowWorkRecord(WorkRecord);
//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int RecordCnt = 0;
CFile file;
if(file.Open(RecordFilePath,CFile::modeRead))
{
CArchive ar(&file,CArchive::load);
(ar)>>RecordCnt;
for(int k=0;k<RecordCnt;k++)
{
CWorkRecord Record;
int ParCnt;
ar>>ParCnt;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(int i=0;i<ParCnt;i++)
{
CRecordPar RecordPar;
ar>>RecordPar.m_ParName;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ar>>RecordPar.m_ParVal;//<2F><><EFBFBD><EFBFBD>ֵ
Record.AddRecordPar(RecordPar);
}
//ͬ<><CDAC>ReadWorkRecord <20><>WorkRecord (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>һ<EFBFBD><D2BB>)
SynchWorkRecord(WorkRecord,Record);
m_ShowRecordVec.push_back(WorkRecord);
m_WorkRecordVec.push_back(Record);
}
}
}
//ͬ<><CDAC>ReadWorkRecord <20><>WorkRecord
void CWorkRecordMgr::SynchWorkRecord(CWorkRecord &Record,CWorkRecord &ReadRecord)
{
vector<CRecordPar>&RecordParVec = Record.m_RecordParVec;
vector<CRecordPar>&ReadRecordParVec = ReadRecord.m_RecordParVec;
int ParCnt = RecordParVec.size();
for(int k=0;k<ParCnt;k++)
{
bool bFindPar = false;//<2F>Ƿ<EFBFBD><C7B7>ҵ<EFBFBD>
int ReadParCnt = ReadRecordParVec.size();
for(int i=0;i<ReadParCnt;i++)
{
//ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>
if(RecordParVec[k].m_ParName == ReadRecordParVec[i].m_ParName)
{
RecordParVec[k].m_ParVal = ReadRecordParVec[i].m_ParVal;
bFindPar = true;
break;
}
}
//û<>ҵ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>¼ӵIJ<D3B5><C4B2><EFBFBD>
if(!bFindPar)
{
RecordParVec[k].m_ParVal = "";
}
}
}
void CWorkRecordMgr::GetAllRecordNameVec(vector<CString> &DateVec,CString StartDate,CString EndDate)
{
vector<CString> AllDateVec;
CString FullFilePath;
CFileMgr FileMgr;
CString WorkRecordFilePath = gProgramLaserTuiHuo->GetWorkRecordFilePath();
if(WorkRecordFilePath=="")
{
CString FilePath = RECORD_FILE_PATH;
FilePath += "\\";
FileMgr.GetFullFilePath(FullFilePath,FilePath);
}
else
{
FullFilePath = WorkRecordFilePath+"\\";
}
FileMgr.GetChildFileOrDirName(false,FullFilePath,AllDateVec,".rcd");
int size = AllDateVec.size();
for(int k=0;k<size;k++)
{
CString DateStr = FileMgr.GetFileNameFromPath(AllDateVec[k],true);
if(DateStr>=StartDate && DateStr<=EndDate)
DateVec.push_back(DateStr);
}
}
#endif
#if 1
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼list
void CWorkRecordMgr::InitWorkRecordList(CListCtrl &List)
{
//<2F><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>
List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
CWorkRecord WorkRecord;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>WorkRecord
CreatListShowWorkRecord(WorkRecord);
int idx = 0;
List.InsertColumn(idx++,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",LVCFMT_CENTER,50,-1);
vector<CRecordPar>&RecordParVec = WorkRecord.m_RecordParVec;
int ParCnt = RecordParVec.size();
for(int k=0;k<ParCnt;k++)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CRecordPar &RecordPar = RecordParVec[k];
List.InsertColumn(idx++,RecordPar.m_ParName,LVCFMT_CENTER,RecordPar.m_ListItemWidht,-1);
}
}
//<2F><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>list
void CWorkRecordMgr::InsertRecordList(CListCtrl &List,CString StartDate,CString EndDate)
{
CString log;
log += "StartDate : ";
log += StartDate;
log += " , EndDate : ";
log += EndDate;
gLogMgr->WriteDebugLog(log);
vector<CString> DateVec;
GetAllRecordNameVec(DateVec,StartDate,EndDate);
int size = DateVec.size();
int MaxWorkRecodCnt = gLogMgr->GetMaxWorkRecodCnt();
if(size>MaxWorkRecodCnt)
{
CString s;
s.Format("<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%ld <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%ld",size,MaxWorkRecodCnt);
CMsgBox MsgBox;
MsgBox.Show(s);
return;
}
List.DeleteAllItems();
m_ShowRecordVec.clear();
m_WorkRecordVec.clear();
for(int k=0;k<size;k++)
{
//<2F><>Date <20><>record <20>ļ<EFBFBD><C4BC><EFBFBD>ȡ<EFBFBD><C8A1>¼
CString RecordFilePath = GetRecordFilePath(DateVec[k]);
ReadWorkRecord(RecordFilePath);
}
//<2F><><EFBFBD><EFBFBD>б<EFBFBD>
InsertRecordListExt(List,m_ShowRecordVec);
}
void CWorkRecordMgr::InsertRecordListExt(CListCtrl &List,vector<CWorkRecord> &WorkRecordVec)
{
int size = WorkRecordVec.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+1));//<2F><><EFBFBD><EFBFBD>
vector<CRecordPar> &RecordParVec = WorkRecordVec[i].m_RecordParVec;
int ParCnt = RecordParVec.size();
for(int k=0;k<ParCnt;k++)
{
List.SetItemText(i,idx++,RecordParVec[k].m_ParVal);
}
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>WorkRecord
void CWorkRecordMgr::CreatListShowWorkRecord(CWorkRecord &WorkRecord)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
CreatBaseInfoRecord(WorkRecord);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰRecipe <20><>Ϣ
CreatRecipeRecord(WorkRecord);
}
#endif
#if 1
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼list
void CWorkRecordMgr::InitWorkRecordInfoList(CListCtrl &List)
{
//<2F><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>
List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
int idx = 0;
List.InsertColumn(idx,"Idx",LVCFMT_LEFT,30,-1);
idx++;
List.InsertColumn(idx,"<EFBFBD><EFBFBD>Ŀ",LVCFMT_LEFT,140,-1);
idx++;
List.InsertColumn(idx,"ֵ",LVCFMT_LEFT,200,-1);
idx++;
}
void CWorkRecordMgr::InsertRecordInfoList(CListCtrl &List,int Idx)
{
List.DeleteAllItems();
int RecordCnt = m_WorkRecordVec.size();
if(Idx <0 || Idx >= RecordCnt)
return;
SetbSelWorkInfoRecord(true);
CWorkRecord &WorkRecord = m_WorkInfoRecord;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>WorkRecord
CreatListWorkInfoRecord(WorkRecord);//ֻ<>Ǵ<EFBFBD><C7B4><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>յ<EFBFBD>WorkRecord
CWorkRecord &SelRecord = m_WorkRecordVec[Idx];
//<2F><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>SelRecord <20><><EFBFBD><EFBFBD>ֵͬ<D6B5><CDAC><EFBFBD><EFBFBD>WorkRecord <20><>
//<2F><>ΪWorkRecord <20><><EFBFBD>ܻ<EFBFBD><DCBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SynchWorkRecord(WorkRecord,SelRecord);
vector<CRecordPar> &RecordParVec = WorkRecord.m_RecordParVec;
int size = RecordParVec.size();
for(int i=0;i<size;i++)
{
CRecordPar &RecordPar = RecordParVec[i];
if(RecordPar.m_ParName != "")
{
int idx = 0;
List.InsertItem(i," ");//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
List.SetItemText(i,idx++,Int2CString(i+1));//<2F><><EFBFBD><EFBFBD>
List.SetItemText(i,idx++,RecordPar.m_ParName);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
List.SetItemText(i,idx++,RecordPar.m_ParVal);//<2F><><EFBFBD><EFBFBD>ֵ
}
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>WorkRecord
void CWorkRecordMgr::CreatListWorkInfoRecord(CWorkRecord &WorkRecord)
{
WorkRecord.Reset();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
CreatBaseInfoRecord(WorkRecord);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰRecipe <20><>Ϣ
CreatRecipeRecord(WorkRecord);
//<2F><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
CreatScanDataRecord(WorkRecord);
}
//<2F>ָ<EFBFBD><D6B8>ӹ<EFBFBD><D3B9><EFBFBD>¼<EFBFBD>е<EFBFBD>recipe
void CWorkRecordMgr::RecoverRecipeByRecord()
{
gLogMgr->WriteDebugLog("Func---->OnBnClickedRecoverFormRcd");
CMsgBox MsgBox;
if(gProgramLaserTuiHuo->IsbAutoWorking())
{
gLogMgr->WriteDebugLog("<EFBFBD>ӹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
return;
}
if(!gAuthorityMgr->CheckAuthority(_Authority_Engineer,true))
return;
if(!m_bSelWorkInfoRecord)
{
MsgBox.Show("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ָ<EFBFBD><EFBFBD>ļ<EFBFBD>¼!");
return;
}
if(!MsgBox.ConfirmOkCancel("<EFBFBD><EFBFBD>ѡ<EFBFBD>м<EFBFBD>¼<EFBFBD>ָ<EFBFBD>recipe ?"))
return;
int EndScanIdx = 0;//ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int TotalScanIdx = 0;//ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CRecipe RecordRecipe;
//<2F><>record <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>recipe
vector<CRecordPar> &RecordParVec = m_WorkInfoRecord.m_RecordParVec;
int size = RecordParVec.size();
for(int k=0;k<size;k++)
{
CRecordPar &RecordPar = RecordParVec[k];
if(RecordPar.m_RecordParType==_RecordParType_Recipe)
{
vector<CRecipeParameter>&RecipeParVec = RecordRecipe.GetRecipeParVec();
int size1 = RecipeParVec.size();
for(int i=0;i<size1;i++)
{
CRecipeParameter &RecipePar = RecipeParVec[i];
if(RecipePar.m_ParShowName == RecordPar.m_ParName)
{
RecipePar.SetValByStr(RecordPar.m_ParVal);
break;
}
}
}
if(RecordPar.m_ParName == RECOR_SPAN_END_SCAN_IDX)
{
EndScanIdx = CStringToInt(RecordPar.m_ParVal);
}
if(RecordPar.m_ParName == RECOR_SPAN_TOTAL_SCAN_IDX)
{
TotalScanIdx = CStringToInt(RecordPar.m_ParVal);
}
if(RecordPar.m_ParName == RECOR_RECIPE)
{
RecordRecipe.m_RecipeName = RecordPar.m_ParVal;
}
}
int StartFillIdx = 0;
if(EndScanIdx<(TotalScanIdx-1))
{
if(MsgBox.ConfirmOkCancel("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>¼δɨ<EFBFBD>貿<EFBFBD><EFBFBD>?"))
{
StartFillIdx = EndScanIdx+1-gProgramLaserTuiHuo->GetRecoverScanIdxAdjust();
}
}
gObjFillMgr.SetStartFillIdx(StartFillIdx);
CString log;
log.Format("EndScanIdx = %d,TotalScanIdx = %d,StartFillIdx = %d",EndScanIdx,TotalScanIdx,StartFillIdx);
gLogMgr->WriteDebugLog(log);
//<2F><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8>״̬
gWorkRecordMgr->ResetScanState();
//<2F><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>recipe
gRecipeMgr->SetCurWorkRecipe(RecordRecipe);
gObjFillMgr.SetStartFillIdx(0);
}
//ѡ<>еļӹ<C4BC><D3B9><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>txt <20>ļ<EFBFBD>
void CWorkRecordMgr::SelWrokRecordToFile()
{
gLogMgr->WriteDebugLog("Func---->SelWrokRecordToFile");
CMsgBox MsgBox;
if(!gAuthorityMgr->CheckAuthority(_Authority_Engineer,true))
return;
int RcdCnt = m_WorkRecordVec.size();
if(RcdCnt<=0)
{
CMsgBox MsgBox;
MsgBox.Show("û<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>¼!");
return;
}
TCHAR szFilters[]=("TXT <20>ļ<EFBFBD>(*.txt)|*.txt");
CString FileName("WrokRecord_");
FileName += gWorkTime.GetDateTime("_","_");
CFileDialog dlg(FALSE,("txt"),FileName,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilters);
CString Path = "E:\\";//Ĭ<><C4AC>·<EFBFBD><C2B7>
dlg.m_ofn.lpstrInitialDir = Path;
if(dlg.DoModal()==IDOK)
{
ofstream FileStream;
FileStream.open(dlg.GetPathName());
for(int k=0;k<RcdCnt;k++)
{
CWorkRecord &WorkRecord = m_WorkRecordVec[k];
vector<CRecordPar> &RecordParVec = WorkRecord.m_RecordParVec;
int size = RecordParVec.size();
for(int i=0;i<size;i++)
{
CRecordPar &RecordPar = RecordParVec[i];
if(RecordPar.m_ParName!="")
{
FileStream<<"["<<RecordPar.m_ParName<<"]"<<RecordPar.m_ParVal<<"\n";
}
}
FileStream<<"-----------------------------------------------------\n";
}
}
}
#endif