#if !defined(AFX_MAINDOC_H__E674CB70_B34D_11D7_898C_000629A6E157__INCLUDED_)
#define AFX_MAINDOC_H__E674CB70_B34D_11D7_898C_000629A6E157__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MainDoc.h : header file
//

#include "PageSecurity.h"
#include "structure.h"
#include <afxtempl.h>
// #include "CheckSwitch.h"
#include "MotorRS.h"
#include "MtrProfileRS.h"
#include "MaintenanceInputRS.h"
#include "MaintenanceOutputRS.h"
#include "MaintMsgRS.h"
// #include "Utility.h"
#include "DeleteLotInfo.h"
#include "DefCommon.h"
#include "LotMsg.h"
// #include "MessageBox.h"
#include "ISGManagerObserver.h"

// Gary 24Jul12, V1.24.11
// #include "ShadeCheckButtonST.h"

#define MAX_STATUS_DISPLAY  10
#define MAX_MESSAGE_BUFFER  10

#ifdef  BUILD_GUIDLL
#define     DLLCLASS    __declspec(dllexport)
#else
#define     DLLCLASS    __declspec(dllimport)
#endif

class CMotionController;
class CInputController;
class COutputController;
class CShadeButtonST;
class CShadeCheckButtonST;
class CMessageBox;

/////////////////////////////////////////////////////////////////////////////
// CMainDoc document
class CRun;
class CRunCtrl;

class DLLCLASS CMainDoc : public CDocument, public ISGManagerObserver
{
protected:
    CMainDoc(); // protected constructor used by dynamic creation
    CMainDoc(int numRun, CRun **run, stModule *Module);
    DECLARE_DYNCREATE(CMainDoc)

// Attributes
public:

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
// {{AFX_VIRTUAL(CMainDoc)
public:
    virtual void Serialize(CArchive& ar); // overridden for document i/o
protected:
    virtual BOOL OnNewDocument();
    virtual void OnCloseDocument();
// }}AFX_VIRTUAL

// Implementation
public:
    virtual ~CMainDoc();
#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
#endif

#define CLEAR_MSG_ID        true

#define DO_NOT_CLEAR_MSG_ID false

    HWND m_hwndMainApp;
public:
// Gary 24Jul12, V1.24.11
// virtual method to handle custom run view buttons processing
    virtual void OnRunViewButton(int nButton, CShadeButtonST * checkBtn);

    virtual void OnRunViewCheck(int nButton, CShadeCheckButtonST * Btn);
    bool         OnSecsGemMessageReceived(WPARAM wParam, LPARAM lParam);
// Gary 3 Oct11, V1.24.07
// new function to query if machine is in EStop state
    bool IsEStopState();

// Gary 16Aug11, V1.24.06
// new virtual function for application to do any handling
    virtual void OnAirLow(bool bLow);

    virtual void OnVacuumLow(bool bLow);

    virtual void OnDoorOpen(bool bOpen);

    virtual void OnCurtainSensorTriggered(bool bTriggered);

    virtual void OnEngineeringModeOn(bool bInEngineeringMode);

