// InputControllerBase.h: interface for the CInputControllerBase class.
//
//////////////////////////////////////////////////////////////////////
#pragma once

#include <map>
#include <vector>

#include "hardwareini.h"

class CInputSetting;
class CInputBase;

class CInputControllerBase : public CCard
{
public:
    CInputControllerBase(std::string csMutexName);
    virtual ~CInputControllerBase();

    void RegisterInput(const CInputSetting& inputSetting, CInputBase* pInput);

    void DeRegisterInput(const CInputSetting& inputSetting);

    BOOL Init(int nHardwareIniTypeID);

    // virtual method to initialise the input controller card
    virtual int InitCard(int nHardwareIniTypeID, int nHardwareIniTypeCardNo, int* pPhysicalCardID) = 0;

    // virtual method to close the input controller card
    void Close(int nHardwareIniTypeID);

    virtual int CloseCard(int nPhysicalCardID) = 0;

    // virtual method to query if the input is OFF
    virtual BOOL IsOff(const CInputSetting& InputSetting);

    // virtual method to query if the input is ON
    virtual BOOL IsOn(const CInputSetting& InputSetting);

    // virtual method to query for current analog voltage of analog output
    virtual BOOL GetVoltage(const CInputSetting& InputSetting, double& dVoltage, int nRange);

    /***********************************************************************/
    /*********************currently for 9222 ONLY***************************/

    // virtual method to setup general counter
    virtual BOOL SetupCounter(const CInputSetting& InputSetting, int nMode);

    // new virtual method to cater for auto reset counter using Org Signal
    virtual BOOL SetupCounter(const CInputSetting& InputSetting, int nMode, unsigned int LReg1_Val, unsigned int LReg2_Val);

    // virtual method to clear counter
    virtual BOOL ClearCounter(const CInputSetting& InputSetting);

    // virtual method to enable counter counting
    virtual BOOL EnableCounter(const CInputSetting& InputSetting);

    // virtual method to disable counter counting
    virtual BOOL DisableCounter(const CInputSetting& InputSetting);

    // virtual method read the counter
    virtual unsigned long ReadCounter(const CInputSetting& InputSetting);

    std::map<std::string, CInputBase*>& GetIpMap();

    //
    virtual bool ReadInputs(std::vector<unsigned short>& vecInData);

protected:
    CMutex m_mutexInput;

    CHardwareIni m_iniHardware;
};
