// Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// General information section.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// $Author:yongkiang$ User who last changed the file
// $Date:1/2/2013 12:16:58 PM$ Date and time of last check in
// $Revision:1.0$ Visual SourceSafe version number
// $Workfile::   runview.h                                             $ Filename
// End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// {{AFX_INCLUDES()
#include "WinMessage.h"
#include "BtnST.h"
#include "ShadeButtonST.h"
#include "ShadeCheckButtonST.h"
#include "PictureEx.h"
#include "commondef.h"

// }}AFX_INCLUDES
#if !defined(AFX_RUNVIEW_H__49DF5541_1831_11D1_BB66_00A0C9338123__INCLUDED_)
#define AFX_RUNVIEW_H__49DF5541_1831_11D1_BB66_00A0C9338123__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

// RunView.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CRunView form view

#ifndef __AFXEXT_H__
#include <afxext.h>
#endif

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

enum MAIN_MODE_VIEW_SELECTION_OP
{
    MAIN_MODE_VIEW_HIDE,
    MAIN_MODE_VIEW_SHOW,
    MAIN_MODE_VIEW_DO_NOTHING,
};

enum MAIN_MODE_VIEW_SELECTION_PRESSED
{
    MAIN_MODE_VIEW_BTN_PRESSED,
    MAIN_MODE_VIEW_PRODUCTION_BTN_PRESSED,
    MAIN_MODE_VIEW_ENGINEERING_BTN_PRESSED,
    MAIN_MODE_VIEW_SCHEDULE_ACTIVITY_BTN_PRESSED,
    MAIN_MODE_VIEW_NO_MATERIAL_BTN_PRESSED,
};

// Gary 24Jul12, V1.24.11
enum RUN_VIEW_CUSTOM_BUTTON
{
    RUN_VIEW_CUSTOM_BTN_1=0,
    RUN_VIEW_CUSTOM_BTN_2,
    RUN_VIEW_CUSTOM_BTN_3,
    RUN_VIEW_CUSTOM_BTN_4,
    RUN_VIEW_CUSTOM_CHECK_1,
    RUN_VIEW_CUSTOM_CHECK_2,
    RUN_VIEW_CUSTOM_CHECK_3,
    RUN_VIEW_CUSTOM_BTN_CNT,
};

class CMainDoc;

class DLLCLASS CRunView : public CFormView
{
protected:
    CRunView(); // protected constructor used by dynamic creation
    DECLARE_DYNCREATE(CRunView)

// Form Data
public:
// {{AFX_DATA(CRunView)
    enum {
        IDD = IDD_RUN_VIEW
    };
    CShadeCheckButtonST m_customCheck3;
    CShadeCheckButtonST m_customCheck2;
    CShadeCheckButtonST m_customCheck1;
    CShadeButtonST      m_customBtn4;
    CShadeButtonST      m_customBtn3;
    CShadeButtonST      m_customBtn2;
    CShadeButtonST      m_customBtn1;
    CPictureEx          m_picMITLogo;
    CShadeButtonST      m_logBtn;
    CShadeButtonST      m_stopBtn;
    CShadeButtonST      m_startBtn;
    CShadeButtonST      m_restartBtn;
    CShadeButtonST      m_resetBtn;
    CShadeButtonST      m_purgeBtn;
    CShadeButtonST      m_productionModeBtn;
    CShadeButtonST      m_engineeringModeBtn;
    CShadeButtonST      m_scheduleModeBtn;
    CShadeButtonST      m_noMaterialBtn;
    CStatic             m_DebugMsg;
    CPictureEx          m_layout;
    CStatic             m_lampRed;
    CStatic             m_lampGreen;
    CStatic             m_lampAmber;
    CString             m_runStatus;
    CString             m_hostmessage;
    CShadeButtonST      m_loginBtn;
    CShadeButtonST      m_btnSGMainMode;
    CShadeCheckButtonST m_jogBtn;
    CEdit               m_strSG_E10;
    CEdit               m_strSGSpoolTxt;
    CEdit               m_strSGModeTxt;
    CEdit               m_strSGLinkTxt;
    CEdit               m_strSGCtrlTxt;
    CEdit               m_strSGHandlerTxt;
// }}AFX_DATA

// Attributes
public:
//  CRunAnimate m_runAnimate;
// CPrjDoc* GetDocument();
    CMainDoc* GetDocument();
//  CDoorBypass* doorBypass;    //JG<07/Apr/2003>
    bool  door; // JG<07/Apr/2003>
    DWORD m_lAutoLogoutSuperUserDuration;

// Operations
public:
// Gary 2Aug11, V1.24.05
// method to reset autologout start timer
    void ResetAutoLogoutTimer();

