Уточняем период работы функции nowInTimePeriod

Добавляем <vector> в IoTItem.h
This commit is contained in:
2024-05-01 10:06:10 +03:00
parent be18ef6875
commit 6605108052
3 changed files with 66 additions and 1 deletions

View File

@@ -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"

View File

@@ -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;
}
} }

View 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
}