// OutputController.h: interface for the COutputController class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_OUTPUTCONTROLLER_H__65E8EEA4_D76F_11D7_89B3_000629A6E157__INCLUDED_)
#define AFX_OUTPUTCONTROLLER_H__65E8EEA4_D76F_11D7_89B3_000629A6E157__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "hardwareini.h"
#include "OutputControllerBase.h"
#include <map>

#ifdef  BUILD_IODLL
#define     IODLLCLASS  __declspec(dllexport)
#else
#define     IODLLCLASS  __declspec(dllimport)
#endif

class COutputSetting;

class IODLLCLASS COutputController : public CCard
{
public:
    COutputController();
    virtual ~COutputController();

    BOOL SetVoltage(const COutputSetting &OutputSetting,  double dVoltage, double dRange);
    BOOL Off(const COutputSetting &OutputSetting);
    BOOL IsOn(const COutputSetting &OutputSetting);
    BOOL On(const COutputSetting &OutputSetting);
    BOOL InitController(void);

//  return the size of gOutputArray
    int GetSizeofOutputArray();

//  make a copy of gOutputArray
    void CopyOutputStatus();
//  void CopyOutputArray(BOOL bOutputArray[]);

//  check if there is state change in output
    BOOL IsOutputStateChange(int iOutputNo, BOOL &bOutputState);
//  BOOL IsOutputStateChange(BOOL bOutputState,int iOutputNo);

//  allocate array size for output array
    void InitOutputArray();

//  copy of gOutputArray that is used to compare the output state during machine running vs
//  output state in maintenance mode
    BOOL *m_bpOutputArray;

//  to keep track output state array size
    int m_iOutputStateArraySize;

    CMutex m_OutputMutex;

    static COutputController* GetInstance();
    COutputControllerBase   * GetController(int nCardType);

private:
    COutputControllerBase* m_outputControllerBase[MAX_OUTPUT_CARD_TYPE];

    int                    m_nNoOfCardType;
    CHardwareIni           m_iniHardware;
    CArray<stCard, stCard> m_astCard;

    static COutputController* instance;
};
#endif // !defined(AFX_OUTPUTCONTROLLER_H__65E8EEA4_D76F_11D7_89B3_000629A6E157__INCLUDED_)
