// WEB_IO_TESTDlg.h :
//

#pragma once

#include "StatusWnd.h"
#include "OutputButton.h"
//#include "CommProcess.h"
#include "SettingDlg.h"
#include "afxcmn.h"
#include "afxwin.h"
#include "RHIO_Process.h"

#define ID_INPUT_STATUS			10000
#define ID_COMM_PROCESS			20000

class CWEB_IO_TESTDlg : public CDialog
{

public:

	//////////////////////////////////////////////////////////////////////////
	//Definition of the RHIO Process Dll 
	HMODULE m_hModule;
	pRHIO_CommProcessCreate m_rhCreate;
	pRHIO_SockConnect m_rhSockConnect;
	pRHIO_CommConnect m_rhCommConnect;
	pRHIO_Close	m_rhClose;
	pRHIO_SndCmd_SetOnOff m_rhSndSetOnOff;
	pRHIO_SndCmd_GetOnOff m_rhSndGetOnOff;
	pRHIO_SndCmd_SetSettingMode m_rhSndSetSettingMode;
	pRHIO_SndCmd_SetRunMode	m_rhSndSetRunMode;
	pRHIO_SndCmd_SetMACRO m_rhSndSetMacro;
	pRHIO_SndCmd_GetMACRO m_rhSndGetMacro;
	pRHIO_SndCmd_SetDelayPulse m_rhSndSetDelayPulse;
	pRHIO_SndCmd_GetDelayPulse m_rhSndGetDelayPulse;
	pRHIO_SndCmd_SetADC m_rhSndSetADC;
	pRHIO_SndCmd_GetADC m_rhSndGetADC;
	pRHIO_SndCmd_SetPortEnable m_rhSndSetEnable;
	pRHIO_SndCmd_GetPortEnable m_rhSndGetEnable;
	pRHIO_SndCmd_SetPwrStopEnable m_rhSndSetPwrStop;
	pRHIO_SndCmd_GetPwrStopEnable m_rhSndGetPwrStop;
	pRHIO_SndCmd_SetFactoryReset m_rhSndSetFactory;
	pRHIO_SndCmd_SetSerial m_rhSndSetSerial;
	pRHIO_SndCmd_GetSerial m_rhSndGetSerial;
	pRHIO_SndCmd_GetFirmware m_rhSndGetFirmware;
	pRHIO_GetSettingData m_rhGetSettingData;
	pRHIO_GetOnOffData m_rhGetOnOffData;
	//////////////////////////////////////////////////////////////////////////
	


	CStatusWnd m_wndSample[4];
	CStatic m_sttSample[4];

	CSettingDlg m_dlgSetting;

//	CCommProcess m_comProcess;		//Window for communication processing.


	CStatusWnd m_wndInput[16];		//input (1~16)
	CStatic m_sttInput[16];			//
	CStatic m_sttInputTitle;

	COutputButton m_btnOutput[10];		//output (1~10)
	CBitmap m_bmpOutput[10];
	

public:
	CWEB_IO_TESTDlg(CWnd* pParent = NULL);

	enum { IDD = IDD_WEB_IO_TEST_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);


protected:
	HICON m_hIcon;

	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg LRESULT OnUpdateStatus(WPARAM wParam, LPARAM lParam);
	DECLARE_MESSAGE_MAP()
public:
	void SetOutPutStatus(int index, EOnOffFlag eStatus);
	void InitOutPutButton(void);
	void Init(void);
	void InitInput(CPoint pntStart, int iWidth, int iHeight, int iTerm);
	void RHIODllLoad();
	void EnableOutputAll(BOOL bCheck);
	afx_msg void OnBnClickedButtonConnect();
	afx_msg void OnBnClickedButtonClose();
	afx_msg void OnBnClickedButtonSetting();
	void InitSample(CPoint pntStart, int iWidth, int iHeight, int iTerm);
	afx_msg void OnBnClickedRadioTcp();
	afx_msg void OnBnClickedRadioCom();
	void InitSelComm(void);
	BOOL m_rdCommVal;
	afx_msg void OnBnClickedButtonStatusView();
	CIPAddressCtrl m_IPaddrCtrl;
	CEdit m_edtTCPPort;
	void InitSerialNum(void);
};
