fixed myPV timer initialization
This commit is contained in:
parent
5b8291b29c
commit
9d75fb9dcc
@ -134,6 +134,11 @@ void IntegrationPluginMyPv::setupThing(ThingSetupInfo *info)
|
|||||||
|
|
||||||
void IntegrationPluginMyPv::postSetupThing(Thing *thing)
|
void IntegrationPluginMyPv::postSetupThing(Thing *thing)
|
||||||
{
|
{
|
||||||
|
if (!m_refreshTimer) {
|
||||||
|
m_refreshTimer = hardwareManager()->pluginTimerManager()->registerTimer(10);
|
||||||
|
connect(m_refreshTimer, &PluginTimer::timeout, this, &IntegrationPluginMyPv::onRefreshTimer);
|
||||||
|
}
|
||||||
|
|
||||||
if (thing->thingClassId() == elwaThingClassId) {
|
if (thing->thingClassId() == elwaThingClassId) {
|
||||||
update(thing);
|
update(thing);
|
||||||
}
|
}
|
||||||
@ -145,6 +150,11 @@ void IntegrationPluginMyPv::thingRemoved(Thing *thing)
|
|||||||
ModbusTCPMaster *modbusTCPMaster = m_modbusTcpMasters.take(thing);
|
ModbusTCPMaster *modbusTCPMaster = m_modbusTcpMasters.take(thing);
|
||||||
modbusTCPMaster->deleteLater();
|
modbusTCPMaster->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (myThings().isEmpty()) {
|
||||||
|
hardwareManager()->pluginTimerManager()->unregisterTimer(m_refreshTimer);
|
||||||
|
m_refreshTimer = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginMyPv::executeAction(ThingActionInfo *info)
|
void IntegrationPluginMyPv::executeAction(ThingActionInfo *info)
|
||||||
@ -179,11 +189,12 @@ void IntegrationPluginMyPv::executeAction(ThingActionInfo *info)
|
|||||||
Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8());
|
Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT_X(false, "executeAction", QString("Unhandled deviceClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginMyPv::onRefreshTimer(){
|
void IntegrationPluginMyPv::onRefreshTimer()
|
||||||
|
{
|
||||||
|
|
||||||
foreach (Thing *thing, myThings()) {
|
foreach (Thing *thing, myThings()) {
|
||||||
update(thing);
|
update(thing);
|
||||||
|
|||||||
@ -11,4 +11,3 @@ SOURCES += \
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
integrationpluginmypv.h \
|
integrationpluginmypv.h \
|
||||||
../modbus/modbustcpmaster.h \
|
../modbus/modbustcpmaster.h \
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user