//////////////////////////////////////
// header file for Rtr_Trig project //
//////////////////////////////////////

#if !defined(AFX_RTR_TRIG_H__6E1F4185_1C5F_11D4_82C5_00105AC8787D__INCLUDED_)
#define AFX_RTR_TRIG_H__6E1F4185_1C5F_11D4_82C5_00105AC8787D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "resource.h"

// TODO:	Insert additional constants, function prototypes etc. in this file

/* max size of buffer for data from string resource */
#define			MAX_LOADSTRING	100

/* max number of items in listbox */
#define			MAX_LB_ITEMS	500

#define		APP_WIDTH			640
#define		APP_HEIGHT			640

//SLOT DEFINITIONS***********************//
#define RELOAD_DEFAULTS_SLOT 100
#define ROUTER_SLOT 101
#define DESTINATION_SLOT 102
#define RANGE_SLOT 103
#define TRIGGER_DEVICE_TYPE_SLOT 104
#define TRIGGER_DEVICE_NUMBER_SLOT 105
#define OFFSET_SLOT 106
#define INVERT_TRIGGER_SLOT 107
#define LAST_SOURCE_SLOT 108
#define REROUTE_SLOT 110
//need to get rid of this lot!!
//#define LASTSOURCETIMER 1
//#define LASTSOURCEDELAY 5000
//#define LASTSOURCEPOLLTIMER 2
//#define LASTSOURCEPOLLDELAY 10000
//#define TIELINED_ROUTER 131
//#define TIELINE_DEST 108
//#define TIELINE_SOURCE 1
//|||||||||||||||||||||||||||||||GET RID OF
//LAst Source
#define LAST_SOURCE_DATABASE 3
//what is this one - looks like number of quartz buttons +1 OR Number of GPIs + 1????
#define NUMBER_OF_TRIGGERS 17
//application globals
#define BUFFER_LENGTH 256
#define MAX_NUMBER_OF_SOURCES 80
//Quartz Panel 'Colour Button Offset Slot'
#define CP1000_COLOUR_SLOT_OFFSET 40
#define Q3201_COLOUR_SLOT_OFFSET 100



