Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+27
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(Data)
|
||||
ADD_SUBDIRECTORY(Gui)
|
||||
|
||||
#
|
||||
# Gui Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(MdmGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mdm_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
GuiPluginInterface
|
||||
)
|
||||
|
||||
#
|
||||
# Data Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(MdmDataPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mdm_data_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
DataPluginInterface
|
||||
svcMdmCommon
|
||||
)
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE; 2016-09-06
|
||||
#
|
||||
|
||||
#
|
||||
# Data Plugin
|
||||
#
|
||||
NGL_ADD_LIBRARY2(WS MdmDataPlugin MODULE mdm_data_plugin.cpp mdm_data_plugin.h)
|
||||
NGL_TARGET_LINK_LIBRARIES(MdmDataPlugin
|
||||
Qt5::Core
|
||||
MdmDataPluginInterface
|
||||
svcMdmClient
|
||||
NGLLogger
|
||||
LtsSessionDataDds
|
||||
)
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for MeteoDataManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#include "mdm_data_plugin.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
|
||||
namespace MeteoDataManagement
|
||||
{
|
||||
std::shared_ptr<DataPluginBase::Interface> DataPlugin::createDataInterface(LtsSession::LtsSessionDataDds *session)
|
||||
{
|
||||
std::shared_ptr<Interface::Dtc> dtc;
|
||||
std::shared_ptr<Interface::Ftc> ftc;
|
||||
if (!session->createTopicClient(dtc, ftc, false, true))
|
||||
return std::shared_ptr<DataPluginBase::Interface>();
|
||||
|
||||
return std::make_shared<DataInterfaceImpl>(dtc,ftc);
|
||||
}
|
||||
|
||||
DataInterfaceImpl::DataInterfaceImpl(const std::shared_ptr<MeteoDataManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<MeteoDataManagement::Interface::Ftc> &ftc)
|
||||
: DataInterface()
|
||||
, m_dtc(dtc)
|
||||
, m_ftc(ftc)
|
||||
{}
|
||||
|
||||
} // namespace MeteoDataManagement
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for MeteoDataManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <Plugins/MeteoDataManagement/mdm_data_plugin_interface.h>
|
||||
|
||||
#include <MeteoDataManagement/mdm_dtc.h>
|
||||
#include <MeteoDataManagement/mdm_ftc.h>
|
||||
|
||||
|
||||
namespace MeteoDataManagement
|
||||
{
|
||||
|
||||
class DataPlugin final : public QObject, public DataPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "data:3:mdm")
|
||||
Q_INTERFACES(DataPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataPlugin() = default;
|
||||
~DataPlugin() = default;
|
||||
|
||||
QString pluginName() const override { return QStringLiteral("MeteoDataManagement"); }
|
||||
std::shared_ptr<DataPluginBase::Interface> createDataInterface(LtsSession::LtsSessionDataDds *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class DataInterfaceImpl final : public DataInterface
|
||||
{
|
||||
public:
|
||||
DataInterfaceImpl(const std::shared_ptr<MeteoDataManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<MeteoDataManagement::Interface::Ftc> &ftc);
|
||||
|
||||
std::shared_ptr<MeteoDataManagement::Interface::Dtc> getDtc() override { return m_dtc; }
|
||||
std::shared_ptr<MeteoDataManagement::Interface::Ftc> getFtc() override { return m_ftc; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<MeteoDataManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<MeteoDataManagement::Interface::Ftc> m_ftc;
|
||||
};
|
||||
|
||||
} // namespace MeteoDataManagement
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(MeteoData)
|
||||
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Patric Karwat, SLSE, 2016-10-05
|
||||
#
|
||||
|
||||
SET(mdm_meteo_data_gui_SRCS
|
||||
mdm_meteo_data_gui_plugin.cpp
|
||||
mdm_meteo_data_gui_plugin.h
|
||||
mdm_meteo_data.cpp
|
||||
mdm_meteo_data.h
|
||||
mdm_meteo_data_model.cpp
|
||||
mdm_meteo_data_model.h
|
||||
mdm_static_meteo_data_edit.cpp
|
||||
mdm_static_meteo_data_edit.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(mdm_meteo_data_gui_SRCS
|
||||
mdm_meteo_data.ui
|
||||
mdm_static_meteo_data_edit.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS MdmMeteoDataGuiPlugin MODULE ${mdm_meteo_data_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(MdmMeteoDataGuiPlugin
|
||||
NGLLogger
|
||||
LtsPrinting
|
||||
LtsSession
|
||||
MdmGuiPluginInterface
|
||||
MdmDataPluginInterface
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsDataView
|
||||
LtsUtilsGuiDds
|
||||
LtsSessionDataDds
|
||||
LtsUtilsSettings
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(MdmMeteoDataGuiPlugin)
|
||||
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for MeteoDataManagement - Meteo Data Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#include "mdm_meteo_data.h"
|
||||
#include "ui_mdm_meteo_data.h"
|
||||
#include "mdm_static_meteo_data_edit.h"
|
||||
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace MeteoDataManagement
|
||||
{
|
||||
|
||||
MeteoDataView::MeteoDataView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_model(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::MeteoDataView)
|
||||
, m_logger(getLogger("MeteoDataManagementDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
// connects fuer Widgetaenderungen
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &MeteoDataView::onSelectionChanged);
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &MeteoDataView::onEditStaticMeteoData);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalEnterPressed, this, &MeteoDataView::onEditStaticMeteoData);
|
||||
|
||||
// Edit-Button erzeugen
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &MeteoDataView::onEditStaticMeteoData);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &MeteoDataView::onPrint);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Weather_Stations"));
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
MeteoDataView::~MeteoDataView()
|
||||
{
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void MeteoDataView::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Weather Stations"));
|
||||
}
|
||||
|
||||
bool MeteoDataView::init(const std::shared_ptr<MeteoDataManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<MeteoDataManagement::Interface::Ftc> &ftc)
|
||||
{
|
||||
if (!dtc || !ftc)
|
||||
return false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_model = new MeteoDataModel(this);
|
||||
m_model->initModel(m_dtc);
|
||||
m_ui->widget->setModel(m_model);
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(MeteoDataModel::Id);
|
||||
#endif
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void MeteoDataView::onSelectionChanged()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
MeteoDataManagement::MeteoData meteoData = m_model->getRowData(row);
|
||||
|
||||
if(meteoData.isStaticMeteoData())
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
}
|
||||
} // end of onSelectionChanged()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void MeteoDataView::onEditStaticMeteoData()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
MeteoDataManagement::MeteoData meteoData = m_model->getRowData(row);
|
||||
|
||||
DEBUG_LOG(m_logger) << "--- onEditStaticMeteoData() "
|
||||
<< " id: " << meteoData.id()
|
||||
<< " mduId: " << meteoData.weatherStationId()
|
||||
<< " isStaticData: " << meteoData.isStaticMeteoData()
|
||||
<< " WindDirection: " << meteoData.windDirection()
|
||||
<< " WindSpeed: " << meteoData.windSpeed()
|
||||
<< " Temp: " << meteoData.temperature()
|
||||
<< " Pressure: " << meteoData.pressure()
|
||||
<< " Humidity: " << meteoData.humidity()
|
||||
;
|
||||
|
||||
if(meteoData.isStaticMeteoData())
|
||||
{
|
||||
StaticMeteoDataEdit *dialog = new StaticMeteoDataEdit(this);
|
||||
dialog->init(m_dtc, m_ftc, m_session);
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("mdmSetStaticMeteoData"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
} // end of onEditStaticMeteoData()
|
||||
//-----------------------------------------------------------------------------
|
||||
void MeteoDataView::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView() );
|
||||
} // end of onPrint()
|
||||
|
||||
void MeteoDataView::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
} // namespace MeteoDataManagement
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for MeteoDataManagement - Meteo Data Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mdm_meteo_data_model.h"
|
||||
|
||||
#include <Services/MeteoDataManagement/mdm_dtc.h>
|
||||
#include <Services/MeteoDataManagement/mdm_ftc.h>
|
||||
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MeteoDataView;
|
||||
}
|
||||
namespace MeteoDataManagement
|
||||
{
|
||||
|
||||
class MeteoDataView : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MeteoDataView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~MeteoDataView();
|
||||
bool init(const std::shared_ptr<MeteoDataManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<MeteoDataManagement::Interface::Ftc> &ftc);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onEditStaticMeteoData();
|
||||
void onPrint();
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
QString m_menuGroup;
|
||||
MeteoDataModel *m_model;
|
||||
std::shared_ptr<MeteoDataManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<MeteoDataManagement::Interface::Ftc> m_ftc;
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::MeteoDataView *m_ui;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
};
|
||||
|
||||
} // namespace MeteoDataManagement
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MeteoDataView</class>
|
||||
<widget class="QWidget" name="MeteoDataView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>455</width>
|
||||
<height>341</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Meteo Data</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>250</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for MeteoDataManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#include "mdm_meteo_data.h"
|
||||
#include "mdm_meteo_data_gui_plugin.h"
|
||||
#include "mdm_static_meteo_data_edit.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Services/MeteoDataManagement/mdm_operator_rights.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
namespace MeteoDataManagement
|
||||
{
|
||||
|
||||
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.Mdm.MeteoData"))
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_enableB(false)
|
||||
, m_enableC(false)
|
||||
, m_enableN(false)
|
||||
{
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
m_enableB = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableBiologicalContamination")).toBool();
|
||||
m_enableC = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableChemicalContamination")).toBool();
|
||||
m_enableN = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableNuclearContaminations")).toBool();
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<MeteoDataManagement::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<MeteoDataManagement::DataInterface>(m_ftc))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_dtc = nullptr;
|
||||
m_ftc = nullptr;
|
||||
}
|
||||
|
||||
|
||||
QString InterfaceImpl::menuGroup() const
|
||||
{
|
||||
if (!m_enableB && !m_enableC && m_enableN)
|
||||
return tr("Area Effect Simulation N");
|
||||
else if (m_enableB && !m_enableC && m_enableN)
|
||||
return tr("Area Effect Simulation NB");
|
||||
else if (!m_enableB && m_enableC && m_enableN)
|
||||
return tr("Area Effect Simulation NC");
|
||||
else if (m_enableB && !m_enableC && !m_enableN)
|
||||
return tr("Area Effect Simulation B");
|
||||
else if (m_enableB && m_enableC && !m_enableN)
|
||||
return tr("Area Effect Simulation BC");
|
||||
else if (!m_enableB && m_enableC && !m_enableN)
|
||||
return tr("Area Effect Simulation C");
|
||||
else
|
||||
return tr("Area Effect Simulation NBC");
|
||||
}
|
||||
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableShowMeteoDataStations = ps->value(QStringLiteral("mdm"),
|
||||
QStringLiteral("enableShowMeteoDataStations")).toBool();
|
||||
const bool enableEditStaticMeteoData = ps->value(QStringLiteral("mdm"),
|
||||
QStringLiteral("enableEditStaticMeteoData")).toBool();
|
||||
|
||||
LtsWidgets::PluginData plData;
|
||||
if (enableShowMeteoDataStations)
|
||||
{
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Weather Stations");
|
||||
plData.identifier = QLatin1String("mdmMeteoData");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:meteorological_data.svg"));
|
||||
plData.operatorRight = OperatorRights::MeteoDataWeatherStationsShow;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eExecution;
|
||||
plData.createWidgetFunc = [this](QWidget *parent)
|
||||
{
|
||||
return onShowMeteoData(parent);
|
||||
};
|
||||
ret.append(plData);
|
||||
}
|
||||
|
||||
if (enableEditStaticMeteoData)
|
||||
{
|
||||
// Action 'Set Static Meteo Data' anlegen
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Static Meteo Data");
|
||||
plData.identifier = QLatin1String("mdmSetStaticMeteoData");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:meteorological_data_edit.svg"));
|
||||
plData.operatorRight = OperatorRights::MeteoDataStaticWeatherEdit;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eExecution;
|
||||
plData.createWidgetFunc = [this](QWidget *parent)
|
||||
{
|
||||
return onShowSetStaticMeteoData(parent);
|
||||
};
|
||||
ret.append(plData);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowMeteoData(QWidget *parent)
|
||||
{
|
||||
MeteoDataView *dialog = new MeteoDataView(menuGroup(), m_session, parent);
|
||||
dialog->init(m_dtc, m_ftc);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowSetStaticMeteoData(QWidget *parent)
|
||||
{
|
||||
StaticMeteoDataEdit *dialog = new StaticMeteoDataEdit(parent);
|
||||
dialog->init(m_dtc, m_ftc, m_session);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
} // namespace MeteoDataManagement
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for MeteoDataManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <MeteoDataManagement/logger.h>
|
||||
#include <MeteoDataManagement/mdm_ftc.h>
|
||||
#include <MeteoDataManagement/mdm_dtc.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/MeteoDataManagement/mdm_data_plugin_interface.h>
|
||||
#include <Plugins/MeteoDataManagement/mdm_gui_plugin_interface.h>
|
||||
|
||||
|
||||
namespace MeteoDataManagement
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:mdm")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QLatin1String("MeteoDataManagementGuiPlugin"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise;
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QString menuGroup() const override;
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Exercise || partition == IDL::PartitionType::Global; }
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowMeteoData(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onShowSetStaticMeteoData(QWidget *parent);
|
||||
|
||||
std::shared_ptr<MeteoDataManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<MeteoDataManagement::Interface::Ftc> m_ftc;
|
||||
bool m_enableB;
|
||||
bool m_enableC;
|
||||
bool m_enableN;
|
||||
};
|
||||
|
||||
} // namespace MeteoDataManagement
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for MeteoDataManagement - Weather Station Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10.05
|
||||
*/
|
||||
|
||||
#include "mdm_meteo_data_model.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QColor>
|
||||
|
||||
namespace MeteoDataManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// MeteoDataModel
|
||||
//---------------------------------
|
||||
MeteoDataModel::MeteoDataModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<MeteoDataManagement::MeteoData>({tr("Id"),
|
||||
tr("Description"),
|
||||
tr("Wind Direction [°]"),
|
||||
tr("Wind Speed [m/s]"),
|
||||
tr("Temperature [°C]"),
|
||||
tr("Pressure [hPa]"),
|
||||
tr("Humidity [%]")},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_logger(getLogger("MeteoDataModel"))
|
||||
{}
|
||||
|
||||
|
||||
bool MeteoDataModel::initModel(const std::shared_ptr<MeteoDataManagement::Interface::Dtc> &dtc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
|
||||
connect(m_dtc.get(), &MeteoDataManagement::Interface::Dtc::meteoDataChanged,
|
||||
this, &MeteoDataModel::onDataChanged);
|
||||
// insert Model
|
||||
m_dtc->meteoDatas([this](const MeteoDataManagement::MeteoData &meteoData) { insertRow(meteoData); });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant MeteoDataModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if ((role != Qt::DisplayRole && role != Qt::BackgroundRole) || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const MeteoDataManagement::MeteoData &meteoData = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::BackgroundRole )
|
||||
{
|
||||
if (meteoData.isStaticMeteoData())
|
||||
return QVariant();
|
||||
if (index.column() == WindDirection || index.column() == WindSpeed)
|
||||
return meteoData.windOk() ? QVariant() : QColor(Qt::red);
|
||||
|
||||
if (index.column() == Temperature || index.column() == Pressure || index.column() == Humidity)
|
||||
return meteoData.climateOk() ? QVariant() : QColor(Qt::red);
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return meteoData.weatherStationId();
|
||||
case Note:
|
||||
if (meteoData.isStaticMeteoData())
|
||||
return QCoreApplication::translate("dds", meteoData.note().c_str());
|
||||
return QString::fromStdString(meteoData.note());
|
||||
case WindDirection:
|
||||
return qRound((meteoData.windDirection() * 100.0)) / 100.0;
|
||||
case WindSpeed:
|
||||
return qRound(meteoData.windSpeed());
|
||||
case Temperature:
|
||||
return meteoData.temperature();
|
||||
case Pressure:
|
||||
return meteoData.pressure();
|
||||
case Humidity:
|
||||
return meteoData.humidity();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
} // namespace MeteoDataManagement
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for MeteoDataManagement - Weather Station Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10.05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <MeteoDataManagement/mdm_dtc.h>
|
||||
#include <MeteoDataManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
|
||||
namespace MeteoDataManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// MeteoDataModel
|
||||
// --------------------------------------------------------
|
||||
class MeteoDataModel final : public LtsWidgets::LtsAbstractTableModel<MeteoDataManagement::MeteoData>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
Note,
|
||||
WindDirection,
|
||||
WindSpeed,
|
||||
Temperature,
|
||||
Pressure,
|
||||
Humidity
|
||||
};
|
||||
explicit MeteoDataModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<MeteoDataManagement::Interface::Dtc> &dtc);
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
|
||||
private:
|
||||
std::shared_ptr<MeteoDataManagement::Interface::Dtc> m_dtc;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} //namespace MeteoDataManagement
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* MeteoDataManagement - Static Meteo Data Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-10-17
|
||||
*/
|
||||
|
||||
#include "mdm_static_meteo_data_edit.h"
|
||||
#include "ui_mdm_static_meteo_data_edit.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
|
||||
|
||||
namespace MeteoDataManagement
|
||||
{
|
||||
|
||||
StaticMeteoDataEdit::StaticMeteoDataEdit(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::StaticMeteoDataEdit)
|
||||
, m_logger(getLogger("MeteoDataManagementEdit"))
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_meteoDataId(0) // invalid / new
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Edit_Static_Weather"));
|
||||
}
|
||||
|
||||
|
||||
StaticMeteoDataEdit::~StaticMeteoDataEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void StaticMeteoDataEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Static Meteo Data"));
|
||||
}
|
||||
|
||||
|
||||
bool StaticMeteoDataEdit::init(const std::shared_ptr<MeteoDataManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<MeteoDataManagement::Interface::Ftc> &ftc,
|
||||
LtsSession::LtsSession *session)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "StaticMeteoDataEdit::init()";
|
||||
|
||||
if (!dtc || !ftc || !session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "StaticMeteoDataEdit::init() Invalid shared_ptr!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_session = session;
|
||||
|
||||
loadStaticMeteoDataFromDatabase();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool StaticMeteoDataEdit::apply()
|
||||
{
|
||||
if (m_meteoDataId < 1)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("There is no static Meteo Data."), tr("Error"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Send modified data via FTC call
|
||||
return m_requestHelper->startSingleRequest([this]()
|
||||
{
|
||||
StaticMeteoDataModifyRequest requestData;
|
||||
requestData.id(m_meteoDataId);
|
||||
requestData.windDirection(m_ui->sbWindDirection->value());
|
||||
requestData.windSpeed(m_ui->sbWindSpeed->value());
|
||||
requestData.temperature(m_ui->sbTemperature->value());
|
||||
requestData.pressure(m_ui->sbPressure->value());
|
||||
requestData.humidity(m_ui->sbHumidity->value());
|
||||
requestData.timeStamp(m_session->partitionTime());
|
||||
|
||||
return m_ftc->staticMeteoDataModifyRequest(requestData, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void StaticMeteoDataEdit::loadStaticMeteoDataFromDatabase()
|
||||
{
|
||||
const QMap<qint32, MeteoDataManagement::MeteoData> meteoDatas = m_dtc->meteoDatas();
|
||||
|
||||
for (const MeteoDataManagement::MeteoData &meteoData : meteoDatas)
|
||||
{
|
||||
if (meteoData.isStaticMeteoData())
|
||||
{
|
||||
m_meteoDataId = meteoData.id();
|
||||
|
||||
m_ui->sbWindDirection->setValue(meteoData.windDirection());
|
||||
m_ui->sbWindSpeed->setValue(meteoData.windSpeed());
|
||||
m_ui->sbTemperature->setValue(meteoData.temperature());
|
||||
m_ui->sbPressure->setValue(meteoData.pressure());
|
||||
m_ui->sbHumidity->setValue(meteoData.humidity());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace MeteoDataManagement
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* MeteoDataManagement - Static Meteo Data Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-10-17
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Services/MeteoDataManagement/mdm_dtc.h>
|
||||
#include <Services/MeteoDataManagement/mdm_ftc.h>
|
||||
#include <MeteoDataManagement/logger.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class StaticMeteoDataEdit;
|
||||
}
|
||||
|
||||
namespace MeteoDataManagement
|
||||
{
|
||||
|
||||
class StaticMeteoDataEdit : public LtsWidgets::LtsDialog,
|
||||
protected MeteoDataManagement::Interface::Ftc::StaticMeteoDataModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit StaticMeteoDataEdit(QWidget *parent = nullptr);
|
||||
~StaticMeteoDataEdit();
|
||||
|
||||
bool init(const std::shared_ptr<MeteoDataManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<MeteoDataManagement::Interface::Ftc> &ftc,
|
||||
LtsSession::LtsSession *session);
|
||||
bool apply() override;
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void loadStaticMeteoDataFromDatabase();
|
||||
void onStaticMeteoDataModifyReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<MeteoDataManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<MeteoDataManagement::Interface::Ftc> m_ftc;
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::StaticMeteoDataEdit *m_ui;
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
int m_meteoDataId;
|
||||
};
|
||||
|
||||
} //namespace MeteoDataManagement
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>StaticMeteoDataEdit</class>
|
||||
<widget class="QWidget" name="StaticMeteoDataEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>488</width>
|
||||
<height>254</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblWindSpeed">
|
||||
<property name="text">
|
||||
<string>Wind Speed [m/s]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lblPressure">
|
||||
<property name="text">
|
||||
<string>Pressure [hPa]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lblHumidity">
|
||||
<property name="text">
|
||||
<string>Humidity [%]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbTemperature">
|
||||
<property name="text">
|
||||
<string>Temperature [°C]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblWindDirection">
|
||||
<property name="text">
|
||||
<string>Wind Direction *) [°]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="4" column="0">
|
||||
<widget class="QDoubleSpinBox" name="sbHumidity">
|
||||
<property name="maximum">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QDoubleSpinBox" name="sbTemperature">
|
||||
<property name="minimum">
|
||||
<double>-40.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>70.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QDoubleSpinBox" name="sbPressure">
|
||||
<property name="minimum">
|
||||
<double>800.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1035.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QDoubleSpinBox" name="sbWindDirection">
|
||||
<property name="maximum">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QSpinBox" name="sbWindSpeed">
|
||||
<property name="maximum">
|
||||
<number>327</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblInfo">
|
||||
<property name="text">
|
||||
<string>*) North=0°, East=90°, South=180°, West=270°</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <MeteoDataManagement/mdm_dtc.h>
|
||||
#include <MeteoDataManagement/mdm_ftc.h>
|
||||
|
||||
namespace MeteoDataManagement
|
||||
{
|
||||
/**
|
||||
* @brief The DataInterface class provides the Topics Clients only for the GUI Plugins
|
||||
*/
|
||||
class DataInterface : public DataPluginBase::Interface
|
||||
{
|
||||
public:
|
||||
using DataPluginBase::Interface::Interface;
|
||||
|
||||
virtual std::shared_ptr<MeteoDataManagement::Interface::Dtc> getDtc() = 0;
|
||||
virtual std::shared_ptr<MeteoDataManagement::Interface::Ftc> getFtc() = 0;
|
||||
};
|
||||
|
||||
} // namespace MeteoDataManagement
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for MeteoDataManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace MeteoDataManagement
|
||||
{
|
||||
|
||||
class ForeignGuiInterface
|
||||
{
|
||||
public:
|
||||
ForeignGuiInterface() = default;
|
||||
virtual ~ForeignGuiInterface() = default;
|
||||
};
|
||||
|
||||
} //namespace MeteoDataManagement
|
||||
Reference in new issue
Block a user