Continue dev -> train info from modbus
This commit is contained in:
@@ -25,74 +25,99 @@
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "ZT1StatsZone.h"
|
||||
|
||||
|
||||
CZT1StatsZone::CZT1StatsZone(QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
|
||||
QFont font;
|
||||
//font.setPixelSize(15);
|
||||
font.setPointSize(15);
|
||||
mTrainCompositionText = 0;
|
||||
|
||||
mTrainSpeedText = new QGraphicsTextItem(this);
|
||||
mTrainSpeedText->setPos(0,12);
|
||||
mModbusEnabled = false;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
unsigned int CZT1StatsZone::Init(bool ModbusEnabled)
|
||||
{
|
||||
mModbusEnabled = ModbusEnabled;
|
||||
int textpos = 12;
|
||||
QFont font;
|
||||
font.setPointSize(15);
|
||||
|
||||
mTrainSpeedText = new QGraphicsTextItem(this);
|
||||
mTrainSpeedText->setPos(0,textpos);
|
||||
// mTrainSpeedText->setPlainText("Vitesse du train: 0");
|
||||
mTrainSpeedText->setFont(font);
|
||||
mTrainSpeedText->setFont(font);
|
||||
|
||||
mBogieCountText = new QGraphicsTextItem(this);
|
||||
mBogieCountText->setPos(0,34);
|
||||
textpos += 22;
|
||||
mBogieCountText = new QGraphicsTextItem(this);
|
||||
mBogieCountText->setPos(0,textpos);
|
||||
// mBogieCountText->setPlainText("Compte Bogie: 0");
|
||||
mBogieCountText->setFont(font);
|
||||
mBogieCountText->setFont(font);
|
||||
|
||||
mS1CountText = new QGraphicsTextItem(this);
|
||||
mS1CountText->setPos(0,56);
|
||||
textpos += 22;
|
||||
mS1CountText = new QGraphicsTextItem(this);
|
||||
mS1CountText->setPos(0,textpos);
|
||||
// mS1CountText->setPlainText("Compte S1: 0");
|
||||
mS1CountText->setFont(font);
|
||||
mS1CountText->setFont(font);
|
||||
|
||||
mS2CountText = new QGraphicsTextItem(this);
|
||||
mS2CountText->setPos(0,78);
|
||||
textpos += 22;
|
||||
mS2CountText = new QGraphicsTextItem(this);
|
||||
mS2CountText->setPos(0,textpos);
|
||||
// mS2CountText->setPlainText("Compte S2: 0");
|
||||
mS2CountText->setFont(font);
|
||||
mS2CountText->setFont(font);
|
||||
|
||||
mFNCountText = new QGraphicsTextItem(this);
|
||||
mFNCountText->setPos(0,100);
|
||||
textpos += 22;
|
||||
mFNCountText = new QGraphicsTextItem(this);
|
||||
mFNCountText->setPos(0,textpos);
|
||||
// mFNCountText->setPlainText("Compte FN: 0");
|
||||
mFNCountText->setFont(font);
|
||||
mFNCountText->setFont(font);
|
||||
|
||||
mActualRankText = new QGraphicsTextItem(this);
|
||||
mActualRankText->setPos(0,122);
|
||||
textpos += 22;
|
||||
mActualRankText = new QGraphicsTextItem(this);
|
||||
mActualRankText->setPos(0,textpos);
|
||||
// mActualRankText->setPlainText("Rang: 0");
|
||||
mActualRankText->setFont(font);
|
||||
mActualRankText->setFont(font);
|
||||
|
||||
mTrainTypeText = new QGraphicsTextItem(this);
|
||||
mTrainTypeText->setPos(0,144);
|
||||
textpos += 22;
|
||||
mTrainTypeText = new QGraphicsTextItem(this);
|
||||
mTrainTypeText->setPos(0,textpos);
|
||||
// mTrainTypeText->setPlainText("Train Détecté: Aucun");
|
||||
mTrainTypeText->setFont(font);
|
||||
mTrainTypeText->setFont(font);
|
||||
|
||||
if(mModbusEnabled == true)
|
||||
{
|
||||
textpos += 22;
|
||||
mTrainCompositionText = new QGraphicsTextItem(this);
|
||||
mTrainCompositionText->setPos(0,textpos);
|
||||
mTrainCompositionText->setFont(font);
|
||||
}
|
||||
|
||||
textpos += 22;
|
||||
mPIValueText = new QGraphicsTextItem(this);
|
||||
mPIValueText->setPos(0,166);
|
||||
mPIValueText->setPos(0,textpos);
|
||||
// mTrainTypeText->setPlainText("Train Détecté: Aucun");
|
||||
mPIValueText->setFont(font);
|
||||
|
||||
textpos += 22;
|
||||
mPEValueText = new QGraphicsTextItem(this);
|
||||
mPEValueText->setPos(0,188);
|
||||
mPEValueText->setPos(0,textpos);
|
||||
// mTrainTypeText->setPlainText("Train Détecté: Aucun");
|
||||
mPEValueText->setFont(font);
|
||||
|
||||
|
||||
mLastActivationDateTime = new QGraphicsTextItem(this);
|
||||
mLastActivationDateTime->setPos(0,210);
|
||||
mLastActivationDateTime->setFont(font);
|
||||
mLastActivationDateTime->setPlainText("Dernier passage : ");
|
||||
textpos += 22;
|
||||
mLastActivationDateTime = new QGraphicsTextItem(this);
|
||||
mLastActivationDateTime->setPos(0,textpos);
|
||||
mLastActivationDateTime->setFont(font);
|
||||
mLastActivationDateTime->setPlainText("Dernier passage : ");
|
||||
|
||||
Reset();
|
||||
Reset();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZT1StatsZone::UpdateStats(CZT1ThreadData *DataPtr)
|
||||
@@ -148,14 +173,17 @@ unsigned int CZT1StatsZone::UpdateStats(CZT1ThreadData *DataPtr)
|
||||
mTrainSpeedText->setPlainText(temp);
|
||||
}
|
||||
|
||||
if(mTrainType != DataPtr->mTrainType)
|
||||
{
|
||||
mTrainType = DataPtr->mTrainType;
|
||||
temp.clear();
|
||||
temp = "Train détecté: ";
|
||||
temp += CZTData::GetTrainTypeString(mTrainType);
|
||||
mTrainTypeText->setPlainText(temp);
|
||||
}
|
||||
if(mModbusEnabled == false)
|
||||
{
|
||||
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;
|
||||
@@ -201,8 +229,43 @@ unsigned int CZT1StatsZone::Reset()
|
||||
mFNCountText->setPlainText("Compte FN: 0");
|
||||
mActualRankText->setPlainText("Rang: 0");
|
||||
mTrainTypeText->setPlainText("Train Détecté: Aucun");
|
||||
if(mTrainCompositionText != 0)
|
||||
{
|
||||
mTrainCompositionText->setPlainText("Composition : Inconnue");
|
||||
}
|
||||
mPIValueText->setPlainText("Pneu Guidage Int.: ?");
|
||||
mPEValueText->setPlainText("Pneu Guidage Ext.: ?");
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZT1StatsZone::SetTrainParameters(int TrainType, QList<qint16> TrainComposition)
|
||||
{
|
||||
if(mTrainType != (unsigned)TrainType)
|
||||
{
|
||||
mTrainType = TrainType;
|
||||
// temp.clear();
|
||||
// temp = "Train détecté: ";
|
||||
// temp += CZTData::GetTrainTypeString(mTrainType);
|
||||
mTrainTypeText->setPlainText(QString("Train détecté : %1").arg(CZTData::GetTrainTypeString(mTrainType)));
|
||||
}
|
||||
|
||||
if(TrainComposition.size() != 3)
|
||||
{
|
||||
//Invalid composition
|
||||
mTrainCompositionText->setPlainText("Composition: Inconnue");
|
||||
}
|
||||
else if((TrainComposition[0] == 0) ||
|
||||
(TrainComposition[1] == 0) ||
|
||||
(TrainComposition[2] == 0))
|
||||
{
|
||||
//Composition invalide...
|
||||
mTrainCompositionText->setPlainText("Composition: Inconnue");
|
||||
}
|
||||
else
|
||||
{
|
||||
mTrainCompositionText->setPlainText(QString("Composition : %1-%2-%3").arg(TrainComposition[0]).arg(TrainComposition[1]).arg(TrainComposition[2]));
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <QGraphicsWidget>
|
||||
#include <QGraphicsTextItem>
|
||||
#include "ZTData.h"
|
||||
#include <QList>
|
||||
|
||||
class CZT1StatsZone : public QGraphicsWidget
|
||||
{
|
||||
@@ -40,15 +41,18 @@ public:
|
||||
|
||||
// unsigned int UpdateStats(unsigned int BogieCount, unsigned int S1Count, unsigned int S2Count, unsigned int FNCount, unsigned int Rank, unsigned int Bogie, unsigned int TrainType, float TrainSpeed);
|
||||
unsigned int UpdateStats(CZT1ThreadData *DataPtr);
|
||||
unsigned int SetTrainParameters(int TrainType, QList<qint16> TrainComposition);
|
||||
unsigned int Reset();
|
||||
unsigned int SetLastActivationDateTime();
|
||||
unsigned int Init(bool ModbusEnabled);
|
||||
|
||||
private:
|
||||
unsigned int mBogieCount,mS1Count,mS2Count,mFNCount,mActualRank,mActualBogie,mTrainType;
|
||||
float mTrainSpeed;
|
||||
int mPIValue, mPEValue;
|
||||
bool mModbusEnabled;
|
||||
|
||||
QGraphicsTextItem *mTrainSpeedText, *mBogieCountText, *mS1CountText, *mS2CountText, *mFNCountText, *mActualRankText, *mActualBogieText, *mTrainTypeText, *mPIValueText, *mPEValueText, *mLastActivationDateTime;
|
||||
QGraphicsTextItem *mTrainSpeedText, *mBogieCountText, *mS1CountText, *mS2CountText, *mFNCountText, *mActualRankText, *mActualBogieText, *mTrainTypeText, *mTrainCompositionText, *mPIValueText, *mPEValueText, *mLastActivationDateTime;
|
||||
};
|
||||
|
||||
#endif // ZT1STATSZONE_H
|
||||
|
||||
@@ -341,6 +341,13 @@ unsigned int CZTPage::SetZT1Data(CZT1ThreadData *Data, bool ForceDisplay)
|
||||
|
||||
}
|
||||
|
||||
unsigned int CZTPage::SetZT1TrainData(int TrainType, QList<qint16> TrainComposition)
|
||||
{
|
||||
//This is a low frequency stats update (only once for every train), so no timer filtering is necessary.
|
||||
mZT1Stats->SetTrainParameters(TrainType,TrainComposition);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZTPage::SetZT2Data(CZT2ThreadData *Data)
|
||||
{
|
||||
if(Data == 0)
|
||||
|
||||
@@ -55,6 +55,8 @@ public:
|
||||
CZTPage(QGraphicsWidget *Parent = 0);
|
||||
CPushButton *mToolsPushButton;
|
||||
CPushButton *mZTLogPushButton;
|
||||
CZT1StatsZone *mZT1Stats;
|
||||
CZT2StatsZone *mZT2Stats;
|
||||
|
||||
|
||||
CZoneTest *mProgramHandle;
|
||||
@@ -67,6 +69,7 @@ public:
|
||||
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 SetZT1ActivationState(bool ZT1Activated);
|
||||
unsigned int SetZT2ActivationSTate(bool ZT2Activated);
|
||||
@@ -86,8 +89,7 @@ private:
|
||||
CStatusBar *mStatusBar;
|
||||
CZT1EquipmentWidget *mZT1EquipmentWidget;
|
||||
CZT2EquipmentWidget *mZT2EquipmentWidget;
|
||||
CZT1StatsZone *mZT1Stats;
|
||||
CZT2StatsZone *mZT2Stats;
|
||||
|
||||
CEventsBar *mEventsBar;
|
||||
QElapsedTimer mZT1DisplayTimer;
|
||||
bool mIsZT2Present;
|
||||
|
||||
Reference in New Issue
Block a user