Merge branch 'Historien_PI'

# Conflicts:
#	sftpbatch
#	sources/ZTVersion.h
This commit is contained in:
jfmartel 2024-07-08 07:33:31 -04:00
commit 3392348ede
20 changed files with 1234 additions and 112 deletions

View File

@ -63,6 +63,18 @@ MODBUS_SEI_DEVID=1
#Port Modbus/TCP
MODBUS_SEI_PORT=502
#----------------------------------
#Paramètres de communication Modbus avec le SEI (Serveur NetTrac).
#Changer cette valeur à OUI, NON ou AUTO pour activer la communication Modbus l'historienPI.
# OUI: Active la communication avec l'historien.
# NON: Désactive la communication avec l'historien.
ACTIVER_HISTORIEN_PI=OUI
#Adresse modbus de la ZT
HISTORIEN_PI_DEVID=1
#Port Modbus/TCP du serveur historien
HISTORIEN_PI_PORT=2183
#----------------------------------
#Changer cette valeur à OUI ou NON pour activer le
SIMULATEUR=OUI

7
ZT.pro
View File

@ -123,7 +123,8 @@ SOURCES += \
sources/GuiElements/ModbusDisplayPage.cpp \
sources/NetDriveMgr.cpp \
sources/SFTPServerManager.cpp \
sources/PIHistorianManager.cpp
sources/Modbus/PIHistorianManager.cpp \
sources/Modbus/PIHistorianSession.cpp
HEADERS += \
sources/MainPanel.h \
@ -247,7 +248,9 @@ HEADERS += \
sources/GuiElements/ModbusDisplayPage.h \
sources/NetDriveMgr.h \
sources/SFTPServerManager.h \
sources/PIHistorianManager.h
sources/Modbus/PIHistorianManager.h \
sources/Modbus/PIHistorianSession.h \
sources/Modbus/PIHistorianDefs.h
#QMAKE_LIBDIR += ./ExtLib

View File

@ -1,3 +1,3 @@
put ./Trains/LOGZT1_2024-06-14-14-16-29-560.bin CVRT-D-LOGZT1_2024-06-14-14-16-29-560.bin
put ./Trains/LOGZT1_2024-06-04-10-54-27-273.bin CVRT-D-LOGZT1_2024-06-04-10-54-27-273.bin
put ./LOG/LogZT.txt CVRT-LogZT.txt
put ./ING/IngLog.txt CVRT-IngLog.txt

7
sftpbatch.orig Normal file
View File

@ -0,0 +1,7 @@
<<<<<<< HEAD
put ./Trains/LOGZT1_2024-06-14-14-16-29-560.bin CVRT-D-LOGZT1_2024-06-14-14-16-29-560.bin
=======
put ./Trains/LOGZT1_2024-07-04-15-45-02-320.bin CVRT-D-LOGZT1_2024-07-04-15-45-02-320.bin
>>>>>>> Historien_PI
put ./LOG/LogZT.txt CVRT-LogZT.txt
put ./ING/IngLog.txt CVRT-IngLog.txt

View File

@ -0,0 +1,83 @@
#ifndef PIHISTORIANDEFS_H
#define PIHISTORIANDEFS_H
#define HISTORIAN_WATCHDOG_TIMEOUT 3000
//PI HISTORIAN modbus table masks
#define HISTORIAN_ZT_DATA_BASE_REG 2000
#define HISTORIAN_MODBUS_ZT_TABLE_DATA_SIZE 50 //Taille de la table = 50 registres (2000 à 2049)
//Flags definitions for HR2000
#define HISTORIAN_ZT1_FN_ENABLED_FLAG_MASK 0x0001
#define HISTORIAN_ZT1_PP_ENABLED_FLAG_MASK 0x0002
#define HISTORIAN_ZT1_PG_ENABLED_FLAG_MASK 0x0004
#define HISTORIAN_ZT2_PP_ENABLED_FLAG_MASK 0x0008
#define HISTORIAN_ZT_MAINTENANCE_MODE_FLAG_MASK 0x0010
#define HISTORIAN_ZT_HPC_COMM_HEALTH_FLAG_MASK 0x0020
#define HISTORIAN_ZT_SEI_COMM_FLAG_MASK 0x0040
#define HISTORIAN_ZT_ZT1_ENABLED_FLAG_MASK 0x0080
#define HISTORIAN_ZT_ZT2_ENABLED_FLAG_MASK 0x0100
#define HISTORIAN_ZT_RESERVED_FLAG_MASK_7 0x0200
#define HISTORIAN_ZT_RESERVED_FLAG_MASK_6 0x0400
#define HISTORIAN_ZT_RESERVED_FLAG_MASK_5 0x0800
#define HISTORIAN_ZT_RESERVED_FLAG_MASK_4 0x1000
#define HISTORIAN_ZT_RESERVED_FLAG_MASK_3 0x2000
#define HISTORIAN_ZT_RESERVED_FLAG_MASK_2 0x4000
#define HISTORIAN_ZT_RESERVED_FLAG_MASK_1 0x8000
#define HISTORIAN_ZT_STATUS_FLAGS_REG_ADD 2000
#define HISTORIAN_PG_CALIBRATION_REG_ADD 2001
#define HISTORIAN_BOOT_DATE_YEAR_REG_ADD 2002
#define HISTORIAN_BOOT_DATE_MONTH_REG_ADD 2003
#define HISTORIAN_BOOT_DATE_DAY_REG_ADD 2004
#define HISTORIAN_BOOT_DATE_HOUR_REG_ADD 2005
#define HISTORIAN_BOOT_DATE_MINUTES_REG_ADD 2006
#define HISTORIAN_BOOT_DATE_SECONDS_REG_ADD 2007
#define HISTORIAN_TRAINS_TOTAL_REG_ADD 2008
#define HISTORIAN_DETECTIONS_TOTAL_REG_ADD 2009
#define HISTORIAN_TRAINS_TODAY_REG_ADD 2010
#define HISTORIAN_DETECTIONS_TODAY_REG_ADD 2011
#define HISTORIAN_FN_DETECTS_TODAY_REG_ADD 2012
#define HISTORIAN_PPI_ZT1_DETECTS_TODAY_REG_ADD 2013
#define HISTORIAN_PPE_ZT1_DETECTS_TODAY_REG_ADD 2014
#define HISTORIAN_PG_DETECTS_TODAY_REG_ADD 2015
#define HISTORIAN_PPI_ZT2_DETECTS_TODAY_REG_ADD 2016
#define HISTORIAN_PPE_ZT2_DETECTS_TODAY_REG_ADD 2017
#define HISTORIAN_LAST_TRAIN_YEAR_REG_ADD 2018
#define HISTORIAN_LAST_TRAIN_MONTH_REG_ADD 2019
#define HISTORIAN_LAST_TRAIN_DAY_REG_ADD 2020
#define HISTORIAN_LAST_TRAIN_HOUR_REG_ADD 2021
#define HISTORIAN_LAST_TRAIN_MINUTE_REG_ADD 2022
#define HISTORIAN_LAST_TRAIN_SECONDS_REG_ADD 2023
#define HISTORIAN_LAST_TRAIN_ZONE_REG_ADD 2024
#define HISTORIAN_LAST_TRAIN_NB_DETECTS_REG_ADD 2025
#define HISTORIAN_LAST_TRAIN_PPI_RK_1_REG_ADD 2026
#define HISTORIAN_LAST_TRAIN_PPI_RK_2_REG_ADD 2027
#define HISTORIAN_LAST_TRAIN_PPI_RK_3_REG_ADD 2028
#define HISTORIAN_LAST_TRAIN_PPI_RK_4_REG_ADD 2029
#define HISTORIAN_LAST_TRAIN_PPE_RK_1_REG_ADD 2030
#define HISTORIAN_LAST_TRAIN_PPE_RK_2_REG_ADD 2031
#define HISTORIAN_LAST_TRAIN_PPE_RK_3_REG_ADD 2032
#define HISTORIAN_LAST_TRAIN_PPE_RK_4_REG_ADD 2033
#define HISTORIAN_LAST_TRAIN_PG_RK_1_REG_ADD 2034
#define HISTORIAN_LAST_TRAIN_PG_RK_2_REG_ADD 2035
#define HISTORIAN_LAST_TRAIN_PG_RK_3_REG_ADD 2036
#define HISTORIAN_LAST_TRAIN_PG_RK_4_REG_ADD 2037
#define HISTORIAN_LAST_TRAIN_FN_RK_1_REG_ADD 2038
#define HISTORIAN_LAST_TRAIN_FN_RK_2_REG_ADD 2039
#define HISTORIAN_LAST_TRAIN_FN_RK_3_REG_ADD 2040
#define HISTORIAN_LAST_TRAIN_FN_RK_4_REG_ADD 2041
#define HISTORIAN_LAST_TRAIN_COMPTAGE_DET_REG_ADD 2042
#define HISTORIAN_LAST_TRAIN_PEQ_REG_ADD 2043
#define HISTORIAN_LAST_TRAIN_TYPE_REG_ADD 2044
#define HISTORIAN_LAST_TRAIN_ID1_REG_ADD 2045
#define HISTORIAN_LAST_TRAIN_ID2_REG_ADD 2046
#define HISTORIAN_LAST_TRAIN_ID3_REG_ADD 2047
#define HISTORIAN_RESERVED_1_REG_ADD 2048
#define HISTORIAN_RESERVED_2_REG_ADD 2049
#endif // PIHISTORIANDEFS_H

