Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

+83
View File
@@ -0,0 +1,83 @@
/**
* DbWriter for RecordingManagement
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <QHash>
#include <QMutex>
#include <QThread>
#include <QVector>
#include <memory>
#include "logger.h"
class NSqlQuery;
namespace NGL
{
class Settings;
}
namespace RecordReplay
{
class RecordReplayPlugin;
}
namespace RecordingManagement
{
class DatabaseInterface;
class DbWriterSnapshot : public QObject
{
Q_OBJECT
public:
explicit DbWriterSnapshot(const QVector<RecordReplay::RecordReplayPlugin *> &plugins,
int exerciseId,
NGL::Settings *settings);
~DbWriterSnapshot();
/**
* Set the minimum sample time per topic which was found during the last record calls
* to ensure, that all telegrams are considered during snapshot creation
* because some telegrams can come in very later (tetra buffering / player unit out of tetra coverage)
*/
void setMinRecordedSampleTimes(const QHash<QString, qint64> &minRecordedSampleTimes);
void init();
void cleanup();
private:
static QString dbConnectionName() { return QStringLiteral("DbWriterSnapshotThread"); }
void initSnapshot();
QHash<QString, qint64> getMinRecordedSampleTimes(qint64 getUntil);
void writeSnapshotData();
void writeSnapshotDataPlugin(qint64 endInterval,
NSqlQuery &recSnapshotQuery,
RecordReplay::RecordReplayPlugin *recPlugin,
const QHash<QString, qint64> &minRecordedSampleTimes);
private:
QVector<RecordReplay::RecordReplayPlugin *> m_plugins;
int m_snapshotInterval;
QHash<QString, qint64> m_minRecordedSampleTimes; // do not access directly, only through minRecordedSampleTime()
QMutex m_minRecordedSampleTimesMutex;
std::shared_ptr<DatabaseInterface> m_dbInterface;
int m_exerciseId;
NGL::Settings *m_settings;
LOGGER_T m_logger;
};
class DbWriterSnapshotThread : public QThread
{
Q_OBJECT
public:
DbWriterSnapshotThread(DbWriterSnapshot *dbWriterSnapshot, QObject *parent = nullptr)
: QThread(parent)
, m_dbWriterSnapshot(dbWriterSnapshot)
{}
protected:
void run() override final;
private:
DbWriterSnapshot *m_dbWriterSnapshot;
};
} // namespace RecordingManagement