122 lines
4.4 KiB
C++
Executable File
122 lines
4.4 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Handler for all exercise objects
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Hanna E. Rathje, SLSE, 2015-09-03
|
|
*/
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QQueue>
|
|
#include <QHash>
|
|
#include <QCache>
|
|
#include <QSize>
|
|
|
|
#include <DBAdministration/exercise_table_generator.h>
|
|
#include "dds_handler.h"
|
|
#include <ExerciseManagement/exm_db.h>
|
|
#include "logger.h"
|
|
|
|
class QTimer;
|
|
namespace ExerciseManagement
|
|
{
|
|
class MainHandler;
|
|
class ObjectExercise;
|
|
class HandlerExercise final : public QObject
|
|
, protected Interface::Fts::ExerciseCreateRequestHandler
|
|
, protected Interface::Fts::ExerciseModifyRequestHandler
|
|
, protected Interface::Fts::ExerciseRemoveRequestHandler
|
|
, protected Interface::Fts::ExerciseImageModifyRequestHandler
|
|
, protected Interface::Fts::GetExerciseImageRequestHandler
|
|
, protected ServiceManagement::Interface::Ftc::StartGroupReplyHandler
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit HandlerExercise(MainHandler *mainHandler,
|
|
const std::shared_ptr<DdsHandler> &ddsHandler,
|
|
const std::shared_ptr<DatabaseInterface> &db,
|
|
const std::shared_ptr<DBAdministration::ExerciseTableGenerator> &exTableGenerator,
|
|
QObject *parent = nullptr);
|
|
~HandlerExercise();
|
|
|
|
bool init();
|
|
ObjectExercise *getExerciseById(qint32 id) const;
|
|
const QHash<int, ObjectExercise*> &getExerciseMap() const { return m_exeObjMap; }
|
|
|
|
bool startGroupRequest(const ServiceManagement::GroupRequest &req);
|
|
|
|
|
|
// class ImageKey
|
|
// {
|
|
// public:
|
|
// ImageKey(const QSize &size = QSize(0, 0), bool lowBandwith = false)
|
|
// : m_lowBandwidth(lowBandwith)
|
|
// , m_size(size)
|
|
// {}
|
|
// bool m_lowBandwidth { false };
|
|
// QSize m_size;
|
|
|
|
// bool operator<(const ImageKey &o) const
|
|
// {
|
|
// if (m_size.height() != o.m_size.height())
|
|
// return m_size.height() < o.m_size.height();
|
|
// if (m_size.width() != o.m_size.width())
|
|
// return m_size.width() < o.m_size.width();
|
|
// return m_lowBandwidth < o.m_lowBandwidth;
|
|
// }
|
|
|
|
// bool operator==(const ImageKey &o) const
|
|
// {
|
|
// return (m_size == o.m_size && m_lowBandwidth == o.m_lowBandwidth);
|
|
// }
|
|
// };
|
|
private:
|
|
void onStartNextExercise();
|
|
private:
|
|
/**
|
|
* @brief HandlerExercise::hasError
|
|
* checks if there is an error in the replyObject and, if given, deletes
|
|
* the ifs pointer and logs the error
|
|
* @param replyObject
|
|
* @param ifs
|
|
* @return
|
|
*/
|
|
bool hasError(const Core::FunctionReplyObject &replyObject, ObjectExercise *ifs) const;
|
|
|
|
void onExerciseCreateRequest(const rti::core::SampleIdentity &cookie,
|
|
const ExerciseCreateRequest &request) override final;
|
|
Core::FunctionReplyObject exerciseCreateRequest(const ExerciseCreateRequest &request);
|
|
void onExerciseModifyRequest(const rti::core::SampleIdentity &cookie,
|
|
const ExerciseModifyRequest &request) override final;
|
|
Core::FunctionReplyObject exerciseModifyRequest(const ExerciseModifyRequest &request);
|
|
// void onExerciseChangeStateRequest(const rti::core::SampleIdentity &cookie,
|
|
// const ExerciseChangeStateRequest &request) override final;
|
|
void onExerciseRemoveRequest(const rti::core::SampleIdentity &cookie,
|
|
const ExerciseRemoveRequest &request) override final;
|
|
void onExerciseImageModifyRequest(const rti::core::SampleIdentity &cookie,
|
|
const ExerciseImageModifyRequest &request) override final;
|
|
void onGetExerciseImageRequest(const rti::core::SampleIdentity &cookie,
|
|
const GetExerciseImageRequest &request) override final;
|
|
|
|
void onStartGroupReply(const Core::FunctionReplyObject &replyObject) override final;
|
|
|
|
bool checkEquipmentNumbersOnAllExercises(int exerciseIdToBeStarted, QString &mesgOut);
|
|
|
|
QStringList doubleChannels(int exerciseAId, int exerciseBId) const;
|
|
|
|
private:
|
|
QHash<int, ObjectExercise*> m_exeObjMap;
|
|
MainHandler *m_mainHandler;
|
|
std::shared_ptr<DdsHandler> m_ddsHandler;
|
|
std::shared_ptr<DatabaseInterface>m_db;
|
|
std::shared_ptr<DBAdministration::ExerciseTableGenerator> m_exTblGen;
|
|
QTimer *m_startupExerciseTimer;
|
|
QQueue<int> m_exercisesToStart;
|
|
//QCache<ImageKey, QByteArray> m_imageCache;
|
|
NGL::INGLLogger &m_logger;
|
|
|
|
};
|
|
}
|