Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,30 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Mike Wille, SLSE, 2016-05-05
#
SET(ism_combobox_gui_SRCS
ism_combobox_gui_plugin.cpp
ism_combobox_gui_plugin.h
ism_combobox.cpp
ism_combobox.h
)
NGL_WRAP_UI(ism_combobox_gui_SRCS
)
NGL_ADD_LIBRARY(WS IsmComboBoxGuiPlugin MODULE ${ism_combobox_gui_SRCS})
NGL_TARGET_LINK_LIBRARIES(IsmComboBoxGuiPlugin
NGLLogger
IsmGuiComboboxPluginInterface
IsmDataPluginInterface
Qt5::Widgets
LtsWidgets
LtsSession
)
NGL_INSTALL_TARGET(IsmComboBoxGuiPlugin)
@@ -0,0 +1,99 @@
/**
* @RDE_HEADER@
* InfrastructureManagement - IsmComboBox Gui Plugin
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, SLSE, 2018-01-16
*/
#include "ism_combobox.h"
#include <InfrastructureManagement/ism_translation.h>
#include <LtsUtilsCore/json_object.h>
namespace InfrastructureManagement
{
bool IsmComboBox::fill(LtsWidgets::LtsComboBox *cbx, IsmComboBoxType type, LtsSession::LtsSession *session,
const std::shared_ptr<Interface::Dtc> &dtc, int filter)
{
Q_UNUSED(session);
cbx->clear();
switch (type)
{
case IsmComboBoxType::CbRadioStations:
{
auto cb = [cbx,filter](const InfrastructureManagement::MainStructureElement &mse)
{
if (mse.structureElementTypeId() == InfrastructureManagement::StructureElementType::RadioStation && !mse.isDeleted() && mse.id() > 0 )
{
const RadioStation &rs = RadioStation::fromMSE(mse);
if (((filter >= 0) && rs.radios.contains(static_cast<FrequencyBand>(filter))) ||
(filter < 0))
{
cbx->addItem(QString::fromStdString(mse.name()), mse.id());
cbx->setItemData(cbx->findData(mse.id()), rs.radioStationId, Qt::UserRole + 1);
}
}
};
dtc->mainStructureElements(cb);
break;
}
case IsmComboBoxType::CbApproachingPoints:
{
auto cb = [cbx](const InfrastructureManagement::MainStructureElement &mse)
{
if ((mse.structureElementTypeId() == InfrastructureManagement::StructureElementType::ApproachingPoint) && !mse.isDeleted() && (mse.id() > 0))
{
cbx->addItem(QString::fromStdString(mse.name()), mse.id());
cbx->setItemData(cbx->findData(mse.id()), mse.angle(), Qt::UserRole + 1);
}
};
dtc->mainStructureElements(cb);
break;
}
case IsmComboBoxType::CbScheduleStatus:
{
cbx->addItem(toString(ScheduleStatus::Active), ScheduleStatus::Active);
cbx->addItem(toString(ScheduleStatus::Inactive), ScheduleStatus::Inactive);
break;
}
case IsmComboBoxType::CbBridgeStatus:
{
cbx->addItem(toString(BridgeStatus::Intact), BridgeStatus::Intact);
cbx->addItem(toString(BridgeStatus::Broken), BridgeStatus::Broken);
}
case IsmComboBoxType::CbUnknown:
default:
break;
}
return cbx->count() > 0;
}
RadioStation RadioStation::fromMSE(const MainStructureElement &mse)
{
RadioStation rs;
rs.mse_id = mse.id();
rs.name = QString::fromStdString(mse.name());
LtsUtils::JsonObject jo = LtsUtils::JsonObject::fromJson(mse.properties());
LtsUtils::JsonArray radios = jo.valueOr<LtsUtils::JsonArray>("radios", {});
// The best and easiest solution is to iterate over the JsonArray right!?
// for (const QJsonValue &radioValues : qAsConst(radios))
// for (const JsonObject &radioObject : qAsConst(radios))
const QVector<LtsUtils::JsonObject> &radiosAsVector = radios.toVector<LtsUtils::JsonObject>();
for (const LtsUtils::JsonObject &radio : qAsConst(radiosAsVector))
{
FrequencyBand fb = static_cast<FrequencyBand>(radio.valueOr<int>("frequencyBand", -1));
int count = radio.valueOr<int>("count", 0);
if (fb != FrequencyBand::INVALID)
rs.radios.insert(fb,count);
}
rs.radioStationId = jo.valueOr<int>("stationId", 0);
return rs;
}
} // namespace InfrastructureManagement
@@ -0,0 +1,61 @@
/**
* @RDE_HEADER@
* InfrastructureManagement - IsmComboBox Gui Plugin
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, SLSE, 2018-01-16
*/
#pragma once
#include <LtsSession/lts_session.h>
#include <LtsWidgets/lts_combo_box.h>
#include <InfrastructureManagement/logger.h>
#include <InfrastructureManagement/ism_dtc.h>
#include <QMap>
#include <QString>
namespace InfrastructureManagement
{
enum IsmComboBoxType
{
CbUnknown = 0,
CbRadioStations,
CbApproachingPoints,
CbScheduleStatus,
CbBridgeStatus
};
// Keep in sync with avm_enums.h!
enum FrequencyBand
{
INVALID = -1,
VHF = 0,
UHF = 1,
HF = 2,
REL = 3
};
struct RadioStation
{
int mse_id;
int radioStationId;
QString name;
QMap<FrequencyBand, int> radios; // How many radios are there per type?
static RadioStation fromMSE(const MainStructureElement &mse);
};
// --------------------------------------------------------
// ComboBox
// --------------------------------------------------------
class IsmComboBox
{
public:
Q_REQUIRED_RESULT static bool fill(LtsWidgets::LtsComboBox *cbx,
IsmComboBoxType type,
LtsSession::LtsSession *session,
const std::shared_ptr<Interface::Dtc> &dtc, int filter = -1);
};
} // namespace InfrastructureManagement
@@ -0,0 +1,70 @@
/**
* @RDE_HEADER@
* GUI Plugin for InfrastructureManagement - IsmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, SLSE, 2018-01-16
*/
#include "ism_combobox_gui_plugin.h"
namespace InfrastructureManagement
{
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
{
return std::make_shared<InterfaceImpl>(session);
}
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
: GuiPluginBase::Interface(session, getLogger("Plugins.Gui.IsmCombobox"))
, m_dtc(nullptr)
{}
bool InterfaceImpl::fetchInterfaces()
{
// if (!m_session->getDtc<InfrastructureManagement::DataInterface>(m_dtc))
// {
// DEBUG_LOG(m_logger) << "Failed to fetch Dtc InfrastructureManagement interface!";
// return false;
// }
return true;
}
void InterfaceImpl::clearInterfaces()
{
m_dtc = nullptr;
}
bool InterfaceImpl::fillRadioStationsComboBox(LtsWidgets::LtsComboBox *cbx, int filter)
{
return fillIsmComboBox(cbx, IsmComboBoxType::CbRadioStations, filter);
}
bool InterfaceImpl::fillApproachingPointsComboBox(LtsWidgets::LtsComboBox *cbx)
{
return fillIsmComboBox(cbx, IsmComboBoxType::CbApproachingPoints);
}
bool InterfaceImpl::fillScheduleStatusComboBox(LtsWidgets::LtsComboBox *cbx)
{
return fillIsmComboBox(cbx, IsmComboBoxType::CbScheduleStatus);
}
bool InterfaceImpl::fillBridgeStatusComboBox(LtsWidgets::LtsComboBox *cbx)
{
return fillIsmComboBox(cbx, IsmComboBoxType::CbBridgeStatus);
}
//private
bool InterfaceImpl::fillIsmComboBox(LtsWidgets::LtsComboBox *cbx, IsmComboBoxType type, int filter)
{
if (!m_dtc && !m_session->getDtc<InfrastructureManagement::DataInterface>(m_dtc))
return false;
return IsmComboBox::fill(cbx, type, m_session, m_dtc, filter);
}
} // namespace InfrastructureManagement
@@ -0,0 +1,69 @@
/**
* @RDE_HEADER@
* Gui Plugin for InfrastructureManagement - IsmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, SLSE, 2018-01-16
*/
#pragma once
#include "ism_combobox.h"
#include <LtsSession/lts_session.h>
#include <InfrastructureManagement/logger.h>
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/InfrastructureManagement/ism_combobox_gui_plugin_interface.h>
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
#include <QComboBox>
namespace InfrastructureManagement
{
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "gui:3:ism.combobox")
Q_INTERFACES(GuiPluginBase::Plugin)
Q_OBJECT
public:
GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return QStringLiteral("InfrastructureManagement.GuiPlugin.ComboBox"); }
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
bool availableInPartition(IDL::PartitionType partition) const override
{
return (partition == IDL::PartitionType::Global ||
partition == IDL::PartitionType::Exercise ||
partition == IDL::PartitionType::Replay);
}
};
class InterfaceImpl final : public QObject, public ForeignGuiComboboxInterface, public GuiPluginBase::Interface
{
Q_OBJECT
public:
explicit InterfaceImpl(LtsSession::LtsSession *session);
bool fetchInterfaces() override;
void clearInterfaces() override;
QString menuGroup() const override { return QString(); }
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Global || partition == IDL::PartitionType::Exercise; }
// ForeignDataInterface
bool fillRadioStationsComboBox(LtsWidgets::LtsComboBox *cbx, int filter) override;
bool fillApproachingPointsComboBox(LtsWidgets::LtsComboBox *cbx) override;
bool fillScheduleStatusComboBox(LtsWidgets::LtsComboBox *cbx) override;
bool fillBridgeStatusComboBox(LtsWidgets::LtsComboBox *cbx) override;
private:
bool fillIsmComboBox(LtsWidgets::LtsComboBox *cbx, IsmComboBoxType type, int filter = -1);
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_dtc;
};
} // namespace InfrastructureManagement