mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-26 23:12:34 +03:00
добавлен класс сбора бинарных данных
This commit is contained in:
@@ -203,6 +203,49 @@
|
|||||||
sortingLayout();
|
sortingLayout();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
class blobToJson {
|
||||||
|
constructor(data, st, end) {
|
||||||
|
this.data = data;
|
||||||
|
this.st = st;
|
||||||
|
this.end = end;
|
||||||
|
this.flag = true;
|
||||||
|
this.blob = new MyBlobBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
stEvent() {
|
||||||
|
if (this.data === st) {
|
||||||
|
this.flag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endEvent() {
|
||||||
|
if (this.data === end) {
|
||||||
|
this.flag = false;
|
||||||
|
var bb = blob.getBlob();
|
||||||
|
let reader = new FileReader();
|
||||||
|
reader.readAsText(bb);
|
||||||
|
reader.onload = () => {
|
||||||
|
let result = reader.result;
|
||||||
|
if (IsJsonParse(result)) {
|
||||||
|
let out = JSON.parse(result);
|
||||||
|
if (debug) console.log("✔", "chartJson parced", out);
|
||||||
|
//дергаем функцию из класса
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.blob.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//сборщик данных
|
||||||
|
append(data) {
|
||||||
|
if (this.flag) this.blob.append(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Использование:
|
||||||
|
//let chartJson = new blobToJson();
|
||||||
|
//user.sayHi();
|
||||||
|
|
||||||
//****************************************************web sockets section******************************************************/
|
//****************************************************web sockets section******************************************************/
|
||||||
function connectToAllDevices() {
|
function connectToAllDevices() {
|
||||||
//closeAllConnection();
|
//closeAllConnection();
|
||||||
@@ -452,6 +495,7 @@
|
|||||||
itemsJsonBlob.clear();
|
itemsJsonBlob.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//прием от всех учтройств
|
||||||
//сборщик layoutJson пакетов
|
//сборщик layoutJson пакетов
|
||||||
if (data === "/st/layout.json") {
|
if (data === "/st/layout.json") {
|
||||||
layoutReceivingCompleted = false;
|
layoutReceivingCompleted = false;
|
||||||
@@ -520,9 +564,9 @@
|
|||||||
if (widgetsJsonFlag) widgetsJsonBlob.append(event.data);
|
if (widgetsJsonFlag) widgetsJsonBlob.append(event.data);
|
||||||
if (itemsJsonFlag) itemsJsonBlob.append(event.data);
|
if (itemsJsonFlag) itemsJsonBlob.append(event.data);
|
||||||
if (scenarioJsonFlag) scenarioTxtBlob.append(event.data);
|
if (scenarioJsonFlag) scenarioTxtBlob.append(event.data);
|
||||||
if (chartJsonFlag) chartJsonBlob.append(event.data);
|
|
||||||
}
|
}
|
||||||
//принимаем данные от всех устройств
|
//принимаем данные от всех устройств
|
||||||
|
if (chartJsonFlag) chartJsonBlob.append(event.data);
|
||||||
if (!layoutJsonArray[ws]) layoutJsonArray[ws] = new MyBlobBuilder();
|
if (!layoutJsonArray[ws]) layoutJsonArray[ws] = new MyBlobBuilder();
|
||||||
layoutJsonArray[ws].append(event.data);
|
layoutJsonArray[ws].append(event.data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user