Добавил массив виджетов и реализовал их отправку

This commit is contained in:
Dmitry Borisenko
2022-01-17 00:06:50 +01:00
parent ee322ce185
commit 775d7a11ad
39 changed files with 6648 additions and 209 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

180
data_svelte/widgets.json Normal file
View File

@@ -0,0 +1,180 @@
[
{
"name": "anydataRed",
"rus": "Сообщение1",
"widget": "anydata",
"icon": "body",
"color": "red",
"descrColor": "red"
},
{
"name": "anydataDgr",
"rus": "Сообщение2",
"widget": "anydata",
"after": "",
"color": "red",
"icon": "walk"
},
{
"name": "anydataDef",
"rus": "Текст",
"widget": "anydata",
"after": "",
"icon": ""
},
{
"name": "anydataAmp",
"rus": "Амперы",
"widget": "anydata",
"after": "Amp",
"icon": "speedometer"
},
{
"name": "anydataHtz",
"rus": "Герцы",
"widget": "anydata",
"after": "Htz",
"icon": "speedometer"
},
{
"name": "anydataHum",
"rus": "Влажность",
"widget": "anydata",
"after": "%",
"icon": "water",
"color": "#88AADF"
},
{
"name": "anydataMm",
"rus": "Давление",
"widget": "anydata",
"after": "mm",
"icon": "speedometer"
},
{
"name": "anydataTm",
"rus": "Время",
"widget": "anydata",
"after": "",
"icon": "speedometer"
},
{
"name": "button",
"rus": "Кнопка",
"widget": "btn",
"size": "large",
"color": "green",
"send": "test"
},
{
"name": "toggle",
"rus": "Переключатель",
"widget": "toggle",
"icon": "",
"iconOff": ""
},
{
"name": "chart1",
"rus": рафик1",
"widget": "chart",
"dateFormat": "HH:mm",
"pointRadius": 0
},
{
"name": "chart2",
"rus": рафик2",
"widget": "chart",
"dateFormat": "HH:mm"
},
{
"name": "chart3",
"rus": рафик3",
"widget": "chart",
"dateFormat": "DD.MM.YYYY",
"type": "bar"
},
{
"name": "chart4",
"rus": рафик4",
"widget": "chart",
"dateFormat": "DD.MM.YYYY"
},
{
"name": "fillgauge",
"rus": "Бочка",
"widget": "fillgauge",
"circleColor": "#00FFFF",
"textColor": "#FFFFFF",
"waveTextColor": "#000000",
"waveColor": "#00FFFF"
},
{
"name": "inputDate",
"rus": "Ввод даты",
"widget": "input",
"size": "small",
"color": "orange",
"type": "date"
},
{
"name": "inputDgt",
"rus": "Ввод цифры",
"widget": "input",
"color": "blue",
"type": "number"
},
{
"name": "inputTxt",
"rus": "Ввод текста",
"widget": "input",
"size": "small",
"color": "orange",
"type": "text"
},
{
"name": "inputTm",
"rus": "Ввод времени",
"widget": "input",
"color": "blue",
"type": "time"
},
{
"name": "progressLine",
"rus": "Статус линия",
"widget": "progress-line",
"icon": "sunny",
"max": "100",
"stroke": "10"
},
{
"name": "progressRound",
"rus": "Статус круг",
"widget": "progress-round",
"max": "100",
"stroke": "20",
"color": "#45ccce",
"background": "#777",
"semicircle": "1"
},
{
"name": "range",
"rus": "Ползунок",
"widget": "range",
"descrColor": "red",
"after": "%",
"k": 0.0977,
"min": 0,
"max": 100,
"debounce": 500
},
{
"name": "select",
"rus": "Выпадающий",
"widget": "select",
"options": [
"Выключен",
"Включен"
],
"status": 0
}
]

View File

@@ -1,6 +0,0 @@
{
"widget": "anydata",
"icon": "body",
"color": "red",
"descrColor": "red"
}

View File

@@ -1,5 +0,0 @@
{
"widget": "anydata",
"after": "",
"icon": ""
}

View File

@@ -1,6 +0,0 @@
{
"widget": "anydata",
"after": "",
"color":"red",
"icon": "walk"
}

View File

@@ -1,5 +0,0 @@
{
"widget": "anydata",
"after": "Amp",
"icon": "speedometer"
}

View File

@@ -1,5 +0,0 @@
{
"widget": "anydata",
"after": "Htz",
"icon": "speedometer"
}

View File

@@ -1,6 +0,0 @@
{
"widget": "anydata",
"after": "%",
"icon": "water",
"color": "#88AADF"
}

View File

@@ -1,5 +0,0 @@
{
"widget": "anydata",
"after": "ppb",
"icon": "body"
}

View File

@@ -1,5 +0,0 @@
{
"widget": "anydata",
"after": "ppm",
"icon": "body"
}

View File

@@ -1,5 +0,0 @@
{
"widget": "anydata",
"after": "mm",
"icon": "speedometer"
}

View File

@@ -1,16 +0,0 @@
{
"widget": "anydata",
"after": "°С",
"icon": "thermometer",
"font": "OCR A Std",
"color": [
{ "level": -20, "value": "#0000CC" },
{ "level": -10, "value": "#0000CC" },
{ "level": 0, "value": "#0000CC" },
{ "level": 12, "value": "#3366FF" },
{ "level": 16, "value": "#33CCFF" },
{ "level": 18, "value": "#009933" },
{ "level": 30, "value": "#FF9900" },
{ "level": 40, "value": "red" }
]
}

