mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
scheduler task priority, add comments
This commit is contained in:
@@ -39,7 +39,7 @@ void WebSchedulerService::begin() {
|
|||||||
snprintf(topic, sizeof(topic), "%s/#", F_(scheduler));
|
snprintf(topic, sizeof(topic), "%s/#", F_(scheduler));
|
||||||
Mqtt::subscribe(EMSdevice::DeviceType::SCHEDULER, topic, nullptr); // use empty function callback
|
Mqtt::subscribe(EMSdevice::DeviceType::SCHEDULER, topic, nullptr); // use empty function callback
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
xTaskCreate((TaskFunction_t)scheduler_task, "scheduler_task", 4096, NULL, 3, NULL);
|
xTaskCreate((TaskFunction_t)scheduler_task, "scheduler_task", 4096, NULL, 1, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,6 +192,15 @@ bool WebSchedulerService::get_value_info(JsonObject output, const char * cmd) {
|
|||||||
char result[12];
|
char result[12];
|
||||||
output["value"] = Helpers::render_boolean(result, scheduleItem.active);
|
output["value"] = Helpers::render_boolean(result, scheduleItem.active);
|
||||||
}
|
}
|
||||||
|
if (scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_CONDITION) {
|
||||||
|
output["condition"] = scheduleItem.time;
|
||||||
|
} else if (scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_ONCHANGE) {
|
||||||
|
output["onchange"] = scheduleItem.time;
|
||||||
|
} else if (scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_TIMER) {
|
||||||
|
output["timer"] = scheduleItem.time;
|
||||||
|
} else {
|
||||||
|
output["time"] = scheduleItem.time;
|
||||||
|
}
|
||||||
output["command"] = scheduleItem.cmd;
|
output["command"] = scheduleItem.cmd;
|
||||||
output["cmd_data"] = scheduleItem.value;
|
output["cmd_data"] = scheduleItem.value;
|
||||||
output["readable"] = true;
|
output["readable"] = true;
|
||||||
@@ -426,8 +435,8 @@ bool WebSchedulerService::command(const char * name, const std::string & command
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "shuntingYard.hpp"
|
// called from emsesp.cpp on every entity-change
|
||||||
|
// queue schedules to be handled executed in scheduler-loop
|
||||||
bool WebSchedulerService::onChange(const char * cmd) {
|
bool WebSchedulerService::onChange(const char * cmd) {
|
||||||
for (ScheduleItem & scheduleItem : *scheduleItems_) {
|
for (ScheduleItem & scheduleItem : *scheduleItems_) {
|
||||||
if (scheduleItem.active && scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_ONCHANGE
|
if (scheduleItem.active && scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_ONCHANGE
|
||||||
@@ -439,6 +448,9 @@ bool WebSchedulerService::onChange(const char * cmd) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "shuntingYard.hpp"
|
||||||
|
|
||||||
|
// handle condition schedules, parse string stored in schedule.time field
|
||||||
void WebSchedulerService::condition() {
|
void WebSchedulerService::condition() {
|
||||||
for (ScheduleItem & scheduleItem : *scheduleItems_) {
|
for (ScheduleItem & scheduleItem : *scheduleItems_) {
|
||||||
if (scheduleItem.active && scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_CONDITION) {
|
if (scheduleItem.active && scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_CONDITION) {
|
||||||
@@ -529,6 +541,7 @@ void WebSchedulerService::loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// process schedules async
|
||||||
void WebSchedulerService::scheduler_task(void * pvParameters) {
|
void WebSchedulerService::scheduler_task(void * pvParameters) {
|
||||||
while (1) {
|
while (1) {
|
||||||
delay(100); // no need to hurry
|
delay(100); // no need to hurry
|
||||||
|
|||||||
Reference in New Issue
Block a user