|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "WorkCmdInvoker.h"
|
|
|
|
|
#include "GlobalFunction.h"
|
|
|
|
|
#include "MsgBox.h"
|
|
|
|
|
#include "FileMgr.h"
|
|
|
|
|
#include "WorkCmdContainer.h"
|
|
|
|
|
#include "ExceptionMsg.h"
|
|
|
|
|
#include "ProgressMgr.h"
|
|
|
|
|
#include "CommonFlowMgr.h"
|
|
|
|
|
#include "ProgramLaserTuiHuo.h"
|
|
|
|
|
#include "Laser.h"
|
|
|
|
|
#include "WarningMgr.h"
|
|
|
|
|
#include "WorkRecord.h"
|
|
|
|
|
#include "CStringFuc.h"
|
|
|
|
|
#include "CriticalSection.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool gStopAllWrokCmd = false;//ȫ<>ֿ<EFBFBD><D6BF><EFBFBD>
|
|
|
|
|
|
|
|
|
|
CWorkCmdInvoker gCmdInvoker_WaferTransfer;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wafer <20><><EFBFBD><EFBFBD>cmd <20><>Invoker
|
|
|
|
|
|
|
|
|
|
CWorkCmdInvoker gCmdInvoker_WaferAneal;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wafer <20>˻<EFBFBD>cmd <20><>Invoker
|
|
|
|
|
CWorkCmdInvoker gCmdInvoker_ManualOperation;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD> cmd <20><>Invoker
|
|
|
|
|
CWorkCmdInvoker gCmdInvoker_JobQueueCtrl;//<2F><><EFBFBD><EFBFBD>job <20><><EFBFBD>Ƶ<EFBFBD>Invoker
|
|
|
|
|
CWorkCmdInvoker gCmdInvoker_FoupLoadPort1;//<2F><><EFBFBD><EFBFBD>FoupLoadPort1 <20><><EFBFBD>Ƶ<EFBFBD>Invoker
|
|
|
|
|
CWorkCmdInvoker gCmdInvoker_FoupLoadPort2;//<2F><><EFBFBD><EFBFBD>FoupLoadPort2 <20><><EFBFBD>Ƶ<EFBFBD>Invoker
|
|
|
|
|
CWorkCmdInvoker gCmdInvoker_TrheeLightCtrl;//<2F><><EFBFBD><EFBFBD>TrheeLightCtrl <20><><EFBFBD>Ƶ<EFBFBD>Invoker
|
|
|
|
|
CWorkCmdInvoker gCmdInvoker_ClearWarning;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Invoker
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool gAllCmdInvokerStopFlg = false;//<2F><><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>CmdInvoker <20>ı<EFBFBD>ʶ
|
|
|
|
|
|
|
|
|
|
CWorkCmdInvoker::CWorkCmdInvoker(void)
|
|
|
|
|
{
|
|
|
|
|
m_bExcutingStop = false;//<2F>Ƿ<EFBFBD>ֹͣcmd <20><>ִ<EFBFBD><D6B4>
|
|
|
|
|
m_bExcuting = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
|
|
|
|
|
m_bNeedUpdateCmdList = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫˢ<D2AA><CBA2>cmd <20>б<EFBFBD>
|
|
|
|
|
m_bExcutingPause = false;//ִ<><D6B4><EFBFBD><EFBFBD>ͣ
|
|
|
|
|
}
|
|
|
|
|
CWorkCmdInvoker::~CWorkCmdInvoker(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
//ָ<><D6B8><EFBFBD>߳<EFBFBD>ִ<EFBFBD>к<EFBFBD><D0BA><EFBFBD>
|
|
|
|
|
UINT ExcuteAllCmdThread(LPVOID pParam)
|
|
|
|
|
{
|
|
|
|
|
CWorkCmdInvoker *p = (CWorkCmdInvoker *)pParam;
|
|
|
|
|
p->ExcuteAllCmdExt();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
UINT ExcuteCmdThread(LPVOID pParam)
|
|
|
|
|
{
|
|
|
|
|
CWorkCmdInvoker *p = (CWorkCmdInvoker *)pParam;
|
|
|
|
|
p->ExcuteCmdExt();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
//ֱ<><D6B1>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|
|
|
|
void CWorkCmdInvoker::Excute()
|
|
|
|
|
{
|
|
|
|
|
//ִ<><D6B4>ָ<EFBFBD>
|
|
|
|
|
ExcuteAllCmd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ִ<><D6B4>ָ<EFBFBD><EFBFBD><EEBCAF><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ָ<EFBFBD><D6B8>-------------------------------------------------
|
|
|
|
|
void CWorkCmdInvoker::ExcuteAllCmd(bool bNewThread,bool WaitForThread)
|
|
|
|
|
{
|
|
|
|
|
if(bNewThread)//<2F><><EFBFBD>µ<EFBFBD><C2B5>߳<EFBFBD><DFB3><EFBFBD>ִ<EFBFBD><D6B4>
|
|
|
|
|
{
|
|
|
|
|
CWinThread* pThread = AfxBeginThread(ExcuteAllCmdThread,this);
|
|
|
|
|
if(WaitForThread)//<2F>ȴ<EFBFBD><C8B4>߳̽<DFB3><CCBD><EFBFBD>
|
|
|
|
|
WaitForThreadExit(pThread);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ExcuteAllCmdExt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CWorkCmdInvoker::ExcuteAllCmdExt()
|
|
|
|
|
{
|
|
|
|
|
CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();
|
|
|
|
|
vector<Sptr<CWorkCmd>> &WorkCmdVec = CmdContainer.GetContainer();
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ִ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ״̬
|
|
|
|
|
gStopAllWrokCmd = false;
|
|
|
|
|
m_bCancel = false;//ָ<><D6B8><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ֹ
|
|
|
|
|
int size = WorkCmdVec.size();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
CString ErrMsg;
|
|
|
|
|
int CmdCnt = WorkCmdVec.size();//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
vector<Sptr<CWorkCmd>>::iterator iter = WorkCmdVec.begin();
|
|
|
|
|
vector<Sptr<CWorkCmd>>::iterator iter_end = WorkCmdVec.end();
|
|
|
|
|
for(double k = 1;iter!=iter_end;iter++,k += 1)
|
|
|
|
|
{
|
|
|
|
|
if(!m_bCancel && (gStopAllWrokCmd))
|
|
|
|
|
{
|
|
|
|
|
if(gCommonFlowMgr->IsbStopWorkMsg())//<2F><>ʾֹͣ<CDA3><D6B9>ʾ
|
|
|
|
|
{
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
|
|
if(MsgBox.ConfirmOkCancel(_T("ִֹͣ<EFBFBD><EFBFBD>?")))
|
|
|
|
|
{
|
|
|
|
|
gLogMgr->WriteDebugLog(_T("func : ExcuteAllCmd---->Stop"));
|
|
|
|
|
m_bCancel = true;//ֹͣ
|
|
|
|
|
}
|
|
|
|
|
else//<2F><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
|
|
|
|
|
{
|
|
|
|
|
gStopAllWrokCmd = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_bCancel = true;//ֹͣ
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
m_bCancel = (*iter)->Work(m_bCancel);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ִ<EFBFBD><D6B4>ʧ<EFBFBD><CAA7>,ǿ<><C7BF><EFBFBD><EFBFBD>ֹ
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
gProgressMgr.SetCurProgress(static_cast<int>(k),size);
|
|
|
|
|
}
|
|
|
|
|
catch(CExceptionMsg &Msg)
|
|
|
|
|
{
|
|
|
|
|
ErrMsg = Msg.GetMsgStr();
|
|
|
|
|
//<2F><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ϣ
|
|
|
|
|
gCommonFlowMgr->SetErrMsg(ErrMsg);
|
|
|
|
|
gLogMgr->WriteDebugLog(ErrMsg);
|
|
|
|
|
m_bCancel = true;
|
|
|
|
|
//ǿ<>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
gProgressMgr.SetCurProgress(100,100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gWorkRecordMgr->EndRecordTime();//ֹͣ<CDA3><D6B9>ʱ
|
|
|
|
|
|
|
|
|
|
if(ErrMsg != "" && gCommonFlowMgr->IsbShowErrMsg())
|
|
|
|
|
{
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
|
|
MsgBox.Show(ErrMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|
|
|
|
void CWorkCmdInvoker::AddCmd(CWorkCmd *p)
|
|
|
|
|
{
|
|
|
|
|
gCriticalSection_WorkCmdInvoker.Lock();
|
|
|
|
|
//<2F><><EFBFBD>浽<EFBFBD><E6B5BD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|
|
|
|
Sptr<CWorkCmd> sPtr(p);
|
|
|
|
|
m_WorkCmdVec.push_back(sPtr);
|
|
|
|
|
m_bNeedUpdateCmdList = true;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫˢ<D2AA><CBA2>cmd <20>б<EFBFBD>
|
|
|
|
|
gCriticalSection_WorkCmdInvoker.Unlock();
|
|
|
|
|
}
|
|
|
|
|
void CWorkCmdInvoker::ClearCmd()
|
|
|
|
|
{
|
|
|
|
|
gCriticalSection_WorkCmdInvoker.Lock();
|
|
|
|
|
m_WorkCmdVec.clear();
|
|
|
|
|
m_bNeedUpdateCmdList = true;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫˢ<D2AA><CBA2>cmd <20>б<EFBFBD>
|
|
|
|
|
gCriticalSection_WorkCmdInvoker.Unlock();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void CWorkCmdInvoker::ExcuteCmd(bool bNewThread,bool WaitForThread)
|
|
|
|
|
{
|
|
|
|
|
if(bNewThread)//<2F><><EFBFBD>µ<EFBFBD><C2B5>߳<EFBFBD><DFB3><EFBFBD>ִ<EFBFBD><D6B4>
|
|
|
|
|
{
|
|
|
|
|
CWinThread* pThread = AfxBeginThread(ExcuteCmdThread,this);
|
|
|
|
|
if(WaitForThread)//<2F>ȴ<EFBFBD><C8B4>߳̽<DFB3><CCBD><EFBFBD>
|
|
|
|
|
WaitForThreadExit(pThread);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ExcuteCmdExt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CWorkCmdInvoker::ExcuteCmdExt()
|
|
|
|
|
{
|
|
|
|
|
m_bExcuting = true;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
|
|
|
|
|
m_InvokerWorkTime.StartRecordTime();//<2F><>ʼ<EFBFBD><CABC>ʱ
|
|
|
|
|
CString Log;
|
|
|
|
|
Log = m_CmdInvokerName + "Start";
|
|
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ִ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ״̬
|
|
|
|
|
gStopAllWrokCmd = false;
|
|
|
|
|
m_bCancel = false;//ָ<><D6B8><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ֹ
|
|
|
|
|
int size = m_WorkCmdVec.size();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
CString ErrMsg;
|
|
|
|
|
vector<Sptr<CWorkCmd>>::iterator iter = m_WorkCmdVec.begin();
|
|
|
|
|
vector<Sptr<CWorkCmd>>::iterator iter_end = m_WorkCmdVec.end();
|
|
|
|
|
for(double k = 1;iter!=iter_end;iter++,k += 1)
|
|
|
|
|
{
|
|
|
|
|
if(!m_bCancel && (gStopAllWrokCmd || m_bExcutingStop))
|
|
|
|
|
{
|
|
|
|
|
m_bCancel = true;//ֹͣ
|
|
|
|
|
}
|
|
|
|
|
(*iter)->SetbExcuting(true);
|
|
|
|
|
while(m_bExcutingPause)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>˾<EFBFBD>һֱ<D2BB>ȴ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
Sleep(500);
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if(!m_bCancel)
|
|
|
|
|
{
|
|
|
|
|
CString s;
|
|
|
|
|
s = Int2Str_LeftZero(k) + " ";
|
|
|
|
|
s += (*iter)->GetWorkCmdInfoStr();
|
|
|
|
|
m_CurExcuteCmdInfo = s;
|
|
|
|
|
}
|
|
|
|
|
m_bCancel = (*iter)->Work(m_bCancel);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ִ<EFBFBD><D6B4>ʧ<EFBFBD><CAA7>,ǿ<><C7BF><EFBFBD><EFBFBD>ֹ
|
|
|
|
|
}
|
|
|
|
|
catch(CExceptionMsg &Msg)
|
|
|
|
|
{
|
|
|
|
|
ErrMsg = Msg.GetMsgStr();
|
|
|
|
|
//<2F><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ϣ
|
|
|
|
|
gCommonFlowMgr->SetErrMsg(ErrMsg);
|
|
|
|
|
gLogMgr->WriteDebugLog(ErrMsg);
|
|
|
|
|
m_bCancel = true;
|
|
|
|
|
}
|
|
|
|
|
(*iter)->SetbExcuting(false);
|
|
|
|
|
}
|
|
|
|
|
//<2F>ָ<EFBFBD>״̬
|
|
|
|
|
m_bExcutingStop = false;
|
|
|
|
|
m_bExcutingPause = false;
|
|
|
|
|
m_bCancel = false;
|
|
|
|
|
m_InvokerWorkTime.StopRecordTime();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
|
|
|
|
Log = m_CmdInvokerName + "End";
|
|
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
|
|
|
|
|
|
|
if(ErrMsg != "" && gCommonFlowMgr->IsbShowErrMsg())
|
|
|
|
|
{
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
|
|
MsgBox.Show(ErrMsg);
|
|
|
|
|
}
|
|
|
|
|
m_bExcuting = false;
|
|
|
|
|
}
|
|
|
|
|
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>е<EFBFBD>cmd <20><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>
|
|
|
|
|
bool CWorkCmdInvoker::IsAllCmdExcuted()
|
|
|
|
|
{
|
|
|
|
|
bool Ret = true;
|
|
|
|
|
vector<Sptr<CWorkCmd>>::iterator iter = m_WorkCmdVec.begin();
|
|
|
|
|
vector<Sptr<CWorkCmd>>::iterator iter_end = m_WorkCmdVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if(!(*iter)->IsbExcuted())
|
|
|
|
|
{
|
|
|
|
|
Ret = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Ret;
|
|
|
|
|
}
|
|
|
|
|
void CWorkCmdInvoker::InitCmdList(CListCtrl &List)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>
|
|
|
|
|
List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int idx = 0;
|
|
|
|
|
List.InsertColumn(idx,"Idx",LVCFMT_CENTER,50);
|
|
|
|
|
idx++;
|
|
|
|
|
List.InsertColumn(idx,"Step Info",LVCFMT_LEFT,400,-1);
|
|
|
|
|
idx++;
|
|
|
|
|
}
|
|
|
|
|
void CWorkCmdInvoker::UpdateCmdList(CListCtrl &List)
|
|
|
|
|
{
|
|
|
|
|
gCriticalSection_WorkCmdInvoker.Lock();
|
|
|
|
|
int size = m_WorkCmdVec.size();
|
|
|
|
|
if(m_bNeedUpdateCmdList)
|
|
|
|
|
{
|
|
|
|
|
List.DeleteAllItems();
|
|
|
|
|
}
|
|
|
|
|
else//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
{
|
|
|
|
|
if(size != List.GetItemCount())
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int ExcuteIdx = 0;//<2F><>ǰִ<C7B0>е<EFBFBD>cmd
|
|
|
|
|
for(int k=0;k<size;k++)
|
|
|
|
|
{
|
|
|
|
|
CString CmdInfoStr = m_WorkCmdVec[k]->GetWorkCmdInfoStr();
|
|
|
|
|
if(m_bNeedUpdateCmdList)
|
|
|
|
|
List.InsertItem(k," ");
|
|
|
|
|
List.SetItemText(k,0,Int2Str_LeftZero(k+1));
|
|
|
|
|
List.SetItemText(k,1,CmdInfoStr);
|
|
|
|
|
if(m_WorkCmdVec[k]->IsbExcuted())
|
|
|
|
|
ExcuteIdx = k;
|
|
|
|
|
}
|
|
|
|
|
m_bNeedUpdateCmdList = false;
|
|
|
|
|
gCriticalSection_WorkCmdInvoker.Unlock();
|
|
|
|
|
}
|
|
|
|
|
COLORREF CWorkCmdInvoker::GetCmdListColor(int Idx)
|
|
|
|
|
{
|
|
|
|
|
COLORREF c = RGB_WHITE;
|
|
|
|
|
int size = m_WorkCmdVec.size();
|
|
|
|
|
if(Idx>=0&&Idx<size)
|
|
|
|
|
{
|
|
|
|
|
if(m_WorkCmdVec[Idx]->IsbExcuted())
|
|
|
|
|
c = RGB_BLUE1;
|
|
|
|
|
if(m_WorkCmdVec[Idx]->IsbExcuting())
|
|
|
|
|
c = RGB_YELLOW;
|
|
|
|
|
}
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ
|
|
|
|
|
void CWorkCmdInvoker::SetbExcutingPause(bool b)
|
|
|
|
|
{
|
|
|
|
|
m_bExcutingPause = b;
|
|
|
|
|
if(b)
|
|
|
|
|
{
|
|
|
|
|
CString log("Flow--->");
|
|
|
|
|
log += m_CmdInvokerName;
|
|
|
|
|
log += " ExcutingPause";
|
|
|
|
|
gLogMgr->WriteDebugLog(log);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|