Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Services/MeteoDataManagement/handler_meteo_data_unit.cpp
T
torstenandCopilot b774f4035c Qt6 Migration: DDS-Stubs, Logger-Fixes, Export-Header Korrekturen
- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung
- 44 Export-Header Include-Pfade korrigiert (_export.h)
- 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h)
- INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros
- Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits)
- FATAL_LOG Makro hinzugefügt
- InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h)
- FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h)
- AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp)
- SymbolAppearance Klasse vollständig definiert mit content() Methode
- BuildingComponentFilter Klasse definiert mit Copy-Konstruktor
- Ftc Factory: nullptr Return (abstract class)
- AesFilter Klasse in aes.hpp hinzugefügt
- Dtc Klasse in ppm.hpp mit participantChanged Signal
- AesType Enum: alle 15 At* Werte definiert
- AesEffectState_def: EsReceived hinzugefügt
- DataModification Enum: eAdded/eModified/eRemoved
- function_reply_object.h → core_types.h Include-Pfad (72 Dateien)
- Enum-Class-Streaming Template-Operator in INGLLogger.h
- ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen
- ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge
- QRegExp → QRegularExpression in tpm_js_parser.cpp
- .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert
- Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-19 06:06:24 +02:00

145 lines
4.7 KiB
C++
Executable File

/**
* Handler for one meteo data unit
* Manages the connection to a MDU and sends data via DDS as soon as they have been changed
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-09-27
*/
#include "handler_meteo_data_unit.h"
#include "handler_meteo_data_units.h"
#include "handler_infrastructure_data.h"
#include "tcpweatherstation.h"
#include "main_handler.h"
#include <QJsonDocument>
#include <QJsonObject>
using namespace MeteoDataManagement;
HandlerMeteoDataUnit::HandlerMeteoDataUnit(MainHandler *mainHandler,
const InfrastructureManagement::InstrumentationAsset &asset,
QObject *parent)
: QObject(parent)
, m_mainHandler(mainHandler)
, m_asset(asset)
, m_tcpWS(nullptr)
{
init();
} // end of ctor()
//-----------------------------------------------------------------------------
HandlerMeteoDataUnit::~HandlerMeteoDataUnit()
{
delete m_tcpWS;
} // end of dtor()
//-----------------------------------------------------------------------------
bool HandlerMeteoDataUnit::init()
{
delete m_tcpWS;
QJsonParseError jError;
QJsonDocument doc(QJsonDocument::fromJson(m_asset.properties().c_str(), &jError));
if (jError.error != QJsonParseError::NoError ||
!doc.isObject())
{
ERROR_LOG() << "Can not initialize meteo data unit - properties are not parsable: "
<< jError.errorString() << " - '" << m_asset.properties() << "'";
return false;
}
QJsonObject obj(doc.object());
quint16 climatePort = obj[QStringLiteral("climatePort")].toInt();
quint16 windPort = obj[QStringLiteral("windPort")].toInt();
if (climatePort == 0 || windPort == 0)
{
ERROR_LOG() << "Can not parse climate and/or wind port from properties: '" <<
m_asset.properties() << "'";
return false;
}
m_tcpWS = new TcpWeatherStation(m_asset.id(),
QString::fromStdString(m_asset.hostname()),
climatePort,
windPort);
// init local MeteoData Values for compare
m_newMeteoData.id(m_asset.id());
m_newMeteoData.weatherStationId(m_asset.id());
m_newMeteoData.note(m_asset.name());
m_newMeteoData.isStaticMeteoData(false);
// Position der MDU eintragen (GeoPosition2D)
if (m_mainHandler->ism())
{
const Core::GeoPosition geoPos = m_mainHandler->ism()->getStructureElementPosition(m_asset.id());
//GeoPos->GeoPos2D
m_newMeteoData.pos(Core::GeoPosition2D(geoPos.lon(), geoPos.lat()));
}
m_newMeteoData.pressure(800.0);
m_newMeteoData.humidity(0.0);
m_newMeteoData.temperature(0.0);
m_newMeteoData.windSpeed(0.0);
m_newMeteoData.windDirection(0.0);
m_lastMeteoData = m_newMeteoData;
connect(m_tcpWS, &TcpWeatherStation::sigWeatherDataChanged,
this, &HandlerMeteoDataUnit::onMeteoDataChanged);
return true;
} // end of init()
//-----------------------------------------------------------------------------
void HandlerMeteoDataUnit::onMeteoDataChanged(int id,
float pressure, float temperature, float humidity,
float direction, float speed, bool climateOk, bool windOk)
{
m_newMeteoData.id(id);
m_newMeteoData.pressure(pressure); // in hPa
m_newMeteoData.temperature(temperature); // in Grad Celsius
m_newMeteoData.humidity(humidity); // % rel. Feuchte
m_newMeteoData.windDirection(direction); // Grad, Nordbezogen mathem. negativ
m_newMeteoData.windSpeed(speed); // in m/s
m_newMeteoData.climateOk(climateOk);
m_newMeteoData.windOk(windOk);
// Position der MDU eintragen (falls sie noch nicht beim init() ermittelt werden konnte)
if (m_lastMeteoData.pos() == Core::GeoPosition2D())
{
if (m_mainHandler->ism())
{
const Core::GeoPosition geoPos = m_mainHandler->ism()->getStructureElementPosition(m_asset.id());
m_newMeteoData.pos(Core::GeoPosition2D(geoPos.lon(), geoPos.lat()));
}
}
if (m_lastMeteoData == m_newMeteoData)
return;
// publish newMeteoData
onPublishData();
// safe for next compare
m_lastMeteoData = m_newMeteoData;
} // end of onMeteoDataChanged()
//-----------------------------------------------------------------------------
void HandlerMeteoDataUnit::onPublishData()
{
MeteoDataManagement::MeteoData ddsData;
ddsData = m_newMeteoData;
ddsData.timeStamp(m_mainHandler->dds()->currentPartitionTime());
INFO_LOG() << "Publish dynamic MeteoData to dds: " << ddsData;
if (!m_mainHandler->dds()->dts()->publish(ddsData))
ERROR_LOG() << "Error publishing MdmMeteoData to dds";
} // end of onPublishData()
//-----------------------------------------------------------------------------