#ifndef TakeUndoCancel_INCLUDED
	#define TakeUndoCancel_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 MAX_MTX_DEST 200

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

	void buttonCallback( buttonNotify *b );
	int revertiveCallback( revertiveNotify * r );
	void databaseCallback( revertiveNotify * r );
	bncs_string parentCallback( parentNotify *p );
	void timerCallback( int );
	
private:
	bncs_string m_instance;
	bncs_string bgndState;
	bncs_string takeHighState;
	bncs_string takeLowState;

	int matrixID;			// BNCS Driver ID passed to us by instance
	int sourceID;			// Source ID from selection panel
	int destID;				// Destination ID from selection panel
	int undoSource;			// Source ID for UNDO button
	int undoDest;			// Destination ID for UNDO button
	int takeCounter;		// Holds the count value that limits the TAKE enabled availability
	int numDestinations;	// Number of destinations for router matrixID

	bool takeEnabled;		// Indicates that the TAKE button is active - valid source and destination available
	bool undoEnabled;		// Indicates that the UNDO button is active
	bool revertRegistered;	// Flag to show if there is an active revertive registration
	bool m_takeDouble;		// Flag used to hold the double press property for TAKE button
	bool m_undoDouble;		// Flag used to hold the double press property for UNDO button

	int revertState[MAX_MTX_DEST+1];	// Keeps copy of current state of matrix routes
	
	void checkTakeEnable(void);			// Function that checks for valid source and destination
	void disableUndo(void);				// Service function to clear down UNDO button
};


#endif // TakeUndoCancel_INCLUDED