mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Merge pull request #146 from biveraxe/ver4dev
Добавляем переменные в систему как специальный Item
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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;}
|
||||
@@ -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;
|
||||
|
||||
21
src/modules/Variable.cpp
Normal file
21
src/modules/Variable.cpp
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user