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,382 @@
/**
* @RDE_HEADER@
* The MountingPointInfoDialog shows information about a single mounting point
* $Id$
* $HeadURL$
* $Author$
* Created by Hannes Baeuerle, SLSE, 2017-01-12
*/
#include "ism_mounting_point_info_dialog.h"
#include "ui_ism_mounting_point_info_dialog.h"
#include <InfrastructureManagement/ism_translation.h>
#include <InfrastructureManagement/Shared/ism_mounting_point.h>
#include <AudioVideoManagement/ava_session.h>
#include <LtsCoordTrans/lts_coord_trans.h>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
namespace InfrastructureManagement
{
MountingPointInfoDialog::MountingPointInfoDialog(int32_t mountingPointId, int32_t scheduleId, const QString &menuGroup, QWidget *parent)
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
, m_ui(new Ui::MountingPointInfoDialog)
, m_mountingPointId(mountingPointId)
, m_assetId(-1)
, m_scheduleId(scheduleId)
, m_menuGroup(menuGroup)
, m_dtc(nullptr)
, m_ismIfc(nullptr)
, m_avmIfc(nullptr)
, m_logger(getLogger("MountingPointInfoDialog"))
{
m_ui->setupUi(this);
m_ui->gbxAsset->hide();
}
MountingPointInfoDialog::~MountingPointInfoDialog()
{
delete m_ui;
qDeleteAll(m_dynamicAssetPropLabels);
}
void MountingPointInfoDialog::retranslate()
{
//nfrastructureManagement::InstrumentationAsset ia = m_dtc->instrumentationAsset(m_mountingPointId);
StructureElement se;
m_dtc->getStructureElementById(m_mountingPointId, se);
QString seName = QString::fromStdString(se.displayName()).trimmed();
QString lbName;
// display name is composed by mse name and se name => se.displayname
// when se.displayname is empty > we will manually compose it.
if(seName.isEmpty())
{
MainStructureElement mse= m_dtc->mainStructureElement(se.mainStructureElementId());
lbName = QString::fromStdString(mse.name()) + QStringLiteral(" - ") + QString::fromStdString(se.name());
}
else
{
lbName = seName.replace(QStringLiteral("bldg_"), QStringLiteral(""));
}
translate(m_ui, lbName);
}
bool MountingPointInfoDialog::init(const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &dtc,
const std::shared_ptr<ForeignDataInterface> &ismIfc,
const std::shared_ptr<AudioVideoManagement::ForeignDataInterface> &avmIfc)
{
DEBUG_LOG(m_logger) << "Initializing MountingPointInfoDialog ...";
disconnect();
m_dtc = dtc;
m_ismIfc = ismIfc;
m_avmIfc = avmIfc;
StructureElement mountingPointData;
if (!(dtc != nullptr &&
m_dtc->enableInstrumentationAsset() &&
m_dtc->enableMountingPointAsset() &&
m_dtc->enableMainStructureElement() &&
m_dtc->enableMainSchedule() &&
m_dtc->waitForHistoricalDataInstrumentationAsset(10000) &&
m_dtc->waitForHistoricalDataMountingPointAsset(10000) &&
m_dtc->waitForHistoricalDataMainStructureElement(10000) &&
m_dtc->waitForHistoricalDataMainSchedule(10000) &&
m_dtc->getStructureElementById(m_mountingPointId, mountingPointData) &&
connect(m_dtc.get(), &Interface::Dtc::instrumentationAssetChanged,
this, &MountingPointInfoDialog::onInstrumentationAssetChanged) &&
connect(m_dtc.get(), &Interface::Dtc::mountingPointAssetChanged,
this, &MountingPointInfoDialog::onMountingPointAssetChanged) &&
connect(m_dtc.get(), &Interface::Dtc::mainScheduleChanged,
this, &MountingPointInfoDialog::onMainScheduleChanged)
))
return false;
m_ui->lblNameEntry->setText(QString::fromStdString(mountingPointData.name()));
m_ui->lblTypeEntry->setText(toString(mountingPointData.mountingPointTypeId()));
if (mountingPointData.mountingPointTypeId() != MountingPointType::OutdoorCamera &&
mountingPointData.mountingPointTypeId() != MountingPointType::MeteoDataUnit &&
mountingPointData.mountingPointTypeId() != MountingPointType::VirtualIPS)
{
// searching path backwards until we find a building structure element
QMap<StructureElementType, QString> names;
for (int parentId = mountingPointData.path().size() - 1; parentId >= 0; --parentId)
{
StructureElement parent;
m_dtc->getStructureElementById(mountingPointData.path().at(parentId), parent);
names[parent.structureElementTypeId()] = QString::fromStdString(parent.displayName().size() > 0 ? parent.displayName() : parent.name());
if (StructureElementType::Building == parent.structureElementTypeId().underlying())
break;
}
// Building lbl
m_ui->lblBuildingEntry->setText(names.value(StructureElementType::Building));
m_ui->lblPosition->hide();
m_ui->lblPositionEntry->hide();
// Floor lbl
if (names.contains(StructureElementType::Floor))
m_ui->lblFloorEntry->setText(names.value(StructureElementType::Floor));
else
{
m_ui->lblFloorEntry->hide();
m_ui->lblFloor->hide();
}
// Room lbl
if (names.contains(StructureElementType::Room))
m_ui->lblRoomEntry->setText(names.value(StructureElementType::Room));
else
{
m_ui->lblRoomEntry->hide();
m_ui->lblRoom->hide();
}
}
else
{
// hide what isn't needed
m_ui->lblBuildingEntry->hide();
m_ui->lblBuilding->hide();
m_ui->lblFloorEntry->hide();
m_ui->lblFloor->hide();
m_ui->lblRoomEntry->hide();
m_ui->lblRoom->hide();
MainStructureElement mainStructure = m_dtc->mainStructureElement(mountingPointData.mainStructureElementId());
m_ui->lblPositionEntry->setText(LtsCoordTrans::mgrsFromGeographic(mainStructure.geoPosition().lon(),
mainStructure.geoPosition().lat()));
}
if (mountingPointData.mountingPointTypeId() == MountingPointType::OutdoorCamera ||
mountingPointData.mountingPointTypeId() == MountingPointType::IndoorCamera)
{
connect(m_ui->pbShowStream, &QToolButton::clicked, this, &MountingPointInfoDialog::onShowStream);
m_ui->pbShowStream->setVisible(m_avmIfc->hasAvsSession() && m_avmIfc->avaSession()->isEstablished());
m_ui->pbAnnouncement->hide();
}
else
{
connect(m_ui->pbAnnouncement, &QToolButton::clicked, this, &MountingPointInfoDialog::onAnnouncement);
m_ui->pbShowStream->hide();
m_ui->pbAnnouncement->setVisible(m_avmIfc->hasAvsSession() && m_avmIfc->avaSession()->isEstablished());
}
setIsIncluded(m_dtc->mainSchedule(m_scheduleId));
// set the asset (if possible)
QMap<qint32, MountingPointAsset> mpAssets = m_dtc->mountingPointAssets();
for (auto it = mpAssets.begin(); it != mpAssets.end(); ++it)
{
if (it.value().structureElementId() == m_mountingPointId)
{
showAsset(m_dtc->instrumentationAsset(it.value().assetId()));
break;
}
}
switch (mountingPointData.mountingPointTypeId().underlying())
{
case InfrastructureManagement::MountingPointType::BuildingSensorModule:
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Building_Sensor_Module"));
break;
case InfrastructureManagement::MountingPointType::BuildingControlUnit:
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Building_Control_Unit"));
break;
case InfrastructureManagement::MountingPointType::OutdoorCamera:
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Outdoor_Camera"));
break;
case InfrastructureManagement::MountingPointType::IndoorCamera:
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Indoor_Camera"));
break;
case InfrastructureManagement::MountingPointType::OutdoorIPS:
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Outdoor_IPS"));
break;
case InfrastructureManagement::MountingPointType::IndoorIPS:
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Indoor_IPS"));
break;
case InfrastructureManagement::MountingPointType::MeteoDataUnit:
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Meteo_Data_Unit"));
break;
case InfrastructureManagement::MountingPointType::AnnouncementUnit:
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Announcement_Unit"));
break;
case InfrastructureManagement::MountingPointType::VirtualIPS:
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Virtual_IPS"));
break;
case InfrastructureManagement::MountingPointType::EffectGenerationControlUnit:
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Effect_Generation_Control_Unit"));
break;
case InfrastructureManagement::MountingPointType::BuildingNetworkSwitch:
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Building_Network_Switch_Control_Unit"));
break;
case InfrastructureManagement::MountingPointType::OutdoorControlUnit:
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Outdoor_Control_Unit"));
break;
case InfrastructureManagement::MountingPointType::Unknown:
default:
WARNING_LOG(m_logger) << "Unknown MountingPointType found for assetId " << m_assetId << ": " << toString(mountingPointData.mountingPointTypeId());
break;
} // switch
DEBUG_LOG(m_logger) << "Initializing MountingPointInfoDialog done :)";
return true;
}
void MountingPointInfoDialog::onInstrumentationAssetChanged(const InfrastructureManagement::InstrumentationAsset &data, DataModification modType)
{
if (data.id() != m_assetId)
return;
if (modType == DataModification::eRemoved)
removeAsset();
else
showAsset(data);
}
void MountingPointInfoDialog::onMountingPointAssetChanged(const InfrastructureManagement::MountingPointAsset &data, DataModification modType)
{
if (data.structureElementId() != m_mountingPointId)
return;
if (modType == DataModification::eRemoved)
removeAsset();
else
showAsset(m_dtc->instrumentationAsset(data.assetId()));
}
void MountingPointInfoDialog::onMainScheduleChanged(const InfrastructureManagement::MainSchedule &data, DataModification modType)
{
if (data.id() != m_scheduleId ||
modType != DataModification::eModified)
return;
setIsIncluded(data);
}
void MountingPointInfoDialog::onShowStream() const
{
if (!m_avmIfc)
{
ERROR_LOG(m_logger) << "m_avmIfc is not loaded.";
return;
}
m_avmIfc->showCamera(/*m_session->baseLayoutWidget()*/nullptr, m_mountingPointId);
}
void MountingPointInfoDialog::onAnnouncement() const
{
if (!m_avmIfc)
{
ERROR_LOG(m_logger) << "m_avmIfc is not loaded.";
return;
}
m_avmIfc->showAnnouncementUnit(m_mountingPointId);
}
void MountingPointInfoDialog::showAsset(const InfrastructureManagement::InstrumentationAsset &asset)
{
removeAsset();
DEBUG_LOG(m_logger) << "Showing new asset";
m_assetId = asset.id();
addAssetProperty(tr("Name"), QString::fromStdString(asset.name()));
addAssetProperty(tr("State"), toString(asset.assetStateId()));
addAssetProperty(tr("Hostname"), QString::fromStdString(asset.hostname()));
addAssetProperty(tr("Barcode"), QString::fromStdString(asset.barcode()));
const QJsonObject dynamicProps(QJsonDocument::fromJson(QByteArray::fromStdString(asset.properties())).object());
for (auto it = dynamicProps.begin(); it != dynamicProps.end(); ++it)
{
if (it.key() == QStringLiteral("hasSpeaker") && it.value() == true)
{
// Show Button Announcement
connect(m_ui->pbAnnouncement, &QToolButton::clicked, this, &MountingPointInfoDialog::onAnnouncement);
m_ui->pbAnnouncement->setVisible(m_avmIfc->hasAvsSession() && m_avmIfc->avaSession()->isEstablished());
}
addAssetProperty(it.key(), jsonValToString(it.value()));
}
m_ui->gbxAsset->show();
}
void MountingPointInfoDialog::removeAsset()
{
DEBUG_LOG(m_logger) << "Removing asset information";
m_assetId = -1;
m_ui->gbxAsset->hide();
for (QLabel *lbl : qAsConst(m_dynamicAssetPropLabels))
m_ui->gbxAsset->layout()->removeWidget(lbl);
qDeleteAll(m_dynamicAssetPropLabels);
m_dynamicAssetPropLabels.clear();
}
void MountingPointInfoDialog::addAssetProperty(const QString &propName, const QString &propValue)
{
DEBUG_LOG(m_logger) << "Adding asset property "
<< propName
<< ':'
<< propValue;
QLabel *lblPropName = new LtsWidgets::LtsElidedLabel(propName + QLatin1Char(':'));
QLabel *lblPropValue = new QLabel(propValue);
m_dynamicAssetPropLabels.append(lblPropName);
m_dynamicAssetPropLabels.append(lblPropValue);
QGridLayout *assetsLayout = static_cast<QGridLayout *>(m_ui->gbxAsset->layout());
int row = assetsLayout->rowCount();
assetsLayout->addWidget(lblPropName, row, 0);
assetsLayout->addWidget(lblPropValue, row, 1);
}
void MountingPointInfoDialog::setIsIncluded(const MainSchedule &schedule)
{
for (const MountingPointPlan &currentPlan : schedule.elements())
{
if (currentPlan.structureElementId() == m_mountingPointId)
{
m_ui->lblIncludedEntry->setText(tr("Yes"));
return;
}
}
m_ui->lblIncludedEntry->setText(tr("No"));
}
QString MountingPointInfoDialog::jsonValToString(const QJsonValue &val) const
{
switch (val.type())
{
case QJsonValue::Bool:
case QJsonValue::Double:
case QJsonValue::String:
return val.toVariant().toString();
case QJsonValue::Array:
return QString::fromUtf8(QJsonDocument(val.toArray()).toJson(QJsonDocument::Compact));
case QJsonValue::Object:
return QString::fromUtf8(QJsonDocument(val.toObject()).toJson(QJsonDocument::Compact));
case QJsonValue::Null:
case QJsonValue::Undefined:
default:
return QString();
}
}
} // namespace InfrastructureManagement
@@ -0,0 +1,69 @@
/**
* @RDE_HEADER@
* The MountingPointInfoDialog shows information about a single mounting point
* $Id$
* $HeadURL$
* $Author$
* Created by Hannes Baeuerle, SLSE, 2017-01-12
*/
#pragma once
#include <LtsWidgets/lts_dialog.h>
#include <Plugins/AudioVideoManagement/avm_data_plugin_interface.h>
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
#include <InfrastructureManagement/logger.h>
class QJsonValue;
class QLabel;
namespace Ui
{
class MountingPointInfoDialog;
}
namespace InfrastructureManagement
{
class MountingPointInfoDialog
: public LtsWidgets::LtsDialog
{
Q_OBJECT
public:
explicit MountingPointInfoDialog(int32_t mountingPointId, int32_t scheduleId, const QString &menuGroup, QWidget *parent = nullptr);
~MountingPointInfoDialog();
bool init(const std::shared_ptr<Interface::Dtc> &dtc,
const std::shared_ptr<InfrastructureManagement::ForeignDataInterface> &ismIfc,
const std::shared_ptr<AudioVideoManagement::ForeignDataInterface> &avmIfc);
private Q_SLOTS:
void onInstrumentationAssetChanged(const InfrastructureManagement::InstrumentationAsset &data, DataModification modType);
void onMountingPointAssetChanged(const InfrastructureManagement::MountingPointAsset &data, DataModification modType);
void onMainScheduleChanged(const InfrastructureManagement::MainSchedule &data, DataModification modType);
void onShowStream() const;
void onAnnouncement() const;
private: // methods
void retranslate() override;
void showAsset(const InfrastructureManagement::InstrumentationAsset &asset);
void removeAsset();
void addAssetProperty(const QString &propName, const QString &propValue);
void setIsIncluded(const MainSchedule &schedule);
QString jsonValToString(const QJsonValue &val) const;
private: // attributes
Ui::MountingPointInfoDialog *m_ui;
int32_t m_mountingPointId;
int32_t m_assetId;
int32_t m_scheduleId;
QString m_menuGroup;
std::shared_ptr<Interface::Dtc> m_dtc;
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> m_ismIfc;
std::shared_ptr<AudioVideoManagement::ForeignDataInterface> m_avmIfc;
QVector<QLabel *> m_dynamicAssetPropLabels;
LOGGER_T m_logger;
}; // class MountingPointInfoDialog
} // namespace InfrastructureManagement
@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MountingPointInfoDialog</class>
<widget class="QWidget" name="MountingPointInfoDialog">
<property name="windowTitle">
<string notr="true">Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="7" column="0" colspan="2">
<widget class="LtsWidgets::LtsElidedLabel" name="lblPosition">
<property name="text">
<string>Position:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QToolButton" name="pbAnnouncement">
<property name="maximumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../../Styles/Light/resources/rme_light_style.qrc">
<normaloff>:/style/announcement_menu.svg</normaloff>:/style/announcement_menu.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QToolButton" name="pbShowStream">
<property name="maximumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../../Styles/Light/resources/rme_light_style.qrc">
<normaloff>:/style/video_menu.svg</normaloff>:/style/video_menu.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="LtsWidgets::LtsElidedLabel" name="lblBuilding">
<property name="text">
<string>Building:</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="LtsWidgets::LtsElidedLabel" name="lblIncluded">
<property name="text">
<string>Included:</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="LtsWidgets::LtsElidedLabel" name="lblRoom">
<property name="text">
<string>Room:</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblIcon">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="5" column="0" colspan="2">
<widget class="LtsWidgets::LtsElidedLabel" name="lblFloor">
<property name="text">
<string>Floor:</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="LtsWidgets::LtsElidedLabel" name="lblType">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="lblNameEntry">
<property name="text">
<string notr="true">&lt;NAME&gt;</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="lblTypeEntry">
<property name="text">
<string notr="true">&lt;TYPE&gt;</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="0" colspan="4">
<widget class="QGroupBox" name="gbxAsset">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>Equipped asset</string>
</property>
<layout class="QGridLayout" name="gridLayout"/>
</widget>
</item>
<item row="7" column="2" colspan="2">
<widget class="QLabel" name="lblPositionEntry">
<property name="text">
<string notr="true">&lt;POSITION&gt;</string>
</property>
</widget>
</item>
<item row="6" column="2" colspan="2">
<widget class="QLabel" name="lblRoomEntry">
<property name="text">
<string notr="true">&lt;ROOM&gt;</string>
</property>
</widget>
</item>
<item row="5" column="2" colspan="2">
<widget class="QLabel" name="lblFloorEntry">
<property name="text">
<string notr="true">&lt;FLOOR&gt;</string>
</property>
</widget>
</item>
<item row="4" column="2" colspan="2">
<widget class="QLabel" name="lblBuildingEntry">
<property name="text">
<string notr="true">&lt;TYPE&gt;</string>
</property>
</widget>
</item>
<item row="3" column="2" colspan="2">
<widget class="QLabel" name="lblIncludedEntry">
<property name="text">
<string notr="true">&lt;INCLUDED&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LtsWidgets::LtsElidedLabel</class>
<extends>QLabel</extends>
<header>LtsWidgets/lts_elided_label.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../Styles/Light/resources/rme_light_style.qrc"/>
</resources>
<connections/>
</ui>