#pragma once

enum EOnOffFlag
{
	EOF_ON,
	EOF_ON_ADC_LEVEL,
	EOF_OFF,
	EOF_NOT,
	EOF_ON_DELAY,
	EOF_OFF_DELAY,
	EOF_ONOFF_MACRO,
	EOF_ONOFF_PULSE
};

enum SendStatusFlag
{
	ESF_ONOFF,
	ESF_SET,
	ESF_SET_MODE,
	ESF_RUN_MODE,
	ESF_SET_MACRO,
	ESF_SET_DELAY_PULSE,
	ESF_SET_ADC,
	ESF_SET_ENABLE,
	ESF_SET_PWR_STOP,
	ESF_SET_FACTROY_RESET,
	ESF_SET_SERIAL,
	ESF_MON_MACRO,
	ESF_MON_DELAY_PULSE,
	ESF_MON_ADC,
	ESF_MON_ENABLE,
	ESF_MON_PWR_STOP,
	ESF_MON_SERIAL,
	ESF_MON_FIRMWARE,
	ESF_NONE
};

enum ESetOutputFlag
{
	ESOF_CLEAR,
	ESOF_SETTING
};

#define WM_RHIO_RECEIVE          WM_USER + 1013


//////////////////////////////////////////////////////////////////////////
// Structure for the On/Off status
typedef struct _ADCData
{
	EOnOffFlag eADC;
	char cADC[5];
}SADCData;

typedef struct _OnOffStatusData
{
	EOnOffFlag eOutput[10];
	EOnOffFlag eInput[12];
	SADCData sADC[4];
}SOnOffStatusData;
//////////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////////////
// Structure for the setting-value
typedef struct _SetOutput
{
	ESetOutputFlag eMacro;			//MACRO Flag : ESOF_CLEAR, ESOF_SETTING
	char cMacro[106];				//MACRO Data
	ESetOutputFlag eDelayPulse;		//DelayPulse Flag : ESOF_CLEAR, ESOF_SETTING
	char cDelayPulse[11];			//DelayPulse Data
	bool isEnable[10];				//Output prot Enable
	bool isEnablePowerStop[10];		//Output port power stoppage
}SSetOutput;


enum EADCMode
{
	EAM_LEVEL,
	EAM_SWITCH
};

typedef struct _SetADC
{
	EADCMode eModeADC[4];			//ADC port Mode
	BYTE bReference;				//ADC Reference
	SADCData sADCData[4];			//ADC Level Data
}SSetADC;

typedef struct _SetInput
{
	bool isEnable[12];				//Input port Enable
}SSetInput;

typedef struct _RHIOSetting
{
	SSetOutput sOutput;			//Setting Output port Data;
	SSetADC sADC;				//Setting ADC port Data;
	SSetInput sInput;			//Setting Input port Data;
	char cGetSerial[18];		//Model name & Serial number
    char cGetFirmVer[9];		//Firmware Version
}SRHIOSetting;
//////////////////////////////////////////////////////////////////////////