    virtual void OnEStopActivated(bool bEStopActivated);
//
// Gary 28Jul1, V1.24.04, virtual function when Stop Button is pressed and before
// calling OnStopCtr();
// Application layer can blocked the Stop Control by returning false
    virtual bool OnStopButtonPressed();

// Gary 28Jul1, V1.24.04, virtual function when Start Button is pressed and before
// calling OnStartCtr();
// Application layer can blocked the Stop Control by returning false
    virtual bool OnStartButtonPressed();

// Gary 28Jul1, V1.24.04, virtual function when Reset Button is pressed and before
// calling OnResetCtr();
// Application layer can blocked the Stop Control by returning false
    virtual bool OnResetButtonPressed();

// Gary 12May11, V1.24.02
// call maindoc virtual OnLogin function to provide flexibility
// in case application layer needs to have control over the user login
    virtual bool OnLogin();

// Gary 10May11, V1.24.02
// Add call to new virtual function in MainDoc to let application layer
// have some control over conditions to allow the exit of the application.
    virtual bool OnCloseApplication();

// Gary 4May11, V1.24.02
// runview OnTimer virtual function for application layer flexibility to
// carry some non-blocking tasks.
    virtual void OnRunViewTimer();

// Gary 4Aug11, V1.24.05
// Enhance with elasped timer parameter
    virtual void OnRunViewTimer(UINT nIDEvent);

// Gary 26Aug10 V1.23.01, virtual method to handle the main operation mode selection
    int OnMainModeViewSelection(int nModeBtnPressed, CShadeButtonST *cShadeButton, COLORREF &colorMainView);

// Gary 26Aug10 V1.23.01, virtual method to handle the Production mode selection
    virtual int OnMainModeViewProductionBtnPressed(CShadeButtonST *cShadeButton, COLORREF &colorMainView);

// Gary 26Aug10 V1.23.01, virtual method to handle the Engineering mode selection
    virtual int OnMainModeViewEngineeringBtnPressed(CShadeButtonST *cShadeButton, COLORREF &colorMainView);

// Gary 26Aug10 V1.23.01, virtual method to handle the Schedule Activity mode selection
    virtual int OnMainModeViewScheduleActivityBtnPressed(CShadeButtonST *cShadeButton, COLORREF &colorMainView);

// Gary 26Aug10 V1.23.01, virtual method to handle the No Material/ Non Schedule mode selection
    virtual int OnMainModeViewNoMaterialBtnPressed(CShadeButtonST *cShadeButton, COLORREF &colorMainView);

// Gary 26Aug10 V1.23.01, virtual method to handle the main mode button pressed
    virtual int OnMainModeViewBtnPressed(CShadeButtonST *cShadeButton, COLORREF &colorMainView);

// Gary 1Feb10, new multiuser password access
    CString GetUserName();
    void    SetUserName(CString csUserName);

    virtual void OnUserLoginChanged();
    virtual void OnCustomizedSwitch(int nSwitchNo, int nState);
    virtual void OnThirdPartyMessage(WPARAM wp, LPARAM lp);
    void         DisableRun();
    void         EnableRun();

// Gary 4May11, V1.24.02
// allow application layer to control the Reset Button
    void DisableReset();
    void EnableReset();

// Gary 4May11, V1.24.02v
// allow application layer to control the Stop Button
    void DisableStop();
    void EnableStop();

    void         OnEMSStatus(int nState);
    virtual void EStopCleanUp();
    virtual void EStopRelease();
    void         RefreshMessageDisplay();
    void         InsertStatus(WPARAM wp, LPARAM lp);
    void         InsertPrompt(WPARAM wp, LPARAM lp);
    virtual void DisplayPrompt(WPARAM wp, LPARAM lp);
    void         DisplayStatus(CString csName, CString csText, LPARAM lp, bool bProgress = true);
    virtual void StartAllRun();
    void         FindGUIWindow();
    CString      GetStatusMsg();
    bool         IsHardwareSafetyBypass();
    BOOL         IsEngineeringMode();
    void         OnEngineeringMode(BOOL bState);
    void         EnableAllSafetyCheck();
    void         SetOutput(int nOutput, COutput *pOutput);
    bool         IsUseGoldenPackageMethod();

//  print report to Machine\\Report\\ReportFileName.txt
    virtual BOOL PrintReportToAFile(CListCtrl& listCtrl, int ntype, CString csFilename,
                                    CString &csReportFileName);

