Skip to content

Commit

Permalink
Fix routing task
Browse files Browse the repository at this point in the history
(cherry picked from commit e0413c84fa449aa41ad8500a25e20d436ef557bc)
  • Loading branch information
mathieucarbou committed Jul 15, 2024
1 parent 169693f commit 2cba0c2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/init/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Mycila::Task initConfigTask("Init Config", [](void* params) {
relayTask.setInterval(7 * Mycila::TaskDuration::SECONDS);
routerTask.setInterval(537 * Mycila::TaskDuration::MILLISECONDS);
routingTask.setEnabledWhen([]() { return output1.isAutoDimmerEnabled() || output2.isAutoDimmerEnabled(); });
routingTask.setInterval(1000 * Mycila::TaskDuration::MILLISECONDS);
#ifdef APP_MODEL_TRIAL
trialTask.setInterval(30 * Mycila::TaskDuration::SECONDS);
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/init/Events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,11 @@ Mycila::Task initEventsTask("Init Events", [](void* params) {
});

jsy.setCallback([](const Mycila::JSYEventType eventType) {
if (eventType == Mycila::JSYEventType::EVT_CHANGE) {
if (eventType == Mycila::JSYEventType::EVT_READ) {
Mycila::JSYData data;
jsy.getData(data);
if (grid.updateJSYData(data)) {
routingTask.resume();
routingTask.requestEarlyRun();
}
}
});
Expand Down Expand Up @@ -371,7 +371,7 @@ Mycila::Task initEventsTask("Init Events", [](void* params) {
udpMessageRateBuffer.add(millis() / 1000.0f);

if (grid.updateRemoteJSYData(jsyData)) {
routingTask.resume();
routingTask.requestEarlyRun();
}
});
});
2 changes: 1 addition & 1 deletion src/init/MQTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Mycila::Task initMqttSubscribersTask("Init MQTT Subscribers", [](void* params) {
float p = payload.toFloat();
logger.info(TAG, "Grid Power from MQTT: %f", p);
if (grid.updateMQTTGridPower(p))
routingTask.resume();
routingTask.requestEarlyRun();
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/tasks/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Mycila::Task relayTask("Relay", [](void* params) {
return;
});

Mycila::Task routingTask("Routing", Mycila::TaskType::ONCE, [](void* params) {
Mycila::Task routingTask("Routing", [](void* params) {
Mycila::GridMetrics gridMetrics;
grid.getMeasurements(gridMetrics);
router.divert(gridMetrics.voltage, gridMetrics.power);
Expand Down

0 comments on commit 2cba0c2

Please sign in to comment.