Skip to content

Commit

Permalink
Some little fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Apr 3, 2024
1 parent b16e4da commit 2d2a104
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion include/YaSolR.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ extern Mycila::TemperatureSensor output2TemperatureSensor;
extern Mycila::TemperatureSensor systemTemperatureSensor;

extern Mycila::TaskManager loopTaskManager;
extern Mycila::TaskManager meterTaskManager;
// extern Mycila::TaskManager meterTaskManager;
extern Mycila::TaskManager routerTaskManager;

extern Mycila::Task assignOutput1PZEMTask;
Expand Down
18 changes: 9 additions & 9 deletions include/YaSolRMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@

// default settings

#ifndef YASOLR_METER_TASK_PRIORITY
#define YASOLR_METER_TASK_PRIORITY 1
#endif
// #ifndef YASOLR_METER_TASK_PRIORITY
// #define YASOLR_METER_TASK_PRIORITY 1
// #endif

#ifndef YASOLR_METER_TASK_STACK
#define YASOLR_METER_TASK_STACK 256 * 12
#endif
// #ifndef YASOLR_METER_TASK_STACK
// #define YASOLR_METER_TASK_STACK 256 * 12
// #endif

#ifndef YASOLR_METER_TASK_CORE
#define YASOLR_METER_TASK_CORE 0
#endif
// #ifndef YASOLR_METER_TASK_CORE
// #define YASOLR_METER_TASK_CORE 0
// #endif