    void         ResetPowerUpComplete(void);
    virtual void WriteRuntimePackageInfo(void);
    virtual void WriteRuntimeRecipeInfo(void);

//  Read field of interest from Database amd write to runtime.ini
    virtual bool ReadFromDbWriteToRuntimeIni(CDaoRecordset &RecordSet, CIniFile &iniFile, int iStartFieldNo);

//  Read Motor speed info from Motor Pos table from Package.mdb and write to runtime.ini
    virtual void WriteMtrInfo();

//  Read Motor speed info from Motor Speed table from Package.mdb and write to runtime.ini
    virtual void WriteMtrSpeedInfo();

    virtual stPackageInfo * GetPackageInfo(void);
    virtual stRecipeInfo  * GetRecipeInfo(void);
    virtual void            ClearPackageInfo(void);
    virtual void            ClearRecipeInfo(void);
    virtual BOOL            ReadRuntimePackage(void);
    virtual void            WriteRuntimeRecipe();
    virtual BOOL            ReadRuntimeRecipe(void);
    void                    RecipeSelected(BOOL bSelected);
    virtual void            ClearLotInfo(void);
    virtual void            WriteRuntimeLotInfo(void);
    BOOL                    IsIncompleteLot(void);
    BOOL                    IsRecipeSelected(void);
    virtual BOOL            ReadRuntimeLotInfo(void);
    virtual BOOL            LoadRecipe(CString csRecipe, CString csPackage);
    void                    UpdateSecurityPageLevel(int nSecurity, int nLevel);
    void                    OnSetModuleWarning(BOOL bState);
    void                    OnSystemWarning(BOOL bState);
    CMotionController      *GetMotionController(void);
    COutputController      *GetOutputController(void);
    CInputController       *GetInputController(void);
    void                    SetSwitch(int nSwitch, CInput *pInput);
    void                    SetLight(int nIndicator, COutput *pOutput);
    void                    InitParameters(void);
    void                    SetCopyRight(CString csCopyRight);
    CString                 GetCopyRight(void);
    void                    SetMachineModel(CString csModel);
    CString                 GetMachineModel(void);
    CStringArray          * GetOutputMode(void);
    void                    InsertOutputMode(CString csMode);
    virtual void            SaveLotInfo(void);
    BOOL                    IsClosingLot(void);
    virtual stLotInfo     * GetLotInfo(void);
    virtual void            CloseLotComplete(void);
    BOOL                    IsLotOpened();
    virtual void          * InitMainSheet(int nID);
    int                     GetNoOfModule(void);
    stModule              * GetModule(void);
    void                    SetModule(stModule *Module, int nNoOfModule);
    int                     GetSecurityLevel(int nPage);
    void                    ByPassCurtain(BOOL bState);
    void                    ByPassDoor(BOOL bState);
    void                    OnCurtain(BOOL bState);
    void                    OnAir(BOOL bState);
    void                    OnVacuum(BOOL bState);
    void                    OnEStop(BOOL bState);
    void                    OnDoor(BOOL bState);
    void                    SetUserLevel(int nLevel);

// Receive Remote Command from Host through SECSGEM
/*TISDREMOVE    virtual void ReceiveRemoteCmdSTART();
    virtual void ReceiveRemoteCmdSTOP();
    virtual void ReceiveRemoteCmdPAUSE();
    virtual void ReceiveRemoteCmdRESUME();
    virtual void ReceiveRemoteCmdCASSETTEACK();
    virtual void ReceiveRemoteCmdPPSELECT();
    virtual void ReceiveRemoteCmdLOTACK();
 */
// **************SecsGem *****************************
// SecsGem Attribute
/*****************************************************/
// TISGADD {{
    BOOL m_bSecsGemApplicationRemoteLink;
    BOOL m_bSecsGemRealTimeDataEnable;
    bool m_bSecsGemAppLication;

    CString m_strControlState;
    CString m_strSpoolState;
    CString m_strLinkState;
    CString m_strE10State;
    CString m_strMainMode;

    CString m_strSecsGemDataFileName;
    CString m_strRecipeFileFolder;

