// Input.h: interface for the CInput class.
//
//////////////////////////////////////////////////////////////////////
#pragma once

#include "hardwareini.h"
#include "InputBase.h"

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

class IODLLCLASS CInputSetting
{
public:

    std::string m_strName;
    std::string m_strModuleName;
    BOOL m_bLogic{FALSE};
    int m_nPointNo{ 0 };
    int m_nSlaveID{ 0 };
    int m_nPtrNo{ 0 };
    int m_nBoardType{ 0 };
    int m_nCardNo{ 0 };
};

class IODLLCLASS CInput : public CCard
{
public:
    CInput(const CInputSetting& Setting);
    virtual ~CInput();

    BOOL SetLastAICh(int nLastChannel);
    BOOL SetAIConfig(int nSignalRange);

    BOOL GetVoltage(double& dVoltage, int nRange);

    // method to start read
    BOOL StartRead();

    // method to get voltage only
    BOOL GetVoltageOnly(double& dVoltage, int nRange);

    // method to stop read
    BOOL StopRead();

    void AbortCheck(void);

    HANDLE GetEvt(BOOL bState);

    void StartWait(BOOL bState, DWORD dwDebounce, DWORD dwTimeout);

    BOOL Wait(BOOL bState, DWORD dwDebounce, DWORD dwTimeout);

    BOOL IsOff(void);

    BOOL IsOn(void);

    BOOL operator==(const BOOL bState);
    BOOL operator!=(const BOOL bState);

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

    // method to setup general counter
    BOOL SetupCounter(int nMode);

    // method to clear counter
    BOOL ClearCounter();

    // method to enable counter counting
    BOOL EnableCounter();

    // method to disable counter counting
    BOOL DisableCounter();

    // method read the counter
    unsigned long ReadCounter();

private:
    CInputBase* m_inputBase{ nullptr };
};
