//{{AFX_INCLUDES()
#include "cwbutton.h"
#include "indicator2.h"
//}}AFX_INCLUDES
#if !defined(AFX_DEVICEDLG_H__43BE01B1_F824_4B28_814B_74337570EBC9__INCLUDED_)
#define AFX_DEVICEDLG_H__43BE01B1_F824_4B28_814B_74337570EBC9__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DeviceDlg.h : header file
//

#include "StatusStatic.h"

class CDashboardRecipient;
class CDashboardDlg;
class CTailconeDlg;
class CAhrsDlg;
class CDepthSensorDlg;
class CPowerBoardDlg;
class CBatteryDlg;
class CDvlDlg;
class CHomingDlg;
class CGpsDlg;
class COasDlg;
class CSvsDlg;
class CAvtrakDlg;
class CLN250Dlg;
class CTestDlg;

#include <remote/MMAlarm.h>
#include "DataRecipient.h"

#define NUM_PORTS 16

/////////////////////////////////////////////////////////////////////////////
// CDeviceDlg dialog

class CDeviceDlg : public CDialog, public CDataRecipient
{
// Construction
public:
	CDeviceDlg(CWnd* pParent = NULL);   // standard constructor
	~CDeviceDlg();

// Dialog Data
	//{{AFX_DATA(CDeviceDlg)
	enum { IDD = IDD_DEVICE_DIALOG };
	CButton	m_test9;
	CButton	m_test8;
	CButton	m_test7;
	CButton	m_test6;
	CButton	m_test5;
	CButton	m_test4;
	CButton	m_test3;
	CButton	m_test2;
	CButton	m_test16;
	CButton	m_test15;
	CButton	m_test14;
	CButton	m_test13;
	CButton	m_test12;
	CButton	m_test11;
	CButton	m_test10;
	CButton	m_test1;
	CButton	m_start9;
	CButton	m_start8;
	CButton	m_start7;
	CButton	m_start6;
	CButton	m_start5;
	CButton	m_start4;
	CButton	m_start3;
	CButton	m_start2;
	CButton	m_start16;
	CButton	m_start15;
	CButton	m_start14;
	CButton	m_start13;
	CButton	m_start12;
	CButton	m_start11;
	CButton	m_start10;
	CButton	m_start1;
	CButton	m_stop9;
	CButton	m_stop8;
	CButton	m_stop7;
	CButton	m_stop6;
	CButton	m_stop5;
	CButton	m_stop4;
	CButton	m_stop3;
	CButton	m_stop2;
	CButton	m_stop16;
	CButton	m_stop15;
	CButton	m_stop14;
	CButton	m_stop13;
	CButton	m_stop12;
	CButton	m_stop11;
	CButton	m_stop10;
	CButton	m_stop1;
	CString	m_device1;
	CString	m_device10;
	CString	m_device11;
	CString	m_device12;
	CString	m_device13;
	CString	m_device14;
	CString	m_device15;
	CString	m_device16;
	CString	m_device2;
	CString	m_device3;
	CString	m_device4;
	CString	m_device5;
	CString	m_device6;
	CString	m_device7;
	CString	m_device8;
	CString	m_device9;
	//}}AFX_DATA

	// My public functions
	void setRecipient(CDashboardRecipient *recipient);
	void setDevice(int number, const char *name, int circuit);
	void setDriverStatus(char *name, int status);
	void resetDialog();
	void requestUpdate();
	void stopRequests();
	void launchTest(int portNum);
	void StartDriver(int portNum);
	void StopDriver(int portNum);
	void closeAllTests();


	void setDashboardDlg(CDashboardDlg *dd)
		{ m_dd = dd; };
	void setHomeDir(CString hd)
		{ m_homeDir = hd; };

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CDeviceDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:

	// MMRecipient
	CDashboardRecipient* m_recipient;

	BOOL OnToolTipNotify(UINT id, NMHDR * pTTTStruct, LRESULT * pResult);

	bool m_dataRequested;

