#include "HistorienDisplayPage.h"
#include "Zonetest.h"
#include <QGraphicsProxyWidget>
#include "ModbusCCDefs.h"
#include "ModbusSEIDefs.h"
#include "ModbusRepository.h"
#include <QGraphicsTextItem>
#include "HistorienData.h"
#include "PIHistorianDefs.h"

CHistorienDisplayPage::CHistorienDisplayPage(QGraphicsWidget *parent)
{
    setParentItem(parent);

    mProgramHandle = 0;
    mHistorienRepoHandle = 0;


    mBackgroundRect = new QGraphicsRectItem(boundingRect(), this);
    QBrush BackgroundBrush(QColor(245, 245, 255,200));
    mBackgroundRect->setBrush(BackgroundBrush);

    QGraphicsTextItem *TableTitle = new QGraphicsTextItem("Table Modbus Historien",this);
    QFont font;
    font.setPointSize(18);
    TableTitle->setFont(font);
    TableTitle->setPos(40,10);

    mCloseBtn = new CTextButtonWidget("Fermer");
  //  mCloseBtn->setParentItem(this);
    mCloseBtn->setPos(775,610);
    connect(mCloseBtn,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));

    mHistorienDataTree = new QTreeWidget;
    QGraphicsProxyWidget *Proxy = new QGraphicsProxyWidget(this);
    Proxy->setWidget(mHistorienDataTree);
    Proxy->setPos(0,0);



    QTreeWidgetItem *Item = new QTreeWidgetItem(QStringList()<<"ZT");
    mHistorienDataTree->setColumnCount(3);
    mHistorienDataTree->setHeaderItem(new QTreeWidgetItem(QStringList()<<"Registre"<<"Description"<<"Valeur"));

    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2000/b0")<<"Détection FN en service"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2000/b1")<<"Détection PP  en service"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2000/b2")<<"Détection PG en service"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2000/b3")<<"Détection PP ZT2 en service"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2000/b4")<<"Mode entretien activé"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2000/b5")<<"Santé lien HPC"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2000/b6")<<"Santé lien SEI"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2000/b7")<<"ZT1 en service"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2000/b8")<<"ZT2 en service"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2001")<<"Calibration pneu de guidage"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2002")<<"Date démarrage  ZT année"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2003")<<"Date démarrage ZT mois"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2004")<<"Date démarrage ZT jour"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2005")<<"Heure démarrage ZT heure"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2006")<<"Heure démarrage ZT minutes"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2007")<<"Heure démarrage ZT secondes"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2008")<<"Nb passages total"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2009")<<"Nb déclenchements total"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2010")<<"Nb passages aujourd'hui"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2011")<<"Nb déclenchements aujourd'hui"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2012")<<"Nb décl. FN aujourd'hui"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2013")<<"Nb décl. PPI  aujourd'hui"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2014")<<"Nb décl. PPE  aujourd'hui"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2015")<<"Nb décl. PG ajourd'hui"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2016")<<"Nb décl. PPI ZT2 aujourd'hui"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2017")<<"Nb décl. PPE ZT2 aujourd'hui"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2018")<<"Date dernier passage année"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2019")<<"Date dernier passage mois"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2020")<<"Date dernier passage jour"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2021")<<"Heure dernier passage heure"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2022")<<"Heure dernier passage minutes"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2023")<<"Heure dernier passage secondes"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2024")<<"Zone franchie (ZT1 = 1, ZT2 = 2)"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2025")<<"Nb déclenchement lors du passage"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2026")<<"Rang dernier passage PPI 1"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2027")<<"Rang dernier passage PPI 2"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2028")<<"Rang dernier passage PPI 3"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2029")<<"Rang dernier passage PPI 4"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2030")<<"Rang dernier passage PPE 1"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2032")<<"Rang dernier passage PPE 2"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2032")<<"Rang dernier passage PPE 3"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2033")<<"Rang dernier passage PPE 4"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2034")<<"Rang dernier passage PG 1"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2035")<<"Rang dernier passage PG 2"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2036")<<"Rang dernier passage PG 3"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2037")<<"Rang dernier passage PG 4"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2038")<<"Rang dernier passage FN 1"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2039")<<"Rang dernier passage FN 2"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2040")<<"Rang dernier passage FN 3"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2041")<<"Rang dernier passage FN 4"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2042")<<"Erreur comptage"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2043")<<"Panne équipement"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2044")<<"Type MR (63,73,10)"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2045")<<"Identification du train  - élément 1"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2046")<<"Identification du train  - élément 2"<<"---"));
    Item->addChild(new QTreeWidgetItem(QStringList()<<QString().fromUtf8("2047")<<"Identification du train  - élément 3"<<"---"));



    mHistorienDataTree->insertTopLevelItem(0,Item);
    mHistorienDataTree->expandAll();
    mHistorienDataTree->resizeColumnToContents(0);
    mHistorienDataTree->resizeColumnToContents(1);
    mHistorienDataTree->resizeColumnToContents(2);





    mHistorienDataTree->resize(750,750);


    mRefreshTimer = new QTimer();
    mRefreshTimer->setSingleShot(false);
    mRefreshTimer->setInterval(500);
    mRefreshTimer->stop();
    connect(mRefreshTimer,SIGNAL(timeout()),this,SLOT(RefreshTimerExpired()));
}

