Skip to content

Commit

Permalink
connect every metering node on deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Lober committed Jan 31, 2024
1 parent eb74cda commit c4b09c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/backend/ewio2ConnObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/backend/ewio2Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -407,17 +407,17 @@ function getIoTypeDataAndStartLivedata(keyEwio2Data, ioType, counterId, RED) {
}
// request "get®config®<ioType>®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});
});
}
}
Expand Down

0 comments on commit c4b09c3

Please sign in to comment.