#ifndef LD_Select_INCLUDED
	#define LD_Select_INCLUDED

#include <bncs_script_helper.h>

#ifdef WIN32
	#ifdef DOEXPORT_SCRIPT
		#define EXPORT_SCRIPT __declspec(dllexport) 
	#else
		#define EXPORT_SCRIPT 
	#endif
#else 
	#define EXPORT_SCRIPT
#endif
 
class LD_Select : public bncs_script_helper
{
public:
	LD_Select( bncs_client_callback * parent, const char* path );
	virtual ~LD_Select();

	void buttonCallback( buttonNotify *b );
	int revertiveCallback( revertiveNotify * r );
	void databaseCallback( revertiveNotify * r );
	bncs_string parentCallback( parentNotify *p );
	void timerCallback( int );
	
private:
	bncs_string m_myParam;
	bncs_string m_instance;
	
	bncs_config myVals;				// Used to fetch config strings from xml files

	bncs_string Btn_Off;			// State for button mimic block when button not pressed
	bncs_string Btn_On;				// State for button mimic block when button pressed
	bncs_string defaultSourceName;	// Name of default source used when no button pressed
	bncs_string currentSourceName;	// Name of SDI source currently routed to LD monitor
	bncs_string stateHi, stateLo;	// Hold the names of the statesheet settings for button pressed and released

	bool BtnPressed;				// Set true if any of the buttons are pressed
	bool sdiRegistered;				// Set true when SDI router register has been actioned
	bool gpiRegistered;				// Set true when GPI router has been registered
	bool tallyRegistered;			// Set true when Tally Infodriver has been registered
	bool pollTimer;					// Shows first poll timer is running. Used by destructor code
	bool awaitTally;				// Flag that is cleared once tally infodriver has replied
	bool awaitGPI;					// Flag that is cleared once GPI device has replied

	int sdSDIdriver;				// Matrix driver number of SDI router
	int tallyInfodriver;			// Driver ID for the tally infodriver
	int matrixDestination;			// Output crosspoint no. that feeds Vision Monitor
	int gpiDriverID;				// GPI driver number of GPI interface that has joystick tallies
	int gpiSlotFirst;				// GPI connection number for the first joystick
	int gpiSlotLast;				// GPI connection number for the last joystick

	int defaultSDIsourceID;			// SD-SDI source number routed when no joystick is pressed
	int currentSDIsourceID;			// SD-SDI source currently routed to the vision monitor

	int sw_src[8];					// Array of monitor destinations
	int pressed[8];					// Holds the known state of the GPI buttons

	void switchDest(void);
};


#endif // LD_Select_INCLUDED