    CString m_strDeletedRecipeName;
    CString m_strAddedUserRecipeName;
    CString m_strUploadedRecipeName;
    CString m_strDownloadedRecipeName;
    CString m_strUploadedDataName;
    CString m_strDownloadedDataName;
    CString m_strReceivedRemoteCmdName;
    CString m_strUploadedWaferMapName;
    CString m_strDownloadedWaferMapName;
    CString m_strUploadedStripMapName;
    CString m_strDownloadedStripMapName;
    CString m_strReceivedOthersMsgName; // for general purpose for future

// Gary 03Nov, added to cater for new secsgemdll v1.1
    CString m_strDeletedAllRecipeStatus;
    CString m_strEditedUserRecipeName;

// Gary 6Jan11, V1.23.02, support ECID handling
    CString m_strECID;

    int  m_nSendHandlerAcknowledgeEnable; // phyu 02-Oct-2012
    bool m_bSecsgemWarningEnable;
    bool m_bSecsgemAlarmClearEnable;
//  create sec gem object

    virtual void CreateSecGemObject();
    virtual void SendSecsGemEvent(int evt);
    virtual void SecsGemDeletedRecipeFile(CString strDeletedRecipeName);
    virtual void SecsGemAddedUserRecipeName(CString strUserRecipeName);
    virtual void SecsGemUpdatedRecipeList();
    virtual void SecsGemUploadedRecipeFile(CString strUploadedRecipeName);
    virtual void SecsGemDownloadedRecipeFile(CString strDownloadedRecipeName);
    virtual void SecsGemUploadedDataFile(CString strUploadedDataName);
    virtual void SecsGemDownloadedDataFile(CString strDownloadedDataName);
    virtual void SecsGemReceivedRemoteCmd(CString strReceivedRemoteCmdName);
    virtual void SecsGemReceivedRemoteCmd(CString strReceivedRemoteCmdName, int nStatus); // nStatus=0:remote cmd received,1: remote cmd time out error.phyu 24-Sep-2012
    virtual void SecsGemUploadedWaferMapFile(CString strUploadedWaferMapName);
    virtual void SecsGemDownloadedWaferMapFile(CString strDownloadedWaferMapName);
    virtual void SecsGemDownLoadedStripMapFile(CString strDownloadedStripMapName);
    virtual void SecsGemReceivedOthersMsg(CString strReceivedOthersMsgName);              // for general purpose for future

// Gary 03Nov09, cater for new features
    virtual void SecsGemEditedRecipeName(CString strUserRecipeName);

    virtual void SecsGemDeletedAllRecipes(CString strStatus);

// Gary 6Jan11, V1.23.02, support ECID handling
    virtual void SecsGemReceivedECID(int nECID, CString csData);

// }}

// gary, 30Sep08
    virtual bool    CheckSecsGemConfigIPAddress();
    virtual CString GetSecsGemConfigIPAddress(CString strFileName);
    virtual void    GetLocalIPAddress(CString *pIPAddress, int &nCount);

    virtual bool SecsGemSendLoadRecipe(CString strRecipeName);
    virtual bool SecsGemSendUploadRecipe(CString strRecipeName);

    virtual bool SecsGemSendLoadData(CString strDataFileName);
    virtual bool SecsGemSendUploadData(CString strDataFileName);

    virtual bool SecsGemSendLoadRecipeList();
    virtual bool SecsGemSendDeleteRecipe(CString strRecipeName);
    virtual bool SecsGemSendAddUserRecipe(CString strRecipeName);

    CEvt m_evtGetRecipeFile;     // TISGADD
    CEvt m_evtGetDataFile;       // TISGADD
    CEvt m_evtGetRecipeList;     // TISGADD
    CEvt m_evtRecipeDeleted;     // TISGADD
    CEvt m_evtRecipeUploaded;    // TISGADD
    CEvt m_evtDataFileUploaded;  // TISGADD
    CEvt m_evtUserRecipeAdded;   // TISGADD

// Gary 03Nov09, cater for new features
    CEvt m_evtUserRecipeEdited;  // TISGADD
    CEvt m_evtAllRecipesDeleted; // TISGADD

