Merge PR #83: Schrack: Only complete the setup if reading a register actually works
commit
b2fb3fb53b
|
|
@ -161,6 +161,16 @@
|
||||||
"unit": "A",
|
"unit": "A",
|
||||||
"defaultValue": 13,
|
"defaultValue": 13,
|
||||||
"access": "R"
|
"access": "R"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "dipSwitches",
|
||||||
|
"address": 700,
|
||||||
|
"size": 1,
|
||||||
|
"type": "uint16",
|
||||||
|
"registerType": "holdingRegister",
|
||||||
|
"readSchedule": "init",
|
||||||
|
"description": "DIP switch states",
|
||||||
|
"access": "R"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,25 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
|
||||||
|
|
||||||
CionModbusRtuConnection *cionConnection = new CionModbusRtuConnection(hardwareManager()->modbusRtuResource()->getModbusRtuMaster(uuid), address, this);
|
CionModbusRtuConnection *cionConnection = new CionModbusRtuConnection(hardwareManager()->modbusRtuResource()->getModbusRtuMaster(uuid), address, this);
|
||||||
|
|
||||||
|
connect(cionConnection, &CionModbusRtuConnection::reachableChanged, thing, [cionConnection, thing](bool reachable){
|
||||||
|
qCDebug(dcSchrack()) << "Reachable state changed" << reachable;
|
||||||
|
if (reachable) {
|
||||||
|
cionConnection->initialize();
|
||||||
|
} else {
|
||||||
|
thing->setStateValue("connected", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(cionConnection, &CionModbusRtuConnection::initializationFinished, info, [info, cionConnection](bool success){
|
||||||
|
qCDebug(dcSchrack()) << "Initialisation finsihed" << success;
|
||||||
|
if (success) {
|
||||||
|
qCDebug(dcSchrack) << "DIP switche states:" << cionConnection->dipSwitches();
|
||||||
|
info->finish(Thing::ThingErrorNoError);
|
||||||
|
} else {
|
||||||
|
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
connect(cionConnection, &CionModbusRtuConnection::updateFinished, thing, [cionConnection, thing](){
|
connect(cionConnection, &CionModbusRtuConnection::updateFinished, thing, [cionConnection, thing](){
|
||||||
qCDebug(dcSchrack()) << "Update finished:" << thing->name() << cionConnection;
|
qCDebug(dcSchrack()) << "Update finished:" << thing->name() << cionConnection;
|
||||||
});
|
});
|
||||||
|
|
@ -183,7 +202,6 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
|
||||||
thing->setStateMinMaxValues(cionMaxChargingCurrentStateTypeId, 6, 32);
|
thing->setStateMinMaxValues(cionMaxChargingCurrentStateTypeId, 6, 32);
|
||||||
|
|
||||||
m_cionConnections.insert(thing, cionConnection);
|
m_cionConnections.insert(thing, cionConnection);
|
||||||
info->finish(Thing::ThingErrorNoError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginSchrack::postSetupThing(Thing *thing)
|
void IntegrationPluginSchrack::postSetupThing(Thing *thing)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue