Développement transfert des logs sur le réseau Exploitation
This commit is contained in:
parent
1380f16140
commit
7207362d5c
@ -63,6 +63,22 @@ MODBUS_SEI_DEVID=1
|
|||||||
#Port Modbus/TCP
|
#Port Modbus/TCP
|
||||||
MODBUS_SEI_PORT=502
|
MODBUS_SEI_PORT=502
|
||||||
|
|
||||||
|
#----------------------------------
|
||||||
|
#Paramètres du dossier partagé sur le réseau pour la copie des fichiers logs
|
||||||
|
#Path du dossier cible sur le réseau
|
||||||
|
NETWORK_SHARE_PATH=//192.168.50.110/TestZT
|
||||||
|
#Login pour accéder au drive
|
||||||
|
NETWORK_SHALRE_LOGIN=JF
|
||||||
|
#Mot de passe pour accéder au drive
|
||||||
|
NETWORK_SHARE_PASSWORD=signal77240
|
||||||
|
|
||||||
|
#Path du dossier cible sur le réseau
|
||||||
|
#NETWORK_SHARE_PATH=//ca01-sdg-fs03.metro.local/vers_corpo/CT
|
||||||
|
#Login pour accéder au drive
|
||||||
|
#NETWORK_SHALRE_LOGIN=service.controle_train
|
||||||
|
#Mot de passe pour accéder au drive
|
||||||
|
#NETWORK_SHARE_PASSWORD=SigN4lisat1On!77240?TraNsf3Rt@
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------
|
#----------------------------------
|
||||||
#Changer cette valeur à OUI ou NON pour activer le
|
#Changer cette valeur à OUI ou NON pour activer le
|
||||||
@ -80,9 +96,9 @@ ENGLOG=3
|
|||||||
#Une seule station doit être sélectionnée
|
#Une seule station doit être sélectionnée
|
||||||
|
|
||||||
#STATION=HONORE_BEAUGRAND
|
#STATION=HONORE_BEAUGRAND
|
||||||
#STATION=ANGRIGNON
|
STATION=ANGRIGNON
|
||||||
#STATION=HENRI_BOURASSA
|
#STATION=HENRI_BOURASSA
|
||||||
STATION=COTE_VERTU
|
#STATION=COTE_VERTU
|
||||||
#STATION=BERRI_UQAM
|
#STATION=BERRI_UQAM
|
||||||
#STATION=LONGUEIL
|
#STATION=LONGUEIL
|
||||||
#STATION=SAINT_MICHEL
|
#STATION=SAINT_MICHEL
|
||||||
|
|||||||
Binary file not shown.
6
ZT.pro
6
ZT.pro
@ -120,7 +120,8 @@ SOURCES += \
|
|||||||
sources/Modbus/NetworkCfgMgr.cpp \
|
sources/Modbus/NetworkCfgMgr.cpp \
|
||||||
sources/Modbus/ModbusSEIMgr.cpp \
|
sources/Modbus/ModbusSEIMgr.cpp \
|
||||||
sources/GuiElements/SEISettingsPage.cpp \
|
sources/GuiElements/SEISettingsPage.cpp \
|
||||||
sources/GuiElements/ModbusDisplayPage.cpp
|
sources/GuiElements/ModbusDisplayPage.cpp \
|
||||||
|
sources/NetDriveMgr.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
sources/MainPanel.h \
|
sources/MainPanel.h \
|
||||||
@ -241,7 +242,8 @@ HEADERS += \
|
|||||||
sources/Modbus/ModbusSEIMgr.h \
|
sources/Modbus/ModbusSEIMgr.h \
|
||||||
sources/Modbus/ModbusSEIDefs.h \
|
sources/Modbus/ModbusSEIDefs.h \
|
||||||
sources/GuiElements/SEISettingsPage.h \
|
sources/GuiElements/SEISettingsPage.h \
|
||||||
sources/GuiElements/ModbusDisplayPage.h
|
sources/GuiElements/ModbusDisplayPage.h \
|
||||||
|
sources/NetDriveMgr.h
|
||||||
|
|
||||||
#QMAKE_LIBDIR += ./ExtLib
|
#QMAKE_LIBDIR += ./ExtLib
|
||||||
#QT += network
|
#QT += network
|
||||||
|
|||||||
@ -46,6 +46,7 @@
|
|||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include "RamMonitor.h"
|
#include "RamMonitor.h"
|
||||||
|
|
||||||
//#include <stdio.h>
|
//#include <stdio.h>
|
||||||
|
|
||||||
CEngineeringPage::~CEngineeringPage()
|
CEngineeringPage::~CEngineeringPage()
|
||||||
|
|||||||
@ -10,7 +10,8 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
/*
|
||||||
Description:
|
Description:
|
||||||
Affiche un bitmap d'une DEL verte (allumée ou éteinte).
|
Affiche un bitmap d'une prise verte lorsque la connexion est etablie ou
|
||||||
|
rouge lorsque la connexion est rompue.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@ -258,8 +258,9 @@ unsigned int CLogsListPage::DeleteAllFiles()
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLogsListPage::NewTrainLogFileSaved()
|
void CLogsListPage::NewTrainLogFileSaved(QString Filename)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(Filename)
|
||||||
RefreshList(true);
|
RefreshList(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -126,7 +126,7 @@ public slots:
|
|||||||
void LogsArchivingFinished();
|
void LogsArchivingFinished();
|
||||||
// void TableCurItemChanged(QTableWidgetItem*,QTableWidgetItem*);
|
// void TableCurItemChanged(QTableWidgetItem*,QTableWidgetItem*);
|
||||||
void LogsTableCellSelected(/*int, int*/);
|
void LogsTableCellSelected(/*int, int*/);
|
||||||
void NewTrainLogFileSaved();
|
void NewTrainLogFileSaved(QString);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
372
sources/NetDriveMgr.cpp
Normal file
372
sources/NetDriveMgr.cpp
Normal file
@ -0,0 +1,372 @@
|
|||||||
|
#include "NetDriveMgr.h"
|
||||||
|
#include <QFile>
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QDate>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// sudo mount -t cifs -o domain=TID,user=JF,password=signal77240,vers=2.1 //192.168.50.110/TestZT /home/zonetest/ZT/NetDrive
|
||||||
|
/// /proc/self/mountinfo
|
||||||
|
/// /proc/self/mounts
|
||||||
|
/// /sys/class/net/eth0
|
||||||
|
///
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CNetDriveMgr::CNetDriveMgr(QObject *parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
mNetDriveSMState = NET_DRIVE_MOUNTING_STATE;
|
||||||
|
mProcessTimer = new QTimer();
|
||||||
|
mProcessTimer->setSingleShot(true);
|
||||||
|
connect(mProcessTimer,SIGNAL(timeout()),this,SLOT(ProcessExecTimerExpired()));
|
||||||
|
|
||||||
|
mNASMountPath = NAS_MOUNT_POINT;
|
||||||
|
mNASMountPath.append("/");
|
||||||
|
|
||||||
|
mTransferProcess = new QProcess(this);
|
||||||
|
connect(mTransferProcess,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(ProcessFinished(int,QProcess::ExitStatus)));
|
||||||
|
|
||||||
|
mIsNetDriveEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CNetDriveMgr::~CNetDriveMgr()
|
||||||
|
{
|
||||||
|
delete mProcessTimer;
|
||||||
|
delete mTransferProcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CNetDriveMgr::IsNetworkDriveAvailable()
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
QFile *SysFile = new QFile("/sys/class/net/eth0/carrier");
|
||||||
|
if(SysFile)
|
||||||
|
{
|
||||||
|
SysFile->open(QIODevice::ReadOnly | QIODevice::Text | QIODevice::Unbuffered);
|
||||||
|
QString FileData = QString(SysFile->readAll());
|
||||||
|
SysFile->close();
|
||||||
|
|
||||||
|
if(FileData.isEmpty() == false)
|
||||||
|
{
|
||||||
|
if(FileData.left(1) == "1")
|
||||||
|
{
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
else if(FileData.left(1) == "0")
|
||||||
|
{
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = false;
|
||||||
|
qDebug("CNetDriveMgr: Valeur inatendue dans/sys/class/net/eth0/carrier");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete SysFile;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CNetDriveMgr::IsNetworkDriveMounted()
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
QFile *MountInfo = new QFile("/proc/self/mounts");
|
||||||
|
if(MountInfo)
|
||||||
|
{
|
||||||
|
MountInfo->open(QIODevice::ReadOnly | QIODevice::Text | QIODevice::Unbuffered);
|
||||||
|
QString FileData = QString(MountInfo->readAll());
|
||||||
|
MountInfo->close();
|
||||||
|
|
||||||
|
if(FileData.contains(NAS_MOUNT_POINT) == true)
|
||||||
|
{
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete MountInfo;
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int CNetDriveMgr::CopyFileToNetworkDrive(QString FilePath)
|
||||||
|
{
|
||||||
|
if(mIsNetDriveEnabled == false)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CNetDriveMgr::TransferTrainLogToNetDrive(QString NewLogFileName)
|
||||||
|
{
|
||||||
|
if(mIsNetDriveEnabled == false)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
if(mNetDriveSMState != NET_DRIVE_STANDBY_STATE)
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DestFilePath = NewLogFileName;
|
||||||
|
DestFilePath.prepend(mFilesPrefix + "-");
|
||||||
|
DestFilePath.prepend(mNASMountPath);
|
||||||
|
QString OriginFilePath = NewLogFileName;
|
||||||
|
OriginFilePath.prepend("./Trains/");
|
||||||
|
|
||||||
|
QString Cmd = QString ("cp -f %1 %2").arg(OriginFilePath).arg(DestFilePath);
|
||||||
|
|
||||||
|
|
||||||
|
mTransferProcess->start(Cmd);
|
||||||
|
mProcessTimer->start(PROCESS_TIMEOUT); //Allow some time to copy the file
|
||||||
|
mNetDriveSMState = NET_DRIVE_TRANSFERRING_TRAIN_LOG_STATE;
|
||||||
|
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CNetDriveMgr::TransferZTLogToNetDrive()
|
||||||
|
{
|
||||||
|
if(mIsNetDriveEnabled == false)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
|
||||||
|
QString DestFileDate = QDate::currentDate().toString("yyyyMMdd");
|
||||||
|
QString DestFilePath = QString("%1%2%3_LogZT.txt").arg(mNASMountPath).arg(mFilesPrefix).arg(DestFileDate);
|
||||||
|
QString OriginFilePath = QString("./LOG/LogZT.txt");
|
||||||
|
|
||||||
|
QString Cmd = QString ("cp -f %1 %2").arg(OriginFilePath).arg(DestFilePath);
|
||||||
|
|
||||||
|
|
||||||
|
mTransferProcess->start(Cmd);
|
||||||
|
mProcessTimer->start(PROCESS_TIMEOUT); //Allow some time to copy the file
|
||||||
|
mNetDriveSMState = NET_DRIVE_TRANSFERRING_ZT_LOG_STATE;
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CNetDriveMgr::NetworkDriveStateMachine(int Event)
|
||||||
|
{
|
||||||
|
switch(mNetDriveSMState)
|
||||||
|
{
|
||||||
|
case NET_DRIVE_STANDBY_STATE:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NET_DRIVE_TRANSFERRING_TRAIN_LOG_STATE:
|
||||||
|
{
|
||||||
|
switch(Event)
|
||||||
|
{
|
||||||
|
case NET_DRIVE_SM_PROCESS_TIMER_EXPIRED_EVENT:
|
||||||
|
{
|
||||||
|
//The network drive is stale or disconnected
|
||||||
|
mTransferProcess->kill();
|
||||||
|
mNetDriveSMState = NET_DRIVE_STANDBY_STATE;
|
||||||
|
qDebug("Failed to transfer train log file to NAS");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NET_DRIVE_SM_PROCESS_FINISHED_EVENT:
|
||||||
|
{
|
||||||
|
mProcessTimer->stop();
|
||||||
|
TransferZTLogToNetDrive();
|
||||||
|
qDebug("NAS transfer result: %s @ %s",qPrintable(mTransferProcess->readAllStandardOutput()),qPrintable(mTransferProcess->readAllStandardError()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NET_DRIVE_TRANSFERRING_ZT_LOG_STATE:
|
||||||
|
{
|
||||||
|
switch(Event)
|
||||||
|
{
|
||||||
|
case NET_DRIVE_SM_PROCESS_TIMER_EXPIRED_EVENT:
|
||||||
|
{
|
||||||
|
//The network drive is stale or disconnected
|
||||||
|
mTransferProcess->kill();
|
||||||
|
mNetDriveSMState = NET_DRIVE_STANDBY_STATE;
|
||||||
|
QString("Failed to transfer ZT log file to NAS");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NET_DRIVE_SM_PROCESS_FINISHED_EVENT:
|
||||||
|
{
|
||||||
|
mNetDriveSMState = NET_DRIVE_STANDBY_STATE;
|
||||||
|
qDebug("NAS transfer result: %s @ %s",qPrintable(mTransferProcess->readAllStandardOutput()),qPrintable(mTransferProcess->readAllStandardError()));
|
||||||
|
mProcessTimer->stop();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NET_DRIVE_TRASFERRING_MISC_FILE_STATE:
|
||||||
|
{
|
||||||
|
switch(Event)
|
||||||
|
{
|
||||||
|
case NET_DRIVE_SM_PROCESS_TIMER_EXPIRED_EVENT:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NET_DRIVE_SM_PROCESS_FINISHED_EVENT:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NET_DRIVE_MOUNTING_STATE:
|
||||||
|
{
|
||||||
|
switch(Event)
|
||||||
|
{
|
||||||
|
case NET_DRIVE_SM_PROCESS_TIMER_EXPIRED_EVENT:
|
||||||
|
{
|
||||||
|
qDebug("Failed to mount network drive within allowed period. Will retry later %s @ %s",qPrintable(mTransferProcess->readAllStandardOutput()),qPrintable(mTransferProcess->readAllStandardError()));
|
||||||
|
|
||||||
|
QString stdout = QString(mTransferProcess->readAllStandardOutput());
|
||||||
|
QString stderr = QString(mTransferProcess->readAllStandardError());
|
||||||
|
|
||||||
|
mTransferProcess->kill();
|
||||||
|
mNetDriveSMState = NET_DRIVE_RETRY_MOUNTING_STATE;
|
||||||
|
|
||||||
|
MountNetworkDrive();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NET_DRIVE_SM_PROCESS_FINISHED_EVENT:
|
||||||
|
{
|
||||||
|
QString StdOut = mTransferProcess->readAllStandardOutput();
|
||||||
|
qDebug("%s",qPrintable(StdOut));
|
||||||
|
mProcessTimer->stop();
|
||||||
|
|
||||||
|
if(IsNetworkDriveMounted())
|
||||||
|
{
|
||||||
|
qDebug("Drive mounted successfuly");
|
||||||
|
mNetDriveSMState = NET_DRIVE_STANDBY_STATE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("Mount command failed: %s @ %s",qPrintable(mTransferProcess->readAllStandardOutput()),qPrintable(mTransferProcess->readAllStandardError()));
|
||||||
|
mNetDriveSMState = NET_DRIVE_RETRY_MOUNTING_STATE;
|
||||||
|
mProcessTimer->start(MOUNT_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NET_DRIVE_RETRY_MOUNTING_STATE:
|
||||||
|
{
|
||||||
|
switch(Event)
|
||||||
|
{
|
||||||
|
case NET_DRIVE_SM_PROCESS_TIMER_EXPIRED_EVENT:
|
||||||
|
{
|
||||||
|
qDebug("Retrying to mount net drive");
|
||||||
|
MountNetworkDrive();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NET_DRIVE_SM_PROCESS_FINISHED_EVENT:
|
||||||
|
{
|
||||||
|
//Should not come here...
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CNetDriveMgr::ProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||||
|
{
|
||||||
|
Q_UNUSED(exitCode)
|
||||||
|
Q_UNUSED(exitStatus)
|
||||||
|
|
||||||
|
qDebug("Process finished %d - %d",exitCode,exitStatus);
|
||||||
|
NetworkDriveStateMachine(NET_DRIVE_SM_PROCESS_FINISHED_EVENT);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetDriveMgr::ProcessExecTimerExpired()
|
||||||
|
{
|
||||||
|
NetworkDriveStateMachine(NET_DRIVE_SM_PROCESS_TIMER_EXPIRED_EVENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CNetDriveMgr::InitNetDriveMgr(bool Enabled, QString RemoteAccessPath, QString RemoteLogin, QString RemotePwd, QString RemoteDomain, QString FilenamePrefix)
|
||||||
|
{
|
||||||
|
if(Enabled == false)
|
||||||
|
{
|
||||||
|
mIsNetDriveEnabled = false;
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
mIsNetDriveEnabled = true;
|
||||||
|
|
||||||
|
mRemoteDriveAccessPath = RemoteAccessPath;
|
||||||
|
mRemoteDriveLogin = RemoteLogin;
|
||||||
|
mRemoteDrivePassword = RemotePwd;
|
||||||
|
mRemoteDriveDomain = RemoteDomain;
|
||||||
|
mFilesPrefix = FilenamePrefix;
|
||||||
|
|
||||||
|
MountNetworkDrive();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int CNetDriveMgr::MountNetworkDrive()
|
||||||
|
{
|
||||||
|
if(mIsNetDriveEnabled == false)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
if(IsNetworkDriveMounted())
|
||||||
|
{
|
||||||
|
qDebug("Network drive already mounted, aborting mount operation");
|
||||||
|
mNetDriveSMState = NET_DRIVE_STANDBY_STATE;
|
||||||
|
return RET_ERROR; //drive already mounted.
|
||||||
|
}
|
||||||
|
|
||||||
|
if(IsNetworkDriveAvailable() == false) //Network is disconnected... retry later.
|
||||||
|
{
|
||||||
|
qDebug("Network interface not connected. Cannot mount network drive. Will retry later");
|
||||||
|
mNetDriveSMState = NET_DRIVE_RETRY_MOUNTING_STATE;
|
||||||
|
mProcessTimer->start(MOUNT_TIMEOUT);
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
//sudo mount -t cifs -o domain=TID,user=JF,password=signal77240,vers=2.1 //192.168.50.110/TestZT /home/zonetest/ZT/NetDrive
|
||||||
|
|
||||||
|
qDebug("Trying to mount network drive");
|
||||||
|
QString Cmd;
|
||||||
|
if(mRemoteDriveDomain.isEmpty())
|
||||||
|
Cmd = QString("mount -t cifs -o user=%2,password=%3,vers=2.1 %4 %5").arg(mRemoteDriveLogin).arg(mRemoteDrivePassword).arg(mRemoteDriveAccessPath).arg(NAS_MOUNT_POINT);
|
||||||
|
else
|
||||||
|
Cmd = QString("mount -t cifs -o domain=%1,user=%2,password=%3,vers=2.1 %4 %5").arg(mRemoteDriveDomain).arg(mRemoteDriveLogin).arg(mRemoteDrivePassword).arg(mRemoteDriveAccessPath).arg(NAS_MOUNT_POINT);
|
||||||
|
|
||||||
|
mTransferProcess->start(Cmd);
|
||||||
|
mNetDriveSMState = NET_DRIVE_MOUNTING_STATE;
|
||||||
|
mProcessTimer->start(MOUNT_TIMEOUT);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CNetDriveMgr::UnMountNetworkDrive()
|
||||||
|
{
|
||||||
|
if(mIsNetDriveEnabled == false)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
if(IsNetworkDriveMounted() == false)
|
||||||
|
{
|
||||||
|
qDebug("Network drive not mounted, aborting unmount operation");
|
||||||
|
mNetDriveSMState = NET_DRIVE_MOUNTING_STATE;
|
||||||
|
return RET_ERROR; //drive already mounted.
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Cmd = QString("umount %1").arg(NAS_MOUNT_POINT);
|
||||||
|
QProcess::startDetached(Cmd);
|
||||||
|
mNetDriveSMState = NET_DRIVE_MOUNTING_STATE;
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetDriveMgr::NewTrainFileSaved(QString filename)
|
||||||
|
{
|
||||||
|
TransferTrainLogToNetDrive(filename);
|
||||||
|
}
|
||||||
72
sources/NetDriveMgr.h
Normal file
72
sources/NetDriveMgr.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#ifndef NETDRIVEMGR_H
|
||||||
|
#define NETDRIVEMGR_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
enum eNetworkDriveSMStates
|
||||||
|
{
|
||||||
|
NET_DRIVE_STANDBY_STATE,
|
||||||
|
NET_DRIVE_TRANSFERRING_TRAIN_LOG_STATE,
|
||||||
|
NET_DRIVE_TRANSFERRING_ZT_LOG_STATE,
|
||||||
|
NET_DRIVE_TRASFERRING_MISC_FILE_STATE,
|
||||||
|
NET_DRIVE_MOUNTING_STATE,
|
||||||
|
NET_DRIVE_RETRY_MOUNTING_STATE,
|
||||||
|
|
||||||
|
NET_DRIVE_MAX_STATE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eNetworkDriveSMEvents
|
||||||
|
{
|
||||||
|
NET_DRIVE_SM_PROCESS_TIMER_EXPIRED_EVENT,
|
||||||
|
NET_DRIVE_SM_PROCESS_FINISHED_EVENT,
|
||||||
|
|
||||||
|
NET_DRIVE_SM_MAX_EVENT
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define NAS_MOUNT_POINT "/home/zonetest/ZT/NetDrive"
|
||||||
|
#define PROCESS_TIMEOUT 10000 //ms
|
||||||
|
#define MOUNT_TIMEOUT 10000
|
||||||
|
|
||||||
|
class CNetDriveMgr : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit CNetDriveMgr(QObject *parent = 0);
|
||||||
|
~CNetDriveMgr();
|
||||||
|
|
||||||
|
bool IsNetworkDriveMounted();
|
||||||
|
bool IsNetworkDriveAvailable();
|
||||||
|
int CopyFileToNetworkDrive(QString FilePath);
|
||||||
|
int TransferTrainLogToNetDrive(QString NewLogFileName);
|
||||||
|
int TransferZTLogToNetDrive();
|
||||||
|
int InitNetDriveMgr(bool Enabled,QString RemoteAccessPath, QString RemoteLogin, QString RemotePwd, QString RemoteDomain, QString FilenamePrefix);
|
||||||
|
int MountNetworkDrive();
|
||||||
|
int UnMountNetworkDrive();
|
||||||
|
|
||||||
|
int NetworkDriveStateMachine(int Event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString mRemoteDriveAccessPath;
|
||||||
|
QString mRemoteDriveLogin;
|
||||||
|
QString mRemoteDrivePassword;
|
||||||
|
QString mRemoteDriveDomain;
|
||||||
|
QString mNASMountPath;
|
||||||
|
QString mFilesPrefix;
|
||||||
|
int mNetDriveSMState;
|
||||||
|
QProcess *mTransferProcess;
|
||||||
|
QTimer *mProcessTimer;
|
||||||
|
bool mIsNetDriveEnabled;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ProcessExecTimerExpired();
|
||||||
|
void ProcessFinished( int exitCode, QProcess::ExitStatus exitStatus);
|
||||||
|
void NewTrainFileSaved(QString filename);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NETDRIVEMGR_H
|
||||||
@ -60,6 +60,7 @@ CZTStateMachine::CZTStateMachine(CZoneTest *ZTPtr, QObject *parent) :
|
|||||||
mLogMgr = 0;
|
mLogMgr = 0;
|
||||||
mCalibrationPassagesCount = 0;
|
mCalibrationPassagesCount = 0;
|
||||||
mModbusCCMgr = 0;
|
mModbusCCMgr = 0;
|
||||||
|
//mNetworkDriveMgr = 0;
|
||||||
//mExtIOInterface = 0;
|
//mExtIOInterface = 0;
|
||||||
|
|
||||||
mNbPassages = 0;
|
mNbPassages = 0;
|
||||||
@ -1497,6 +1498,11 @@ void CZTStateMachine::BindModbusCCMgrPtr(CModbusCCMgr *ModbusCCPtr)
|
|||||||
mModbusCCMgr = ModbusCCPtr;
|
mModbusCCMgr = ModbusCCPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void CZTStateMachine::BindNetworkDrivePtr(CNetDriveMgr *mNetDrivePtr)
|
||||||
|
//{
|
||||||
|
// mNetDrivePtr = mNetDrivePtr;
|
||||||
|
//}
|
||||||
|
|
||||||
unsigned int CZTStateMachine::SetPGTreshold(qint32 PGTreshold)
|
unsigned int CZTStateMachine::SetPGTreshold(qint32 PGTreshold)
|
||||||
{
|
{
|
||||||
mZT1WorkerThread->SetPGTreshold(PGTreshold);
|
mZT1WorkerThread->SetPGTreshold(PGTreshold);
|
||||||
@ -1702,24 +1708,27 @@ unsigned int CZTStateMachine::DestroyCalibrationData()
|
|||||||
unsigned int CZTStateMachine::SaveZT1EventsLog(CZT1Log *Log)
|
unsigned int CZTStateMachine::SaveZT1EventsLog(CZT1Log *Log)
|
||||||
{
|
{
|
||||||
|
|
||||||
QString FileName1 = "./Trains/LOGZT1_";
|
QString FileName1 = "LOGZT1_";
|
||||||
FileName1 += QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss-zzz");
|
FileName1 += QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss-zzz");
|
||||||
QString FileName = FileName1 + ".bin";
|
QString FileName = FileName1 + ".bin";
|
||||||
|
QString FilePath = FileName;
|
||||||
|
FilePath.prepend("./Trains/");
|
||||||
qDebug("%s",FileName.toAscii().data());
|
qDebug("%s",FileName.toAscii().data());
|
||||||
|
|
||||||
CTrainLogFileMgr::instance()->SaveTrainLog(FileName,Log,&mZT1DetectionsLog,mZTStationPtr->GetStationTextualName());
|
CTrainLogFileMgr::instance()->SaveTrainLog(FilePath,Log,&mZT1DetectionsLog,mZTStationPtr->GetStationTextualName());
|
||||||
mLogMgr->ParseNewLog(FileName);
|
mLogMgr->ParseNewLog(FilePath);
|
||||||
|
|
||||||
|
|
||||||
if(mAutoExportZT1CSV)
|
if(mAutoExportZT1CSV)
|
||||||
{
|
{
|
||||||
FileName = FileName1 + ".csv";
|
FilePath = FileName1 + ".csv";
|
||||||
CTrainLogFileMgr::instance()->SaveCSVFile(FileName,Log,&mZT1DetectionsLog,mZTStationPtr->GetStationTextualName());
|
FilePath.prepend("./Trains/");
|
||||||
|
CTrainLogFileMgr::instance()->SaveCSVFile(FilePath,Log,&mZT1DetectionsLog,mZTStationPtr->GetStationTextualName());
|
||||||
}
|
}
|
||||||
|
|
||||||
DestroyZT1Log();
|
DestroyZT1Log();
|
||||||
|
|
||||||
emit NewTrainLogSaved();
|
emit NewTrainLogSaved(FileName);
|
||||||
|
|
||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
@ -1727,23 +1736,26 @@ unsigned int CZTStateMachine::SaveZT1EventsLog(CZT1Log *Log)
|
|||||||
|
|
||||||
unsigned int CZTStateMachine::SaveZT2EventsLog(CZT2Log *Log)
|
unsigned int CZTStateMachine::SaveZT2EventsLog(CZT2Log *Log)
|
||||||
{
|
{
|
||||||
QString FileName1 = "./Trains/LOGZT2_";
|
QString FileName1 = "LOGZT2_";
|
||||||
FileName1 += QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss-zzz");
|
FileName1 += QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss-zzz");
|
||||||
QString FileName = FileName1 + ".bin";
|
QString FileName = FileName1 + ".bin";
|
||||||
|
QString FilePath = FileName;
|
||||||
|
FilePath.prepend("./Trains/");
|
||||||
qDebug("%s",FileName.toAscii().data());
|
qDebug("%s",FileName.toAscii().data());
|
||||||
|
|
||||||
CTrainLogFileMgr::instance()->SaveTrainLog(FileName,Log,&mZT2DetectionsLog,mZTStationPtr->GetStationTextualName());
|
CTrainLogFileMgr::instance()->SaveTrainLog(FilePath,Log,&mZT2DetectionsLog,mZTStationPtr->GetStationTextualName());
|
||||||
mLogMgr->ParseNewLog(FileName);
|
mLogMgr->ParseNewLog(FilePath);
|
||||||
|
|
||||||
if(mAutoExportZT2CSV)
|
if(mAutoExportZT2CSV)
|
||||||
{
|
{
|
||||||
FileName = FileName1 + ".csv";
|
FilePath = FileName1 + ".csv";
|
||||||
CTrainLogFileMgr::instance()->SaveCSVFile(FileName,Log,&mZT2DetectionsLog,mZTStationPtr->GetStationTextualName());
|
FilePath.prepend("./Trains/");
|
||||||
|
CTrainLogFileMgr::instance()->SaveCSVFile(FilePath,Log,&mZT2DetectionsLog,mZTStationPtr->GetStationTextualName());
|
||||||
}
|
}
|
||||||
|
|
||||||
DestroyZT2Log();
|
DestroyZT2Log();
|
||||||
|
|
||||||
emit NewTrainLogSaved();
|
emit NewTrainLogSaved(FileName);
|
||||||
|
|
||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
|
|||||||
@ -46,6 +46,7 @@
|
|||||||
//#include "ModbusRepository.h"
|
//#include "ModbusRepository.h"
|
||||||
#include "TKTransportInterface.h"
|
#include "TKTransportInterface.h"
|
||||||
#include "ModbusCCMgr.h"
|
#include "ModbusCCMgr.h"
|
||||||
|
#include "NetDriveMgr.h"
|
||||||
|
|
||||||
|
|
||||||
#define ZT_SM_DEFAULT_LOG_DELAY 10 //millilseconds
|
#define ZT_SM_DEFAULT_LOG_DELAY 10 //millilseconds
|
||||||
@ -108,6 +109,7 @@ public:
|
|||||||
unsigned int ZTStateMachine(unsigned int Event, unsigned int SubEvent = 0); //Exécution de la SM principale
|
unsigned int ZTStateMachine(unsigned int Event, unsigned int SubEvent = 0); //Exécution de la SM principale
|
||||||
void BindPointers(CStation *ptr,CInputModule *InputModule,COutputModule *OutputModule,CZTPage *ZTPagePTr,CPCIIOMgr *PCIIOPtr,CAbstractLazerProbe *PGIntProbePtr, CAbstractLazerProbe *PGExtProbePTr,CLogMgr *LogMgr,CTKTransportInterface *TKTransport,CZTSimulator *ZTSimPtr = 0,CAnalogInputModule *DataQInterface = 0); //Assignation de pointeurs
|
void BindPointers(CStation *ptr,CInputModule *InputModule,COutputModule *OutputModule,CZTPage *ZTPagePTr,CPCIIOMgr *PCIIOPtr,CAbstractLazerProbe *PGIntProbePtr, CAbstractLazerProbe *PGExtProbePTr,CLogMgr *LogMgr,CTKTransportInterface *TKTransport,CZTSimulator *ZTSimPtr = 0,CAnalogInputModule *DataQInterface = 0); //Assignation de pointeurs
|
||||||
void BindModbusCCMgrPtr(CModbusCCMgr *ModbusCCPtr);
|
void BindModbusCCMgrPtr(CModbusCCMgr *ModbusCCPtr);
|
||||||
|
// void BindNetworkDrivePtr(CNetDriveMgr *mNetDrivePtr);
|
||||||
|
|
||||||
CZTDetectionFunctionConfig *mZTDetectionConfig;
|
CZTDetectionFunctionConfig *mZTDetectionConfig;
|
||||||
CTKGenerator *mTKGenerator; //pointeur vers la classe qui gère les alarmes au PCC
|
CTKGenerator *mTKGenerator; //pointeur vers la classe qui gère les alarmes au PCC
|
||||||
@ -178,6 +180,7 @@ private:
|
|||||||
CInputModule *mInputModule;
|
CInputModule *mInputModule;
|
||||||
// CModbusRepository *mCCModbusRepo;
|
// CModbusRepository *mCCModbusRepo;
|
||||||
CModbusCCMgr *mModbusCCMgr;
|
CModbusCCMgr *mModbusCCMgr;
|
||||||
|
// CNetDriveMgr *mNetworkDriveMgr;
|
||||||
|
|
||||||
|
|
||||||
CPCIIOMgr *mPCIIOPtr;
|
CPCIIOMgr *mPCIIOPtr;
|
||||||
@ -231,7 +234,7 @@ signals:
|
|||||||
void PGCalibrationFinished(int); //Signal envoyé lorsque la calibration est terminée. Le paramètre est la valeur calculée.
|
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.
|
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.
|
||||||
void MaintenancePPActivated(unsigned int); //Signal envoyé à la page d'entretien pour indiquer qu'une pédale PP a été activée.
|
void MaintenancePPActivated(unsigned int); //Signal envoyé à la page d'entretien pour indiquer qu'une pédale PP a été activée.
|
||||||
void NewTrainLogSaved(); //Signal envoyé pour notifier l'interface graphique qu'un nouveau fichier de passage a été sauvegardé.
|
void NewTrainLogSaved(QString Filename); //Signal envoyé pour notifier l'interface graphique qu'un nouveau fichier de passage a été sauvegardé.
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
|||||||
@ -29,9 +29,12 @@
|
|||||||
#ifndef ZTVERSION_H
|
#ifndef ZTVERSION_H
|
||||||
#define ZTVERSION_H
|
#define ZTVERSION_H
|
||||||
|
|
||||||
#define ZT_SOFT_VERSION "V1.24"
|
#define ZT_SOFT_VERSION "V1.25"
|
||||||
|
|
||||||
//LOG DES CHANGEMENTS
|
//LOG DES CHANGEMENTS
|
||||||
|
//Version 1.25
|
||||||
|
//-Ajout de la fonctionnalité de transfert des fichiers de passage sur le réseau
|
||||||
|
|
||||||
//Version 1.24
|
//Version 1.24
|
||||||
//-Changements à la station Côte-Vertu pour la nouvelle configuration de la ZT.
|
//-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
|
//-Correction d'un petit bug qui ne permettait pas d'avoir le bon itinéraire dans les
|
||||||
|
|||||||
@ -288,7 +288,9 @@ unsigned int CZoneTest::Start()
|
|||||||
// mEventMgr->UpdateEvents(mZTSettings->mDetectionFunctionSettings);
|
// mEventMgr->UpdateEvents(mZTSettings->mDetectionFunctionSettings);
|
||||||
|
|
||||||
mZTStateMachine->mZTDetectionConfig = mZTSettings->mDetectionFunctionSettings;
|
mZTStateMachine->mZTDetectionConfig = mZTSettings->mDetectionFunctionSettings;
|
||||||
connect(mZTStateMachine,SIGNAL(NewTrainLogSaved()),panel.mLogsListPage,SLOT(NewTrainLogFileSaved()));
|
connect(mZTStateMachine,SIGNAL(NewTrainLogSaved(QString)),panel.mLogsListPage,SLOT(NewTrainLogFileSaved(QString)));
|
||||||
|
|
||||||
|
connect(mZTStateMachine,SIGNAL(NewTrainLogSaved(QString)),&mNetworkDriveMgr,SLOT(NewTrainFileSaved(QString)));
|
||||||
|
|
||||||
CZTLog::instance()->mProgramHandle = this;
|
CZTLog::instance()->mProgramHandle = this;
|
||||||
|
|
||||||
@ -640,6 +642,7 @@ unsigned int CZoneTest::InitZT()
|
|||||||
panel.mZTMainPage->mZT2Stats->Init(true);
|
panel.mZTMainPage->mZT2Stats->Init(true);
|
||||||
|
|
||||||
|
|
||||||
|
mNetworkDriveMgr.InitNetDriveMgr(true,"//192.168.50.110/TestZT","JF","signal77240","",mZTStation->GetStationShortName());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -652,6 +655,7 @@ unsigned int CZoneTest::InitZT()
|
|||||||
TransportInterface->BindPointers(mZTStation->GetOutputMasks(),mExtIOWorkerThread);
|
TransportInterface->BindPointers(mZTStation->GetOutputMasks(),mExtIOWorkerThread);
|
||||||
panel.mZTMainPage->mZT1Stats->Init(false);
|
panel.mZTMainPage->mZT1Stats->Init(false);
|
||||||
panel.mZTMainPage->mZT2Stats->Init(false);
|
panel.mZTMainPage->mZT2Stats->Init(false);
|
||||||
|
mNetworkDriveMgr.InitNetDriveMgr(false,"","","","","");
|
||||||
}
|
}
|
||||||
connect(mTKTransportInterface,SIGNAL(TKOutputStatesChanged(bool,bool)),panel.mMaintenancePage,SLOT(TKOutputChanged(bool,bool)));
|
connect(mTKTransportInterface,SIGNAL(TKOutputStatesChanged(bool,bool)),panel.mMaintenancePage,SLOT(TKOutputChanged(bool,bool)));
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,7 @@
|
|||||||
#include "ModbusCCMgr.h"
|
#include "ModbusCCMgr.h"
|
||||||
#include "ModbusSEIMgr.h"
|
#include "ModbusSEIMgr.h"
|
||||||
#include "NetworkCfgMgr.h"
|
#include "NetworkCfgMgr.h"
|
||||||
|
#include "NetDriveMgr.h"
|
||||||
|
|
||||||
#include "TCPProtocol.h"
|
#include "TCPProtocol.h"
|
||||||
|
|
||||||
@ -201,6 +202,7 @@ private:
|
|||||||
CModbusCCMgr *mModbusCCMgr;
|
CModbusCCMgr *mModbusCCMgr;
|
||||||
CModbusSEIMgr *mModbusSEIMgr;
|
CModbusSEIMgr *mModbusSEIMgr;
|
||||||
CNetworkCfgMgr mNetworkCfgMgr;
|
CNetworkCfgMgr mNetworkCfgMgr;
|
||||||
|
CNetDriveMgr mNetworkDriveMgr;
|
||||||
|
|
||||||
QLocalSocket mACPISocket;
|
QLocalSocket mACPISocket;
|
||||||
// CWatchdogCtrl mWatchdogCtrl;
|
// CWatchdogCtrl mWatchdogCtrl;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user