// EquipState.h: interface for the CEquipState class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_EQUIPSTATE_H__2F80B5CC_3DE5_4842_A583_A1482102E235__INCLUDED_)
#define AFX_EQUIPSTATE_H__2F80B5CC_3DE5_4842_A583_A1482102E235__INCLUDED_

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

#include "TimeEquipSubState.h"

/*
   #ifdef   BUILD_MCCTRDLL
   #define      MCCTRDLLCLASS   __declspec(dllexport)
   #else
   #define      MCCTRDLLCLASS   __declspec(dllimport)
   #endif

   class MCCTRDLLCLASS CEquipState*/
class CEquipState
{
public:
//  default constructor
    explicit CEquipState(int iNoOfEquipState);

//  default Destructor
    virtual ~CEquipState();

//  read all equipment SubState time span from file
    virtual void ReadTimeSpanFromFile();

//  get equipment substate time
    virtual LONGLONG GetEquipSubStateTime(int iEvt);

//  save equipment substate time that is clocking to file
    virtual void SaveTimeInfo();

//  check is equipment Substate timer started
    virtual bool IsTimerStarted(int iEvt);

    enum
    {
        NON_SCHEDULE_TIME,
        ENGINEERING_TIME,
        PRODUCTIVE_TIME,
        STANDBY_TIME,
        UNSCHEDULED_DOWNTIME,
        SCHEDULED_DOWNTIME,
        MANUFACTURING_TIME,
        UPTIME,
        DOWNTIME,
        OPERATIONS_TIME,
        TOTAL_TIME,
        MAX_EQUIP_STATE,
    };

    enum
    {
        UNWORK_SHIFT_DAYS_EVT,
        INSTALLATION_MODIFICATION_REBULID_UPGRADE_EVT,
        OFFLINE_TRAINING_EVT,
        SHUTDOWN_START_UP_EVT,
        PROCESS_EXPERIMENTS_EVT,
        EQUIP_EXPERIMENTS_EVT,
        SOFTWARE_QUALIFICATION_EVT,
        REGULAR_PRODUCTION_EVT,
        WORK_FOR_3RD_PARTY_EVT,
        REWORK_EVT,
        ENGINEERING_RUNS_EVT,
        NO_OPERATOR_EVT,
        NO_PRODUCT_EVT,
        NO_SUPPORT_TOOL_EVT,
        STOP_MACHINE_EVT,
        UNSCHEDULED_MAINT_DELAY_EVT,
        JAM_EVT,
        UNSCHEDULED_CHANGE_OF_CONSUMABLES_CHEMICALS_EVT,
        OUT_OF_SPEC_INPUT_EVT,
        UNSCHEDULED_FACILITIES_RELATED_EVT,
        SCHEDULED_MAINT_DELAY_EVT,
        PRODUCTION_TEST_EVT,
        PREVENTIVE_MAINT_EVT,
        SCHEDULED_CHANGE_OF_CONSUMABLES_CHEMICALS_EVT,
        SETUP_EVT,
        SCHEDULED_FACILITIES_RELATED_EVT,
        MAX_EQUIPMENT_SUBSTATE,
        LOT_CLOSED_EVT,
        LOT_OPEN_EVT,
        STOP_ALL_TIMER_EVT,
        RESET_ALL_TIMER_EVT,
        START_ALL_TIMER_EVT,                                // Possible to start all timer? need to have this event?
    };

    static CString     m_csKeyName[MAX_EQUIPMENT_SUBSTATE]; // key name of debug info file
    static const char *sSectionName[MAX_EQUIP_STATE];       // Section name of debug info file

protected:
//  set equipment state time
    virtual void SetEquipTime(int iEquipSubStateNo, int iState);

//  get total Equipment time
    virtual LONGLONG GetTotalEquipTime();

//  set all equipment State
    virtual void SetAllEquipState(int iEvt, int iState);

//  write all equipment SubState time span To File
    virtual void WriteAllEquipSubStateTimeSpanToFile(CString csFileName = RUNTIME_INI,
                                                     CString csSectionName = "SEMIE10");

//  write individual equipment SubState time span to file
    virtual void WriteTimeSpanToFile(int iEquipSubStateNo, CString csFileName = RUNTIME_INI,
                                     CString csSectionName = "SEMIE10");

//  read individual equipment SubState time span from file
    virtual void ReadTimeSpanFromFile(int iEquipSubStateNo, CString csFileName = RUNTIME_INI,
                                      CString csSectionName = "SEMIE10");

//  Check open lot event
    virtual void CheckOpenLotEvt(int iEvt);

//  Check close lot event
    virtual void CheckCloseLotEvt(int iEvt);

//  set equipment SubState time
    virtual void SetEquipSubStateTime(int iEquipSubStateNo, LONGLONG lTimeSpan);

//  add equipment SubState time
    virtual void AddEquipSubStateTime(int iEquipSubStateNo, LONGLONG lTimeSpan);

    int *m_iEvt;

    CTimeEquipSubState *m_ctesEquipSubState;

private:
    // prevent accidental copy
    CEquipState(const CEquipState& rhs);

    int m_iNoOfEquipSubState; // num of equipment state
//  int m_iEquipSubStateNo; // equipment state number

//  Equipment substate time has been written to file before
    bool m_bOpenLot;

//  to init section name and keyname
    static void iniSectionAndKeyName();
};

#endif // !defined(AFX_EQUIPSTATE_H__2F80B5CC_3DE5_4842_A583_A1482102E235__INCLUDED_)
