// OutputControllerBase.h: interface for the COutputControllerBase class.
//
//////////////////////////////////////////////////////////////////////
#pragma once

#include <map>

#include "HardwareIni.h"

class COutputSetting;
class COutputBase;

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

    void RegisterOutput(const COutputSetting& outputSetting, COutputBase* pOutput);

    void DeRegisterOutput(const COutputSetting& outputSetting);

    BOOL Init(int nHardwareIniTypeID);

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

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

    virtual int CloseCard(int nPhysicalCardID) = 0;

    // virtual method to set analog voltage
    BOOL SetVoltage(const COutputSetting& OutputSetting, double dVoltage, double dRange);

    // virtual method to turn output OFF
    BOOL Off(const COutputSetting& OutputSetting);

    // virtual method to turn output ON
    BOOL On(const COutputSetting& OutputSetting);

    std::map<std::string, COutputBase*>& GetOpMap();

protected:
    CMutex m_mutexOutput;

    CHardwareIni m_iniHardware;

    void UpdateOutputMap(const COutputSetting& OutputSetting, BOOL bLogic);
};