View File

@@ -1,5 +0,0 @@
{
"widget": "anydata",
"after": "",
"icon": "speedometer"
}

View File

@@ -1,5 +0,0 @@
{
"widget": "anydata",
"after": "Vlt",
"icon": "speedometer"
}

View File

@@ -1,5 +0,0 @@
{
"widget": "anydata",
"after": "Whr",
"icon": "speedometer"
}

View File

@@ -1,5 +0,0 @@
{
"widget": "anydata",
"after": "Wtt",
"icon": "speedometer"
}

View File

@@ -1,6 +0,0 @@
{
"widget": "btn",
"size": "large",
"color": "green",
"send": "test"
}

View File

@@ -1,5 +0,0 @@
{
"widget": "chart",
"dateFormat": "HH:mm",
"pointRadius": 0
}

View File

@@ -1,4 +0,0 @@
{
"widget": "chart",
"dateFormat": "HH:mm"
}

View File

@@ -1,5 +0,0 @@
{
"widget": "chart",
"dateFormat": "DD.MM.YYYY",
"type":"bar"
}

View File

@@ -1,4 +0,0 @@
{
"widget": "chart",
"dateFormat": "DD.MM.YYYY"
}

View File

@@ -1,7 +0,0 @@
{
"widget": "fillgauge",
"circleColor": "#00FFFF",
"textColor": "#FFFFFF",
"waveTextColor": "#000000",
"waveColor": "#00FFFF"
}

View File

@@ -1,6 +0,0 @@
{
"widget" : "input",
"size" : "small",
"color" : "orange",
"type" : "date"
}

View File

@@ -1,5 +0,0 @@
{
"widget" : "input",
"color" : "blue",
"type" : "number"
}

View File

@@ -1,7 +0,0 @@
{
"widget" : "input",
"color" : "green",
"type" : "number",
"size" : "small",
"icon": "thermometer"
}

View File

@@ -1,6 +0,0 @@
{
"widget" : "input",
"size" : "small",
"color" : "orange",
"type" : "text"
}

View File

@@ -1,5 +0,0 @@
{
"widget" : "input",
"color" : "blue",
"type" : "time"
}

View File

@@ -1,7 +0,0 @@
{
"widget" : "input",
"color" : "orange",
"type" : "time",
"size" : "small",
"icon": "alarm-outline"
}

View File

@@ -1,12 +0,0 @@
{
"widget": "progress-line",
"icon": "sunny",
"descrColor": "",
"color": "",
"max": "100",
"background": "",
"stroke": "10",
"disabled": "",
"before": "",
"after": ""
}

View File

@@ -1,11 +0,0 @@
{
"widget": "progress-round",
"descrColor": "",
"max": "100",
"stroke": "20",
"color": "#45ccce",
"background": "#777",
"before": "",
"semicircle": "1",
"after": ""
}

View File

@@ -1,9 +0,0 @@
{
"widget" : "range",
"descrColor": "red",
"after" : "%",
"k" : 0.0977,
"min" : 0,
"max" : 100,
"debounce": 500
}

View File

@@ -1,8 +0,0 @@
{
"widget": "select",
"options": [
"Выключен",
"Включен"
],
"status": 0
}

View File

@@ -1,5 +0,0 @@
{
"widget": "toggle",
"icon": "",
"iconOff": ""
}

View File

@@ -1,5 +0,0 @@
{
"widget": "toggle",
"icon": "sunny",
"iconOff": "moon"
}

View File

@@ -23,4 +23,5 @@ class SendJson {
String _path;
};
extern SendJson* mySendJson;
extern SendJson* sendConfigJson;
extern SendJson* sendWigdetsJson;

View File

@@ -38,7 +38,8 @@ void setup() {
mqttInit();
//создаем объект класса выгружающего json массив из файла
mySendJson = new SendJson;
sendConfigJson = new SendJson;
sendWigdetsJson = new SendJson;
configure("/config.json");
@@ -61,7 +62,8 @@ void loop() {
ts.update();
//отправка json
if (mySendJson) mySendJson->loop();
if (sendConfigJson) sendConfigJson->loop();
if (sendWigdetsJson) sendWigdetsJson->loop();
#ifdef STANDARD_WEB_SERVER
//обработка web сервера

View File

@@ -212,8 +212,10 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
payloadStr += (char)payload[i];
}
if (payloadStr.startsWith("/config")) { //если прилетел url страницы /config то отправим пакеты с меткой /config.json
if (mySendJson) mySendJson->sendFile("/config.json", num);
if (payloadStr.startsWith("/config")) {
//если прилетел url страницы /config то отправим widgets.json и config.json
if (sendWigdetsJson) sendWigdetsJson->sendFile("/widgets.json", num);
if (sendConfigJson) sendConfigJson->sendFile("/config.json", num);
}
if (payloadStr.startsWith("/gifnoc.json")) { //если прилетел измененный пакет с меткой /gifnoc (config наоборот) то перепишем файл, пока переписываем целеком

View File

@@ -24,4 +24,5 @@ void SendJson::sendMqtt(String& jsonArrayElement) {
// mqtt send to do
}
SendJson* mySendJson;
SendJson* sendConfigJson;
SendJson* sendWigdetsJson;