From c4b09c32a00e6b6478c2508b2924409bc267c801 Mon Sep 17 00:00:00 2001 From: Stefan Lober Date: Wed, 31 Jan 2024 09:18:32 +0100 Subject: [PATCH] connect every metering node on deploy --- package.json | 2 +- src/backend/ewio2ConnObj.js | 2 +- src/backend/ewio2Connection.js | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 5670374..c363ece 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@metz-connect/node-red-ewio2", - "version": "1.0.0", + "version": "1.0.1", "description": "Provides nodes to access EWIO2 interfaces like IOs and metering - from Node-RED", "dependencies": { "ws": "^8.8.0", diff --git a/src/backend/ewio2ConnObj.js b/src/backend/ewio2ConnObj.js index 3135dbd..5064d1f 100644 --- a/src/backend/ewio2ConnObj.js +++ b/src/backend/ewio2ConnObj.js @@ -473,7 +473,7 @@ class Ewio2Connection { const recvCntrDpAddr = parts[0] + "®" + parts[2] + "®" + parts[3]; connObj.values[recvCntrDpAddr] = datapointsElement; // only publish received livedata (no ws-setup promise (getPromise) available) - if (connObj.#noGetPromisePending(datapointsElement.ioType)) { + if (connObj.#noGetPromisePending(datapointsElement.ioType + "®" + datapointsElement.counterId)) { connObj.publishIoPortStatus(datapointsElement, RED, true, false); } } diff --git a/src/backend/ewio2Connection.js b/src/backend/ewio2Connection.js index e001a12..9101171 100644 --- a/src/backend/ewio2Connection.js +++ b/src/backend/ewio2Connection.js @@ -391,14 +391,14 @@ function getIoTypeDataAndStartLivedata(keyEwio2Data, ioType, counterId, RED) { // values of ioType not yet known --> request values if (!conn.isIoTypeValueKnown(ioTypeToCheck)) { // not getPromise for ioType available --> store resolve and reject function of getPromise and enqueue websocket msg - if (!conn.getPromises[ioType] || conn.getPromises[ioType].length === 0) { + if (!conn.getPromises[ioTypeToCheck] || conn.getPromises[ioTypeToCheck].length === 0) { log(node, 'getIoTypeDataAndStartLivedata, add promise for first IO data'); getIoTypeAndStartLivedataPromise = new Promise(async (resolve, reject) => { - if (!conn.getPromises[ioType]) { + if (!conn.getPromises[ioTypeToCheck]) { // create ioType category (of getPromises) - conn.getPromises[ioType] = []; + conn.getPromises[ioTypeToCheck] = []; } - conn.getPromises[ioType].push({resolve: resolve, reject: reject}); + conn.getPromises[ioTypeToCheck].push({resolve: resolve, reject: reject}); log(node, 'no IO type data available and livedata not started'); let portIndicator = "all"; // datapoints: request given counter ID; all other (DI, AI, DO, AO, counter): request "all" @@ -407,17 +407,17 @@ function getIoTypeDataAndStartLivedata(keyEwio2Data, ioType, counterId, RED) { } // request "get®config®®all", to get all IO data of ioType await conn.sendWsMessage("get®config®" + ioType + "®" + portIndicator, RED); - conn.resolveAllStoredGetPromises(ioType, RED); + conn.resolveAllStoredGetPromises(ioTypeToCheck, RED); }); } // getPromises to request ioType values already available --> only store resolve and reject function else { log(node, 'getIoTypeDataAndStartLivedata, add promise for further IO data'); getIoTypeAndStartLivedataPromise = new Promise((resolve, reject) => { - if (!conn.getPromises[ioType]) { - conn.getPromises[ioType] = []; + if (!conn.getPromises[ioTypeToCheck]) { + conn.getPromises[ioTypeToCheck] = []; } - conn.getPromises[ioType].push({resolve: resolve, reject: reject}); + conn.getPromises[ioTypeToCheck].push({resolve: resolve, reject: reject}); }); } }