    int       m_numRun;
    CRun    **m_run;
    CRunCtrl *m_runCtrl;
    WPARAM    m_wp;
    LPARAM    m_lp;

    void RecipeChangeLogging(CString& ItemName, CString& oldValue, CString& newValue, bool bReqToCloseFile = false);
    void RecipeChangeLogging(CString& ItemName, double oldValue, double newValue, bool bReqToCloseFile = false);

// For Touch Screen Graphic Keyboard
    CString LaunchKeyboard(bool bPasswordType = false);

// Recipe Operations

// Control Operations
    void OnPackageLoadCtr();
    void OnLotStartCtr();
    void OnLotEndCtr(bool bTerminate = false);
    void OnMachineSettingChangeCtr();
    bool OnStartCtr();

//  void OnStopCtr();
    void OnStopCtr(bool bAuto = true);

    void OnResetCtr();
    void OnRestartCtr();

    bool StartDiagnose();
    bool EndDiagnose();

// Run statistics
    void AddTotalRun(int n);
    void AddTotalPass(int n);
    void AddTotalReject(int n);
    void AddUnitsInTape(int n);

// Debug Log Data
    void DebugKeybdEvent();

// gary 03jul03

// Implementation
    void         DisplayMsg(CDC *pDC, CString& msg, int xOff, int yOff);
    int          GetUserLevel(void);
    int          IsSoftwareDebug(void);
    virtual BOOL InitRun(int iNoOfMaintModule);
    bool    m_bEnableAutoPromptMsg;
    CLotMsg m_lotMsg;
    void CheckIncompleteLot(void);

    int GetSequenceModuleNo(int iModuleNo); // function to get which sequence module
    int GetNoOfMtr();                       // return no of motor

    CString * GetAllMtrName();              // return motor name in motor table

//  set maintenance message ID,
//  bClearMsg = TRUE to clear maintenance message
//  bClearMsg = False to display maintenance message
    virtual void SetMaintMsgId(int iMsgID, BOOL bClearMsg);

//  Get Maintenance Message ID
//  clear maintenance message if bClrMsg = true
    virtual int GetMaintMsgId(bool bClrMsg = CLEAR_MSG_ID);

//  clear maintenance message id
    virtual void ClrMaintMsdId();

    virtual CString GetMaintMsg(int iMaintMsgId); // get maintenance message base on message id

//  store general message parameters
    virtual void SetGeneralMsgId(WPARAM wp, LPARAM lp);

//  Make a copy of output status before going into maintenance mode
    virtual void CopyOutputStatus();

//  Make a copy of motor status before going into maintanence mode
    virtual void CopyMtrStatus();

//  check whether output state has changed before
    virtual bool CheckOpMtrStateChange();

//  set or clear m_bMvMtrOrOp Flag
    void SetMvMtrFlag(bool bState);

//  set or clear m_bMvMtrOrOp Flag
    void SetMvOpFlag(bool bState);

//  check if output has been moved in maintenance page
    bool IsMvOpInMaintPage();

//  check if motor has been moved in maintenance page
    bool IsMvMtrInMaintPage();

//  get current module motor position no
    int GetMtrPosNo(CString csModuleName, int iMtrNo, CString csMtrPos,
                    CString csSubPosName);

    virtual void Purge(); // purge machine unit

// TISGREMOVE    virtual void PostSecsGemMessage(int iEvt, WPARAM wp = 0);

    enum
    {
        NO_MODULE_DEFINED   = -1,
        NO_MAINT_MESSAGE    = -1, // no maintenance message
        CLEAR_MAINT_MESSAGE = -2, // clear maintenance message
    };

    CMotorRS m_motorRecSet;

