modbuscommander: update action behavior and fix RTU crash on resource removal
This commit is contained in:
parent
015e25ee13
commit
28cc24029c
@ -387,7 +387,15 @@ void IntegrationPluginModbusCommander::thingRemoved(Thing *thing)
|
|||||||
qCDebug(dcModbusCommander()) << "Removing thing" << thing->name();
|
qCDebug(dcModbusCommander()) << "Removing thing" << thing->name();
|
||||||
if (thing->thingClassId() == modbusTCPClientThingClassId) {
|
if (thing->thingClassId() == modbusTCPClientThingClassId) {
|
||||||
ModbusTCPMaster *modbus = m_modbusTCPMasters.take(thing);
|
ModbusTCPMaster *modbus = m_modbusTCPMasters.take(thing);
|
||||||
|
if (modbus) {
|
||||||
|
modbus->deleteLater();
|
||||||
|
}
|
||||||
|
} else if (thing->thingClassId() == modbusRTUClientThingClassId) {
|
||||||
|
ModbusRtuMaster *modbus = m_modbusRtuMasters.take(thing);
|
||||||
modbus->deleteLater();
|
modbus->deleteLater();
|
||||||
|
if (modbus) {
|
||||||
|
modbus->deleteLater();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myThings().empty()) {
|
if (myThings().empty()) {
|
||||||
@ -426,12 +434,12 @@ void IntegrationPluginModbusCommander::onRequestExecuted(QUuid requestId, bool s
|
|||||||
{
|
{
|
||||||
if (m_asyncActions.contains(requestId)){
|
if (m_asyncActions.contains(requestId)){
|
||||||
ThingActionInfo *info = m_asyncActions.take(requestId);
|
ThingActionInfo *info = m_asyncActions.take(requestId);
|
||||||
|
info->thing()->setStateValue(m_connectedStateTypeId.value(info->thing()->thingClassId()), success);
|
||||||
if (success){
|
if (success){
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
} else {
|
} else {
|
||||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||||
}
|
}
|
||||||
info->thing()->setStateValue(m_connectedStateTypeId.value(info->thing()->thingClassId()), success);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_readRequests.contains(requestId)){
|
if (m_readRequests.contains(requestId)){
|
||||||
@ -689,7 +697,7 @@ void IntegrationPluginModbusCommander::writeRegister(Thing *thing, ThingActionIn
|
|||||||
info->finish(Thing::ThingErrorHardwareFailure);
|
info->finish(Thing::ThingErrorHardwareFailure);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
thing->setStateValue("value", action.param(coilValueActionValueParamTypeId).value().toBool());
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
});
|
});
|
||||||
} else if (thing->thingClassId() == holdingRegisterThingClassId) {
|
} else if (thing->thingClassId() == holdingRegisterThingClassId) {
|
||||||
@ -705,6 +713,7 @@ void IntegrationPluginModbusCommander::writeRegister(Thing *thing, ThingActionIn
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thing->setStateValue("value", action.param(holdingRegisterValueActionValueParamTypeId).value().toUInt());
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,7 +62,6 @@
|
|||||||
"id": "725b541a-9e0c-4634-81eb-e415c0b8f012",
|
"id": "725b541a-9e0c-4634-81eb-e415c0b8f012",
|
||||||
"name": "connected",
|
"name": "connected",
|
||||||
"displayName": "Connected",
|
"displayName": "Connected",
|
||||||
"displayNameEvent": "Connection status changed",
|
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
}
|
}
|
||||||
@ -88,7 +87,6 @@
|
|||||||
"id": "dffc59fe-b230-4345-81d6-0a55f9e16520",
|
"id": "dffc59fe-b230-4345-81d6-0a55f9e16520",
|
||||||
"name": "connected",
|
"name": "connected",
|
||||||
"displayName": "Connected",
|
"displayName": "Connected",
|
||||||
"displayNameEvent": "Connection status changed",
|
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
}
|
}
|
||||||
@ -106,14 +104,14 @@
|
|||||||
"name": "slaveAddress",
|
"name": "slaveAddress",
|
||||||
"displayName": "Slave address",
|
"displayName": "Slave address",
|
||||||
"type": "uint",
|
"type": "uint",
|
||||||
"defaultValue": 180
|
"defaultValue": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "9d40c4ce-d251-43bb-a55e-a8780567bbac",
|
"id": "9d40c4ce-d251-43bb-a55e-a8780567bbac",
|
||||||
"name": "registerAddress",
|
"name": "registerAddress",
|
||||||
"displayName": "Register address",
|
"displayName": "Register address",
|
||||||
"type": "uint",
|
"type": "uint",
|
||||||
"defaultValue": 100
|
"defaultValue": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
@ -121,7 +119,6 @@
|
|||||||
"id": "9b3852ac-1518-4417-8a0a-452fcfec8963",
|
"id": "9b3852ac-1518-4417-8a0a-452fcfec8963",
|
||||||
"name": "connected",
|
"name": "connected",
|
||||||
"displayName": "Connected",
|
"displayName": "Connected",
|
||||||
"displayNameEvent": "Connection status changed",
|
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
},
|
},
|
||||||
@ -130,7 +127,6 @@
|
|||||||
"name": "value",
|
"name": "value",
|
||||||
"displayName": "Value",
|
"displayName": "Value",
|
||||||
"displayNameAction": "Write value",
|
"displayNameAction": "Write value",
|
||||||
"displayNameEvent": "Value changed",
|
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"writable": true,
|
"writable": true,
|
||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
@ -149,14 +145,14 @@
|
|||||||
"name": "slaveAddress",
|
"name": "slaveAddress",
|
||||||
"displayName": "Slave address",
|
"displayName": "Slave address",
|
||||||
"type": "uint",
|
"type": "uint",
|
||||||
"defaultValue": 180
|
"defaultValue": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "d37be0cc-6155-4894-b70f-cbc9adfbe48b",
|
"id": "d37be0cc-6155-4894-b70f-cbc9adfbe48b",
|
||||||
"name": "registerAddress",
|
"name": "registerAddress",
|
||||||
"displayName": "Register address",
|
"displayName": "Register address",
|
||||||
"type": "uint",
|
"type": "uint",
|
||||||
"defaultValue": 100
|
"defaultValue": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
@ -165,16 +161,14 @@
|
|||||||
"name": "connected",
|
"name": "connected",
|
||||||
"displayName": "Connected",
|
"displayName": "Connected",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false,
|
"defaultValue": false
|
||||||
"displayNameEvent": "connection status changed"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "c772bd7f-6e51-4b28-b182-3b979c1298ce",
|
"id": "c772bd7f-6e51-4b28-b182-3b979c1298ce",
|
||||||
"name": "value",
|
"name": "value",
|
||||||
"displayName": "Value",
|
"displayName": "Value",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false,
|
"defaultValue": false
|
||||||
"displayNameEvent": "value changed"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -190,14 +184,14 @@
|
|||||||
"name": "slaveAddress",
|
"name": "slaveAddress",
|
||||||
"displayName": "Slave address",
|
"displayName": "Slave address",
|
||||||
"type": "uint",
|
"type": "uint",
|
||||||
"defaultValue": 180
|
"defaultValue": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "264e381c-d259-4e11-b4b3-332b518ebba3",
|
"id": "264e381c-d259-4e11-b4b3-332b518ebba3",
|
||||||
"name": "registerAddress",
|
"name": "registerAddress",
|
||||||
"displayName": "Register address",
|
"displayName": "Register address",
|
||||||
"type": "uint",
|
"type": "uint",
|
||||||
"defaultValue": 100
|
"defaultValue": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
@ -206,16 +200,14 @@
|
|||||||
"name": "connected",
|
"name": "connected",
|
||||||
"displayName": "Connected",
|
"displayName": "Connected",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false,
|
"defaultValue": false
|
||||||
"displayNameEvent": "Connection status changed"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "eabe2d1b-abe5-4063-adab-3cdd8500b286",
|
"id": "eabe2d1b-abe5-4063-adab-3cdd8500b286",
|
||||||
"name": "Value",
|
"name": "Value",
|
||||||
"displayName": "Value",
|
"displayName": "Value",
|
||||||
"type": "int",
|
"type": "int",
|
||||||
"defaultValue": 0,
|
"defaultValue": 0
|
||||||
"displayNameEvent": "Value received"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -231,14 +223,14 @@
|
|||||||
"name": "slaveAddress",
|
"name": "slaveAddress",
|
||||||
"displayName": "Slave address",
|
"displayName": "Slave address",
|
||||||
"type": "uint",
|
"type": "uint",
|
||||||
"defaultValue": 180
|
"defaultValue": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "c771e09e-15fe-4ea9-9662-c44e2df556a8",
|
"id": "c771e09e-15fe-4ea9-9662-c44e2df556a8",
|
||||||
"name": "registerAddress",
|
"name": "registerAddress",
|
||||||
"displayName": "Register address",
|
"displayName": "Register address",
|
||||||
"type": "uint",
|
"type": "uint",
|
||||||
"defaultValue": 100
|
"defaultValue": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
@ -246,7 +238,6 @@
|
|||||||
"id": "1f55b72a-5d13-4ae1-b136-bfd84fd9761f",
|
"id": "1f55b72a-5d13-4ae1-b136-bfd84fd9761f",
|
||||||
"name": "connected",
|
"name": "connected",
|
||||||
"displayName": "Connected",
|
"displayName": "Connected",
|
||||||
"displayNameEvent": "Connection status changed",
|
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
},
|
},
|
||||||
@ -255,10 +246,9 @@
|
|||||||
"name": "value",
|
"name": "value",
|
||||||
"displayName": "Value",
|
"displayName": "Value",
|
||||||
"displayNameAction": "Write value",
|
"displayNameAction": "Write value",
|
||||||
"displayNameEvent": "Value changed",
|
"type": "uint",
|
||||||
"type": "int",
|
|
||||||
"writable": true,
|
"writable": true,
|
||||||
"defaultValue": false
|
"defaultValue": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user