Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Services/MeteoDataManagement/tcpweatherstation.cpp
T
torsten 950d669538 Qt6 Migration: BUILD_RTI guards und CMake fixes
- BUILD_RTI conditional compilation für RTI Connext DDS dependencies
- Namespace fixes in core_dtc.h (Core:: → DDS::Core::)
- CMakeLists.txt: BUILD_RTI option und conditional dependencies
- Handler minelayer: namespace closing mit BUILD_RTI guard
- Build erfolgreich mit BUILD_RTI=OFF validiert

Signed-off-by: Torsten Wierschin <torsten.wierschin@life-maps.com>
2026-08-21 18:37:18 +02:00

104 lines
3.3 KiB
C++
Executable File

/**
* Handle one weatherstation consist of one wind- and climate sensor
* All data will be send by signal/slot connection in case of data change.
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-09-22
*/
#include "tcpweatherstation.h"
#include "tcpclimate.h"
#include "tcpwind.h"
namespace MeteoDataManagement
{
TcpWeatherStation::TcpWeatherStation(int id,
const QString &converterIp,
quint16 climatePort,
quint16 windPort,
QObject *parent) : QObject(parent)
, m_id(id)
, m_converterIp(converterIp)
, m_climatePort(climatePort)
, m_windPort(windPort)
, m_tcpClimate(nullptr)
, m_tcpWind(nullptr)
, m_pressure(800.0)
, m_temperature(0.0)
, m_humidity(0.0)
, m_direction(0.0)
, m_speed(0.0)
, m_climateOk(false)
, m_windOk(false),
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()) {
INFO_LOG(m_logger) << "Start TcpWeatherStation ip/(hostname): " << m_converterIp
<< " climatePort: " << m_climatePort
<< " windPort: " << m_windPort;
if (m_climatePort)
{
m_tcpClimate = new TcpClimate(this);
INFO_LOG(m_logger) << "m_tcpClimate->start(" << m_converterIp << ", "
<< QString::number(m_climatePort) << ")";
m_tcpClimate->start(m_converterIp, m_climatePort);
connect(m_tcpClimate, &TcpClimate::sigClimateDataChanged,
this, &TcpWeatherStation::onClimateDataChanged);
}
if (m_windPort)
{
m_tcpWind = new TcpWind(this);
INFO_LOG(m_logger) << "m_tcpWind->start(" << m_converterIp << ", "
<< QString::number(m_windPort) << ")";
m_tcpWind->start(m_converterIp, m_windPort);
connect(m_tcpWind, &TcpWind::sigWindDataChanged,
this, &TcpWeatherStation::onWindDataChanged);
}
}
//-------------------------------------------------------------------
void TcpWeatherStation::onClimateDataChanged(float pressure, float temperature, float humidity, bool climateOk)
{
INFO_LOG(m_logger) << "onClimateDataChanged()"
<< " MDU AssetId: " << m_id
<< " pressure: " << pressure
<< " temperature: " << temperature
<< " humidity: " << humidity
<< " climateOk: " << climateOk;
m_pressure = pressure;
m_temperature = temperature;
m_humidity = humidity;
m_climateOk = climateOk;
emit sigWeatherDataChanged(m_id, m_pressure, m_temperature, m_humidity, m_direction, m_speed, m_climateOk, m_windOk);
}
//-------------------------------------------------------------------
void TcpWeatherStation::onWindDataChanged(float direction, float speed, bool windOk)
{
INFO_LOG(m_logger) << "onWindDataChanged()"
<< " MDU AssetId: " << m_id
<< " direction: " << direction
<< " speed: " << speed
<< " climateOk: " << m_climateOk;
m_direction = direction;
m_speed = speed;
m_windOk = windOk;
emit sigWeatherDataChanged(m_id, m_pressure, m_temperature, m_humidity, m_direction, m_speed, m_climateOk, m_windOk);
}
//-------------------------------------------------------------------
} // namespace MeteoDataManagement