Add Qt6 support
This commit is contained in:
parent
439d35fd47
commit
17a5d33861
@ -1,6 +1,6 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2021, nymea GmbH
|
||||
* Copyright 2013 - 2025, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
@ -29,6 +29,7 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "integrationpluginalphainnotec.h"
|
||||
#include "alphainnotecmodbustcpconnection.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
#include <network/networkdevicediscovery.h>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2020, nymea GmbH
|
||||
* Copyright 2013 - 2025, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
@ -34,9 +34,8 @@
|
||||
#include <plugintimer.h>
|
||||
#include <integrations/integrationplugin.h>
|
||||
|
||||
#include "alphainnotecmodbustcpconnection.h"
|
||||
|
||||
class NetworkDeviceMonitor;
|
||||
class AlphaInnotecModbusTcpConnection;
|
||||
|
||||
class IntegrationPluginAlphaInnotec: public IntegrationPlugin
|
||||
{
|
||||
|
||||
@ -52,7 +52,7 @@ void AmperfiedConnectDiscovery::startDiscovery(const QString &nameFilter)
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::hostAddressDiscovered, this, &AmperfiedConnectDiscovery::checkNetworkDevice);
|
||||
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
||||
qCDebug(dcAmperfied()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "network devices";
|
||||
qCDebug(dcAmperfied()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "network devices";
|
||||
m_networkDeviceInfos = discoveryReply->networkDeviceInfos();
|
||||
m_gracePeriodTimer.start();
|
||||
discoveryReply->deleteLater();
|
||||
@ -144,14 +144,14 @@ void AmperfiedConnectDiscovery::finishDiscovery()
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
// Fill in finished network device information
|
||||
for (int i = 0; i < m_discoveryResults.count(); i++)
|
||||
for (int i = 0; i < m_discoveryResults.length(); i++)
|
||||
m_discoveryResults[i].networkDeviceInfo = m_networkDeviceInfos.get(m_discoveryResults.value(i).address);
|
||||
|
||||
// Cleanup any leftovers...we don't care any more
|
||||
foreach (AmperfiedModbusTcpConnection *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcAmperfied()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.count()
|
||||
qCInfo(dcAmperfied()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.length()
|
||||
<< "Amperfied wallboxes in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
m_gracePeriodTimer.stop();
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ void IntegrationPluginAmperfied::discoverThings(ThingDiscoveryInfo *info)
|
||||
return;
|
||||
}
|
||||
|
||||
qCInfo(dcAmperfied()) << "Discovery results:" << discovery->discoveryResults().count();
|
||||
qCInfo(dcAmperfied()) << "Discovery results:" << discovery->discoveryResults().length();
|
||||
|
||||
foreach (const EnergyControlDiscovery::Result &result, discovery->discoveryResults()) {
|
||||
ThingDescriptor descriptor(energyControlThingClassId, "Amperfied Energy Control", QString("Slave ID: %1").arg(result.slaveId));
|
||||
@ -82,7 +82,7 @@ void IntegrationPluginAmperfied::discoverThings(ThingDiscoveryInfo *info)
|
||||
if (info->thingClassId() == connectHomeThingClassId || info->thingClassId() == connectBusinessThingClassId || info->thingClassId() == connectSolarThingClassId) {
|
||||
AmperfiedConnectDiscovery *discovery = new AmperfiedConnectDiscovery(hardwareManager()->networkDeviceDiscovery(), info);
|
||||
connect(discovery, &AmperfiedConnectDiscovery::discoveryFinished, info, [this, info, discovery](){
|
||||
qCInfo(dcAmperfied()) << "Discovery results:" << discovery->discoveryResults().count();
|
||||
qCInfo(dcAmperfied()) << "Discovery results:" << discovery->discoveryResults().length();
|
||||
|
||||
foreach (const AmperfiedConnectDiscovery::Result &result, discovery->discoveryResults()) {
|
||||
QString description;
|
||||
|
||||
@ -132,7 +132,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Inverter active power\" register" << 32080 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Inverter active power\" register" << 32080 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 2)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 2 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -177,7 +177,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Inverter input power\" register" << 32064 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Inverter input power\" register" << 32064 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 2)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 2 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -222,7 +222,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Inverter device status\" register" << 32089 << "size:" << 1 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Inverter device status\" register" << 32089 << "size:" << 1 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 1)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 1 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -266,7 +266,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Inverter energy produced\" register" << 32106 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Inverter energy produced\" register" << 32106 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 2)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 2 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -309,7 +309,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Power meter active power\" register" << 37113 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Power meter active power\" register" << 37113 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 2)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 2 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -353,7 +353,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Power meter Positive active electricity\" register" << 37119 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Power meter Positive active electricity\" register" << 37119 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 2)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 2 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -398,7 +398,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Power meter Reverse active power\" register" << 37121 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Power meter Reverse active power\" register" << 37121 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 2)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 2 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -443,7 +443,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Luna 2000 Battery 1 status\" register" << 37000 << "size:" << 1 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Luna 2000 Battery 1 status\" register" << 37000 << "size:" << 1 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 1)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 1 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -499,7 +499,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Luna 2000 Battery 1 power\" register" << 37001 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Luna 2000 Battery 1 power\" register" << 37001 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 2)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 2 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -542,7 +542,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Luna 2000 Battery 1 state of charge\" register" << 37004 << "size:" << 1 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Luna 2000 Battery 1 state of charge\" register" << 37004 << "size:" << 1 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 1)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 1 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -586,7 +586,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Luna 2000 Battery 2 status\" register" << 37741 << "size:" << 1 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Luna 2000 Battery 2 status\" register" << 37741 << "size:" << 1 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 1)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values count. Requested" << 1 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -642,7 +642,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Luna 2000 Battery 2 power\" register" << 37743 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Luna 2000 Battery 2 power\" register" << 37743 << "size:" << 2 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 2)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values count. Requested" << 2 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -685,7 +685,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
handleModbusError(reply->error());
|
||||
if (reply->error() == QModbusDevice::NoError) {
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Luna 2000 Battery 2 state of charge\" register" << 37738 << "size:" << 1 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().count();
|
||||
qCDebug(dcHuaweiFusionSolar()) << "<-- Response from \"Luna 2000 Battery 2 state of charge\" register" << 37738 << "size:" << 1 << "valueCount:" << unit.valueCount() << unit.values() << unit.values().length();
|
||||
if (!valuesAreVaild(unit.values(), 1)) {
|
||||
qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 1 << "but received" << unit.values();
|
||||
} else {
|
||||
@ -712,7 +712,7 @@ void HuaweiFusionSolar::readNextRegister()
|
||||
|
||||
bool HuaweiFusionSolar::valuesAreVaild(const QVector<quint16> &values, int readSize)
|
||||
{
|
||||
if (values.count() != readSize) {
|
||||
if (values.length() != readSize) {
|
||||
qCDebug(dcHuaweiFusionSolar()) << "Invalid values. The received values count does not match the requested" << readSize << "registers.";
|
||||
return false;
|
||||
}
|
||||
@ -722,7 +722,7 @@ bool HuaweiFusionSolar::valuesAreVaild(const QVector<quint16> &values, int readS
|
||||
// 0xFFFF: invalid value of a type other than the floating point type returned by one register
|
||||
// 0xFFFFFFFF: invalid value returned by two registers
|
||||
|
||||
if (values.count() == 2) {
|
||||
if (values.length() == 2) {
|
||||
bool floatingPointValid = (values != QVector<quint16>() << 0x7fff << 0xffff);
|
||||
if (!floatingPointValid)
|
||||
qCDebug(dcHuaweiFusionSolar()) << "Invalid values. The received values match the invalid for floating pointer:" << values;
|
||||
@ -734,7 +734,7 @@ bool HuaweiFusionSolar::valuesAreVaild(const QVector<quint16> &values, int readS
|
||||
return floatingPointValid && otherTypesValid;
|
||||
}
|
||||
|
||||
if (values.count() == 1)
|
||||
if (values.length() == 1)
|
||||
return values.at(0) != 0x7fff && values.at(0) != 0xffff;
|
||||
|
||||
return true;
|
||||
|
||||
@ -153,14 +153,14 @@ void HuaweiFusionSolarDiscovery::finishDiscovery()
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
// Fill in finished network device information
|
||||
for (int i = 0; i < m_results.count(); i++)
|
||||
for (int i = 0; i < m_results.length(); i++)
|
||||
m_results[i].networkDeviceInfo = m_networkDeviceInfos.get(m_results.value(i).address);
|
||||
|
||||
// Cleanup any leftovers...we don't care any more
|
||||
foreach (HuaweiFusionSolar *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcHuawei()) << "Discovery: Finished the discovery process. Found" << m_results.count()
|
||||
qCInfo(dcHuawei()) << "Discovery: Finished the discovery process. Found" << m_results.length()
|
||||
<< "inverters in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
|
||||
emit discoveryFinished();
|
||||
|
||||
@ -669,7 +669,7 @@ void IntegrationPluginHuawei::evaluateEnergyProducedValue(Thing *inverterThing,
|
||||
|
||||
int historyMaxSize = 3;
|
||||
int absurdlyHighValueLimit= 25000000;
|
||||
int historySize = m_inverterEnergyProducedHistory.value(inverterThing).count();
|
||||
int historySize = m_inverterEnergyProducedHistory.value(inverterThing).length();
|
||||
|
||||
if (historySize > historyMaxSize) {
|
||||
m_inverterEnergyProducedHistory[inverterThing].removeFirst();
|
||||
|
||||
@ -51,7 +51,7 @@ void IntegrationPluginIdm::discoverThings(ThingDiscoveryInfo *info)
|
||||
NetworkDeviceDiscoveryReply *discoveryReply = hardwareManager()->networkDeviceDiscovery()->discover();
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [this, discoveryReply, info](){
|
||||
qCDebug(dcIdm()) << "Discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "devices";
|
||||
qCDebug(dcIdm()) << "Discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "devices";
|
||||
foreach (const NetworkDeviceInfo &networkDeviceInfo, discoveryReply->networkDeviceInfos()) {
|
||||
qCDebug(dcIdm()) << networkDeviceInfo;
|
||||
QString title;
|
||||
|
||||
@ -53,7 +53,7 @@ void IntegrationPluginInro::discoverThings(ThingDiscoveryInfo *info)
|
||||
|
||||
// Check if we already have set up this device
|
||||
Things existingThings = myThings().filterByParam(pantaboxThingSerialNumberParamTypeId, result.deviceInfo.serialNumber);
|
||||
if (existingThings.count() == 1) {
|
||||
if (existingThings.length() == 1) {
|
||||
qCDebug(dcInro()) << "This PANTABOX already exists in the system:" << result.deviceInfo.serialNumber << result.deviceInfo.ipAddress.toString();
|
||||
descriptor.setThingId(existingThings.first()->id());
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ void PantaboxDiscovery::finishDiscovery()
|
||||
foreach (Pantabox *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcInro()) << "Discovery: Finished the discovery process. Found" << m_results.count()
|
||||
qCInfo(dcInro()) << "Discovery: Finished the discovery process. Found" << m_results.length()
|
||||
<< "PANTABOXE wallboxes in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
|
||||
emit discoveryFinished();
|
||||
|
||||
@ -72,7 +72,7 @@ void IntegrationPluginKostal::discoverThings(ThingDiscoveryInfo *info)
|
||||
|
||||
// Note: we introduced the serial number later, if the current thing has no serialnumber, we use the mac
|
||||
Things existingThings = myThings().filterByParam(kostalInverterThingSerialNumberParamTypeId, result.serialNumber);
|
||||
if (existingThings.count() == 1) {
|
||||
if (existingThings.length() == 1) {
|
||||
qCDebug(dcKostal()) << "This Kostal inverter with this serial number already exists in the system:" << result.networkDeviceInfo;
|
||||
descriptor.setThingId(existingThings.first()->id());
|
||||
}
|
||||
@ -422,7 +422,7 @@ void IntegrationPluginKostal::setupKostalConnection(ThingSetupInfo *info)
|
||||
|
||||
// Update the battery if available
|
||||
Things batteryThings = myThings().filterByParentId(thing->id()).filterByThingClassId(kostalBatteryThingClassId);
|
||||
if (batteryThings.count() == 1) {
|
||||
if (batteryThings.length() == 1) {
|
||||
Thing *batteryThing = batteryThings.first();
|
||||
|
||||
batteryThing->setStateValue(kostalBatteryVoltageStateTypeId, kostalConnection->batteryVoltage());
|
||||
@ -446,7 +446,7 @@ void IntegrationPluginKostal::setupKostalConnection(ThingSetupInfo *info)
|
||||
|
||||
// Update the meter if available
|
||||
Things meterThings = myThings().filterByParentId(thing->id()).filterByThingClassId(kostalMeterThingClassId);
|
||||
if (meterThings.count() == 1) {
|
||||
if (meterThings.length() == 1) {
|
||||
Thing *meterThing = meterThings.first();
|
||||
|
||||
// Power
|
||||
|
||||
@ -52,7 +52,7 @@ void KostalDiscovery::startDiscovery()
|
||||
// Check what might be left on finished
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
||||
qCDebug(dcKostal()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "network devices";
|
||||
qCDebug(dcKostal()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "network devices";
|
||||
m_networkDeviceInfos = discoveryReply->networkDeviceInfos();
|
||||
|
||||
// Give the last connections added right before the network discovery finished a chance to check the device...
|
||||
@ -152,14 +152,14 @@ void KostalDiscovery::finishDiscovery()
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
// Fill in all network device infos we have
|
||||
for (int i = 0; i < m_discoveryResults.count(); i++)
|
||||
for (int i = 0; i < m_discoveryResults.length(); i++)
|
||||
m_discoveryResults[i].networkDeviceInfo = m_networkDeviceInfos.get(m_discoveryResults.at(i).address);
|
||||
|
||||
// Cleanup any leftovers...we don't care any more
|
||||
foreach (KostalModbusTcpConnection *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcKostal()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.count()
|
||||
qCInfo(dcKostal()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.length()
|
||||
<< "Kostal Inverters in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
emit discoveryFinished();
|
||||
}
|
||||
|
||||
@ -1,8 +1,21 @@
|
||||
QMAKE_CXXFLAGS += -Werror -std=c++11 -z defs
|
||||
QMAKE_LFLAGS += -std=c++11 -z defs
|
||||
|
||||
QT += network serialbus
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5) {
|
||||
message("Building using Qt6 support")
|
||||
CONFIG *= c++17
|
||||
QMAKE_LFLAGS *= -std=c++17
|
||||
QMAKE_CXXFLAGS *= -std=c++17
|
||||
} else {
|
||||
message("Building using Qt5 support")
|
||||
CONFIG *= c++11
|
||||
QMAKE_LFLAGS *= -std=c++11
|
||||
QMAKE_CXXFLAGS *= -std=c++11
|
||||
DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x050F00
|
||||
}
|
||||
|
||||
QMAKE_CXXFLAGS += -Werror -z defs
|
||||
QMAKE_LFLAGS += -z defs
|
||||
|
||||
CONFIG += link_pkgconfig
|
||||
PKGCONFIG += nymea
|
||||
|
||||
|
||||
@ -54,3 +54,15 @@ for(MODBUS_CONNECTION, MODBUS_CONNECTIONS_INCLUDES) {
|
||||
INCLUDEPATH += $${OUT_PWD}/autogenerated
|
||||
}
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5) {
|
||||
message("Building using Qt6 support")
|
||||
CONFIG *= c++17
|
||||
QMAKE_LFLAGS *= -std=c++17
|
||||
QMAKE_CXXFLAGS *= -std=c++17
|
||||
} else {
|
||||
message("Building using Qt5 support")
|
||||
CONFIG *= c++11
|
||||
QMAKE_LFLAGS *= -std=c++11
|
||||
QMAKE_CXXFLAGS *= -std=c++11
|
||||
DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x050F00
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2021, nymea GmbH
|
||||
* Copyright 2013 - 2025, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
@ -39,21 +39,25 @@ ModbusDataUtils::ModbusDataUtils()
|
||||
|
||||
quint16 ModbusDataUtils::convertToUInt16(const QVector<quint16> ®isters)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 1, "ModbusDataUtils", "invalid raw data size for converting value to quint16");
|
||||
Q_ASSERT_X(registers.length() == 1, "ModbusDataUtils", "invalid raw data size for converting value to quint16");
|
||||
return registers.at(0);
|
||||
}
|
||||
|
||||
qint16 ModbusDataUtils::convertToInt16(const QVector<quint16> ®isters)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 1, "ModbusDataUtils", "invalid raw data size for converting value to qint16");
|
||||
Q_ASSERT_X(registers.length() == 1, "ModbusDataUtils", "invalid raw data size for converting value to qint16");
|
||||
return static_cast<qint16>(registers.at(0));
|
||||
}
|
||||
|
||||
quint32 ModbusDataUtils::convertToUInt32(const QVector<quint16> ®isters, ByteOrder byteOrder)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 2, "ModbusDataUtils", "invalid raw data size for converting value to quint32");
|
||||
Q_ASSERT_X(registers.length() == 2, "ModbusDataUtils", "invalid raw data size for converting value to quint32");
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
if (byteOrder == ByteOrderBigEndian) {
|
||||
inputStream << registers.at(0);
|
||||
inputStream << registers.at(1);
|
||||
@ -62,7 +66,11 @@ quint32 ModbusDataUtils::convertToUInt32(const QVector<quint16> ®isters, Byte
|
||||
inputStream << registers.at(0);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
quint32 result = 0;
|
||||
outputStream >> result;
|
||||
return result;
|
||||
@ -70,9 +78,13 @@ quint32 ModbusDataUtils::convertToUInt32(const QVector<quint16> ®isters, Byte
|
||||
|
||||
qint32 ModbusDataUtils::convertToInt32(const QVector<quint16> ®isters, ByteOrder byteOrder)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 2, "ModbusDataUtils", "invalid raw data size for converting value to quint32");
|
||||
Q_ASSERT_X(registers.length() == 2, "ModbusDataUtils", "invalid raw data size for converting value to quint32");
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
if (byteOrder == ByteOrderBigEndian) {
|
||||
inputStream << registers.at(0);
|
||||
inputStream << registers.at(1);
|
||||
@ -81,7 +93,11 @@ qint32 ModbusDataUtils::convertToInt32(const QVector<quint16> ®isters, ByteOr
|
||||
inputStream << registers.at(0);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
qint32 result = 0;
|
||||
outputStream >> result;
|
||||
return result;
|
||||
@ -89,9 +105,13 @@ qint32 ModbusDataUtils::convertToInt32(const QVector<quint16> ®isters, ByteOr
|
||||
|
||||
quint64 ModbusDataUtils::convertToUInt64(const QVector<quint16> ®isters, ByteOrder byteOrder)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 4, "ModbusDataUtils", "invalid raw data size for converting value to quint64");
|
||||
Q_ASSERT_X(registers.length() == 4, "ModbusDataUtils", "invalid raw data size for converting value to quint64");
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
if (byteOrder == ByteOrderBigEndian) {
|
||||
inputStream << registers.at(0);
|
||||
inputStream << registers.at(1);
|
||||
@ -104,7 +124,11 @@ quint64 ModbusDataUtils::convertToUInt64(const QVector<quint16> ®isters, Byte
|
||||
inputStream << registers.at(0);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
quint64 result = 0;
|
||||
outputStream >> result;
|
||||
return result;
|
||||
@ -112,9 +136,13 @@ quint64 ModbusDataUtils::convertToUInt64(const QVector<quint16> ®isters, Byte
|
||||
|
||||
qint64 ModbusDataUtils::convertToInt64(const QVector<quint16> ®isters, ByteOrder byteOrder)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 4, "ModbusDataUtils", "invalid raw data size for converting value to qint64");
|
||||
Q_ASSERT_X(registers.length() == 4, "ModbusDataUtils", "invalid raw data size for converting value to qint64");
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
if (byteOrder == ByteOrderBigEndian) {
|
||||
inputStream << registers.at(0);
|
||||
inputStream << registers.at(1);
|
||||
@ -127,7 +155,12 @@ qint64 ModbusDataUtils::convertToInt64(const QVector<quint16> ®isters, ByteOr
|
||||
inputStream << registers.at(0);
|
||||
}
|
||||
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
qint64 result = 0;
|
||||
outputStream >> result;
|
||||
return result;
|
||||
@ -136,10 +169,14 @@ qint64 ModbusDataUtils::convertToInt64(const QVector<quint16> ®isters, ByteOr
|
||||
QString ModbusDataUtils::convertToString(const QVector<quint16> ®isters, ByteOrder characterByteOrder)
|
||||
{
|
||||
QByteArray bytes;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream stream(&bytes, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
#endif
|
||||
// Note: some devices use little endian within the register uint16 representation of the 2 characters.
|
||||
stream.setByteOrder(characterByteOrder == ByteOrderBigEndian ? QDataStream::BigEndian : QDataStream::LittleEndian);
|
||||
for (int i = 0; i < registers.count(); i++) {
|
||||
for (int i = 0; i < registers.length(); i++) {
|
||||
stream << registers.at(i);
|
||||
}
|
||||
|
||||
@ -149,8 +186,12 @@ QString ModbusDataUtils::convertToString(const QVector<quint16> ®isters, Byte
|
||||
QByteArray ModbusDataUtils::convertToByteArray(const QVector<quint16> ®isters)
|
||||
{
|
||||
QByteArray bytes;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream stream(&bytes, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
for (int i = 0; i < registers.count(); i++) {
|
||||
#endif
|
||||
for (int i = 0; i < registers.length(); i++) {
|
||||
stream << registers.at(i);
|
||||
}
|
||||
return bytes;
|
||||
@ -158,7 +199,7 @@ QByteArray ModbusDataUtils::convertToByteArray(const QVector<quint16> ®isters
|
||||
|
||||
float ModbusDataUtils::convertToFloat32(const QVector<quint16> ®isters, ByteOrder byteOrder)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 2, "ModbusDataUtils", "invalid raw data size for converting value to float32");
|
||||
Q_ASSERT_X(registers.length() == 2, "ModbusDataUtils", "invalid raw data size for converting value to float32");
|
||||
quint32 rawValue = ModbusDataUtils::convertToUInt32(registers, byteOrder);
|
||||
float value = 0;
|
||||
memcpy(&value, &rawValue, sizeof(quint32));
|
||||
@ -168,7 +209,7 @@ float ModbusDataUtils::convertToFloat32(const QVector<quint16> ®isters, ByteO
|
||||
double ModbusDataUtils::convertToFloat64(const QVector<quint16> ®isters, ByteOrder byteOrder)
|
||||
{
|
||||
|
||||
Q_ASSERT_X(registers.count() == 4, "ModbusDataUtils", "invalid raw data size for converting value to float64");
|
||||
Q_ASSERT_X(registers.length() == 4, "ModbusDataUtils", "invalid raw data size for converting value to float64");
|
||||
quint64 rawValue = ModbusDataUtils::convertToUInt64(registers, byteOrder);
|
||||
double value = 0;
|
||||
memcpy(&value, &rawValue, sizeof(quint64));
|
||||
@ -188,10 +229,18 @@ QVector<quint16> ModbusDataUtils::convertFromInt16(qint16 value)
|
||||
QVector<quint16> ModbusDataUtils::convertFromUInt32(quint32 value, ByteOrder byteOrder)
|
||||
{
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
inputStream << value;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
QVector<quint16> values;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
quint16 registerValue = 0;
|
||||
@ -214,10 +263,18 @@ QVector<quint16> ModbusDataUtils::convertFromInt32(qint32 value, ByteOrder byteO
|
||||
QVector<quint16> ModbusDataUtils::convertFromUInt64(quint64 value, ByteOrder byteOrder)
|
||||
{
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
inputStream << value;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
QVector<quint16> values;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
quint16 registerValue = 0;
|
||||
@ -234,10 +291,18 @@ QVector<quint16> ModbusDataUtils::convertFromUInt64(quint64 value, ByteOrder byt
|
||||
QVector<quint16> ModbusDataUtils::convertFromInt64(qint64 value, ByteOrder byteOrder)
|
||||
{
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
inputStream << value;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
QVector<quint16> values;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
quint16 registerValue = 0;
|
||||
@ -254,8 +319,12 @@ QVector<quint16> ModbusDataUtils::convertFromInt64(qint64 value, ByteOrder byteO
|
||||
QVector<quint16> ModbusDataUtils::convertFromString(const QString &value, quint16 stringLength, ByteOrder characterByteOrder)
|
||||
{
|
||||
Q_ASSERT_X(value.length() <= stringLength, "ModbusDataUtils", "cannot convert a string which is bigger than the desired register vector.");
|
||||
QByteArray data = value.toLatin1() + QByteArray('\0', stringLength - value.count());
|
||||
QByteArray data = value.toLatin1() + QByteArray('\0', stringLength - value.length());
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream stream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream stream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
// Note: some devices use little endian within the register uint16 representation of the 2 characters.
|
||||
stream.setByteOrder(characterByteOrder == ByteOrderBigEndian ? QDataStream::BigEndian : QDataStream::LittleEndian);
|
||||
QVector<quint16> values;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2021, nymea GmbH
|
||||
* Copyright 2013 - 2025, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
@ -34,6 +34,7 @@
|
||||
#include <QVector>
|
||||
#include <QObject>
|
||||
#include <QModbusPdu>
|
||||
#include <QMetaObject>
|
||||
#include <QModbusDataUnit>
|
||||
|
||||
class ModbusDataUtils
|
||||
|
||||
@ -44,7 +44,7 @@ ModbusTcpMaster::ModbusTcpMaster(const QHostAddress &hostAddress, uint port, QOb
|
||||
m_modbusTcpClient->setNumberOfRetries(m_numberOfRetries);
|
||||
|
||||
connect(m_modbusTcpClient, &QModbusTcpClient::stateChanged, this, &ModbusTcpMaster::onModbusStateChanged);
|
||||
connect(m_modbusTcpClient, &QModbusRtuSerialMaster::errorOccurred, this, &ModbusTcpMaster::onModbusErrorOccurred);
|
||||
connect(m_modbusTcpClient, &QModbusTcpClient::errorOccurred, this, &ModbusTcpMaster::onModbusErrorOccurred);
|
||||
|
||||
m_reconnectTimer = new QTimer(this);
|
||||
m_reconnectTimer->setSingleShot(true);
|
||||
|
||||
@ -80,9 +80,9 @@ def writePropertyGetSetDataUnitImplementationsTcp(fileDescriptor, className, reg
|
||||
|
||||
writeLine(fileDescriptor, ' QVector<quint16> values = %s;' % getConversionToValueMethod(registerDefinition))
|
||||
if registerDefinition['registerType'] == 'holdingRegister':
|
||||
writeLine(fileDescriptor, ' QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, %s, values.count());' % (registerDefinition['address']))
|
||||
writeLine(fileDescriptor, ' QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, %s, values.length());' % (registerDefinition['address']))
|
||||
elif registerDefinition['registerType'] == 'coils':
|
||||
writeLine(fileDescriptor, ' QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::Coils, %s, values.count());' % (registerDefinition['address']))
|
||||
writeLine(fileDescriptor, ' QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::Coils, %s, values.length());' % (registerDefinition['address']))
|
||||
else:
|
||||
logger.warning('Error: invalid register type for writing.')
|
||||
exit(1)
|
||||
@ -831,7 +831,7 @@ def writeUpdateMethodTcp(fileDescriptor, className, registerDefinitions, blockDe
|
||||
writeLine(fileDescriptor)
|
||||
|
||||
writeLine(fileDescriptor, ' if (!m_updateRequestQueue.isEmpty()) {')
|
||||
writeLine(fileDescriptor, ' qCDebug(dc%s()) << "Tried to update but there are still some update requests pending. Waiting for them to be finished..." << m_updateRequestQueue.count();' % className)
|
||||
writeLine(fileDescriptor, ' qCDebug(dc%s()) << "Tried to update but there are still some update requests pending. Waiting for them to be finished..." << m_updateRequestQueue.length();' % className)
|
||||
writeLine(fileDescriptor, ' sendNextQueuedRequest();')
|
||||
writeLine(fileDescriptor, ' return true;')
|
||||
writeLine(fileDescriptor, ' }')
|
||||
|
||||
@ -1,8 +1,20 @@
|
||||
QMAKE_CXXFLAGS += -Werror -std=c++11 -z defs
|
||||
QMAKE_LFLAGS += -std=c++11
|
||||
|
||||
QT += network serialbus
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5) {
|
||||
message("Building using Qt6 support")
|
||||
CONFIG *= c++17
|
||||
QMAKE_LFLAGS *= -std=c++17
|
||||
QMAKE_CXXFLAGS *= -std=c++17
|
||||
} else {
|
||||
message("Building using Qt5 support")
|
||||
CONFIG *= c++11
|
||||
QMAKE_LFLAGS *= -std=c++11
|
||||
QMAKE_CXXFLAGS *= -std=c++11
|
||||
DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x050F00
|
||||
}
|
||||
|
||||
QMAKE_CXXFLAGS += -Werror -z defs
|
||||
|
||||
TARGET = nymea-sunspec1
|
||||
TEMPLATE = lib
|
||||
|
||||
|
||||
@ -313,7 +313,7 @@ void SunSpecConnection::processDiscoveryResult()
|
||||
qCDebug(dcSunSpec()) << "Sorted model list:";
|
||||
SunSpecCommonModel *currentCommonModel = nullptr;
|
||||
SunSpecModel::CommonModelInfo commonModelInfo;
|
||||
for (int i = 0; i < m_models.count(); i++) {
|
||||
for (int i = 0; i < m_models.length(); i++) {
|
||||
SunSpecModel *model = m_models.at(i);
|
||||
qCDebug(dcSunSpec()) << "-->" << model;
|
||||
if (model->modelId() == SunSpecModelFactory::ModelIdCommon) {
|
||||
@ -467,7 +467,7 @@ void SunSpecConnection::scanModelsOnBaseRegister(quint16 offset)
|
||||
} else {
|
||||
qCWarning(dcSunSpec()) << "Error occurred while reading model header from" << this << "using offset" << offset << m_modbusTcpClient->errorString();
|
||||
if (!m_modelDiscoveryResult.isEmpty()) {
|
||||
qCWarning(dcSunSpec()) << "Error occurred but already discovered" << m_modelDiscoveryResult.count() << "models. Continue with the discovered models, but the discovery may be incomplete due to header reading errors.";
|
||||
qCWarning(dcSunSpec()) << "Error occurred but already discovered" << m_modelDiscoveryResult.length() << "models. Continue with the discovered models, but the discovery may be incomplete due to header reading errors.";
|
||||
qCDebug(dcSunSpec()) << "Scan for SunSpec models on" << this << m_baseRegister << "finished successfully";
|
||||
processDiscoveryResult();
|
||||
} else {
|
||||
|
||||
@ -261,7 +261,7 @@ bool SunSpecDataPoint::isValid() const
|
||||
break;
|
||||
case DataType::String: {
|
||||
bool isNull = true;
|
||||
for (int i = 0; i < m_rawData.count(); i++) {
|
||||
for (int i = 0; i < m_rawData.length(); i++) {
|
||||
if (m_rawData.at(i) != 0x0000) {
|
||||
isNull = false;
|
||||
valid = true;
|
||||
@ -416,7 +416,7 @@ double SunSpecDataPoint::toDouble() const
|
||||
QString SunSpecDataPoint::registersToString(const QVector<quint16> ®isters)
|
||||
{
|
||||
QStringList valueStrings;
|
||||
for (int i = 0; i < registers.count(); i++) {
|
||||
for (int i = 0; i < registers.length(); i++) {
|
||||
QString hexString(QStringLiteral("0x%1"));
|
||||
valueStrings.append(hexString.arg(registers.at(i), 4, 16, QLatin1Char('0')));
|
||||
}
|
||||
@ -427,21 +427,25 @@ QString SunSpecDataPoint::registersToString(const QVector<quint16> ®isters)
|
||||
|
||||
quint16 SunSpecDataPoint::convertToUInt16(const QVector<quint16> ®isters)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 1, "SunSpecDataPoint", "invalid raw data size for converting value to quint16");
|
||||
Q_ASSERT_X(registers.length() == 1, "SunSpecDataPoint", "invalid raw data size for converting value to quint16");
|
||||
return registers.at(0);
|
||||
}
|
||||
|
||||
qint16 SunSpecDataPoint::convertToInt16(const QVector<quint16> ®isters)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 1, "SunSpecDataPoint", "invalid raw data size for converting value to qint16");
|
||||
Q_ASSERT_X(registers.length() == 1, "SunSpecDataPoint", "invalid raw data size for converting value to qint16");
|
||||
return static_cast<qint16>(registers.at(0));
|
||||
}
|
||||
|
||||
quint32 SunSpecDataPoint::convertToUInt32(const QVector<quint16> ®isters, ByteOrder byteOrder)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 2, "SunSpecDataPoint", "invalid raw data size for converting value to quint32");
|
||||
Q_ASSERT_X(registers.length() == 2, "SunSpecDataPoint", "invalid raw data size for converting value to quint32");
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
if (byteOrder == ByteOrderBigEndian) {
|
||||
inputStream << registers.at(0);
|
||||
inputStream << registers.at(1);
|
||||
@ -450,7 +454,11 @@ quint32 SunSpecDataPoint::convertToUInt32(const QVector<quint16> ®isters, Byt
|
||||
inputStream << registers.at(0);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
quint32 result = 0;
|
||||
outputStream >> result;
|
||||
return result;
|
||||
@ -458,9 +466,13 @@ quint32 SunSpecDataPoint::convertToUInt32(const QVector<quint16> ®isters, Byt
|
||||
|
||||
qint32 SunSpecDataPoint::convertToInt32(const QVector<quint16> ®isters, ByteOrder byteOrder)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 2, "SunSpecDataPoint", "invalid raw data size for converting value to quint32");
|
||||
Q_ASSERT_X(registers.length() == 2, "SunSpecDataPoint", "invalid raw data size for converting value to quint32");
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
if (byteOrder == ByteOrderBigEndian) {
|
||||
inputStream << registers.at(0);
|
||||
inputStream << registers.at(1);
|
||||
@ -469,7 +481,11 @@ qint32 SunSpecDataPoint::convertToInt32(const QVector<quint16> ®isters, ByteO
|
||||
inputStream << registers.at(0);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
qint32 result = 0;
|
||||
outputStream >> result;
|
||||
return result;
|
||||
@ -477,9 +493,13 @@ qint32 SunSpecDataPoint::convertToInt32(const QVector<quint16> ®isters, ByteO
|
||||
|
||||
quint64 SunSpecDataPoint::convertToUInt64(const QVector<quint16> ®isters, ByteOrder byteOrder)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 4, "SunSpecDataPoint", "invalid raw data size for converting value to quint64");
|
||||
Q_ASSERT_X(registers.length() == 4, "SunSpecDataPoint", "invalid raw data size for converting value to quint64");
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
if (byteOrder == ByteOrderBigEndian) {
|
||||
inputStream << registers.at(0);
|
||||
inputStream << registers.at(1);
|
||||
@ -492,7 +512,11 @@ quint64 SunSpecDataPoint::convertToUInt64(const QVector<quint16> ®isters, Byt
|
||||
inputStream << registers.at(0);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
quint64 result = 0;
|
||||
outputStream >> result;
|
||||
return result;
|
||||
@ -500,9 +524,13 @@ quint64 SunSpecDataPoint::convertToUInt64(const QVector<quint16> ®isters, Byt
|
||||
|
||||
qint64 SunSpecDataPoint::convertToInt64(const QVector<quint16> ®isters, ByteOrder byteOrder)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 4, "SunSpecDataPoint", "invalid raw data size for converting value to qint64");
|
||||
Q_ASSERT_X(registers.length() == 4, "SunSpecDataPoint", "invalid raw data size for converting value to qint64");
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
if (byteOrder == ByteOrderBigEndian) {
|
||||
inputStream << registers.at(0);
|
||||
inputStream << registers.at(1);
|
||||
@ -515,7 +543,11 @@ qint64 SunSpecDataPoint::convertToInt64(const QVector<quint16> ®isters, ByteO
|
||||
inputStream << registers.at(0);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
qint64 result = 0;
|
||||
outputStream >> result;
|
||||
return result;
|
||||
@ -524,8 +556,12 @@ qint64 SunSpecDataPoint::convertToInt64(const QVector<quint16> ®isters, ByteO
|
||||
QString SunSpecDataPoint::convertToString(const QVector<quint16> ®isters)
|
||||
{
|
||||
QByteArray bytes;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream stream(&bytes, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
for (int i = 0; i < registers.count(); i++) {
|
||||
#endif
|
||||
for (int i = 0; i < registers.length(); i++) {
|
||||
stream << registers.at(i);
|
||||
}
|
||||
|
||||
@ -534,7 +570,7 @@ QString SunSpecDataPoint::convertToString(const QVector<quint16> ®isters)
|
||||
|
||||
float SunSpecDataPoint::convertToFloat32(const QVector<quint16> ®isters, ByteOrder byteOrder)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 2, "SunSpecDataPoint", "invalid raw data size for converting value to float32");
|
||||
Q_ASSERT_X(registers.length() == 2, "SunSpecDataPoint", "invalid raw data size for converting value to float32");
|
||||
quint32 rawValue = SunSpecDataPoint::convertToUInt32(registers, byteOrder);
|
||||
float value = 0;
|
||||
memcpy(&value, &rawValue, sizeof(quint32));
|
||||
@ -543,7 +579,7 @@ float SunSpecDataPoint::convertToFloat32(const QVector<quint16> ®isters, Byte
|
||||
|
||||
double SunSpecDataPoint::convertToFloat64(const QVector<quint16> ®isters, ByteOrder byteOrder)
|
||||
{
|
||||
Q_ASSERT_X(registers.count() == 4, "SunSpecDataPoint", "invalid raw data size for converting value to float64");
|
||||
Q_ASSERT_X(registers.length() == 4, "SunSpecDataPoint", "invalid raw data size for converting value to float64");
|
||||
quint64 rawValue = SunSpecDataPoint::convertToUInt64(registers, byteOrder);
|
||||
double value = 0;
|
||||
memcpy(&value, &rawValue, sizeof(quint64));
|
||||
@ -563,10 +599,18 @@ QVector<quint16> SunSpecDataPoint::convertFromInt16(qint16 value)
|
||||
QVector<quint16> SunSpecDataPoint::convertFromUInt32(quint32 value, ByteOrder byteOrder)
|
||||
{
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
inputStream << value;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
QVector<quint16> values;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
quint16 registerValue = 0;
|
||||
@ -588,10 +632,18 @@ QVector<quint16> SunSpecDataPoint::convertFromInt32(qint32 value, ByteOrder byte
|
||||
QVector<quint16> SunSpecDataPoint::convertFromUInt64(quint64 value, ByteOrder byteOrder)
|
||||
{
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
inputStream << value;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
QVector<quint16> values;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
quint16 registerValue = 0;
|
||||
@ -608,10 +660,18 @@ QVector<quint16> SunSpecDataPoint::convertFromUInt64(quint64 value, ByteOrder by
|
||||
QVector<quint16> SunSpecDataPoint::convertFromInt64(qint64 value, ByteOrder byteOrder)
|
||||
{
|
||||
QByteArray data;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream inputStream(&data, QDataStream::WriteOnly);
|
||||
#else
|
||||
QDataStream inputStream(&data, QIODevice::WriteOnly);
|
||||
#endif
|
||||
inputStream << value;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream outputStream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream outputStream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
QVector<quint16> values;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
quint16 registerValue = 0;
|
||||
@ -628,8 +688,12 @@ QVector<quint16> SunSpecDataPoint::convertFromInt64(qint64 value, ByteOrder byte
|
||||
QVector<quint16> SunSpecDataPoint::convertFromString(const QString &value, quint16 stringLength)
|
||||
{
|
||||
Q_ASSERT_X(value.length() <= stringLength, "SunSpecDataPoint", "cannot convert a string which is bigger than the desired register vector.");
|
||||
QByteArray data = value.toLatin1() + QByteArray('\0', stringLength - value.count());
|
||||
QByteArray data = value.toLatin1() + QByteArray('\0', stringLength - value.length());
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream stream(&data, QDataStream::ReadOnly);
|
||||
#else
|
||||
QDataStream stream(&data, QIODevice::ReadOnly);
|
||||
#endif
|
||||
QVector<quint16> values;
|
||||
for (int i = 0; i < stringLength; i++) {
|
||||
quint16 registerValue = 0;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2020, nymea GmbH
|
||||
* Copyright 2013 - 2025, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
@ -31,9 +31,10 @@
|
||||
#ifndef SUNSPECDATAPOINT_H
|
||||
#define SUNSPECDATAPOINT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QMetaObject>
|
||||
|
||||
class SunSpecDataPoint
|
||||
{
|
||||
|
||||
@ -126,12 +126,12 @@ void SunSpecModel::readBlockData()
|
||||
}
|
||||
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
qCDebug(dcSunSpecModelData()) << "-->" << "Received block data" << this << unit.values().count() << SunSpecDataPoint::registersToString(unit.values());
|
||||
qCDebug(dcSunSpecModelData()) << "-->" << "Received block data" << this << unit.values().length() << SunSpecDataPoint::registersToString(unit.values());
|
||||
m_blockData = unit.values();
|
||||
emit blockDataChanged(m_blockData);
|
||||
|
||||
if (m_blockData.count() != m_modelLength + 2) {
|
||||
qCWarning(dcSunSpecModelData()) << "Received invalid block data count from read block data request. Model lenght:" << m_modelLength << "Response block count:" << m_blockData.count();
|
||||
if (m_blockData.length() != m_modelLength + 2) {
|
||||
qCWarning(dcSunSpecModelData()) << "Received invalid block data count from read block data request. Model lenght:" << m_modelLength << "Response block count:" << m_blockData.length();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2023, nymea GmbH
|
||||
* Copyright 2013 - 2025, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
@ -33,6 +33,8 @@
|
||||
|
||||
#include <modbusdatautils.h>
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
QList<int> slaveIdCandidates = {50, 11, 12, 13, 14};
|
||||
|
||||
AmtronCompact20Discovery::AmtronCompact20Discovery(ModbusRtuHardwareResource *modbusRtuResource, QObject *parent):
|
||||
@ -83,7 +85,7 @@ void AmtronCompact20Discovery::tryConnect(ModbusRtuMaster *master, quint16 slave
|
||||
|
||||
if (reply->error() == ModbusRtuReply::NoError) {
|
||||
|
||||
QString serialNumber = ModbusDataUtils::convertToString(reply->result(), ModbusDataUtils::ByteOrderBigEndian).remove(QRegExp("^_*"));
|
||||
QString serialNumber = ModbusDataUtils::convertToString(reply->result(), ModbusDataUtils::ByteOrderBigEndian).remove(QRegularExpression("^_*"));
|
||||
qCDebug(dcMennekes()) << "Test reply finished!" << reply->error() << serialNumber;
|
||||
|
||||
Result result {master->modbusUuid(), serialNumber, slaveId};
|
||||
@ -91,7 +93,7 @@ void AmtronCompact20Discovery::tryConnect(ModbusRtuMaster *master, quint16 slave
|
||||
|
||||
}
|
||||
|
||||
if (slaveIdIndex < slaveIdCandidates.count() - 1) {
|
||||
if (slaveIdIndex < slaveIdCandidates.length() - 1) {
|
||||
tryConnect(master, slaveIdIndex+1);
|
||||
} else {
|
||||
emit discoveryFinished(true);
|
||||
|
||||
@ -53,7 +53,7 @@ void AmtronECUDiscovery::startDiscovery()
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::hostAddressDiscovered, this, &AmtronECUDiscovery::checkNetworkDevice);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
||||
qCDebug(dcMennekes()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "network devices";
|
||||
qCDebug(dcMennekes()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "network devices";
|
||||
m_networkDeviceInfos = discoveryReply->networkDeviceInfos();
|
||||
m_gracePeriodTimer.start();
|
||||
});
|
||||
@ -142,14 +142,14 @@ void AmtronECUDiscovery::finishDiscovery()
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
// Fill in all network device infos we have
|
||||
for (int i = 0; i < m_discoveryResults.count(); i++)
|
||||
for (int i = 0; i < m_discoveryResults.length(); i++)
|
||||
m_discoveryResults[i].networkDeviceInfo = m_networkDeviceInfos.get(m_discoveryResults.at(i).address);
|
||||
|
||||
// Cleanup any leftovers...we don't care any more
|
||||
foreach (AmtronECU *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcMennekes()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.count()
|
||||
qCInfo(dcMennekes()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.length()
|
||||
<< "AMTRON ECU wallboxes in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
m_gracePeriodTimer.stop();
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2024, nymea GmbH
|
||||
* Copyright 2013 - 2025, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
@ -51,7 +51,7 @@ void AmtronHCC3Discovery::startDiscovery()
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::hostAddressDiscovered, this, &AmtronHCC3Discovery::checkNetworkDevice);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
||||
qCDebug(dcMennekes()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "network devices";
|
||||
qCDebug(dcMennekes()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "network devices";
|
||||
m_networkDeviceInfos = discoveryReply->networkDeviceInfos();
|
||||
m_gracePeriodTimer.start();
|
||||
});
|
||||
@ -93,7 +93,7 @@ void AmtronHCC3Discovery::checkNetworkDevice(const QHostAddress &address)
|
||||
|
||||
AmtronDiscoveryResult result;
|
||||
result.wallboxName = connection->name();
|
||||
result.serialNumber = connection->serialNumber();
|
||||
result.serialNumber = QString::number(connection->serialNumber());
|
||||
result.address = address;
|
||||
m_discoveryResults.append(result);
|
||||
|
||||
@ -133,14 +133,14 @@ void AmtronHCC3Discovery::finishDiscovery()
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
// Fill in all network device infos we have
|
||||
for (int i = 0; i < m_discoveryResults.count(); i++)
|
||||
for (int i = 0; i < m_discoveryResults.length(); i++)
|
||||
m_discoveryResults[i].networkDeviceInfo = m_networkDeviceInfos.get(m_discoveryResults.at(i).address);
|
||||
|
||||
// Cleanup any leftovers...we don't care any more
|
||||
foreach (AmtronHCC3ModbusTcpConnection *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcMennekes()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.count()
|
||||
qCInfo(dcMennekes()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.length()
|
||||
<< "AMTRON HCC3 wallboxes in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
m_gracePeriodTimer.stop();
|
||||
|
||||
|
||||
@ -148,7 +148,7 @@ void IntegrationPluginMennekes::discoverThings(ThingDiscoveryInfo *info)
|
||||
return;
|
||||
}
|
||||
|
||||
qCInfo(dcMennekes()) << "Discovery results:" << discovery->discoveryResults().count();
|
||||
qCInfo(dcMennekes()) << "Discovery results:" << discovery->discoveryResults().length();
|
||||
|
||||
foreach (const AmtronCompact20Discovery::Result &result, discovery->discoveryResults()) {
|
||||
ThingDescriptor descriptor(amtronCompact20ThingClassId, "AMTRON Compact 2.0s", QString("Slave ID: %1, Serial: %2").arg(result.slaveId).arg(result.serialNumber));
|
||||
|
||||
@ -119,7 +119,7 @@ void IntegrationPluginModbusCommander::discoverThings(ThingDiscoveryInfo *info)
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
||||
ThingDescriptors descriptors;
|
||||
qCDebug(dcModbusCommander()) << "Discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "devices";
|
||||
qCDebug(dcModbusCommander()) << "Discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "devices";
|
||||
foreach (const NetworkDeviceInfo &networkDeviceInfo, discoveryReply->networkDeviceInfos()) {
|
||||
qCDebug(dcModbusCommander()) << networkDeviceInfo;
|
||||
QString title;
|
||||
@ -145,7 +145,7 @@ void IntegrationPluginModbusCommander::discoverThings(ThingDiscoveryInfo *info)
|
||||
|
||||
// Check if we already have set up this device
|
||||
Things existingThings = myThings().filterByParam(modbusTCPClientThingIpAddressParamTypeId, networkDeviceInfo.address().toString());
|
||||
if (existingThings.count() == 1) {
|
||||
if (existingThings.length() == 1) {
|
||||
qCDebug(dcModbusCommander()) << "This thing already exists in the system." << existingThings.first() << networkDeviceInfo;
|
||||
descriptor.setThingId(existingThings.first()->id());
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2022, nymea GmbH
|
||||
* Copyright 2013 - 2025, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
@ -34,11 +34,16 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <QSerialPort>
|
||||
#include <QHostAddress>
|
||||
#include <QSerialPortInfo>
|
||||
#include <QModbusTcpClient>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QModbusRtuSerialClient>
|
||||
#else
|
||||
#include <QModbusRtuSerialMaster>
|
||||
#endif
|
||||
|
||||
void sendRequest(quint16 modbusServerAddress, QModbusDataUnit::RegisterType registerType, quint16 registerAddress, quint16 length, const QByteArray &writeData, QModbusClient *client);
|
||||
QString exceptionCodeToString(QModbusPdu::ExceptionCode exception);
|
||||
@ -51,7 +56,7 @@ int main(int argc, char *argv[])
|
||||
application.setApplicationVersion("1.2.0");
|
||||
|
||||
QString description = QString("\nTool for testing and reading Modbus TCP or RTU registers.\n\n");
|
||||
description.append(QString("Copyright %1 2016 - 2023 nymea GmbH <contact@nymea.io>\n\n").arg(QChar(0xA9)));
|
||||
description.append(QString("Copyright %1 2016 - 2025 nymea GmbH <contact@nymea.io>\n\n").arg(QChar(0xA9)));
|
||||
|
||||
|
||||
|
||||
@ -290,7 +295,11 @@ int main(int argc, char *argv[])
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QModbusRtuSerialClient *client = new QModbusRtuSerialClient(nullptr);
|
||||
#else
|
||||
QModbusRtuSerialMaster *client = new QModbusRtuSerialMaster(nullptr);
|
||||
#endif
|
||||
client->setConnectionParameter(QModbusDevice::SerialPortNameParameter, serialPortName);
|
||||
client->setConnectionParameter(QModbusDevice::SerialBaudRateParameter, baudrate);
|
||||
client->setConnectionParameter(QModbusDevice::SerialDataBitsParameter, dataBits);
|
||||
@ -308,7 +317,11 @@ int main(int argc, char *argv[])
|
||||
sendRequest(modbusServerAddress, registerType, registerAddress, length, writeData, client);
|
||||
});
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QObject::connect(client, &QModbusRtuSerialClient::errorOccurred, &application, [=](QModbusDevice::Error error){
|
||||
#else
|
||||
QObject::connect(client, &QModbusRtuSerialMaster::errorOccurred, &application, [=](QModbusDevice::Error error){
|
||||
#endif
|
||||
if (error != QModbusDevice::NoError) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@ -3,11 +3,23 @@ TARGET = nymea-modbus-cli
|
||||
QT += network serialport serialbus
|
||||
QT -= gui
|
||||
|
||||
CONFIG += c++11 console
|
||||
greaterThan(QT_MAJOR_VERSION, 5) {
|
||||
message("Building using Qt6 support")
|
||||
CONFIG *= c++17
|
||||
QMAKE_LFLAGS *= -std=c++17
|
||||
QMAKE_CXXFLAGS *= -std=c++17
|
||||
} else {
|
||||
message("Building using Qt5 support")
|
||||
CONFIG *= c++11
|
||||
QMAKE_LFLAGS *= -std=c++11
|
||||
QMAKE_CXXFLAGS *= -std=c++11
|
||||
DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x050F00
|
||||
}
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
QMAKE_CXXFLAGS *= -Werror -std=c++11 -g
|
||||
QMAKE_LFLAGS *= -std=c++11
|
||||
QMAKE_CXXFLAGS *= -Werror -g
|
||||
|
||||
gcc {
|
||||
COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion")
|
||||
|
||||
@ -63,7 +63,7 @@ void IntegrationPluginPcElectric::discoverThings(ThingDiscoveryInfo *info)
|
||||
|
||||
// Check if we already have set up this device
|
||||
Things existingThings = myThings().filterByParam(ev11ThingSerialNumberParamTypeId, result.serialNumber);
|
||||
if (existingThings.count() == 1) {
|
||||
if (existingThings.length() == 1) {
|
||||
qCDebug(dcPcElectric()) << "This PCE wallbox already exists in the system:" << result.serialNumber << result.networkDeviceInfo;
|
||||
descriptor.setThingId(existingThings.first()->id());
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ void PcElectricDiscovery::checkNetworkDevice(const QHostAddress &address)
|
||||
|
||||
QByteArray macRawData;
|
||||
QDataStream stream(&macRawData, QIODevice::WriteOnly);
|
||||
for (int i = 0; i < connection->macAddress().count(); i++)
|
||||
for (int i = 0; i < connection->macAddress().length(); i++)
|
||||
stream << connection->macAddress().at(i);
|
||||
|
||||
MacAddress registerMacAddress(macRawData);
|
||||
@ -104,7 +104,7 @@ void PcElectricDiscovery::checkNetworkDevice(const QHostAddress &address)
|
||||
QByteArray serialRawData;
|
||||
QDataStream stream(&serialRawData, QIODevice::ReadWrite);
|
||||
stream << static_cast<quint16>(0);
|
||||
for (int i = 0; i < connection->serialNumber().count(); i++)
|
||||
for (int i = 0; i < connection->serialNumber().length(); i++)
|
||||
stream << connection->serialNumber().at(i);
|
||||
|
||||
quint64 serialNumber = serialRawData.toHex().toULongLong(nullptr, 16);
|
||||
@ -158,7 +158,7 @@ void PcElectricDiscovery::finishDiscovery()
|
||||
{
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
for (int i = 0; i < m_potentialResults.count(); i++) {
|
||||
for (int i = 0; i < m_potentialResults.length(); i++) {
|
||||
const NetworkDeviceInfo networkDeviceInfo = m_networkDeviceInfos.get(m_potentialResults.at(i).address);
|
||||
m_potentialResults[i].networkDeviceInfo = networkDeviceInfo;
|
||||
|
||||
@ -184,7 +184,7 @@ void PcElectricDiscovery::finishDiscovery()
|
||||
foreach (EV11ModbusTcpConnection *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcPcElectric()) << "Discovery: Finished the discovery process. Found" << m_results.count()
|
||||
qCInfo(dcPcElectric()) << "Discovery: Finished the discovery process. Found" << m_results.length()
|
||||
<< "PCE wallboxes in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
emit discoveryFinished();
|
||||
}
|
||||
|
||||
@ -571,10 +571,10 @@ void PceWallbox::sendNextRequest()
|
||||
if (!m_writeQueue.isEmpty()) {
|
||||
// Prioritize write requests
|
||||
m_currentReply = m_writeQueue.dequeue();
|
||||
qCDebug(dcPcElectric()) << "Dequeued write request. Queue count: W" << m_writeQueue.count() << "| R:" << m_readQueue.count();
|
||||
qCDebug(dcPcElectric()) << "Dequeued write request. Queue count: W" << m_writeQueue.length() << "| R:" << m_readQueue.length();
|
||||
} else {
|
||||
m_currentReply = m_readQueue.dequeue();
|
||||
qCDebug(dcPcElectric()) << "Dequeued read request. Queue count: W" << m_writeQueue.count() << "| R:" << m_readQueue.count();
|
||||
qCDebug(dcPcElectric()) << "Dequeued read request. Queue count: W" << m_writeQueue.length() << "| R:" << m_readQueue.length();
|
||||
}
|
||||
|
||||
switch(m_currentReply->requestType()) {
|
||||
|
||||
@ -51,7 +51,7 @@ void PhoenixDiscovery::startDiscovery()
|
||||
NetworkDeviceDiscoveryReply *discoveryReply = m_networkDeviceDiscovery->discover();
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::hostAddressDiscovered, this, &PhoenixDiscovery::checkNetworkDevice);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
||||
qCDebug(dcPhoenixConnect()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "network devices";
|
||||
qCDebug(dcPhoenixConnect()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "network devices";
|
||||
m_networkDeviceInfos = discoveryReply->networkDeviceInfos();
|
||||
discoveryReply->deleteLater();
|
||||
m_gracePeriodTimer.start();
|
||||
@ -123,14 +123,14 @@ void PhoenixDiscovery::finishDiscovery()
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
// Fill in all network device infos we have
|
||||
for (int i = 0; i < m_discoveryResults.count(); i++)
|
||||
for (int i = 0; i < m_discoveryResults.length(); i++)
|
||||
m_discoveryResults[i].networkDeviceInfo = m_networkDeviceInfos.get(m_discoveryResults.at(i).address);
|
||||
|
||||
// Cleanup any leftovers...we don't care any more
|
||||
foreach (PhoenixModbusTcpConnection *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcPhoenixConnect()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.count()
|
||||
qCInfo(dcPhoenixConnect()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.length()
|
||||
<< "Phoenix connect wallboxes in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
m_gracePeriodTimer.stop();
|
||||
emit discoveryFinished();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2023, nymea GmbH
|
||||
* Copyright 2013 - 2025, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
@ -29,11 +29,11 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "ciondiscovery.h"
|
||||
|
||||
#include "extern-plugininfo.h"
|
||||
|
||||
#include <modbusdatautils.h>
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
CionDiscovery::CionDiscovery(ModbusRtuHardwareResource *modbusRtuResource, QObject *parent)
|
||||
: QObject{parent},
|
||||
@ -90,8 +90,7 @@ void CionDiscovery::tryConnect(ModbusRtuMaster *master, quint16 slaveId)
|
||||
// Examples of how this looks like:
|
||||
// EBE 1.2: "V1.2 15.02.2021"
|
||||
// ICC: "003090056-01 20220913"
|
||||
QRegExp re = QRegExp("[A-Z0-9\\.- ]{18,32}");
|
||||
if (re.exactMatch(firmwareVersion)) {
|
||||
if (QRegularExpression("[A-Z0-9\\.- ]{18,32}").match(firmwareVersion).hasMatch()) {
|
||||
Result result {master->modbusUuid(), firmwareVersion, slaveId};
|
||||
m_discoveryResults.append(result);
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ void IntegrationPluginSchrack::discoverThings(ThingDiscoveryInfo *info)
|
||||
return;
|
||||
}
|
||||
|
||||
qCInfo(dcSchrack()) << "Discovery results:" << discovery->discoveryResults().count();
|
||||
qCInfo(dcSchrack()) << "Discovery results:" << discovery->discoveryResults().length();
|
||||
|
||||
foreach (const CionDiscovery::Result &result, discovery->discoveryResults()) {
|
||||
ThingDescriptor descriptor(cionThingClassId, "Schrack CION", QString("Slave ID: %1, Version: %2").arg(result.slaveId).arg(result.firmwareVersion));
|
||||
|
||||
@ -54,7 +54,7 @@ void IntegrationPluginSenseAir::discoverThings(ThingDiscoveryInfo *info)
|
||||
}
|
||||
|
||||
QString displayMessage;
|
||||
if (info->thingDescriptors().count() == 0) {
|
||||
if (info->thingDescriptors().length() == 0) {
|
||||
displayMessage = QT_TR_NOOP("Please set up a Modbus RTU master with baudrate 9600, 8 data bits, 1 stop bits and no parity first.");
|
||||
}
|
||||
|
||||
|
||||
@ -229,7 +229,7 @@ void IntegrationPluginSma::discoverThings(ThingDiscoveryInfo *info)
|
||||
|
||||
// Note: use the serial and not the mac address as identifier because more than one inverter might be behind a network device
|
||||
Things existingThings = myThings().filterByParam(modbusSolarInverterThingSerialNumberParamTypeId, result.serialNumber);
|
||||
if (existingThings.count() == 1) {
|
||||
if (existingThings.length() == 1) {
|
||||
qCDebug(dcSma()) << "This SMA inverter already exists in the system:" << result.serialNumber;
|
||||
descriptor.setThingId(existingThings.first()->id());
|
||||
}
|
||||
@ -265,7 +265,7 @@ void IntegrationPluginSma::discoverThings(ThingDiscoveryInfo *info)
|
||||
ThingDescriptor descriptor(modbusBatteryInverterThingClassId, "SMA battery inverter", QT_TR_NOOP("Serial: ") + result.serialNumber + " (" + result.networkDeviceInfo.address().toString() + ")");
|
||||
|
||||
Things existingThings = myThings().filterByParam(modbusBatteryInverterThingSerialNumberParamTypeId, result.serialNumber);
|
||||
if (existingThings.count() == 1) {
|
||||
if (existingThings.length() == 1) {
|
||||
qCInfo(dcSma()) << "This SMA inverter already exists in the system:" << result.serialNumber;
|
||||
descriptor.setThingId(existingThings.first()->id());
|
||||
}
|
||||
@ -299,7 +299,7 @@ void IntegrationPluginSma::confirmPairing(ThingPairingInfo *info, const QString
|
||||
|
||||
if (info->thingClassId() == speedwireInverterThingClassId) {
|
||||
// On speedwire the password length has a maximum of 12 characters
|
||||
if (secret.count() > 12) {
|
||||
if (secret.length() > 12) {
|
||||
info->finish(Thing::ThingErrorInvalidParameter, QT_TR_NOOP("The password can not be longer than 12 characters."));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ void SmaModbusBatteryInverterDiscovery::startDiscovery()
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::hostAddressDiscovered, this, &SmaModbusBatteryInverterDiscovery::checkNetworkDevice);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
||||
qCDebug(dcSma()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "network devices";
|
||||
qCDebug(dcSma()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "network devices";
|
||||
m_networkDeviceInfos = discoveryReply->networkDeviceInfos();
|
||||
m_gracePeriodTimer.start();
|
||||
});
|
||||
@ -137,14 +137,14 @@ void SmaModbusBatteryInverterDiscovery::finishDiscovery()
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
// Fill in all network device infos we have
|
||||
for (int i = 0; i < m_discoveryResults.count(); i++)
|
||||
for (int i = 0; i < m_discoveryResults.length(); i++)
|
||||
m_discoveryResults[i].networkDeviceInfo = m_networkDeviceInfos.get(m_discoveryResults.at(i).address);
|
||||
|
||||
// Cleanup any leftovers...we don't care any more
|
||||
foreach (SmaBatteryInverterModbusTcpConnection *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcSma()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.count()
|
||||
qCInfo(dcSma()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.length()
|
||||
<< "SMA battery inverters in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
m_gracePeriodTimer.stop();
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ void SmaModbusSolarInverterDiscovery::startDiscovery()
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::hostAddressDiscovered, this, &SmaModbusSolarInverterDiscovery::checkNetworkDevice);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [this, discoveryReply](){
|
||||
qCDebug(dcSma()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "network devices";
|
||||
qCDebug(dcSma()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "network devices";
|
||||
m_networkDeviceInfos = discoveryReply->networkDeviceInfos();
|
||||
|
||||
// Give the last connections added right before the network discovery finished a chance to check the device...
|
||||
@ -152,14 +152,14 @@ void SmaModbusSolarInverterDiscovery::finishDiscovery()
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
// Fill in all network device infos we have
|
||||
for (int i = 0; i < m_discoveryResults.count(); i++)
|
||||
for (int i = 0; i < m_discoveryResults.length(); i++)
|
||||
m_discoveryResults[i].networkDeviceInfo = m_networkDeviceInfos.get(m_discoveryResults.at(i).address);
|
||||
|
||||
// Cleanup any leftovers...we don't care any more
|
||||
foreach (SmaSolarInverterModbusTcpConnection *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcSma()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.count()
|
||||
qCInfo(dcSma()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.length()
|
||||
<< "SMA inverters in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
emit discoveryFinished();
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2022, nymea GmbH
|
||||
* Copyright 2013 - 2025, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
@ -58,7 +58,11 @@ public:
|
||||
|
||||
// Software version
|
||||
QByteArray rawData;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream stream(&rawData, QDataStream::ReadWrite);
|
||||
#else
|
||||
QDataStream stream(&rawData, QIODevice::ReadWrite);
|
||||
#endif
|
||||
stream << versionData;
|
||||
|
||||
quint8 major = static_cast<quint8>(rawData.at(0));
|
||||
|
||||
@ -105,7 +105,7 @@ void SpeedwireDiscovery::startUnicastDiscovery()
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::hostAddressDiscovered, this, &SpeedwireDiscovery::sendUnicastDiscoveryRequest);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [this, discoveryReply](){
|
||||
qCDebug(dcSma()) << "Discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "network devices for unicast requests.";
|
||||
qCDebug(dcSma()) << "Discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "network devices for unicast requests.";
|
||||
|
||||
m_networkDeviceInfos = discoveryReply->networkDeviceInfos();
|
||||
|
||||
@ -239,10 +239,10 @@ void SpeedwireDiscovery::finishDiscovery()
|
||||
m_results = m_resultMeters.values() + m_resultInverters.values();
|
||||
|
||||
// Fill in all network device infos we have
|
||||
for (int i = 0; i < m_results.count(); i++)
|
||||
for (int i = 0; i < m_results.length(); i++)
|
||||
m_results[i].networkDeviceInfo = m_networkDeviceInfos.get(m_results.at(i).address);
|
||||
|
||||
qCDebug(dcSma()) << "SpeedwireDiscovery: Discovey finished. Found" << m_results.count() << "SMA devices in the network";
|
||||
qCDebug(dcSma()) << "SpeedwireDiscovery: Discovey finished. Found" << m_results.length() << "SMA devices in the network";
|
||||
m_multicastSearchRequestTimer.stop();
|
||||
|
||||
foreach (const SpeedwireDiscoveryResult &result, m_results) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2022, nymea GmbH
|
||||
* Copyright 2013 - 2025, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
@ -57,7 +57,11 @@ SpeedwireInterface::SpeedwireInterface(quint32 sourceSerialNumber, QObject *pare
|
||||
qCDebug(dcSma()) << "SpeedwireInterface: Unicast socket state changed" << socketState;
|
||||
});
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
connect(m_unicast, &QUdpSocket::errorOccurred, this, [=](QAbstractSocket::SocketError error){
|
||||
#else
|
||||
connect(m_unicast, static_cast<void (QUdpSocket::*)( QAbstractSocket::SocketError )>(&QAbstractSocket::error), this, [=](QAbstractSocket::SocketError error){
|
||||
#endif
|
||||
qCWarning(dcSma()) << "SpeedwireInterface: Unicast socket error occurred" << error << m_unicast->errorString();
|
||||
});
|
||||
|
||||
@ -85,7 +89,11 @@ SpeedwireInterface::SpeedwireInterface(quint32 sourceSerialNumber, QObject *pare
|
||||
connect(m_multicast, &QUdpSocket::stateChanged, this, [=](QAbstractSocket::SocketState socketState){
|
||||
qCDebug(dcSma()) << "SpeedwireInterface: Multicast socket state changed" << socketState;
|
||||
});
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
connect(m_multicast, &QUdpSocket::errorOccurred, this, [=](QAbstractSocket::SocketError error){
|
||||
#else
|
||||
connect(m_multicast, static_cast<void (QUdpSocket::*)( QAbstractSocket::SocketError )>(&QAbstractSocket::error), this, [=](QAbstractSocket::SocketError error){
|
||||
#endif
|
||||
qCWarning(dcSma()) << "SpeedwireInterface: Multicast socket error occurred" << error << m_multicast->errorString();
|
||||
});
|
||||
|
||||
|
||||
@ -235,12 +235,12 @@ SpeedwireInverterReply *SpeedwireInverter::sendLoginRequest(const QString &passw
|
||||
// Encode password
|
||||
QByteArray passwordData = password.toUtf8();
|
||||
QByteArray encodedPassword(12, loginAsUser ? 0x88 : 0xBB);
|
||||
for (int i = 0; i < password.count(); i++) {
|
||||
for (int i = 0; i < password.length(); i++) {
|
||||
encodedPassword[i] = (passwordData.at(i) + (loginAsUser ? 0x88 : 0xBB) % 0xff);
|
||||
}
|
||||
|
||||
// Add encoded password
|
||||
for (int i = 0; i < encodedPassword.count(); i++) {
|
||||
for (int i = 0; i < encodedPassword.length(); i++) {
|
||||
stream << static_cast<quint8>(encodedPassword.at(i));
|
||||
}
|
||||
|
||||
|
||||
@ -142,7 +142,7 @@ void SunnyWebBoxDiscovery::finishDiscovery()
|
||||
foreach (const QHostAddress &address, m_discoveredHosts)
|
||||
m_discoveryResults.append(m_networkDeviceInfos.get(address));
|
||||
|
||||
qCInfo(dcSma()) << "Discovery: SunnyWebBox: Finished the discovery process. Found" << m_discoveryResults.count()
|
||||
qCInfo(dcSma()) << "Discovery: SunnyWebBox: Finished the discovery process. Found" << m_discoveryResults.length()
|
||||
<< "Sunny WebBoxes in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
|
||||
cleanupPendingReplies();
|
||||
|
||||
@ -49,7 +49,7 @@ void SolaxDiscovery::startDiscovery()
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::hostAddressDiscovered, this, &SolaxDiscovery::checkNetworkDevice);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [this, discoveryReply](){
|
||||
qCDebug(dcSolax()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "network devices";
|
||||
qCDebug(dcSolax()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "network devices";
|
||||
m_networkDeviceInfos = discoveryReply->networkDeviceInfos();
|
||||
|
||||
// Give the last connections added right before the network discovery finished a chance to check the device...
|
||||
@ -156,14 +156,14 @@ void SolaxDiscovery::finishDiscovery()
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
// Fill in all network device infos we have
|
||||
for (int i = 0; i < m_discoveryResults.count(); i++)
|
||||
for (int i = 0; i < m_discoveryResults.length(); i++)
|
||||
m_discoveryResults[i].networkDeviceInfo = m_networkDeviceInfos.get(m_discoveryResults.at(i).address);
|
||||
|
||||
// Cleanup any leftovers...we don't care any more
|
||||
foreach (SolaxModbusTcpConnection *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcSolax()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.count()
|
||||
qCInfo(dcSolax()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.length()
|
||||
<< "Solax Inverters in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
emit discoveryFinished();
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ void SungrowDiscovery::startDiscovery()
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::hostAddressDiscovered, this, &SungrowDiscovery::checkNetworkDevice);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=] () {
|
||||
qCDebug(dcSungrow()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "network devices";
|
||||
qCDebug(dcSungrow()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "network devices";
|
||||
m_networkDeviceInfos = discoveryReply->networkDeviceInfos();
|
||||
|
||||
// Give the last connections added right before the network discovery finished a chance to check the device...
|
||||
@ -269,12 +269,12 @@ void SungrowDiscovery::finishDiscovery()
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
// Fill in all network device infos we have
|
||||
for (int i = 0; i < m_discoveryResults.count(); i++)
|
||||
for (int i = 0; i < m_discoveryResults.length(); i++)
|
||||
m_discoveryResults[i].networkDeviceInfo = m_networkDeviceInfos.get(m_discoveryResults.at(i).address);
|
||||
|
||||
foreach (SungrowModbusTcpConnection *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCDebug(dcSungrow()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.count() << "Sungrow inverters in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
qCDebug(dcSungrow()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.length() << "Sungrow inverters in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
emit discoveryFinished();
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ void SolarEdgeBattery::readBlockData()
|
||||
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
QVector<quint16> values = unit.values();
|
||||
qCDebug(dcSunSpec()) << "SolarEdgeBattery: Received first block data" << m_modbusStartRegister << values.count();
|
||||
qCDebug(dcSunSpec()) << "SolarEdgeBattery: Received first block data" << m_modbusStartRegister << values.length();
|
||||
qCDebug(dcSunSpec()) << "SolarEdgeBattery:" << SunSpecDataPoint::registersToString(values);
|
||||
|
||||
m_batteryData.manufacturerName = SunSpecDataPoint::convertToString(values.mid(ManufacturerName, 16));
|
||||
@ -167,7 +167,7 @@ void SolarEdgeBattery::readBlockData()
|
||||
const QModbusDataUnit unit = reply->result();
|
||||
QVector<quint16> values = unit.values();
|
||||
|
||||
qCDebug(dcSunSpec()) << "SolarEdgeBattery: Received second block data" << m_modbusStartRegister + offset << values.count();
|
||||
qCDebug(dcSunSpec()) << "SolarEdgeBattery: Received second block data" << m_modbusStartRegister + offset << values.length();
|
||||
qCDebug(dcSunSpec()) << "SolarEdgeBattery:" << SunSpecDataPoint::registersToString(values);
|
||||
QVector<quint16> valueRegisters;
|
||||
|
||||
@ -236,24 +236,24 @@ void SolarEdgeBattery::readBlockData()
|
||||
|
||||
QDebug operator<<(QDebug debug, const SolarEdgeBattery::BatteryData &batteryData)
|
||||
{
|
||||
debug << "SolarEdgeBatteryData(" << batteryData.manufacturerName << "-" << batteryData.model << ")" << endl;
|
||||
debug << " - Battery Device ID" << batteryData.batteryDeviceId << endl;
|
||||
debug << " - Firmware version" << batteryData.firmwareVersion << endl;
|
||||
debug << " - Serial number" << batteryData.serialNumber << endl;
|
||||
debug << " - Rated Energy" << batteryData.ratedEnergy << "W * H" << endl;
|
||||
debug << " - Max charging continues power" << batteryData.maxChargeContinuesPower << "W" << endl;
|
||||
debug << " - Max discharging continues power" << batteryData.maxDischargeContinuesPower << "W" << endl;
|
||||
debug << " - Max charging peak power" << batteryData.maxChargePeakPower << "W" << endl;
|
||||
debug << " - Max discharging peak power" << batteryData.maxDischargePeakPower << "W" << endl;
|
||||
debug << " - Average temperature" << batteryData.averageTemperature << "°C" << endl;
|
||||
debug << " - Max temperature" << batteryData.maxTemperature << "°C" << endl;
|
||||
debug << " - Instantuouse Voltage" << batteryData.instantaneousVoltage << "V" << endl;
|
||||
debug << " - Instantuouse Current" << batteryData.instantaneousCurrent << "A" << endl;
|
||||
debug << " - Instantuouse Power" << batteryData.instantaneousPower << "W" << endl;
|
||||
debug << " - Max energy" << batteryData.maxEnergy << "W * H" << endl;
|
||||
debug << " - Available energy" << batteryData.availableEnergy << "W * H" << endl;
|
||||
debug << " - State of health" << batteryData.stateOfHealth << "%" << endl;
|
||||
debug << " - State of energy" << batteryData.stateOfEnergy << "%" << endl;
|
||||
debug << " - Battery status" << batteryData.batteryStatus << endl;
|
||||
debug << "SolarEdgeBatteryData(" << batteryData.manufacturerName << "-" << batteryData.model << ")" << "\n";
|
||||
debug << " - Battery Device ID" << batteryData.batteryDeviceId << "\n";
|
||||
debug << " - Firmware version" << batteryData.firmwareVersion << "\n";
|
||||
debug << " - Serial number" << batteryData.serialNumber << "\n";
|
||||
debug << " - Rated Energy" << batteryData.ratedEnergy << "W * H" << "\n";
|
||||
debug << " - Max charging continues power" << batteryData.maxChargeContinuesPower << "W" << "\n";
|
||||
debug << " - Max discharging continues power" << batteryData.maxDischargeContinuesPower << "W" << "\n";
|
||||
debug << " - Max charging peak power" << batteryData.maxChargePeakPower << "W" << "\n";
|
||||
debug << " - Max discharging peak power" << batteryData.maxDischargePeakPower << "W" << "\n";
|
||||
debug << " - Average temperature" << batteryData.averageTemperature << "°C" << "\n";
|
||||
debug << " - Max temperature" << batteryData.maxTemperature << "°C" << "\n";
|
||||
debug << " - Instantuouse Voltage" << batteryData.instantaneousVoltage << "V" << "\n";
|
||||
debug << " - Instantuouse Current" << batteryData.instantaneousCurrent << "A" << "\n";
|
||||
debug << " - Instantuouse Power" << batteryData.instantaneousPower << "W" << "\n";
|
||||
debug << " - Max energy" << batteryData.maxEnergy << "W * H" << "\n";
|
||||
debug << " - Available energy" << batteryData.availableEnergy << "W * H" << "\n";
|
||||
debug << " - State of health" << batteryData.stateOfHealth << "%" << "\n";
|
||||
debug << " - State of energy" << batteryData.stateOfEnergy << "%" << "\n";
|
||||
debug << " - Battery status" << batteryData.batteryStatus << "\n";
|
||||
return debug;
|
||||
}
|
||||
|
||||
@ -230,14 +230,14 @@ void SunSpecDiscovery::finishDiscovery()
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
// Fill in all network device infos we have
|
||||
for (int i = 0; i < m_results.count(); i++)
|
||||
for (int i = 0; i < m_results.length(); i++)
|
||||
m_results[i].networkDeviceInfo = m_networkDeviceInfos.get(m_results.at(i).address);
|
||||
|
||||
// Cleanup any leftovers...we don't care any more
|
||||
foreach (SunSpecConnection *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcSunSpec()) << "Discovery: Finished the discovery process. Found" << m_results.count()
|
||||
qCInfo(dcSunSpec()) << "Discovery: Finished the discovery process. Found" << m_results.length()
|
||||
<< "SunSpec devices in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
emit discoveryFinished();
|
||||
}
|
||||
|
||||
@ -895,7 +895,7 @@ void IntegrationPluginUniPi::onRequestExecuted(const QUuid &requestId, bool succ
|
||||
{
|
||||
if (m_asyncActions.contains(requestId)){
|
||||
ThingActionInfo *info = m_asyncActions.take(requestId);
|
||||
qCDebug(dcUniPi()) << "Request executed, pending requests:" << m_asyncActions.count();
|
||||
qCDebug(dcUniPi()) << "Request executed, pending requests:" << m_asyncActions.size();
|
||||
if (success){
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
} else {
|
||||
|
||||
@ -134,7 +134,7 @@ QList<QString> NeuronCommon::userLEDs()
|
||||
NeuronCommon::RegisterDescriptor NeuronCommon::registerDescriptorFromStringList(const QStringList &data)
|
||||
{
|
||||
RegisterDescriptor descriptor;
|
||||
if (data.count() < 7) {
|
||||
if (data.length() < 7) {
|
||||
return descriptor;
|
||||
}
|
||||
descriptor.address = data[0].toInt();
|
||||
@ -235,7 +235,7 @@ QUuid NeuronCommon::setDigitalOutput(const QString &circuit, bool value)
|
||||
{
|
||||
if (!m_modbusDigitalOutputRegisters.contains(circuit)) {
|
||||
qCWarning(dcUniPi()) << "Neuron: Digital output circuit not found" << circuit;
|
||||
return "";
|
||||
return QUuid();
|
||||
}
|
||||
int modbusAddress = m_modbusDigitalOutputRegisters.value(circuit);
|
||||
//qDebug(dcUniPi()) << "Neuron: Setting digital ouput" << circuit << modbusAddress << value;
|
||||
@ -248,7 +248,7 @@ QUuid NeuronCommon::setDigitalOutput(const QString &circuit, bool value)
|
||||
if (m_writeRequestQueue.isEmpty()) {
|
||||
modbusWriteRequest(request);
|
||||
} else if (m_writeRequestQueue.length() > 100) {
|
||||
return "";
|
||||
return QUuid();
|
||||
} else {
|
||||
m_writeRequestQueue.append(request);
|
||||
}
|
||||
@ -297,7 +297,7 @@ QUuid NeuronCommon::setAnalogOutput(const QString &circuit, double value)
|
||||
if (m_writeRequestQueue.isEmpty()) {
|
||||
modbusWriteRequest(request);
|
||||
} else if (m_writeRequestQueue.length() > 100) {
|
||||
return "";
|
||||
return QUuid();
|
||||
} else {
|
||||
m_writeRequestQueue.append(request);
|
||||
}
|
||||
@ -305,7 +305,7 @@ QUuid NeuronCommon::setAnalogOutput(const QString &circuit, double value)
|
||||
}
|
||||
}
|
||||
qCWarning(dcUniPi()) << "Neuron: Analog output circuit not found" << circuit;
|
||||
return "";
|
||||
return QUuid();
|
||||
}
|
||||
|
||||
|
||||
@ -327,7 +327,7 @@ QUuid NeuronCommon::setUserLED(const QString &circuit, bool value)
|
||||
//qDebug(dcUniPi()) << "Neuron: Setting user led" << circuit << modbusAddress << value;
|
||||
|
||||
if (!m_modbusInterface)
|
||||
return "";
|
||||
return QUuid();
|
||||
|
||||
Request request;
|
||||
request.id = QUuid::createUuid();
|
||||
@ -337,10 +337,10 @@ QUuid NeuronCommon::setUserLED(const QString &circuit, bool value)
|
||||
|
||||
if (m_writeRequestQueue.isEmpty()) {
|
||||
if (!modbusWriteRequest(request)) {
|
||||
return "";
|
||||
return QUuid();
|
||||
}
|
||||
} else if (m_writeRequestQueue.length() > 100) {
|
||||
return "";
|
||||
return QUuid();
|
||||
} else {
|
||||
m_writeRequestQueue.append(request);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ void EVC04Discovery::startDiscovery()
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::hostAddressDiscovered, this, &EVC04Discovery::checkNetworkDevice);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
||||
qCDebug(m_dc()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "network devices";
|
||||
qCDebug(m_dc()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "network devices";
|
||||
m_networkDeviceInfos = discoveryReply->networkDeviceInfos();
|
||||
m_gracePeriodTimer.start();
|
||||
});
|
||||
@ -133,14 +133,14 @@ void EVC04Discovery::finishDiscovery()
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
// Fill in all network device infos we have
|
||||
for (int i = 0; i < m_discoveryResults.count(); i++)
|
||||
for (int i = 0; i < m_discoveryResults.length(); i++)
|
||||
m_discoveryResults[i].networkDeviceInfo = m_networkDeviceInfos.get(m_discoveryResults.at(i).address);
|
||||
|
||||
// Cleanup any leftovers...we don't care any more
|
||||
foreach (EVC04ModbusTcpConnection *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(m_dc()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.count()
|
||||
qCInfo(m_dc()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.length()
|
||||
<< "EVC04 wallboxes in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
m_gracePeriodTimer.stop();
|
||||
|
||||
|
||||
@ -101,8 +101,8 @@ void WattsonicDiscovery::tryConnect(ModbusRtuMaster *master, quint16 slaveId)
|
||||
Result result {master->modbusUuid(), connection->serialNumber(), slaveId, connection->generation(), connection->inverterInfo()};
|
||||
m_discoveryResults.append(result);
|
||||
|
||||
if (m_verifiedMasters.count() == m_candidateMasters.count()) {
|
||||
qCDebug(dcWattsonic()) << "Discovery: Verified all masters. Finish discovery with" << m_discoveryResults.count() << "discovered inverters.";
|
||||
if (m_verifiedMasters.length() == m_candidateMasters.length()) {
|
||||
qCDebug(dcWattsonic()) << "Discovery: Verified all masters. Finish discovery with" << m_discoveryResults.length() << "discovered inverters.";
|
||||
emit discoveryFinished(true);
|
||||
}
|
||||
});
|
||||
|
||||
@ -69,7 +69,7 @@ void IntegrationPluginWebasto::discoverThings(ThingDiscoveryInfo *info)
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [this, discoveryReply, info](){
|
||||
ThingDescriptors descriptors;
|
||||
qCDebug(dcWebasto()) << "Discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "devices";
|
||||
qCDebug(dcWebasto()) << "Discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "devices";
|
||||
foreach (const NetworkDeviceInfo &networkDeviceInfo, discoveryReply->networkDeviceInfos()) {
|
||||
qCDebug(dcWebasto()) << networkDeviceInfo;
|
||||
if (!networkDeviceInfo.hostName().contains("webasto", Qt::CaseSensitivity::CaseInsensitive))
|
||||
@ -665,7 +665,7 @@ void IntegrationPluginWebasto::executeAction(ThingActionInfo *info)
|
||||
QDateTime accessTokenExpireDateTime = QDateTime::fromString(responseMap.value("access_token_exp").toString(), Qt::ISODate);
|
||||
|
||||
QStringList tokenParts = accessToken.split('.');
|
||||
if (tokenParts.count() != 3) {
|
||||
if (tokenParts.length() != 3) {
|
||||
qCWarning(dcWebasto()) << "HTTP: Could not read expiration timestamp. Invalid JWT token formatting. Does not contain 3 parts separated by dot.";
|
||||
return;
|
||||
}
|
||||
@ -1131,14 +1131,14 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb
|
||||
evaluatePhaseCount(thing);
|
||||
break;
|
||||
case Webasto::TqActivePower: {
|
||||
if (data.count() < 2)
|
||||
if (data.length() < 2)
|
||||
return;
|
||||
int power = (static_cast<quint32>(data[0])<<16 | data[1]);
|
||||
qCDebug(dcWebasto()) << " - Active power:" << power;
|
||||
thing->setStateValue(webastoLiveCurrentPowerStateTypeId, power);
|
||||
} break;
|
||||
case Webasto::TqEnergyMeter: {
|
||||
if (data.count() < 2)
|
||||
if (data.length() < 2)
|
||||
return;
|
||||
int energy = (static_cast<quint32>(data[0])<<16 | data[1]);
|
||||
qCDebug(dcWebasto()) << " - Energy meter:" << energy << "Wh";
|
||||
@ -1167,7 +1167,7 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb
|
||||
qCDebug(dcWebasto()) << " - Battery state" << data[0];
|
||||
break;
|
||||
case Webasto::TqEVBatteryCapacity: {
|
||||
if (data.count() < 2)
|
||||
if (data.length() < 2)
|
||||
return;
|
||||
uint batteryCapacity = (static_cast<quint32>(data[0])<<16 | data[1]);
|
||||
qCDebug(dcWebasto()) << " - Battery capacity" << batteryCapacity << "Wh";
|
||||
@ -1176,7 +1176,7 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb
|
||||
qCDebug(dcWebasto()) << " - Schedule type" << data[0];
|
||||
break;
|
||||
case Webasto::TqRequiredEnergy: {
|
||||
if (data.count() < 2)
|
||||
if (data.length() < 2)
|
||||
return;
|
||||
uint requiredEnergy = (static_cast<quint32>(data[0])<<16 | data[1]);
|
||||
qCDebug(dcWebasto()) << " - Required energy" << requiredEnergy;
|
||||
@ -1198,14 +1198,14 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb
|
||||
qCDebug(dcWebasto()) << " - Start time" << (static_cast<quint32>(data[0])<<16 | data[1]);
|
||||
break;
|
||||
case Webasto::TqChargingTime: {
|
||||
if (data.count() < 2)
|
||||
if (data.length() < 2)
|
||||
return;
|
||||
uint seconds = (static_cast<quint32>(data[0])<<16 | data[1]);
|
||||
qCDebug(dcWebasto()) << " - Charging time" << seconds << "s";
|
||||
thing->setStateValue(webastoLiveSessionTimeStateTypeId, seconds/60.00); // Charging time in minutes
|
||||
} break;
|
||||
case Webasto::TqEndTime: {
|
||||
if (data.count() < 2)
|
||||
if (data.length() < 2)
|
||||
return;
|
||||
uint hour = ((static_cast<quint32>(data[0])<<16 | data[1])&0xff0000)>>16;
|
||||
uint minutes = ((static_cast<quint32>(data[0])<<16 | data[1])&0x00ff00)>>8;
|
||||
@ -1213,7 +1213,7 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb
|
||||
qCDebug(dcWebasto()) << " - End time" << hour << "h" << minutes << "m" << seconds << "s";
|
||||
} break;
|
||||
case Webasto::TqUserId: {
|
||||
if (data.count() < 10)
|
||||
if (data.length() < 10)
|
||||
return;
|
||||
QByteArray userID;
|
||||
Q_FOREACH(quint16 i, data) {
|
||||
|
||||
@ -53,7 +53,7 @@ void WebastoDiscovery::startDiscovery()
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::hostAddressDiscovered, this, &WebastoDiscovery::checkNetworkDevice);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [this, discoveryReply](){
|
||||
qCDebug(dcWebasto()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "network devices";
|
||||
qCDebug(dcWebasto()) << "Discovery: Network discovery finished. Found" << discoveryReply->networkDeviceInfos().length() << "network devices";
|
||||
m_networkDeviceInfos = discoveryReply->networkDeviceInfos();
|
||||
|
||||
// Give the last connections added right before the network discovery finished a chance to check the device...
|
||||
@ -190,7 +190,7 @@ void WebastoDiscovery::finishDiscovery()
|
||||
{
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
|
||||
for (int i = 0; i < m_temporaryResults.count(); i++) {
|
||||
for (int i = 0; i < m_temporaryResults.length(); i++) {
|
||||
// Fill in all network device infos we have
|
||||
m_temporaryResults[i].networkDeviceInfo = m_networkDeviceInfos.get(m_temporaryResults.at(i).address);
|
||||
|
||||
@ -215,6 +215,6 @@ void WebastoDiscovery::finishDiscovery()
|
||||
foreach (WebastoNextModbusTcpConnection *connection, m_connections)
|
||||
cleanupConnection(connection);
|
||||
|
||||
qCInfo(dcWebasto()) << "Discovery: Finished the discovery process. Found" << m_results.count() << "Webasto NEXT wallboxes in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
qCInfo(dcWebasto()) << "Discovery: Finished the discovery process. Found" << m_results.length() << "Webasto NEXT wallboxes in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
emit discoveryFinished();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user