extern "C" __declspec(dllexport) void RHIO_CommProcessCreate(CWnd *pParentWnd);
extern "C" __declspec(dllexport) bool RHIO_SockConnect(BYTE bAddr1, BYTE bAddr2, BYTE bAddr3, BYTE bAddr4, int iPort);
extern "C" __declspec(dllexport) bool RHIO_CommConnect(int iPort);
extern "C" __declspec(dllexport) bool RHIO_Close();
extern "C" __declspec(dllexport) bool RHIO_SndCmd_SetOnOff(int iOutputNum, EOnOffFlag eOnOff);
extern "C" __declspec(dllexport) bool RHIO_SndCmd_GetOnOff();
extern "C" __declspec(dllexport) bool RHIO_SndCmd_SetSettingMode();
extern "C" __declspec(dllexport) bool RHIO_SndCmd_SetRunMode();
extern "C" __declspec(dllexport) bool RHIO_SndCmd_SetMACRO(SRHIOSetting sSetData, int iPortNum);
extern "C" __declspec(dllexport) bool RHIO_SndCmd_GetMACRO(int iPortNum);
extern "C" __declspec(dllexport) bool RHIO_SndCmd_SetDelayPulse(SRHIOSetting sSetData, int iPortNum);
extern "C" __declspec(dllexport) bool RHIO_SndCmd_GetDelayPulse(int iPortNum);
extern "C" __declspec(dllexport) bool RHIO_SndCmd_SetADC(SRHIOSetting sSetData);
extern "C" __declspec(dllexport) bool RHIO_SndCmd_GetADC();
extern "C" __declspec(dllexport) bool RHIO_SndCmd_SetPortEnable(SRHIOSetting sSetData);
extern "C" __declspec(dllexport) bool RHIO_SndCmd_GetPortEnable();
extern "C" __declspec(dllexport) bool RHIO_SndCmd_SetPwrStopEnable(SRHIOSetting sSetData);
extern "C" __declspec(dllexport) bool RHIO_SndCmd_GetPwrStopEnable();
extern "C" __declspec(dllexport) bool RHIO_SndCmd_SetFactoryReset();
extern "C" __declspec(dllexport) bool RHIO_SndCmd_SetSerial(CString strSerial);
extern "C" __declspec(dllexport) bool RHIO_SndCmd_GetSerial();
extern "C" __declspec(dllexport) bool RHIO_SndCmd_GetFirmware();
extern "C" __declspec(dllexport) bool RHIO_GetSettingData(SRHIOSetting &sSetData);
extern "C" __declspec(dllexport) bool RHIO_GetOnOffData(SOnOffStatusData &sOnOffData);


typedef void (*pRHIO_CommProcessCreate)(CWnd *pParentWnd);
typedef bool (*pRHIO_SockConnect)(BYTE bAddr1, BYTE bAddr2, BYTE bAddr3, BYTE bAddr4, int iPort);
typedef bool (*pRHIO_CommConnect)(int iPort);
typedef bool (*pRHIO_Close)();
typedef bool (*pRHIO_SndCmd_SetOnOff)(int iOutputNum, EOnOffFlag eOnOff);
typedef bool (*pRHIO_SndCmd_GetOnOff)();
typedef bool (*pRHIO_SndCmd_SetSettingMode)();
typedef bool (*pRHIO_SndCmd_SetRunMode)();
typedef bool (*pRHIO_SndCmd_SetMACRO)(SRHIOSetting sSetData, int iPortNum);
typedef bool (*pRHIO_SndCmd_GetMACRO)(int iPortNum);
typedef bool (*pRHIO_SndCmd_SetDelayPulse)(SRHIOSetting sSetData, int iPortNum);
typedef bool (*pRHIO_SndCmd_GetDelayPulse)(int iPortNum);
typedef bool (*pRHIO_SndCmd_SetADC)(SRHIOSetting sSetData);
typedef bool (*pRHIO_SndCmd_GetADC)();
typedef bool (*pRHIO_SndCmd_SetPortEnable)(SRHIOSetting sSetData);
typedef bool (*pRHIO_SndCmd_GetPortEnable)();
typedef bool (*pRHIO_SndCmd_SetPwrStopEnable)(SRHIOSetting sSetData);
typedef bool (*pRHIO_SndCmd_GetPwrStopEnable)();
typedef bool (*pRHIO_SndCmd_SetFactoryReset)();
typedef bool (*pRHIO_SndCmd_SetSerial)(CString strSerial);
typedef bool (*pRHIO_SndCmd_GetSerial)();
typedef bool (*pRHIO_SndCmd_GetFirmware)();
typedef bool (*pRHIO_GetSettingData)(SRHIOSetting &sSetData);
typedef bool (*pRHIO_GetOnOffData)(SOnOffStatusData &sOnOffData);