Added SG Ready Support

master
l.heizinger 2022-02-17 15:10:38 +01:00 committed by Simon Stürz
parent eac316e6f8
commit 374b107c10
4 changed files with 176 additions and 170 deletions

View File

@ -303,8 +303,8 @@ void IntegrationPluginStiebelEltron::setupThing(ThingSetupInfo *info) {
connect( connect(
connection, &StiebelEltronModbusConnection::sgReadyStateChanged, connection, &StiebelEltronModbusConnection::sgReadyStateChanged,
this, this,
[thing](StiebelEltronModbusConnection::SmartGridState [thing](
smartGridState) { StiebelEltronModbusConnection::SmartGridState smartGridState) {
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron())
<< thing << "SG Ready activation changed" << smartGridState; << thing << "SG Ready activation changed" << smartGridState;
switch (smartGridState) { switch (smartGridState) {
@ -379,52 +379,130 @@ void IntegrationPluginStiebelEltron::executeAction(ThingActionInfo *info) {
Thing *thing = info->thing(); Thing *thing = info->thing();
StiebelEltronModbusConnection *connection = m_connections.value(thing); StiebelEltronModbusConnection *connection = m_connections.value(thing);
if (!connection->connected()) { if (!connection->connected()) {
qCWarning(dcStiebelEltron()) << "Could not execute action. The modbus connection is currently not available."; qCWarning(dcStiebelEltron())
<< "Could not execute action. The modbus connection is currently "
"not available.";
info->finish(Thing::ThingErrorHardwareNotAvailable); info->finish(Thing::ThingErrorHardwareNotAvailable);
return; return;
} }
// Got this from StiebelEltron plugin, not sure if necessary // Got this from StiebelEltron plugin, not sure if necessary
if (thing->thingClassId() != stiebelEltronThingClassId) { if (thing->thingClassId() != stiebelEltronThingClassId) {
info->finish(Thing::ThingErrorNoError); info->finish(Thing::ThingErrorNoError);
} }
if (info->action().actionTypeId() == stiebelEltronSgReadyActiveActionTypeId) {
bool sgReadyActiveBool = info->action().paramValue(stiebelEltronSgReadyActiveActionSgReadyActiveParamTypeId).toBool();
qCDebug(dcStiebelEltron()) << "Execute action" << info->action().actionTypeId().toString() << info->action().params();
qCDebug(dcStiebelEltron()) << "Value: " << sgReadyActiveBool;
QModbusReply *reply = connection->setSgReadyActive(sgReadyActiveBool);
if (!reply) {
qCWarning(dcStiebelEltron()) << "Execute action failed because the reply could not be created.";
info->finish(Thing::ThingErrorHardwareFailure);
return;
}
if (info->action().actionTypeId() ==
stiebelEltronSgReadyActiveActionTypeId) {
bool sgReadyActiveBool =
info->action()
.paramValue(
stiebelEltronSgReadyActiveActionSgReadyActiveParamTypeId)
.toBool();
qCDebug(dcStiebelEltron())
<< "Execute action" << info->action().actionTypeId().toString()
<< info->action().params();
qCDebug(dcStiebelEltron()) << "Value: " << sgReadyActiveBool;
connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); QModbusReply *reply = connection->setSgReadyActive(sgReadyActiveBool);
connect(reply, &QModbusReply::finished, info, [info, reply, sgReadyActiveBool]{ if (!reply) {
if (reply->error() != QModbusDevice::NoError) { qCWarning(dcStiebelEltron()) << "Execute action failed because the "
qCWarning(dcStiebelEltron()) << "Set SG ready activation finished with error" << reply->errorString(); "reply could not be created.";
info->finish(Thing::ThingErrorHardwareFailure); info->finish(Thing::ThingErrorHardwareFailure);
return; return;
} }
connect(reply, &QModbusReply::finished, reply,
&QModbusReply::deleteLater);
connect(reply, &QModbusReply::finished, info,
[info, reply, sgReadyActiveBool] {
if (reply->error() != QModbusDevice::NoError) {
qCWarning(dcStiebelEltron())
<< "Set SG ready activation finished with error"
<< reply->errorString();
info->finish(Thing::ThingErrorHardwareFailure);
return;
}
qCDebug(dcStiebelEltron()) << "Execute action finished successfully" << info->action().actionTypeId().toString() << info->action().params(); qCDebug(dcStiebelEltron())
info->thing()->setStateValue(stiebelEltronSgReadyActiveStateTypeId, sgReadyActiveBool); << "Execute action finished successfully"
info->finish(Thing::ThingErrorNoError); << info->action().actionTypeId().toString()
}); << info->action().params();
info->thing()->setStateValue(
stiebelEltronSgReadyActiveStateTypeId,
sgReadyActiveBool);
info->finish(Thing::ThingErrorNoError);
});
connect(reply, &QModbusReply::errorOccurred, this, [reply] (QModbusDevice::Error error){ connect(reply, &QModbusReply::errorOccurred, this,
qCWarning(dcStiebelEltron()) << "Modbus reply error occurred while execute action" << error << reply->errorString(); [reply](QModbusDevice::Error error) {
emit reply->finished(); // To make sure it will be deleted qCWarning(dcStiebelEltron())
}); << "Modbus reply error occurred while execute action"
<< error << reply->errorString();
emit reply->finished(); // To make sure it will be deleted
});
} else if (info->action().actionTypeId() ==
stiebelEltronSgReadyModeActionTypeId) {
QString sgReadyModeString =
info->action()
.paramValue(
stiebelEltronSgReadyModeActionSgReadyModeParamTypeId)
.toString();
qCDebug(dcStiebelEltron())
<< "Execute action" << info->action().actionTypeId().toString()
<< info->action().params();
StiebelEltronModbusConnection::SmartGridState sgReadyState;
if (sgReadyModeString == "Mode 1") {
sgReadyState =
StiebelEltronModbusConnection::SmartGridStateModeOne;
} else if (sgReadyModeString == "Mode 2") {
sgReadyState =
StiebelEltronModbusConnection::SmartGridStateModeTwo;
} else if (sgReadyModeString == "Mode 3") {
sgReadyState =
StiebelEltronModbusConnection::SmartGridStateModeThree;
} else {
sgReadyState =
StiebelEltronModbusConnection::SmartGridStateModeFour;
}
QModbusReply *reply = connection->setSgReadyState(sgReadyState);
if (!reply) {
qCWarning(dcStiebelEltron()) << "Execute action failed because the "
"reply could not be created.";
info->finish(Thing::ThingErrorHardwareFailure);
return;
}
connect(reply, &QModbusReply::finished, reply,
&QModbusReply::deleteLater);
connect(reply, &QModbusReply::finished, info,
[info, reply, sgReadyModeString] {
if (reply->error() != QModbusDevice::NoError) {
qCWarning(dcStiebelEltron())
<< "Set SG ready mode finished with error"
<< reply->errorString();
info->finish(Thing::ThingErrorHardwareFailure);
return;
}
qCDebug(dcStiebelEltron())
<< "Execute action finished successfully"
<< info->action().actionTypeId().toString()
<< info->action().params();
info->thing()->setStateValue(
stiebelEltronSgReadyModeStateTypeId, sgReadyModeString);
info->finish(Thing::ThingErrorNoError);
});
connect(reply, &QModbusReply::errorOccurred, this,
[reply](QModbusDevice::Error error) {
qCWarning(dcStiebelEltron())
<< "Modbus reply error occurred while execute action"
<< error << reply->errorString();
emit reply->finished(); // To make sure it will be deleted
});
} }
info->finish(Thing::ThingErrorNoError); info->finish(Thing::ThingErrorNoError);
} }

View File

@ -36,19 +36,23 @@
"values": [ "values": [
{ {
"key": "ModeOne", "key": "ModeOne",
"value": 1 "value": 1,
"comment": "0x00000001"
}, },
{ {
"key": "ModeTwo", "key": "ModeTwo",
"value": 2 "value": 0,
"comment": "0x00000000"
}, },
{ {
"key": "ModeThree", "key": "ModeThree",
"value": 3 "value": 65536,
"comment": "0x00010000"
}, },
{ {
"key": "ModeFour", "key": "ModeFour",
"value": 4 "value": 65537,
"comment": "0x00010001"
} }
] ]
} }
@ -282,15 +286,14 @@
"access": "RO" "access": "RO"
}, },
{ {
"id": "sgReadyState", "id": "sgReadyStateRO",
"address": 5000, "address": 5000,
"size": 1, "size": 1,
"type": "uint16", "type": "uint16",
"enum": "SmartGridState",
"registerType": "inputRegister", "registerType": "inputRegister",
"readSchedule": "update", "readSchedule": "update",
"description": "Smart grid status", "description": "Smart grid status",
"defaultValue": "SmartGridStateModeTwo", "defaultValue": 3,
"access": "RO" "access": "RO"
}, },
{ {
@ -305,27 +308,16 @@
"access": "RW" "access": "RW"
}, },
{ {
"id": "sgReadyInputOne", "id": "sgReadyState",
"address": 4001, "address": 4001,
"size": 1, "size": 2,
"type": "uint16", "type": "uint32",
"registerType": "holdingRegister", "registerType": "holdingRegister",
"enum": "SmartGridState",
"readSchedule": "update", "readSchedule": "update",
"description": "SG Ready Input 1", "description": "SG Ready mode",
"defaultValue": 0, "defaultValue": "SmartGridStateModeThree",
"access": "RW"
},
{
"id": "sgReadyInputTwo",
"address": 4002,
"size": 1,
"type": "uint16",
"registerType": "holdingRegister",
"readSchedule": "update",
"description": "SG Read Input 2",
"defaultValue": 0,
"access": "RW" "access": "RW"
} }
] ]
} }

