210 lines
8.0 KiB
C++
Executable File
210 lines
8.0 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Timeline Model for DDS
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Mike Wille, SLSE, 2017-03-31
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "detail_data.h"
|
|
|
|
#include <LtsTimelineClassic/AbstractTimelineModel.h>
|
|
#include <Plugins/Timeline/tln_data_plugin_interface.h>
|
|
#include <Plugins/MarkerManagement/mrk_data_plugin_interface.h>
|
|
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
|
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
|
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
|
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
|
|
|
#include <QJsonArray>
|
|
#include <QAbstractSocket>
|
|
|
|
|
|
namespace LtsUtils
|
|
{
|
|
class RequestHelper;
|
|
}
|
|
|
|
namespace LtsSession
|
|
{
|
|
class LtsSession;
|
|
}
|
|
|
|
namespace AudioVideoManagement
|
|
{
|
|
class StreamNameMapping;
|
|
}
|
|
|
|
namespace Timeline
|
|
{
|
|
struct CacheRange : public LtsTimelineClassic::Range
|
|
{
|
|
QVector<LtsTimelineClassic::Event *> events;
|
|
bool incomplete = true;
|
|
bool visible = false; // events currently visible/set on timeline?
|
|
};
|
|
|
|
|
|
class DDSTimelineModel : public LtsTimelineClassic::AbstractTimelineModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit DDSTimelineModel(QObject *parent);
|
|
~DDSTimelineModel();
|
|
|
|
bool init(const std::shared_ptr<TimeLineManagement::ForeignDataInterface> &eemForeign,
|
|
const std::shared_ptr<MarkerManagement::Interface::Dtc> &mrkDtc,
|
|
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc,
|
|
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
|
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
|
|
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
|
LtsSession::LtsSession *session,
|
|
Timeline::DetailData *detailData,
|
|
AudioVideoManagement::StreamNameMapping *streamNameMapping);
|
|
|
|
void applyFilter(const QJsonArray &filter);
|
|
void setDetailData(DetailData *detailData) { m_detailData = detailData; }
|
|
void setColorPaintFun(LtsTimelineClassic::Event::EventPaintFunc &paintFunc, QColor &color, ProjectDataManagement::EventType eventType) const;
|
|
void setTimeRange(qint64 min, qint64 max);
|
|
void getEvents(qint64 rangeMin, qint64 rangeMax);
|
|
QVector<LtsTimelineClassic::Range> getKnownRanges() const;
|
|
const QVector<QPair<qint64, CacheRange>> &cachedEvents() const { return m_cachedEvents; } // for debug only !
|
|
const CacheRange &liveCache() const { return m_liveCache; } // for debug only !
|
|
void forceUncache();
|
|
void setLive(bool isLive = true);
|
|
void setCreateFakeEvents(bool createFakeEvents = true);
|
|
void setActiveEventTypeIds(const QSet<int> &activeEventTypeIds);
|
|
const QSet<int> &activeEventTypeIds() const { return m_activeEventTypeIds; }
|
|
bool hasActiveEventTypes() const { return !m_activeEventTypeIds.isEmpty(); }
|
|
void getAllEventsOfType(const QSet<int> &eventTypeIds);
|
|
|
|
|
|
private:
|
|
qint64 currentTime() const override;
|
|
//void addExerciseEventManagementEvent(const ExerciseEventManagement::Event &data);
|
|
QStringList getPathForAvsEvents(const QString &type, const QJsonObject &obj) const;
|
|
QStringList getPathForBuildingEvents(const QString &type, const QJsonObject &obj) const;
|
|
QStringList getPathForAesEvents(const QString &type, const QJsonObject &obj) const;
|
|
void addMarkerManagementMarker(const MarkerManagement::Marker &data);
|
|
void addEventsAndFilter(const QVector<LtsTimelineClassic::Event *> &eventList);
|
|
void addEventAndFilter(LtsTimelineClassic::Event *event); // returns false if NOT added (so delete the event if false)
|
|
void deleteMarker(int uniqueId);
|
|
void modifyMarker(const MarkerManagement::Marker &data);
|
|
QJsonObject createMarkerDetailData(const MarkerManagement::Marker &data) const;
|
|
LtsTimelineClassic::Event *getMarker(int uniqueId);
|
|
void checkCache();
|
|
void removeEvent(int eventId);
|
|
void addCacheRange(const LtsTimelineClassic::Range &range, const QVector<LtsTimelineClassic::Event *> &cachedEvents, qint64 incompleteEnd, bool addToTimeline = true);
|
|
bool isLive() const { return m_isLive; }
|
|
LtsTimelineClassic::Event *createEvent(const ExerciseEventManagement::Event &data) const;
|
|
//const QVector<LtsTimelineClassic::Event *> createEvents(const QVector<ExerciseEventManagement::Event> &eventList) const;
|
|
bool checkDetailData(const LtsTimelineClassic::Event *event) const;
|
|
void processEventList(qint64 &highest, bool &incomplete, QVector<LtsTimelineClassic::Event *> &cachedEvents, QVector<LtsTimelineClassic::Event *> &eventList, const int initialCount = 0);
|
|
void receivedEvents(const LtsTimelineClassic::Range &range, QVector<LtsTimelineClassic::Event *> &receivedEventsList);
|
|
void requestEvents(const LtsTimelineClassic::Range &range);
|
|
QVector<LtsTimelineClassic::Event *> createTestEvents(qint64 time, int count, qint64 distance, qint64 duration = 0);
|
|
static bool isInsideCachedRange(const CacheRange &cacheRange, qint64 start, qint64 end);
|
|
bool isCached(int eventId) const;
|
|
void showCached(CacheRange &cacheRange);
|
|
bool isCacheFull() const;
|
|
//void forceUncache();
|
|
void uncache(CacheRange &cr);
|
|
const CacheRange *getCache(int eventId) const;
|
|
void addCacheRangeToTimeline(const CacheRange &cr);
|
|
bool splitLowest(qint64 &rangeMin, qint64 rangeMax, qint64 &requestMin, qint64 &requestMax, const CacheRange &lowestCache) const;
|
|
void rebuildTimelineKnownRanges();
|
|
void _uncache(const CacheRange &cr);
|
|
void saveAndClearLiveCache();
|
|
const QJsonObject getDetailData(const ExerciseEventManagement::Event &event) const;
|
|
const QJsonObject getDetailData(const QByteArray &data, int id, const ProjectDataManagement::EventType& type, qint64 startTime) const;
|
|
|
|
std::shared_ptr<TimeLineManagement::ForeignDataInterface> m_eemForeign;
|
|
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_dtcExm;
|
|
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
|
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
|
std::shared_ptr<MarkerManagement::Interface::Dtc> m_mrkDtc;
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
|
|
|
QJsonArray m_filter;
|
|
LtsSession::LtsSession *m_session;
|
|
int64_t m_startTime;
|
|
int64_t m_endTime;
|
|
DetailData *m_detailData;
|
|
AudioVideoManagement::StreamNameMapping *m_streamNameMapping;
|
|
bool m_isLive;
|
|
int m_cacheSize; // per range in m_cachedEvents
|
|
int m_maxCacheRanges; // max entries in m_cachedEvents
|
|
int m_eventCount;
|
|
|
|
qint64 m_lastCachedEventsId;
|
|
QVector<QPair<qint64, CacheRange>> m_cachedEvents;
|
|
|
|
CacheRange m_liveCache;
|
|
bool m_createFakeEvents;
|
|
QSet<int> m_activeEventTypeIds;
|
|
//bool m_dtorEmergencyMode;
|
|
QVector<int> m_knownMarkerIds;
|
|
NGL::INGLLogger &m_logger;
|
|
|
|
|
|
public slots:
|
|
void slotAddLiveEvent(const ExerciseEventManagement::Event &event);
|
|
|
|
|
|
private slots:
|
|
//void slotEventChanged(const ExerciseEventManagement::Event &data, DataModification modType);
|
|
void slotMarkerChanged(const MarkerManagement::Marker &data, DataModification modType);
|
|
void slotAddLiveEventsFake();
|
|
void slotRequestMessageReceived(const QString &message);
|
|
|
|
|
|
signals:
|
|
void signalTooMuchEvents();
|
|
void signalRebuildTimelineKnownRanges(); // sadly, the model cannot do this..
|
|
void signalLoading();
|
|
void signalLoadingDone();
|
|
|
|
};
|
|
|
|
|
|
class EventRequest : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
EventRequest(const QUrl &url, qint64 start, qint64 end, const QSet<int> &eventTypes, int limit);
|
|
~EventRequest() = default;
|
|
|
|
void append(LtsTimelineClassic::Event *newEvent) { m_eventList.push_back(newEvent); }
|
|
const QVector<LtsTimelineClassic::Event *> &eventList() const { return m_eventList; }
|
|
qint64 start() const { return m_start; }
|
|
qint64 end() const { return m_end; }
|
|
|
|
private:
|
|
void requestFailed(const QString &errorString);
|
|
|
|
qint64 m_start;
|
|
qint64 m_end;
|
|
QVector<LtsTimelineClassic::Event *> m_eventList;
|
|
QTimer *m_timeoutTimer;
|
|
|
|
|
|
private slots:
|
|
void slotRequestFailed();
|
|
void slotMessageReceived(const QString &message);
|
|
|
|
|
|
signals:
|
|
void signalRequestFailed(const QString &errorString);
|
|
void signalMessageReceived(const QString &message);
|
|
void signalDone();
|
|
void signalTimeout();
|
|
|
|
};
|
|
|
|
} // namespace Timeline
|