void CHistorienDisplayPage::UpdateHistorienTable()
{
    if(mHistorienRepoHandle == 0)
        return;

    CHistorienData NewData;
    bool OK;
    mHistorienRepoHandle->GetSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,&OK);

    NewData.mFNEnabled = 0;
    NewData.mPPEnabled = 0;
    NewData.mPGEnabled = 0;
    NewData.mPPZT2Enabled = 0;
    NewData.mMaintenanceMode = 0;
    NewData.mHPCHealth = 0;
    NewData.mSEIHealth = 0;
    NewData.mZT1Enabled = 0;
    NewData.mZT2Enabled = 0;
    NewData.mCalibPG = 0;



    quint16 reg = mHistorienRepoHandle->GetSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,&OK);
    NewData.mFNEnabled = ((reg & HISTORIAN_ZT1_FN_ENABLED_FLAG_MASK) != 0);
    NewData.mPPEnabled = ((reg & HISTORIAN_ZT1_PP_ENABLED_FLAG_MASK) != 0);
    NewData.mPGEnabled = ((reg & HISTORIAN_ZT1_PG_ENABLED_FLAG_MASK) != 0);
    NewData.mPPZT2Enabled = ((reg & HISTORIAN_ZT2_PP_ENABLED_FLAG_MASK) != 0);
    NewData.mMaintenanceMode = ((reg & HISTORIAN_ZT_MAINTENANCE_MODE_FLAG_MASK) != 0);
    NewData.mHPCHealth = ((reg & HISTORIAN_ZT_HPC_COMM_HEALTH_FLAG_MASK) != 0);
    NewData.mSEIHealth = ((reg & HISTORIAN_ZT_SEI_COMM_FLAG_MASK) != 0);
    NewData.mZT1Enabled = ((reg & HISTORIAN_ZT_ZT1_ENABLED_FLAG_MASK) != 0);
    NewData.mZT2Enabled = ((reg & HISTORIAN_ZT_ZT2_ENABLED_FLAG_MASK) != 0);
    NewData.mCalibPG = ((reg & HISTORIAN_PG_CALIBRATION_REG_ADD) != 0);



    NewData.mBootDateYr = mHistorienRepoHandle->GetSingleReg(HISTORIAN_BOOT_DATE_YEAR_REG_ADD,&OK);
    NewData.mBootDateMonth = mHistorienRepoHandle->GetSingleReg(HISTORIAN_BOOT_DATE_MONTH_REG_ADD,&OK);
    NewData.mBootDateDay = mHistorienRepoHandle->GetSingleReg(HISTORIAN_BOOT_DATE_DAY_REG_ADD,&OK);
    NewData.mBootDateHour = mHistorienRepoHandle->GetSingleReg(HISTORIAN_BOOT_DATE_HOUR_REG_ADD,&OK);
    NewData.mBootDateMinutes = mHistorienRepoHandle->GetSingleReg(HISTORIAN_BOOT_DATE_MINUTES_REG_ADD,&OK);
    NewData.mBootDateSeconds = mHistorienRepoHandle->GetSingleReg(HISTORIAN_BOOT_DATE_SECONDS_REG_ADD,&OK);
    NewData.mTotalTrains = mHistorienRepoHandle->GetSingleReg(HISTORIAN_TRAINS_TOTAL_REG_ADD,&OK);
    NewData.mTotalDetections = mHistorienRepoHandle->GetSingleReg(HISTORIAN_DETECTIONS_TOTAL_REG_ADD,&OK);
    NewData.mTrainsToday = mHistorienRepoHandle->GetSingleReg(HISTORIAN_TRAINS_TODAY_REG_ADD ,&OK);
    NewData.mDetectToday = mHistorienRepoHandle->GetSingleReg(HISTORIAN_DETECTIONS_TODAY_REG_ADD ,&OK);
    NewData.mFNDetectToday = mHistorienRepoHandle->GetSingleReg(HISTORIAN_FN_DETECTS_TODAY_REG_ADD,&OK);
    NewData.mPPIDetectToday = mHistorienRepoHandle->GetSingleReg(HISTORIAN_PPI_ZT1_DETECTS_TODAY_REG_ADD,&OK);
    NewData.mPPEDetectToday = mHistorienRepoHandle->GetSingleReg(HISTORIAN_PPE_ZT1_DETECTS_TODAY_REG_ADD,&OK);
    NewData.mPGDetectToday = mHistorienRepoHandle->GetSingleReg(HISTORIAN_PG_DETECTS_TODAY_REG_ADD,&OK);
    NewData.mPPIZT2DetectToday = mHistorienRepoHandle->GetSingleReg(HISTORIAN_PPI_ZT2_DETECTS_TODAY_REG_ADD,&OK);
    NewData.mPPEZT2DetectToday = mHistorienRepoHandle->GetSingleReg(HISTORIAN_PPE_ZT2_DETECTS_TODAY_REG_ADD,&OK);
    NewData.mLastTrainYear = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_YEAR_REG_ADD,&OK);
    NewData.mLastTrainMonth = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_MONTH_REG_ADD,&OK);
    NewData.mLastTrainDay = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_DAY_REG_ADD,&OK);
    NewData.mLastTrainHour = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_HOUR_REG_ADD,&OK);
    NewData.mLastTrainMinutes = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_MINUTE_REG_ADD,&OK);
    NewData.mLastTrainSeconds = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_SECONDS_REG_ADD,&OK);
    NewData.mLastZone = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_ZONE_REG_ADD ,&OK);
    NewData.mNbDetectLasTrain = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_NB_DETECTS_REG_ADD ,&OK);
    NewData.mLastTrainPPI1 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PPI_RK_1_REG_ADD,&OK);
    NewData.mLastTrainPPI2 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PPI_RK_2_REG_ADD,&OK);
    NewData.mLastTrainPPI3 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PPI_RK_3_REG_ADD,&OK);
    NewData.mLastTrainPPI4 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PPI_RK_4_REG_ADD,&OK);
    NewData.mLastTrainPPE1 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PPE_RK_1_REG_ADD,&OK);
    NewData.mLastTrainPPE2 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PPE_RK_2_REG_ADD,&OK);
    NewData.mLastTrainPPE3 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PPE_RK_3_REG_ADD,&OK);
    NewData.mLastTrainPPE4 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PPE_RK_4_REG_ADD,&OK);
    NewData.mLastTrainPG1 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PG_RK_1_REG_ADD,&OK);
    NewData.mLastTrainPG2 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PG_RK_2_REG_ADD,&OK);
    NewData.mLastTrainPG3 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PG_RK_3_REG_ADD,&OK);
    NewData.mLastTrainPG4 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PG_RK_4_REG_ADD,&OK);
    NewData.mLastTrainFN1 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_FN_RK_1_REG_ADD,&OK);
    NewData.mLastTrainFN2 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_FN_RK_2_REG_ADD,&OK);
    NewData.mLastTrainFN3 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_FN_RK_3_REG_ADD,&OK);
    NewData.mLastTrainFN4 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_FN_RK_4_REG_ADD,&OK);
    NewData.mLastTrainCountErr = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_COMPTAGE_DET_REG_ADD,&OK);
    NewData.mLastTrainPEQ = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_PEQ_REG_ADD,&OK);
    NewData.mLastTrainType = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_TYPE_REG_ADD,&OK);
    NewData.mLastTrainCompo1 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_ID1_REG_ADD,&OK);
    NewData.mLastTrainCompo2 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_ID2_REG_ADD,&OK);
    NewData.mLastTrainCompo3 = mHistorienRepoHandle->GetSingleReg(HISTORIAN_LAST_TRAIN_ID3_REG_ADD,&OK);



    QTreeWidgetItem* Item = mHistorienDataTree->topLevelItem(0);

    Item->child(0)->setText(2,QString("%1").arg(NewData.mFNEnabled));
    Item->child(1)->setText(2,QString("%1").arg(NewData.mPPEnabled));
    Item->child(2)->setText(2,QString("%1").arg(NewData.mPGEnabled));
    Item->child(3)->setText(2,QString("%1").arg(NewData.mPPZT2Enabled));
    Item->child(4)->setText(2,QString("%1").arg(NewData.mMaintenanceMode));
    Item->child(5)->setText(2,QString("%1").arg(NewData.mHPCHealth));
    Item->child(6)->setText(2,QString("%1").arg(NewData.mSEIHealth));
    Item->child(7)->setText(2,QString("%1").arg(NewData.mZT1Enabled));
    Item->child(8)->setText(2,QString("%1").arg(NewData.mZT2Enabled));
    Item->child(9)->setText(2,QString("%1").arg(NewData.mCalibPG));
    Item->child(10)->setText(2,QString("%1").arg(NewData.mBootDateYr));
    Item->child(11)->setText(2,QString("%1").arg(NewData.mBootDateMonth));
    Item->child(12)->setText(2,QString("%1").arg(NewData.mBootDateDay));
    Item->child(13)->setText(2,QString("%1").arg(NewData.mBootDateHour));
    Item->child(14)->setText(2,QString("%1").arg(NewData.mBootDateMinutes));
    Item->child(15)->setText(2,QString("%1").arg(NewData.mBootDateSeconds));
    Item->child(16)->setText(2,QString("%1").arg(NewData.mTotalTrains));
    Item->child(17)->setText(2,QString("%1").arg(NewData.mTotalDetections));
    Item->child(18)->setText(2,QString("%1").arg(NewData.mTrainsToday));
    Item->child(19)->setText(2,QString("%1").arg(NewData.mDetectToday));
    Item->child(20)->setText(2,QString("%1").arg(NewData.mFNDetectToday));
    Item->child(21)->setText(2,QString("%1").arg(NewData.mPPIDetectToday));
    Item->child(22)->setText(2,QString("%1").arg(NewData.mPPEDetectToday));
    Item->child(23)->setText(2,QString("%1").arg(NewData.mPGDetectToday));
    Item->child(24)->setText(2,QString("%1").arg(NewData.mPPIZT2DetectToday));
    Item->child(25)->setText(2,QString("%1").arg(NewData.mPPEZT2DetectToday));
    Item->child(26)->setText(2,QString("%1").arg(NewData.mLastTrainYear));
    Item->child(27)->setText(2,QString("%1").arg(NewData.mLastTrainMonth));
    Item->child(28)->setText(2,QString("%1").arg(NewData.mLastTrainDay));
    Item->child(29)->setText(2,QString("%1").arg(NewData.mLastTrainHour));
    Item->child(30)->setText(2,QString("%1").arg(NewData.mLastTrainMinutes));
    Item->child(31)->setText(2,QString("%1").arg(NewData.mLastTrainSeconds));
    Item->child(32)->setText(2,QString("%1").arg(NewData.mLastZone));
    Item->child(33)->setText(2,QString("%1").arg(NewData.mNbDetectLasTrain));
    Item->child(34)->setText(2,QString("%1").arg(NewData.mLastTrainPPI1));
    Item->child(35)->setText(2,QString("%1").arg(NewData.mLastTrainPPI2));
    Item->child(36)->setText(2,QString("%1").arg(NewData.mLastTrainPPI3));
    Item->child(37)->setText(2,QString("%1").arg(NewData.mLastTrainPPI4));
    Item->child(38)->setText(2,QString("%1").arg(NewData.mLastTrainPPE1));
    Item->child(39)->setText(2,QString("%1").arg(NewData.mLastTrainPPE2));
    Item->child(40)->setText(2,QString("%1").arg(NewData.mLastTrainPPE3));
    Item->child(41)->setText(2,QString("%1").arg(NewData.mLastTrainPPE4));
    Item->child(42)->setText(2,QString("%1").arg(NewData.mLastTrainPG1));
    Item->child(43)->setText(2,QString("%1").arg(NewData.mLastTrainPG2));
    Item->child(44)->setText(2,QString("%1").arg(NewData.mLastTrainPG3));
    Item->child(45)->setText(2,QString("%1").arg(NewData.mLastTrainPG4));
    Item->child(46)->setText(2,QString("%1").arg(NewData.mLastTrainFN1));
    Item->child(47)->setText(2,QString("%1").arg(NewData.mLastTrainFN2));
    Item->child(48)->setText(2,QString("%1").arg(NewData.mLastTrainFN3));
    Item->child(49)->setText(2,QString("%1").arg(NewData.mLastTrainFN4));
    Item->child(50)->setText(2,QString("%1").arg(NewData.mLastTrainCountErr));
    Item->child(51)->setText(2,QString("%1").arg(NewData.mLastTrainPEQ));
    Item->child(52)->setText(2,QString("%1").arg(NewData.mLastTrainType));
    Item->child(53)->setText(2,QString("%1").arg(NewData.mLastTrainCompo1));
    Item->child(54)->setText(2,QString("%1").arg(NewData.mLastTrainCompo2));
    Item->child(55)->setText(2,QString("%1").arg(NewData.mLastTrainCompo3));
}

void CHistorienDisplayPage::ButtonClicked(CTextButtonWidget *)
{

}

void CHistorienDisplayPage::RefreshTimerExpired()
{
    UpdateHistorienTable();
}

void CHistorienDisplayPage::showEvent(QShowEvent *event)
{
    if(mHistorienRepoHandle == 0 ||
       mProgramHandle == 0)
    {
        return;
    }


    mRefreshTimer->start();
}

void CHistorienDisplayPage::HideHistorienPage()
{
    mRefreshTimer->stop();
    this->hide();
}

void CHistorienDisplayPage::resizeEvent(QGraphicsSceneResizeEvent *event)
{
    Q_UNUSED(event)
    mBackgroundRect->setRect(boundingRect());
    mHistorienDataTree->setGeometry(0,50,((boundingRect().width()) - 10),boundingRect().height()-100);

}