    bool m_bSecsGemOnline;
    bool m_bSecsGemEnable;
    BOOL m_bSecsGemCapable;
    bool m_bRemoteCommandProcessed;
    BOOL m_bSecsGemAutoConnect;
    bool m_bOPEOpened;

    int m_iMainMode;

// TISGREMOVE    RemoteCmdStruct RemoteMsg;

    void RemoveStatusMsg(CString csMsg);
    void SetStatusMsg(CString csMsg);

    void DestroyControl(); // called by destructor only

// update the run Package Data
    bool UpdateCurrentPackageData(CString csPackageName, bool bOverWrite = false);

    CFrameWnd *m_pMainFrame;
    CView     *m_pRunView;

public:
// Gary 5 Oct10, V1.23.02, multilanguage for Modules, IOs and Motors
    stModule m_stMultiLanguageModule[MAX_MODULE];

    stMaintIoModule m_stMultiLanguageMaintIoModule[MAX_MODULE];

    stMaintIoModule m_stMultiLanguageMaintOutputModule[MAX_MODULE];

    stMaintMotorModule m_stMultiLanguageMaintMotorModule[MAX_MODULE];

    void InitModule2ndLanguage();
    void InitMaintenanceInputInfo2ndLanguage();
    void InitMaintenanceOutputInfo2ndLanguage();
    void InitMaintenanceMotorInfo2ndLanguage();

// Generated message map functions
protected:
    HWND GetActivePageHWND();
// {{AFX_MSG(CMainDoc)
// NOTE - the ClassWizard will add and remove member functions here.
// }}AFX_MSG
    DECLARE_MESSAGE_MAP()

    int m_iSequenceModuleNo[MAX_MODULE];
    int m_iSeqMaintMtrNo[MAX_MODULE][MAX_MOTOR]; // Sequence to Maintenance module Motor Number Map

//  Init maintenance module Motor sequence mapping
    virtual void InitMaintModuleMtrMapToSeq();

//  void RemoveStatusMsg(CString csMsg);
//  void SetStatusMsg(CString csMsg);

private:
    void         DestroyAllStatusDisplay();
    void         CloseStatusDisplay(CString csName);
    int          GetAvailableMsgBox();
    void         AsignDefaultRecipe(void);
    virtual void SetSystemSwitch(void);
    virtual void SetSystemOutput();
    virtual void SetEMSInput();
    virtual void SetEMSOutput();
    BOOL         InitHardware(void);
    virtual void SetTowerLight(void);
    BOOL m_bClosingLot;
    BOOL m_bLotOpened;
    BOOL m_bCurtainActivate;
    BOOL m_bDoorOpen;
    BOOL m_bEStopActivate;
    BOOL m_bAirLow;
    BOOL m_bVacuumOff;
    BOOL m_bEngineeringMode;

    CStringArray m_csaStatusMsg;

    stModule *m_stModule;

    int m_nNoOfModule;

    CMaintenanceInputRS  m_inputRecSet;
    CMaintenanceOutputRS m_outputRecSet;
    CMaintMsgRS          m_maintMsgRecSet;

    void ReadConfigFileUpdateGlobalVariables();
    void CompactAndBackupMachineSettings();

    void GetPageSecurityLevel();

// Control Operations
    bool InitRunModule();
    void CreateControl(); // called by constructor only

//  create sec gem object
// TISGREMOVE    virtual void CreateSecGemObject();

// Gary 30Nov10, V1.23.02, change to protected so that
// run view can access

    int  InitModule();                  // Init no of modules in maintenance page
    void InitMaintenanceMtrInfo();      // Init maintenance page motor information
    void InitMaintenanceInputInfo();    // Init maintenance page input information
    void InitMaintenanceOutputInfo();   // Init maintenance page output information