View File

@ -0,0 +1,584 @@
#include "PIHistorianManager.h"
#include "ZTLog.h"
#include "ModbusRepository.h"
#include "PIHistorianDefs.h"
CPIHistorianManager::CPIHistorianManager(CModbusRepository *PIHistorianRepo, int ModbusPort, int ModbusDevID)
{
mModbusPort = ModbusPort;
mModbusServer = new QTcpServer();
connect(mModbusServer,SIGNAL(newConnection()),this,SLOT(NewModbusConnection()));
mPIHistorianRepo = PIHistorianRepo;
mModbusDevID = ModbusDevID;
mHistorianTimer = new QTimer;
mHistorianTimer->setSingleShot(true);
mNbPassagesToday = 0;
mNbDeclToday = 0;
mNbDeclTotal = 0;
mNbFNToday = 0;
mNbPGToday = 0;
mNbPPIZT1Today = 0;
mNbPPEZT1Today = 0;
mNbPPIZT2Today = 0;
mNbPPEZT2Today = 0;
}
CPIHistorianManager::~CPIHistorianManager()
{
StopPIHistorian();
delete mModbusServer;
delete mHistorianTimer;
}
void CPIHistorianManager::NewModbusConnection()
{
QTcpSocket* SessionSocket = mModbusServer->nextPendingConnection();
if(SessionSocket != 0)
{
CPIHistorianSession *NewSession = new CPIHistorianSession(mPIHistorianRepo,mModbusDevID);
connect(NewSession,SIGNAL(PIHistorianSessionClosed(CPIHistorianSession*)),this,SLOT(HistorianSessionClosed(CPIHistorianSession*)));
mHistorianSessionsList.append(NewSession);
NewSession->OpenSession(SessionSocket);
}
}
void CPIHistorianManager::HistorianSessionClosed(CPIHistorianSession *SessionPtr)
{
for(int i = 0; i < mHistorianSessionsList.size(); i++)
{
if(mHistorianSessionsList.at(i) == SessionPtr)
{
CPIHistorianSession *Session = mHistorianSessionsList.takeAt(i);
Session->CloseSession();
delete Session;
return;
}
}
CZTLog::instance()->AddLogString(QString("Erreur de logique dans PIHistorianManager::HistorianSessionClosed. [Session fermée inconnue] "));
}
int CPIHistorianManager::StartPIHistorian()
{
mModbusServer->listen(QHostAddress::Any,mModbusPort);
CZTLog::instance()->AddLogString(QString("Gestionnaire de l'historien PI démarré sur le port %1").arg(mModbusPort),true);
StartHistorianTimer();
return RET_OK;
}
int CPIHistorianManager::StopPIHistorian()
{
mModbusServer->close();
for(int i = 0; i < mHistorianSessionsList.size(); i++)
{
CPIHistorianSession *Session = mHistorianSessionsList.takeFirst();
Session->CloseSession();
delete Session;
}
mHistorianTimer->stop();
return RET_OK;
}
int CPIHistorianManager::UpdateDetectionFunctions(CZTDetectionFunctionConfig *DetectionCfg)
{
bool OK;
quint16 StatusReg = mPIHistorianRepo->GetSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,&OK);
if(OK == false)
return RET_ERROR;
if(DetectionCfg->mZTDetectionConfig[DETECTION_FCT_FN].AnalysisActive == true && DetectionCfg->mZTDetectionConfig[DETECTION_FCT_FN].TKActive == true)
{
StatusReg |= HISTORIAN_ZT1_FN_ENABLED_FLAG_MASK;
}
else
{
StatusReg &= ~HISTORIAN_ZT1_FN_ENABLED_FLAG_MASK;
}
if(DetectionCfg->mZTDetectionConfig[DETECTION_FCT_PG].AnalysisActive == true && DetectionCfg->mZTDetectionConfig[DETECTION_FCT_PG].TKActive == true)
{
StatusReg |= HISTORIAN_ZT1_PG_ENABLED_FLAG_MASK;
}
else
{
StatusReg &= ~HISTORIAN_ZT1_PG_ENABLED_FLAG_MASK;
}
if(DetectionCfg->mZTDetectionConfig[DETECTION_FCT_PP].AnalysisActive == true && DetectionCfg->mZTDetectionConfig[DETECTION_FCT_PP].TKActive == true)
{
StatusReg |= HISTORIAN_ZT1_PP_ENABLED_FLAG_MASK;
}
else
{
StatusReg &= ~HISTORIAN_ZT1_PP_ENABLED_FLAG_MASK;
}
if(DetectionCfg->mZTDetectionConfig[DETECTION_FCT_PP2].AnalysisActive == true && DetectionCfg->mZTDetectionConfig[DETECTION_FCT_PP2].TKActive == true)
{
StatusReg |= HISTORIAN_ZT2_PP_ENABLED_FLAG_MASK;
}
else
{
StatusReg &= ~HISTORIAN_ZT2_PP_ENABLED_FLAG_MASK;
}
if(DetectionCfg->mZTDetectionConfig[DETECTION_FCT_ZT1].AnalysisActive == true && DetectionCfg->mZTDetectionConfig[DETECTION_FCT_ZT1].TKActive == true)
{
StatusReg |= HISTORIAN_ZT_ZT1_ENABLED_FLAG_MASK;
}
else
{
StatusReg &= ~HISTORIAN_ZT_ZT1_ENABLED_FLAG_MASK;
}
if(DetectionCfg->mZTDetectionConfig[DETECTION_FCT_ZT2].AnalysisActive == true && DetectionCfg->mZTDetectionConfig[DETECTION_FCT_ZT2].TKActive == true)
{
StatusReg |= HISTORIAN_ZT_ZT2_ENABLED_FLAG_MASK;
}
else
{
StatusReg &= ~HISTORIAN_ZT_ZT2_ENABLED_FLAG_MASK;
}
return mPIHistorianRepo->WriteSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,StatusReg);
}
int CPIHistorianManager::UpdatePGTreshold(int Treshold)
{
return mPIHistorianRepo->WriteSingleReg(HISTORIAN_PG_CALIBRATION_REG_ADD,(quint16)Treshold);
}
int CPIHistorianManager::UpdateMaintenanceMode(bool MaintenanceON)
{
bool OK;
quint16 StatusReg = mPIHistorianRepo->GetSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,&OK);
if(OK == false)
return RET_ERROR;
if(MaintenanceON)
{
StatusReg |= HISTORIAN_ZT_MAINTENANCE_MODE_FLAG_MASK;
}
else
{
StatusReg &= ~HISTORIAN_ZT_MAINTENANCE_MODE_FLAG_MASK;
}
return mPIHistorianRepo->WriteSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,StatusReg);
}
int CPIHistorianManager::SetSystemStartDateTime(QDateTime StartDateTime)
{
quint16 year, month, day, hour, minute, seconds;
year = (quint16)StartDateTime.date().year();
day = (quint16)StartDateTime.date().day();
month = (quint16)StartDateTime.date().month();
hour = (quint16)StartDateTime.time().hour();
minute = (quint16)StartDateTime.time().minute();
seconds = (quint16)StartDateTime.time().second();
int ret;
ret = mPIHistorianRepo->WriteSingleReg(HISTORIAN_BOOT_DATE_YEAR_REG_ADD,year);
ret |= mPIHistorianRepo->WriteSingleReg(HISTORIAN_BOOT_DATE_DAY_REG_ADD,day);
ret |= mPIHistorianRepo->WriteSingleReg(HISTORIAN_BOOT_DATE_MONTH_REG_ADD,month);
ret |= mPIHistorianRepo->WriteSingleReg(HISTORIAN_BOOT_DATE_HOUR_REG_ADD,hour);
ret |= mPIHistorianRepo->WriteSingleReg(HISTORIAN_BOOT_DATE_MINUTES_REG_ADD,minute);
ret |= mPIHistorianRepo->WriteSingleReg(HISTORIAN_BOOT_DATE_SECONDS_REG_ADD,seconds);
return ret;
}
void CPIHistorianManager::HPCDisconnected()
{
bool OK;
quint16 StatusReg = mPIHistorianRepo->GetSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,&OK);
if(OK == false)
return;
StatusReg &= ~HISTORIAN_ZT_HPC_COMM_HEALTH_FLAG_MASK;
mPIHistorianRepo->WriteSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,StatusReg);
}
void CPIHistorianManager::HPCConnected(qint32 IP1,qint32 IP2)
{
Q_UNUSED(IP1)
Q_UNUSED(IP2)
bool OK;
quint16 StatusReg = mPIHistorianRepo->GetSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,&OK);
if(OK == false)
return;
StatusReg |= HISTORIAN_ZT_HPC_COMM_HEALTH_FLAG_MASK;
mPIHistorianRepo->WriteSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,StatusReg);
}
void CPIHistorianManager::SEIConnected(qint32 IP1,qint32 IP2)
{
Q_UNUSED(IP1)
Q_UNUSED(IP2)
bool OK;
quint16 StatusReg = mPIHistorianRepo->GetSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,&OK);
if(OK == false)
return;
StatusReg |= HISTORIAN_ZT_SEI_COMM_FLAG_MASK;
mPIHistorianRepo->WriteSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,StatusReg);
}
void CPIHistorianManager::SEIDisconnected()
{ bool OK;
quint16 StatusReg = mPIHistorianRepo->GetSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,&OK);
if(OK == false)
return;
StatusReg &= ~HISTORIAN_ZT_SEI_COMM_FLAG_MASK;
mPIHistorianRepo->WriteSingleReg(HISTORIAN_ZT_STATUS_FLAGS_REG_ADD,StatusReg);
}
int CPIHistorianManager::NewZT1Passage(CZTPassageInfo ZT1PassageInfo)
{
QByteArray EmptyList; //create an empty buffer to reset modbus table values
EmptyList.fill(0x00, 18*2);
//Reset last declenchements values in the modbus table
mPIHistorianRepo->WriteHRData(HISTORIAN_LAST_TRAIN_PPI_RK_1_REG_ADD,18,EmptyList);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_TRAINS_TOTAL_REG_ADD,ZT1PassageInfo.mNbPassages);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_ZONE_REG_ADD,1);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_TYPE_REG_ADD,ZT1PassageInfo.mTrainType);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_ID1_REG_ADD,ZT1PassageInfo.mTrainCompo1);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_ID2_REG_ADD,ZT1PassageInfo.mTrainCompo2);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_ID3_REG_ADD,ZT1PassageInfo.mTrainCompo3);
QDateTime PassageDateTime = ZT1PassageInfo.mPassageDateTime;
quint16 year, month, day, hour, minute, seconds;
year = (quint16)PassageDateTime.date().year();
day = (quint16)PassageDateTime.date().day();
month = (quint16)PassageDateTime.date().month();
hour = (quint16)PassageDateTime.time().hour();
minute = (quint16)PassageDateTime.time().minute();
seconds = (quint16)PassageDateTime.time().second();
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_YEAR_REG_ADD,year);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_DAY_REG_ADD,day);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_MONTH_REG_ADD,month);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_HOUR_REG_ADD,hour);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_MINUTE_REG_ADD,minute);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_SECONDS_REG_ADD,seconds);
quint16 NbDecl = ZT1PassageInfo.mDetections->size();
quint16 NbDeclFN = 0, NbDeclPG = 0, NbDeclPPI = 0, NbDeclPPE = 0;
quint16 PEQ = 0, ErrComptage = 0;
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_NB_DETECTS_REG_ADD,NbDecl);
if(NbDecl != 0)
{
for(int i = 0; i < NbDecl; i++)
{
CZTDetectionData *CurDetection = ZT1PassageInfo.mDetections->at(i);
switch(CurDetection->mDetectionID)
{
case DETECTION_MAGNETIC_SENSOR_COUNT:
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_COMPTAGE_DET_REG_ADD,1);
break;
}
case DETECTION_FN_DETECTION:
{
NbDeclFN++;
if(NbDeclFN == 1)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_FN_RK_1_REG_ADD,CurDetection->mRank);
}
else if(NbDeclFN == 2)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_FN_RK_2_REG_ADD,CurDetection->mRank);
}
else if(NbDeclFN == 3)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_FN_RK_3_REG_ADD,CurDetection->mRank);
}
else if(NbDeclFN == 4)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_FN_RK_4_REG_ADD,CurDetection->mRank);
}
else
{
//Ignore if more than 4
}
break;
}
case DETECTION_PG_DETECTION:
{
NbDeclPG++;
if(NbDeclPG == 1)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PG_RK_1_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPG == 2)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PG_RK_2_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPG == 3)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PG_RK_3_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPG == 4)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PG_RK_4_REG_ADD,CurDetection->mRank);
}
else
{
//Ignore if more than 4
}
break;
}
case DETECTION_PPI_DETECTION:
{
NbDeclPPI++;
if(NbDeclPPI == 1)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPI_RK_1_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPPI == 2)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPI_RK_2_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPPI == 3)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPI_RK_3_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPPI == 4)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPI_RK_4_REG_ADD,CurDetection->mRank);
}
else
{
//Ignore if more than 4
}
break;
}
case DETECTION_PPE_DETECTION:
{
NbDeclPPE++;
if(NbDeclPPE == 1)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPE_RK_1_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPPE == 2)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPE_RK_2_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPPE == 3)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPE_RK_3_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPPE == 4)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPE_RK_4_REG_ADD,CurDetection->mRank);
}
else
{
//Ignore if more than 4
}
break;
}
case DETECTION_PEQ1_DETECTION:
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PEQ_REG_ADD,1);
break;
}
}
}
mNbPassagesToday ++;
mNbDeclToday += NbDecl;
mNbDeclTotal += NbDecl;
mNbFNToday += NbDeclFN;
mNbPGToday += NbDeclPG;
mNbPPIZT1Today += NbDeclPPI;
mNbPPEZT1Today += NbDeclPPE;
mPIHistorianRepo->WriteSingleReg(HISTORIAN_TRAINS_TODAY_REG_ADD,mNbPassagesToday);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_DETECTIONS_TOTAL_REG_ADD,ZT1PassageInfo.mNbDeclenchements);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_DETECTIONS_TODAY_REG_ADD,mNbDeclToday);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_FN_DETECTS_TODAY_REG_ADD,mNbFNToday);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_PPI_ZT1_DETECTS_TODAY_REG_ADD,mNbPPIZT1Today);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_PPE_ZT1_DETECTS_TODAY_REG_ADD,mNbPPEZT1Today);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_PG_DETECTS_TODAY_REG_ADD,mNbPGToday);
}
return RET_OK;
}
int CPIHistorianManager::NewZT2Passage(CZTPassageInfo ZT2PassageInfo)
{
QByteArray EmptyList; //create an empty buffer to reset modbus table values
EmptyList.fill(0x00, 18*2);
//Reset last declenchements values in the modbus table
mPIHistorianRepo->WriteHRData(HISTORIAN_LAST_TRAIN_PPI_RK_1_REG_ADD,18,EmptyList);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_TRAINS_TOTAL_REG_ADD,ZT2PassageInfo.mNbPassages);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_ZONE_REG_ADD,2);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_TYPE_REG_ADD,ZT2PassageInfo.mTrainType);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_ID1_REG_ADD,ZT2PassageInfo.mTrainCompo1);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_ID2_REG_ADD,ZT2PassageInfo.mTrainCompo2);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_ID3_REG_ADD,ZT2PassageInfo.mTrainCompo3);
QDateTime PassageDateTime = ZT2PassageInfo.mPassageDateTime;
quint16 year, month, day, hour, minute, seconds;
year = (quint16)PassageDateTime.date().year();
day = (quint16)PassageDateTime.date().day();
month = (quint16)PassageDateTime.date().month();
hour = (quint16)PassageDateTime.time().hour();
minute = (quint16)PassageDateTime.time().minute();
seconds = (quint16)PassageDateTime.time().second();
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_YEAR_REG_ADD,year);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_DAY_REG_ADD,day);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_MONTH_REG_ADD,month);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_HOUR_REG_ADD,hour);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_MINUTE_REG_ADD,minute);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_SECONDS_REG_ADD,seconds);
quint16 NbDecl = ZT2PassageInfo.mDetections->size();
quint16 NbDeclPPI = 0, NbDeclPPE = 0;
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_NB_DETECTS_REG_ADD,NbDecl);
if(NbDecl != 0)
{
for(int i = 0; i < NbDecl; i++)
{
CZTDetectionData *CurDetection = ZT2PassageInfo.mDetections->at(i);
switch(CurDetection->mDetectionID)
{
case DETECTION_ZT2_MAGNETIC_SENSOR_COUNT:
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_COMPTAGE_DET_REG_ADD,1);
break;
}
case DETECTION_ZT2_PPI_DETECTION:
{
NbDeclPPI++;
if(NbDeclPPI == 1)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPI_RK_1_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPPI == 2)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPI_RK_2_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPPI == 3)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPI_RK_3_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPPI == 4)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPI_RK_4_REG_ADD,CurDetection->mRank);
}
else
{
//Ignore if more than 4
}
break;
}
case DETECTION_ZT2_PPE_DETECTION:
{
NbDeclPPE++;
if(NbDeclPPE == 1)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPE_RK_1_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPPE == 2)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPE_RK_2_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPPE == 3)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPE_RK_3_REG_ADD,CurDetection->mRank);
}
else if(NbDeclPPE == 4)
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PPE_RK_4_REG_ADD,CurDetection->mRank);
}
else
{
//Ignore if more than 4
}
break;
}
case DETECTION_PEQ2_DETECTION:
{
mPIHistorianRepo->WriteSingleReg(HISTORIAN_LAST_TRAIN_PEQ_REG_ADD,1);
break;
}
}
}
mNbDeclToday += NbDecl;
mNbDeclTotal += NbDecl;
mNbPPIZT2Today += NbDeclPPI;
mNbPPEZT2Today += NbDeclPPE;
mPIHistorianRepo->WriteSingleReg(HISTORIAN_TRAINS_TODAY_REG_ADD,mNbPassagesToday);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_DETECTIONS_TOTAL_REG_ADD,ZT2PassageInfo.mNbDeclenchements);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_DETECTIONS_TODAY_REG_ADD,mNbDeclToday);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_PPI_ZT2_DETECTS_TODAY_REG_ADD,mNbPPIZT2Today);
mPIHistorianRepo->WriteSingleReg(HISTORIAN_PPE_ZT2_DETECTS_TODAY_REG_ADD,mNbPPEZT2Today);
}
return RET_OK;
}
void CPIHistorianManager::StartHistorianTimer()
{
QTime Time = QTime::currentTime();
int Delay = Time.msecsTo(QTime(23,59,59));
if(Delay < 0)
{
Delay += MSECS_IN_A_DAY;
}
mHistorianTimer->start(Delay);
}
void CPIHistorianManager::HistorianTimerExpired()
{
mNbFNToday = 0;
mNbPGToday = 0;
mNbPPIZT1Today = 0;
mNbPPEZT1Today = 0;
mNbPPIZT2Today = 0;
mNbPPEZT2Today = 0;
StartHistorianTimer();
}