	// Sub dialogs
	CTailconeDlg *m_tailconeDlg;
	CAhrsDlg *m_ahrsDlg;
	CDepthSensorDlg *m_depthSensorDlg;
	CPowerBoardDlg *m_powerBoardDlg;
	CBatteryDlg *m_batteryDlg;
	CDvlDlg *m_dvlDlg;
	CHomingDlg *m_homingDlg;
	CGpsDlg *m_gpsDlg;
	COasDlg *m_oasDlg;
	CSvsDlg *m_svsDlg;
	CAvtrakDlg *m_avtrakDlg;
	CLN250Dlg *m_ln250Dlg;

	CDashboardDlg *m_dd;
	CString m_homeDir;

	//info for holding config information

	typedef CArray<CString, CString> ServerNames;
	typedef struct SingleDia {
		CString name;
		int exStart; //index of most likely one to start
		ServerNames serverNames;
	};

	CArray<SingleDia*, SingleDia*> diaInfo;
	bool passed[NUM_PORTS];
	bool initPassed[NUM_PORTS];
	int circuits[NUM_PORTS];
	CString savedDevNames[NUM_PORTS];

	int m_circuitList[NUM_PORTS];
	CString * m_nameList[NUM_PORTS];
	CTestDlg * m_dialogList[NUM_PORTS];
	CStatusStatic * m_statusList[NUM_PORTS];
	CButton * m_testList[NUM_PORTS];
	CButton * m_startList[NUM_PORTS];
	CButton * m_stopList[NUM_PORTS];
	
	// My members
	void setAllCircuits(bool value);
	bool circuitSwitchActive();
	virtual BOOL OnInitDialog();
	void parseConfig(CString fname);
	int serverNameFound(CString dname, CString sName);
	int diaNameIndex(CString dname);
	int serverNameIndex(CString sname);

	int findDialogNameFromDeviceName(CString sName, char * dName);

	CString m_title;
	void receiveData();

	

	bool m_active;

	// Generated message map functions
	//{{AFX_MSG(CDeviceDlg)
	afx_msg void OnUpdate();
	afx_msg void OnTest1();
	afx_msg void OnTest2();
	afx_msg void OnTest3();
	afx_msg void OnTest4();
	afx_msg void OnTest5();
	afx_msg void OnTest6();
	afx_msg void OnTest7();
	afx_msg void OnTest8();
	afx_msg void OnTest9();
	afx_msg void OnTest10();
	afx_msg void OnTest11();
	afx_msg void OnTest12();
	virtual void OnOK();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnTest13();
	afx_msg void OnTest14();
	afx_msg void OnTest15();
	afx_msg void OnTest16();
	afx_msg void OnClose();
	afx_msg void OnButton1();
	afx_msg void OnStart1();
	afx_msg void OnStart2();
	afx_msg void OnStart3();
	afx_msg void OnStart4();
	afx_msg void OnStart5();
	afx_msg void OnStart6();
	afx_msg void OnStart7();
	afx_msg void OnStart8();
	afx_msg void OnStart9();
	afx_msg void OnStart10();
	afx_msg void OnStart11();
	afx_msg void OnStart12();
	afx_msg void OnStart13();
	afx_msg void OnStart14();
	afx_msg void OnStart15();
	afx_msg void OnStart16();
	afx_msg void OnStop1();
	afx_msg void OnStop2();
	afx_msg void OnStop3();
	afx_msg void OnStop4();
	afx_msg void OnStop5();
	afx_msg void OnStop6();
	afx_msg void OnStop7();
	afx_msg void OnStop8();
	afx_msg void OnStop9();
	afx_msg void OnStop10();
	afx_msg void OnStop11();
	afx_msg void OnStop12();
	afx_msg void OnStop13();
	afx_msg void OnStop14();
	afx_msg void OnStop15();
	afx_msg void OnStop16();
	DECLARE_EVENTSINK_MAP()
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DEVICEDLG_H__43BE01B1_F824_4B28_814B_74337570EBC9__INCLUDED_)