View File

@ -131,9 +131,9 @@ quint16 StiebelEltronModbusConnection::systemStatus() const
return m_systemStatus; return m_systemStatus;
} }
StiebelEltronModbusConnection::SmartGridState StiebelEltronModbusConnection::sgReadyState() const quint16 StiebelEltronModbusConnection::sgReadyStateRO() const
{ {
return m_sgReadyState; return m_sgReadyStateRO;
} }
quint16 StiebelEltronModbusConnection::sgReadyActive() const quint16 StiebelEltronModbusConnection::sgReadyActive() const
@ -150,34 +150,20 @@ QModbusReply *StiebelEltronModbusConnection::setSgReadyActive(quint16 sgReadyAct
return sendWriteRequest(request, m_slaveId); return sendWriteRequest(request, m_slaveId);
} }
quint16 StiebelEltronModbusConnection::sgReadyInputOne() const StiebelEltronModbusConnection::SmartGridState StiebelEltronModbusConnection::sgReadyState() const
{ {
return m_sgReadyInputOne; return m_sgReadyState;
} }
QModbusReply *StiebelEltronModbusConnection::setSgReadyInputOne(quint16 sgReadyInputOne) QModbusReply *StiebelEltronModbusConnection::setSgReadyState(SmartGridState sgReadyState)
{ {
QVector<quint16> values = ModbusDataUtils::convertFromUInt16(sgReadyInputOne); QVector<quint16> values = ModbusDataUtils::convertFromUInt32(static_cast<quint32>(sgReadyState), ModbusDataUtils::ByteOrderBigEndian);
qCDebug(dcStiebelEltronModbusConnection()) << "--> Write \"SG Ready Input 1\" register:" << 4001 << "size:" << 1 << values; qCDebug(dcStiebelEltronModbusConnection()) << "--> Write \"SG Ready mode\" register:" << 4001 << "size:" << 2 << values;
QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 4001, values.count()); QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 4001, values.count());
request.setValues(values); request.setValues(values);
return sendWriteRequest(request, m_slaveId); return sendWriteRequest(request, m_slaveId);
} }
quint16 StiebelEltronModbusConnection::sgReadyInputTwo() const
{
return m_sgReadyInputTwo;
}
QModbusReply *StiebelEltronModbusConnection::setSgReadyInputTwo(quint16 sgReadyInputTwo)
{
QVector<quint16> values = ModbusDataUtils::convertFromUInt16(sgReadyInputTwo);
qCDebug(dcStiebelEltronModbusConnection()) << "--> Write \"SG Read Input 2\" register:" << 4002 << "size:" << 1 << values;
QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 4002, values.count());
request.setValues(values);
return sendWriteRequest(request, m_slaveId);
}
void StiebelEltronModbusConnection::initialize() void StiebelEltronModbusConnection::initialize()
{ {
// No init registers defined. Nothing to be done and we are finished. // No init registers defined. Nothing to be done and we are finished.
@ -204,10 +190,9 @@ void StiebelEltronModbusConnection::update()
updateConsumedEnergyHotWater(); updateConsumedEnergyHotWater();
updateOperatingMode(); updateOperatingMode();
updateSystemStatus(); updateSystemStatus();
updateSgReadyState(); updateSgReadyStateRO();
updateSgReadyActive(); updateSgReadyActive();
updateSgReadyInputOne(); updateSgReadyState();
updateSgReadyInputTwo();
} }
void StiebelEltronModbusConnection::updateOutdoorTemperature() void StiebelEltronModbusConnection::updateOutdoorTemperature()
@ -804,11 +789,11 @@ void StiebelEltronModbusConnection::updateSystemStatus()
} }
} }
void StiebelEltronModbusConnection::updateSgReadyState() void StiebelEltronModbusConnection::updateSgReadyStateRO()
{ {
// Update registers from Smart grid status // Update registers from Smart grid status
qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Smart grid status\" register:" << 5000 << "size:" << 1; qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Smart grid status\" register:" << 5000 << "size:" << 1;
QModbusReply *reply = readSgReadyState(); QModbusReply *reply = readSgReadyStateRO();
if (reply) { if (reply) {
if (!reply->isFinished()) { if (!reply->isFinished()) {
connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater);
@ -817,10 +802,10 @@ void StiebelEltronModbusConnection::updateSgReadyState()
const QModbusDataUnit unit = reply->result(); const QModbusDataUnit unit = reply->result();
const QVector<quint16> values = unit.values(); const QVector<quint16> values = unit.values();
qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Smart grid status\" register" << 5000 << "size:" << 1 << values; qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Smart grid status\" register" << 5000 << "size:" << 1 << values;
SmartGridState receivedSgReadyState = static_cast<SmartGridState>(ModbusDataUtils::convertToUInt16(values)); quint16 receivedSgReadyStateRO = ModbusDataUtils::convertToUInt16(values);
if (m_sgReadyState != receivedSgReadyState) { if (m_sgReadyStateRO != receivedSgReadyStateRO) {
m_sgReadyState = receivedSgReadyState; m_sgReadyStateRO = receivedSgReadyStateRO;
emit sgReadyStateChanged(m_sgReadyState); emit sgReadyStateROChanged(m_sgReadyStateRO);
} }
} }
}); });
@ -870,11 +855,11 @@ void StiebelEltronModbusConnection::updateSgReadyActive()
} }
} }
void StiebelEltronModbusConnection::updateSgReadyInputOne() void StiebelEltronModbusConnection::updateSgReadyState()
{ {
// Update registers from SG Ready Input 1 // Update registers from SG Ready mode
qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"SG Ready Input 1\" register:" << 4001 << "size:" << 1; qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"SG Ready mode\" register:" << 4001 << "size:" << 2;
QModbusReply *reply = readSgReadyInputOne(); QModbusReply *reply = readSgReadyState();
if (reply) { if (reply) {
if (!reply->isFinished()) { if (!reply->isFinished()) {
connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater);
@ -882,57 +867,24 @@ void StiebelEltronModbusConnection::updateSgReadyInputOne()
if (reply->error() == QModbusDevice::NoError) { if (reply->error() == QModbusDevice::NoError) {
const QModbusDataUnit unit = reply->result(); const QModbusDataUnit unit = reply->result();
const QVector<quint16> values = unit.values(); const QVector<quint16> values = unit.values();
qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"SG Ready Input 1\" register" << 4001 << "size:" << 1 << values; qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"SG Ready mode\" register" << 4001 << "size:" << 2 << values;
quint16 receivedSgReadyInputOne = ModbusDataUtils::convertToUInt16(values); SmartGridState receivedSgReadyState = static_cast<SmartGridState>(ModbusDataUtils::convertToUInt32(values, ModbusDataUtils::ByteOrderBigEndian));
if (m_sgReadyInputOne != receivedSgReadyInputOne) { if (m_sgReadyState != receivedSgReadyState) {
m_sgReadyInputOne = receivedSgReadyInputOne; m_sgReadyState = receivedSgReadyState;
emit sgReadyInputOneChanged(m_sgReadyInputOne); emit sgReadyStateChanged(m_sgReadyState);
} }
} }
}); });
connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){
qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"SG Ready Input 1\" registers from" << hostAddress().toString() << error << reply->errorString(); qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"SG Ready mode\" registers from" << hostAddress().toString() << error << reply->errorString();
emit reply->finished(); // To make sure it will be deleted emit reply->finished(); // To make sure it will be deleted
}); });
} else { } else {
delete reply; // Broadcast reply returns immediatly delete reply; // Broadcast reply returns immediatly
} }
} else { } else {
qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"SG Ready Input 1\" registers from" << hostAddress().toString() << errorString(); qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"SG Ready mode\" registers from" << hostAddress().toString() << errorString();
}
}
void StiebelEltronModbusConnection::updateSgReadyInputTwo()
{
// Update registers from SG Read Input 2
qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"SG Read Input 2\" register:" << 4002 << "size:" << 1;
QModbusReply *reply = readSgReadyInputTwo();
if (reply) {
if (!reply->isFinished()) {
connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater);
connect(reply, &QModbusReply::finished, this, [this, reply](){
if (reply->error() == QModbusDevice::NoError) {
const QModbusDataUnit unit = reply->result();
const QVector<quint16> values = unit.values();
qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"SG Read Input 2\" register" << 4002 << "size:" << 1 << values;
quint16 receivedSgReadyInputTwo = ModbusDataUtils::convertToUInt16(values);
if (m_sgReadyInputTwo != receivedSgReadyInputTwo) {
m_sgReadyInputTwo = receivedSgReadyInputTwo;
emit sgReadyInputTwoChanged(m_sgReadyInputTwo);
}
}
});
connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){
qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"SG Read Input 2\" registers from" << hostAddress().toString() << error << reply->errorString();
emit reply->finished(); // To make sure it will be deleted
});
} else {
delete reply; // Broadcast reply returns immediatly
}
} else {
qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"SG Read Input 2\" registers from" << hostAddress().toString() << errorString();
} }
} }
@ -1044,7 +996,7 @@ QModbusReply *StiebelEltronModbusConnection::readSystemStatus()
return sendReadRequest(request, m_slaveId); return sendReadRequest(request, m_slaveId);
} }
QModbusReply *StiebelEltronModbusConnection::readSgReadyState() QModbusReply *StiebelEltronModbusConnection::readSgReadyStateRO()
{ {
QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 5000, 1); QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 5000, 1);
return sendReadRequest(request, m_slaveId); return sendReadRequest(request, m_slaveId);
@ -1056,15 +1008,9 @@ QModbusReply *StiebelEltronModbusConnection::readSgReadyActive()
return sendReadRequest(request, m_slaveId); return sendReadRequest(request, m_slaveId);
} }
QModbusReply *StiebelEltronModbusConnection::readSgReadyInputOne() QModbusReply *StiebelEltronModbusConnection::readSgReadyState()
{ {
QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 4001, 1); QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 4001, 2);
return sendReadRequest(request, m_slaveId);
}
QModbusReply *StiebelEltronModbusConnection::readSgReadyInputTwo()
{
QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 4002, 1);
return sendReadRequest(request, m_slaveId); return sendReadRequest(request, m_slaveId);
} }
@ -1097,10 +1043,9 @@ QDebug operator<<(QDebug debug, StiebelEltronModbusConnection *stiebelEltronModb
debug.nospace().noquote() << " - Consumed energy hot water:" << stiebelEltronModbusConnection->consumedEnergyHotWater() << " [kWh]" << "\n"; debug.nospace().noquote() << " - Consumed energy hot water:" << stiebelEltronModbusConnection->consumedEnergyHotWater() << " [kWh]" << "\n";
debug.nospace().noquote() << " - Operating mode:" << stiebelEltronModbusConnection->operatingMode() << "\n"; debug.nospace().noquote() << " - Operating mode:" << stiebelEltronModbusConnection->operatingMode() << "\n";
debug.nospace().noquote() << " - System status:" << stiebelEltronModbusConnection->systemStatus() << "\n"; debug.nospace().noquote() << " - System status:" << stiebelEltronModbusConnection->systemStatus() << "\n";
debug.nospace().noquote() << " - Smart grid status:" << stiebelEltronModbusConnection->sgReadyState() << "\n"; debug.nospace().noquote() << " - Smart grid status:" << stiebelEltronModbusConnection->sgReadyStateRO() << "\n";
debug.nospace().noquote() << " - SG ready active:" << stiebelEltronModbusConnection->sgReadyActive() << "\n"; debug.nospace().noquote() << " - SG ready active:" << stiebelEltronModbusConnection->sgReadyActive() << "\n";
debug.nospace().noquote() << " - SG Ready Input 1:" << stiebelEltronModbusConnection->sgReadyInputOne() << "\n"; debug.nospace().noquote() << " - SG Ready mode:" << stiebelEltronModbusConnection->sgReadyState() << "\n";
debug.nospace().noquote() << " - SG Read Input 2:" << stiebelEltronModbusConnection->sgReadyInputTwo() << "\n";
return debug.quote().space(); return debug.quote().space();
} }

