You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

148 regels
4.0 KiB

  1. /*******************************************************************************
  2. * *
  3. * Société de Transports de Montréal. *
  4. * 2012 - 2013 *
  5. * *
  6. * Projet Zones Tests *
  7. * *
  8. * *
  9. * *
  10. *******************************************************************************/
  11. /*
  12. Description:
  13. Description du fichier si nécessaire.
  14. */
  15. /* ************************************************************************** */
  16. /* Revision:
  17. ### YYYMMDD JFM
  18. Verision d'origine.
  19. ### YYYYMMDD Description du besoin ou du bug
  20. Description du changement.
  21. */
  22. /* ************************************************************************** */
  23. #ifndef LOGMGR_H
  24. #define LOGMGR_H
  25. #include "ZTData.h"
  26. #include "GlobalDefine.h"
  27. #include <QList>
  28. #include <QDir>
  29. #include <QTimer>
  30. #include <QReadWriteLock>
  31. #include "DirParserThread.h"
  32. class CLogElement
  33. {
  34. public:
  35. unsigned int mZTLogType;
  36. virtual ~CLogElement();
  37. };
  38. //QDataStream &operator<<(QDataStream &out, const CLogElement &source);
  39. //QDataStream &operator>>(QDataStream &in, CLogElement &dest);
  40. class CZT1LogElement : public CLogElement
  41. {
  42. public:
  43. CZT1LogElement(){mZTLogType=ZT1_LOG_TYPE;}
  44. ~CZT1LogElement();
  45. QDateTime mPassageDateTime;
  46. QVector<CZT1LogData*> mZTLogData;
  47. QVector<CZTDetectionData*> mZTDetections;
  48. quint32 mTrainType;
  49. quint32 mNbElements;
  50. quint64 mThreadDataStartTime, mThreadDataEndTime;
  51. QString mLogFileName;
  52. qreal mMeanSpeed;
  53. CZT1FlagsData mFlags;
  54. QString mStationName;
  55. bool mFileProtected;
  56. int mFileVersion;
  57. bool mDetectionFlagsValid;
  58. };
  59. //QDataStream &operator<<(QDataStream &out, const CZT1LogElement &source);
  60. //QDataStream &operator>>(QDataStream &in, CZT1LogElement &dest);
  61. class CZT2LogElement : public CLogElement
  62. {
  63. public:
  64. CZT2LogElement(){mZTLogType = ZT2_LOG_TYPE;}
  65. ~CZT2LogElement();
  66. QDateTime mPassageDateTime;
  67. QVector<CZT2LogData*> mZTLogData;
  68. QVector<CZTDetectionData*> mZTDetections;
  69. QString mLogFileName;
  70. quint32 mNbElements;
  71. QString mStationName;
  72. CZT2FlagsData mFlags;
  73. bool mFileProtected;
  74. bool mDetectionFlagsValid;
  75. };
  76. class COutilZT;
  77. class CLogMgr : public QObject
  78. {
  79. Q_OBJECT
  80. public:
  81. CLogMgr();
  82. ~CLogMgr();
  83. COutilZT *mProgramHandle;
  84. unsigned int GetLogsCount();
  85. QList<CLogElement*> *GetLogsList();
  86. unsigned int ParseLogs(bool RebuildDatabase = false, bool KeepData = false);
  87. unsigned int ParseNewLog(QString FileName, bool KeepData = false);
  88. unsigned int ParseImportedLogs(QStringList *NewLogFiles);
  89. CLogElement* LoadLogData(CLogElement * Element);
  90. unsigned int FreeLogData(CLogElement * Element);
  91. unsigned int DeleteLog(int LogIndex);
  92. void SetLogDataDir(QString Dir){mLogDataDir = Dir;}
  93. bool ParseNextLog();
  94. unsigned int SaveDatabaseFile();
  95. unsigned int RebuildDatabaseFile();
  96. unsigned int ProtectLogElementFile(bool IsProtected, CLogElement *Element);
  97. QTimer *mDatabaseParsingTimer;
  98. QDir GetBaseLogDataDir(){return QDir(mLogDataDir);}
  99. private:
  100. CDirParserThread *mDirParserWorkerThread;
  101. QThread *mDirParserThread;
  102. QList<CLogElement*> mPassagesList;
  103. unsigned int DestroyLogList();
  104. int ParseDir(QDir dir, bool KeepData = false);
  105. QFileInfoList mLogsFilelist;
  106. unsigned int mLogsFileIndex;
  107. QString mLogDataDir;
  108. bool mParsingFinished;
  109. unsigned int mDatabaseFileCounter;
  110. bool mSaveDBFile;
  111. public slots:
  112. void NewLogParsed(QString,bool);
  113. void NewLogParsed(CLogElement*);
  114. void DirParsingFinished(int);
  115. void ParsingTimerExpired();
  116. void EmptyDirParsed();
  117. void ThreadQuit();
  118. void ThreadTerminated();
  119. };
  120. #endif // LOGMGR_H