From 613d60256af43fd2a3389e2ae28d82406b788005 Mon Sep 17 00:00:00 2001 From: biver Date: Sat, 26 Mar 2022 21:35:51 +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=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B2=D1=82=D0=BE=D1=80=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D1=82=D0=B0=D0=B9=D0=BC=D0=B5=D1=80?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/exec/Timer/Timer.cpp | 10 +++++++++- src/modules/exec/Timer/items.json | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/modules/exec/Timer/Timer.cpp b/src/modules/exec/Timer/Timer.cpp index d3a1724b..2e1251db 100644 --- a/src/modules/exec/Timer/Timer.cpp +++ b/src/modules/exec/Timer/Timer.cpp @@ -8,18 +8,26 @@ class Timer : public IoTItem { private: bool _unfin = false; bool _ticker = false; + bool _repeat = false; public: Timer(String parameters): IoTItem(parameters) { jsonRead(parameters, "countDown", value.valD); jsonRead(parameters, "ticker", _ticker); + jsonRead(parameters, "repeat", _repeat); + if (_repeat) _repeat = value.valD; // если в параметрах просят повторить, то запоминаем настроечное значение отчета _unfin = !value.valD; + + } void doByInterval() { if (!_unfin && value.valD) { value.valD--; - if (value.valD == 0) regEvent(value.valD, "Time's up"); + if (value.valD == 0) { + regEvent(value.valD, "Time's up"); + if (_repeat) value.valD = _repeat; + } } if (_ticker) regEvent(value.valD, "Timer tick"); diff --git a/src/modules/exec/Timer/items.json b/src/modules/exec/Timer/items.json index d275696c..821676a5 100644 --- a/src/modules/exec/Timer/items.json +++ b/src/modules/exec/Timer/items.json @@ -11,6 +11,7 @@ "int": 1, "countDown": 15, - "ticker": 0 + "ticker": 0, + "repeat": 0 } ] \ No newline at end of file