189 lines
8.5 KiB
C++
Executable File
189 lines
8.5 KiB
C++
Executable File
/**
|
|
* Handler for all Language HMI objects
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Hanna E. Rathje, SLSE, 2015-09-03
|
|
*/
|
|
#pragma once
|
|
|
|
#include <QHash>
|
|
#include <QTimer>
|
|
|
|
#include "dds_handler.h"
|
|
#include "initialization.h"
|
|
#include "logger.h"
|
|
#include <EffectShowManagement/esm_fts.h>
|
|
#include <EffectShowManagement/esm_db.h>
|
|
#include <AreaEffectSimulation/aes_ftc.h>
|
|
|
|
#include "esm_convert_from_tab.h"
|
|
|
|
|
|
namespace EffectShowManagement
|
|
{
|
|
constexpr int MAX_EFFECT_SHOWS = 3;
|
|
constexpr int CLEANUPTIME = 10*60*1000;
|
|
|
|
class Initialization;
|
|
class ObjectEffectShow;
|
|
/**
|
|
* @brief Handler for effect shows.
|
|
*
|
|
* (1)Fetches the gui-interactions for effect shows and triggers data base administration
|
|
* accordingly.\n
|
|
* (2)If an effect show was updated and an effect show actor was allocted, the Training Area Base
|
|
* Proxy will be triggered to send an effect show order to the allocated effect show actor.
|
|
* If needed, a retract order will be sent to the previous allocated effect show actor.\n
|
|
* (3)If an effect shall be deleted and an effect show actor is allocated and the status
|
|
* is < ORDER CARRIED OUT, the Training Area Base Proxy will be triggered to send a retract
|
|
* order to the effect show actor.\n
|
|
* (4)If the area of the area effect simulation (AES) was changed, the existing effect shows
|
|
* related to the AES will be removed and new effect shows will be created related to the
|
|
* new area. Effect Show Actors will not be allocated. This has to be done via Dialog by
|
|
* the user.\n
|
|
* (5)If the charge type, effect start, effect duration or the number of volley was changed
|
|
* by the AES, the related effect shows will be updated accordingly.\n
|
|
* (6)Receives the confirmation from the effect show actor via Training Area Base
|
|
* Proxy for effect show order and triggers the update of the data base with the new
|
|
* confirmation.\n
|
|
* (7)If the confirmation indicates: ORDER CARRIED OUT the effect show will be deleted after
|
|
* 1min automatically.\n
|
|
* (8)If the AES changes into the state EsPaused, the Training Area Base Proxy sill be triggered
|
|
* to send a STOP order to the effect show actor.\n
|
|
* (9)If the AES changes into the state EsActivated and the previous start time was zero
|
|
* (start button was pressed by AES), the Training Area Base Proxy will be triggered to
|
|
* send a CONTINUE order to the effect show actor.\n
|
|
* (10)Meteo data will be sent to the vehicle every 10 min,
|
|
* if the effect show actor has indicated by the order confirmation, that the effect show
|
|
* is in processing. Meteo Data will be read from "HandlerMdmData".\n
|
|
*/
|
|
class HandlerEffectShow : public QObject
|
|
, protected Interface::Fts::EffectShowModifyRequestHandler
|
|
, protected Interface::Fts::EffectShowRemoveRequestHandler
|
|
, protected AreaEffectSimulation::Interface::Ftc::SetAesItemEffectorStateReplyHandler
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit HandlerEffectShow(Initialization *mainHandler,
|
|
QObject *parent = nullptr);
|
|
~HandlerEffectShow();
|
|
|
|
/**
|
|
* @brief Updates effect shows data from the data base and distributes the data.
|
|
* @return (true)Initialization was successfull
|
|
*/
|
|
bool init();
|
|
|
|
/**
|
|
* @brief The kind of modification of the area effect simulation
|
|
*/
|
|
enum class KindOfModification_e : int { Added = 0, ModifiedArea, ModifiedData, Removed, Paused, Continued, None };
|
|
static QString enumToString(HandlerEffectShow::KindOfModification_e mod);
|
|
|
|
void onSetAesItemEffectorStateReply(const Core::FunctionReplyObject &replyObject) override {DEBUG_LOG(m_logger) << replyObject.translated();}
|
|
/**
|
|
* @brief Create, update, remove & create or remove Effect Shows in relation to the changes of the Explosion Area.
|
|
* @param[in] data
|
|
* @param]in] kindOfModification
|
|
*/
|
|
void onExplosionAreaChanged(const AreaEffectSimulation::ExplosionArea &data, KindOfModification_e kindOfModification);
|
|
|
|
/**
|
|
* @brief Create, update, remove & create or remove Effect Shows in relation to the changes of the Explosion Cluster.
|
|
* @param[in] data
|
|
* @param]in] kindOfModification
|
|
*/
|
|
void onExplosionClusterChanged(const AreaEffectSimulation::ExplosionCluster &data, KindOfModification_e kindOfModification);
|
|
|
|
/**
|
|
* @brief Create, update, remove & create or remove Effect Shows in relation to the changes of the Explosion Cluster.
|
|
* @param[in] data
|
|
* @param]in] kindOfModification
|
|
*/
|
|
void onEffectClusterChanged(const AreaEffectSimulation::EffectCluster &data, KindOfModification_e kindOfModification);
|
|
|
|
|
|
/**
|
|
* @brief Create, update, remove & create or remove Effect Shows in relation to the changes of the Explosion Area.
|
|
* @param[in] data
|
|
* @param[in] kindOfModification
|
|
*/
|
|
void onMineAreaChanged(const AreaEffectSimulation::MineArea &data, KindOfModification_e kindOfModification);
|
|
|
|
/**
|
|
* @brief Updates Effect Show data with #orderConfirmation received from effect show actor via TAB service.
|
|
* @param[in] orderConfirmation Order Confirmation received from effect show actor via TAB service.
|
|
*/
|
|
void effectShowOrderConfirmationReceived(const ConvertFromTab::OrderConfirmation_t &orderConfirmation);
|
|
|
|
/**
|
|
* @brief Creates a new effect show
|
|
* @param[in] data Effect Show data
|
|
*/
|
|
void createEffectShow(const Database::EsmEffectShow &data, bool bForceUpdateDb = false);
|
|
|
|
private:
|
|
void onEffectShowModifyRequest(const rti::core::SampleIdentity &cookie,
|
|
const EffectShow &request) override final;
|
|
Core::FunctionReplyObject effectShowModifyRequest(const EffectShow &request);
|
|
void onEffectShowRemoveRequest(const rti::core::SampleIdentity &cookie,
|
|
const Core::RemoveElementRequest &request) override final;
|
|
|
|
void createEffectShowsRelatedToMineArea(const AreaEffectSimulation::MineArea &data);
|
|
void createEffectShowsRelatedToExplosionArea(const AreaEffectSimulation::ExplosionArea &data);
|
|
void createEffectShowsRelatedToExplosionCluster(const AreaEffectSimulation::ExplosionCluster &data);
|
|
void createEffectShowsRelatedToEffectCluster(const AreaEffectSimulation::EffectCluster &data);
|
|
|
|
|
|
QVector<Database::EsmEffectShow> createEffectShowDbDataRelatedToMineArea(const AreaEffectSimulation::MineArea &data);
|
|
QVector<Database::EsmEffectShow> createEffectShowDbDataRelatedToExplosionArea(const AreaEffectSimulation::ExplosionArea &data);
|
|
QVector<Database::EsmEffectShow> createEffectShowDbDataRelatedToExplosionCluster(const AreaEffectSimulation::ExplosionCluster &data);
|
|
QVector<Database::EsmEffectShow> createEffectShowDbDataRelatedToEffectCluster(const AreaEffectSimulation::EffectCluster &data);
|
|
|
|
|
|
void removeEffectShowsRelatedToAes(int idAes, bool retract = true);
|
|
|
|
void updateEffectShowsRelatedToMineArea(const AreaEffectSimulation::MineArea &data);
|
|
void updateEffectShowsRelatedToExplosionArea(const AreaEffectSimulation::ExplosionArea &data);
|
|
void updateEffectShowsRelatedToExplosionCluster(const AreaEffectSimulation::ExplosionCluster &data);
|
|
void updateEffectShowsRelatedToEffectCluster(const AreaEffectSimulation::EffectCluster &data);
|
|
|
|
|
|
void modifyEffectShowsRelatedToMineArea(const AreaEffectSimulation::MineArea &data);
|
|
void modifyEffectShowsRelatedToExplosionArea(const AreaEffectSimulation::ExplosionArea &data);
|
|
void modifyEffectShowsRelatedToExplosionCluster(const AreaEffectSimulation::ExplosionCluster &data);
|
|
void modifyEffectShowsRelatedToEffectCluster(const AreaEffectSimulation::EffectCluster &data);
|
|
|
|
|
|
void modifyEffectShows(const QVector<Database::EsmEffectShow> &esmEffectShows, int aesId);
|
|
void updateEffectShowOrdersRelatedToAes(int idAes);
|
|
void pauseEffectShowsRelatedToAes(int idAes);
|
|
void continueEffectShowsRelatedToAes(int idAes);
|
|
|
|
QVector<ObjectEffectShow* > removeFromEffectShowMapByAesId(int aesId);
|
|
|
|
private:
|
|
Core::FunctionReplyObject removeEffectShow(ObjectEffectShow *ifs, bool bWarnWhenNotInMap = true, bool retract = true);
|
|
void triggerEffectShowOrder(const ObjectEffectShow *ifs);
|
|
void triggerRetractOrder(const ObjectEffectShow *ifs);
|
|
void triggerEffectShowStop(const ObjectEffectShow *ifs);
|
|
void triggerEffectShowContinue(const ObjectEffectShow *ifs);
|
|
void triggerMeteoData(const ObjectEffectShow *ifs);
|
|
private Q_SLOTS:
|
|
void onSendMeteoData();
|
|
void onCleanUp();
|
|
|
|
private:
|
|
QHash<int, ObjectEffectShow *> m_effectShowObjMap;
|
|
static constexpr qint64 meteoDataSendInterval = 600000; // 10 min send time interval for meteo data
|
|
QTimer *m_cleanupTimer;
|
|
QTimer *m_timerMeteoData;
|
|
|
|
Initialization *m_mainHandler;
|
|
NGL::INGLLogger &m_logger;
|
|
|
|
};
|
|
}
|