132 lines
3.7 KiB
C++
Executable File
132 lines
3.7 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Data Plugin for The Timeline - DDS => GUI
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*
|
|
* Created by Mike Wille, SLSE, 2017-03-27
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <PluginInterfaces/data_plugin_interface.h>
|
|
#include <Plugins/Timeline/tln_data_plugin_interface.h>
|
|
#include <ExerciseEventManagement/eem.hpp>
|
|
|
|
#include <QHash>
|
|
#include <QMap>
|
|
#include <QVector>
|
|
|
|
class QTimer;
|
|
class QWebSocket;
|
|
namespace TimeLineManagement
|
|
{
|
|
class DataPlugin final : public QObject, public DataPluginBase::Plugin
|
|
{
|
|
Q_PLUGIN_METADATA(IID "data:3:tln")
|
|
Q_INTERFACES(DataPluginBase::Plugin)
|
|
|
|
Q_OBJECT
|
|
public:
|
|
DataPlugin() = default;
|
|
~DataPlugin() = default;
|
|
|
|
QString pluginName() const override { return QStringLiteral("Timeline"); }
|
|
std::shared_ptr<DataPluginBase::Interface> createDataInterface(LtsSession::LtsSessionDataDds *session) override;
|
|
bool availableInPartition(IDL::PartitionType partition) const override
|
|
{
|
|
return partition == IDL::PartitionType::Exercise || partition == IDL::PartitionType::Replay;
|
|
}
|
|
};
|
|
|
|
|
|
class DataInterfaceImpl final : public QObject, public DataInterface
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit DataInterfaceImpl(LtsSession::LtsSessionDataDds *session);
|
|
|
|
std::shared_ptr<TimeLineManagement::ForeignDataInterface> getForeignDataInterface() override { return m_foreign; }
|
|
|
|
private:
|
|
std::shared_ptr<TimeLineManagement::ForeignDataInterface> m_foreign;
|
|
|
|
NGL::INGLLogger &m_logger;
|
|
};
|
|
|
|
|
|
class TimelineDataProvider final : public QObject, public TimelineDataProviderInterface
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
TimelineDataProvider(int requestId, const QUrl &url,
|
|
qint64 from, qint64 to,
|
|
const QVector<int> &eventTypeIds = QVector<int>(),
|
|
const QJsonObject &filter = QJsonObject());
|
|
~TimelineDataProvider();
|
|
|
|
const QVector<ExerciseEventManagement::Event> &eventData() const override { return m_eventData; }
|
|
int requestId() const override { return m_requestId; }
|
|
void getRequestTime(qint64 &requestMin /* out */, qint64 &requestMax /* out */) const override { requestMin = m_requestMin; requestMax = m_requestMax; }
|
|
|
|
signals:
|
|
void finished();
|
|
|
|
private:
|
|
void disconnectedFromEem();
|
|
void textMessageFromEem(const QString &message);
|
|
|
|
private:
|
|
QVector<ExerciseEventManagement::Event> m_eventData;
|
|
QWebSocket *m_webSocketEem;
|
|
int m_requestId;
|
|
bool m_bFinshed;
|
|
qint64 m_requestMin;
|
|
qint64 m_requestMax;
|
|
NGL::INGLLogger &m_logger;
|
|
};
|
|
|
|
class ForeignInterfaceImpl final : public ForeignDataInterface
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit ForeignInterfaceImpl(LtsSession::LtsSessionDataDds *session);
|
|
~ForeignInterfaceImpl();
|
|
|
|
TimelineDataProviderInterface *requestData(qint64 from,
|
|
qint64 to,
|
|
const QVector<int> &eventTypeIds = QVector<int>(),
|
|
const QJsonObject &filter = QJsonObject()) override;
|
|
QVector<ExerciseEventManagement::Event> liveHistory() const override;
|
|
const QUrl eemUrl() const override;
|
|
|
|
private:
|
|
void connectToScm();
|
|
void connectedToScm();
|
|
void textMessageFromScm(const QString &message);
|
|
void connectToEem();
|
|
void connectedToEem();
|
|
void disconnectedFromEem();
|
|
void textMessageFromEem(const QString &message);
|
|
|
|
void requestFinished();
|
|
void cleanupSocket(QWebSocket *s);
|
|
|
|
void onClearHistoryBuffer();
|
|
|
|
private:
|
|
QMap<qint64, QVector<ExerciseEventManagement::Event>> m_liveHistoryBuffer;
|
|
QHash<int, TimelineDataProvider *> m_pendingRequests; // requestId
|
|
|
|
LtsSession::LtsSessionDataDds *m_session;
|
|
QWebSocket *m_webSocketScm;
|
|
QWebSocket *m_webSocketEem;
|
|
QTimer *m_liveHistoryBufferTimer;
|
|
quint16 m_eemPort;
|
|
NGL::INGLLogger &m_logger;
|
|
};
|
|
|
|
} // namespace TimeLineManagement
|