From 094bb44ed691e61b684980a813fb40f9c9f3430a Mon Sep 17 00:00:00 2001 From: biver Date: Mon, 25 Apr 2022 23:30:56 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D0=BC=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D1=85=D1=80=D0=B0=D0=BD=D0=B8=D1=82=D1=8C?= =?UTF-8?q?=20=D0=B2=D1=80=D0=B5=D0=BC=D1=8F=20=D0=BF=D0=BE=20=D1=88=D0=B0?= =?UTF-8?q?=D0=B1=D0=BB=D0=BE=D0=BD=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_svelte/items.json | 5 +++-- src/modules/system/Variable/Variable.cpp | 16 +++++++++++++++- src/modules/system/Variable/items.json | 5 +++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/data_svelte/items.json b/data_svelte/items.json index 69bdf142..8395e9f4 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -55,8 +55,9 @@ "widget": "", "page": "", "descr": "", - "int": "0", - "val": "0" + "int": "1", + "val": "0", + "dtFormat": "" }, { "header": "Модули управления" diff --git a/src/modules/system/Variable/Variable.cpp b/src/modules/system/Variable/Variable.cpp index e0d8b111..cc9037e5 100644 --- a/src/modules/system/Variable/Variable.cpp +++ b/src/modules/system/Variable/Variable.cpp @@ -1,15 +1,29 @@ #include "Global.h" #include "classes/IoTItem.h" +#include "classes/IoTRTC.h" +extern IoTRTC *watch; class Variable : public IoTItem { + private: + String _dtFormat; public: - Variable(String parameters): IoTItem(parameters) { } + Variable(String parameters): IoTItem(parameters) { + jsonRead(parameters, "dtFormat", _dtFormat); + _dtFormat = _dtFormat; + } // особенность данного модуля - просто хранение значения для сценария, нет событий // void setValue(IoTValue Value) { // value = Value; // } + + void doByInterval() { + if (_dtFormat != "") { + value.isDecimal = false; + value.valS = watch->gettime(_dtFormat + " "); + } + } }; void* getAPI_Variable(String subtype, String param) { diff --git a/src/modules/system/Variable/items.json b/src/modules/system/Variable/items.json index d86f6d58..4d36fa3d 100644 --- a/src/modules/system/Variable/items.json +++ b/src/modules/system/Variable/items.json @@ -9,7 +9,8 @@ "page": "", "descr": "", - "int": "0", - "val": "0" + "int": "1", + "val": "0", + "dtFormat": "" } ] \ No newline at end of file