    void InitMaintModuleMapToInvalid(); // init Maintenance module mapping to sequence to invalid(-1)

//  check if output state has changed in maintenance page
    void CheckOpStateChanged(CString Msg[], int &iWarnMsg);

//  check if motor state has changed in maintenance page
    void CheckMtrStateChange(CString Msg[], int &iWarnMsg);

//  format state changed message
    bool FormatPromptStateChangedMsg(CString *Msg, int &iWarnMsg, CString csState,
                                     CString csPos, bool bMtrPosMsg = true);

// Attributes
    BOOL m_bRecipeSelected;

    BOOL InitRunCtrl();

//  initliased delete lot parameters
    void InitDelLotPara();

//  delete old lot record
    void DeleteOldLotRecord();

//  auto delete lot
    void AutoDelLot(BOOL bAutoDelLot, int iKeepLotPeriod);

// Create Run Package Table

    bool CreateGoldenPackageDataTable();
    bool CopyTableWithoutData(CDaoDatabase *pDatabase, CString csDestTableName, CString csSourceTableName);
    bool CopyPackageData(CDaoDatabase* pDatabase, CString csDestTableName, CString csSourceTableName, CString csPackageName = "");
    bool IsCurrentPackageExist(CDaoDatabase* pDatabase, CString csTableName, CString csPackageName);
    bool DeleteDBData(CDaoDatabase* pDatabase, CString csTableName);
// for debugging purpose
    int m_iSoftwareDebug;

    int m_nUserLevel;

// For Security level
    int m_nPageSecurityLevel[NUM_SECURITY_ITEM];

    CStringArray m_aOutputMode;

    CString m_csModel;
    CString m_csCopyRight;

    CInputController  *m_inputController;
    COutputController *m_outputController;
    CMotionController *m_motionController;

    COutput *m_copDoorLock;

    BOOL m_bIncompleteLot;
    BOOL m_RecipeSelected;

    int    m_iMaintMsgId;        // store Maintenance Message ID
    CMutex m_maintMsgMutex;      // inter locking to set and clear maintenance message

    int m_iNoOfMtr;              // keep track no of motor

    bool m_bMvOp;                // motor or output has been moved in maintenance page
    bool m_bMvMtr;               // flag to detemine whether motor has been moved in maintenance page
    bool m_bChangeMtrOnOff;      // flag to detemine whether motor has been changed on/off in maintenance page

    CDeleteLotInfo m_delLotInfo; // del lot info when close lot complete

    enum
    {
        MAX_MAINT_LIST_BOX_MSG = 100,
    };

    CDefCommon DefCommon;

    CMessageBox *m_msgBox[MAX_STATUS_DISPLAY];

    enum
    {
        PROMPT,
        STATUS,
    };

    void ShiftQueue(int nType);
    int  GetEmptyQueue(int nType);
    bool RequirePrompt(int nType);
    int m_nPromptBuffer[MAX_MESSAGE_BUFFER];
    int m_nOption[MAX_MESSAGE_BUFFER];
    int m_nStatusBuffer[MAX_MESSAGE_BUFFER];
    int m_nStatusOption[MAX_MESSAGE_BUFFER];

    void ResetAllBuffer(int nType);
    bool IsAnyPrompt(int nType);
    void InsertPrompt(int nType, WPARAM wp, LPARAM lp);

    CMutex m_MainDocMutex;

// flag to disable machine from running
    bool m_bDisableRun;

// Gary 5May11, V1.24.02
// flag to disable machine from Resetting
    bool m_bDisableReset;

// Gary 5May11, V1.24.02
// flag to disable machine from Stopping
    bool m_bDisableStop;

// Gary 1Feb10, new multiuser password access
    CString m_csUserName;

// Gary 31May10, mutex to interlock status msg update
    CMutex m_mutexStatusMsg;

// Gary 01Jun10, flag to indicate if need to prompt Initialise message
    bool m_bPromptInitMachine;

    bool IsSecsGemConnected();
    bool IsSecsGemCommunicating();

    int GetSecsGemTimeOut();
};

// {{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAINDOC_H__E674CB70_B34D_11D7_898C_000629A6E157__INCLUDED_)
