From 05fef853e43d22da707262e099009e245158d028 Mon Sep 17 00:00:00 2001 From: TD-er Date: Sun, 27 Sep 2020 13:09:58 +0200 Subject: [PATCH] Add stubs for new controllers up-to C025 --- src/_CPlugin_Helper.h | 3 ++ src/__CPlugin.ino | 9 ++-- .../ControllerDelayHandlerStruct.h | 5 +- .../ControllerQueue/DelayQueueElements.cpp | 40 +++++++++++++-- src/src/ControllerQueue/DelayQueueElements.h | 38 ++++++++++++-- src/src/Helpers/Scheduler.cpp | 51 ++++++++++++++++++- src/src/Helpers/Scheduler.h | 8 +++ 7 files changed, 142 insertions(+), 12 deletions(-) diff --git a/src/_CPlugin_Helper.h b/src/_CPlugin_Helper.h index 6905aadaa9..be0ba1cbca 100644 --- a/src/_CPlugin_Helper.h +++ b/src/_CPlugin_Helper.h @@ -2,6 +2,9 @@ #define CPLUGIN_HELPER_H CPLUGIN_HELPER_H #include + +#include "ESPEasy_common.h" + #include "src/Globals/CPlugins.h" #include "src/Globals/ESPEasy_Scheduler.h" #include "src/Helpers/Numerical.h" diff --git a/src/__CPlugin.ino b/src/__CPlugin.ino index 5bb773ffb0..e045c82e1b 100644 --- a/src/__CPlugin.ino +++ b/src/__CPlugin.ino @@ -1,3 +1,5 @@ +#include "ESPEasy_common.h" + #include "src/Globals/CPlugins.h" #include "src/Globals/Protocol.h" #include "src/Globals/Settings.h" @@ -6,9 +8,6 @@ #include "src/DataStructs/ESPEasy_plugin_functions.h" #include "src/DataStructs/TimingStats.h" -#include "ESPEasy_common.h" - - // ******************************************************************************** // Initialize all Controller CPlugins that where defined earlier @@ -148,6 +147,10 @@ void CPluginInit(void) ADDCPLUGIN(025) #endif +// When extending this, search for EXTEND_CONTROLLER_IDS +// in the code to find all places that need to be updated too. + + CPluginCall(CPlugin::Function::CPLUGIN_PROTOCOL_ADD, 0); // Set all not supported cplugins to disabled. diff --git a/src/src/ControllerQueue/ControllerDelayHandlerStruct.h b/src/src/ControllerQueue/ControllerDelayHandlerStruct.h index cd2e102969..0ab70f1e59 100644 --- a/src/src/ControllerQueue/ControllerDelayHandlerStruct.h +++ b/src/src/ControllerQueue/ControllerDelayHandlerStruct.h @@ -13,8 +13,11 @@ #include "../Helpers/Scheduler.h" #include "../Helpers/StringConverter.h" +#include #include #include // For std::shared_ptr +#include // std::nothrow + /*********************************************************************************************\ * ControllerDelayHandlerStruct @@ -234,7 +237,7 @@ struct ControllerDelayHandlerStruct { } \ bool init_c##NNN####M##_delay_queue(controllerIndex_t ControllerIndex) { \ if (C##NNN####M##_DelayHandler == nullptr) { \ - C##NNN####M##_DelayHandler = new (std::nothrow) C##NNN####M##_DelayHandler_t; \ + C##NNN####M##_DelayHandler = new (std::nothrow) (C##NNN####M##_DelayHandler_t); \ } \ if (C##NNN####M##_DelayHandler == nullptr) { return false; } \ MakeControllerSettings(ControllerSettings); \ diff --git a/src/src/ControllerQueue/DelayQueueElements.cpp b/src/src/ControllerQueue/DelayQueueElements.cpp index 04e82d729b..5b013257d2 100644 --- a/src/src/ControllerQueue/DelayQueueElements.cpp +++ b/src/src/ControllerQueue/DelayQueueElements.cpp @@ -1,5 +1,8 @@ #include "DelayQueueElements.h" +#include "../DataStructs/ControllerSettingsStruct.h" +#include "../DataStructs/TimingStats.h" +#include "../Globals/ESPEasy_Scheduler.h" #ifdef USES_MQTT ControllerDelayHandlerStruct *MQTTDelayHandler = nullptr; @@ -11,7 +14,7 @@ bool init_mqtt_delay_queue(controllerIndex_t ControllerIndex, String& pubname, b } LoadControllerSettings(ControllerIndex, ControllerSettings); if (MQTTDelayHandler == nullptr) { - MQTTDelayHandler = new (std::nothrow) ControllerDelayHandlerStruct; + MQTTDelayHandler = new (std::nothrow) ControllerDelayHandlerStruct; } if (MQTTDelayHandler == nullptr) { return false; @@ -145,6 +148,37 @@ DEFINE_Cxxx_DELAY_QUEUE_MACRO_CPP(0, 18) #endif */ +/* + #ifdef USES_C021 + DEFINE_Cxxx_DELAY_QUEUE_MACRO_CPP(0, 21) + #endif + */ + +/* + #ifdef USES_C022 + DEFINE_Cxxx_DELAY_QUEUE_MACRO_CPP(0, 22) + #endif + */ + +/* + #ifdef USES_C023 + DEFINE_Cxxx_DELAY_QUEUE_MACRO_CPP(0, 23) + #endif + */ + +/* + #ifdef USES_C024 + DEFINE_Cxxx_DELAY_QUEUE_MACRO_CPP(0, 24) + #endif + */ + +/* + #ifdef USES_C025 + DEFINE_Cxxx_DELAY_QUEUE_MACRO_CPP(0, 25) + #endif + */ + + -// When extending this, also extend in Scheduler.cpp: -// void process_interval_timer(unsigned long id, unsigned long lasttimer) \ No newline at end of file +// When extending this, search for EXTEND_CONTROLLER_IDS +// in the code to find all places that need to be updated too. diff --git a/src/src/ControllerQueue/DelayQueueElements.h b/src/src/ControllerQueue/DelayQueueElements.h index 2282c8fc90..9177f168fa 100644 --- a/src/src/ControllerQueue/DelayQueueElements.h +++ b/src/src/ControllerQueue/DelayQueueElements.h @@ -1,14 +1,16 @@ #ifndef DELAY_QUEUE_ELEMENTS_H #define DELAY_QUEUE_ELEMENTS_H + #include "../../ESPEasy_common.h" -#include "../DataStructs/ControllerSettingsStruct.h" #include "../../ESPEasy_fdwdecl.h" #include "../ControllerQueue/ControllerDelayHandlerStruct.h" #include "../ControllerQueue/SimpleQueueElement_string_only.h" #include "../ControllerQueue/queue_element_single_value_base.h" +#include "../DataStructs/ControllerSettingsStruct.h" + // The most logical place to have these queue element handlers defined would be in their // respective _Cxxx.ino file. @@ -156,9 +158,39 @@ DEFINE_Cxxx_DELAY_QUEUE_MACRO(0, 18) #endif */ +/* + #ifdef USES_C021 + DEFINE_Cxxx_DELAY_QUEUE_MACRO(0, 21) + #endif + */ + +/* + #ifdef USES_C022 + DEFINE_Cxxx_DELAY_QUEUE_MACRO(0, 22) + #endif + */ + +/* + #ifdef USES_C023 + DEFINE_Cxxx_DELAY_QUEUE_MACRO(0, 23) + #endif + */ + +/* + #ifdef USES_C024 + DEFINE_Cxxx_DELAY_QUEUE_MACRO(0, 24) + #endif + */ + +/* + #ifdef USES_C025 + DEFINE_Cxxx_DELAY_QUEUE_MACRO(0, 25) + #endif + */ + -// When extending this, also extend in Scheduler.cpp: -// void process_interval_timer(unsigned long id, unsigned long lasttimer) +// When extending this, search for EXTEND_CONTROLLER_IDS +// in the code to find all places that need to be updated too. #endif // ifndef DELAY_QUEUE_ELEMENTS_H diff --git a/src/src/Helpers/Scheduler.cpp b/src/src/Helpers/Scheduler.cpp index 8346e52680..c96fd49bb2 100644 --- a/src/src/Helpers/Scheduler.cpp +++ b/src/src/Helpers/Scheduler.cpp @@ -211,6 +211,13 @@ void ESPEasy_Scheduler::setIntervalTimer(IntervalTimer_e id, unsigned long lastt case IntervalTimer_e::TIMER_C018_DELAY_QUEUE: case IntervalTimer_e::TIMER_C019_DELAY_QUEUE: case IntervalTimer_e::TIMER_C020_DELAY_QUEUE: + case IntervalTimer_e::TIMER_C021_DELAY_QUEUE: + case IntervalTimer_e::TIMER_C022_DELAY_QUEUE: + case IntervalTimer_e::TIMER_C023_DELAY_QUEUE: + case IntervalTimer_e::TIMER_C024_DELAY_QUEUE: + case IntervalTimer_e::TIMER_C025_DELAY_QUEUE: + // When extending this, search for EXTEND_CONTROLLER_IDS + // in the code to find all places that need to be updated too. interval = 1000; break; } unsigned long timer = lasttimer; @@ -368,8 +375,48 @@ void ESPEasy_Scheduler::process_interval_timer(IntervalTimer_e id, unsigned long */ break; - // When extending this, also extend in DelayQueueElements.h - // Also make sure to extend the "TIMER_C020_DELAY_QUEUE" list of defines. + case IntervalTimer_e::TIMER_C021_DELAY_QUEUE: + /* + #ifdef USES_C021 + process_c021_delay_queue(); + #endif + */ + break; + + case IntervalTimer_e::TIMER_C022_DELAY_QUEUE: + /* + #ifdef USES_C022 + process_c022_delay_queue(); + #endif + */ + break; + + case IntervalTimer_e::TIMER_C023_DELAY_QUEUE: + /* + #ifdef USES_C023 + process_c023_delay_queue(); + #endif + */ + break; + + case IntervalTimer_e::TIMER_C024_DELAY_QUEUE: + /* + #ifdef USES_C024 + process_c024_delay_queue(); + #endif + */ + break; + + case IntervalTimer_e::TIMER_C025_DELAY_QUEUE: + /* + #ifdef USES_C025 + process_c025_delay_queue(); + #endif + */ + break; + + // When extending this, search for EXTEND_CONTROLLER_IDS + // in the code to find all places that need to be updated too. } } diff --git a/src/src/Helpers/Scheduler.h b/src/src/Helpers/Scheduler.h index b32daf22ee..1ef812420c 100644 --- a/src/src/Helpers/Scheduler.h +++ b/src/src/Helpers/Scheduler.h @@ -42,6 +42,14 @@ class ESPEasy_Scheduler { TIMER_C018_DELAY_QUEUE, TIMER_C019_DELAY_QUEUE, TIMER_C020_DELAY_QUEUE, + TIMER_C021_DELAY_QUEUE, + TIMER_C022_DELAY_QUEUE, + TIMER_C023_DELAY_QUEUE, + TIMER_C024_DELAY_QUEUE, + TIMER_C025_DELAY_QUEUE, + // When extending this, search for EXTEND_CONTROLLER_IDS + // in the code to find all places that need to be updated too. + }; enum class PluginPtrType {