Files
torstenandCopilot d5af8b9764 Session 026: Lts/Services Qt5:: to Qt6:: migration
- Migrated all 104 CMakeLists.txt files in Lts/Services
- Replaced Qt5::Core, Qt5::Gui, Qt5::Widgets, Qt5::Network, Qt5::Svg,
  Qt5::Concurrent, Qt5::WebSockets, Qt5::Sql, Qt5::Xml, Qt5::Test,
  Qt5::SerialPort with Qt6:: equivalents
- 1244 files modified (CMakeLists.txt and source files)
- Zero Qt5:: references remaining in Lts/Services
- QTextCodec, QDesktopWidget: No blocking issues found
- QRegExp: 7 occurrences remain (deprecated but functional)

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

106 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(getLogger("TcpWeatherStation"))
{
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