// EMS.h: interface for the CEMS class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_EMS_H__3229B831_5AAD_4384_A3B8_A51DD9C0D40C__INCLUDED_)
#define AFX_EMS_H__3229B831_5AAD_4384_A3B8_A51DD9C0D40C__INCLUDED_

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

#include "RunTask.h"
#include "Input.h"
#include "Output.h"
#include "commondef.h"

class CEMS : public CRunTask
{
public:
    bool CanMachineRun();
    bool IsEMSEnable();
    void UpdateMachineStart();
    void UpdateMachineStop();
    void UpdateUnitCount();
    void InitParameters();
    UINT RunThread();
    void SetEMSOutput(int nNo, COutput *copOutput);
    void SetEMSInput(int nNo, CInput *cipInput);
    CEMS();
    virtual ~CEMS();

private:
    void CheckHostAllowMachineToRun();
    void CheckMachineStatus();
    void CheckUnitCountUpdate();
    void GetMainApp();

    CEvt m_evtSendUnitPulse;
    CEvt m_evtMachineStop;
    CEvt m_evtMachineStart;

    HWND m_hwndMainApp;

    CInput  *m_cipEMSStatus;
    COutput *m_copEMSCount;

    bool m_bEMSEnable;
    bool m_bMsgSendOn;
    bool m_bMsgSendOff;

    int m_iEmsPulse;
};

#endif // !defined(AFX_EMS_H__3229B831_5AAD_4384_A3B8_A51DD9C0D40C__INCLUDED_)
