@bitpoolos/edge-bacnet 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/bacnet_client.js +73 -49
- package/bacnet_gateway.html +233 -18
- package/bacnet_gateway.js +41 -8
- package/bacnet_inspector.js +88 -12
- package/bacnet_inspector_worker.js +13 -3
- package/bacnet_read.html +229 -8
- package/bacnet_read.js +13 -1
- package/inspector.html +35 -1
- package/package.json +1 -1
- package/resources/style.css +28 -1
- package/treeBuilder.js +80 -5
package/bacnet_inspector.js
CHANGED
|
@@ -61,9 +61,41 @@ module.exports = function (RED) {
|
|
|
61
61
|
site_Name: false,
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
// Function to update node status with combined information
|
|
65
|
+
function updateNodeStatus() {
|
|
66
|
+
// Calculate offline percentage for display
|
|
67
|
+
const totalPolledPoints = cachedData.onlineCount + cachedData.offlineCount;
|
|
68
|
+
const offlinePercentage = totalPolledPoints > 0 ?
|
|
69
|
+
Math.round((cachedData.offlineCount / totalPolledPoints) * 100) : 0;
|
|
70
|
+
|
|
71
|
+
// Build comprehensive status text
|
|
72
|
+
const statusParts = [];
|
|
73
|
+
|
|
74
|
+
// Add online/offline info if we have polled points
|
|
75
|
+
if (totalPolledPoints > 0) {
|
|
76
|
+
statusParts.push(`Online: ${cachedData.onlineCount}/${totalPolledPoints} (${100 - offlinePercentage}%)`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Add points to read info if we have read list
|
|
80
|
+
if (cachedData.totalUniqueReadCount > 0) {
|
|
81
|
+
statusParts.push(`Total Points: ${cachedData.totalUniqueReadCount}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Fallback status if no data
|
|
85
|
+
if (statusParts.length === 0) {
|
|
86
|
+
statusParts.push("No data");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Update node status
|
|
90
|
+
node.status({ text: statusParts.join(" | ") });
|
|
91
|
+
}
|
|
92
|
+
|
|
64
93
|
// Initialize cache from flow context
|
|
65
94
|
initializeCache();
|
|
66
95
|
|
|
96
|
+
// Set initial status
|
|
97
|
+
updateNodeStatus();
|
|
98
|
+
|
|
67
99
|
function initializeCache() {
|
|
68
100
|
let flow = context.flow;
|
|
69
101
|
|
|
@@ -187,21 +219,31 @@ module.exports = function (RED) {
|
|
|
187
219
|
} else if (msg.type === "Read") {
|
|
188
220
|
calculateCombinedReadList(node, msg);
|
|
189
221
|
if (done) done();
|
|
190
|
-
} else if (msg.payload && msg.payload.error !== undefined && msg.payload.error !== "none") {
|
|
191
|
-
// bacnet error msg found
|
|
192
|
-
setErrorTopics(msg);
|
|
193
|
-
if (done) done();
|
|
194
222
|
} else if (msg.payload && msg.topic) {
|
|
195
|
-
//regular bacnet output
|
|
223
|
+
//regular bacnet output (including those with errors)
|
|
196
224
|
// Queue the message for batch processing instead of immediate processing
|
|
197
225
|
messageQueue.push({ msg, send, done });
|
|
198
226
|
if (messageQueue.length >= MAX_BATCH_SIZE) {
|
|
199
227
|
processBatch();
|
|
200
228
|
}
|
|
229
|
+
|
|
230
|
+
// Also handle error tracking for messages with errors or offline status
|
|
231
|
+
if ((msg.payload.error !== undefined && msg.payload.error !== "none") ||
|
|
232
|
+
(msg.payload.status !== undefined && msg.payload.status === "offline")) {
|
|
233
|
+
setErrorTopics(msg);
|
|
234
|
+
}
|
|
201
235
|
} else if (msg.type === "sendMqttStats") {
|
|
202
236
|
// Make sure we have the latest statBlock values before sending stats
|
|
203
237
|
syncStatBlockWithWorkerResults().then(() => {
|
|
204
238
|
let statBlock = node.statBlock;
|
|
239
|
+
let statCounts = node.statCounts || {};
|
|
240
|
+
|
|
241
|
+
// Calculate appropriate totals for percentage calculations
|
|
242
|
+
const readCount = statCounts.readCount || 0;
|
|
243
|
+
const discoveryCount = statCounts.discoveryCount || 0;
|
|
244
|
+
const totalDevices = statCounts.totalDevices || 1; // Fallback to 1 to prevent division by zero
|
|
245
|
+
|
|
246
|
+
// Send raw values
|
|
205
247
|
for (let key in statBlock) {
|
|
206
248
|
let value = statBlock[key];
|
|
207
249
|
let keyText = key.toUpperCase();
|
|
@@ -211,6 +253,35 @@ module.exports = function (RED) {
|
|
|
211
253
|
};
|
|
212
254
|
node.send(newMsg);
|
|
213
255
|
}
|
|
256
|
+
|
|
257
|
+
// Send percentage values
|
|
258
|
+
for (let key in statBlock) {
|
|
259
|
+
let rawValue = statBlock[key];
|
|
260
|
+
let percentage = 0;
|
|
261
|
+
|
|
262
|
+
// Calculate percentage based on appropriate denominator (rounded to 2 decimal places)
|
|
263
|
+
if (key === 'unmapped') {
|
|
264
|
+
// Unmapped points are from discovery list
|
|
265
|
+
percentage = discoveryCount > 0 ? Math.round((rawValue / discoveryCount) * 10000) / 100 : 0;
|
|
266
|
+
} else if (key === 'offlinePercentage') {
|
|
267
|
+
// Already a percentage, just round to 2 decimal places
|
|
268
|
+
percentage = Math.round(rawValue * 100) / 100;
|
|
269
|
+
} else if (key === 'deviceIdConflict') {
|
|
270
|
+
// Device conflicts as percentage of total devices
|
|
271
|
+
percentage = totalDevices > 0 ? Math.round((rawValue / totalDevices) * 10000) / 100 : 0;
|
|
272
|
+
} else {
|
|
273
|
+
// All other stats (ok, error, missing, warnings, moved, deviceIdChange) are based on read list
|
|
274
|
+
percentage = readCount > 0 ? Math.round((rawValue / readCount) * 10000) / 100 : 0;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
let keyText = key.toUpperCase();
|
|
278
|
+
let percentageMsg = {
|
|
279
|
+
topic: `EDGE_DEVICE_${node.siteName}/BACNETSTATS/${keyText}PERCENTAGE`,
|
|
280
|
+
payload: percentage,
|
|
281
|
+
};
|
|
282
|
+
node.send(percentageMsg);
|
|
283
|
+
}
|
|
284
|
+
|
|
214
285
|
if (done) done();
|
|
215
286
|
});
|
|
216
287
|
|
|
@@ -419,6 +490,10 @@ module.exports = function (RED) {
|
|
|
419
490
|
topicData.error = error;
|
|
420
491
|
entryChanged = true;
|
|
421
492
|
}
|
|
493
|
+
if (status !== undefined && topicData.status !== status) {
|
|
494
|
+
topicData.status = status;
|
|
495
|
+
entryChanged = true;
|
|
496
|
+
}
|
|
422
497
|
|
|
423
498
|
if (entryChanged) {
|
|
424
499
|
topicData.key = topicData.deviceID + ":" + topicData.objectType + ":" + topicData.objectInstance;
|
|
@@ -436,8 +511,8 @@ module.exports = function (RED) {
|
|
|
436
511
|
dirtyFlags.offlinePercentage = true;
|
|
437
512
|
}
|
|
438
513
|
|
|
439
|
-
// Update the node status
|
|
440
|
-
|
|
514
|
+
// Update the node status with combined information
|
|
515
|
+
updateNodeStatus();
|
|
441
516
|
|
|
442
517
|
// Periodically call getModelStats to keep model stats updated
|
|
443
518
|
// Use a debounce pattern to avoid calling it too frequently
|
|
@@ -581,6 +656,7 @@ module.exports = function (RED) {
|
|
|
581
656
|
function setErrorTopics(msg) {
|
|
582
657
|
let topic = msg.topic;
|
|
583
658
|
let error = msg.payload.error;
|
|
659
|
+
let status = msg.payload.status;
|
|
584
660
|
|
|
585
661
|
// Extract properties only if they exist
|
|
586
662
|
let deviceID = msg.payload.meta?.device?.deviceId;
|
|
@@ -595,7 +671,8 @@ module.exports = function (RED) {
|
|
|
595
671
|
? msg.payload.meta.device.address.address
|
|
596
672
|
: msg.payload.meta?.device?.address;
|
|
597
673
|
|
|
598
|
-
|
|
674
|
+
// Track entries with explicit errors or offline status
|
|
675
|
+
if ((error !== undefined && error !== "none") || (status !== undefined && status === "offline")) {
|
|
599
676
|
// Use the cache instead of direct flow context access
|
|
600
677
|
cachedData.entriesWithErrors.set(topic, {
|
|
601
678
|
deviceID: deviceID,
|
|
@@ -605,7 +682,7 @@ module.exports = function (RED) {
|
|
|
605
682
|
displayName: displayName,
|
|
606
683
|
deviceName: deviceName,
|
|
607
684
|
ipAddress: ipAddress,
|
|
608
|
-
error: error,
|
|
685
|
+
error: error || (status === "offline" ? "Point offline" : "N/A"),
|
|
609
686
|
});
|
|
610
687
|
|
|
611
688
|
// Mark as dirty so it will be synced to flow context
|
|
@@ -771,12 +848,11 @@ module.exports = function (RED) {
|
|
|
771
848
|
// Force sync with flow context to ensure data is immediately available
|
|
772
849
|
syncWithFlowContext();
|
|
773
850
|
|
|
774
|
-
// Update the node status
|
|
775
|
-
|
|
851
|
+
// Update the node status with combined information
|
|
852
|
+
updateNodeStatus();
|
|
776
853
|
}
|
|
777
854
|
|
|
778
855
|
function getPublishedPointsList() {
|
|
779
|
-
node.warn("Generating Published Points List...");
|
|
780
856
|
let flow = context.flow;
|
|
781
857
|
let now = new Date();
|
|
782
858
|
|
|
@@ -149,6 +149,7 @@ function processModelStats(data) {
|
|
|
149
149
|
// Store the data under all variations
|
|
150
150
|
const publishData = {
|
|
151
151
|
error: data.error || "N/A",
|
|
152
|
+
status: data.status || "N/A",
|
|
152
153
|
presentValue: data.presentValue,
|
|
153
154
|
bacnetLastSeen: data.bacnetLastSeen
|
|
154
155
|
};
|
|
@@ -232,15 +233,24 @@ function processModelStats(data) {
|
|
|
232
233
|
|
|
233
234
|
if (DiscoveryKeyMatch) {
|
|
234
235
|
if (PublishPointTopicMatch) {
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
const publishData = PublishTopicsNormalized.get(matchVariation);
|
|
237
|
+
const error = publishData.error;
|
|
238
|
+
const status = publishData.status;
|
|
239
|
+
|
|
240
|
+
// Check if point has error or is offline
|
|
241
|
+
if ((error !== "none" && error !== "N/A") || status === "offline") {
|
|
242
|
+
if (status === "offline") {
|
|
243
|
+
PointResult.dataModelStatus = `Point Error - Matched in Discovery / Data Model and publishing, however point status is offline`;
|
|
244
|
+
} else {
|
|
245
|
+
PointResult.dataModelStatus = `Point Error - Matched in Discovery / Data Model and publishing, however BACNet Error is present: ${error}`;
|
|
246
|
+
}
|
|
238
247
|
statBlock.error++;
|
|
239
248
|
} else {
|
|
240
249
|
PointResult.dataModelStatus = "Point Ok - Matched in Discovery / Data Model and publishing";
|
|
241
250
|
statBlock.ok++;
|
|
242
251
|
}
|
|
243
252
|
PointResult.error = error;
|
|
253
|
+
PointResult.status = status; // Also store the status for reference
|
|
244
254
|
pointOkCount++;
|
|
245
255
|
} else {
|
|
246
256
|
if (DiscoveryPointMap[ReadPointKey].objectName !== ReadPointObj.pointName) {
|
package/bacnet_read.html
CHANGED
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
progressBarValue: ref(),
|
|
63
63
|
rightClickedDevice: ref(),
|
|
64
64
|
rightClickedPoint: ref(),
|
|
65
|
+
rightClickedMstpFolder: ref(),
|
|
65
66
|
showDeviceNameDialog: ref(false),
|
|
66
67
|
showPointNameDialog: ref(false),
|
|
67
68
|
deviceDisplayNameValue: ref(),
|
|
@@ -288,7 +289,13 @@
|
|
|
288
289
|
newReadParent = JSON.parse(JSON.stringify(parentDevice));
|
|
289
290
|
}
|
|
290
291
|
newReadParent.children[0].children = [];
|
|
291
|
-
|
|
292
|
+
|
|
293
|
+
// Create a copy of the point with preserved display name
|
|
294
|
+
let pointCopy = JSON.parse(JSON.stringify(slotProps.node));
|
|
295
|
+
// Ensure display name is preserved from the original point
|
|
296
|
+
pointCopy.label = slotProps.node.label;
|
|
297
|
+
newReadParent.children[0].children.push(pointCopy);
|
|
298
|
+
|
|
292
299
|
while (newReadParent.children.length > 1) {
|
|
293
300
|
newReadParent.children.forEach(function (child, index) {
|
|
294
301
|
if (child.label.includes("MSTP")) {
|
|
@@ -307,7 +314,10 @@
|
|
|
307
314
|
(ele) => ele.pointName == slotProps.node.pointName
|
|
308
315
|
);
|
|
309
316
|
if (pointIndex == -1) {
|
|
310
|
-
|
|
317
|
+
// Create a copy of the point with preserved display name
|
|
318
|
+
let pointCopy = JSON.parse(JSON.stringify(slotProps.node));
|
|
319
|
+
pointCopy.label = slotProps.node.label;
|
|
320
|
+
this.readDevices[foundDeviceIndex].children[0].children.push(pointCopy);
|
|
311
321
|
}
|
|
312
322
|
}
|
|
313
323
|
|
|
@@ -321,6 +331,10 @@
|
|
|
321
331
|
}
|
|
322
332
|
|
|
323
333
|
let point = this.pointList[key][slotProps.node.pointName];
|
|
334
|
+
// Preserve any existing display name when adding to pointsToRead
|
|
335
|
+
if (slotProps.node.label !== slotProps.node.pointName) {
|
|
336
|
+
point.displayName = slotProps.node.label;
|
|
337
|
+
}
|
|
324
338
|
this.pointsToRead[key][point.objectName] = point;
|
|
325
339
|
|
|
326
340
|
//force a deploy state
|
|
@@ -566,6 +580,27 @@
|
|
|
566
580
|
pointMenu.classList.remove("pointAddedToRead");
|
|
567
581
|
}
|
|
568
582
|
},
|
|
583
|
+
// NEW: Handle right-click on MSTP network folders
|
|
584
|
+
onMstpFolderRightClick(slotProps, event) {
|
|
585
|
+
let app = this;
|
|
586
|
+
app.rightClickedMstpFolder = slotProps;
|
|
587
|
+
event.preventDefault();
|
|
588
|
+
event.stopPropagation();
|
|
589
|
+
|
|
590
|
+
// Hide other context menus first
|
|
591
|
+
const menu = document.querySelector(".context-menu");
|
|
592
|
+
const pointMenu = document.querySelector(".point-context-menu");
|
|
593
|
+
if (menu) menu.style.display = "none";
|
|
594
|
+
if (pointMenu) pointMenu.style.display = "none";
|
|
595
|
+
|
|
596
|
+
const mstpFolderMenu = document.querySelector(".mstp-folder-context-menu");
|
|
597
|
+
|
|
598
|
+
if (mstpFolderMenu) {
|
|
599
|
+
mstpFolderMenu.style.setProperty("--mouse-x", event.clientX + "px");
|
|
600
|
+
mstpFolderMenu.style.setProperty("--mouse-y", event.clientY + "px");
|
|
601
|
+
mstpFolderMenu.style.display = "block";
|
|
602
|
+
}
|
|
603
|
+
},
|
|
569
604
|
handleContextMenuClick(type) {
|
|
570
605
|
let app = this;
|
|
571
606
|
switch (type) {
|
|
@@ -589,6 +624,17 @@
|
|
|
589
624
|
break;
|
|
590
625
|
}
|
|
591
626
|
},
|
|
627
|
+
// NEW: Handle context menu clicks for MSTP folders
|
|
628
|
+
handleMstpFolderContextMenuClick(type) {
|
|
629
|
+
let app = this;
|
|
630
|
+
switch (type) {
|
|
631
|
+
case "updateAllDevices":
|
|
632
|
+
app.updateAllMstpDevices(app.rightClickedMstpFolder);
|
|
633
|
+
break;
|
|
634
|
+
default:
|
|
635
|
+
break;
|
|
636
|
+
}
|
|
637
|
+
},
|
|
592
638
|
handlePointContextMenuClick(type) {
|
|
593
639
|
let app = this;
|
|
594
640
|
switch (type) {
|
|
@@ -603,18 +649,52 @@
|
|
|
603
649
|
break;
|
|
604
650
|
}
|
|
605
651
|
},
|
|
652
|
+
// NEW: Update all devices within an MSTP network folder
|
|
653
|
+
updateAllMstpDevices(slotProps) {
|
|
654
|
+
let app = this;
|
|
655
|
+
|
|
656
|
+
if (!slotProps || !slotProps.node || !slotProps.node.children) {
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
const mstpDevices = slotProps.node.children;
|
|
661
|
+
let updatedCount = 0;
|
|
662
|
+
|
|
663
|
+
// Iterate through all MSTP devices in the folder
|
|
664
|
+
mstpDevices.forEach(function (mstpDevice) {
|
|
665
|
+
// Find the device in the device list
|
|
666
|
+
let device = app.getDeviceFromDeviceList(mstpDevice.ipAddr, mstpDevice.deviceId);
|
|
667
|
+
if (device) {
|
|
668
|
+
app.nodeService.updatePointsForDevice(device).then(function (result) {
|
|
669
|
+
updatedCount++;
|
|
670
|
+
}).catch(function (error) {
|
|
671
|
+
// Handle error silently
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
|
|
676
|
+
// Show user feedback
|
|
677
|
+
if (mstpDevices.length > 0) {
|
|
678
|
+
app.$toast?.add({
|
|
679
|
+
severity: 'info',
|
|
680
|
+
summary: 'Update Started',
|
|
681
|
+
detail: `Updating points for ${mstpDevices.length} devices in ${slotProps.node.label}`,
|
|
682
|
+
life: 3000
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
},
|
|
606
686
|
purgeDevice(slotProps) {
|
|
607
687
|
let app = this;
|
|
608
688
|
let device = app.getDeviceFromDeviceList(slotProps.node.ipAddr, slotProps.node.deviceId);
|
|
609
689
|
if (device) {
|
|
610
|
-
app.nodeService.purgeDevice(device).then(function (result) {});
|
|
690
|
+
app.nodeService.purgeDevice(device).then(function (result) { });
|
|
611
691
|
}
|
|
612
692
|
},
|
|
613
693
|
updatePointsForDevice(slotProps) {
|
|
614
694
|
let app = this;
|
|
615
695
|
let device = app.getDeviceFromDeviceList(slotProps.node.ipAddr, slotProps.node.deviceId);
|
|
616
696
|
if (device) {
|
|
617
|
-
app.nodeService.updatePointsForDevice(device).then(function (result) {});
|
|
697
|
+
app.nodeService.updatePointsForDevice(device).then(function (result) { });
|
|
618
698
|
}
|
|
619
699
|
},
|
|
620
700
|
updatePoint(slotProps) {
|
|
@@ -625,7 +705,7 @@
|
|
|
625
705
|
});
|
|
626
706
|
const deviceKey = `${app.getDeviceAddress(device.address)}-${device.deviceId}`;
|
|
627
707
|
if (device) {
|
|
628
|
-
app.nodeService.updatePoint(deviceKey, pointKey).then(function (result) {});
|
|
708
|
+
app.nodeService.updatePoint(deviceKey, pointKey).then(function (result) { });
|
|
629
709
|
}
|
|
630
710
|
},
|
|
631
711
|
setDeviceName() {
|
|
@@ -660,13 +740,95 @@
|
|
|
660
740
|
|
|
661
741
|
app.nodeService.setPointDisplayName(deviceKey, pointName, pointDisplayName).then(function (result) {
|
|
662
742
|
if (result) {
|
|
663
|
-
|
|
743
|
+
// Update the display name across all UI representations
|
|
744
|
+
app.syncPointDisplayNameAcrossUI(deviceKey, pointName, pointDisplayName);
|
|
745
|
+
app.updatePointsToReadDisplayName(deviceKey, pointName, pointDisplayName);
|
|
664
746
|
}
|
|
665
747
|
});
|
|
666
748
|
}
|
|
667
749
|
|
|
668
750
|
app.showPointNameDialog = false;
|
|
669
751
|
},
|
|
752
|
+
// NEW: Centralized method to sync display names across all UI trees
|
|
753
|
+
syncPointDisplayNameAcrossUI(deviceKey, pointName, newDisplayName) {
|
|
754
|
+
let app = this;
|
|
755
|
+
|
|
756
|
+
// Update in main devices tree
|
|
757
|
+
app.updatePointDisplayNameInDevicesTree(deviceKey, pointName, newDisplayName);
|
|
758
|
+
|
|
759
|
+
// Update in read devices tree
|
|
760
|
+
app.updatePointDisplayNameInReadDevicesTree(deviceKey, pointName, newDisplayName);
|
|
761
|
+
|
|
762
|
+
// Force UI update
|
|
763
|
+
app.$forceUpdate();
|
|
764
|
+
},
|
|
765
|
+
// NEW: Update display name in main devices tree
|
|
766
|
+
updatePointDisplayNameInDevicesTree(deviceKey, pointName, newDisplayName) {
|
|
767
|
+
let app = this;
|
|
768
|
+
let [ipAddress, deviceId] = deviceKey.split('-');
|
|
769
|
+
|
|
770
|
+
// Find the device in main tree
|
|
771
|
+
let deviceIndex = app.devices ? app.devices.findIndex(device =>
|
|
772
|
+
device.ipAddr === ipAddress && device.deviceId.toString() === deviceId) : -1;
|
|
773
|
+
|
|
774
|
+
if (deviceIndex !== -1) {
|
|
775
|
+
// Update direct device points
|
|
776
|
+
let pointIndex = app.devices[deviceIndex].children[0].children.findIndex(point =>
|
|
777
|
+
point.pointName === pointName);
|
|
778
|
+
if (pointIndex !== -1) {
|
|
779
|
+
app.devices[deviceIndex].children[0].children[pointIndex].label = newDisplayName;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// Update MSTP device points if applicable
|
|
783
|
+
app.devices[deviceIndex].children.forEach(child => {
|
|
784
|
+
if (child.label && child.label.includes("MSTP") && child.children) {
|
|
785
|
+
child.children.forEach(mstpDevice => {
|
|
786
|
+
if (mstpDevice.deviceId.toString() === deviceId) {
|
|
787
|
+
let mstpPointIndex = mstpDevice.children[0].children.findIndex(point =>
|
|
788
|
+
point.pointName === pointName);
|
|
789
|
+
if (mstpPointIndex !== -1) {
|
|
790
|
+
mstpDevice.children[0].children[mstpPointIndex].label = newDisplayName;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
},
|
|
798
|
+
// NEW: Update display name in read devices tree
|
|
799
|
+
updatePointDisplayNameInReadDevicesTree(deviceKey, pointName, newDisplayName) {
|
|
800
|
+
let app = this;
|
|
801
|
+
let [ipAddress, deviceId] = deviceKey.split('-');
|
|
802
|
+
|
|
803
|
+
if (!app.readDevices) return;
|
|
804
|
+
|
|
805
|
+
// Find the device in read devices tree
|
|
806
|
+
let readDeviceIndex = app.readDevices.findIndex(device =>
|
|
807
|
+
device.deviceId.toString() === deviceId);
|
|
808
|
+
|
|
809
|
+
if (readDeviceIndex !== -1) {
|
|
810
|
+
let pointIndex = app.readDevices[readDeviceIndex].children[0].children.findIndex(point =>
|
|
811
|
+
point.pointName === pointName);
|
|
812
|
+
if (pointIndex !== -1) {
|
|
813
|
+
app.readDevices[readDeviceIndex].children[0].children[pointIndex].label = newDisplayName;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
},
|
|
817
|
+
// NEW: Update display name in pointsToRead data structure
|
|
818
|
+
updatePointsToReadDisplayName(deviceKey, pointName, newDisplayName) {
|
|
819
|
+
let app = this;
|
|
820
|
+
|
|
821
|
+
if (app.pointsToRead && app.pointsToRead[deviceKey]) {
|
|
822
|
+
// Find the point by objectName (since pointsToRead uses objectName as key)
|
|
823
|
+
for (let objectName in app.pointsToRead[deviceKey]) {
|
|
824
|
+
let point = app.pointsToRead[deviceKey][objectName];
|
|
825
|
+
if (point && point.objectName === pointName) {
|
|
826
|
+
point.displayName = newDisplayName;
|
|
827
|
+
break;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
},
|
|
670
832
|
getDeviceFromDeviceList(ip, id) {
|
|
671
833
|
let app = this;
|
|
672
834
|
let device = app.deviceList.find((ele) => {
|
|
@@ -896,7 +1058,30 @@
|
|
|
896
1058
|
app.$forceUpdate();
|
|
897
1059
|
},
|
|
898
1060
|
refreshReadListTree() {
|
|
899
|
-
|
|
1061
|
+
// Enhanced refresh that maintains display names
|
|
1062
|
+
let app = this;
|
|
1063
|
+
|
|
1064
|
+
// First apply any saved display names to the current pointsToRead
|
|
1065
|
+
app.applyStoredDisplayNames();
|
|
1066
|
+
|
|
1067
|
+
// Then rebuild the read list tree
|
|
1068
|
+
app.addToReadDevices(app.pointsToRead);
|
|
1069
|
+
},
|
|
1070
|
+
// NEW: Apply stored display names from backend to current data
|
|
1071
|
+
applyStoredDisplayNames() {
|
|
1072
|
+
let app = this;
|
|
1073
|
+
|
|
1074
|
+
if (!app.pointsToRead) return;
|
|
1075
|
+
|
|
1076
|
+
// Send current pointsToRead to backend to apply any stored display names
|
|
1077
|
+
let msg = { applyDisplayNames: true };
|
|
1078
|
+
// This will be handled by the backend node to apply stored display names
|
|
1079
|
+
app.nodeService.applyDisplayNames(app.pointsToRead).then(function (result) {
|
|
1080
|
+
if (result) {
|
|
1081
|
+
// Refresh the main tree with updated display names
|
|
1082
|
+
app.getData();
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
900
1085
|
},
|
|
901
1086
|
calculateMstpCount(slotProps) {
|
|
902
1087
|
let count = 0;
|
|
@@ -912,6 +1097,7 @@
|
|
|
912
1097
|
let count = 0;
|
|
913
1098
|
return count;
|
|
914
1099
|
},
|
|
1100
|
+
|
|
915
1101
|
},
|
|
916
1102
|
components: {
|
|
917
1103
|
"p-tree": primevue.tree,
|
|
@@ -970,6 +1156,13 @@
|
|
|
970
1156
|
pointMenu.style.display = "none";
|
|
971
1157
|
});
|
|
972
1158
|
|
|
1159
|
+
var mstpFolderMenu = document.querySelector(".mstp-folder-context-menu");
|
|
1160
|
+
window.addEventListener("click", (event) => {
|
|
1161
|
+
if (menu) menu.style.display = "none";
|
|
1162
|
+
if (pointMenu) pointMenu.style.display = "none";
|
|
1163
|
+
if (mstpFolderMenu) mstpFolderMenu.style.display = "none";
|
|
1164
|
+
});
|
|
1165
|
+
|
|
973
1166
|
function handleCheckboxClick() {
|
|
974
1167
|
if (this.id == "node-input-object_property_simplePayload") {
|
|
975
1168
|
document.getElementById("node-input-object_property_fullObject").checked = false;
|
|
@@ -1113,6 +1306,18 @@
|
|
|
1113
1306
|
</ul>
|
|
1114
1307
|
<!-- End Point Context Menu -->
|
|
1115
1308
|
|
|
1309
|
+
<!-- Start MSTP Folder Context Menu -->
|
|
1310
|
+
<ul
|
|
1311
|
+
class="red-ui-menu red-ui-menu-dropdown red-ui-menu-dropdown-direction-right red-ui-menu-dropdown-noicons red-ui-menu-dropdown-submenus mstp-folder-context-menu">
|
|
1312
|
+
<li class="context-menu-item" @click="handleMstpFolderContextMenuClick('updateAllDevices')">
|
|
1313
|
+
<a class="red-ui-menu-label">
|
|
1314
|
+
<i class="pi pi-refresh context-menu-icon"></i>
|
|
1315
|
+
<span class="context-menu-item-text">Update All Devices</span>
|
|
1316
|
+
</a>
|
|
1317
|
+
</li>
|
|
1318
|
+
</ul>
|
|
1319
|
+
<!-- End MSTP Folder Context Menu -->
|
|
1320
|
+
|
|
1116
1321
|
<!--
|
|
1117
1322
|
*
|
|
1118
1323
|
*
|
|
@@ -1194,6 +1399,7 @@
|
|
|
1194
1399
|
filterMode="lenient"
|
|
1195
1400
|
filterPlaceholder="No results found."
|
|
1196
1401
|
v-if="hasData()">
|
|
1402
|
+
|
|
1197
1403
|
<template #device="slotProps">
|
|
1198
1404
|
<div @contextmenu="onDeviceRightClick(slotProps, $event)" class="p-treenode-label">
|
|
1199
1405
|
<div v-if="isDeviceActive(slotProps)" class="deviceLabelParent">
|
|
@@ -1233,6 +1439,20 @@
|
|
|
1233
1439
|
</div>
|
|
1234
1440
|
</template>
|
|
1235
1441
|
|
|
1442
|
+
|
|
1443
|
+
<template #mstpfolder="slotProps">
|
|
1444
|
+
<div @contextmenu="onMstpFolderRightClick(slotProps, $event)" class="p-treenode-label">
|
|
1445
|
+
<div class="deviceLabelParent">
|
|
1446
|
+
<b class="mstpLabel">
|
|
1447
|
+
<span>{{slotProps.node.label}}</span>
|
|
1448
|
+
<span class="mstpDeviceCount" >
|
|
1449
|
+
{{slotProps.node.children ? slotProps.node.children.length : 0}}
|
|
1450
|
+
</span>
|
|
1451
|
+
</b>
|
|
1452
|
+
</div>
|
|
1453
|
+
</div>
|
|
1454
|
+
</template>
|
|
1455
|
+
|
|
1236
1456
|
<template #point="slotProps" v-model:class="pointContent">
|
|
1237
1457
|
<div @contextmenu="onPointRightClick(slotProps, $event)">
|
|
1238
1458
|
<b class="pointLabel">{{slotProps.node.label}}</b>
|
|
@@ -1253,6 +1473,7 @@
|
|
|
1253
1473
|
</button>
|
|
1254
1474
|
</div>
|
|
1255
1475
|
</template>
|
|
1476
|
+
|
|
1256
1477
|
</p-tree>
|
|
1257
1478
|
<div v-else style="text-align: center; padding-top: 20px;">
|
|
1258
1479
|
<a>Building Tree...</a>
|
|
@@ -1492,4 +1713,4 @@
|
|
|
1492
1713
|
<li><a href="https://wiki.bitpool.com/">wiki.bitpool.com</a> - find more documentation.</li>
|
|
1493
1714
|
<li><a href="https://bacnet.org/">BACnet</a> - find more about the protocol.</li>
|
|
1494
1715
|
</ul>
|
|
1495
|
-
</script>
|
|
1716
|
+
</script>
|
package/bacnet_read.js
CHANGED
|
@@ -99,7 +99,19 @@ module.exports = function (RED) {
|
|
|
99
99
|
useDeviceName = node.useDeviceName;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
// Ensure pointsToRead has the latest display names before processing
|
|
103
|
+
let pointsToReadWithDisplayNames = JSON.parse(JSON.stringify(node.pointsToRead));
|
|
104
|
+
|
|
105
|
+
// Apply any stored display names from the backend data model
|
|
106
|
+
for (let deviceKey in pointsToReadWithDisplayNames) {
|
|
107
|
+
for (let pointKey in pointsToReadWithDisplayNames[deviceKey]) {
|
|
108
|
+
let point = pointsToReadWithDisplayNames[deviceKey][pointKey];
|
|
109
|
+
// The display name should already be preserved in the point object
|
|
110
|
+
// from the setPointDisplayName operations and addPointClicked enhancements
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let readConfig = new ReadCommandConfig(pointsToReadWithDisplayNames, node.object_props, node.roundDecimal);
|
|
103
115
|
|
|
104
116
|
let output = {
|
|
105
117
|
type: "Read",
|
package/inspector.html
CHANGED
|
@@ -186,7 +186,11 @@
|
|
|
186
186
|
</div>
|
|
187
187
|
</template>
|
|
188
188
|
<p-column v-for="col in visibleColumns" :key="col.field" :field="col.field" :header="col.header" sortable
|
|
189
|
-
filter
|
|
189
|
+
filter>
|
|
190
|
+
<template #body="slotProps" v-if="col.field === 'objectType'">
|
|
191
|
+
{{ getObjectTypeString(slotProps.data.objectType) }}
|
|
192
|
+
</template>
|
|
193
|
+
</p-column>
|
|
190
194
|
<template #paginatorstart>
|
|
191
195
|
|
|
192
196
|
</template>
|
|
@@ -331,6 +335,36 @@
|
|
|
331
335
|
},
|
|
332
336
|
},
|
|
333
337
|
methods: {
|
|
338
|
+
getObjectTypeString(objectType) {
|
|
339
|
+
switch (objectType) {
|
|
340
|
+
case 0:
|
|
341
|
+
return "Analog Input";
|
|
342
|
+
case 1:
|
|
343
|
+
return "Analog Output";
|
|
344
|
+
case 2:
|
|
345
|
+
return "Analog Value";
|
|
346
|
+
case 3:
|
|
347
|
+
return "Binary Input";
|
|
348
|
+
case 4:
|
|
349
|
+
return "Binary Output";
|
|
350
|
+
case 5:
|
|
351
|
+
return "Binary Value";
|
|
352
|
+
case 8:
|
|
353
|
+
return "Device";
|
|
354
|
+
case 10:
|
|
355
|
+
return "File";
|
|
356
|
+
case 13:
|
|
357
|
+
return "Multistate Input";
|
|
358
|
+
case 14:
|
|
359
|
+
return "Multistate Output";
|
|
360
|
+
case 19:
|
|
361
|
+
return "Multistate Value";
|
|
362
|
+
case 40:
|
|
363
|
+
return "Character String";
|
|
364
|
+
default:
|
|
365
|
+
return "";
|
|
366
|
+
}
|
|
367
|
+
},
|
|
334
368
|
statusItemClicked(e) {
|
|
335
369
|
// Get the filter category from the clicked item's text content
|
|
336
370
|
const clickedItem = e.currentTarget;
|