/*******************************************************************************
*                                                                              *
* Société de Transports de Montréal.                                    	   *
* 2012                                                                         *
*                                                                              *
* Projet Zones Tests                                                           *
*                                                                              *
*                                                                              *
*                                                                              *
*******************************************************************************/
/*
    Description:
    Description du fichier si nécessaire.

*/

/* ************************************************************************** */
/* Revision:
### 20121221 JFM
    Verision d'origine.

### YYYMMDD Description du besoin ou du bug
    Description du changement.
 */

/* ************************************************************************** */


#ifndef ZTPAGE_H
#define ZTPAGE_H

#include "GlobalDefine.h"
#include <QGraphicsWidget>
#include "Guipage.h"
#include <QString>
#include "PushButton.h"
#include "ZTSimulator.h"
#include "CDVItem.h"
#include "CDV.h"
#include "StatusBar.h"
#include "ZT1EquipmentWidget.h"
#include "ZT1StatsZone.h"
#include "EventsBar.h"
#include "ZT2EquipmentWidget.h"
#include "ZT2StatsZone.h"
#include "PasswordPrompt.h"

class CZoneTest;
class CEvent;

class CZTPage : public CGuiPage
{
Q_OBJECT
public:
	CZTPage(QGraphicsWidget *Parent = 0);
	CPushButton *mToolsPushButton;
    CPushButton *mZTLogPushButton;
    CZT1StatsZone *mZT1Stats;
    CZT2StatsZone *mZT2Stats;


	CZoneTest *mProgramHandle;
    CPasswordPrompt *mExitPasswordPrompt;

	unsigned int SetZTSimulator(CZTSimulator* Ptr);
	unsigned int SetStationName(QString Name);
	unsigned int SetCDVList(QList<CCDV*> *CDVListPtr);

	unsigned int UpdateCDVDisplay(int CDVIndex = -1);
	unsigned int SetZTStatus(unsigned int NbPass, unsigned int NbTriggers, unsigned int ZT1Active, unsigned int ZT2Active);
	unsigned int SetZT1Data(CZT1ThreadData *Data, bool ForceDisplay = false);
    unsigned int SetZT1TrainData(int TrainType, QList<qint16> TrainComposition);
    unsigned int SetZT2Data(CZT2ThreadData *Data);
    unsigned int SetZT2TrainData(int TrainType, QList<qint16> TrainComposition);
	unsigned int SetZT1ActivationState(bool ZT1Activated);
    unsigned int SetZT2ActivationSTate(bool ZT2Activated);
	unsigned int ResetZT1Stats();
    unsigned int ResetZT2Stats();
	unsigned int SetEventListPtr(QList<CEvent*>* ListPtr);
	unsigned int UpdateEventsList();
    unsigned int RequestExitPassword();
    unsigned int SetZT2Presence(bool IsPresent);
    unsigned int SetModbusPresent(bool IsPresent);


private:
	CZTSimulator *mZTSimulatorPtr;
	QTimer *mTimeDisplayTimer;
	QGraphicsTextItem *mTimeDisplayText;
    QGraphicsRectItem *mDeckRect;
	CStatusBar *mStatusBar;
	CZT1EquipmentWidget *mZT1EquipmentWidget;
    CZT2EquipmentWidget *mZT2EquipmentWidget;

	CEventsBar *mEventsBar;
	QElapsedTimer mZT1DisplayTimer;
    bool mIsZT2Present;


	QList<CCDV*> *mCDVList;	//pointer to the list of CDVs
	QList<CCDVItem*> mCDVItemsList;	//Graphical representation items only

public slots:
	void SettingsButtonPressed();
	void LogsButtonPressed();
	void UpdateTime();
    void ExitPasswordValid();
    void ExitPasswordInvalid();
    void ShowZTLogButtonPressed();
    void ModbusCCConnected();
    void ModbusCCDisconnected();
    void ModbusSEIConnected();
    void ModbusSEIDisconnected();
    void ModbusHistorienConnected();
    void ModbusHistorienDisconnected();


};

#endif // WELCOMEPAGE_H
