209 lines
5.7 KiB
C++
209 lines
5.7 KiB
C++
/*******************************************************************************
|
|
* *
|
|
* Société de Transports de Montréal. *
|
|
* 2012 - 2013 *
|
|
* *
|
|
* Projet Zones Tests *
|
|
* *
|
|
* *
|
|
* *
|
|
*******************************************************************************/
|
|
/*
|
|
Description:
|
|
Zone de texte qui affiche les statistiques de passage d'un train dans la ZT1
|
|
|
|
*/
|
|
|
|
/* ************************************************************************** */
|
|
/* Revision:
|
|
### YYYMMDD JFM
|
|
Verision d'origine.
|
|
|
|
### YYYYMMDD Description du besoin ou du bug
|
|
Description du changement.
|
|
*/
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "ZT1StatsZone.h"
|
|
|
|
CZT1StatsZone::CZT1StatsZone(QGraphicsItem *Parent)
|
|
{
|
|
setParentItem(Parent);
|
|
|
|
QFont font;
|
|
//font.setPixelSize(15);
|
|
font.setPointSize(15);
|
|
|
|
mTrainSpeedText = new QGraphicsTextItem(this);
|
|
mTrainSpeedText->setPos(0,12);
|
|
// mTrainSpeedText->setPlainText("Vitesse du train: 0");
|
|
mTrainSpeedText->setFont(font);
|
|
|
|
mBogieCountText = new QGraphicsTextItem(this);
|
|
mBogieCountText->setPos(0,34);
|
|
// mBogieCountText->setPlainText("Compte Bogie: 0");
|
|
mBogieCountText->setFont(font);
|
|
|
|
mS1CountText = new QGraphicsTextItem(this);
|
|
mS1CountText->setPos(0,56);
|
|
// mS1CountText->setPlainText("Compte S1: 0");
|
|
mS1CountText->setFont(font);
|
|
|
|
mS2CountText = new QGraphicsTextItem(this);
|
|
mS2CountText->setPos(0,78);
|
|
// mS2CountText->setPlainText("Compte S2: 0");
|
|
mS2CountText->setFont(font);
|
|
|
|
mFNCountText = new QGraphicsTextItem(this);
|
|
mFNCountText->setPos(0,100);
|
|
// mFNCountText->setPlainText("Compte FN: 0");
|
|
mFNCountText->setFont(font);
|
|
|
|
mActualRankText = new QGraphicsTextItem(this);
|
|
mActualRankText->setPos(0,122);
|
|
// mActualRankText->setPlainText("Rang: 0");
|
|
mActualRankText->setFont(font);
|
|
|
|
mTrainTypeText = new QGraphicsTextItem(this);
|
|
mTrainTypeText->setPos(0,144);
|
|
// mTrainTypeText->setPlainText("Train Détecté: Aucun");
|
|
mTrainTypeText->setFont(font);
|
|
|
|
mPIValueText = new QGraphicsTextItem(this);
|
|
mPIValueText->setPos(0,166);
|
|
// mTrainTypeText->setPlainText("Train Détecté: Aucun");
|
|
mPIValueText->setFont(font);
|
|
|
|
mPEValueText = new QGraphicsTextItem(this);
|
|
mPEValueText->setPos(0,188);
|
|
// mTrainTypeText->setPlainText("Train Détecté: Aucun");
|
|
mPEValueText->setFont(font);
|
|
|
|
|
|
mLastActivationDateTime = new QGraphicsTextItem(this);
|
|
mLastActivationDateTime->setPos(0,210);
|
|
mLastActivationDateTime->setFont(font);
|
|
mLastActivationDateTime->setPlainText("Dernier passage : ");
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
unsigned int CZT1StatsZone::UpdateStats(CZT1ThreadData *DataPtr)
|
|
{
|
|
QString temp;
|
|
|
|
if(mBogieCount != DataPtr->mBogie)
|
|
{
|
|
mBogieCount = DataPtr->mBogie;
|
|
temp.clear();
|
|
temp.sprintf("Compte Bogie: %d",mBogieCount);
|
|
mBogieCountText->setPlainText(temp);
|
|
}
|
|
|
|
if(mS1Count != DataPtr->mS1Count)
|
|
{
|
|
mS1Count = DataPtr->mS1Count;
|
|
temp.clear();
|
|
temp.sprintf("Compte S1: %d",mS1Count);
|
|
mS1CountText->setPlainText(temp);
|
|
}
|
|
|
|
if(mS2Count != DataPtr->mS2Count)
|
|
{
|
|
mS2Count = DataPtr->mS2Count;
|
|
temp.clear();
|
|
temp.sprintf("Compte S2: %d",mS2Count);
|
|
mS2CountText->setPlainText(temp);
|
|
}
|
|
|
|
if(mFNCount != DataPtr->mFNCount)
|
|
{
|
|
mFNCount = DataPtr->mFNCount;
|
|
temp.clear();
|
|
temp.sprintf("Compte FN: %d",mFNCount);
|
|
mFNCountText->setPlainText(temp);
|
|
}
|
|
|
|
if(mActualRank != DataPtr->mRank)
|
|
{
|
|
mActualRank = DataPtr->mRank;
|
|
temp.clear();
|
|
temp.sprintf("Rang: %d",mActualRank);
|
|
mActualRankText->setPlainText(temp);
|
|
}
|
|
|
|
|
|
if(mTrainSpeed != DataPtr->mTrainSpeed)
|
|
{
|
|
mTrainSpeed = DataPtr->mTrainSpeed;
|
|
temp.clear();
|
|
temp.sprintf("Vitesse du train: %.2f Mph",mTrainSpeed);
|
|
mTrainSpeedText->setPlainText(temp);
|
|
}
|
|
|
|
if(mTrainType != DataPtr->mTrainType)
|
|
{
|
|
mTrainType = DataPtr->mTrainType;
|
|
temp.clear();
|
|
temp = "Train détecté: ";
|
|
temp += CZTData::GetTrainTypeString(mTrainType);
|
|
mTrainTypeText->setPlainText(temp);
|
|
}
|
|
if(mPIValue != DataPtr->mPGIntValue)
|
|
{
|
|
mPIValue = DataPtr->mPGIntValue;
|
|
temp.clear();
|
|
temp = "Train détecté: ";
|
|
temp.sprintf("Pneu Guidage Int.: %i",mPIValue);
|
|
mPIValueText->setPlainText(temp);
|
|
}
|
|
if(mPEValue != DataPtr->mPGExtValue)
|
|
{
|
|
mPEValue = DataPtr->mPGExtValue;
|
|
temp.clear();
|
|
temp = "Train détecté: ";
|
|
temp.sprintf("Pneu Guidage Ext.: %i",mPEValue);
|
|
mPEValueText->setPlainText(temp);
|
|
}
|
|
|
|
|
|
return RET_OK;
|
|
|
|
|
|
}
|
|
|
|
unsigned int CZT1StatsZone::SetLastActivationDateTime()
|
|
{
|
|
QString txt = "Dernier passage: ";
|
|
txt += QDateTime::currentDateTime().toString("yyyy/MM/dd - hh:mm:ss");
|
|
mLastActivationDateTime->setPlainText(txt);
|
|
return RET_OK;
|
|
}
|
|
|
|
unsigned int CZT1StatsZone::Reset()
|
|
{
|
|
mBogieCount = mS1Count = mS2Count = mFNCount = mActualRank = mActualBogie = mTrainType = 0;
|
|
mTrainSpeed = 0.0;
|
|
mPEValue = 0;
|
|
mPIValue = 0;
|
|
|
|
mTrainSpeedText->setPlainText("Vitesse du train: 0");
|
|
mBogieCountText->setPlainText("Compte Bogie: 0");
|
|
mS1CountText->setPlainText("Compte S1: 0");
|
|
mS2CountText->setPlainText("Compte S2: 0");
|
|
mFNCountText->setPlainText("Compte FN: 0");
|
|
mActualRankText->setPlainText("Rang: 0");
|
|
mTrainTypeText->setPlainText("Train Détecté: Aucun");
|
|
mPIValueText->setPlainText("Pneu Guidage Int.: ?");
|
|
mPEValueText->setPlainText("Pneu Guidage Ext.: ?");
|
|
|
|
return RET_OK;
|
|
}
|