View File

@ -0,0 +1,63 @@
#ifndef PIHISTORIANMANAGER_H
#define PIHISTORIANMANAGER_H
#include <QObject>
#include "PIHistorianSession.h"
#include <QList>
#include <QTcpServer>
#include "ZTData.h"
#define PI_HISTORIAN_MODBUS_DEVICE_ID 1
#define MSECS_IN_A_DAY (24 * 60 * 60 * 1000)
class CPIHistorianManager : public QObject
{
Q_OBJECT
public:
CPIHistorianManager(CModbusRepository *PIHistorianRepo, int ModbusPort, int ModbusDevID);
virtual ~CPIHistorianManager();
int StartPIHistorian();
int StopPIHistorian();
int UpdateDetectionFunctions(CZTDetectionFunctionConfig* DetectionCfg);
int UpdatePGTreshold(int Treshold);
int UpdateMaintenanceMode(bool MaintenanceON);
int SetSystemStartDateTime(QDateTime StartDateTime);
int NewZT1Passage(CZTPassageInfo ZT1PassageInfo);
int NewZT2Passage(CZTPassageInfo ZT2PassageInfo);
QTcpServer *mModbusServer; //L'instance du serveur TCP
int mModbusPort;
int mModbusDevID;
CModbusRepository *mPIHistorianRepo;
QTimer *mHistorianTimer;
void StartHistorianTimer();
private:
QList<CPIHistorianSession*> mHistorianSessionsList; //Les sessions établies par le serveur sont gardées dans cette liste
quint16 mNbPassagesToday;
quint16 mNbDeclToday;
quint16 mNbDeclTotal;
quint16 mNbFNToday;
quint16 mNbPGToday;
quint16 mNbPPIZT1Today;
quint16 mNbPPEZT1Today;
quint16 mNbPPIZT2Today;
quint16 mNbPPEZT2Today;
public slots:
void NewModbusConnection();
void HistorianSessionClosed(CPIHistorianSession*);
void HPCDisconnected();
void HPCConnected(qint32 IP1, qint32 IP2);
void SEIConnected(qint32, qint32 IP2);
void SEIDisconnected();
void HistorianTimerExpired();
};
#endif // PIHISTORIANMANAGER_H

