Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+139
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* CombatNetRadioHandler - reads TetraChannel and TvcConfig data from the database and publishes the data to dds,
|
||||
* reacts to TvcConfig related Function topics
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-07-25
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "logger.h"
|
||||
#include "avm_fts.h"
|
||||
#include <AudioVideoManagement/avm_db.h>
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <QVector>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <boost/optional.hpp>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
|
||||
class MainStructureElement;
|
||||
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
|
||||
|
||||
enum class DataModification;
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
namespace Interface
|
||||
{
|
||||
class Dts;
|
||||
class Fts;
|
||||
}
|
||||
|
||||
class ExerciseContext;
|
||||
class ActiveExercises;
|
||||
class FrequencyPlanningHandler;
|
||||
|
||||
|
||||
class CnrHandler
|
||||
: public QObject
|
||||
, protected Interface::Fts::ModifyCnrConfigRequestHandler
|
||||
, protected Interface::Fts::RemoveCnrConfigRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CnrHandler(Interface::Dts *dts, Interface::Fts *fts, InfrastructureManagement::Interface::Dtc *ismDtc, FrequencyPlanningHandler *frequencyPlanningHandler, DatabaseInterface *db, ActiveExercises *activeExercises);
|
||||
|
||||
~CnrHandler();
|
||||
|
||||
bool init();
|
||||
|
||||
bool hasConfig(int32_t configId) const;
|
||||
const CnrConfig &config(int32_t configId) const;
|
||||
|
||||
void onRemoveCnrConfigRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override final;
|
||||
void onModifyCnrConfigRequest(const rti::core::SampleIdentity &cookie,
|
||||
const ModifyCnrConfigRequest &request) override final;
|
||||
signals:
|
||||
/** Signalled after device_config modifications. */
|
||||
void avDbReloadNeeded();
|
||||
|
||||
/** Only emitted on change, i.e. not on create or remove. */
|
||||
void cnrConfigChanged(const CnrConfig &tvcConfig);
|
||||
void cnrConfigRemoved(int cnrConfigId);
|
||||
|
||||
private slots:
|
||||
void onContextActivated(const ExerciseContext &context);
|
||||
void onContextDeactivated(const ExerciseContext &context);
|
||||
void onFrequencyPlanningChanged();
|
||||
|
||||
void onDbDeleteAvmCnrConfig(const QVariant &id);
|
||||
|
||||
void onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType);
|
||||
void onRadioStationChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType);
|
||||
|
||||
private:
|
||||
void reevalutate();
|
||||
void updateDeviceConfig();
|
||||
|
||||
CnrConfig toDds(const Database::AvmCnrConfig &config) const;
|
||||
Database::AvmDeviceConfig toDeviceConfig(const CnrConfig &cnrConfig) const;
|
||||
|
||||
Core::FunctionReplyObject validateRequest(const ModifyCnrConfigRequest &request);
|
||||
bool checkConstraint(const std::function<bool (const CnrConfig &)> &constraint, const boost::optional<int> &exerciseId, const boost::optional<int32_t> &excludeId) const;
|
||||
|
||||
bool isValidChannel(int64_t channelId) const;
|
||||
|
||||
bool isFreeChannel(const ModifyCnrConfigRequest &request) const;
|
||||
bool isFreeChannel(int32_t channelId, const boost::optional<int> &exerciseId, const boost::optional<int32_t> &excludeId = boost::none) const;
|
||||
|
||||
bool isNameUnique(const ModifyCnrConfigRequest &request);
|
||||
bool isNameUnique(const std::string &name, const boost::optional<int> &exerciseId, const boost::optional<int32_t> &excludeId = boost::none) const;
|
||||
|
||||
Core::FunctionReplyObject createCnrConfig(const ModifyCnrConfigRequest &request, const boost::optional<int32_t> &dbId = boost::none);
|
||||
Core::FunctionReplyObject modifyCnrConfig(const ModifyCnrConfigRequest &request);
|
||||
Core::FunctionReplyObject removeCnrConfig(const Core::RemoveElementRequest &request);
|
||||
|
||||
void onRadioStationAdded(int id, const QString &name, const QString &hostname);
|
||||
void onRadioStationRemoved(int id);
|
||||
|
||||
bool isActiveExercise(int exerciseId) const;
|
||||
bool needDeviceConfig(const CnrConfig &config) const;
|
||||
bool haveActiveFrequencyPlanning() const;
|
||||
|
||||
QString exerciseList(const CnrConfig &config) const;
|
||||
QString stationList(int addacChannel) const;
|
||||
int normalizedAddacChannel(int addacChannel) const;
|
||||
Database::AvmCnrChannel channelById(int32_t id) const;
|
||||
|
||||
class DeviceConfig;
|
||||
|
||||
Interface::Dts *m_dts;
|
||||
Interface::Fts *m_fts;
|
||||
FrequencyPlanningHandler *m_frequencyPlanningHandler;
|
||||
DatabaseInterface *m_db;
|
||||
ActiveExercises *m_activeExercises;
|
||||
QMap<int32_t, CnrConfig> m_cache;
|
||||
QVector<Database::AvmCnrChannel> m_channels;
|
||||
QHash<int, QString> m_cnrRadioStations;
|
||||
LOGGER_T &m_logger;
|
||||
std::unique_ptr<DeviceConfig> m_deviceConfig;
|
||||
};
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
Reference in new issue
Block a user