#ifndef MODBUSDISPLAYPAGE_H
#define MODBUSDISPLAYPAGE_H

#include "Guipage.h"
#include "GlobalDefine.h"
#include <QGraphicsWidget>
#include "TextButtonWidget.h"
#include <QTreeWidget>
#include <QTimer>

enum eModbusTableSource
{
    CC_MODBUS_TABLE_SOURCE,
    SEI_MODBUS_TABLE_SOURCE
};

class CZoneTest;
class CModbusRepository;

class CModbusDisplayPage : public CGuiPage
{
    Q_OBJECT
public:
    CModbusDisplayPage(QGraphicsWidget *parent = 0);
    ~CModbusDisplayPage();
    virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
    virtual void showEvent(QShowEvent *event);


    CZoneTest *mProgramHandle;
    QGraphicsRectItem *mBackgroundRect;
    CTextButtonWidget *mCloseBtn;
    QTreeWidget *mModbusCCDataTree, *mModbusSEIDataTree;
    CModbusRepository *mCCRepoHandle, *mSEIRepoHandle;
    QTimer *mRefreshTimer;


private:
    int UpdateTable(int source);
    quint8 BCDToDecByte(const quint8 byte);
    quint16 BCDToDecWord(const quint16 word);

signals:

public slots:
    void ButtonClicked(CTextButtonWidget*);
    void UpdateCCModbusTable();
    void UpdateSEIModbusTable();
    void RefreshTimerExpired();

};


class CZTInfo
{
public:
    int mZT1PPIAlarmFlag1;
    int mZT1PPIAlarmFlag2;
    int mZT1PPIAlarmFlag3;
    int mZT1PPIAlarmFlag4;
    int mZT1PPEAlarmFlag1;
    int mZT1PPEAlarmFlag2;
    int mZT1PPEAlarmFlag3;
    int mZT1PPEAlarmFlag4;
    int mZT1PGAlarmFlag1;
    int mZT1PGAlarmFlag2;
    int mZT1PGAlarmFlag3;
    int mZT1PGAlarmFlag4;
    int mZT1FNAlarmFlag1;
    int mZT1FNAlarmFlag2;
    int mZT1FNAlarmFlag3;
    int mZT1FNAlarmFlag4;

    QList<qint16> mZT1Ranks;

    int mZT1V00AlarmFlag;
    int mZT1PEQ1AlarmFlag;

    int mZT2PPIAlarmFlag1;
    int mZT2PPIAlarmFlag2;
    int mZT2PPIAlarmFlag3;
    int mZT2PPIAlarmFlag4;
    int mZT2PPEAlarmFlag1;
    int mZT2PPEAlarmFlag2;
    int mZT2PPEAlarmFlag3;
    int mZT2PPEAlarmFlag4;

    QList<qint16> mZT2Ranks;

    int mZT2V02AlarmFlag;
    int mZT2PEQ2AlarmFlag;

    int mITI10_12Flag;

    int mWatchdogZT;

    int mWatchdogRemote;
    int mAN1;
    int mAN2;
    int mInhibitZT1;
    int mInhibitZT2;
    int mZT1TrainType;
    int mZT2TrainType;
    int mZT1TrainID1, mZT1TrainID2, mZT1TrainID3;
    int mZT2TrainID1, mZT2TrainID2, mZT2TrainID3;

    int mUpdateDateTimeFlag;
    int mNTPSeconds, mNTPHourMinutes, mNTPMonthDay, mNTPYear;


    CZTInfo(){;}
};


#endif // MODBUSDISPLAYPAGE_H