View File

@ -0,0 +1,51 @@
#include "PIHistorianSession.h"
#include "ZTLog.h"
CPIHistorianSession::CPIHistorianSession(CModbusRepository *Repo, int DevID) :
CModbusBackend(Repo)
{
mDeviceID = DevID;
mModbusMode = MODBUS_SLAVE_MODE;
}
CPIHistorianSession::~CPIHistorianSession()
{
}
int CPIHistorianSession::OpenSession(QTcpSocket *ModbusSocket)
{
mModbusTCPSocketHandle = ModbusSocket;
connect(mModbusTCPSocketHandle,SIGNAL(readyRead()),this,SLOT(ModbusDataReady()));
connect(mModbusTCPSocketHandle,SIGNAL(disconnected()),this,SLOT(HistorianConnectionLost()));
CZTLog::instance()->AddLogString(QString("Session avec Historien PI établie. IP locale [%1] - IP HPC [%2]").arg(mModbusTCPSocketHandle->localAddress().toString()).arg(mModbusTCPSocketHandle->peerAddress().toString()),true);
return RET_OK;
}
int CPIHistorianSession::CloseSession()
{
disconnect(mModbusTCPSocketHandle,SIGNAL(readyRead()),this,SLOT(ModbusDataReady()));
mModbusTCPSocketHandle->close();
CZTLog::instance()->AddLogString(QString("Session avec Historien PI fermée avec succès."),true);
return RET_OK;
}
void CPIHistorianSession::RegistersDatabaseUpdated(quint16 StartAddress, quint16 Length)
{
}
void CPIHistorianSession::ModbusRequestException(quint8 ExceptionCode, quint8 FctCode)
{
}
void CPIHistorianSession::HistorianConnectionLost()
{
CZTLog::instance()->AddLogString(QString("Session avec Historien PI fermée (connexion perdue)."));
emit PIHistorianSessionClosed(this);
}

