Premier commit
This commit is contained in:
@@ -0,0 +1,264 @@
|
||||
#include "DirParserThread.h"
|
||||
#include "ZTData.h"
|
||||
#include "GlobalDefine.h"
|
||||
#include "QString"
|
||||
#include "QStringList"
|
||||
#include <QDate>
|
||||
|
||||
|
||||
|
||||
void CDirParserThread::ParseDirectories()
|
||||
{
|
||||
// if(mRootDir.absolutePath().isEmpty() == true)
|
||||
// {
|
||||
// emit ParsingFinished(0);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// ParseDir(mRootDir,mKeepData);
|
||||
mMutex.lockForWrite();
|
||||
mExecThread = true;
|
||||
mMutex.unlock();
|
||||
GatherReportData(mReportSettings,mReportFilters);
|
||||
|
||||
// emit ParsingFinished(1);
|
||||
qDebug("Worker thread finished");
|
||||
|
||||
|
||||
}
|
||||
|
||||
CDirParserThread::CDirParserThread()
|
||||
{
|
||||
mExecThread = true;
|
||||
//Allocate a directory list for each station.
|
||||
for(int i = 0; i < NB_ZT_ID; i++)
|
||||
{
|
||||
mReportDirectoriesList.append(QStringList());
|
||||
}
|
||||
}
|
||||
|
||||
void CDirParserThread::GatherReportData(CReportProgramSettingsData ReportSettings, CReportConfigData ReportFilters)
|
||||
{
|
||||
//First, get a list of the filtered directories
|
||||
for(int i = 0; i < NB_ZT_ID; i++)
|
||||
{
|
||||
mReportDirectoriesList[i].clear();
|
||||
}
|
||||
|
||||
for(int i = 0; i < ReportSettings.mDataSourceDirectoryPaths.size(); i++)
|
||||
{
|
||||
QString BaseDir(ReportSettings.mDataSourceDirectoryPaths.at(i));
|
||||
if(ReportFilters.mReportStationAngrignon == true)
|
||||
{
|
||||
QDir AngDir(QString("%1/ANG/").arg(BaseDir));
|
||||
mReportDirectoriesList[ANGRIGNON_ZT_ID].append(FilterDirectories(AngDir,ReportFilters.mReportStartDate,ReportFilters.mReportEndDate));
|
||||
}
|
||||
if(ReportFilters.mReportStationBeaugrand == true)
|
||||
{
|
||||
QDir Dir(QString("%1/HBGR/").arg(BaseDir));
|
||||
mReportDirectoriesList[HONORE_BEAUGRAND_ZT_ID].append(FilterDirectories(Dir,ReportFilters.mReportStartDate,ReportFilters.mReportEndDate));
|
||||
}
|
||||
if(ReportFilters.mReportStationVertu == true)
|
||||
{
|
||||
QDir Dir(QString("%1/CVRT/").arg(BaseDir));
|
||||
mReportDirectoriesList[COTE_VERTU_ZT_ID].append(FilterDirectories(Dir,ReportFilters.mReportStartDate,ReportFilters.mReportEndDate));
|
||||
}
|
||||
if(ReportFilters.mReportStationBourassa == true)
|
||||
{
|
||||
QDir Dir(QString("%1/HBOU/").arg(BaseDir));
|
||||
mReportDirectoriesList[HENRI_BOURASSA_ZT_ID].append(FilterDirectories(Dir,ReportFilters.mReportStartDate,ReportFilters.mReportEndDate));
|
||||
}
|
||||
if(ReportFilters.mReportStationMontmorency == true)
|
||||
{
|
||||
QDir Dir(QString("%1/MMO/").arg(BaseDir));
|
||||
mReportDirectoriesList[MONTMORENCY_ZT_ID].append(FilterDirectories(Dir,ReportFilters.mReportStartDate,ReportFilters.mReportEndDate));
|
||||
}
|
||||
if(ReportFilters.mReportStationBerri == true)
|
||||
{
|
||||
QDir Dir(QString("%1/BUQ4/").arg(BaseDir));
|
||||
mReportDirectoriesList[BERRI_UQAM_ZT_ID].append(FilterDirectories(Dir,ReportFilters.mReportStartDate,ReportFilters.mReportEndDate));
|
||||
}
|
||||
if(ReportFilters.mReportStationLongueuil == true)
|
||||
{
|
||||
QDir Dir(QString("%1/LONG/").arg(BaseDir));
|
||||
mReportDirectoriesList[LONGUEUIL_ZT_ID].append(FilterDirectories(Dir,ReportFilters.mReportStartDate,ReportFilters.mReportEndDate));
|
||||
}
|
||||
if(ReportFilters.mReportStationStMichel == true)
|
||||
{
|
||||
QDir Dir(QString("%1/SMIC/").arg(BaseDir));
|
||||
mReportDirectoriesList[SAINT_MICHEL_ZT_ID].append(FilterDirectories(Dir,ReportFilters.mReportStartDate,ReportFilters.mReportEndDate));
|
||||
}
|
||||
if(ReportFilters.mReportStationSnowdon == true)
|
||||
{
|
||||
QDir Dir(QString("%1/SNW5/").arg(BaseDir));
|
||||
mReportDirectoriesList[SNOWDON_ZT_ID].append(FilterDirectories(Dir,ReportFilters.mReportStartDate,ReportFilters.mReportEndDate));
|
||||
}
|
||||
}
|
||||
|
||||
//Check if we found any directory...
|
||||
bool found = false;
|
||||
for(int i = 0; i < mReportDirectoriesList.size(); i++)
|
||||
{
|
||||
if(mReportDirectoriesList.at(i).isEmpty() == false)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(found == false)
|
||||
{
|
||||
emit ReportProgressStatus("Aucun log correspondant aux filtres n'a été trouvé");
|
||||
emit ParsingFinished(0);
|
||||
return;
|
||||
}
|
||||
|
||||
//Now, parse each directory and collect data from ZT files.
|
||||
for(int station = 0; station < mReportDirectoriesList.size(); station++)
|
||||
{
|
||||
if(mReportDirectoriesList[station].isEmpty() == false)
|
||||
{
|
||||
|
||||
QList<CLogElement*> *Container = mReportDataContainer->at(station);
|
||||
for(int dir =0; dir < mReportDirectoriesList[station].size(); dir++)
|
||||
{
|
||||
mMutex.lockForRead();
|
||||
bool Run = mExecThread;
|
||||
mMutex.unlock();
|
||||
|
||||
if(Run == false)
|
||||
{
|
||||
emit ThreadAborted();
|
||||
return;
|
||||
}
|
||||
emit ReportProgressStatus(QString("Analyse des fichiers du répertoire %1").arg(mReportDirectoriesList[station].at(dir)));
|
||||
ParseDir(QDir(mReportDirectoriesList[station].at(dir)),Container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit ParsingFinished(1);
|
||||
}
|
||||
|
||||
QStringList CDirParserThread::FilterDirectories(QDir BaseDir, QDate StartDate, QDate EndDate)
|
||||
{
|
||||
QStringList OutputList;
|
||||
OutputList.clear();
|
||||
|
||||
BaseDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
BaseDir.setSorting(QDir::Name);
|
||||
//QStringList DirList = BaseDir.entryList();
|
||||
QFileInfoList DirList = BaseDir.entryInfoList();
|
||||
for(int i = 0; i < DirList.size(); i++)
|
||||
{
|
||||
QString curDir = DirList.at(i).absoluteFilePath();
|
||||
// QStringList DirNameChunks = curDir.split(BaseDir.separator());
|
||||
// if(!DirNameChunks.isEmpty())
|
||||
{
|
||||
//QDate DirDate;
|
||||
QString DirDateString = DirList.at(i).baseName().right(8);
|
||||
QDate DirDate = QDate::fromString(DirDateString,"yyyyMMdd");
|
||||
|
||||
//Check if the directory is in the date range
|
||||
if(DirDate <= EndDate && DirDate >= StartDate)
|
||||
{
|
||||
OutputList.append(curDir);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return OutputList;
|
||||
}
|
||||
|
||||
int CDirParserThread::ParseDir(QDir dir, QList<CLogElement *> *Container)
|
||||
{
|
||||
mMutex.lockForRead();
|
||||
bool Run = mExecThread;
|
||||
mMutex.unlock();
|
||||
if(Run == false)
|
||||
{
|
||||
emit ThreadAborted();
|
||||
return 0;
|
||||
}
|
||||
|
||||
QStringList LogFilters;
|
||||
QFileInfoList list;
|
||||
// QString LogDataDir = mProgramHandle->GetLogDataPath();
|
||||
LogFilters << "*.bin";
|
||||
|
||||
//Load files in base directory
|
||||
QDir LogDir(dir);
|
||||
LogDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||
LogDir.setNameFilters(LogFilters);
|
||||
LogDir.setSorting(QDir::Name);
|
||||
list = LogDir.entryInfoList();
|
||||
if(list.size() != 0)
|
||||
{
|
||||
//Extract data for each passage
|
||||
for(int i = 0; i < list.size(); i++)
|
||||
{
|
||||
mMutex.lockForRead();
|
||||
bool Run = mExecThread;
|
||||
mMutex.unlock();
|
||||
|
||||
if(Run == false)
|
||||
{
|
||||
emit ThreadAborted();
|
||||
return 0;
|
||||
}
|
||||
//ParseNewLog(list.at(i).filePath(),KeepData);
|
||||
unsigned int ret;
|
||||
|
||||
// emit ReportProgressStatus(QString("Analyse du fichiers %1").arg(list.at(i).fileName()));
|
||||
CLogElement *NewLog = CTrainLogFileMgr::instance()->OpenTrainLog(list.at(i).filePath(),ret);
|
||||
if(ret == RET_OK)
|
||||
{
|
||||
emit NewLogParsed(NewLog);
|
||||
mMutex.lockForWrite();
|
||||
Container->append(NewLog);
|
||||
mMutex.unlock();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emit EmptyDirParsed();
|
||||
}
|
||||
|
||||
|
||||
// //Check for subdirectories
|
||||
// QDir SubDirectories(dir);
|
||||
|
||||
// SubDirectories.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
|
||||
// QFileInfoList SubDirList = SubDirectories.entryInfoList();
|
||||
// for(int i = 0; i < SubDirList.size(); i++)
|
||||
// {
|
||||
// ParseDir(QDir(SubDirList.at(i).absoluteFilePath()), KeepData);
|
||||
// }
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//void CDirParserThread::SetParsingInfo(QDir dir, QString Filter, bool KeepData)
|
||||
//{
|
||||
// //qDebug("DirParserThread parsing info: dir: %s, Filter: %s",dir.dirName().toAscii().data(),Filter.toAscii().data());
|
||||
// mRootDir = dir;
|
||||
// mKeepData = KeepData;
|
||||
// mFilter = Filter;
|
||||
//}
|
||||
void CDirParserThread::SetParsingInfo(CReportProgramSettingsData ReportSettings, CReportConfigData ReportFilters, QList<QList<CLogElement *> *> *ReportDataContainer)
|
||||
{
|
||||
mMutex.lockForWrite();
|
||||
mReportSettings = ReportSettings;
|
||||
mReportFilters = ReportFilters;
|
||||
mReportDataContainer = ReportDataContainer;
|
||||
mMutex.unlock();
|
||||
}
|
||||
void CDirParserThread::KillThread()
|
||||
{
|
||||
mMutex.lockForWrite();
|
||||
mExecThread = false;
|
||||
mMutex.unlock();
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef DIRPARSERTHREAD_H
|
||||
#define DIRPARSERTHREAD_H
|
||||
#include "GlobalDefine.h"
|
||||
#include <QDir>
|
||||
#include <QReadWriteLock>
|
||||
#include "TrainLogFileMgr.h"
|
||||
#include "ReportSettingsData.h"
|
||||
|
||||
class CDirParserThread : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CDirParserThread();
|
||||
// void SetParsingInfo(QDir dir,QString Filter,bool KeepData = false);
|
||||
void SetParsingInfo(CReportProgramSettingsData ReportSettings, CReportConfigData ReportFilters, QList<QList<CLogElement *> *> *ReportDataContainer);
|
||||
void KillThread();
|
||||
int ParseDir(QDir dir, QList<CLogElement*> *Container);
|
||||
|
||||
void GatherReportData(CReportProgramSettingsData ReportSettings, CReportConfigData ReportFilters);
|
||||
QStringList FilterDirectories(QDir BaseDir, QDate StartDate, QDate EndDate);
|
||||
|
||||
private:
|
||||
QDir mRootDir;
|
||||
bool mKeepData;
|
||||
QReadWriteLock mMutex;
|
||||
bool mExecThread;
|
||||
QString mFilter;
|
||||
QList<QStringList> mReportDirectoriesList;
|
||||
|
||||
CReportProgramSettingsData mReportSettings;
|
||||
CReportConfigData mReportFilters;
|
||||
QList<QList<CLogElement*>*> *mReportDataContainer;
|
||||
|
||||
public slots:
|
||||
void ParseDirectories();
|
||||
|
||||
signals:
|
||||
void NewLogParsed(QString,bool);
|
||||
void NewLogParsed(CLogElement*);
|
||||
void ParsingFinished(int);
|
||||
void EmptyDirParsed();
|
||||
void ThreadAborted();
|
||||
void ReportProgressStatus(QString);
|
||||
};
|
||||
|
||||
#endif // DIRPARSERTHREAD_H
|
||||
@@ -0,0 +1,75 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121210 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
#ifndef GLOBAL_DEFINE
|
||||
#define GLOBAL_DEFINE
|
||||
|
||||
//Screen resolution.
|
||||
#define SCREEN_RES_WIDTH 1200
|
||||
#define SCREEN_RES_HEIGHT 700
|
||||
|
||||
//Train parameters
|
||||
#define MR_BOGIE_LENGTH 1.52 //meters
|
||||
#define MPM_BOGIE_LENGTH 2.0 //meters
|
||||
|
||||
|
||||
|
||||
//Misc definitions
|
||||
#define USE_FAST_LOGFILE_LOADING
|
||||
#define MAX_LOG_FILE_COUNT 25000
|
||||
#define MAX_LOG_DIR_SIZE (qint64)1073741824 //in bytes = 1 GB
|
||||
#define USE_ANALOG_ACQUISITION
|
||||
|
||||
|
||||
#define ZT_TCP_PORT 1234
|
||||
#define ZT_UDP_PORT 41245
|
||||
|
||||
//Debug defs
|
||||
//#define LOG_RAM_USAGE
|
||||
|
||||
//General purpose return values.
|
||||
enum eGeneralRetValue
|
||||
{
|
||||
RET_OK,
|
||||
RET_ERROR
|
||||
};
|
||||
|
||||
enum eZTID
|
||||
{
|
||||
ANGRIGNON_ZT_ID,
|
||||
HONORE_BEAUGRAND_ZT_ID,
|
||||
LONGUEUIL_ZT_ID,
|
||||
BERRI_UQAM_ZT_ID,
|
||||
SNOWDON_ZT_ID,
|
||||
SAINT_MICHEL_ZT_ID,
|
||||
COTE_VERTU_ZT_ID,
|
||||
HENRI_BOURASSA_ZT_ID,
|
||||
MONTMORENCY_ZT_ID,
|
||||
|
||||
NB_ZT_ID
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,646 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Cette classe est responsable de la création d'une liste d'objets CLogElement
|
||||
à partir des données de passage des trains contenues dans les fichiers log.
|
||||
Cette classe est principalement utilisée par l'interface graphique pour la
|
||||
visualisation des passages.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121024 JFM
|
||||
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "LogMgr.h"
|
||||
|
||||
#include "TrainLogFileMgr.h"
|
||||
//#include "OutilZT.h"
|
||||
//#include "ZTLog.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QBuffer>
|
||||
#include <QThread>
|
||||
|
||||
CLogMgr::CLogMgr()
|
||||
{
|
||||
mProgramHandle = 0;
|
||||
|
||||
mDirParserThread = new QThread();
|
||||
mDirParserWorkerThread = new CDirParserThread();
|
||||
mDirParserWorkerThread->moveToThread(mDirParserThread);
|
||||
connect(mDirParserThread,SIGNAL(started()),mDirParserWorkerThread,SLOT(ParseDirectories()));
|
||||
connect(mDirParserThread,SIGNAL(finished()),this,SLOT(ThreadQuit()));
|
||||
connect(mDirParserThread,SIGNAL(terminated()),this,SLOT(ThreadTerminated()));
|
||||
// connect(mDirParserWorkerThread,SIGNAL(NewLogParsed(QString,bool)),this,SLOT(NewLogParsed(QString,bool)));
|
||||
connect(mDirParserWorkerThread,SIGNAL(NewLogParsed(CLogElement*)),this,SLOT(NewLogParsed(CLogElement*)));
|
||||
connect(mDirParserWorkerThread,SIGNAL(ParsingFinished(int)),this,SLOT(DirParsingFinished(int)));
|
||||
connect(mDirParserWorkerThread,SIGNAL(EmptyDirParsed()),this,SLOT(EmptyDirParsed()));
|
||||
|
||||
mDatabaseParsingTimer = new QTimer();
|
||||
mDatabaseParsingTimer->setInterval(60000);
|
||||
connect(mDatabaseParsingTimer,SIGNAL(timeout()),this,SLOT(ParsingTimerExpired()));
|
||||
|
||||
}
|
||||
|
||||
CLogMgr::~CLogMgr()
|
||||
{
|
||||
DestroyLogList();
|
||||
delete mDirParserThread;
|
||||
delete mDirParserWorkerThread;
|
||||
delete mDatabaseParsingTimer;
|
||||
}
|
||||
|
||||
unsigned int CLogMgr::DestroyLogList()
|
||||
{
|
||||
for(int i = 0; i < mPassagesList.size(); i++)
|
||||
{
|
||||
delete mPassagesList.at(i);
|
||||
}
|
||||
|
||||
mPassagesList.clear();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CLogMgr::ProtectLogElementFile(bool IsProtected, CLogElement *Element)
|
||||
{
|
||||
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||
{
|
||||
CZT1LogElement *ZT1Element = (CZT1LogElement*)Element;
|
||||
if(CTrainLogFileMgr::instance()->SetTrainLogProtected(IsProtected,ZT1Element->mLogFileName) == RET_OK)
|
||||
{
|
||||
ZT1Element->mFileProtected = IsProtected;
|
||||
SaveDatabaseFile();
|
||||
return RET_OK;
|
||||
}
|
||||
}
|
||||
else if(Element->mZTLogType == ZT2_LOG_TYPE)
|
||||
{
|
||||
CZT2LogElement *ZT2Element = (CZT2LogElement*)Element;
|
||||
if(CTrainLogFileMgr::instance()->SetTrainLogProtected(IsProtected,ZT2Element->mLogFileName) == RET_OK)
|
||||
{
|
||||
ZT2Element->mFileProtected = IsProtected;
|
||||
SaveDatabaseFile();
|
||||
return RET_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return RET_ERROR;
|
||||
}
|
||||
unsigned int CLogMgr::ParseLogs(bool RebuildDatabase, bool KeepData)
|
||||
{
|
||||
DestroyLogList();
|
||||
qDebug("Parsing Logs now...");
|
||||
|
||||
mSaveDBFile = false;
|
||||
mParsingFinished = false;
|
||||
// mProgramHandle->DatabaseFetchingBegin(this);
|
||||
mDatabaseFileCounter = 0;
|
||||
if(RebuildDatabase == true)
|
||||
{
|
||||
qDebug("Rebuilding database now...");
|
||||
//mDirParserWorkerThread->SetParsingInfo(QDir(mLogDataDir),"*.bin",KeepData);
|
||||
qDebug("Starting parser thread now...");
|
||||
mDirParserThread->start();
|
||||
mSaveDBFile = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Load database file.
|
||||
QDir BaseDir(mLogDataDir);
|
||||
QString DatabaseFilePath = BaseDir.filePath("Trains.zdb");
|
||||
// DatabaseFilePath += "Trains.zdb";
|
||||
QFile* DatabaseFile = new QFile(BaseDir.filePath("Trains.zdb")/*DatabaseFilePath*/);
|
||||
if(DatabaseFile)
|
||||
{
|
||||
if(DatabaseFile->open(QIODevice::ReadOnly | QIODevice::Unbuffered) == false)
|
||||
{
|
||||
//rebuild database...
|
||||
qDebug("Failed to open Trains.zdb, rebuilding database now...");
|
||||
//mDirParserWorkerThread->SetParsingInfo(QDir(mLogDataDir),"*.bin",KeepData);
|
||||
qDebug("Starting parser thread now...");
|
||||
mDirParserThread->start();
|
||||
mSaveDBFile = true;
|
||||
delete DatabaseFile;
|
||||
return RET_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DirParsingFinished(0);
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
|
||||
QByteArray DBData = DatabaseFile->readAll();
|
||||
QDataStream *DBStrm = new QDataStream(DBData);
|
||||
|
||||
qint32 NBRecords;
|
||||
*DBStrm >> NBRecords;
|
||||
|
||||
for(qint32 i = 0; i < NBRecords; i++)
|
||||
{
|
||||
unsigned int LogType;
|
||||
*DBStrm >> LogType;
|
||||
|
||||
if(LogType == ZT1_LOG_TYPE)
|
||||
{
|
||||
CZT1LogElement *NewElement = new CZT1LogElement;
|
||||
|
||||
|
||||
*DBStrm >> NewElement->mPassageDateTime
|
||||
>> NewElement->mTrainType
|
||||
>> NewElement->mNbElements
|
||||
>> NewElement->mThreadDataStartTime
|
||||
>> NewElement->mThreadDataEndTime
|
||||
>> NewElement->mLogFileName
|
||||
>> NewElement->mMeanSpeed
|
||||
>> NewElement->mFlags
|
||||
>> NewElement->mStationName
|
||||
>> NewElement->mFileProtected;
|
||||
|
||||
int NBDetect;
|
||||
*DBStrm >> NBDetect;
|
||||
|
||||
for(int i = 0; i < NBDetect; i++)
|
||||
{
|
||||
CZTDetectionData *NewDetection = new CZTDetectionData;
|
||||
*DBStrm >> NewDetection->mDetectionID
|
||||
>> NewDetection->mRank
|
||||
>> NewDetection->mTimeStamp;
|
||||
|
||||
NewElement->mZTDetections.append(NewDetection);
|
||||
}
|
||||
NewLogParsed(NewElement);
|
||||
|
||||
}
|
||||
else if(LogType == ZT2_LOG_TYPE)
|
||||
{
|
||||
CZT2LogElement *NewElement = new CZT2LogElement;
|
||||
|
||||
|
||||
*DBStrm >> NewElement->mPassageDateTime
|
||||
>> NewElement->mLogFileName
|
||||
>> NewElement->mNbElements
|
||||
>> NewElement-> mStationName
|
||||
>> NewElement->mFlags
|
||||
>> NewElement->mFileProtected;
|
||||
|
||||
int NBDetect;
|
||||
*DBStrm >> NBDetect;
|
||||
|
||||
for(int i = 0; i < NBDetect; i++)
|
||||
{
|
||||
CZTDetectionData *NewDetection = new CZTDetectionData;
|
||||
*DBStrm >> NewDetection->mDetectionID
|
||||
>> NewDetection->mRank
|
||||
>> NewDetection->mTimeStamp;
|
||||
|
||||
NewElement->mZTDetections.append(NewDetection);
|
||||
}
|
||||
|
||||
NewLogParsed(NewElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Invalid logtype in DB file...");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
DatabaseFile->close();
|
||||
delete DatabaseFile;
|
||||
delete DBStrm;
|
||||
|
||||
DirParsingFinished(1);
|
||||
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CLogMgr::SaveDatabaseFile()
|
||||
{
|
||||
|
||||
QDir BaseDir(mLogDataDir);
|
||||
QString DatabaseFilePath = BaseDir.filePath("Trains.zdb");
|
||||
// DatabaseFilePath += "Trains.zdb";
|
||||
QFile* DatabaseFile = new QFile(BaseDir.filePath("Trains.zdb")/*DatabaseFilePath*/);
|
||||
|
||||
|
||||
if(DatabaseFile)
|
||||
{
|
||||
if(DatabaseFile->open(QIODevice::WriteOnly | QIODevice::Unbuffered) == false)
|
||||
{
|
||||
QMessageBox::information(0,"Erreur","Impossible de créer le fichier DB");
|
||||
delete DatabaseFile;
|
||||
return RET_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(0,"Erreur","Impossible de créer le fichier DB");
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
|
||||
QByteArray byteArray;
|
||||
QBuffer FileBuffer(&byteArray);
|
||||
FileBuffer.open(QIODevice::WriteOnly);
|
||||
QDataStream *DBStrm = new QDataStream(&FileBuffer);
|
||||
|
||||
qint32 NBRecords = mPassagesList.size();
|
||||
*DBStrm << NBRecords;
|
||||
|
||||
for(qint32 i = 0; i < NBRecords; i++)
|
||||
{
|
||||
unsigned int LogType = mPassagesList.at(i)->mZTLogType;
|
||||
*DBStrm << LogType;
|
||||
|
||||
if(LogType == ZT1_LOG_TYPE)
|
||||
{
|
||||
CZT1LogElement *NewElement = (CZT1LogElement*)mPassagesList.at(i);
|
||||
|
||||
QDateTime test = NewElement->mPassageDateTime;
|
||||
|
||||
// *DBStrm << NewElement->mPassageDateTime
|
||||
*DBStrm << test
|
||||
<< NewElement->mTrainType
|
||||
<< NewElement->mNbElements
|
||||
<< NewElement->mThreadDataStartTime
|
||||
<< NewElement->mThreadDataEndTime
|
||||
<< NewElement->mLogFileName
|
||||
<< NewElement->mMeanSpeed
|
||||
<< NewElement->mFlags
|
||||
<< NewElement->mStationName
|
||||
<< NewElement->mFileProtected;
|
||||
|
||||
int NBDetect = NewElement->mZTDetections.size();
|
||||
*DBStrm << NBDetect;
|
||||
|
||||
for(int i = 0; i < NBDetect; i++)
|
||||
{
|
||||
*DBStrm << NewElement->mZTDetections.at(i)->mDetectionID
|
||||
<< NewElement->mZTDetections.at(i)->mRank
|
||||
<< NewElement->mZTDetections.at(i)->mTimeStamp;
|
||||
}
|
||||
}
|
||||
else if(LogType == ZT2_LOG_TYPE)
|
||||
{
|
||||
CZT2LogElement *NewElement = (CZT2LogElement*)mPassagesList.at(i);
|
||||
|
||||
|
||||
*DBStrm << NewElement->mPassageDateTime
|
||||
<< NewElement->mLogFileName
|
||||
<< NewElement->mNbElements
|
||||
<< NewElement->mStationName
|
||||
<< NewElement->mFlags
|
||||
<< NewElement->mFileProtected;
|
||||
|
||||
int NBDetect = NewElement->mZTDetections.size();
|
||||
*DBStrm << NBDetect;
|
||||
|
||||
for(int i = 0; i < NBDetect; i++)
|
||||
{
|
||||
*DBStrm << NewElement->mZTDetections.at(i)->mDetectionID
|
||||
<< NewElement->mZTDetections.at(i)->mRank
|
||||
<< NewElement->mZTDetections.at(i)->mTimeStamp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Invalid log type in array!!!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
FileBuffer.seek(0);
|
||||
DatabaseFile->write(FileBuffer.buffer());
|
||||
DatabaseFile->flush();
|
||||
|
||||
FileBuffer.close();
|
||||
DatabaseFile->close();
|
||||
delete DatabaseFile;
|
||||
delete DBStrm;
|
||||
mSaveDBFile = false;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CLogMgr::RebuildDatabaseFile()
|
||||
{
|
||||
ParseLogs(true,false);
|
||||
mSaveDBFile = true;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int CLogMgr::ParseDir(QDir dir, bool KeepData)
|
||||
{
|
||||
|
||||
QStringList LogFilters;
|
||||
QFileInfoList list;
|
||||
// QString LogDataDir = mProgramHandle->GetLogDataPath();
|
||||
LogFilters << "*.bin";
|
||||
|
||||
//Load files in base directory
|
||||
QDir LogDir(dir);
|
||||
LogDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||
LogDir.setNameFilters(LogFilters);
|
||||
LogDir.setSorting(QDir::Name);
|
||||
list = LogDir.entryInfoList();
|
||||
if(list.size() != 0)
|
||||
{
|
||||
//Extract data for each passage
|
||||
for(int i = 0; i < list.size(); i++)
|
||||
{
|
||||
ParseNewLog(list.at(i).filePath(),KeepData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Check for subdirectories
|
||||
QDir SubDirectories(dir);
|
||||
|
||||
SubDirectories.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
|
||||
QFileInfoList SubDirList = SubDirectories.entryInfoList();
|
||||
for(int i = 0; i < SubDirList.size(); i++)
|
||||
{
|
||||
ParseDir(QDir(SubDirList.at(i).absoluteFilePath()), KeepData);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
CLogElement* CLogMgr::LoadLogData(CLogElement *Element)
|
||||
{
|
||||
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||
{
|
||||
CZT1LogElement *TargetElement = (CZT1LogElement*)Element;
|
||||
QString FilePath = TargetElement->mLogFileName;
|
||||
unsigned int ret;
|
||||
|
||||
//Make shure that the lists are empty in the target element
|
||||
for(int i = 0; i < TargetElement->mZTLogData.size(); i++)
|
||||
{
|
||||
delete TargetElement->mZTLogData.at(i);
|
||||
}
|
||||
for(int i = 0; i < TargetElement->mZTDetections.size(); i++)
|
||||
{
|
||||
delete TargetElement->mZTDetections.at(i);
|
||||
}
|
||||
|
||||
TargetElement->mZTLogData.clear();
|
||||
TargetElement->mZTDetections.clear();
|
||||
|
||||
//Passing the TargetElement to the OpenTrainLog function will fill it with data
|
||||
CTrainLogFileMgr::instance()->OpenTrainLog(FilePath,ret,TargetElement,true);
|
||||
|
||||
return (CLogElement*)TargetElement;
|
||||
}
|
||||
else if(Element->mZTLogType == ZT2_LOG_TYPE)
|
||||
{
|
||||
CZT2LogElement *TargetElement = (CZT2LogElement*)Element;
|
||||
QString FilePath = TargetElement->mLogFileName;
|
||||
unsigned int ret;
|
||||
|
||||
//Make shure that the lists are empty in the target element
|
||||
for(int i = 0; i < TargetElement->mZTLogData.size(); i++)
|
||||
{
|
||||
delete TargetElement->mZTLogData.at(i);
|
||||
}
|
||||
for(int i = 0; i < TargetElement->mZTDetections.size(); i++)
|
||||
{
|
||||
delete TargetElement->mZTDetections.at(i);
|
||||
}
|
||||
|
||||
TargetElement->mZTLogData.clear();
|
||||
TargetElement->mZTDetections.clear();
|
||||
|
||||
//Passing the TargetElement to the OpenTrainLog function will fill it with data
|
||||
CTrainLogFileMgr::instance()->OpenTrainLog(FilePath,ret,TargetElement,true);
|
||||
|
||||
return (CLogElement*)TargetElement;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
unsigned int CLogMgr::FreeLogData(CLogElement *Element)
|
||||
{
|
||||
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||
{
|
||||
CZT1LogElement *temp = (CZT1LogElement*)Element;
|
||||
for(int i = 0; i < temp->mZTLogData.size(); i++)
|
||||
delete temp->mZTLogData.at(i);
|
||||
temp->mZTLogData.clear();
|
||||
}
|
||||
if(Element->mZTLogType == ZT2_LOG_TYPE)
|
||||
{
|
||||
CZT2LogElement *temp = (CZT2LogElement*)Element;
|
||||
for(int i = 0; i < temp->mZTLogData.size(); i++)
|
||||
delete temp->mZTLogData.at(i);
|
||||
temp->mZTLogData.clear();
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
|
||||
}
|
||||
|
||||
unsigned int CLogMgr::DeleteLog(int LogIndex)
|
||||
{
|
||||
if(LogIndex >= mPassagesList.size())
|
||||
return RET_ERROR;
|
||||
|
||||
QString Filename;
|
||||
|
||||
CLogElement *Element = mPassagesList.takeAt(LogIndex);
|
||||
FreeLogData(Element); //make shure no data will be leaked
|
||||
{
|
||||
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||
{
|
||||
CZT1LogElement *temp = (CZT1LogElement*)Element;
|
||||
Filename = temp->mLogFileName;
|
||||
|
||||
}
|
||||
if(Element->mZTLogType == ZT2_LOG_TYPE)
|
||||
{
|
||||
CZT2LogElement *temp = (CZT2LogElement*)Element;
|
||||
Filename = temp->mLogFileName;
|
||||
}
|
||||
}
|
||||
QDir DirObject;
|
||||
DirObject.remove(Filename);
|
||||
delete Element;
|
||||
|
||||
SaveDatabaseFile();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
bool CLogMgr::ParseNextLog()
|
||||
{
|
||||
if((int)mLogsFileIndex >= mLogsFilelist.size())
|
||||
return false;
|
||||
|
||||
//Extract data
|
||||
|
||||
if(ParseNewLog(mLogsFilelist.at(mLogsFileIndex).filePath()) == RET_ERROR)
|
||||
return false;
|
||||
|
||||
mLogsFileIndex++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CLogMgr::NewLogParsed(QString Filename,bool KeepData)
|
||||
{
|
||||
ParseNewLog(Filename,KeepData);
|
||||
mDatabaseParsingTimer->start();
|
||||
}
|
||||
|
||||
void CLogMgr::NewLogParsed(CLogElement * NewLog)
|
||||
{
|
||||
mPassagesList.append(NewLog);
|
||||
mDatabaseParsingTimer->start();
|
||||
// mProgramHandle->DatabaseFetchingTick(this,mDatabaseFileCounter++);
|
||||
|
||||
}
|
||||
|
||||
void CLogMgr::DirParsingFinished(int Res)
|
||||
{
|
||||
|
||||
mDatabaseParsingTimer->stop();
|
||||
mParsingFinished = true;
|
||||
mDirParserThread->quit();
|
||||
// mProgramHandle->LogsDatabaseLoaded(this,Res);
|
||||
|
||||
if(mSaveDBFile == true)
|
||||
{
|
||||
SaveDatabaseFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CLogMgr::ParsingTimerExpired()
|
||||
{
|
||||
qDebug("Parsing timer timeout");
|
||||
mDirParserWorkerThread->KillThread();
|
||||
mDirParserThread->terminate();
|
||||
DirParsingFinished(2);
|
||||
|
||||
}
|
||||
void CLogMgr::EmptyDirParsed()
|
||||
{
|
||||
//The thread is not stuck. Kick the timer...
|
||||
mDatabaseParsingTimer->start();
|
||||
}
|
||||
|
||||
void CLogMgr::ThreadQuit()
|
||||
{
|
||||
qDebug("Thread quit slot");
|
||||
}
|
||||
|
||||
void CLogMgr::ThreadTerminated()
|
||||
{
|
||||
qDebug("Thread terminated slot");
|
||||
}
|
||||
|
||||
|
||||
unsigned int CLogMgr::ParseNewLog(QString FileName, bool KeepData)
|
||||
{
|
||||
Q_UNUSED(KeepData)
|
||||
|
||||
unsigned int ret;
|
||||
CLogElement *NewLog = CTrainLogFileMgr::instance()->OpenTrainLog(FileName,ret);
|
||||
|
||||
if(ret == RET_ERROR)
|
||||
{
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
//the date and time of the log entry is assigned the date and time of the first record...
|
||||
if(NewLog->mZTLogType == ZT1_LOG_TYPE)
|
||||
{
|
||||
mPassagesList.append(NewLog);
|
||||
}
|
||||
else if(NewLog->mZTLogType == ZT2_LOG_TYPE)
|
||||
{
|
||||
mPassagesList.append(NewLog);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CLogMgr::ParseImportedLogs(QStringList *NewLogFiles)
|
||||
{
|
||||
if(NewLogFiles == 0)
|
||||
{
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
for(int i = 0; i < NewLogFiles->size(); i++)
|
||||
{
|
||||
ParseNewLog(NewLogFiles->at(i));
|
||||
}
|
||||
|
||||
SaveDatabaseFile();
|
||||
// mProgramHandle->LogsDatabaseLoaded(this,1);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CLogMgr::GetLogsCount()
|
||||
{
|
||||
return mPassagesList.size();
|
||||
}
|
||||
|
||||
QList<CLogElement*> * CLogMgr::GetLogsList()
|
||||
{
|
||||
return &mPassagesList;
|
||||
}
|
||||
|
||||
CLogElement::~CLogElement()
|
||||
{
|
||||
}
|
||||
|
||||
CZT1LogElement::~CZT1LogElement()
|
||||
{
|
||||
qDeleteAll(mZTLogData);
|
||||
mZTLogData.clear();
|
||||
|
||||
qDeleteAll(mZTDetections);
|
||||
mZTDetections.clear();
|
||||
}
|
||||
|
||||
CZT2LogElement::~CZT2LogElement()
|
||||
{
|
||||
for(int i = 0; i < mZTLogData.size(); i++)
|
||||
delete mZTLogData.at(i);
|
||||
mZTLogData.clear();
|
||||
|
||||
for(int i = 0; i < mZTDetections.size(); i++)
|
||||
delete mZTDetections.at(i);
|
||||
mZTDetections.clear();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* 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 LOGMGR_H
|
||||
#define LOGMGR_H
|
||||
|
||||
#include "ZTData.h"
|
||||
#include "GlobalDefine.h"
|
||||
#include <QList>
|
||||
#include <QDir>
|
||||
#include <QTimer>
|
||||
#include <QReadWriteLock>
|
||||
#include "DirParserThread.h"
|
||||
|
||||
class CLogElement
|
||||
{
|
||||
public:
|
||||
unsigned int mZTLogType;
|
||||
virtual ~CLogElement();
|
||||
};
|
||||
//QDataStream &operator<<(QDataStream &out, const CLogElement &source);
|
||||
//QDataStream &operator>>(QDataStream &in, CLogElement &dest);
|
||||
|
||||
class CZT1LogElement : public CLogElement
|
||||
{
|
||||
public:
|
||||
CZT1LogElement(){mZTLogType=ZT1_LOG_TYPE;}
|
||||
~CZT1LogElement();
|
||||
QDateTime mPassageDateTime;
|
||||
QVector<CZT1LogData*> mZTLogData;
|
||||
QVector<CZTDetectionData*> mZTDetections;
|
||||
quint32 mTrainType;
|
||||
quint32 mNbElements;
|
||||
quint64 mThreadDataStartTime, mThreadDataEndTime;
|
||||
QString mLogFileName;
|
||||
qreal mMeanSpeed;
|
||||
CZT1FlagsData mFlags;
|
||||
QString mStationName;
|
||||
bool mFileProtected;
|
||||
int mFileVersion;
|
||||
};
|
||||
//QDataStream &operator<<(QDataStream &out, const CZT1LogElement &source);
|
||||
//QDataStream &operator>>(QDataStream &in, CZT1LogElement &dest);
|
||||
|
||||
class CZT2LogElement : public CLogElement
|
||||
{
|
||||
public:
|
||||
CZT2LogElement(){mZTLogType = ZT2_LOG_TYPE;}
|
||||
~CZT2LogElement();
|
||||
QDateTime mPassageDateTime;
|
||||
QVector<CZT2LogData*> mZTLogData;
|
||||
QVector<CZTDetectionData*> mZTDetections;
|
||||
QString mLogFileName;
|
||||
quint32 mNbElements;
|
||||
QString mStationName;
|
||||
CZT2FlagsData mFlags;
|
||||
bool mFileProtected;
|
||||
};
|
||||
|
||||
class COutilZT;
|
||||
|
||||
class CLogMgr : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CLogMgr();
|
||||
~CLogMgr();
|
||||
|
||||
COutilZT *mProgramHandle;
|
||||
|
||||
unsigned int GetLogsCount();
|
||||
QList<CLogElement*> *GetLogsList();
|
||||
unsigned int ParseLogs(bool RebuildDatabase = false, bool KeepData = false);
|
||||
unsigned int ParseNewLog(QString FileName, bool KeepData = false);
|
||||
unsigned int ParseImportedLogs(QStringList *NewLogFiles);
|
||||
CLogElement* LoadLogData(CLogElement * Element);
|
||||
unsigned int FreeLogData(CLogElement * Element);
|
||||
unsigned int DeleteLog(int LogIndex);
|
||||
void SetLogDataDir(QString Dir){mLogDataDir = Dir;}
|
||||
bool ParseNextLog();
|
||||
unsigned int SaveDatabaseFile();
|
||||
unsigned int RebuildDatabaseFile();
|
||||
unsigned int ProtectLogElementFile(bool IsProtected, CLogElement *Element);
|
||||
QTimer *mDatabaseParsingTimer;
|
||||
QDir GetBaseLogDataDir(){return QDir(mLogDataDir);}
|
||||
|
||||
|
||||
private:
|
||||
CDirParserThread *mDirParserWorkerThread;
|
||||
QThread *mDirParserThread;
|
||||
QList<CLogElement*> mPassagesList;
|
||||
unsigned int DestroyLogList();
|
||||
int ParseDir(QDir dir, bool KeepData = false);
|
||||
|
||||
|
||||
QFileInfoList mLogsFilelist;
|
||||
unsigned int mLogsFileIndex;
|
||||
QString mLogDataDir;
|
||||
|
||||
bool mParsingFinished;
|
||||
unsigned int mDatabaseFileCounter;
|
||||
bool mSaveDBFile;
|
||||
|
||||
public slots:
|
||||
void NewLogParsed(QString,bool);
|
||||
void NewLogParsed(CLogElement*);
|
||||
void DirParsingFinished(int);
|
||||
void ParsingTimerExpired();
|
||||
void EmptyDirParsed();
|
||||
|
||||
|
||||
void ThreadQuit();
|
||||
void ThreadTerminated();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // LOGMGR_H
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "MainWindow.h"
|
||||
#include "ui_MainWindow.h"
|
||||
|
||||
CMainWindow::CMainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::CMainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle("Générateur de rapport ZT");
|
||||
|
||||
mMainWindowTabWidget = new QTabWidget(this);
|
||||
mReportPage = new CReportPage(this);
|
||||
mSettingsPage = new CSettingsPage(this);
|
||||
|
||||
setCentralWidget(mMainWindowTabWidget);
|
||||
mMainWindowTabWidget->addTab(mReportPage,"Rapport");
|
||||
mMainWindowTabWidget->addTab(mSettingsPage,"Paramètres");
|
||||
}
|
||||
|
||||
CMainWindow::~CMainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTabWidget>
|
||||
#include "ReportPage.h"
|
||||
#include "SettingsPage.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class CMainWindow;
|
||||
}
|
||||
|
||||
class CMainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CMainWindow(QWidget *parent = 0);
|
||||
~CMainWindow();
|
||||
|
||||
QTabWidget *mMainWindowTabWidget;
|
||||
CReportPage *mReportPage;
|
||||
CSettingsPage *mSettingsPage;
|
||||
|
||||
private:
|
||||
Ui::CMainWindow *ui;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
@@ -0,0 +1,342 @@
|
||||
#include "ReportGenerator.h"
|
||||
#include <QtXlsx>
|
||||
#include <QStringList>
|
||||
#include "ZTData.h"
|
||||
#include "LogMgr.h"
|
||||
#include "GlobalDefine.h"
|
||||
#include "ZTStats.h"
|
||||
|
||||
CReportGenerator::CReportGenerator()
|
||||
{
|
||||
mDirParserThread = new QThread();
|
||||
mDirParserWorkerThread = new CDirParserThread();
|
||||
mDirParserWorkerThread->moveToThread(mDirParserThread);
|
||||
connect(mDirParserThread,SIGNAL(started()),mDirParserWorkerThread,SLOT(ParseDirectories()));
|
||||
connect(mDirParserThread,SIGNAL(finished()),this,SLOT(ThreadQuit()));
|
||||
connect(mDirParserWorkerThread,SIGNAL(ParsingFinished(int)),this,SLOT(DirParsingFinished(int)));
|
||||
connect(mDirParserWorkerThread,SIGNAL(ReportProgressStatus(QString)),this,SLOT(ThreadReportStatus(QString)));
|
||||
connect(mDirParserWorkerThread,SIGNAL(ThreadAborted()),this,SLOT(DirThreadAborted()));
|
||||
|
||||
mStationNames << "Angrignon" << "Beaugrand" << "Longueuil" << "Berri" << "Snowdon" << "St-Michel" << "Vertu" << "Bourassa" << "Montmorency";
|
||||
|
||||
//Allocate report data structure for each station
|
||||
for(int i = 0; i < NB_ZT_ID; i++)
|
||||
{ QList<CLogElement*> *ElementList = new QList<CLogElement*>;
|
||||
mReportData.append(ElementList);
|
||||
}
|
||||
}
|
||||
|
||||
CReportGenerator::~CReportGenerator()
|
||||
{
|
||||
mDirParserThread->quit();
|
||||
delete mDirParserWorkerThread;
|
||||
//delete mDirParserThread;
|
||||
}
|
||||
|
||||
int CReportGenerator::GenerateReport(QString ReportFileName, CReportProgramSettingsData ReportSettings, CReportConfigData ReportFilters)
|
||||
{
|
||||
|
||||
mReportFilename = ReportFileName;
|
||||
mReportFilters = ReportFilters;
|
||||
|
||||
ClearReportData();
|
||||
|
||||
mDirParserWorkerThread->SetParsingInfo(ReportSettings,ReportFilters,&mReportData);
|
||||
mDirParserThread->start();
|
||||
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CReportGenerator::ClearReportData()
|
||||
{
|
||||
for(int station = 0; station < mReportData.size(); station++)
|
||||
{
|
||||
QList<CLogElement*> *LogsList = mReportData.at(station);
|
||||
for(int log = 0; log < LogsList->size(); log++)
|
||||
{
|
||||
delete LogsList->at(log);
|
||||
}
|
||||
LogsList->clear();
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CReportGenerator::ThreadQuit()
|
||||
{
|
||||
qDebug("Parsing thread quit");
|
||||
}
|
||||
|
||||
void CReportGenerator::ThreadTerminated()
|
||||
{
|
||||
qDebug("Parsing thread terminated");
|
||||
}
|
||||
|
||||
void CReportGenerator::DirParsingFinished(int Res)
|
||||
{
|
||||
mDirParserThread->exit();
|
||||
if(Res == 0)
|
||||
{
|
||||
ClearReportData();
|
||||
ThreadReportStatus("La génération du rapport a échoué...");
|
||||
mProgramPtr->ReportCreationFinished(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
//Generate report
|
||||
GenerateExcelReport();
|
||||
}
|
||||
|
||||
void CReportGenerator::DirThreadAborted()
|
||||
{
|
||||
mDirParserThread->exit();
|
||||
ClearReportData();
|
||||
ThreadReportStatus("La génération du rapport a été annulée");
|
||||
mProgramPtr->ReportCreationFinished(QString());
|
||||
}
|
||||
|
||||
int CReportGenerator::GenerateExcelReport()
|
||||
{
|
||||
if(mReportFilename.isEmpty())
|
||||
{
|
||||
return RET_ERROR;
|
||||
}
|
||||
ThreadReportStatus("Passages analysés... création du fichier Excel.");
|
||||
|
||||
QXlsx::Document ExcelDoc(mReportFilename);
|
||||
//Clean the file if it already exist
|
||||
for(int station = 0; station < mStationNames.size(); station++)
|
||||
{
|
||||
ExcelDoc.deleteSheet(mStationNames.at(station));
|
||||
}
|
||||
|
||||
for(int station = 0; station < mReportData.size(); station++)
|
||||
{
|
||||
int PassageID = 1;
|
||||
if(mReportData.at(station)->isEmpty() == false)
|
||||
{
|
||||
QList<CLogElement*> *PassageLogData = mReportData.at(station);
|
||||
int row = 6;
|
||||
ExcelDoc.addSheet(mStationNames.at(station));
|
||||
ExcelDoc.selectSheet(mStationNames.at(station));
|
||||
|
||||
//Create Header
|
||||
ExcelDoc.write(1,1,QString("Rapport de déclenchements ZT de la station %1").arg(mStationNames.at(station)));
|
||||
ExcelDoc.write(2,1,QString("Date de début %1").arg(mReportFilters.mReportStartDate.toString("yyyy-MM-dd")));
|
||||
ExcelDoc.write(3,1,QString("Date de fin %1").arg(mReportFilters.mReportEndDate.toString("yyyy-MM-dd")));
|
||||
|
||||
ExcelDoc.write(5,1,QString("ID Passage"));
|
||||
ExcelDoc.write(5,2,QString("Date et Heure"));
|
||||
ExcelDoc.write(5,3,QString("Nb Décl (passage)"));
|
||||
ExcelDoc.write(5,4,QString("Zone"));
|
||||
ExcelDoc.write(5,5,QString("Composition"));
|
||||
ExcelDoc.write(5,6,QString("Déclenchement"));
|
||||
ExcelDoc.write(5,7,QString("Rang"));
|
||||
|
||||
for(int log = 0; log < PassageLogData->size(); log++)
|
||||
{
|
||||
if(PassageLogData->at(log)->mZTLogType == ZT1_LOG_TYPE)
|
||||
{
|
||||
bool IncPassage = false;
|
||||
CZT1LogElement *Element = (CZT1LogElement*)PassageLogData->at(log);
|
||||
if(mReportFilters.mReportIncludeSansDeclZT1 == true)
|
||||
{
|
||||
ExcelDoc.write(row,1,PassageID);
|
||||
ExcelDoc.write(row,2,Element->mPassageDateTime.toString("yyyy-MM-dd hh:mm:ss"));
|
||||
ExcelDoc.write(row,3,Element->mZTDetections.size());
|
||||
ExcelDoc.write(row,4,"ZT1");
|
||||
ExcelDoc.write(row,5,QString("%1-%2-%3").arg(Element->mFlags.mTrainCompo1).arg(Element->mFlags.mTrainCompo2).arg(Element->mFlags.mTrainCompo3));
|
||||
ExcelDoc.write(row,6,"---");
|
||||
ExcelDoc.write(row,7,"---");
|
||||
row++;
|
||||
}
|
||||
|
||||
if(Element->mZTDetections.size() != 0)
|
||||
{
|
||||
for(int detect = 0; detect < Element->mZTDetections.size(); detect++)
|
||||
{
|
||||
QString DetectionName = "";
|
||||
switch(Element->mZTDetections.at(detect)->mDetectionID)
|
||||
{
|
||||
case DETECTION_FN_DETECTION:
|
||||
{
|
||||
if(mReportFilters.mReportFilterIncludeFN == true)
|
||||
{
|
||||
DetectionName = "FN";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DETECTION_MAGNETIC_SENSOR_COUNT:
|
||||
{
|
||||
if(mReportFilters.mReportfilterIncludeComptage1 == true)
|
||||
{
|
||||
DetectionName = "Erreur de comptage";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DETECTION_PG_DETECTION:
|
||||
{
|
||||
if(mReportFilters.mReportfilterIncludePG == true)
|
||||
{
|
||||
DetectionName = "PG";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DETECTION_PPI_DETECTION:
|
||||
{
|
||||
if(mReportFilters.mReportfilterIncludePPI1 == true)
|
||||
{
|
||||
DetectionName = "PPI";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DETECTION_PPE_DETECTION:
|
||||
{
|
||||
if(mReportFilters.mReportfilterIncludePPE1 == true)
|
||||
{
|
||||
DetectionName = "PPE";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DETECTION_PEQ1_DETECTION:
|
||||
{
|
||||
if(mReportFilters.mReportfilterIncludePEQ1 == true)
|
||||
{
|
||||
DetectionName = "Panne équipement";
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DetectionName.clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(DetectionName.isEmpty() == false)
|
||||
{
|
||||
ExcelDoc.write(row,1,PassageID);
|
||||
ExcelDoc.write(row,2,Element->mPassageDateTime.toString("yyyy-MM-dd hh:mm:ss"));
|
||||
ExcelDoc.write(row,3,Element->mZTDetections.size());
|
||||
ExcelDoc.write(row,4,"ZT1");
|
||||
ExcelDoc.write(row,5,QString("%1-%2-%3").arg(Element->mFlags.mTrainCompo1).arg(Element->mFlags.mTrainCompo2).arg(Element->mFlags.mTrainCompo3));
|
||||
ExcelDoc.write(row,6,DetectionName);
|
||||
ExcelDoc.write(row,7,Element->mZTDetections.at(detect)->mRank);
|
||||
row++;
|
||||
IncPassage = true; //we had ad least one log added, this passage must count...
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(IncPassage == true || mReportFilters.mReportIncludeSansDeclZT1 == true)
|
||||
{
|
||||
PassageID++;
|
||||
}
|
||||
}
|
||||
else if(PassageLogData->at(log)->mZTLogType == ZT2_LOG_TYPE)
|
||||
{
|
||||
bool IncPassage = false;
|
||||
CZT2LogElement *Element = (CZT2LogElement*)PassageLogData->at(log);
|
||||
if(mReportFilters.mReportIncludeSansDeclZT2 == true)
|
||||
{
|
||||
ExcelDoc.write(row,1,PassageID);
|
||||
ExcelDoc.write(row,2,Element->mPassageDateTime.toString("yyyy-MM-dd hh:mm:ss"));
|
||||
ExcelDoc.write(row,3,Element->mZTDetections.size());
|
||||
ExcelDoc.write(row,4,"ZT2");
|
||||
ExcelDoc.write(row,5,QString("%1-%2-%3").arg(Element->mFlags.mTrainCompo1).arg(Element->mFlags.mTrainCompo2).arg(Element->mFlags.mTrainCompo3));
|
||||
ExcelDoc.write(row,6,"---");
|
||||
ExcelDoc.write(row,7,"---");
|
||||
row++;
|
||||
}
|
||||
|
||||
if(Element->mZTDetections.size() != 0)
|
||||
{
|
||||
for(int detect = 0; detect < Element->mZTDetections.size(); detect++)
|
||||
{
|
||||
QString DetectionName = "";
|
||||
switch(Element->mZTDetections.at(detect)->mDetectionID)
|
||||
{
|
||||
case DETECTION_ZT2_MAGNETIC_SENCOR_COUNT:
|
||||
{
|
||||
if(mReportFilters.mReportfilterIncludeComptage2 == true)
|
||||
{
|
||||
DetectionName = "Erreur de comptage";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DETECTION_ZT2_PPI_DETECTION:
|
||||
{
|
||||
if(mReportFilters.mReportfilterIncludePPI2 == true)
|
||||
{
|
||||
DetectionName = "PPI";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DETECTION_ZT2_PPE_DETECTION:
|
||||
{
|
||||
if(mReportFilters.mReportfilterIncludePPE2 == true)
|
||||
{
|
||||
DetectionName = "PPE";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DETECTION_PEQ2_DETECTION:
|
||||
{
|
||||
if(mReportFilters.mReportfilterIncludePEQ2 == true)
|
||||
{
|
||||
DetectionName = "Panne Équipement";
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DetectionName.clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(DetectionName.isEmpty() == false)
|
||||
{
|
||||
ExcelDoc.write(row,1,PassageID);
|
||||
ExcelDoc.write(row,2,Element->mPassageDateTime.toString("yyyy-MM-dd hh:mm:ss"));
|
||||
ExcelDoc.write(row,3,Element->mZTDetections.size());
|
||||
ExcelDoc.write(row,4,"ZT2");
|
||||
ExcelDoc.write(row,5,QString("%1-%2-%3").arg(Element->mFlags.mTrainCompo1).arg(Element->mFlags.mTrainCompo2).arg(Element->mFlags.mTrainCompo3));
|
||||
ExcelDoc.write(row,6,DetectionName);
|
||||
ExcelDoc.write(row,7,Element->mZTDetections.at(detect)->mRank);
|
||||
row++;
|
||||
IncPassage = true; //we had ad least one log added, this passage must count...
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(IncPassage == true || mReportFilters.mReportIncludeSansDeclZT2)
|
||||
{
|
||||
PassageID++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExcelDoc.save();
|
||||
ThreadReportStatus("Rapport créé avec succès!");
|
||||
mProgramPtr->ReportCreationFinished(mReportFilename);
|
||||
qDebug("Création du rapport terminée");
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CReportGenerator::ThreadReportStatus(QString status)
|
||||
{
|
||||
mProgramPtr->UpdateReportProgressStatus(status);
|
||||
}
|
||||
|
||||
int CReportGenerator::AbortReportCreation()
|
||||
{
|
||||
mDirParserWorkerThread->KillThread();
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef REPORTGENERATOR_H
|
||||
#define REPORTGENERATOR_H
|
||||
#include "ReportSettingsData.h"
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include "DirParserThread.h"
|
||||
#include "ZTData.h"
|
||||
|
||||
class CZTStats;
|
||||
|
||||
class CReportGenerator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CReportGenerator();
|
||||
~CReportGenerator();
|
||||
|
||||
|
||||
int GenerateReport(QString ReportFileName,CReportProgramSettingsData ReportSettings, CReportConfigData ReportFilters);
|
||||
int ClearReportData();
|
||||
int GenerateExcelReport();
|
||||
int AbortReportCreation();
|
||||
|
||||
CZTStats *mProgramPtr;
|
||||
|
||||
QThread *mDirParserThread;
|
||||
CDirParserThread *mDirParserWorkerThread;
|
||||
QList<QList<CLogElement*>*> mReportData;
|
||||
QString mReportFilename;
|
||||
QStringList mStationNames;
|
||||
|
||||
CReportConfigData mReportFilters;
|
||||
|
||||
public slots:
|
||||
void ThreadQuit();
|
||||
void ThreadTerminated();
|
||||
void DirParsingFinished(int Res);
|
||||
void ThreadReportStatus(QString status);
|
||||
void DirThreadAborted();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // REPORTGENERATOR_H
|
||||
@@ -0,0 +1,231 @@
|
||||
#include "ReportPage.h"
|
||||
#include "ui_ReportPage.h"
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QString>
|
||||
#include "ZTStats.h"
|
||||
#include <QScrollBar>
|
||||
#include <QDesktopServices>
|
||||
|
||||
|
||||
CReportPage::CReportPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::CReportPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->mReportStartDateEdit->setCalendarPopup(true);
|
||||
ui->mReportStartDateEdit->setDate(QDate::currentDate());
|
||||
ui->mReportStartDateEdit->setMaximumDate(QDate::currentDate());
|
||||
ui->mReportEndDateEdit->setCalendarPopup(true);
|
||||
ui->mReportEndDateEdit->setDate(QDate::currentDate());
|
||||
ui->mReportEndDateEdit->setMaximumDate(QDate::currentDate());
|
||||
|
||||
ui->mReportFunctionFNChkBx->setCheckState(Qt::Checked);
|
||||
|
||||
|
||||
connect(ui->mGenerateReportBtn,&QPushButton::clicked,this,&CReportPage::GenerateReportBtnClicked);
|
||||
connect(ui->mSelectAllFuncZT1Btn,&QPushButton::clicked,this,&CReportPage::FunctionSelectionBtnPressed);
|
||||
connect(ui->mSelectAllFuncZT2Btn,&QPushButton::clicked,this,&CReportPage::FunctionSelectionBtnPressed);
|
||||
connect(ui->mSelectNoneFuncZT1Btn,&QPushButton::clicked,this,&CReportPage::FunctionSelectionBtnPressed);
|
||||
connect(ui->mSelectNoneFuncZT2Btn,&QPushButton::clicked,this,&CReportPage::FunctionSelectionBtnPressed);
|
||||
connect(ui->mOpenReportBtn,&QPushButton::clicked,this,&CReportPage::OpenReportBtnClicked);
|
||||
|
||||
|
||||
mTimeCounter = new QTimer;
|
||||
mTimeCounter->setSingleShot(false);
|
||||
mTimeCounter->setInterval(1000);
|
||||
// connect(mTimeCounter,&QTimer::timeout,this,&CReportPage::TimerExpired);
|
||||
connect(mTimeCounter,SIGNAL(timeout()),this,SLOT(TimerExpired()));
|
||||
|
||||
ui->mTimerLable->setText("");
|
||||
|
||||
ui->mOpenReportBtn->hide();
|
||||
ui->mReportPathLabel->hide();
|
||||
|
||||
ui->mReportProgressBarr->setMinimum(0);
|
||||
ui->mReportProgressBarr->setMaximum(1);
|
||||
ui->mReportProgressBarr->setValue(0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
CReportPage::~CReportPage()
|
||||
{
|
||||
delete ui;
|
||||
delete mTimeCounter;
|
||||
}
|
||||
|
||||
CReportConfigData CReportPage::GetReportFiltersConfig()
|
||||
{
|
||||
CReportConfigData FiltersConfig;
|
||||
|
||||
FiltersConfig.mReportStartDate = ui->mReportStartDateEdit->date();
|
||||
FiltersConfig.mReportEndDate = ui->mReportEndDateEdit->date();
|
||||
|
||||
|
||||
|
||||
FiltersConfig.mReportFilterIncludeFN = ui->mReportFunctionFNChkBx->isChecked();
|
||||
FiltersConfig.mReportfilterIncludePEQ1 = ui->mReportFunctionPEQ1ChkBx->isChecked();
|
||||
FiltersConfig.mReportfilterIncludePG = ui->mReportFunctionPGChkBx->isChecked();
|
||||
FiltersConfig.mReportfilterIncludeComptage1 = ui->mReportFunctionComptage_1ChkBx->isChecked();
|
||||
FiltersConfig.mReportfilterIncludePPE1 = ui->mReportFunctionPPE_1ChkBx->isChecked();
|
||||
FiltersConfig.mReportfilterIncludePPI1 = ui->mReportFunctionPPI_1ChkBx->isChecked();
|
||||
|
||||
FiltersConfig.mReportfilterIncludeComptage2 = ui->mReportFunctionComptage_2ChkBx->isChecked();
|
||||
FiltersConfig.mReportfilterIncludePEQ2 = ui->mReportFunctionPEQ2ChkBx->isChecked();
|
||||
FiltersConfig.mReportfilterIncludePPE2 = ui->mReportFunctionPPE_2ChkBx->isChecked();
|
||||
FiltersConfig.mReportfilterIncludePPI2 = ui->mReportFunctionPPI_2ChkBx->isChecked();
|
||||
|
||||
|
||||
FiltersConfig.mReportStationAngrignon = ui->mReportStationAngrignonChkBx->isChecked();
|
||||
FiltersConfig.mReportStationBeaugrand = ui->mReportStationBeaugrandChkBx->isChecked();
|
||||
FiltersConfig.mReportStationBerri = ui->mReportStationBerriChkBx->isChecked();
|
||||
FiltersConfig.mReportStationBourassa = ui->mReportStationBourassaChkBx->isChecked();
|
||||
FiltersConfig.mReportStationLongueuil = ui->mReportStationLongueuilChkBx->isChecked();
|
||||
FiltersConfig.mReportStationMontmorency = ui->mReportStationMontmorencyChkBx->isChecked();
|
||||
FiltersConfig.mReportStationSnowdon = ui->mReportStationSnowdonChkBx->isChecked();
|
||||
FiltersConfig.mReportStationStMichel = ui->mReportStationStMichelChkBx->isChecked();
|
||||
FiltersConfig.mReportStationVertu = ui->mReportStationVertuChkBx->isChecked();
|
||||
|
||||
FiltersConfig.mReportIncludeSansDeclZT1 = ui->mReportFunctionNoDecl1ChkBx->isChecked();
|
||||
FiltersConfig.mReportIncludeSansDeclZT2 = ui->mReportFunctionNoDecl2ChkBx->isChecked();
|
||||
|
||||
return FiltersConfig;
|
||||
}
|
||||
|
||||
void CReportPage::GenerateReportBtnClicked()
|
||||
{
|
||||
if(ui->mGenerateReportBtn->text() == "Annuler")
|
||||
{
|
||||
mProgramHandle->AbortReportCreationRequest();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Sanity check first...
|
||||
CReportConfigData ConfigFilters = GetReportFiltersConfig();
|
||||
|
||||
if(ConfigFilters.IsAnyFilterSelected() == false)
|
||||
{
|
||||
QMessageBox::critical(this,"Erreur","Vous devez sélectionner au moins 1 alarme à analyser");
|
||||
return;
|
||||
}
|
||||
|
||||
if(ConfigFilters.IsAnyStationSelected() == false)
|
||||
{
|
||||
QMessageBox::critical(this,"Erreur","Vous devez sélectionner au moins 1 station");
|
||||
return;
|
||||
}
|
||||
|
||||
if(ConfigFilters.IsDateRangeValid() == false)
|
||||
{
|
||||
QMessageBox::critical(this,"Erreur","Vous devez sélectionner une période valide (dates)");
|
||||
return;
|
||||
}
|
||||
|
||||
QString ExcelFile = QFileDialog::getSaveFileName(this, tr("Fichier rapport"), QString(),tr("Excel (*.xlsx)"));
|
||||
// qDebug("%s",qPrintable(ExcelFile));
|
||||
if(ExcelFile.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClearProgressStatus();
|
||||
ui->mReportProgressBarr->setMinimum(0);
|
||||
ui->mReportProgressBarr->setMaximum(0);
|
||||
mProgressTime.setHMS(0,0,0,0);
|
||||
mTimeCounter->start();
|
||||
UpdateProgressStatus("Création du rapport en cours... ça peut être long!!!");
|
||||
ui->mGenerateReportBtn->setText("Annuler");
|
||||
mProgramHandle->GenerateReportRequest(ExcelFile,ConfigFilters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CReportPage::UpdateProgressStatus(QString Status)
|
||||
{
|
||||
Status.append("\n");
|
||||
ui->mReportProgressTextEdit->setPlainText(ui->mReportProgressTextEdit->document()->toPlainText().append(Status));
|
||||
ui->mReportProgressTextEdit->verticalScrollBar()->setValue(ui->mReportProgressTextEdit->verticalScrollBar()->maximum());
|
||||
}
|
||||
|
||||
void CReportPage::ClearProgressStatus()
|
||||
{
|
||||
ui->mReportProgressTextEdit->clear();
|
||||
ui->mReportProgressBarr->setMinimum(0);
|
||||
ui->mReportProgressBarr->setMaximum(1);
|
||||
ui->mReportProgressBarr->setValue(0);
|
||||
}
|
||||
|
||||
void CReportPage::ReportCreationFinished(QString ReportFilePath)
|
||||
{
|
||||
// ClearProgressStatus();
|
||||
ui->mReportProgressBarr->setMinimum(0);
|
||||
ui->mReportProgressBarr->setMaximum(1);
|
||||
ui->mReportProgressBarr->setValue(0);
|
||||
ui->mGenerateReportBtn->setText("Générer Rapport");
|
||||
mTimeCounter->stop();
|
||||
|
||||
if(ReportFilePath.isEmpty() == false)
|
||||
{
|
||||
mReportFilePath = ReportFilePath;
|
||||
ui->mReportPathLabel->setText(ReportFilePath);
|
||||
ui->mReportPathLabel->show();
|
||||
ui->mOpenReportBtn->show();
|
||||
}
|
||||
}
|
||||
|
||||
void CReportPage::TimerExpired()
|
||||
{
|
||||
mProgressTime = mProgressTime.addSecs(1);
|
||||
ui->mTimerLable->setText(mProgressTime.toString("hh:mm:ss"));
|
||||
}
|
||||
|
||||
void CReportPage::FunctionSelectionBtnPressed()
|
||||
{
|
||||
QObject *CallerBtn = sender();
|
||||
|
||||
if(CallerBtn == ui->mSelectAllFuncZT1Btn)
|
||||
{
|
||||
ui->mReportFunctionFNChkBx->setCheckState(Qt::Checked);
|
||||
ui->mReportFunctionPEQ1ChkBx->setCheckState(Qt::Checked);
|
||||
ui->mReportFunctionPGChkBx->setCheckState(Qt::Checked);
|
||||
ui->mReportFunctionComptage_1ChkBx->setCheckState(Qt::Checked);
|
||||
ui->mReportFunctionPPI_1ChkBx->setCheckState(Qt::Checked);
|
||||
ui->mReportFunctionPPE_1ChkBx->setCheckState(Qt::Checked);
|
||||
}
|
||||
else if(CallerBtn == ui->mSelectAllFuncZT2Btn)
|
||||
{
|
||||
ui->mReportFunctionComptage_2ChkBx->setCheckState(Qt::Checked);
|
||||
ui->mReportFunctionComptage_2ChkBx->setCheckState(Qt::Checked);
|
||||
ui->mReportFunctionPEQ2ChkBx->setCheckState(Qt::Checked);
|
||||
ui->mReportFunctionPPE_2ChkBx->setCheckState(Qt::Checked);
|
||||
ui->mReportFunctionPPI_2ChkBx->setCheckState(Qt::Checked);
|
||||
}
|
||||
else if(CallerBtn == ui->mSelectNoneFuncZT1Btn)
|
||||
{
|
||||
ui->mReportFunctionFNChkBx->setCheckState(Qt::Unchecked);
|
||||
ui->mReportFunctionPEQ1ChkBx->setCheckState(Qt::Unchecked);
|
||||
ui->mReportFunctionPGChkBx->setCheckState(Qt::Unchecked);
|
||||
ui->mReportFunctionComptage_1ChkBx->setCheckState(Qt::Unchecked);
|
||||
ui->mReportFunctionPPI_1ChkBx->setCheckState(Qt::Unchecked);
|
||||
ui->mReportFunctionPPE_1ChkBx->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
else if(CallerBtn == ui->mSelectNoneFuncZT2Btn)
|
||||
{
|
||||
ui->mReportFunctionComptage_2ChkBx->setCheckState(Qt::Unchecked);
|
||||
ui->mReportFunctionComptage_2ChkBx->setCheckState(Qt::Unchecked);
|
||||
ui->mReportFunctionPEQ2ChkBx->setCheckState(Qt::Unchecked);
|
||||
ui->mReportFunctionPPE_2ChkBx->setCheckState(Qt::Unchecked);
|
||||
ui->mReportFunctionPPI_2ChkBx->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
|
||||
void CReportPage::OpenReportBtnClicked()
|
||||
{
|
||||
// system(qPrintable(mReportFilePath));
|
||||
// QProcess::execute(mReportFilePath);
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(mReportFilePath));
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef REPORTPAGE_H
|
||||
#define REPORTPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "ReportSettingsData.h"
|
||||
#include <QTimer>
|
||||
#include <QTime>
|
||||
|
||||
class CZTStats;
|
||||
|
||||
namespace Ui {
|
||||
class CReportPage;
|
||||
}
|
||||
|
||||
class CReportPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CReportPage(QWidget *parent = 0);
|
||||
~CReportPage();
|
||||
|
||||
CReportConfigData GetReportFiltersConfig();
|
||||
void UpdateProgressStatus(QString Status);
|
||||
void ClearProgressStatus();
|
||||
void ReportCreationFinished(QString ReportFilePath);
|
||||
|
||||
CZTStats *mProgramHandle;
|
||||
QTimer *mTimeCounter;
|
||||
QTime mProgressTime;
|
||||
QString mReportFilePath;
|
||||
|
||||
private:
|
||||
Ui::CReportPage *ui;
|
||||
|
||||
public slots:
|
||||
void GenerateReportBtnClicked();
|
||||
void TimerExpired();
|
||||
void FunctionSelectionBtnPressed();
|
||||
void OpenReportBtnClicked();
|
||||
|
||||
};
|
||||
|
||||
#endif // REPORTPAGE_H
|
||||
@@ -0,0 +1,156 @@
|
||||
#include "ReportSettingsData.h"
|
||||
|
||||
CReportSettingsData::CReportSettingsData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CReportProgramSettingsData::CReportProgramSettingsData()
|
||||
{
|
||||
mDataSourceDirectoryPaths.clear();
|
||||
}
|
||||
|
||||
CReportProgramSettingsData& CReportProgramSettingsData::operator=(const CReportProgramSettingsData &source)
|
||||
{
|
||||
if(&source == this)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
this->mDataSourceDirectoryPaths = source.mDataSourceDirectoryPaths;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool CReportConfigData::IsAnyStationSelected()
|
||||
{
|
||||
if(mReportStationAngrignon == true ||
|
||||
mReportStationBeaugrand == true ||
|
||||
mReportStationVertu == true ||
|
||||
mReportStationBourassa == true ||
|
||||
mReportStationMontmorency == true ||
|
||||
mReportStationBerri == true ||
|
||||
mReportStationLongueuil == true ||
|
||||
mReportStationStMichel == true ||
|
||||
mReportStationSnowdon == true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CReportConfigData::IsAnyFilterSelected()
|
||||
{
|
||||
if(mReportFilterIncludeFN == true ||
|
||||
mReportfilterIncludePPI1 == true ||
|
||||
mReportfilterIncludePPE1 == true ||
|
||||
mReportfilterIncludePG == true ||
|
||||
mReportfilterIncludeComptage1 == true ||
|
||||
mReportfilterIncludePEQ1 == true ||
|
||||
mReportfilterIncludePPI2 == true ||
|
||||
mReportfilterIncludePPE2 == true ||
|
||||
mReportfilterIncludeComptage2 == true ||
|
||||
mReportfilterIncludePEQ2 == true ||
|
||||
mReportIncludeSansDeclZT1 == true ||
|
||||
mReportIncludeSansDeclZT2 == true )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CReportConfigData::IsDateRangeValid()
|
||||
{
|
||||
if(mReportEndDate < mReportStartDate)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CReportConfigData& CReportConfigData::operator=(const CReportConfigData &source)
|
||||
{
|
||||
if(&source == this)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
this->mReportStationAngrignon = source.mReportStationAngrignon;
|
||||
this->mReportStationBeaugrand = source.mReportStationBeaugrand;
|
||||
this->mReportStationVertu = source.mReportStationVertu;
|
||||
this->mReportStationBourassa = source.mReportStationBourassa;
|
||||
this->mReportStationMontmorency = source.mReportStationMontmorency;
|
||||
this->mReportStationBerri = source.mReportStationBerri;
|
||||
this->mReportStationLongueuil = source.mReportStationLongueuil;
|
||||
this->mReportStationStMichel = source.mReportStationStMichel;
|
||||
this->mReportStationSnowdon = source.mReportStationSnowdon;
|
||||
this->mReportFilterIncludeFN = source.mReportFilterIncludeFN;
|
||||
this->mReportfilterIncludePPI1 = source.mReportfilterIncludePPI1;
|
||||
this->mReportfilterIncludePPE1 = source.mReportfilterIncludePPE1;
|
||||
this->mReportfilterIncludePG = source.mReportfilterIncludePG;
|
||||
this->mReportfilterIncludeComptage1 = source.mReportfilterIncludeComptage1;
|
||||
this->mReportfilterIncludePEQ1 = source.mReportfilterIncludePEQ1;
|
||||
this->mReportfilterIncludePPI2 = source.mReportfilterIncludePPI2;
|
||||
this->mReportfilterIncludePPE2 = source.mReportfilterIncludePPE2;
|
||||
this->mReportfilterIncludeComptage2 = source.mReportfilterIncludeComptage2;
|
||||
this->mReportfilterIncludePEQ2 = source.mReportfilterIncludePEQ2;
|
||||
this->mReportStartDate = source.mReportStartDate;
|
||||
this->mReportEndDate = source.mReportEndDate;
|
||||
this->mReportIncludeSansDeclZT1 = source.mReportIncludeSansDeclZT1;
|
||||
this->mReportIncludeSansDeclZT2 = source.mReportIncludeSansDeclZT2;
|
||||
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CReportProgramSettingsData &source)
|
||||
{
|
||||
out << source.mDataSourceDirectoryPaths.size();
|
||||
|
||||
for(int i = 0; i < source.mDataSourceDirectoryPaths.size(); i++)
|
||||
{
|
||||
out << source.mDataSourceDirectoryPaths.at(i);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, CReportProgramSettingsData &dest)
|
||||
{
|
||||
// unsigned int NbPaths;
|
||||
// in >> NbPaths;
|
||||
|
||||
// // in >> NbPaths;
|
||||
// for(int i = 0; i < NbPaths; i++)
|
||||
// {
|
||||
// QString Path;
|
||||
// in >> Path;
|
||||
// dest.mDataSourceDirectoryPaths.append(Path);
|
||||
// }
|
||||
|
||||
// return in;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
#ifndef REPORTSETTINGSDATA_H
|
||||
#define REPORTSETTINGSDATA_H
|
||||
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QDate>
|
||||
|
||||
class CReportProgramSettingsData
|
||||
{
|
||||
public:
|
||||
CReportProgramSettingsData();
|
||||
|
||||
QStringList mDataSourceDirectoryPaths;
|
||||
|
||||
CReportProgramSettingsData &operator=(const CReportProgramSettingsData &source);
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CReportProgramSettingsData &source);
|
||||
QDataStream &operator>>(QDataStream &in, CReportProgramSettingsData &dest);
|
||||
|
||||
class CReportConfigData
|
||||
{
|
||||
public:
|
||||
bool mReportStationAngrignon;
|
||||
bool mReportStationBeaugrand;
|
||||
bool mReportStationVertu;
|
||||
bool mReportStationBourassa;
|
||||
bool mReportStationMontmorency;
|
||||
bool mReportStationBerri;
|
||||
bool mReportStationLongueuil;
|
||||
bool mReportStationStMichel;
|
||||
bool mReportStationSnowdon;
|
||||
|
||||
bool mReportFilterIncludeFN;
|
||||
bool mReportfilterIncludePPI1;
|
||||
bool mReportfilterIncludePPE1;
|
||||
bool mReportfilterIncludePG;
|
||||
bool mReportfilterIncludeComptage1;
|
||||
bool mReportfilterIncludePEQ1;
|
||||
|
||||
bool mReportfilterIncludePPI2;
|
||||
bool mReportfilterIncludePPE2;
|
||||
bool mReportfilterIncludeComptage2;
|
||||
bool mReportfilterIncludePEQ2;
|
||||
|
||||
bool mReportIncludeSansDeclZT1;
|
||||
bool mReportIncludeSansDeclZT2;
|
||||
|
||||
QDate mReportStartDate, mReportEndDate;
|
||||
|
||||
bool IsAnyStationSelected();
|
||||
bool IsAnyFilterSelected();
|
||||
bool IsDateRangeValid();
|
||||
|
||||
CReportConfigData &operator=(const CReportConfigData &source);
|
||||
};
|
||||
|
||||
class CReportSettingsData
|
||||
{
|
||||
public:
|
||||
CReportSettingsData();
|
||||
};
|
||||
|
||||
#endif // REPORTSETTINGSDATA_H
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "SettingsPage.h"
|
||||
#include "ui_SettingsPage.h"
|
||||
|
||||
|
||||
CSettingsPage::CSettingsPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::CSettingsPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
CSettingsPage::~CSettingsPage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef SETTINGSPAGE_H
|
||||
#define SETTINGSPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class CSettingsPage;
|
||||
}
|
||||
|
||||
class CSettingsPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CSettingsPage(QWidget *parent = 0);
|
||||
~CSettingsPage();
|
||||
|
||||
private:
|
||||
Ui::CSettingsPage *ui;
|
||||
};
|
||||
|
||||
#endif // SETTINGSPAGE_H
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSettingsPage</class>
|
||||
<widget class="QWidget" name="CSettingsPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>667</width>
|
||||
<height>650</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>20</y>
|
||||
<width>431</width>
|
||||
<height>471</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Répertoires sources</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,61 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* 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 TRAINLOGFILEMGR_H
|
||||
#define TRAINLOGFILEMGR_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include "ZTData.h"
|
||||
|
||||
|
||||
|
||||
class CLogElement;
|
||||
|
||||
class CTrainLogFileMgr
|
||||
{
|
||||
public:
|
||||
|
||||
//CTrainLogFileMgr is a singleton class
|
||||
static CTrainLogFileMgr* instance(){return &mSingleton;}
|
||||
static CTrainLogFileMgr mSingleton;
|
||||
|
||||
|
||||
CTrainLogFileMgr();
|
||||
unsigned int SaveTrainLog(QString LogFilePathName,CZT1Log *ZT1Log,QVector<CZTDetectionData*> *ZT1DetectionsLog,QString StationName);
|
||||
unsigned int SaveTrainLog(QString LogFilePathName,QVector<CZT2LogData*> *ZT2Log,QVector<CZTDetectionData*> *ZT2DetectionsLog,QString StationName);
|
||||
CLogElement *OpenTrainLog(QString LogFilePathName,unsigned int &RetValue,CLogElement *TargetElement = 0,bool LoadData = false);
|
||||
unsigned int SaveCSVFile(QString CSVFilePathName,QVector<CZT1LogData*> *ZT1Log,CZT1FlagsData *ZT1Flags,QVector<CZTDetectionData*> *ZT1DetectionsLog, QString StationName);
|
||||
unsigned int SaveCSVFile(QString CSVFilePathName,CZT1Log *ZT1Log,QVector<CZTDetectionData*> *ZT1DetectionsLog, QString StationName);
|
||||
unsigned int SaveCSVFile(QString CSVFilePathName,QVector<CZT2LogData*> *ZT2Log,QVector<CZTDetectionData*> *ZT2DetectionsLog, QString StationName);
|
||||
|
||||
unsigned int SetTrainLogProtected(bool IsProtected,QString LogFilePathName);
|
||||
|
||||
unsigned int SaveBINFromCSV(QString CSVFilePathName);
|
||||
};
|
||||
|
||||
#endif // TRAINLOGFILEMGR_H
|
||||
|
||||
@@ -0,0 +1,449 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Classe fourre-tout qui contient les différentes structures données utilisées
|
||||
un peu partout dans le programme.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ZTData.h"
|
||||
|
||||
const char * CZTData::TrainTypeString[] = {"Inconnu","MR63/73", "MPM10"};
|
||||
CZTData::CZTData()
|
||||
{
|
||||
}
|
||||
|
||||
const char * CZTData::ErrorString[] = {"Erreur de comptage S1-S2",
|
||||
"Déclenchement frotteur négatif",
|
||||
"Déclenchement pneu de guidage",
|
||||
"Déclenchement pneu porteur intérieur",
|
||||
"Déclenchement pneu porteur extérieur",
|
||||
|
||||
"Erreur de comptage ZT2",
|
||||
"Déclenchement pneu porteur intérieur ZT2",
|
||||
"Déclenchement pneu porteur extérieur ZT2",
|
||||
|
||||
"Panne équipement ZT1",
|
||||
"Panne équipement ZT2",
|
||||
|
||||
};
|
||||
|
||||
const char * CZTData::ShortErrorString[] = {"V00",
|
||||
"DFN",
|
||||
"DPG",
|
||||
"DPPI",
|
||||
"DPPE",
|
||||
|
||||
"V002",
|
||||
"DPPI2",
|
||||
"DPPE2",
|
||||
|
||||
"PEQ1",
|
||||
"PEQ2"};
|
||||
|
||||
const char* CZTData::GetErrorString(unsigned int ErrorID)
|
||||
{
|
||||
if(ErrorID >= DETECTION_MAX_DETECTION_ID)
|
||||
ErrorID = 0;
|
||||
return ErrorString[ErrorID];
|
||||
}
|
||||
|
||||
const char* CZTData::GetShortErrorString(unsigned int ErrorID)
|
||||
{
|
||||
if(ErrorID >= DETECTION_MAX_DETECTION_ID)
|
||||
ErrorID = 0;
|
||||
return ShortErrorString[ErrorID];
|
||||
}
|
||||
|
||||
const char* CZTData::GetTrainTypeString(unsigned int TrainType)
|
||||
{
|
||||
if(TrainType >= TRAIN_TYPE_MAX_ID)
|
||||
TrainType = TRAIN_TYPE_UNKNOWN;
|
||||
return TrainTypeString[TrainType];
|
||||
}
|
||||
|
||||
const char* CZTData::GetModbusTrainTypeString(unsigned int TrainType)
|
||||
{
|
||||
switch(TrainType)
|
||||
{
|
||||
case MODBUS_CC_TRAIN_TYPE_MR63:
|
||||
{
|
||||
return "MR63";
|
||||
break;
|
||||
}
|
||||
case MODBUS_CC_TRAIN_TYPE_MR73:
|
||||
{
|
||||
return "MR73";
|
||||
break;
|
||||
}
|
||||
case MODBUS_CC_TRAIN_TYPE_MPM10:
|
||||
{
|
||||
return "MPM10";
|
||||
break;
|
||||
}
|
||||
case MODBUS_CC_TRAIN_TYPE_MAINTENANCE:
|
||||
{
|
||||
return "Vehicule Travaux";
|
||||
break;
|
||||
}
|
||||
case MODBUS_CC_TRAIN_TYPE_INVALID_ATS_OFFLINE:
|
||||
case MODBUS_CC_TRAIN_TYPE_INVALID_SERVICE_REBOOT:
|
||||
case MODBUS_CC_TRAIN_TYPE_INVALID_NOT_UPDATED:
|
||||
case MODBUS_CC_TRAIN_TYPE_INVALID_SACL_OFFLINE:
|
||||
default:
|
||||
{
|
||||
return "Inconnu";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CZT1LogData::CZT1LogData(CZT1ThreadData *ThreadData):
|
||||
mZT1ThreadData(ThreadData)
|
||||
{
|
||||
}
|
||||
CZT1LogData::~CZT1LogData()
|
||||
{
|
||||
if(mZT1ThreadData != 0)
|
||||
delete mZT1ThreadData;
|
||||
}
|
||||
|
||||
CZT1ThreadData::~CZT1ThreadData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CZT1ThreadData::operator =(CZT1ThreadData& TD)
|
||||
{
|
||||
mTimeStamp = TD.mTimeStamp;
|
||||
mDateTime = TD.mDateTime;
|
||||
mS1 = TD.mS1;
|
||||
mS2 = TD.mS2;
|
||||
mPInt = TD.mPInt;
|
||||
mPExt = TD.mPExt;
|
||||
mFN = TD.mFN;
|
||||
mPG = TD.mPG;
|
||||
|
||||
mBogie = TD.mBogie;
|
||||
mRank = TD.mRank;
|
||||
mS1Count = TD.mS1Count;
|
||||
mS2Count = TD.mS2Count;
|
||||
mFNCount = TD.mFNCount;
|
||||
mPGExtValue = TD.mPGExtValue;
|
||||
mPGIntValue = TD.mPGIntValue;
|
||||
mTrainSpeed = TD.mTrainSpeed;
|
||||
mTrainType = TD.mTrainType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CZT1FlagsData &source)
|
||||
{
|
||||
out << source.mExtPGOffset
|
||||
<< source.mIntPGOffset
|
||||
<< source.mPGCalibrationON
|
||||
<< source.mPGTresholdValue
|
||||
<< source.mAnalogTracePresent
|
||||
<< source.mIsProblematicPassage
|
||||
<< source.mTrainCompo1
|
||||
<< source.mTrainCompo2
|
||||
<< source.mTrainCompo3
|
||||
<< source.mModbusTrainType
|
||||
<< source.mZT1ITI
|
||||
<< source.mUnusedFlag13
|
||||
<< source.mUnusedFlag14
|
||||
<< source.mUnusedFlag15
|
||||
<< source.mUnusedFlag16
|
||||
<< source.mUnusedFlag17
|
||||
<< source.mUnusedFlag18
|
||||
<< source.mUnusedFlag19
|
||||
<< source.mUnusedFlag20;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, CZT1FlagsData &dest)
|
||||
{
|
||||
in >> dest.mExtPGOffset
|
||||
>> dest.mIntPGOffset
|
||||
>> dest.mPGCalibrationON
|
||||
>> dest.mPGTresholdValue
|
||||
>> dest.mAnalogTracePresent
|
||||
>> dest.mIsProblematicPassage
|
||||
>> dest.mTrainCompo1
|
||||
>> dest.mTrainCompo2
|
||||
>> dest.mTrainCompo3
|
||||
>> dest.mModbusTrainType
|
||||
>> dest.mZT1ITI
|
||||
>> dest.mUnusedFlag13
|
||||
>> dest.mUnusedFlag14
|
||||
>> dest.mUnusedFlag15
|
||||
>> dest.mUnusedFlag16
|
||||
>> dest.mUnusedFlag17
|
||||
>> dest.mUnusedFlag18
|
||||
>> dest.mUnusedFlag19
|
||||
>> dest.mUnusedFlag20;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDataStream& operator<<(QDataStream &out, const CZT1LogData &source)
|
||||
{
|
||||
quint32 ThreadDataValid = 0;
|
||||
if(source.mZT1ThreadData != 0)
|
||||
ThreadDataValid = 1;
|
||||
|
||||
|
||||
out << source.mDateTime
|
||||
<< source.mTimestamp
|
||||
<< source.mCIZT1
|
||||
<< source.mCDVApproach_ZT1
|
||||
<< source.mCDVARM_ZT1
|
||||
<< ThreadDataValid;
|
||||
|
||||
if(ThreadDataValid == 1)
|
||||
{
|
||||
out << source.mZT1ThreadData->mS1
|
||||
<< source.mZT1ThreadData->mS2
|
||||
<< source.mZT1ThreadData->mFN
|
||||
<< source.mZT1ThreadData->mPInt
|
||||
<< source.mZT1ThreadData->mPExt
|
||||
<< source.mZT1ThreadData->mPG
|
||||
<< source.mZT1ThreadData->mTrainSpeed
|
||||
<< source.mZT1ThreadData->mBogie
|
||||
<< source.mZT1ThreadData->mRank
|
||||
<< source.mZT1ThreadData->mPGExtValue
|
||||
<< source.mZT1ThreadData->mPGIntValue
|
||||
<< source.mZT1ThreadData->mTrainType
|
||||
<< source.mZT1ThreadData->mS1Count
|
||||
<< source.mZT1ThreadData->mS2Count;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, CZT1LogData &dest)
|
||||
{
|
||||
quint32 ThreadValid;
|
||||
in >> dest.mDateTime
|
||||
>> dest.mTimestamp
|
||||
>> dest.mCIZT1
|
||||
>> dest.mCDVApproach_ZT1
|
||||
>> dest.mCDVARM_ZT1
|
||||
>> ThreadValid;
|
||||
if(ThreadValid == 1)
|
||||
{
|
||||
dest.mZT1ThreadData = new CZT1ThreadData();
|
||||
in >> dest.mZT1ThreadData->mS1
|
||||
>> dest.mZT1ThreadData->mS2
|
||||
>> dest.mZT1ThreadData->mFN
|
||||
>> dest.mZT1ThreadData->mPInt
|
||||
>> dest.mZT1ThreadData->mPExt
|
||||
>> dest.mZT1ThreadData->mPG
|
||||
>> dest.mZT1ThreadData->mTrainSpeed
|
||||
>> dest.mZT1ThreadData->mBogie
|
||||
>> dest.mZT1ThreadData->mRank
|
||||
>> dest.mZT1ThreadData->mPGExtValue
|
||||
>> dest.mZT1ThreadData->mPGIntValue
|
||||
>> dest.mZT1ThreadData->mTrainType
|
||||
>>dest.mZT1ThreadData->mS1Count
|
||||
>>dest.mZT1ThreadData->mS2Count;
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CZTDetectionData &source)
|
||||
{
|
||||
out << source.mTimeStamp
|
||||
<< source.mRank
|
||||
<< source.mDetectionID;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, CZTDetectionData &dest)
|
||||
{
|
||||
in >> dest.mTimeStamp
|
||||
>> dest.mRank
|
||||
>> dest.mDetectionID;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
CZT2LogData::CZT2LogData(CZT2ThreadData *ThreadData):
|
||||
mZT2ThreadData(ThreadData)
|
||||
{
|
||||
}
|
||||
CZT2LogData::~CZT2LogData()
|
||||
{
|
||||
if(mZT2ThreadData != 0)
|
||||
delete mZT2ThreadData;
|
||||
}
|
||||
QDataStream &operator<<(QDataStream &out, const CZT2FlagsData &source)
|
||||
{
|
||||
out << source.mIsProblematicPassage
|
||||
<< source.mTrainCompo1
|
||||
<< source.mTrainCompo2
|
||||
<< source.mTrainCompo3
|
||||
<< source.mModbusTrainType
|
||||
<< source.mUnusedFlag6
|
||||
<< source.mUnusedFlag7
|
||||
<< source.mUnusedFlag8
|
||||
<< source.mUnusedFlag9
|
||||
<< source.mUnusedFlag10;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, CZT2FlagsData &dest)
|
||||
{
|
||||
in >> dest.mIsProblematicPassage
|
||||
>> dest.mTrainCompo1
|
||||
>> dest.mTrainCompo2
|
||||
>> dest.mTrainCompo3
|
||||
>> dest.mModbusTrainType
|
||||
>> dest.mUnusedFlag6
|
||||
>> dest.mUnusedFlag7
|
||||
>> dest.mUnusedFlag8
|
||||
>> dest.mUnusedFlag9
|
||||
>> dest.mUnusedFlag10;;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
QDataStream& operator<<(QDataStream &out, const CZT2LogData &source)
|
||||
{
|
||||
quint32 ThreadDataValid = 0;
|
||||
if(source.mZT2ThreadData != 0)
|
||||
ThreadDataValid = 1;
|
||||
|
||||
out << source.mDateTime
|
||||
<< source.mTimestamp
|
||||
<< source.mCIZT2
|
||||
<< source.mCDVARM_ZT2
|
||||
<< source.mCDVApproach_ZT2
|
||||
<< ThreadDataValid;
|
||||
|
||||
if(ThreadDataValid == 1)
|
||||
{
|
||||
out << source.mZT2ThreadData->mS1
|
||||
<< source.mZT2ThreadData->mPPInt
|
||||
<< source.mZT2ThreadData->mPPExt
|
||||
<< source.mZT2ThreadData->mBogie
|
||||
<< source.mZT2ThreadData->mRank
|
||||
<< source.mZT2ThreadData->mS1Count;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, CZT2LogData &dest)
|
||||
{
|
||||
quint32 ThreadValid;
|
||||
in >> dest.mDateTime
|
||||
>> dest.mTimestamp
|
||||
>> dest.mCIZT2
|
||||
>> dest.mCDVARM_ZT2
|
||||
>> dest.mCDVApproach_ZT2
|
||||
>> ThreadValid;
|
||||
if(ThreadValid == 1)
|
||||
{
|
||||
dest.mZT2ThreadData = new CZT2ThreadData();
|
||||
in >> dest.mZT2ThreadData->mS1
|
||||
>> dest.mZT2ThreadData->mPPInt
|
||||
>> dest.mZT2ThreadData->mPPExt
|
||||
>> dest.mZT2ThreadData->mBogie
|
||||
>> dest.mZT2ThreadData->mRank
|
||||
>> dest.mZT2ThreadData->mS1Count;
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
CZTDetectionFunctionConfig::CZTDetectionFunctionConfig()
|
||||
{
|
||||
for(int i = 0; i < DETECTION_FCT_MAX_FCT; i++)
|
||||
{
|
||||
mZTDetectionConfig[i].AnalysisActive = false;
|
||||
mZTDetectionConfig[i].TKActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CZTDetectionFunctionConfig::operator =(CZTDetectionFunctionConfig& DF)
|
||||
{
|
||||
for(int i = 0; i < DETECTION_FCT_MAX_FCT; i++)
|
||||
{
|
||||
mZTDetectionConfig[i].AnalysisActive = DF.mZTDetectionConfig[i].AnalysisActive;
|
||||
mZTDetectionConfig[i].TKActive = DF.mZTDetectionConfig[i].TKActive;
|
||||
}
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CZTDetectionFunctionConfig &source)
|
||||
{
|
||||
for(int i = 0; i < DETECTION_FCT_MAX_FCT; i++)
|
||||
{
|
||||
out << source.mZTDetectionConfig[i].AnalysisActive
|
||||
<< source.mZTDetectionConfig[i].TKActive;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, CZTDetectionFunctionConfig &dest)
|
||||
{
|
||||
for(int i = 0; i < DETECTION_FCT_MAX_FCT; i++)
|
||||
{
|
||||
in >> dest.mZTDetectionConfig[i].AnalysisActive
|
||||
>> dest.mZTDetectionConfig[i].TKActive;
|
||||
}
|
||||
return in;
|
||||
}
|
||||
CSettingsData::CSettingsData()
|
||||
{
|
||||
|
||||
}
|
||||
CZTSettingsData::CZTSettingsData()
|
||||
{
|
||||
mDetectionFunctionSettings = new CZTDetectionFunctionConfig();
|
||||
mAutoExportZT1CSV = false;
|
||||
mAutoExportZT2CSV = false;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CZTNetworkConfig &source)
|
||||
{
|
||||
out << source.mZTID
|
||||
<< source.mIPAdress;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, CZTNetworkConfig &dest)
|
||||
{
|
||||
in >> dest.mZTID
|
||||
>> dest.mIPAdress;
|
||||
|
||||
return in;
|
||||
}
|
||||
@@ -0,0 +1,407 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Ces classes contiennent l'état de la Zone Tests et les informations nécessaires
|
||||
au fonctionnement des machines à états.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20130501 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ZTDATA_H
|
||||
#define ZTDATA_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QObject>
|
||||
#include <QTime>
|
||||
#include <QDataStream>
|
||||
#include <QVector>
|
||||
|
||||
enum eZTLOGType
|
||||
{
|
||||
ZT1_LOG_TYPE,
|
||||
ZT2_LOG_TYPE,
|
||||
UNKNOWN_LOG_TYPE
|
||||
};
|
||||
|
||||
enum eCDVState
|
||||
{
|
||||
CDV_STATE_OCCUPIED,
|
||||
CDV_STATE_FREE,
|
||||
CDV_STATE_ITI_CMD,
|
||||
CDV_STATE_UNKNOWN
|
||||
};
|
||||
|
||||
enum eSwitchCVDPosition
|
||||
{
|
||||
SWITCH_CDV_NORMAL_POSITION,
|
||||
SWITCH_CDV_REVERSE_POSITION,
|
||||
SWITCH_CDV_UNKNOWN_POSITION
|
||||
};
|
||||
|
||||
enum eCDVType
|
||||
{
|
||||
CDV_NORMAL_TYPE,
|
||||
CDV_SWITCH_TYPE
|
||||
};
|
||||
|
||||
enum eZTITI
|
||||
{
|
||||
ZT_PRIMARY_ITI, // Itinéraire 10/12 ou en voie normale
|
||||
ZT_SECONDARY_ITI, // Itinéraire 10/22 ou autre changement de voie (quai banalisé)
|
||||
ZT_MAX_ITI
|
||||
};
|
||||
enum eDetectionID
|
||||
{
|
||||
DETECTION_MAGNETIC_SENSOR_COUNT,
|
||||
DETECTION_FN_DETECTION,
|
||||
DETECTION_PG_DETECTION,
|
||||
DETECTION_PPI_DETECTION,
|
||||
DETECTION_PPE_DETECTION,
|
||||
|
||||
DETECTION_ZT2_MAGNETIC_SENCOR_COUNT,
|
||||
DETECTION_ZT2_PPI_DETECTION,
|
||||
DETECTION_ZT2_PPE_DETECTION,
|
||||
|
||||
DETECTION_PEQ1_DETECTION,
|
||||
DETECTION_PEQ2_DETECTION,
|
||||
|
||||
DETECTION_MAX_DETECTION_ID
|
||||
};
|
||||
|
||||
enum eDetectionFunctionID
|
||||
{
|
||||
DETECTION_FCT_FN,
|
||||
DETECTION_FCT_PG,
|
||||
DETECTION_FCT_PP,
|
||||
DETECTION_FCT_PP2,
|
||||
DETECTION_FCT_ZT1,
|
||||
DETECTION_FCT_ZT2,
|
||||
|
||||
DETECTION_FCT_MAX_FCT
|
||||
};
|
||||
|
||||
enum eTrainTypeID
|
||||
{
|
||||
TRAIN_TYPE_UNKNOWN,
|
||||
TRAIN_TYPE_MR63_MR73,
|
||||
TRAIN_TYPE_MPM10,
|
||||
|
||||
|
||||
TRAIN_TYPE_MAX_ID
|
||||
};
|
||||
|
||||
enum eOutilZTFlagsIndex
|
||||
{
|
||||
OUTILZT_FILE_PROTECTED_FLAG,
|
||||
OUTILSZT_UNUSED_FLAG_2,
|
||||
OUTILSZT_UNUSED_FLAG_3,
|
||||
OUTILSZT_UNUSED_FLAG_4,
|
||||
OUTILSZT_UNUSED_FLAG_5,
|
||||
OUTILSZT_UNUSED_FLAG_6,
|
||||
OUTILSZT_UNUSED_FLAG_7,
|
||||
OUTILSZT_UNUSED_FLAG_8,
|
||||
OUTILSZT_UNUSED_FLAG_9,
|
||||
OUTILSZT_UNUSED_FLAG_10
|
||||
};
|
||||
|
||||
enum eModbusCCTrainTypes
|
||||
{
|
||||
MODBUS_CC_TRAIN_TYPE_MR63 = 63,
|
||||
MODBUS_CC_TRAIN_TYPE_MR73 = 73,
|
||||
MODBUS_CC_TRAIN_TYPE_MPM10 = 10,
|
||||
MODBUS_CC_TRAIN_TYPE_MAINTENANCE = 0,
|
||||
MODBUS_CC_TRAIN_TYPE_INVALID_ATS_OFFLINE = 98,
|
||||
MODBUS_CC_TRAIN_TYPE_INVALID_SERVICE_REBOOT = 97,
|
||||
MODBUS_CC_TRAIN_TYPE_INVALID_NOT_UPDATED = 99,
|
||||
MODBUS_CC_TRAIN_TYPE_INVALID_SACL_OFFLINE = 96,
|
||||
|
||||
MODBUS_CC_TRAIN_TYPE_MAX_VALUE
|
||||
};
|
||||
|
||||
|
||||
enum eZT1FlagsID
|
||||
{
|
||||
ZT1_INT_PG_OFFSET_FLAG_ID,
|
||||
ZT1_EXT_PG_OFFSET_FLAG_ID,
|
||||
ZT1_PG_TRESHOLD_VALUE_FLAG_ID,
|
||||
ZT1_PG_CALIB_ON_FLAG_ID,
|
||||
|
||||
|
||||
ZT1_MAX_FLAG_ID
|
||||
};
|
||||
|
||||
enum eZTStatus
|
||||
{
|
||||
SB_ZT_ACTIVE_STATUS,
|
||||
SB_ZT_INACTIVE_STATUS,
|
||||
SB_ZT_NOT_PRESENT_STATUS,
|
||||
SB_ZT_DISABLED_STATUS,
|
||||
SB_ZT_MAX_STATUS
|
||||
};
|
||||
|
||||
|
||||
class CZTData
|
||||
{
|
||||
public:
|
||||
CZTData();
|
||||
|
||||
|
||||
|
||||
unsigned int mCIZT2;
|
||||
|
||||
static const char *ErrorString[];
|
||||
static const char *ShortErrorString[];
|
||||
static const char* GetErrorString(unsigned int ErrorID);
|
||||
static const char* GetShortErrorString(unsigned int ErrorID);
|
||||
|
||||
static const char *TrainTypeString[];
|
||||
static const char *GetTrainTypeString(unsigned int TrainType);
|
||||
static const char *GetModbusTrainTypeString(unsigned int TrainType);
|
||||
|
||||
};
|
||||
|
||||
//This class contains data from the ZT1 analysis thread
|
||||
//that is periodically communicated to the main thread
|
||||
class CZT1ThreadData
|
||||
{
|
||||
|
||||
public:
|
||||
~CZT1ThreadData();
|
||||
qint64 mTimeStamp; //nanosecs
|
||||
QDateTime mDateTime;
|
||||
quint32 mS1;
|
||||
quint32 mS2;
|
||||
quint32 mPInt;
|
||||
quint32 mPExt;
|
||||
quint32 mFN;
|
||||
quint32 mPG;
|
||||
|
||||
quint32 mBogie;
|
||||
quint32 mRank;
|
||||
quint32 mS1Count;
|
||||
quint32 mS2Count;
|
||||
quint32 mFNCount;
|
||||
qint32 mPGExtValue;
|
||||
qint32 mPGIntValue;
|
||||
qreal mTrainSpeed;
|
||||
quint32 mTrainType;
|
||||
|
||||
void operator=(CZT1ThreadData& a);
|
||||
};
|
||||
|
||||
|
||||
class CZT1FlagsData
|
||||
{
|
||||
public:
|
||||
qint32 mIntPGOffset;
|
||||
qint32 mExtPGOffset;
|
||||
qint32 mPGTresholdValue;
|
||||
qint32 mPGCalibrationON;
|
||||
qint32 mAnalogTracePresent;
|
||||
qint32 mIsProblematicPassage; //This flag will be set if problems have been detected but not sent to PCC due to PURE comitee rules.
|
||||
qint32 mTrainCompo1;
|
||||
qint32 mTrainCompo2;
|
||||
qint32 mTrainCompo3;
|
||||
qint32 mModbusTrainType;
|
||||
qint32 mZT1ITI;
|
||||
qint32 mUnusedFlag13;
|
||||
qint32 mUnusedFlag14;
|
||||
qint32 mUnusedFlag15;
|
||||
qint32 mUnusedFlag16;
|
||||
qint32 mUnusedFlag17;
|
||||
qint32 mUnusedFlag18;
|
||||
qint32 mUnusedFlag19;
|
||||
qint32 mUnusedFlag20;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CZT1FlagsData &source);
|
||||
QDataStream &operator>>(QDataStream &in, CZT1FlagsData &dest);
|
||||
|
||||
class CZT1LogData
|
||||
{
|
||||
public:
|
||||
CZT1LogData(CZT1ThreadData *ThreadData = 0);
|
||||
~CZT1LogData();
|
||||
|
||||
QDateTime mDateTime;
|
||||
qint64 mTimestamp;
|
||||
quint32 mCIZT1;
|
||||
quint32 mCDVApproach_ZT1;
|
||||
quint32 mCDVARM_ZT1;
|
||||
#ifdef USE_ANALOG_ACQUISITION
|
||||
qint32 mAnalogData; //The analog data must be written or read to/from file manually (not part of the QStream << operator overloading)
|
||||
#endif
|
||||
|
||||
CZT1ThreadData *mZT1ThreadData;
|
||||
};
|
||||
|
||||
class CZT1Log
|
||||
{
|
||||
public:
|
||||
// QList<CZT1LogData*> mZT1LogData;
|
||||
QVector<CZT1LogData*> mZT1LogData;
|
||||
CZT1FlagsData mZT1Flags;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CZT1LogData &source);
|
||||
QDataStream &operator>>(QDataStream &in, CZT1LogData &dest);
|
||||
|
||||
class CZT2ThreadData
|
||||
{
|
||||
public:
|
||||
qint64 mTimeStamp;
|
||||
quint32 mS1;
|
||||
quint32 mPPInt;
|
||||
quint32 mPPExt;
|
||||
|
||||
quint32 mBogie;
|
||||
quint32 mRank;
|
||||
quint32 mS1Count;
|
||||
};
|
||||
|
||||
class CZTDetectionData
|
||||
{
|
||||
public:
|
||||
|
||||
qint64 mTimeStamp;
|
||||
// QDateTime mDateTime;
|
||||
quint32 mDetectionID;
|
||||
quint32 mRank;
|
||||
// quint32 mBogie;
|
||||
|
||||
};
|
||||
QDataStream &operator<<(QDataStream &out, const CZTDetectionData &source);
|
||||
QDataStream &operator>>(QDataStream &in, CZTDetectionData &dest);
|
||||
|
||||
class CZT2FlagsData
|
||||
{
|
||||
public:
|
||||
qint32 mIsProblematicPassage; //This flag will be set if problems have been detected but not sent to PCC due to PURE comitee rules.
|
||||
qint32 mTrainCompo1;
|
||||
qint32 mTrainCompo2;
|
||||
qint32 mTrainCompo3;
|
||||
qint32 mModbusTrainType;
|
||||
qint32 mUnusedFlag6;
|
||||
qint32 mUnusedFlag7;
|
||||
qint32 mUnusedFlag8;
|
||||
qint32 mUnusedFlag9;
|
||||
qint32 mUnusedFlag10;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CZT2FlagsData &source);
|
||||
QDataStream &operator>>(QDataStream &in, CZT2FlagsData &dest);
|
||||
|
||||
class CZT2LogData
|
||||
{
|
||||
public:
|
||||
CZT2LogData(CZT2ThreadData *ThreadData = 0);
|
||||
~CZT2LogData();
|
||||
|
||||
QDateTime mDateTime;
|
||||
qint64 mTimestamp;
|
||||
quint32 mCIZT2;
|
||||
quint32 mCDVARM_ZT2;
|
||||
quint32 mCDVApproach_ZT2;
|
||||
|
||||
CZT2ThreadData *mZT2ThreadData;
|
||||
};
|
||||
QDataStream &operator<<(QDataStream &out, const CZT2LogData &source);
|
||||
QDataStream &operator>>(QDataStream &in, CZT2LogData &dest);
|
||||
|
||||
class CZT2Log
|
||||
{
|
||||
public:
|
||||
QVector<CZT2LogData*> mZT2LogData;
|
||||
CZT2FlagsData mZT2Flags;
|
||||
};
|
||||
|
||||
|
||||
class CZTDetectionConfig
|
||||
{
|
||||
public:
|
||||
bool AnalysisActive;
|
||||
bool TKActive;
|
||||
};
|
||||
|
||||
class CZTDetectionFunctionConfig
|
||||
{
|
||||
public:
|
||||
CZTDetectionFunctionConfig();
|
||||
CZTDetectionConfig mZTDetectionConfig[DETECTION_FCT_MAX_FCT];
|
||||
|
||||
void operator=(CZTDetectionFunctionConfig& a);
|
||||
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CZTDetectionFunctionConfig &source);
|
||||
QDataStream &operator>>(QDataStream &in, CZTDetectionFunctionConfig &dest);
|
||||
|
||||
class CZTSettingsData
|
||||
{
|
||||
public:
|
||||
CZTSettingsData();
|
||||
|
||||
CZTDetectionFunctionConfig *mDetectionFunctionSettings;
|
||||
bool mAutoExportZT1CSV;
|
||||
bool mAutoExportZT2CSV;
|
||||
int mPGTreshold;
|
||||
|
||||
};
|
||||
class CZTNetworkConfig
|
||||
{
|
||||
public:
|
||||
int mZTID;
|
||||
QString mIPAdress;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CZTNetworkConfig &source);
|
||||
QDataStream &operator>>(QDataStream &in, CZTNetworkConfig &dest);
|
||||
|
||||
class CSettingsData
|
||||
{
|
||||
public:
|
||||
CSettingsData();
|
||||
|
||||
QString mDataSourceDirectoryPath;
|
||||
QList<CZTNetworkConfig> mNetworkCfgList;
|
||||
|
||||
};
|
||||
|
||||
class CZTPGCalibrationData
|
||||
{
|
||||
public:
|
||||
qint64 mTimestamp;
|
||||
int mTrainNbr;
|
||||
qint32 mPGExtValue;
|
||||
qint32 mPGIntValue;
|
||||
};
|
||||
|
||||
class CZTLogFileInfo
|
||||
{
|
||||
public:
|
||||
QDateTime mStartDateTime;
|
||||
QDateTime mEndDateTime;
|
||||
QString mStationName;
|
||||
int mZTStationID;
|
||||
QString mZTLogFilePath;
|
||||
};
|
||||
|
||||
#endif // ZTDATA_H
|
||||
@@ -0,0 +1,391 @@
|
||||
|
||||
#include "ZTLogFilesMgr.h"
|
||||
#include <QFileInfo>
|
||||
#include <QTextStream>
|
||||
#include <QCoreApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QBuffer>
|
||||
|
||||
CZTLogFilesMgr::CZTLogFilesMgr()
|
||||
{
|
||||
|
||||
mProgramHandle = 0;
|
||||
|
||||
mDirParserThread = new QThread();
|
||||
mDirParserWorkerThread = new CDirParserThread();
|
||||
mDirParserWorkerThread->moveToThread(mDirParserThread);
|
||||
connect(mDirParserThread,SIGNAL(started()),mDirParserWorkerThread,SLOT(ParseDirectories()));
|
||||
connect(mDirParserThread,SIGNAL(finished()),this,SLOT(ThreadQuit()));
|
||||
connect(mDirParserThread,SIGNAL(terminated()),this,SLOT(ThreadTerminated()));
|
||||
connect(mDirParserWorkerThread,SIGNAL(NewLogParsed(QString,bool)),this,SLOT(NewZTLogParsed(QString,bool)));
|
||||
connect(mDirParserWorkerThread,SIGNAL(ParsingFinished(int)),this,SLOT(DirParsingFinished(int)));
|
||||
connect(mDirParserWorkerThread,SIGNAL(EmptyDirParsed()),this,SLOT(EmptyDirParsed()));
|
||||
|
||||
mDatabaseParsingTimer = new QTimer();
|
||||
mDatabaseParsingTimer->setInterval(60000);
|
||||
connect(mDatabaseParsingTimer,SIGNAL(timeout()),this,SLOT(ParsingTimerExpired()));
|
||||
|
||||
mSaveDBFile = false;
|
||||
}
|
||||
|
||||
CZTLogFilesMgr::~CZTLogFilesMgr()
|
||||
{
|
||||
delete mDirParserThread;
|
||||
delete mDirParserWorkerThread;
|
||||
delete mDatabaseParsingTimer;
|
||||
}
|
||||
|
||||
|
||||
void CZTLogFilesMgr::DestroyZTLogFilesList()
|
||||
{
|
||||
mZTLogFilesList.clear();
|
||||
}
|
||||
|
||||
void CZTLogFilesMgr::ParseZTLogFiles(bool RebuildDatabase)
|
||||
{
|
||||
mZTLogFilesList.clear();
|
||||
|
||||
if(RebuildDatabase == true)
|
||||
{
|
||||
mSaveDBFile = true;
|
||||
// mDirParserWorkerThread->SetParsingInfo(QDir(mLogDatabaseDir),"*.txt",false);
|
||||
mDirParserThread->start();
|
||||
//mProgramHandle->ZTLogFilesFetchingBegin(this);
|
||||
return ;
|
||||
}
|
||||
else
|
||||
{
|
||||
QDir BaseDir(mLogDatabaseDir);
|
||||
QString DatabaseFilePath = BaseDir.filePath("ZTLogs.zdb");
|
||||
// DatabaseFilePath += "Trains.zdb";
|
||||
QFile* DatabaseFile = new QFile(BaseDir.filePath("ZTLogs.zdb")/*DatabaseFilePath*/);
|
||||
|
||||
|
||||
if(DatabaseFile)
|
||||
{
|
||||
if(DatabaseFile->open(QIODevice::ReadOnly | QIODevice::Unbuffered) == false)
|
||||
{
|
||||
mSaveDBFile = true;
|
||||
// mDirParserWorkerThread->SetParsingInfo(QDir(mLogDatabaseDir),"*.txt",false);
|
||||
mDirParserThread->start();
|
||||
// mProgramHandle->ZTLogFilesFetchingBegin(this);
|
||||
|
||||
delete DatabaseFile;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(0,"Erreur","Impossible de créer le fichier DB ZTLog");
|
||||
return ;
|
||||
}
|
||||
|
||||
QByteArray DBData = DatabaseFile->readAll();
|
||||
QDataStream *DBStrm = new QDataStream(DBData);
|
||||
|
||||
qint32 NBRecords;
|
||||
*DBStrm >> NBRecords;
|
||||
|
||||
for(qint32 i = 0; i < NBRecords; i++)
|
||||
{
|
||||
CZTLogFileInfo NewElement;
|
||||
|
||||
*DBStrm >> NewElement.mStationName
|
||||
>> NewElement.mZTStationID
|
||||
>> NewElement.mStartDateTime
|
||||
>> NewElement.mEndDateTime
|
||||
>> NewElement.mZTLogFilePath;
|
||||
|
||||
mZTLogFilesList.append(NewElement);
|
||||
}
|
||||
|
||||
DatabaseFile->close();
|
||||
delete DatabaseFile;
|
||||
delete DBStrm;
|
||||
|
||||
DirParsingFinished(1);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CZTLogFilesMgr::NewZTLogParsed(QString FilePath, bool KeepData)
|
||||
{
|
||||
Q_UNUSED(KeepData)
|
||||
|
||||
// mProgramHandle->ZTLogFilesFetchingTick(this,mZTLogFilesList.size(),FilePath);
|
||||
ExtractLogInfo(FilePath);
|
||||
mDatabaseParsingTimer->start();
|
||||
}
|
||||
|
||||
void CZTLogFilesMgr::DirParsingFinished(int Res)
|
||||
{
|
||||
qDebug("ZTLog Files Parsing finished with result %d",Res);
|
||||
mDirParserThread->quit();
|
||||
mDatabaseParsingTimer->stop();
|
||||
// mProgramHandle->ZTLogFilesDatabaseLoaded(this,Res);
|
||||
qDebug("Parsed %d ZTLog files",mZTLogFilesList.size());
|
||||
|
||||
if(mSaveDBFile == true)
|
||||
{
|
||||
SaveDatabaseFile();
|
||||
}
|
||||
}
|
||||
|
||||
int CZTLogFilesMgr::GetZTLogFilesCount()
|
||||
{
|
||||
return mZTLogFilesList.size();
|
||||
}
|
||||
|
||||
void CZTLogFilesMgr::ParsingTimerExpired()
|
||||
{
|
||||
qDebug("ZTLogs Parsing timer timeout");
|
||||
mDirParserWorkerThread->KillThread();
|
||||
mDirParserThread->terminate();
|
||||
DirParsingFinished(2);
|
||||
}
|
||||
|
||||
void CZTLogFilesMgr::EmptyDirParsed()
|
||||
{
|
||||
//The thread is not stuck. Kick the timer...
|
||||
mDatabaseParsingTimer->start();
|
||||
}
|
||||
|
||||
void CZTLogFilesMgr::ThreadQuit()
|
||||
{
|
||||
// qDebug("Thread quit slot");
|
||||
}
|
||||
|
||||
void CZTLogFilesMgr::ThreadTerminated()
|
||||
{
|
||||
// qDebug("Thread terminated slot");
|
||||
}
|
||||
|
||||
|
||||
bool CZTLogFilesMgr::ExtractLogInfo(QString LogFilePath)
|
||||
{
|
||||
QFileInfo LogFileInfo(LogFilePath);
|
||||
|
||||
if(LogFileInfo.fileName() != "ZTLog.txt")
|
||||
return false;
|
||||
|
||||
CZTLogFileInfo NewLogFileInfo;
|
||||
|
||||
|
||||
int line =0;
|
||||
QFile *LogFile = new QFile(LogFilePath);
|
||||
if(LogFile)
|
||||
{
|
||||
if(LogFile->open(QIODevice::ReadOnly | QIODevice::Text | QIODevice::Unbuffered) == true)
|
||||
{
|
||||
QString LogText(LogFile->readAll());
|
||||
|
||||
QTextStream strm(&LogText);
|
||||
strm.seek(0);
|
||||
|
||||
QString temp;
|
||||
|
||||
//find a valid line
|
||||
do
|
||||
{
|
||||
temp = strm.readLine();
|
||||
line++;
|
||||
|
||||
if(strm.atEnd())
|
||||
break;
|
||||
}
|
||||
while(temp.length() < 10);
|
||||
|
||||
// temp = strm.readLine();
|
||||
QStringList parts = temp.split(" : ");
|
||||
QString LineText,DateString;
|
||||
|
||||
|
||||
if(parts.size() != 0)
|
||||
{
|
||||
LineText.clear();
|
||||
|
||||
DateString = parts.at(0);
|
||||
NewLogFileInfo.mStartDateTime = QDateTime::fromString(DateString,"yyyy/MM/dd - hh:mm:ss.zzz");
|
||||
}
|
||||
|
||||
//go to end of file
|
||||
QString LastValidLine;
|
||||
do
|
||||
{
|
||||
temp = strm.readLine();
|
||||
if(temp.size() >=10)
|
||||
LastValidLine = temp;
|
||||
}
|
||||
while(!strm.atEnd());
|
||||
|
||||
parts = LastValidLine.split(" : ");
|
||||
|
||||
if(parts.size() != 0)
|
||||
{
|
||||
DateString = parts.at(0);
|
||||
NewLogFileInfo.mEndDateTime = QDateTime::fromString(DateString,"yyyy/MM/dd - hh:mm:ss.zzz");
|
||||
}
|
||||
LogFile->close();
|
||||
}
|
||||
delete LogFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
NewLogFileInfo.mZTLogFilePath = LogFilePath;
|
||||
|
||||
if(LogFilePath.contains("ANG"))
|
||||
{
|
||||
NewLogFileInfo.mZTStationID = ANGRIGNON_ZT_ID;
|
||||
// NewLogFileInfo.mStationName = mProgramHandle->GetStationName(ANGRIGNON_ZT_ID);// "Angrignon";
|
||||
}
|
||||
else if(LogFilePath.contains("BUQ4"))
|
||||
{
|
||||
NewLogFileInfo.mZTStationID = BERRI_UQAM_ZT_ID;
|
||||
// NewLogFileInfo.mStationName = mProgramHandle->GetStationName(BERRI_UQAM_ZT_ID);//"Berri-UQAM";
|
||||
}
|
||||
else if(LogFilePath.contains("HBOU"))
|
||||
{
|
||||
NewLogFileInfo.mZTStationID = HENRI_BOURASSA_ZT_ID;
|
||||
// NewLogFileInfo.mStationName = mProgramHandle->GetStationName(HENRI_BOURASSA_ZT_ID);//"Henri-Bourassa";
|
||||
}
|
||||
else if(LogFilePath.contains("HBGR"))
|
||||
{
|
||||
NewLogFileInfo.mZTStationID = HONORE_BEAUGRAND_ZT_ID;
|
||||
// NewLogFileInfo.mStationName = mProgramHandle->GetStationName(HONORE_BEAUGRAND_ZT_ID);//"Honoré-Beaugrand";
|
||||
}
|
||||
else if(LogFilePath.contains("LONG"))
|
||||
{
|
||||
NewLogFileInfo.mZTStationID = LONGUEUIL_ZT_ID;
|
||||
// NewLogFileInfo.mStationName = mProgramHandle->GetStationName(LONGUEUIL_ZT_ID);//"Longueuil";
|
||||
}
|
||||
else if(LogFilePath.contains("MMOY"))
|
||||
{
|
||||
NewLogFileInfo.mZTStationID = MONTMORENCY_ZT_ID;
|
||||
// NewLogFileInfo.mStationName = mProgramHandle->GetStationName(MONTMORENCY_ZT_ID);//"Montmorency";
|
||||
}
|
||||
// else if(LogFilePath.contains("MMO"))
|
||||
// {
|
||||
// NewLogFileInfo.mZTStationID = MONTMORENCY_10_12_ZT_ID;
|
||||
// // NewLogFileInfo.mStationName = mProgramHandle->GetStationName(MONTMORENCY_10_12_ZT_ID);//"Montmorency 10/12";
|
||||
// }
|
||||
// else if(LogFilePath.contains("MMO2"))
|
||||
// {
|
||||
// NewLogFileInfo.mZTStationID = MONTMORENCY_10_22_ZT_ID;
|
||||
// // NewLogFileInfo.mStationName = mProgramHandle->GetStationName(MONTMORENCY_10_22_ZT_ID);///"Montmorency 10/22";
|
||||
// }
|
||||
else if(LogFilePath.contains("SMIC"))
|
||||
{
|
||||
NewLogFileInfo.mZTStationID = SAINT_MICHEL_ZT_ID;
|
||||
// NewLogFileInfo.mStationName = mProgramHandle->GetStationName(SAINT_MICHEL_ZT_ID);//"Saint-Michel";
|
||||
}
|
||||
else if(LogFilePath.contains("SNW5"))
|
||||
{
|
||||
NewLogFileInfo.mZTStationID = SNOWDON_ZT_ID;
|
||||
// NewLogFileInfo.mStationName = mProgramHandle->GetStationName(SNOWDON_ZT_ID);//"Snowdon";
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
mZTLogFilesList.append(NewLogFileInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CZTLogFilesMgr::ParseDir(QDir dir)
|
||||
{
|
||||
|
||||
QStringList LogFilters;
|
||||
QFileInfoList list;
|
||||
// QString LogDataDir = mProgramHandle->GetLogDataPath();
|
||||
LogFilters << "*.txt";
|
||||
|
||||
//Load files in base directory
|
||||
QDir LogDir(dir);
|
||||
LogDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||
LogDir.setNameFilters(LogFilters);
|
||||
LogDir.setSorting(QDir::Name);
|
||||
list = LogDir.entryInfoList();
|
||||
if(list.size() != 0)
|
||||
{
|
||||
//Extract data for each passage
|
||||
for(int i = 0; i < list.size(); i++)
|
||||
{
|
||||
ExtractLogInfo(list.at(i).absoluteFilePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Check for subdirectories
|
||||
QDir SubDirectories(dir);
|
||||
|
||||
SubDirectories.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
|
||||
QFileInfoList SubDirList = SubDirectories.entryInfoList();
|
||||
for(int i = 0; i < SubDirList.size(); i++)
|
||||
{
|
||||
ParseDir(QDir(SubDirList.at(i).absoluteFilePath()));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CZTLogFilesMgr::SaveDatabaseFile()
|
||||
{
|
||||
qDebug("Saving ZTLogs.zdb database");
|
||||
QDir BaseDir(mLogDatabaseDir);
|
||||
QString DatabaseFilePath = BaseDir.filePath("ZTLogs.zdb");
|
||||
// DatabaseFilePath += "Trains.zdb";
|
||||
QFile* DatabaseFile = new QFile(BaseDir.filePath("ZTLogs.zdb")/*DatabaseFilePath*/);
|
||||
|
||||
|
||||
if(DatabaseFile)
|
||||
{
|
||||
if(DatabaseFile->open(QIODevice::WriteOnly | QIODevice::Unbuffered) == false)
|
||||
{
|
||||
QMessageBox::information(0,"Erreur","Impossible de créer le fichier DB ZTLog");
|
||||
delete DatabaseFile;
|
||||
return RET_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(0,"Erreur","Impossible de créer le fichier DB ZTLog");
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
|
||||
QByteArray byteArray;
|
||||
QBuffer FileBuffer(&byteArray);
|
||||
FileBuffer.open(QIODevice::WriteOnly);
|
||||
QDataStream *DBStrm = new QDataStream(&FileBuffer);
|
||||
|
||||
qint32 NBRecords = mZTLogFilesList.size();
|
||||
*DBStrm << NBRecords;
|
||||
|
||||
for(int i = 0; i < mZTLogFilesList.size(); i++)
|
||||
{
|
||||
*DBStrm << mZTLogFilesList.at(i).mStationName
|
||||
<< mZTLogFilesList.at(i).mZTStationID
|
||||
<< mZTLogFilesList.at(i).mStartDateTime
|
||||
<< mZTLogFilesList.at(i).mEndDateTime
|
||||
<< mZTLogFilesList.at(i).mZTLogFilePath;
|
||||
}
|
||||
|
||||
FileBuffer.seek(0);
|
||||
DatabaseFile->write(FileBuffer.buffer());
|
||||
DatabaseFile->flush();
|
||||
|
||||
FileBuffer.close();
|
||||
DatabaseFile->close();
|
||||
delete DatabaseFile;
|
||||
delete DBStrm;
|
||||
mSaveDBFile = false;
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Cette classe est responsable de la création d'une liste de tous lesfichiers
|
||||
ZTLog présents dans la base de données. À ne pas confondre avec les fichiers
|
||||
de passage.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20150227 JFM
|
||||
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ZTLOGFILESMGR_H
|
||||
#define ZTLOGFILESMGR_H
|
||||
|
||||
#include "ZTData.h"
|
||||
#include "GlobalDefine.h"
|
||||
#include <QList>
|
||||
#include <QDir>
|
||||
#include "DirParserThread.h"
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
|
||||
class COutilZT;
|
||||
|
||||
class CZTLogFilesMgr: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CZTLogFilesMgr();
|
||||
~CZTLogFilesMgr();
|
||||
|
||||
COutilZT *mProgramHandle;
|
||||
|
||||
void DestroyZTLogFilesList();
|
||||
void ParseZTLogFiles(bool RebuildDatabase);
|
||||
bool ExtractLogInfo(QString LogFilePath);
|
||||
void SetLogDataDir(QString Dir){mLogDatabaseDir = Dir;}
|
||||
QList<CZTLogFileInfo> *GetZTLogsList(){return &mZTLogFilesList;}
|
||||
int GetZTLogFilesCount();
|
||||
int SaveDatabaseFile();
|
||||
|
||||
private:
|
||||
|
||||
QList<CZTLogFileInfo> mZTLogFilesList;
|
||||
QString mLogDatabaseDir;
|
||||
QThread *mDirParserThread;
|
||||
CDirParserThread *mDirParserWorkerThread;
|
||||
QTimer *mDatabaseParsingTimer;
|
||||
bool mSaveDBFile;
|
||||
|
||||
|
||||
int ParseDir(QDir dir);
|
||||
|
||||
public slots:
|
||||
void NewZTLogParsed(QString,bool);
|
||||
void DirParsingFinished(int);
|
||||
void ParsingTimerExpired();
|
||||
void EmptyDirParsed();
|
||||
|
||||
|
||||
void ThreadQuit();
|
||||
void ThreadTerminated();
|
||||
};
|
||||
|
||||
#endif // ZTLOGFILESMGR_H
|
||||
@@ -0,0 +1,82 @@
|
||||
#include "ZTStats.h"
|
||||
#include "MainWindow.h"
|
||||
#include <QFile>
|
||||
|
||||
CZTStats::CZTStats(CMainWindow *MainWindowPtr)
|
||||
{
|
||||
mMainWindow = MainWindowPtr;
|
||||
mReportGenerator.mProgramPtr = this;
|
||||
}
|
||||
|
||||
void CZTStats::Init()
|
||||
{
|
||||
mMainWindow->mReportPage->mProgramHandle = this;
|
||||
// mProgramConfig.mDataSourceDirectoryPaths.append("D:\\Main\\Dev\\ZTStats\\LOGS");
|
||||
QString Path = "C:";
|
||||
QFile *CfgFile = new QFile("Source.txt");
|
||||
if(CfgFile != 0)
|
||||
{
|
||||
|
||||
CfgFile->open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
while(!CfgFile->atEnd())
|
||||
{
|
||||
Path = QString(CfgFile->readLine()).trimmed();
|
||||
if(Path.contains("#") == false)
|
||||
{
|
||||
QDir test(Path);
|
||||
if(test.exists() == true)
|
||||
{
|
||||
mProgramConfig.mDataSourceDirectoryPaths.append(Path);
|
||||
}
|
||||
else
|
||||
{
|
||||
mMainWindow->mReportPage->UpdateProgressStatus(QString("Répertoire invalide dans le fichier de configuration: %1").arg(Path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if(Path.isEmpty())
|
||||
// {
|
||||
// Path = "C:";
|
||||
// }
|
||||
|
||||
CfgFile->close();
|
||||
delete CfgFile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(int i = 0; i < mProgramConfig.mDataSourceDirectoryPaths.size(); i++)
|
||||
{
|
||||
UpdateReportProgressStatus(QString("Répertoire source: %1").arg(mProgramConfig.mDataSourceDirectoryPaths.at(i)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CZTStats::Run()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int CZTStats::GenerateReportRequest(QString OutputFileName, CReportConfigData ReportConfigFilters)
|
||||
{
|
||||
mReportGenerator.GenerateReport(OutputFileName,mProgramConfig,ReportConfigFilters);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CZTStats::UpdateReportProgressStatus(QString status)
|
||||
{
|
||||
mMainWindow->mReportPage->UpdateProgressStatus(status);
|
||||
}
|
||||
|
||||
void CZTStats::ReportCreationFinished(QString ReportFilePath)
|
||||
{
|
||||
mMainWindow->mReportPage->ReportCreationFinished(ReportFilePath);
|
||||
}
|
||||
|
||||
void CZTStats::AbortReportCreationRequest()
|
||||
{
|
||||
mReportGenerator.AbortReportCreation();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef ZTSTATS_H
|
||||
#define ZTSTATS_H
|
||||
|
||||
#include "ReportGenerator.h"
|
||||
#include "ReportSettingsData.h"
|
||||
|
||||
class CMainWindow;
|
||||
|
||||
class CZTStats
|
||||
{
|
||||
public:
|
||||
CZTStats(CMainWindow *MainWindowPtr);
|
||||
|
||||
void Init();
|
||||
void Run();
|
||||
|
||||
int GenerateReportRequest(QString OutputFileName,CReportConfigData ReportConfigFilters);
|
||||
void UpdateReportProgressStatus(QString status);
|
||||
void ReportCreationFinished(QString ReportFilePath);
|
||||
void AbortReportCreationRequest();
|
||||
|
||||
CReportGenerator mReportGenerator;
|
||||
CReportProgramSettingsData mProgramConfig;
|
||||
|
||||
CMainWindow *mMainWindow;
|
||||
|
||||
};
|
||||
|
||||
#endif // ZTSTATS_H
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "MainWindow.h"
|
||||
#include <QApplication>
|
||||
#include "ZTStats.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
CMainWindow w;
|
||||
|
||||
CZTStats Program(&w);
|
||||
Program.Init();
|
||||
Program.Run();
|
||||
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user