/* main.cpp */
/* prototypes for main functionality */
ATOM				MyRegisterClass(HINSTANCE hInstance);
BOOL				InitInstance(HINSTANCE, int);
LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK	About(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK DlgProcChild(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT				InitApp(HWND);
void				CloseApp(HWND);

void				LoadIni(void);
int                 getWS(void);

char*               r_p(char* file, char* section, char* entry, char* defval, BOOL fWrite);

void                w_p(char* file, char* section, char* entry, char* setting);


void				Debug(LPCSTR szFmt, ...);
void				Log(LPCSTR szFmt, ...);
int					SplitString(char *string, char *delim, UINT count, char **outarray );

void				LoadConfig(void);
void				SendRouterCrosspoint(extclient*,int iSourceFromSlot);
void				TriggerSet(extclient*);
void				TriggerRelease(extclient*);
void				ReturnDatabaseSizes( int iDevice, int *db0, int *db1 );
void				VersionInfo(void);
//added for easr
void				RouterReRegister(const char* szRouter,const char* szDest);
void				Clear_Source_Configuration();
/* Rtr_Trig.cpp /*

/* prototypes for the notification functions */
void UpdateCounters(void);
void InfoNotify(extinfo* pex,UINT iSlot,LPCSTR szSlot);
LRESULT CSIClientNotify(extclient* pec,LPCSTR szMsg);


// TODO: add prototypes for functions from Rtr_Trig_x.cpp




#ifndef EXT
#define EXT extern
#endif

/////////////////////////////////////////////////////////////////////
// Global Variables for the Rtr_Trig project
/////////////////////////////////////////////////////////////////////

EXT HINSTANCE hInst;								// current instance
EXT TCHAR szTitle[MAX_LOADSTRING];			// The title bar text
EXT TCHAR szWindowClass[MAX_LOADSTRING];	// The title bar text
EXT char szResult[BUFFER_LENGTH];							// global for profile reads
EXT BOOL fLog;										// log enable flag
EXT BOOL fDebug;									// debug enable flag
EXT BOOL fDebugHide;								// debug visible flag
EXT HWND hWndMain,hWndList;					// window handles, main and debug
EXT HWND hWndDlg;									// window handle for child dialog
EXT int iChildHeight;							// height of child dialog
EXT RECT rc;
EXT int iDevice;									// command line parameter = external driver #
EXT int iWorkstation;							// workstation number from CSI.INI
EXT ULONG lTXCSI;									// CSI tx count
EXT ULONG lRXCSI;									// CSI rx count
EXT ULONG lTXID;									// ID tx count
EXT ULONG lRXID;									// ID rx count
EXT extinfo ei;									// an external infodriver class
EXT extclient ec;									// a client connection class

EXT HWND ghWnd;

EXT int iOffset;								//Trigger offset
//EXT int iInvertTrigger;							//Trigger GPI input logic flag
EXT int fQuartz_Label;							//Assign Quartz panel labels flag
EXT int iReRoute_LastSource;					//ReRoute joystick video flag - ReRoute Last Source Flag
EXT int iSave_LastSource;						//Save last Source Flag
EXT char sRouter[BUFFER_LENGTH];							//Current router device number to control

EXT char sDest[BUFFER_LENGTH];							//Current destination number to route to
EXT char sSource[BUFFER_LENGTH];							//Current source number to route
												// - joystick requirement
//EXT char sLastSource[BUFFER_LENGTH];				Now using iLast Source
EXT int iSourceArray[MAX_NUMBER_OF_SOURCES +1];						//Last source routed prior to triggered route
EXT int iTriggerArray[NUMBER_OF_TRIGGERS];						//array of current trigger states
EXT int iTriggerDevice;							//device number of Trigger Infodriver or GPI driver
EXT int iLastTriggerUsed;					//last trigger to cause a crosspoint (lowest priority!)	
EXT int iDTMFSlot;
EXT int iDTMFRevertiveSlot;
EXT int fLastSourceTimeOut;
EXT int fQuartz3201;
EXT char sMaskString[BUFFER_LENGTH];					//the mask feature allow selective triggering
EXT int iMaskInfodriver;
EXT int iMaskArray[NUMBER_OF_TRIGGERS];
EXT int fLoad_Defaults;						//load default router, dest and sources
EXT int iLastDestButton;						//
EXT int iFirstGPIO;
EXT int iTielineSourceArray[NUMBER_OF_TRIGGERS];			//relates to dedicated tieline from studer to aes router for PCR Loudspeaker
//EXT char sLASTSOURCEPOLL[BUFFER_LENGTH];
EXT int iRouterSize;
EXT	int x;					//What is this????????/
//TBS Stuff
EXT	int iTBSDriverNo;								//The Big Switch infodriver
EXT	int iTBSSlot;									//The Big Switch slot
EXT	int iVisionRouter;								//loaded on startup - this is the dual standard router
EXT int iTBSState;								//current state of TBS - initialise to 0 (SD)
// TODO: add additional global variables here, preceded by EXT
EXT BOOL blnContinueAutoInit; // set to true, only set to false if startup of auto fails in some way
EXT routerShim* rsh;					//pointer to the router shim
EXT LastSceRouteHandler * LastSce;		//poinetrt to the Last Source Handler
EXT int iLastSource;						//Stores Last Source ton be Routed on Restore
EXT int iQuartzLightColourState;		//state to write to slot for light colour
EXT int iQuartzDarkColourState;			//state to write to slot for dark colour

EXT char szVersion[BUFFER_LENGTH];		//version Info
#endif // !defined(AFX_RTR_TRIG_H__6E1F4185_1C5F_11D4_82C5_00105AC8787D__INCLUDED_)
