#pragma once
#include "afxwin.h"


// CDevCtrlDlgEx 对话框
class  CPresetList
{
public:
	CPresetList(char *pPresetList)
	{
		m_pStrPresetList = strdup(pPresetList);
		memset(&m_PresetList, 0x00, sizeof(preset_list));
		DoParse();
	}

	~CPresetList()
	{
		free (m_pStrPresetList);
		m_pStrPresetList = NULL;
		memset(&m_PresetList, 0x00, sizeof(m_pStrPresetList));
	}

	char *m_pStrPresetList;
	struct  preset_list
	{
		int nPresetNum;
		int nSRuleNum;
		int nORuleNum;

		int iPreset[255]; //预置点
		struct so_rule
		{
			struct start_end 
			{
				int iHour;
				int iMin;
			}Start, End;
			int iRuleID;
		}SRule[8], ORule[8];
	}m_PresetList;

private:
	int Split(char *m_innerText,char* spobj,int NeedRemoveEmpty,CStringArray &retls);
	void DoParse();

	void BeNoSpace(char *pStr, int iStrLen);
	

};

class CDevCtrlDlgEx : public CDialog
{
	DECLARE_DYNAMIC(CDevCtrlDlgEx)

public:
	CDevCtrlDlgEx(CRect rcWnd, CWnd* pParent = NULL);   // 标准构造函数
	virtual ~CDevCtrlDlgEx();

// 对话框数据
	enum { IDD = IDD_DLG_DEVCTRLEX };
	void StatusEvent(LONG lUser,LONG nStateCode,char *pResponse);
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()
private:
	CString m_strPreset;
	CRect m_rcClient;
	CStatic m_ctlGroup;
	virtual BOOL OnInitDialog();
	afx_msg void OnBnClickedBtnAdd();
	afx_msg void OnBnClickedBtnDelete();
	afx_msg void OnBnClickedBtnQuery();
	
// 	CComboBox m_ctlCBTimerFunc;
// 	CComboBox m_ctlCBFuncRule;
// 	CEdit m_ctlEDTimeStart;
// 	CEdit m_ctlTimeEnd;
	virtual BOOL PreTranslateMessage(MSG* pMsg);


	CComboBox m_ctlCBBack;

	int IsTimeIn(int iHour,int iMin, int iStartHour, int iStartMin, int iEndHour, int iEndMin);
	CComboBox m_ctlCBList;
};