    void RefreshRunViewTitleText(void);
    void DisplayIn2ndLang();
    void SetTitleJobName();
    void SetTitlePackageName();
    void SetTitleViewName(CString& csViewName);

//  hide/unhide machine controls
    void HideMcControls(bool bHide);

//  hide/unhide Main Mode controls
    void HideMainModeControls(bool bHide);

// Overrides
// ClassWizard generated virtual function overrides
// {{AFX_VIRTUAL(CRunView)
public:
    virtual void OnInitialUpdate();
protected:
    virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
    virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
// }}AFX_VIRTUAL

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

// Generated message map functions
// {{AFX_MSG(CRunView)
    afx_msg void   OnTimer(UINT nIDEvent);
    afx_msg void   OnLogging();
    afx_msg void   OnMainLogin();
    afx_msg void   OnStartButton();
    afx_msg void   OnStopButton();
    afx_msg void   OnResetButton();
    afx_msg void   OnRestartButton();
    afx_msg void   OnPurgeButton();
    afx_msg void   OnBtnProductionMode();
    afx_msg void   OnBtnEngineeringMode();
    afx_msg void   OnBtnNomaterialMode();
    afx_msg void   OnBtnScheduleMode();
    afx_msg void   OnSgMainmode();
    afx_msg void   OnJog();
    afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
    afx_msg void   OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void   OnCustomBtn1();
    afx_msg void   OnCustomBtn2();
    afx_msg void   OnCustomBtn3();
    afx_msg void   OnCustomBtn4();
    afx_msg void   OnCustomCheck1();
    afx_msg void   OnCustomCheck2();
    afx_msg void   OnCustomCheck3();
// }}AFX_MSG
    DECLARE_MESSAGE_MAP()

private:

// Gary 24Jul12, V1.24.11
    bool    m_bEnableCustomButton[RUN_VIEW_CUSTOM_BTN_CNT];
    int     m_nCustomButtonLevel[RUN_VIEW_CUSTOM_BTN_CNT];
    CString m_csCustomButtonName[RUN_VIEW_CUSTOM_BTN_CNT];

    void RefreshMessageDisplay();
    enum
    {
        MAX_MAIN_MODE = 4,
    };
    void RefreshControlButtons();
    void LoadBitmapFromFile();
    void RefreshCurrentUserName();
    void InitBitmap();
    void SetDlgItemFont();
    void CreateDlgFont(CString Name = "MS Sans Serif");
    void RefreshMcState(bool bForceRefresh = false);
    void RefreshTowerLamp();
    void RefreshSystemClock();
    void RefreshMessages();
    void MonitorAllThreads();
    CMainDoc* pDoc;
//  CValve* m_pValve;
    BOOL    m_bEndLotMessage;
    bool    m_bActivated;
    CFont   m_fontLogo;
    CBitmap m_bitmapMitLogo;
    CBitmap m_bitmapLamp;
    CBitmap m_bitmapLampRed;
    CBitmap m_bitmapLampAmber;
    CBitmap m_bitmapLampGreen;
    CBitmap m_bitmapLampStand;
    CBitmap m_bitmapMachine;
    CString m_sBuffer;
    HBITMAP hBitmap;

//  For Sec Gem Integration
    void RefreshSecsGemStatus();

    CBrush m_brushBkColor;

    COLORREF m_colorBackground;

// Gary 2Feb10, new multiuser password access
    bool m_bMultiUser;

// Gary 31May10, colour Status Message
    bool m_bColourStatusMessage;

// Gary 1Sep10 V1.23.01, different COLORREF for different login level
    bool     m_bDisplayBKColorByUserLevel;
    COLORREF m_colorLoginLevel[LOGIN_MAX_USER_LEVEL];

// Gary 2Aug11, V1.24.05
// autologout start timer
    DWORD m_dwAutoLogoutStartTimer;

    bool m_bAutoLogoutOnlyWhenEngineeringSwitchOFF;

// Phyu 17June2013 V1.24.15, different COLORREF for E10 State
    bool     m_bDisplayColorByE10Status;
    COLORREF m_colorE10Status[E10_MAX_STATUS];
// Phyu 17June2013 V1.24.15, different COLORREF for Main Mode
    bool     m_bDisplayColorByModeStatus;
    COLORREF m_colorModeStatus[MAINMODE_MAX];
};
///////////////////////////////////////////////////////////////
// Call this function to get a pointer to the view’s document.
// This allows you to call the document’s member functions.
///////////////////////////////////////////////////////////////
/*
   #ifndef _DEBUG  // debug version in RunView.cpp
   inline CPrjDoc* CRunView::GetDocument()
    { return (CPrjDoc*) m_pDocument; }
   #endif
 */
///////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////

// {{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_RUNVIEW_H__49DF5541_1831_11D1_BB66_00A0C9338123__INCLUDED_)
