// client.h : main header file for the CLIENT application
//

#if !defined(CLIENT_H)
#define CLIENT_H

#define NUM_HOUSINGS 2

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "consumer.h"
#include "lrsinterface_client.h"
#include "lrscfg.h"
#include "lrsevtconsumer_i.h"
#include "gui/clientdialog.h"
#include "gui/resource.h"		// main symbols
#include "client.h"
#include "lrsconnectionstatus.h"

// Default settings for temp and rh alarms
#define DEFAULT_WARN_TEMP	24
#define DEFAULT_OVER_TEMP	32
#define DEFAULT_WARN_RH		35
#define DEFAULT_OVER_RH		60

// Name for alarm cfg items in lrs.cfg file
#define TEMP_WARN_CFG	"TEMP_WARNING"
#define TEMP_ALARM_CFG	"TEMP_ALARM"
#define RH_WARN_CFG		"RH_WARNING"
#define RH_ALARM_CFG	"RH_ALARM"

#define BADREADING -1


/////////////////////////////////////////////////////////////////////////////
// CLrsClient:
// See client.cpp for the implementation of this class
//

class CLrsClient : public CWinApp
{
public:
// Construction and destruction
	CLrsClient();
	~CLrsClient();

	// Shutdown ORB interfaces
	void shutdown();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CLrsClient)
	public:
	virtual BOOL InitInstance();
	//}}AFX_VIRTUAL

// Implementation

	//{{AFX_MSG(CLrsClient)	
	// NOTE - the ClassWizard will add and remove member functions here.
	// DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

public:
	void close();

	// Initialize client CORBA object references
	BOOL initCORBAClient();

	// Reconnects to CORBA client; call after connection is lost
	BOOL reconnectCORBAClient();

	// A wrapper class containing all ORB IDL proxy interfaces
	LRSInterface_Client  _interfaceClient;

	// The client dialog 
	CLrsClientDialog _dialog;

	// Application specific event interface consumer. Pushes data to
	// Client dialog for display
	LRSEventConsumer_i _lrsEventConsumer_i;
		
	// Instance of the consumer. This will monitor for events from 
	// the server
	Consumer _consumer;

	// Lrs configuration file manager
	LrsCfg _lrsCfg;

	// Setpoints used to change alarm display colors
	struct HousekeepingSetPoints {
		double overtemp;
		double warntemp;
		double overrh;
		double warnrh;
	};

	//each set of sensors has its own setpoint
	HousekeepingSetPoints	_setpoints[NUM_HOUSINGS]; 

private:

	struct CfgData {
		// Contains config item for relative humidity warn/alarm setpoints
		ConfigItemWrapper rh;
		// Contains config item for temperature warn/alarm setpoints
		ConfigItemWrapper temp;
	};
	
	CfgData _setpointCfg[NUM_HOUSINGS];

	void initSetpoints(const char*cfgname, HousingID id);

	// cmd line argument, used as arguments to restart
	// CORBA 
	int _argc;
	char *_argv[10];
};


/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(CLIENT_H)