View File

@ -0,0 +1,30 @@
#ifndef PIHISTORIANSESSION_H
#define PIHISTORIANSESSION_H
#include "ModbusBackend.h"
class CPIHistorianSession : public CModbusBackend
{
Q_OBJECT
public:
CPIHistorianSession(CModbusRepository *Repo,int DevID);
virtual ~CPIHistorianSession();
int OpenSession(QTcpSocket *ModbusSocket);
int CloseSession();
virtual void RegistersDatabaseUpdated(quint16 StartAddress, quint16 Length);
virtual void ModbusRequestException(quint8 ExceptionCode, quint8 FctCode);
signals:
void PIHistorianSessionClosed(CPIHistorianSession *Sender);
public slots:
void HistorianConnectionLost();
};
#endif // PIHISTORIANSESSION_H

View File

@ -1,5 +0,0 @@
#include "PIHistorianManager.h"
CPIHistorianManager::CPIHistorianManager()
{
}

View File

@ -1,10 +0,0 @@
#ifndef PIHISTORIANMANAGER_H
#define PIHISTORIANMANAGER_H
class CPIHistorianManager
{
public:
CPIHistorianManager();
};
#endif // PIHISTORIANMANAGER_H

View File

@ -379,4 +379,18 @@ class CZTPGCalibrationData
qint32 mPGIntValue;
};
class CZTPassageInfo
{
public:
QVector<CZTDetectionData*> *mDetections;
quint16 mNbPassages;
quint16 mNbDeclenchements;
qint16 mTrainCompo1;
qint16 mTrainCompo2;
qint16 mTrainCompo3;
qint16 mTrainType;
QDateTime mPassageDateTime;
};
#endif // ZTDATA_H

View File

@ -377,6 +377,7 @@ unsigned int CZTStateMachine::ZT1StateMachine(unsigned int Event, unsigned int S
mZT1ActiveStatus = SB_ZT_ACTIVE_STATUS;
mZTPagePTr->SetZTStatus(mNbPassages,mNbTriggers,mZT1ActiveStatus,mZT2ActiveStatus);
mZTPagePTr->SetZT1ActivationState(true);
mZTActivationDateTime = QDateTime::currentDateTime();
mZTPagePTr->ResetZT1Stats();
if(mModbusCCMgr != 0)
@ -1168,6 +1169,19 @@ unsigned int CZTStateMachine::AnalyzeZT1PostDetection()
CZTLog::instance()->ClearBufferString(); //2015-03-03 To avoid potention memory leak. Computer Crash problem resolution tentative...
}
CZTPassageInfo PassageInfo;
PassageInfo.mDetections = &mZT1DetectionsLog;
PassageInfo.mNbPassages = mNbPassages;
PassageInfo.mNbDeclenchements = mNbTriggers;
PassageInfo.mTrainType = mZT1Log.mZT1Flags.mModbusTrainType;
PassageInfo.mTrainCompo1 = mZT1Log.mZT1Flags.mTrainCompo1;
PassageInfo.mTrainCompo2 = mZT1Log.mZT1Flags.mTrainCompo2;
PassageInfo.mTrainCompo3 = mZT1Log.mZT1Flags.mTrainCompo3;
PassageInfo.mPassageDateTime = mZTActivationDateTime;
mProgramPtr->NewZT1Passage(PassageInfo);
mZTPagePTr->SetZTStatus(mNbPassages,mNbTriggers,mZT1ActiveStatus,mZT2ActiveStatus);
return RET_POST_DETECTION_VALID;
@ -1240,6 +1254,7 @@ unsigned int CZTStateMachine::ZT2StateMachine(unsigned int Event, unsigned int S
mEventsRefTimer.start();
mZTPagePTr->SetZT2ActivationSTate(true);
mZT2ActiveStatus = SB_ZT_ACTIVE_STATUS;
mZTActivationDateTime = QDateTime::currentDateTime();
mZTPagePTr->SetZTStatus(mNbPassages,mNbTriggers,mZT1ActiveStatus,mZT2ActiveStatus);
mZTPagePTr->ResetZT2Stats();
if(mModbusCCMgr != 0)
@ -1442,6 +1457,17 @@ unsigned int CZTStateMachine::AnalyzeZT2PostDetection()
CZTLog::instance()->ClearBufferString(); //2015-03-03 To avoid potention memory leak. Computer Crash problem resolution tentative...
}
CZTPassageInfo PassageInfo;
PassageInfo.mDetections = &mZT2DetectionsLog;
PassageInfo.mNbPassages = mNbPassages;
PassageInfo.mNbDeclenchements = mNbTriggers;
PassageInfo.mTrainType = mZT2Log.mZT2Flags.mModbusTrainType;
PassageInfo.mTrainCompo1 = mZT2Log.mZT2Flags.mTrainCompo1;
PassageInfo.mTrainCompo2 = mZT2Log.mZT2Flags.mTrainCompo2;
PassageInfo.mTrainCompo3 = mZT2Log.mZT2Flags.mTrainCompo3;
PassageInfo.mPassageDateTime = mZTActivationDateTime;
mProgramPtr->NewZT2Passage(PassageInfo);
//mZTPagePTr->SetZTStatus(mNbPassages,mNbTriggers,mZT1Active,mZT2Active);
mZTPagePTr->SetZTStatus(mNbPassages,mNbTriggers,mZT1ActiveStatus,mZT2ActiveStatus);

View File

@ -230,6 +230,8 @@ private:
QElapsedTimer mFSSyncTimer;
bool mTimeToForceSyncFS;
QDateTime mZTActivationDateTime;
signals:
void PGCalibrationFinished(int); //Signal envoyé lorsque la calibration est terminée. Le paramètre est la valeur calculée.
void PGCalibrationStatus(int,int); //Signal envoyé pour informer de l'état de la calibration. Le paramètre 1 est le nombre de passages à date et le 2è est le nombre requis.

View File

@ -29,7 +29,7 @@
#ifndef ZTVERSION_H
#define ZTVERSION_H
#define ZT_SOFT_VERSION "V1.26.1"
#define ZT_SOFT_VERSION "V1.26_PI"
//LOG DES CHANGEMENTS
//Version 1.26.1

219
sources/ZTVersion.h.orig Normal file
View File

