mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Уточняем период работы функции nowInTimePeriod
Добавляем <vector> в IoTItem.h
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
#include "classes/IoTGpio.h"
|
#include "classes/IoTGpio.h"
|
||||||
//#include "classes/IoTBench.h"
|
//#include "classes/IoTBench.h"
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,16 @@ private:
|
|||||||
int h2 = selectToMarker(endTime, ":").toInt();
|
int h2 = selectToMarker(endTime, ":").toInt();
|
||||||
int min2 = selectToMarkerLast(endTime, ":").toInt();
|
int min2 = selectToMarkerLast(endTime, ":").toInt();
|
||||||
|
|
||||||
|
int sumMin1 = h1 * 60 + min1;
|
||||||
|
int sumMin2 = h2 * 60 + min2;
|
||||||
|
|
||||||
int nowMinutes = _time_local.hour * 60 + _time_local.minute;
|
int nowMinutes = _time_local.hour * 60 + _time_local.minute;
|
||||||
|
|
||||||
return nowMinutes >= h1 * 60 + min1 && nowMinutes <= h2 * 60 + min2;
|
if (sumMin1 <= sumMin2) {
|
||||||
|
return nowMinutes >= sumMin1 && nowMinutes <= sumMin2;
|
||||||
|
} else {
|
||||||
|
return nowMinutes >= sumMin1 && nowMinutes <= 24 * 60 || nowMinutes >= 0 && nowMinutes <= sumMin2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
57
src/modules/virtual/Math/SimpleTimePeriod.json
Normal file
57
src/modules/virtual/Math/SimpleTimePeriod.json
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
"mark": "iotm",
|
||||||
|
"config": [
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "IoTMath",
|
||||||
|
"id": "math",
|
||||||
|
"widget": "anydataValue",
|
||||||
|
"page": "Ввод",
|
||||||
|
"descr": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Variable",
|
||||||
|
"id": "start",
|
||||||
|
"needSave": 0,
|
||||||
|
"widget": "inputTm",
|
||||||
|
"page": "Ввод",
|
||||||
|
"descr": "Введите время",
|
||||||
|
"int": "0",
|
||||||
|
"val": "02:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Variable",
|
||||||
|
"id": "stop",
|
||||||
|
"needSave": 0,
|
||||||
|
"widget": "inputTm",
|
||||||
|
"page": "Ввод",
|
||||||
|
"descr": "Введите время",
|
||||||
|
"int": "0",
|
||||||
|
"val": "02:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"type": "Writing",
|
||||||
|
"subtype": "ButtonOut",
|
||||||
|
"needSave": 0,
|
||||||
|
"id": "led",
|
||||||
|
"widget": "toggle",
|
||||||
|
"page": "Ввод",
|
||||||
|
"descr": "Освещение",
|
||||||
|
"int": 0,
|
||||||
|
"inv": 0,
|
||||||
|
"pin": 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
scenario=>if start | stop then {
|
||||||
|
if math.nowInTimePeriod(start, stop) then {
|
||||||
|
led = 1
|
||||||
|
} else led = 0
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user