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

*/

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

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

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


#ifndef MAINTENANCEPAGE_H
#define MAINTENANCEPAGE_H

#include "GlobalDefine.h"
#include <QGraphicsWidget>
#include "Guipage.h"
#include <QString>
#include "PushButton.h"
#include "ZTSimulator.h"
#include "TextButtonWidget.h"
#include <QComboBox>
#include <QSpinBox>
#include "ToggleButtonWidget.h"
#include "ONOFFStatusWidget.h"

class CZoneTest;


#define MAINTENANCE_AUTO_EXIT_TIMEOUT (int)7200000	//Exit after 2 hours.

enum ePPId
{
	MAINTENANCE_PPI_ZT1_ID,
	MAINTENANCE_PPE_ZT1_ID,
	MAINTENANCE_PPI_ZT2_ID,
	MAINTENANCE_PPE_ZT2_ID
};

class CMaintenancePage : public CGuiPage
{
Q_OBJECT
public:
    CMaintenancePage(QGraphicsWidget *Parent = 0);

	CZoneTest *mProgramHandle;

	virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
	virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
	virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

private:
	QGraphicsRectItem *mBackgroundRect;
    CTextButtonWidget *mCancelButton, *mGenerateAlarmBtn, *mClearAlarmButton;

	QComboBox *mAlarmTypeList;
	QSpinBox *mAlarmRankSpinBox;
    QGraphicsTextItem *mAlarmDescription, *mRankDescription, *mFctDescription, *mWatchdogDisableDescription;
	QGraphicsTextItem *mPPIZT1Description, *mPPIZT2Description, *mPPEZT1Description, *mPPEZT2Description, *mPPTitle;
	CToggleButtonWidget *mMaintenanceActivationBtn;
    CToggleButtonWidget *mWatchdogEnableBtn;
	CONOFFStatusWidget *mZT1PPIStatus, *mZT1PPEStatus, *mZT2PPIStatus, *mZT2PPEStatus;
	QTimer *mMaintenanceModeAutoExitTimer;

	QGraphicsRectItem *mPPFrame, *mAlarmsFrame;

	void GenerateTK();
	void ShowMaintenanceItems();
	void HideMaintenanceItems();



public slots:
	void ButtonClicked(CTextButtonWidget *);
	void AlarmTypeSelectionChanged(int);
	void ActivationBtnToggled(CToggleButtonWidget*);
	void PPActivated(unsigned int);
	void AutoExit();
    void WatchdogEnableBtnToggled(CToggleButtonWidget*);
    void TKOutputChanged(bool,bool);

};

#endif // OPTIONSPAGE_H