@ -0,0 +1,219 @@
/*******************************************************************************
* *
* Société de Transports de Montréal. *
* 2012 - 2013 *
* *
* Projet Zones Tests *
* *
* *
* *
*******************************************************************************/
/*
Description:
Description du fichier si nécessaire.
*/
/* ************************************************************************** */
/* Revision:
### YYYMMDD JFM
Verision d'origine.
### YYYYMMDD Description du besoin ou du bug
Description du changement.
*/
/* ************************************************************************** */
#ifndef ZTVERSION_H
#define ZTVERSION_H
<<<<<<< HEAD
#define ZT_SOFT_VERSION "V1.26.1"
=======
#define ZT_SOFT_VERSION "V1.26_PI"
>>>>>>> Historien_PI
//LOG DES CHANGEMENTS
//Version 1.26.1
//-Ajout du flag pour ignorer la clef RSA lors du transfert FTP. Suite aux problemes
// a Beaugrand.
//Version 1.26
//-Ajout de la possibilité d'activer le module SFTP pour copier les logs sans que la
// communication avec la CC soit activée (ZT branchée sur le réseau mais interface
// avec la CC en fil-à-fil).
//Version 1.25.1
//-Deplacement de la notification de sychronisation de la date & heure SACL vers le
// log d'ingenierie pour ne pas polluer ZTLog.
//Version 1.25
//-Ajout de la fonctionnalité de transfert des fichiers de passage sur le réseau
//Version 1.24
//-Changements à la station Côte-Vertu pour la nouvelle configuration de la ZT.
//-Correction d'un petit bug qui ne permettait pas d'avoir le bon itinéraire dans les
// alarmes du mode entretien à chaque fois.
//-Retrait de la conservation de tous les passages "problématiques". C'était une fausse
// bonne idée car ça remplit le disque en cas de sondes problématiques.
//Version 1.23
//-Suite à la mise en service du du SEI Angrignon, on a dû changer le CDV d'activation ZT2
// car le CDV 13A s'occupe parfois trop tard et la sonde magnétique cause des PEQ2.
//Version 1.22
//-Ajout de la deconnexion manuelle du socket lors du timeout
// de watchdog avec NetTrac. Suite aux essais site Angrignon.
//V1.21_TEST_ATS (NON DEPLOYE)
//Changement de l'endian du bit de watchdog pour les essais ATS.
//Version 1.21
//-Correction d'un bug dans le calcul de l'adresse IP du Gateway
//-Ajout de la désactivation du log d'ingénierie dans le script de mise à jour
//-Correction d'un bug d'écriture dans un registre SEI
//-Ajout de la composition du train dans le fichier LOG
//-Suite au passage du train test, changement des CDV d'acquitement des alarmes
// à Montmorency. 12A -> (12A & 11A) et 22A -> (22A & 21B).
//Version 1.20
//-Ajout de la gestion de communication modbus avec le SEI.
//-Ajout de la page de visualisation des tables modbus (F4 ou menu ingénierie).
//Version 1.19
//-Suite aux essais sur site, changement des CDV d'acquitement des alarmes
// À Montmorency (12BC -> 12A et 22BC -> 22A).
//-Correction d'un bug qui causait systématiquement une erreur de comptage
// lorsqu'une panne équipement survenait alors que l'analyse était inhibée.
//Version 1.18
//-Correction du bug qui loggait une erreur de PEQ1 frotteur négatif collé à 1
// systématiquement pour n'importe quelle panne.
//-Changement de l'analyse des pannes équipement pour ne pas émettre d'alarme
// lorsque la détection de panne correspond à un équipement désactivé
//Version 1.17
//-Corrections mineures à l'interface graphique
//-Possibilité de générer des alarmes en itinéraire secondaire en mode entretien
//-Correction de la désactivation de la vigie en mode entretien avec le Modbus
//-Possibilité d'avoir un ou des éléments de train assignés à une compo "00" (MPM10)
//Version 1.16
//-Implantation de la communicationp Modbus avec la Commande Centralisée. Ceci implique
// plusieurs changements.
//-Correction d'un bug qui faisait planter le logiciel lors de la désactivation du log
// d'ingénierie.
//Version 1.15
//Modification de l'initialisation de la station à partir de la clef électrique directement.
//Retrait de la vérification de la cohérence de la clef avec le fichier de configuration.
//Version 1.14
//-Correction de la corruption des fichiers de passage lorsque des lectures étaient
// encore dans la queue des "signals" provenant du thread ZT1 alors que le passage
// était terminé. Correction de l'affichage aussi.
//Version 1.13
//-À la demande générale, remise à zéro du nombre de passages lors du téléchargement des
// passages.
//-Ajout d'un checkbox permettant de conserver les fichiers lors de l'archivage.
//Version 1.12
//-Changement du délai de sortie automatique du mode entretien de 1h à 2h.
//-Ajout du nom de la station dans le fichier LOG lors de sa destruction.
//-Correction du changement de la date qui ignorait l'année.
//-Ajout d'entrées dans le log d'ingénierie pour investiguer les détections FN intempestives.
//-Retrait de la trace du signal virtuel PG dans la visualisation des passages et
// aggrandissement de la trace analogique du SDF
//Version 1.11
//-À la demande générale, changement de la couleur d'un CDV occupé pour la couleur orange afin
// de se conformer à l'affichage des PICC.
//-Suite à l'analyse de la Commande Centralisée, le rang par défaut lors d'une détection avec
// erreur de comptage est revenu à 1.
//-Correction d'une fausse détection PEQ1 "FN collé à 1" lors d'une erreur de comptage.
//-Vérification que le fichier log d'ingénierie ne dépasse pas 1Mb.
//Version 1.10
//-Ajout de la condition CDV ZT2 libre lors de l'activation de la CIZT2 pour activer la ZT2.
//-Lors d'une erreur de comptage + détection frotteur, envoyer deux alarmes FN aux rangs 1 et 18.
// Le nouveau rang par défaut pour les autres types de déclenchements est changé pour le rang 0
//Version 1.09
//-Changement du CDV d'approche et combinaison du CDV ZT1 à Longueuil car les équipements sont
// installés trop près du joint isolant.
//-Mise à jour de la liste des passages lorsqu'un train passe alors que la liste est en train
// d'être consultée.
//-Allongement du quai à MMO 10/22 pour couvrir le CDV 22 au complet.
//-Les pédales ZT2 ne sont pas affichées dans la page de maintenance si la station ne possède
// pas de ZT2.
//-Scroll de la vue à la fin du fichier LOG lors de son affichage.
//Version 1.08
//-Synchronisation du filesystem (commande sync) appelée périodiquement à toutes les 40 minutes
// après qu'un train ait quitté ZT2 (ou ZT1 s'il n'y a pas de ZT2) pour s'Assurer que le système
// ne ralentit pas trop lors d'un sync intempestif.
//-Changement du CDV d'armement ZT2 de Bourassa.
//-Ajout d'un flag dans le fichier de passage lorsqu'un déclenchement survient mais que la TK
// n'est pas envoyée au PCC. Les fichiers de passage avec le flag à 1 sont conservés au même titre
// que les déclenchements réguliers.
//-Ajout d'un bouton d'acquitement manuel des alarmes dans le mode entretien.
//-Les alarmes PEQX et V0X sont émises à la fin plutôt qu'au débutlorsque d'autres déclenchements
// sont présents
//-Changment du nombre minimum de fichiers de passage à conserver (dans la page d'ingénierie) à 1.
//Version 1.07
//
//-La copie des fichiers sur la clef USB pouvait faire redémarrer l'ordinateur étant donné que la
// commande "sync" était appelée dans le thread principal (bloquant ainsi le rafraîchissement du
// watchdog interne). sync peut être longue à exécuter, elle a donc été déplacée dans le thread.
//-Finalisation du fichier station Montmorency.cpp afin d'accueillir les 2 itinéraires.
//Version 1.06
//
//-Correction de la valeur par défaut du flag TK ZT1 activé dans ZTSettings::LoadDefaultValues.
//
//Version 1.05
//
//-Correction d'un bug qui faisait planter l'application lorsqu'un module externe n'était
// pas détecté.
//-Ajout d'un curseur horizontal dans la visualisation des passages.
//-Adaptation et modification de la state machine pour les particularités d'installation
// à Snowdon.
//-Correction de l'assignation des inputs à Snowdon
//Version 1.04
//
//-Ajout de la détection du bouton "power" afin de quitter l'application zonetest adéquatement
// avant de redémarrer l'ordinateur.
//-Changement du "toggle" de la sortie Vigie pour un pulse d'une seconde.
//Version 1.03
//
//-Ajout de la possibilité de paramétrer le nombre de fichiers de passages à conserver
// dans la page d'ingénierie et de conserver les fichiers ZT1, ZT2 ou MPM10.
//-Changement du délai de la vigie à 10 secondes pour ménager les relais du module de sortie.
//Version 1.02
//
//-Ajout d'un message dans EngLog dans le cas où l'accès aux modules externes est un échec
// afin de trouver pourquoi la vigie ne fonctionnait plus à C-Vertu.
//Version 1.01
//
//-Corrections diverses reliées au log des erreurs de comptage et autres suite aux problèmes
// de comptage ZT2 rencontrés à C-Vertu.
//Version 1.00:
//
//-Version utilisée lors de l'installation du premier T.O. produit par l'atelier à Côte-Vertu.
#endif // ZTVERSION_H