#ifndef YASOLR_ROUTER_TASK_PRIORITY
#define YASOLR_ROUTER_TASK_PRIORITY 1
Expand Down
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ build_flags =
-Wunused -Wmisleading-indentation -Wduplicated-cond -Wlogical-op -Wnull-dereference
-std=c++17
-std=gnu++17
-D ARDUINO_LOOP_STACK_SIZE=256*18
-D ARDUINO_LOOP_STACK_SIZE=256*20
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1
-D CONFIG_ASYNC_TCP_STACK_SIZE=256*15
-D CONFIG_ETH_ENABLED
Expand All @@ -79,7 +79,7 @@ build_flags =
-D MYCILA_JSY_JSON_SUPPORT
-D MYCILA_MQTT_BUFFER_SIZE=256
-D MYCILA_MQTT_STACK_SIZE=256*15
-D MYCILA_MQTT_TASK_PRIORITY=2
-D MYCILA_MQTT_TASK_PRIORITY=1
-D MYCILA_NTP_JSON_SUPPORT
-D MYCILA_PZEM_JSON_SUPPORT
-D MYCILA_RELAY_JSON_SUPPORT
Expand Down
2 changes: 1 addition & 1 deletion src/YaSolR_API_REST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void YaSolR::YaSolRClass::_initREST() {
Mycila::Lights.toJson(root["lights"].to<JsonObject>());
Mycila::TaskMonitor.toJson(root["stack"].to<JsonObject>());
loopTaskManager.toJson(root["task_managers"][0].to<JsonObject>());
meterTaskManager.toJson(root["task_managers"][1].to<JsonObject>());
// meterTaskManager.toJson(root["task_managers"][1].to<JsonObject>());
routerTaskManager.toJson(root["task_managers"][2].to<JsonObject>());
systemTemperatureSensor.toJson(root["temp_sensor"].to<JsonObject>());
response->setLength();
Expand Down
14 changes: 8 additions & 6 deletions src/YaSolR_Tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static const Mycila::TaskPredicate DEBUG_ENABLED = []() {
return Mycila::Logger.isDebugEnabled();
};
static const Mycila::TaskDoneCallback LOG_EXEC_TIME = [](const Mycila::Task& me, const uint32_t elapsed) {
Mycila::Logger.debug(TAG, "%s in %u ms", me.getName(), elapsed / Mycila::TaskDuration::MILLISECONDS);
Mycila::Logger.debug(TAG, "%s in %u us", me.getName(), elapsed);
};

// Core tasks
Expand All @@ -23,7 +23,7 @@ Mycila::Task lightsTask("Lights", [](void* params) { Mycila::Lights.setYellow(re
Mycila::Task stackMonitorTask("TaskMonitor.log()", [](void* params) { Mycila::TaskMonitor.log(); });
Mycila::Task profilerTask("TaskManager.log()", [](void* params) {
loopTaskManager.log();
meterTaskManager.log();
// meterTaskManager.log();
routerTaskManager.log();
});
Mycila::Task systemTemperatureTask("systemTemperatureSensor.read()", [](void* params) {
Expand Down Expand Up @@ -425,7 +425,7 @@ Mycila::Task configureTaskMonitorTask("configureTaskMonitorTask", [](void* param
Mycila::TaskMonitor.begin(5);
Mycila::TaskMonitor.addTask("async_tcp"); // ESPAsyncTCP
Mycila::TaskMonitor.addTask("loopTask"); // Arduino
Mycila::TaskMonitor.addTask("meterTask"); // YaSolR
// Mycila::TaskMonitor.addTask("meterTask"); // YaSolR
Mycila::TaskMonitor.addTask("mqtt_task"); // NycilaMQTT
Mycila::TaskMonitor.addTask("routerTask"); // YaSolR
});
Expand Down Expand Up @@ -455,7 +455,7 @@ Mycila::Task configureDebugTask("configureDebugTask", [](void* params) {
} else {
Mycila::Logger.info(TAG, "Disable profiling for all tasks");
loopTaskManager.disableProfiling();
meterTaskManager.disableProfiling();
// meterTaskManager.disableProfiling();
routerTaskManager.disableProfiling();
}
});
Expand Down Expand Up @@ -551,12 +551,14 @@ void YaSolR::YaSolRClass::_initTasks() {
// jsyTask.setInterval(100 * Mycila::TaskDuration::MILLISECONDS);

output1PZEMTask.setType(Mycila::TaskType::FOREVER);
output1PZEMTask.setManager(&meterTaskManager);
// output1PZEMTask.setManager(&meterTaskManager);
output1PZEMTask.setManager(&routerTaskManager);
output1PZEMTask.setEnabledWhen([]() { return output1PZEM.isEnabled() && !assignOutput1PZEMTask.isRunning() && !assignOutput2PZEMTask.isRunning(); });
// output1PZEMTask.setInterval(100 * Mycila::TaskDuration::MILLISECONDS);

output2PZEMTask.setType(Mycila::TaskType::FOREVER);
output2PZEMTask.setManager(&meterTaskManager);
// output2PZEMTask.setManager(&meterTaskManager);
output2PZEMTask.setManager(&routerTaskManager);
output2PZEMTask.setEnabledWhen([]() { return output2PZEM.isEnabled() && !assignOutput1PZEMTask.isRunning() && !assignOutput2PZEMTask.isRunning(); });
// output2PZEMTask.setInterval(100 * Mycila::TaskDuration::MILLISECONDS);

Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#define TAG "YASOLR"

Mycila::TaskManager loopTaskManager("loopTask", 49);
Mycila::TaskManager meterTaskManager("meterTask", 2);
Mycila::TaskManager routerTaskManager("routerTask", 1);
// Mycila::TaskManager meterTaskManager("meterTask", 2);
Mycila::TaskManager routerTaskManager("routerTask", 3);

// TODO: switch to PsychicHttp (when WS perf will be better)
AsyncWebServer webServer(80);
Expand Down Expand Up @@ -121,7 +121,7 @@ void setup() {
configureNetworkTask.forceRun();

assert(routerTaskManager.asyncStart(YASOLR_ROUTER_TASK_STACK, YASOLR_ROUTER_TASK_PRIORITY, YASOLR_ROUTER_TASK_CORE));
assert(meterTaskManager.asyncStart(YASOLR_METER_TASK_STACK, YASOLR_METER_TASK_PRIORITY, YASOLR_METER_TASK_CORE));
// assert(meterTaskManager.asyncStart(YASOLR_METER_TASK_STACK, YASOLR_METER_TASK_PRIORITY, YASOLR_METER_TASK_CORE));

// STARTUP READY!
Mycila::Logger.info(TAG, "Started %s %s %s", Mycila::AppInfo.name.c_str(), Mycila::AppInfo.model.c_str(), Mycila::AppInfo.version.c_str());
Expand Down

0 comments on commit 2d2a104

Please sign in to comment.