#ifndef UMDnames_INCLUDED
	#define UMDnames_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
 
#define ROUTERSIZEMAX	128		// Maximum number of matrix outputs or names in database
#define USERNAMESETS	8		// Number of User Name Sets

class UMDnames : public bncs_script_helper
{
public:
	UMDnames( bncs_client_callback * parent, const char* path );
	virtual ~UMDnames();

	void buttonCallback(buttonNotify *b);
	int revertiveCallback(revertiveNotify *r);
	void databaseCallback(revertiveNotify *r);
	bncs_string parentCallback(parentNotify *p);
	void timerCallback(int);
	
private:
	bncs_string sdiNames[ROUTERSIZEMAX + 1];	// Hold SDI names in locations 1 to ROUTERSIZEMAX
	bncs_string mv_func[ROUTERSIZEMAX + 1];		// Holds the names for the multiviewer functions
	bncs_string user_1[ROUTERSIZEMAX + 1];		// User name set 1
	bncs_string user_2[ROUTERSIZEMAX + 1];
	bncs_string user_3[ROUTERSIZEMAX + 1];
	bncs_string user_4[ROUTERSIZEMAX + 1];
	bncs_string user_5[ROUTERSIZEMAX + 1];
	bncs_string user_6[ROUTERSIZEMAX + 1];
	bncs_string user_7[ROUTERSIZEMAX + 1];
	bncs_string user_8[ROUTERSIZEMAX + 1];		// User name set 8
	bncs_string userNames[USERNAMESETS+1];		// Names of the user names sets.
	bncs_string *CurrentName;					// Pointer to the current name set array

	int tallyInfo;			// Driver ID for tally infodriver
	int umdNameMode;		// Holds value reported by Tally Infodriver slot 210
	int	umdBrightness;		// Holds brightness index reported by Tally Infodriver slot 211. Ignored by the multiviewer.
	int umdNameSetID;		// Holds the current name set ID reported by Tally Infodriver slot 212.
	int sdiDevID;			// Driver ID for SDI router
	int sdiMV_First;		// First SDI destination used for multiviewer input
	int sdiMV_Last;			// Number of SDI destinations to multiviewer
	int tslDriver;			// Driver ID for TSL driver.
	int namesDriver;		// Driver ID for User Names storage
	int tallyRevertCount;
	int sdiRevertCount;
	int sdiDests[ROUTERSIZEMAX + 1];	// Keeps copy of current router state

	bool failIniData;		// Flag to show if data initialisation fails
	bool tallyRevertReg;	// Flag to show if tally infodriver revertives registered
	bool sdiRevertReg;		// Flag to show if sdi revertives registered
	bool namesRevertReg;	// Flag to show if names driver has been registered for revertives.
	bool initalPoll;		// Set true whilst the initial data is retrieved from the drivers
	bool tallyRevertFlags[3];			// Hold flags to show revertives received from tally slots
	bool sdiRevertFlags[ROUTERSIZEMAX + 1];

	// Local Methods
	void mimicShowModes(void);
	void setName(const int mvIndex);	// Set the name on a single mimic and UMD
	void setBright(const int mvIndex);	// Update UMD brightness of a single display
	void updateAllNames(void);			// Function to update all 48 names on mimic and UMDs
	void updateAllBrightness(void);		// Sends updated brightness to all UMDs
};


#endif // UMDnames_INCLUDED