View File

@ -66,6 +66,11 @@ CZTConfigMgr::CZTConfigMgr()
//SFTP server parameters
mActivateSFTPClient = false;
//PI historian parameters
mEnablePIHistorian = false;
mPIHistorianModbusPort = 503;
mPIHistorianModbusDevID = 1;
}
ZTConfigResult CZTConfigMgr::LoadZTConfig()
@ -221,7 +226,7 @@ ZTConfigResult CZTConfigMgr::LoadZTConfig()
CEngLog::instance()->AddLogString(QString().sprintf("Invalid MODBUS_SEI_DEVID parameter: %s",string.mid(pos).toUtf8().constData()));
mModbusSEIDevID = 0;
}
CEngLog::instance()->AddLogString(QString().sprintf("Port DevID SEI = %d",mModbusSEIDevID));
CEngLog::instance()->AddLogString(QString().sprintf("Modbus DevID SEI = %d",mModbusSEIDevID));
}
else if(string.contains("MODBUS_SEI_PORT"))
{
@ -232,7 +237,7 @@ ZTConfigResult CZTConfigMgr::LoadZTConfig()
CEngLog::instance()->AddLogString(QString().sprintf("Invalid MODBUS_SEI_PORT parameter: %s",string.mid(pos).toUtf8().constData()));
mModbusSEIPort = 6060;
}
CEngLog::instance()->AddLogString(QString().sprintf("Port DevID SEI = %d",mModbusSEIPort));
CEngLog::instance()->AddLogString(QString().sprintf("Port Modbus SEI = %d",mModbusSEIPort));
}
//Station configuration parameters
@ -332,6 +337,42 @@ ZTConfigResult CZTConfigMgr::LoadZTConfig()
mSFTPRemoteDir = string.mid(pos);
CEngLog::instance()->AddLogString(QString("Répertoire distant SFTP %1").arg(mSFTPRemoteDir),1);
}
else if(string.contains("ACTIVER_HISTORIEN_PI"))
{
if(string.mid(pos) == "OUI")
{
mEnablePIHistorian = true;
CEngLog::instance()->AddLogString(QString().sprintf("Historien PI activé"),1);
}
else
{
mEnablePIHistorian = false;
CEngLog::instance()->AddLogString(QString().sprintf("Historien PI activé"),1);
}
}
else if(string.contains("HISTORIEN_PI_DEVID"))
{
bool OK;
mPIHistorianModbusDevID = (string.mid(pos).toInt(&OK));
if(OK == false)
{
CEngLog::instance()->AddLogString(QString().sprintf("Invalid HISTORIEN_PI_DEVID parameter: %s",string.mid(pos).toUtf8().constData()));
mPIHistorianModbusDevID = 1;
}
CEngLog::instance()->AddLogString(QString().sprintf("Historien PI DevID = %d",mPIHistorianModbusDevID));
}
else if(string.contains("HISTORIEN_PI_PORT"))
{
bool OK;
mPIHistorianModbusPort = (string.mid(pos).toInt(&OK));
if(OK == false)
{
CEngLog::instance()->AddLogString(QString().sprintf("Invalid HISTORIEN_PI_PORT parameter: %s",string.mid(pos).toUtf8().constData()));
mPIHistorianModbusPort = 503;
}
CEngLog::instance()->AddLogString(QString().sprintf("Port Modbus Historien PI = %d",mPIHistorianModbusPort));
}
}
}
@ -457,3 +498,18 @@ QString CZTConfigMgr::GetSFTPServerRemoteDir()
{
return mSFTPRemoteDir;
}
bool CZTConfigMgr::GetPIHistorianEnabled()
{
return mEnablePIHistorian;
}
int CZTConfigMgr::GetPIHistorianModbusDevID()
{
return mPIHistorianModbusDevID;
}
int CZTConfigMgr::GetPIHistorianModbusPort()
{
return mPIHistorianModbusPort;
}

View File

@ -107,6 +107,9 @@ public:
QString GetSFTPPassword();
QString GetSFTPServerAddress();
QString GetSFTPServerRemoteDir();
bool GetPIHistorianEnabled();
int GetPIHistorianModbusDevID();
int GetPIHistorianModbusPort();
@ -146,6 +149,11 @@ private:
QString mSFTPPassword;
QString mSFTPAddress;
QString mSFTPRemoteDir;
//Historien PI parameters
bool mEnablePIHistorian;
int mPIHistorianModbusPort;
int mPIHistorianModbusDevID;
};
#endif // ZTCONFIGMGR_H

View File

