swift
interpolationlogger.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2014 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_MISC_SIMULATION_INTERPOLATION_INTERPOLATIONLOGGER_H
7 #define SWIFT_MISC_SIMULATION_INTERPOLATION_INTERPOLATIONLOGGER_H
8 
9 #include <QObject>
10 #include <QStringList>
11 #include <QtGlobal>
12 
18 
19 namespace swift::misc
20 {
21  class CWorker;
22  namespace simulation
23  {
26  {
27  QChar interpolator;
28  qint64 tsCurrent = -1;
29  qint64 tsInterpolated = -1;
30  double groundFactor = -1;
31  double simTimeFraction = -1;
32  double deltaSampleTimesMs = -1;
33  bool useParts = false;
34  bool interpolantRecalc = false;
35  int noNetworkSituations = 0;
36  int noInvalidSituations = 0;
37  QString elevationInfo;
38  QString altCorrection;
49 
51  double deltaCurrentToInterpolatedTime() const { return static_cast<double>(tsCurrent - tsInterpolated); }
52 
54  const QString &interpolationType() const;
55 
58  {
59  return interpolationSituations.frontOrDefault();
60  }
61 
64  {
65  return interpolationSituations.backOrDefault();
66  }
67 
69  const aviation::CAircraftSituation &secondInterpolationSituation() const;
70 
72  QString toQString(bool withSetup, bool withCurrentSituation, bool withElevation, bool withOtherPositions,
73  bool withDeltaTimes, const QString &separator = { " " }) const;
74  };
75 
78  {
79  qint64 tsCurrent = -1;
80  bool empty = false;
81  int noNetworkParts = 0;
84 
86  QString toQString(const QString &separator = { " " }) const;
87  };
88 
90  class SWIFT_MISC_EXPORT CInterpolationLogger : public QObject
91  {
92  Q_OBJECT
93 
94  public:
96  CInterpolationLogger(QObject *parent = nullptr);
97 
99  static const QStringList &getLogCategories();
100 
102  CWorker *writeLogInBackground(bool clearLog);
103 
105  void clearLog();
106 
108  static QStringList getLatestLogFiles();
109 
111  static QString getLogDirectory();
112 
116  void logInterpolation(const SituationLog &log);
117 
121  void logParts(const PartsLog &log);
122 
124  void setMaxSituations(int max);
125 
128  QList<SituationLog> getSituationsLog() const;
129 
132  QList<PartsLog> getPartsLog() const;
133 
136  QList<SituationLog> getSituationsLog(const aviation::CCallsign &cs) const;
137 
140  QList<PartsLog> getPartsLog(const aviation::CCallsign &cs) const;
141 
144  SituationLog getLastSituationLog() const;
145 
148  SituationLog getLastSituationLog(const aviation::CCallsign &cs) const;
149 
152  aviation::CAircraftSituation getLastSituation() const;
153 
156  aviation::CAircraftSituation getLastSituation(const aviation::CCallsign &cs) const;
157 
160  aviation::CAircraftParts getLastParts() const;
161 
164  aviation::CAircraftParts getLastParts(const aviation::CCallsign &cs) const;
165 
168  PartsLog getLastPartsLog() const;
169 
172  PartsLog getLastPartsLog(const aviation::CCallsign &cs) const;
173 
175  static const QString &filePatternInterpolationLog();
176 
178  static const QString &filePatternPartsLog();
179 
181  static const QStringList &filePatterns();
182 
184  static QString msSinceEpochToTime(qint64 ms);
185 
187  static QString msSinceEpochToTimeAndTimestamp(qint64 ms);
188 
190  static QString msSinceEpochToTime(qint64 t1, qint64 t2, qint64 t3 = -1);
191 
192  private:
194  static QString getHtmlInterpolationLog(const QList<SituationLog> &logs);
195 
197  static QString getKmlChangedSituations(const QList<SituationLog> &logs);
198 
200  static QString getKmlElevations(const QList<SituationLog> &logs);
201 
203  static QString getKmlInterpolatedSituations(const QList<SituationLog> &logs);
204 
206  static QString getHtmlPartsLog(const QList<PartsLog> &logs);
207 
209  static CStatusMessageList writeLogFiles(const QList<SituationLog> &interpolation,
210  const QList<PartsLog> &getPartsLog);
211 
213  static CStatusMessage logStatusFileWriting(bool success, const QString &fileName);
214 
215  mutable QReadWriteLock m_lockSituations;
216  mutable QReadWriteLock m_lockParts;
217  int m_maxSituations = 2500;
218  QList<PartsLog> m_partsLogs;
219  QList<SituationLog> m_situationLogs;
220  };
221  } // namespace simulation
222 } // namespace swift::misc
223 #endif // SWIFT_MISC_SIMULATION_INTERPOLATION_INTERPOLATIONLOGGER_H
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
Class for doing some arbitrary parcel of work in its own thread.
Definition: worker.h:188
Value object encapsulating information of aircraft's parts.
Definition: aircraftparts.h:26
Value object about changes in situations.
Value object encapsulating information of an aircraft's situation.
Value object encapsulating information of a callsign.
Definition: callsign.h:30
Physical unit length (length)
Definition: length.h:18
Value object for interpolator and rendering per callsign.
Record internal state of interpolator for debugging.
Free functions in swift::misc.
Log entry for parts interpolation.
aviation::CAircraftParts parts
parts to be logged
aviation::CCallsign callsign
current callsign
Log entry for situation interpolation.
double deltaCurrentToInterpolatedTime() const
Delta time between interpolation and current time.
QChar interpolator
what interpolator is used
aviation::CAircraftSituationList interpolationSituations
the interpolator uses 2, 3 situations (latest at end)
const aviation::CAircraftSituation & newestInterpolationSituation() const
The newest situation.
aviation::CCallsign callsign
current callsign
aviation::CAircraftSituation situationCurrent
interpolated situation
const aviation::CAircraftSituation & oldestInterpolationSituation() const
The oldest situation.
QString elevationInfo
info about elevation retrieval
aviation::CAircraftSituationChange change
change
aviation::CAircraftParts parts
corresponding parts used in interpolator
QString altCorrection
info about altitude correction as CAircraftSituation::AltitudeCorrection
CInterpolationAndRenderingSetupPerCallsign usedSetup
used setup
#define SWIFT_MISC_EXPORT
Export a class or function from the library.