//	alarms_output_base.h: interface for the alarms_output_base class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_ALARMS_OUTPUT_BASE_H__8956E02E_E1FC_4AC6_94E9_BD18D307F6DE__INCLUDED_)
#define AFX_ALARMS_OUTPUT_BASE_H__8956E02E_E1FC_4AC6_94E9_BD18D307F6DE__INCLUDED_

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

#include <alarms_base.h>

class Calarm_Process;
class QSemaphore;

#include <list>
using namespace std;

//! interface for the alarms_output_base class.

/*!
	This abstract base class provides the function prototypes for the output modules of the alarm system.

	All alarm output modules will be expected to implement the pure virtual functions listed. 
	Alarm modules must be written so that they always present the relevant and correct information, without 
	duplication, this may mean that you only 
	send changes to a network/client, there fore you need to remember the last state that you sent.

	dataReady() is expected to be called up to 50 times a second, if the module does not reply to this within a limited 
	time the module will be assumed to have failed in some way and will not receive any more dataReady() calls.
*/

class alarms_output_base  : public alarms_base
{
public:
	alarms_output_base(){};
	virtual ~alarms_output_base(){};

	/*! init is called when the module needs to load it's configuration file, the module should also do any intialisation it needs
	to do at this point.
	\param sFileName points the the configuration file to load.
	\param sProcs is a list of the processes in the order that they will be presented in the state array in dataReady().
	\return Return true if initialised OK, otherwise false.
	*/
	virtual bool init(char* sFileName, QStringList sProcs)=0;

	/*! This is called each time processing has been done, you are expected to check the data and 
	do what ever is necessary with it.
	\param data is the pointer to the int array of process states.
	\param length is the length of the process state array.
	\return Return true if  OK, otherwise false*/
	virtual bool dataReady(int *data, int length)=0;

	/*! This function points the module at the list of processes, this allows the module to change the state of a process
	i.e. force a process off, or acknowledge an error, not all modules will need to be able to do this.*/
	virtual void setOverrideList(list <Calarm_Process*>* pProcList,QSemaphore* sProcs) = 0;
	/*! This function is called after initialisation to set the last known state of the processes, do with this what ever needs to be done.
	\param data is the pointer to the int array of process states.
	\param length is the length of the process state array.*/
	virtual void setIntialStates(int *data, int length){return;};

	/*! Sets the module to Rx only, this is for redundancy, the main application will do any negotiation with
	other alarm systems to determine which system is active
	\return Return true if in Rx only mode mode*/
	virtual bool setRxOnly()=0;
	/*! Sets the module to TxRx, this is for redundancy, the main application will do any negotiation with
	other alarm systems to determine which system is active
	\return Return true if in TxRx mode*/
	virtual bool setTxRx()=0;
	/*! Sets the module to Force TxRx, this is for redundancy, the main application will do any negotiation with
	other alarm systems to determine which system is active
	\return Return true if in Force TxRx mode*/
	virtual bool forceTxRx()=0;
	/*! \return Return true if in Rx only mode mode*/
	virtual bool getTxMode()=0;

	/*! Sets whether the module does frequent network outputs.
	This is specifically for the database output's feature of sending out all new log lines as revertives as if
	from InfoDriver slot 1.
	\return Returns nothing.*/
	virtual void SetNetworkOutput( bool bOn ) =0;
};

#endif // !defined(AFX_ALARMS_OUTPUT_BASE_H__8956E02E_E1FC_4AC6_94E9_BD18D307F6DE__INCLUDED_)