View File

@ -60,9 +60,8 @@ public:
RegisterConsumedEnergyHeating = 3511, RegisterConsumedEnergyHeating = 3511,
RegisterConsumedEnergyHotWater = 3514, RegisterConsumedEnergyHotWater = 3514,
RegisterSgReadyActive = 4000, RegisterSgReadyActive = 4000,
RegisterSgReadyInputOne = 4001, RegisterSgReadyState = 4001,
RegisterSgReadyInputTwo = 4002, RegisterSgReadyStateRO = 5000
RegisterSgReadyState = 5000
}; };
Q_ENUM(Registers) Q_ENUM(Registers)
@ -78,9 +77,9 @@ public:
enum SmartGridState { enum SmartGridState {
SmartGridStateModeOne = 1, SmartGridStateModeOne = 1,
SmartGridStateModeTwo = 2, SmartGridStateModeTwo = 0,
SmartGridStateModeThree = 3, SmartGridStateModeThree = 65536,
SmartGridStateModeFour = 4 SmartGridStateModeFour = 65537
}; };
Q_ENUM(SmartGridState) Q_ENUM(SmartGridState)
@ -142,19 +141,15 @@ public:
quint16 systemStatus() const; quint16 systemStatus() const;
/* Smart grid status - Address: 5000, Size: 1 */ /* Smart grid status - Address: 5000, Size: 1 */
SmartGridState sgReadyState() const; quint16 sgReadyStateRO() const;
/* SG ready active - Address: 4000, Size: 1 */ /* SG ready active - Address: 4000, Size: 1 */
quint16 sgReadyActive() const; quint16 sgReadyActive() const;
QModbusReply *setSgReadyActive(quint16 sgReadyActive); QModbusReply *setSgReadyActive(quint16 sgReadyActive);
/* SG Ready Input 1 - Address: 4001, Size: 1 */ /* SG Ready mode - Address: 4001, Size: 2 */
quint16 sgReadyInputOne() const; SmartGridState sgReadyState() const;
QModbusReply *setSgReadyInputOne(quint16 sgReadyInputOne); QModbusReply *setSgReadyState(SmartGridState sgReadyState);
/* SG Read Input 2 - Address: 4002, Size: 1 */
quint16 sgReadyInputTwo() const;
QModbusReply *setSgReadyInputTwo(quint16 sgReadyInputTwo);
virtual void initialize(); virtual void initialize();
virtual void update(); virtual void update();
@ -177,10 +172,9 @@ public:
void updateConsumedEnergyHotWater(); void updateConsumedEnergyHotWater();
void updateOperatingMode(); void updateOperatingMode();
void updateSystemStatus(); void updateSystemStatus();
void updateSgReadyState(); void updateSgReadyStateRO();
void updateSgReadyActive(); void updateSgReadyActive();
void updateSgReadyInputOne(); void updateSgReadyState();
void updateSgReadyInputTwo();
signals: signals:
void initializationFinished(); void initializationFinished();
@ -203,10 +197,9 @@ signals:
void consumedEnergyHotWaterChanged(quint32 consumedEnergyHotWater); void consumedEnergyHotWaterChanged(quint32 consumedEnergyHotWater);
void operatingModeChanged(OperatingMode operatingMode); void operatingModeChanged(OperatingMode operatingMode);
void systemStatusChanged(quint16 systemStatus); void systemStatusChanged(quint16 systemStatus);
void sgReadyStateChanged(SmartGridState sgReadyState); void sgReadyStateROChanged(quint16 sgReadyStateRO);
void sgReadyActiveChanged(quint16 sgReadyActive); void sgReadyActiveChanged(quint16 sgReadyActive);
void sgReadyInputOneChanged(quint16 sgReadyInputOne); void sgReadyStateChanged(SmartGridState sgReadyState);
void sgReadyInputTwoChanged(quint16 sgReadyInputTwo);
protected: protected:
QModbusReply *readOutdoorTemperature(); QModbusReply *readOutdoorTemperature();
@ -227,10 +220,9 @@ protected:
QModbusReply *readConsumedEnergyHotWater(); QModbusReply *readConsumedEnergyHotWater();
QModbusReply *readOperatingMode(); QModbusReply *readOperatingMode();
QModbusReply *readSystemStatus(); QModbusReply *readSystemStatus();
QModbusReply *readSgReadyState(); QModbusReply *readSgReadyStateRO();
QModbusReply *readSgReadyActive(); QModbusReply *readSgReadyActive();
QModbusReply *readSgReadyInputOne(); QModbusReply *readSgReadyState();
QModbusReply *readSgReadyInputTwo();
float m_outdoorTemperature = 0; float m_outdoorTemperature = 0;
float m_flowTemperature = 0; float m_flowTemperature = 0;
@ -250,10 +242,9 @@ protected:
quint32 m_consumedEnergyHotWater = 0; quint32 m_consumedEnergyHotWater = 0;
OperatingMode m_operatingMode = OperatingModeStandby; OperatingMode m_operatingMode = OperatingModeStandby;
quint16 m_systemStatus = 0; quint16 m_systemStatus = 0;
SmartGridState m_sgReadyState = SmartGridStateModeTwo; quint16 m_sgReadyStateRO = 3;
quint16 m_sgReadyActive = 0; quint16 m_sgReadyActive = 0;
quint16 m_sgReadyInputOne = 0; SmartGridState m_sgReadyState = SmartGridStateModeThree;
quint16 m_sgReadyInputTwo = 0;
private: private:
quint16 m_slaveId = 1; quint16 m_slaveId = 1;