@ -60,6 +60,7 @@
#include "ModbusTKTransport.h"
#include "ModbusSEIDefs.h"
#include <sys/time.h>
#include "PIHistorianDefs.h"
@ -103,7 +104,7 @@ CZoneTest::CZoneTest():
mExtIOWorkerThread->moveToThread(mExtIOThread);
connect(mExtIOThread,SIGNAL(started()),mExtIOWorkerThread,SLOT(DoAcquisition()));
mPIHistorianManager = 0;
}
CZoneTest::~CZoneTest()
@ -139,6 +140,9 @@ CZoneTest::~CZoneTest()
if(mAnalogModule != 0)
delete mAnalogModule;
if(mPIHistorianManager != 0)
delete mPIHistorianManager;
}
unsigned int CZoneTest::ExecStateMachine(eZTSMEvents_t)
@ -421,44 +425,6 @@ unsigned int CZoneTest::InitZT()
mAnalogModule = 0;
// //Open the DataQ datalogger module if present in config file
// QString DataQIP = CZTConfigMgr::instance()->GetDataQIPAddress();
// if(DataQIP.isEmpty())
// {
// CZTLog::instance()->AddLogString("Module DataQ non trouvé dans le fichier de configuration.",true);
// }
// else
// {
// mDI710Module = new CDI710Driver;
// if(mDI710Module->OpenDevice(DataQIP,DI710_TCP_PORT) != DI710_RET_OK)
// {
// mWelcomePagePtr->InsertTextBoxString(QString("Impossible d'initialiser le module DataQ"));
// mWelcomePagePtr->InsertTextBoxString(QString("Vérifier le fichier de configuration et la connexion."));
// CZTLog::instance()->AddLogString("Impossible d'initialiser le module DataQ",true);
// delete mDI710Module;
// mDI710Module = 0;
// }
// else
// {
// mDataQThread = new QThread;
// mDI710Module->moveToThread(mDataQThread);
// connect(mDataQThread,SIGNAL(started()),mDI710Module,SLOT(Run()));
// mDataQThread->start();
// mWelcomePagePtr->InsertTextBoxString(QString("Initialisation du module DataQ: OK"));
// }
// }
//Now, determine which of the analog module is detected.
// if((mIOManager->GetModule(IO_MODULE_MIXED_TYPE,1) != 0))
// {
// mAnalogModule = (CMixedModule*)mIOManager->GetModule(IO_MODULE_MIXED_TYPE,1);
// }
// else if(mDI710Module != 0)
// {
// mAnalogModule = mDI710Module;
// }
//Open advantech USB-4704 analog acquisition module.
CUSB4704Interface *USBAnalogModule = new CUSB4704Interface();
@ -514,57 +480,6 @@ unsigned int CZoneTest::InitZT()
mExtIOThread->start(QThread::NormalPriority);
bool UseModbusInterface = mZTSettings->mUseModbusCC;
// if(CZTConfigMgr::instance()->GetModbusCCEnabled() != ZT_CONFIG_MODBUS_ENABLE_FORCE_OFF)
// {
// if(CZTConfigMgr::instance()->GetModbusCCEnabled() == ZT_CONFIG_MODBUS_ENABLE_FORCE_ON)
// {
// CEngLog::instance()->AddLogString("Interface Modbus activée (forcée)",1);
// UseModbusInterface = true;
// }
// else
// {
//// //autodetect modbus interface...
// int ModbusPort = CZTConfigMgr::instance()->GetModbusCCPort();
// mWelcomePagePtr->InsertTextBoxString(QString("Détection Modbus CC..."));
// if(CModbusCCMgr::CheckForCCPartner(3000,ModbusPort) == true)
// {
// UseModbusInterface = true;
// mWelcomePagePtr->InsertTextBoxString(QString("Modbus CC détecté et activé"));
// }
// else
// {
// mWelcomePagePtr->InsertTextBoxString(QString("Modbus CC non-détecté"));
// }
//// CEngLog::instance()->AddLogString("Auto-Détection de l'interface Modbus",1);
//// QString IFName = CZTConfigMgr::instance()->GetModbusCCIFName();
//// if(IFName != "INVALID")
//// {
//// QString CarrierFile = QString("/sys/class/net/%1/carrier").arg(IFName);
//// QFile *EthIfStateFile = new QFile(CarrierFile);
//// if(EthIfStateFile)
//// {
//// CEngLog::instance()->AddLogString(QString("Ouverture du fichier %1 ...").arg(IFName),3);
//// if(EthIfStateFile->open(QIODevice::ReadOnly | QIODevice::Text) == true)
//// {
//// QByteArray val = EthIfStateFile->readAll();
//// QString State(val);
//// if(State.contains("1"))
//// {
//// CZTLog::instance()->AddLogString(QString("Connexion Ethernet CC détectée sur %1").arg(IFName),true);
//// UseModbusInterface = true;
//// }
//// else
//// {
//// CZTLog::instance()->AddLogString(QString("Connexion Ethernet CC inactive ou non-détectée sur %1").arg(IFName),true);
//// }
//// EthIfStateFile->close();
//// }
//// delete EthIfStateFile;
//// }
//// }
// }
// }
if(UseModbusInterface == true)
{
@ -680,6 +595,33 @@ unsigned int CZoneTest::InitZT()
connect(mZTStateMachine,SIGNAL(NewTrainLogSaved(QString,bool)),&mSFTPManager,SLOT(NewTrainFileSaved(QString,bool)));
}
//Start Historien PI server
bool EnableHistorian = CZTConfigMgr::instance()->GetPIHistorianEnabled();
int PIHistorianPort = CZTConfigMgr::instance()->GetPIHistorianModbusPort();
int PIHistorianDevID = CZTConfigMgr::instance()->GetPIHistorianModbusDevID();
if(EnableHistorian == true)
{
mPIHistorianRepository = new CModbusRepository;
mPIHistorianRepository->AddHRDataMap(HISTORIAN_ZT_DATA_BASE_REG,HISTORIAN_MODBUS_ZT_TABLE_DATA_SIZE); //Add the ZT data map
mPIHistorianManager = new CPIHistorianManager(mPIHistorianRepository,PIHistorianPort,PIHistorianDevID);
if(UseModbusInterface)
{
connect(mModbusCCMgr,SIGNAL(ModbusCCConnected(qint32,qint32)),mPIHistorianManager,SLOT(HPCConnected(qint32,qint32)));
connect(mModbusCCMgr,SIGNAL(ModbusCCDisconnected()),mPIHistorianManager,SLOT(HPCDisconnected()));
connect(mModbusSEIMgr,SIGNAL(ModbusMasterConnected(qint32,qint32)),mPIHistorianManager,SLOT(SEIConnected(qint32,qint32)));
connect(mModbusSEIMgr,SIGNAL(ModbusMasterDisconnected()),mPIHistorianManager,SLOT(SEIDisconnected()));
}
mPIHistorianManager->UpdateDetectionFunctions(mZTSettings->mDetectionFunctionSettings);
mPIHistorianManager->UpdatePGTreshold(mZTSettings->mPGTreshold);
mPIHistorianManager->UpdateMaintenanceMode(false);
mPIHistorianManager->SetSystemStartDateTime(mZTStartDateTime);
mPIHistorianManager->StartPIHistorian();
}
if(mSimulationON == true)
{
#ifdef USE_REAL_ANALOG_EXTERNAL_MODULE
@ -1021,6 +963,9 @@ unsigned int CZoneTest::DetectionFunctionsConfigChanged(CZTDetectionFunctionConf
mZTSettingsFileMgr.SaveSettings(mZTSettings);
mEventMgr->UpdateEvents(mZTSettings->mDetectionFunctionSettings);
if(mPIHistorianManager != 0)
mPIHistorianManager->UpdateDetectionFunctions(NewConfig);
return RET_OK;
}
@ -1151,6 +1096,9 @@ unsigned int CZoneTest::SetPGTreshold(int NewTreshold)
mZTSettings->mPGTreshold = NewTreshold;
mZTSettingsFileMgr.SaveSettings(mZTSettings);
if(mPIHistorianManager != 0)
mPIHistorianManager->UpdatePGTreshold(NewTreshold);
return RET_OK;
}
@ -1160,6 +1108,11 @@ bool CZoneTest::EnterMaintenanceModeRequest()
if(mZTStateMachine->EnterMaintenanceMode() == RET_OK)
{
mEventMgr->AddSingleEvent(EVENT_MAINTENANCE);
if(mPIHistorianManager != 0)
{
mPIHistorianManager->UpdateMaintenanceMode(true);
}
return true;
}
else
@ -1178,6 +1131,11 @@ void CZoneTest::ExitMaintenanceModeRequest()
}
mZTStateMachine->QuitMaintenanceMode();
mEventMgr->RemoveSingleEvent(EVENT_MAINTENANCE);
if(mPIHistorianManager != 0)
{
mPIHistorianManager->UpdateMaintenanceMode(false);
}
}
unsigned int CZoneTest::ClearMaintenanceCurTKRequest()
@ -1499,6 +1457,23 @@ int CZoneTest::SetZT2InhibitionState(bool InhibitionON)
return RET_OK;
}
int CZoneTest::NewZT1Passage(CZTPassageInfo ZT1PassageInfo)
{
if(mPIHistorianManager != 0)
{
mPIHistorianManager->NewZT1Passage(ZT1PassageInfo);
}
return RET_OK;
}
int CZoneTest::NewZT2Passage(CZTPassageInfo ZT2PassageInfo)
{
if(mPIHistorianManager != 0)
{
mPIHistorianManager->NewZT2Passage(ZT2PassageInfo);
}
return RET_OK;
}
void CZoneTest::ApplicationQuit(int Reason)
{

View File

@ -61,6 +61,7 @@
#include "NetworkCfgMgr.h"
#include "NetDriveMgr.h"
#include "SFTPServerManager.h"
#include "PIHistorianManager.h"
#include "TCPProtocol.h"
@ -169,6 +170,8 @@ public:
//ZTStateMachine requests
int SetZT1InhibitionState(bool InhibitionON);
int SetZT2InhibitionState(bool InhibitionON);
int NewZT1Passage(CZTPassageInfo ZT1PassageInfo);
int NewZT2Passage(CZTPassageInfo ZT2PassageInfo);
@ -200,12 +203,13 @@ private:
CWatchdogCtrl *mInternalWatchdog;
bool mWatchdogEnabled;
CTKTransportInterface *mTKTransportInterface;
CModbusRepository *mCCModbusRepository, *mSEIModbusRepository;
CModbusRepository *mCCModbusRepository, *mSEIModbusRepository, *mPIHistorianRepository;
CModbusCCMgr *mModbusCCMgr;
CModbusSEIMgr *mModbusSEIMgr;
CNetworkCfgMgr mNetworkCfgMgr;
CNetDriveMgr mNetworkDriveMgr;
CSFTPServerManager mSFTPManager;
CPIHistorianManager *mPIHistorianManager;
QLocalSocket mACPISocket;
// CWatchdogCtrl mWatchdogCtrl;