// PatrolDemoDlg.h : 头文件
//

#pragma once
#include "afxcmn.h"
#include "ReportCtrl.h"
#include "NetSDKDLL.h"
#include "DllPlayer.h"
#include <list>

#define DEV_TYPE_DVS            0
#define DEV_TYPE_IPC            1
#define DEV_TYPE_DECODE         2

#define WM_USR_DEV_STATUS_WND WM_USER+1000

typedef struct{	
	char  szDevSN[MAX_IPC_SERIALNUMBER];
	char  szDevId[MAX_IP_NAME_LEN];
	char  szDevName[MAX_IP_NAME_LEN];	
	char  szMACAddr[MAC_ADDRESS_LEN];	
	char  szIPAddr[MAX_IP_NAME_LEN];
	char  szNetMask[MAX_IP_NAME_LEN];
	char  szGateWay[MAX_IP_NAME_LEN];
	char  szDNS1[MAX_IP_NAME_LEN];
	char  szDNS2[MAX_IP_NAME_LEN];	
	char  szResolution[20];   //main or sub stream	
	char  szProtocolType[20];     //TCP or UDP	
	char  szLoginName[ACCOUNT_NAME_MAX_LEN];
	char  szLoginPsw[ACCOUNT_PASSWORD_MAX_LEN];
	char  szStatus[ACCOUNT_STATUS_MAX_LEN];
	
	int   nIndex;
	int   nDevType;
	int   nAuth;
	int	  nEnableDHCP;
	int   nVideoPort;	
	int   nRtpOverRtsp;
	int   nPtzPort;
	int   nWebPort;
	int   nOnline;
	BOOL  bVideo;        //Watch or not
	LONG  lRealHandle;
	LONG  lPlayerId;
	LONG  lAuxPtzId;

	STREAM_AV_PARAM oAVParam;
}DevInfo_t;

// CPatrolDemoDlg 对话框
class CPatrolDemoDlg : public CDialog
{
// 构造
public:
	CPatrolDemoDlg(CWnd* pParent = NULL);	// 标准构造函数

	int  OnInit();
	int  OnExit();	

	int  OnLoginDev();

	int  RefreshDevTree();
	int  RefreshDevTreeImage();

	int  OnAddWatch(DevInfo_t *pDevInfo);
	int  OnStopWatch();

private:
	static LONG CALLBACK OnSearchIPCCallBack(LONG nEventCode,LONG index,IPC_ENTRY *pResponse,void *pUser);
	static LONG CALLBACK OnDevStatusCallBack(LONG lUser,LONG nStateCode,char *pResponse,void *pUser);
	static LONG CALLBACK OnRealDataCallBack(LONG lRealHandle,DWORD dwDataType,BYTE *pBuffer,DWORD dwBufSize,LPFRAME_EXTDATA  pExtData);
	static LONG CALLBACK OnSerialDataCallBack(LONG lUser, char *pRecvDataBuffer, DWORD dwBufSize, void *pUser);

// 对话框数据
	enum { IDD = IDD_PATROLDEMO_DIALOG };

	BOOL             m_bSearchDev;
	BOOL             m_bPatrol;
	BOOL             m_bSound;
	CImageList       m_ImageList;
	DevInfo_t       *m_pPlayDev;
	int              m_nPlayIndex;

	std::list<IPC_ENTRY*> m_lstIPC;
	std::list<DevInfo_t> m_lstDevInfo;

protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 支持


// 实现
protected:
	HICON m_hIcon;

	// 生成的消息映射函数
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	CTreeCtrl m_treeDev;
public:
	CReportCtrl m_lstDev;
public:
	afx_msg void OnBnClickedButton2();
public:
	afx_msg void OnBnClickedBtnAddDev();
public:
	afx_msg void OnClose();
public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
public:
	afx_msg void OnNMDblclkTreeDev(NMHDR *pNMHDR, LRESULT *pResult);
public:
	afx_msg void OnBnClickedBtnStop();
public:
	afx_msg void OnBnClickedBtnPatrol();
public:
	afx_msg void OnTimer(UINT_PTR nIDEvent);
public:
	afx_msg void OnBnClickedBtnTest();
public:
	afx_msg void OnBnClickedBtnOpenSerial();
public:
	afx_msg void OnBnClickedBtnCloseSerial();
};
