diff --git a/data_svelte/items.json b/data_svelte/items.json index 6560cb13..d161eec1 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -308,12 +308,25 @@ "addr": "0x20", "index": 1 }, + { + "name": "23. Переменная", + "num": 23, + "type": "Reading", + "subtype": "Variable", + "id": "var", + "widget": "", + "page": "", + "descr": "", + + "int": "0", + "val": "0" + }, { "header": "Исполнительные устройства" }, { - "name": "23. Кнопка управляющая пином (Реле с кнопкой)", - "num": 23, + "name": "24. Кнопка управляющая пином (Реле с кнопкой)", + "num": 24, "type": "Writing", "subtype": "ButtonOut", "id": "btn", diff --git a/data_svelte/scenario.txt b/data_svelte/scenario.txt index 1ea6a563..f0255d3a 100644 --- a/data_svelte/scenario.txt +++ b/data_svelte/scenario.txt @@ -1,14 +1,4 @@ -#if x > 3 then 1 else x()/2 * x+2; #обратите внимание на приоритет операций -#if 1 < 3 then 1 else 2-1*1+2; -#if 5 < 3 then 1+4 else 2*1*1+2; -#if btn1=1 then rel2 = 1 else rel2 = 0; -#if bt1=1 | timenow>"07:00" then rel2 = 1; -#if 1 < 3 then par+4 else 2*1*1+2 -#if 1 < 3 then "par de" else 3*1*1+2 -#if rel3.run() > 30 then rel2.run(3, 45.1, "wert") else 3*1*1+2 -#if rel2 == 24 then "true" else "false" - -#if rel2 != 1 then {rel2 = 12 + 12; rel2 = rel2 + 10;} -#if rel2 != 24 then tablo.run("ddd") else "2222222222222" -if t22 > 10 then btn.change() - +#if t22 > 10 then var = var + 1; +#if var == 1 then btn1.change(); +#if var == 2 then btn2.change(); +#if var == 3 then { btn3.change(); var = 0;} \ No newline at end of file diff --git a/src/modules/API.cpp b/src/modules/API.cpp index 3ee9b279..df878315 100644 --- a/src/modules/API.cpp +++ b/src/modules/API.cpp @@ -16,6 +16,7 @@ void* getAPI_SysExt(String subtype, String params); void* getAPI_Ads1115(String subtype, String params); void* getAPI_Mcp23017(String subtype, String params); void* getAPI_ButtonOut(String subtype, String params); +void* getAPI_Variable(String subtype, String params); //============================================================================================ void* getAPI(String subtype, String params) { @@ -36,6 +37,7 @@ void* getAPI(String subtype, String params) { if ((tmpAPI = getAPI_Ads1115(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI; + if ((tmpAPI = getAPI_Variable(subtype, params)) != nullptr) return tmpAPI; //================================================================================================================ return nullptr; diff --git a/src/modules/Variable.cpp b/src/modules/Variable.cpp new file mode 100644 index 00000000..e0d8b111 --- /dev/null +++ b/src/modules/Variable.cpp @@ -0,0 +1,21 @@ +#include "Global.h" +#include "classes/IoTItem.h" + + +class Variable : public IoTItem { + public: + Variable(String parameters): IoTItem(parameters) { } + + // особенность данного модуля - просто хранение значения для сценария, нет событий + // void setValue(IoTValue Value) { + // value = Value; + // } +}; + +void* getAPI_Variable(String subtype, String param) { + if (subtype == F("Variable")) { + return new Variable(param); + } else { + return nullptr; + } +}