mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
formatting
This commit is contained in:
@@ -1,17 +1,42 @@
|
|||||||
// @ts-nocheck - Optimized MessagePack unpacking library for EMS-ESP32
|
// @ts-nocheck - Optimized MessagePack unpacking library for EMS-ESP32
|
||||||
let decoder, src, srcEnd, position = 0, strings = [], stringPosition = 0, currentUnpackr = {}, currentStructures, srcString, srcStringStart = 0, srcStringEnd = 0, bundledStrings, referenceMap, dataView;
|
let decoder,
|
||||||
const EMPTY_ARRAY = [], currentExtensions = [];
|
src,
|
||||||
|
srcEnd,
|
||||||
|
position = 0,
|
||||||
|
strings = [],
|
||||||
|
stringPosition = 0,
|
||||||
|
currentUnpackr = {},
|
||||||
|
currentStructures,
|
||||||
|
srcString,
|
||||||
|
srcStringStart = 0,
|
||||||
|
srcStringEnd = 0,
|
||||||
|
bundledStrings,
|
||||||
|
referenceMap,
|
||||||
|
dataView;
|
||||||
|
const EMPTY_ARRAY = [],
|
||||||
|
currentExtensions = [];
|
||||||
const defaultOptions = { useRecords: false, mapsAsObjects: true };
|
const defaultOptions = { useRecords: false, mapsAsObjects: true };
|
||||||
try { decoder = new TextDecoder(); } catch (error) { }
|
try {
|
||||||
|
decoder = new TextDecoder();
|
||||||
|
} catch (error) {}
|
||||||
class C1Type {}
|
class C1Type {}
|
||||||
const C1 = new C1Type();
|
const C1 = new C1Type();
|
||||||
C1.name = 'MessagePack 0xC1';
|
C1.name = 'MessagePack 0xC1';
|
||||||
let sequentialMode = false, inlineObjectReadThreshold = 2, readStruct, onLoadedStructures, onSaveState;
|
let sequentialMode = false,
|
||||||
try { new Function(''); } catch (error) { inlineObjectReadThreshold = Infinity; }
|
inlineObjectReadThreshold = 2,
|
||||||
|
readStruct,
|
||||||
|
onLoadedStructures,
|
||||||
|
onSaveState;
|
||||||
|
try {
|
||||||
|
new Function('');
|
||||||
|
} catch (error) {
|
||||||
|
inlineObjectReadThreshold = Infinity;
|
||||||
|
}
|
||||||
export class Unpackr {
|
export class Unpackr {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
if (options) {
|
if (options) {
|
||||||
if (options.useRecords === false && options.mapsAsObjects === undefined) options.mapsAsObjects = true;
|
if (options.useRecords === false && options.mapsAsObjects === undefined)
|
||||||
|
options.mapsAsObjects = true;
|
||||||
if (options.sequential && options.trusted !== false) {
|
if (options.sequential && options.trusted !== false) {
|
||||||
options.trusted = true;
|
options.trusted = true;
|
||||||
if (!options.structures && options.useRecords != false) {
|
if (!options.structures && options.useRecords != false) {
|
||||||
@@ -19,7 +44,8 @@ export class Unpackr {
|
|||||||
if (!options.maxSharedStructures) options.maxSharedStructures = 0;
|
if (!options.maxSharedStructures) options.maxSharedStructures = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.structures) options.structures.sharedLength = options.structures.length;
|
if (options.structures)
|
||||||
|
options.structures.sharedLength = options.structures.length;
|
||||||
else if (options.getStructures) {
|
else if (options.getStructures) {
|
||||||
(options.structures = []).uninitialized = true;
|
(options.structures = []).uninitialized = true;
|
||||||
options.structures.sharedLength = 0;
|
options.structures.sharedLength = 0;
|
||||||
|
|||||||
@@ -4378,78 +4378,124 @@ router
|
|||||||
|
|
||||||
function deviceData(id: number) {
|
function deviceData(id: number) {
|
||||||
if (id == 1) {
|
if (id == 1) {
|
||||||
return new Response(encoder.encode(emsesp_devicedata_1) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_devicedata_1) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 2) {
|
if (id == 2) {
|
||||||
return new Response(encoder.encode(emsesp_devicedata_2) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_devicedata_2) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 3) {
|
if (id == 3) {
|
||||||
return new Response(encoder.encode(emsesp_devicedata_3) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_devicedata_3) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 4) {
|
if (id == 4) {
|
||||||
return new Response(encoder.encode(emsesp_devicedata_4) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_devicedata_4) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 5) {
|
if (id == 5) {
|
||||||
return new Response(encoder.encode(emsesp_devicedata_5) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_devicedata_5) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 6) {
|
if (id == 6) {
|
||||||
return new Response(encoder.encode(emsesp_devicedata_6) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_devicedata_6) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 7) {
|
if (id == 7) {
|
||||||
return new Response(encoder.encode(emsesp_devicedata_7) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_devicedata_7) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 8) {
|
if (id == 8) {
|
||||||
// test changing the selected flow temp on a Bosch Compress 7000i AW Heat Pump (Boiler/HP)
|
// test changing the selected flow temp on a Bosch Compress 7000i AW Heat Pump (Boiler/HP)
|
||||||
emsesp_devicedata_8.nodes[4].v = Math.floor(Math.random() * 100);
|
emsesp_devicedata_8.nodes[4].v = Math.floor(Math.random() * 100);
|
||||||
return new Response(encoder.encode(emsesp_devicedata_8) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_devicedata_8) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 9) {
|
if (id == 9) {
|
||||||
return new Response(encoder.encode(emsesp_devicedata_9) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_devicedata_9) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 10) {
|
if (id == 10) {
|
||||||
return new Response(encoder.encode(emsesp_devicedata_10) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_devicedata_10) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 11) {
|
if (id == 11) {
|
||||||
return new Response(encoder.encode(emsesp_devicedata_11) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_devicedata_11) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 99) {
|
if (id == 99) {
|
||||||
return new Response(encoder.encode(emsesp_devicedata_99) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_devicedata_99) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deviceEntities(id: number) {
|
function deviceEntities(id: number) {
|
||||||
if (id == 1) {
|
if (id == 1) {
|
||||||
return new Response(encoder.encode(emsesp_deviceentities_1) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_deviceentities_1) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 2) {
|
if (id == 2) {
|
||||||
return new Response(encoder.encode(emsesp_deviceentities_2) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_deviceentities_2) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 3) {
|
if (id == 3) {
|
||||||
return new Response(encoder.encode(emsesp_deviceentities_3) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_deviceentities_3) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 4) {
|
if (id == 4) {
|
||||||
return new Response(encoder.encode(emsesp_deviceentities_4) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_deviceentities_4) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 5) {
|
if (id == 5) {
|
||||||
return new Response(encoder.encode(emsesp_deviceentities_5) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_deviceentities_5) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 6) {
|
if (id == 6) {
|
||||||
return new Response(encoder.encode(emsesp_deviceentities_6) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_deviceentities_6) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 7) {
|
if (id == 7) {
|
||||||
return new Response(encoder.encode(emsesp_deviceentities_7) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_deviceentities_7) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 8) {
|
if (id == 8) {
|
||||||
return new Response(encoder.encode(emsesp_deviceentities_8) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_deviceentities_8) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 9) {
|
if (id == 9) {
|
||||||
return new Response(encoder.encode(emsesp_deviceentities_9) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_deviceentities_9) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (id == 10) {
|
if (id == 10) {
|
||||||
return new Response(encoder.encode(emsesp_deviceentities_10) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_deviceentities_10) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// not found, return empty
|
// not found, return empty
|
||||||
return new Response(encoder.encode(emsesp_deviceentities_none) as BodyInit, { headers });
|
return new Response(encoder.encode(emsesp_deviceentities_none) as BodyInit, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare dashboard data
|
// prepare dashboard data
|
||||||
@@ -4575,7 +4621,9 @@ router
|
|||||||
|
|
||||||
// add analog sensor data. no command c
|
// add analog sensor data. no command c
|
||||||
// remove disabled sensors first (t = 0) and create data in one pass
|
// remove disabled sensors first (t = 0) and create data in one pass
|
||||||
const enabledAnalogSensors = emsesp_sensordata.as.filter((item) => item.t !== 0);
|
const enabledAnalogSensors = emsesp_sensordata.as.filter(
|
||||||
|
(item) => item.t !== 0
|
||||||
|
);
|
||||||
if (enabledAnalogSensors.length > 0) {
|
if (enabledAnalogSensors.length > 0) {
|
||||||
const sensor_data = enabledAnalogSensors.map((item, index) => ({
|
const sensor_data = enabledAnalogSensors.map((item, index) => ({
|
||||||
id: DeviceTypeUniqueID.ANALOGSENSOR_UID * 100 + index,
|
id: DeviceTypeUniqueID.ANALOGSENSOR_UID * 100 + index,
|
||||||
|
|||||||
Reference in New Issue
Block a user