changed interface, fixed remarks from reviewer

pull/7/head
Boernsman 2021-05-10 02:16:59 +02:00 committed by Michael Zanetti
parent ccdb0c371f
commit f004899127
8 changed files with 71 additions and 73 deletions

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2013 - 2020, nymea GmbH * Copyright 2013 - 2021, nymea GmbH
* Contact: contact@nymea.io * Contact: contact@nymea.io
* *
* This file is part of nymea. * This file is part of nymea.
@ -33,7 +33,6 @@
#include "../modbus/modbushelpers.h" #include "../modbus/modbushelpers.h"
#include <QTimer> #include <QTimer>
#include <cstring>
Idm::Idm(const QHostAddress &address, QObject *parent) : Idm::Idm(const QHostAddress &address, QObject *parent) :
QObject(parent), QObject(parent),
@ -61,6 +60,11 @@ bool Idm::connectDevice()
return m_modbusMaster->connectDevice(); return m_modbusMaster->connectDevice();
} }
QHostAddress Idm::getIdmAddress() const
{
return m_hostAddress;
}
void Idm::onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const QVector<quint16> &value) void Idm::onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const QVector<quint16> &value)
{ {
Q_UNUSED(slaveAddress); Q_UNUSED(slaveAddress);
@ -70,7 +74,7 @@ void Idm::onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const
case Idm::OutsideTemperature: case Idm::OutsideTemperature:
/* qCDebug(dcIdm()) << "received outside temperature"; */ /* qCDebug(dcIdm()) << "received outside temperature"; */
if (value.length() == 2) { if (value.length() == 2) {
m_info->outsideTemperature = ModbusHelpers::convertRegisterToFloat(&value[RegisterList::OutsideTemperature - modbusRegister]); m_info.outsideTemperature = ModbusHelpers::convertRegisterToFloat(&value[RegisterList::OutsideTemperature - modbusRegister]);
} }
QTimer::singleShot(200, this, [this] { QTimer::singleShot(200, this, [this] {
m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::CurrentFaultNumber, 1); m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::CurrentFaultNumber, 1);
@ -80,9 +84,9 @@ void Idm::onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const
/* qCDebug(dcIdm()) << "current fault number"; */ /* qCDebug(dcIdm()) << "current fault number"; */
if (value.length() == 1) { if (value.length() == 1) {
if (value[0] > 0) { if (value[0] > 0) {
m_info->error = true; m_info.error = true;
} else { } else {
m_info->error = false; m_info.error = false;
} }
} }
QTimer::singleShot(200, this, [this] { QTimer::singleShot(200, this, [this] {
@ -92,7 +96,7 @@ void Idm::onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const
case Idm::HeatStorageTemperature: case Idm::HeatStorageTemperature:
/* qCDebug(dcIdm()) << "received storage temperature"; */ /* qCDebug(dcIdm()) << "received storage temperature"; */
if (value.length() == 2) { if (value.length() == 2) {
m_info->waterTemperature = ModbusHelpers::convertRegisterToFloat(&value[RegisterList::HeatStorageTemperature - modbusRegister]); m_info.waterTemperature = ModbusHelpers::convertRegisterToFloat(&value[RegisterList::HeatStorageTemperature - modbusRegister]);
} }
QTimer::singleShot(200, this, [this] { QTimer::singleShot(200, this, [this] {
m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::TargetHotWaterTemperature, 1); m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::TargetHotWaterTemperature, 1);
@ -102,7 +106,7 @@ void Idm::onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const
/* qCDebug(dcIdm()) << "received target hot water temperature"; */ /* qCDebug(dcIdm()) << "received target hot water temperature"; */
if (value.length() == 1) { if (value.length() == 1) {
/* The hot water target temperature is stored as UCHAR (manual p. 13) */ /* The hot water target temperature is stored as UCHAR (manual p. 13) */
m_info->targetWaterTemperature = (double)value[RegisterList::TargetHotWaterTemperature - modbusRegister]; m_info.targetWaterTemperature = (double)value[RegisterList::TargetHotWaterTemperature - modbusRegister];
} }
QTimer::singleShot(200, this, [this] { QTimer::singleShot(200, this, [this] {
m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::HeatPumpOperatingMode, 1); m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::HeatPumpOperatingMode, 1);
@ -111,7 +115,7 @@ void Idm::onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const
case Idm::HeatPumpOperatingMode: case Idm::HeatPumpOperatingMode:
/* qCDebug(dcIdm()) << "received heat pump operating mode"; */ /* qCDebug(dcIdm()) << "received heat pump operating mode"; */
if (value.length() == 1) { if (value.length() == 1) {
m_info->mode = heatPumpOperationModeToString((Idm::IdmHeatPumpMode)value[RegisterList::HeatPumpOperatingMode-modbusRegister]); m_info.mode = heatPumpOperationModeToString((Idm::IdmHeatPumpMode)value[RegisterList::HeatPumpOperatingMode-modbusRegister]);
} }
QTimer::singleShot(200, this, [this] { QTimer::singleShot(200, this, [this] {
m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::RoomTemperatureHKA, 2); m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::RoomTemperatureHKA, 2);
@ -120,7 +124,7 @@ void Idm::onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const
case Idm::RoomTemperatureHKA: case Idm::RoomTemperatureHKA:
/* qCDebug(dcIdm()) << "received room temperature hka"; */ /* qCDebug(dcIdm()) << "received room temperature hka"; */
if (value.length() == 2) { if (value.length() == 2) {
m_info->roomTemperature = ModbusHelpers::convertRegisterToFloat(&value[RegisterList::RoomTemperatureHKA - modbusRegister]); m_info.roomTemperature = ModbusHelpers::convertRegisterToFloat(&value[RegisterList::RoomTemperatureHKA - modbusRegister]);
} }
QTimer::singleShot(200, this, [this] { QTimer::singleShot(200, this, [this] {
m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::RoomTemperatureTargetHeatingEcoHKA, 2); m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::RoomTemperatureTargetHeatingEcoHKA, 2);
@ -129,7 +133,7 @@ void Idm::onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const
case Idm::RoomTemperatureTargetHeatingEcoHKA: case Idm::RoomTemperatureTargetHeatingEcoHKA:
/* qCDebug(dcIdm()) << "received room temprature hka eco"; */ /* qCDebug(dcIdm()) << "received room temprature hka eco"; */
if (value.length() == 2) { if (value.length() == 2) {
m_info->targetRoomTemperature = ModbusHelpers::convertRegisterToFloat(&value[RegisterList::RoomTemperatureTargetHeatingEcoHKA - modbusRegister]); m_info.targetRoomTemperature = ModbusHelpers::convertRegisterToFloat(&value[RegisterList::RoomTemperatureTargetHeatingEcoHKA - modbusRegister]);
} }
QTimer::singleShot(200, this, [this] { QTimer::singleShot(200, this, [this] {
m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::CurrentPowerConsumptionHeatPump, 2); m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::CurrentPowerConsumptionHeatPump, 2);
@ -138,12 +142,12 @@ void Idm::onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const
case Idm::CurrentPowerConsumptionHeatPump: case Idm::CurrentPowerConsumptionHeatPump:
/* qCDebug(dcIdm()) << "received power consumption heat pump"; */ /* qCDebug(dcIdm()) << "received power consumption heat pump"; */
if (value.length() == 2) { if (value.length() == 2) {
m_info->powerConsumptionHeatPump = ModbusHelpers::convertRegisterToFloat(&value[RegisterList::CurrentPowerConsumptionHeatPump - modbusRegister]); m_info.powerConsumptionHeatPump = ModbusHelpers::convertRegisterToFloat(&value[RegisterList::CurrentPowerConsumptionHeatPump - modbusRegister]);
} }
/* Everything read without an error /* Everything read without an error
* -> set connected to true */ * -> set connected to true */
m_info->connected = true; m_info.connected = true;
emit statusUpdated(m_info); emit statusUpdated(m_info);
break; break;
} }
@ -152,24 +156,17 @@ void Idm::onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const
void Idm::onModbusError() void Idm::onModbusError()
{ {
qCDebug(dcIdm()) << "iDM: Received modbus error"; qCDebug(dcIdm()) << "iDM: Received modbus error";
m_info.connected = false;
if (m_info != nullptr) { emit statusUpdated(m_info);
m_info->connected = false;
emit statusUpdated(m_info);
}
} }
void Idm::onRequestStatus() void Idm::onRequestStatus()
{ {
m_info = new IdmInfo; m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::OutsideTemperature, 2);
QUuid reqId{};
reqId = m_modbusMaster->readHoldingRegister(Idm::ModbusUnitID, Idm::OutsideTemperature, 2);
/* qCDebug(dcIdm()) << "Request id: " << reqId; */
} }
QString Idm::systemOperationModeToString(IdmSysMode mode) { QString Idm::systemOperationModeToString(IdmSysMode mode)
{
QString result{}; QString result{};
/* Operation modes according to table of manual p. 13 */ /* Operation modes according to table of manual p. 13 */
@ -190,13 +187,12 @@ QString Idm::systemOperationModeToString(IdmSysMode mode) {
result = "Nur Heizung/Kühlung"; result = "Nur Heizung/Kühlung";
break; break;
} }
return result; return result;
} }
QString Idm::heatPumpOperationModeToString(IdmHeatPumpMode mode) { QString Idm::heatPumpOperationModeToString(IdmHeatPumpMode mode)
{
QString result{}; QString result{};
/* Operation modes according to table of manual p. 14 */ /* Operation modes according to table of manual p. 14 */
switch (mode) { switch (mode) {
case IdmHeatPumpModeOff: case IdmHeatPumpModeOff:
@ -215,7 +211,6 @@ QString Idm::heatPumpOperationModeToString(IdmHeatPumpMode mode) {
result = "Defrost"; result = "Defrost";
break; break;
} }
return result; return result;
} }

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2013 - 2020, nymea GmbH * Copyright 2013 - 2021, nymea GmbH
* Contact: contact@nymea.io * Contact: contact@nymea.io
* *
* This file is part of nymea. * This file is part of nymea.
@ -72,12 +72,13 @@ public:
~Idm(); ~Idm();
bool connectDevice(); bool connectDevice();
QHostAddress getIdmAddress() const {return m_hostAddress;}; QHostAddress getIdmAddress() const;
bool setTargetTemperature;
private: private:
/** Modbus Unit ID of Idm device */ /** Modbus Unit ID of Idm device */
static const quint16 ModbusUnitID = 1; static const quint16 ModbusUnitID = 1;
enum IscModus { enum IscModus {
KeineAbwarme = 0, KeineAbwarme = 0,
@ -164,7 +165,7 @@ private:
/** This structure is allocated within onRequestStatus and filled /** This structure is allocated within onRequestStatus and filled
* by the receivedStatusGroupx functions */ * by the receivedStatusGroupx functions */
IdmInfo *m_info = nullptr; IdmInfo m_info;
/** Converts a system operation mode code to a string (according to manual p. 13) */ /** Converts a system operation mode code to a string (according to manual p. 13) */
QString systemOperationModeToString(IdmSysMode mode); QString systemOperationModeToString(IdmSysMode mode);
@ -173,7 +174,7 @@ private:
QString heatPumpOperationModeToString(IdmHeatPumpMode mode); QString heatPumpOperationModeToString(IdmHeatPumpMode mode);
signals: signals:
void statusUpdated(IdmInfo *info); void statusUpdated(const IdmInfo &info);
void targetRoomTemperatureChanged(); void targetRoomTemperatureChanged();
public slots: public slots:

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2013 - 2020, nymea GmbH * Copyright 2013 - 2021, nymea GmbH
* Contact: contact@nymea.io * Contact: contact@nymea.io
* *
* This file is part of nymea. * This file is part of nymea.

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2013 - 2020, nymea GmbH * Copyright 2013 - 2021, nymea GmbH
* Contact: contact@nymea.io * Contact: contact@nymea.io
* *
* This file is part of nymea. * This file is part of nymea.
@ -44,9 +44,10 @@ void IntegrationPluginIdm::setupThing(ThingSetupInfo *info)
if (thing->thingClassId() == navigator2ThingClassId) { if (thing->thingClassId() == navigator2ThingClassId) {
QHostAddress hostAddress = QHostAddress(thing->paramValue(navigator2ThingIpAddressParamTypeId).toString()); QHostAddress hostAddress = QHostAddress(thing->paramValue(navigator2ThingIpAddressParamTypeId).toString());
if (hostAddress.isNull()) {
if (!hostAddress.isNull()) {
qCWarning(dcIdm()) << "Setup failed, IP address not valid"; qCWarning(dcIdm()) << "Setup failed, IP address not valid";
info->finish(Thing::ThingErrorInvalidParameter, "No IP address given"); info->finish(Thing::ThingErrorInvalidParameter, QT_TR_NOOP("No IP address given"));
return; return;
} }
@ -75,8 +76,8 @@ void IntegrationPluginIdm::setupThing(ThingSetupInfo *info)
return; return;
} }
m_idmConnections.insert(thing, idm); m_idmConnections.insert(thing, idm);
connect(idm, &Idm::statusUpdated, info, [info] (IdmInfo *idmInfo) { connect(idm, &Idm::statusUpdated, info, [info] (const IdmInfo &idmInfo) {
if (idmInfo->connected) { if (idmInfo.connected) {
info->finish(Thing::ThingErrorNoError); info->finish(Thing::ThingErrorNoError);
} }
}); });
@ -94,6 +95,7 @@ void IntegrationPluginIdm::postSetupThing(Thing *thing)
qCDebug(dcIdm()) << "postSetupThing called" << thing->name(); qCDebug(dcIdm()) << "postSetupThing called" << thing->name();
if (!m_refreshTimer) { if (!m_refreshTimer) {
qCDebug(dcIdm()) << "Starting refresh timer";
m_refreshTimer = hardwareManager()->pluginTimerManager()->registerTimer(10); m_refreshTimer = hardwareManager()->pluginTimerManager()->registerTimer(10);
connect(m_refreshTimer, &PluginTimer::timeout, this, &IntegrationPluginIdm::onRefreshTimer); connect(m_refreshTimer, &PluginTimer::timeout, this, &IntegrationPluginIdm::onRefreshTimer);
} }
@ -121,6 +123,12 @@ void IntegrationPluginIdm::thingRemoved(Thing *thing)
m_idmConnections.take(thing)->deleteLater(); m_idmConnections.take(thing)->deleteLater();
} }
} }
if (myThings().isEmpty()) {
qCDebug(dcIdm()) << "Stopping refresh timer";
hardwareManager()->pluginTimerManager()->unregisterTimer(m_refreshTimer);
m_refreshTimer = nullptr;
}
} }
void IntegrationPluginIdm::executeAction(ThingActionInfo *info) void IntegrationPluginIdm::executeAction(ThingActionInfo *info)
@ -129,7 +137,9 @@ void IntegrationPluginIdm::executeAction(ThingActionInfo *info)
Action action = info->action(); Action action = info->action();
if (thing->thingClassId() == navigator2ThingClassId) { if (thing->thingClassId() == navigator2ThingClassId) {
if (action.actionTypeId() == navigator2PowerActionTypeId) { if (action.actionTypeId() == navigator2TargetTemperatureActionTypeId) {
double targetTemperature = thing->stateValue(navigator2TargetTemperatureStateTypeId).toDouble();
Q_UNUSED(targetTemperature);
} else { } else {
Q_ASSERT_X(false, "executeAction", QString("Unhandled action: %1").arg(action.actionTypeId().toString()).toUtf8()); Q_ASSERT_X(false, "executeAction", QString("Unhandled action: %1").arg(action.actionTypeId().toString()).toUtf8());
@ -152,15 +162,11 @@ void IntegrationPluginIdm::update(Thing *thing)
} }
} }
void IntegrationPluginIdm::onStatusUpdated(IdmInfo *info) void IntegrationPluginIdm::onStatusUpdated(const IdmInfo &info)
{ {
/* qCDebug(dcIdm()) << "onStatusUpdated"; */
if (!info)
return;
qCDebug(dcIdm()) << "Received status from heat pump"; qCDebug(dcIdm()) << "Received status from heat pump";
Idm *idm = static_cast<Idm *>(sender()); Idm *idm = qobject_cast<Idm *>(sender());
Thing *thing = m_idmConnections.key(idm); Thing *thing = m_idmConnections.key(idm);
if (!thing) if (!thing)
@ -168,16 +174,16 @@ void IntegrationPluginIdm::onStatusUpdated(IdmInfo *info)
/* Received a structure holding the status info of the /* Received a structure holding the status info of the
* heat pump. Update the thing states with the individual fields. */ * heat pump. Update the thing states with the individual fields. */
thing->setStateValue(navigator2ConnectedStateTypeId, info->connected); thing->setStateValue(navigator2ConnectedStateTypeId, info.connected);
thing->setStateValue(navigator2PowerStateTypeId, info->power); thing->setStateValue(navigator2PowerStateTypeId, info.power);
thing->setStateValue(navigator2TemperatureStateTypeId, info->roomTemperature); thing->setStateValue(navigator2TemperatureStateTypeId, info.roomTemperature);
thing->setStateValue(navigator2OutsideAirTemperatureStateTypeId, info->outsideTemperature); thing->setStateValue(navigator2OutsideAirTemperatureStateTypeId, info.outsideTemperature);
thing->setStateValue(navigator2WaterTemperatureStateTypeId, info->waterTemperature); thing->setStateValue(navigator2WaterTemperatureStateTypeId, info.waterTemperature);
thing->setStateValue(navigator2TargetTemperatureStateTypeId, info->targetRoomTemperature); thing->setStateValue(navigator2TargetTemperatureStateTypeId, info.targetRoomTemperature);
thing->setStateValue(navigator2TargetWaterTemperatureStateTypeId, info->targetWaterTemperature); thing->setStateValue(navigator2TargetWaterTemperatureStateTypeId, info.targetWaterTemperature);
thing->setStateValue(navigator2CurrentPowerConsumptionHeatPumpStateTypeId, info->powerConsumptionHeatPump); thing->setStateValue(navigator2CurrentPowerConsumptionHeatPumpStateTypeId, info.powerConsumptionHeatPump);
thing->setStateValue(navigator2ModeStateTypeId, info->mode); thing->setStateValue(navigator2ModeStateTypeId, info.mode);
thing->setStateValue(navigator2ErrorStateTypeId, info->error); thing->setStateValue(navigator2ErrorStateTypeId, info.error);
} }
void IntegrationPluginIdm::onRefreshTimer() void IntegrationPluginIdm::onRefreshTimer()

View File

@ -46,27 +46,24 @@ class IntegrationPluginIdm: public IntegrationPlugin
Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginidm.json") Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginidm.json")
Q_INTERFACES(IntegrationPlugin) Q_INTERFACES(IntegrationPlugin)
public: public:
/** Constructor */
explicit IntegrationPluginIdm(); explicit IntegrationPluginIdm();
void setupThing(ThingSetupInfo *info) override; void setupThing(ThingSetupInfo *info) override;
void postSetupThing(Thing *thing) override; void postSetupThing(Thing *thing) override;
void thingRemoved(Thing *thing) override; void thingRemoved(Thing *thing) override;
void executeAction(ThingActionInfo *info) override; void executeAction(ThingActionInfo *info) override;
void update(Thing *thing);
private: private:
PluginTimer *m_refreshTimer = nullptr; PluginTimer *m_refreshTimer = nullptr;
QHash<Thing *, Idm *> m_idmConnections; QHash<Thing *, Idm *> m_idmConnections;
QHash<QUuid, ThingActionInfo *> m_asyncActions; QHash<QUuid, ThingActionInfo *> m_asyncActions;
void update(Thing *thing);
void onRefreshTimer(); void onRefreshTimer();
private slots: private slots:
void onStatusUpdated(IdmInfo *info); void onStatusUpdated(const IdmInfo &info);
}; };
#endif // INTEGRATIONPLUGINIDM_H #endif // INTEGRATIONPLUGINIDM_H

View File

@ -13,7 +13,7 @@
"displayName": "Navigator 2.0", "displayName": "Navigator 2.0",
"id": "1c95ac91-4eca-4cbf-b0f4-d60d35d069ed", "id": "1c95ac91-4eca-4cbf-b0f4-d60d35d069ed",
"createMethods": ["user"], "createMethods": ["user"],
"interfaces": ["temperaturesensor", "connectable"], "interfaces": ["thermostat", "connectable"],
"paramTypes": [ "paramTypes": [
{ {
"id": "05714e5c-d66a-4095-bbff-a0eb96fb035b", "id": "05714e5c-d66a-4095-bbff-a0eb96fb035b",
@ -37,10 +37,8 @@
"name": "power", "name": "power",
"displayName": "Power", "displayName": "Power",
"displayNameEvent": "Power changed", "displayNameEvent": "Power changed",
"displayNameAction": "Change power",
"type": "bool", "type": "bool",
"defaultValue": 0, "defaultValue": false
"writable": true
}, },
{ {
"id": "f0f596bf-7e45-43ea-b3d4-767b82dd422a", "id": "f0f596bf-7e45-43ea-b3d4-767b82dd422a",
@ -73,10 +71,14 @@
"id": "efae7493-68c3-4cb9-853c-81011bdf09ca", "id": "efae7493-68c3-4cb9-853c-81011bdf09ca",
"name": "targetTemperature", "name": "targetTemperature",
"displayName": "Target room temperature", "displayName": "Target room temperature",
"displayNameAction": "Set target room temperature",
"displayNameEvent": "Target room temperature changed", "displayNameEvent": "Target room temperature changed",
"type": "double", "type": "double",
"unit": "DegreeCelsius", "unit": "DegreeCelsius",
"defaultValue": 22.00 "minValue": "18",
"maxValue": "28",
"defaultValue": 22.00,
"writable": true
}, },
{ {
"id": "746244d6-dd37-4af8-b2ae-a7d8463e51e2", "id": "746244d6-dd37-4af8-b2ae-a7d8463e51e2",

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2013 - 2020, nymea GmbH * Copyright 2013 - 2021, nymea GmbH
* Contact: contact@nymea.io * Contact: contact@nymea.io
* *
* This file is part of nymea. * This file is part of nymea.
@ -30,8 +30,6 @@
#include "modbushelpers.h" #include "modbushelpers.h"
#include <cstring>
float ModbusHelpers::convertRegisterToFloat(const quint16 *reg) { float ModbusHelpers::convertRegisterToFloat(const quint16 *reg) {
float result = 0.0; float result = 0.0;
@ -46,7 +44,6 @@ float ModbusHelpers::convertRegisterToFloat(const quint16 *reg) {
/* needs to be done with char * to avoid pedantic compiler errors */ /* needs to be done with char * to avoid pedantic compiler errors */
memcpy((char *)&result, (char *)&tmp, sizeof(result)); memcpy((char *)&result, (char *)&tmp, sizeof(result));
} }
return result; return result;
} }

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2013 - 2020, nymea GmbH * Copyright 2013 - 2021, nymea GmbH
* Contact: contact@nymea.io * Contact: contact@nymea.io
* *
* This file is part of nymea. * This file is part of nymea.
@ -36,8 +36,8 @@
class ModbusHelpers { class ModbusHelpers {
public: public:
static float convertRegisterToFloat(const quint16 *reg); static float convertRegisterToFloat(const quint16 *reg);
static void convertFloatToRegister(QVector<quint16> &reg, float value); static void convertFloatToRegister(QVector<quint16> &reg, float value);
}; };
#endif #endif