@bitpoolos/edge-bacnet 1.6.1 → 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.
@@ -339,7 +339,9 @@
339
339
  cursor: not-allowed;
340
340
  }
341
341
  }
342
-
342
+ .mstpLabel {
343
+ font-weight: 400;
344
+ }
343
345
  .point-context-menu {
344
346
  --mouse-x: 0;
345
347
  --mouse-y: 0;
@@ -352,6 +354,18 @@
352
354
  transform: translateX(min(var(--mouse-x), calc(100vw - 100%))) translateY(min(var(--mouse-y), calc(100vh - 100%)));
353
355
  z-index: 10;
354
356
  }
357
+ .mstp-folder-context-menu {
358
+ --mouse-x: 0;
359
+ --mouse-y: 0;
360
+ display: none;
361
+ position: fixed;
362
+ margin: 0;
363
+ left: 0;
364
+ top: 0;
365
+ /* The following line is responsible for all the magic */
366
+ transform: translateX(min(var(--mouse-x), calc(100vw - 100%))) translateY(min(var(--mouse-y), calc(100vh - 100%)));
367
+ z-index: 10;
368
+ }
355
369
  .context-menu {
356
370
  --mouse-x: 0;
357
371
  --mouse-y: 0;
@@ -765,4 +779,17 @@
765
779
  .p-confirm-dialog-accept > .p-button-label,
766
780
  .bacnetServerRebuildSchedule_clearButton > .p-button-label {
767
781
  color: white;
782
+ }
783
+
784
+ .deviceFolderLabel {
785
+ display: flex;
786
+ align-items: center;
787
+ color: #333;
788
+ font-weight: 600;
789
+ }
790
+
791
+ .deviceFolderLabel:hover {
792
+ background-color: #f8f9fa;
793
+ border-radius: 4px;
794
+ padding: 2px 4px;
768
795
  }
@@ -278,14 +278,14 @@ async function generatePrimeVueAppHtmlStatic(appData, filename = "bacnet-inspect
278
278
  // Calculate percentages
279
279
  const total = this.tableData.length || 1; // Avoid division by zero
280
280
  this.statPercentages = {
281
- readCount: Math.round((this.statCounts.readCount / total) * 100) || 0,
282
- ok: Math.round((this.statCounts.statBlock?.ok / total) * 100) || 0,
283
- error: Math.round((this.statCounts.statBlock?.error / total) * 100) || 0,
284
- missing: Math.round((this.statCounts.statBlock?.missing / total) * 100) || 0,
285
- warnings: Math.round((this.statCounts.statBlock?.warnings / total) * 100) || 0,
286
- deviceIdChange: Math.round((this.statCounts.statBlock?.deviceIdChange / total) * 100) || 0,
287
- deviceIdConflict: Math.round((this.statCounts.statBlock?.deviceIdConflict / total) * 100) || 0,
288
- unmapped: Math.round((this.statCounts.statBlock?.unmapped / total) * 100) || 0
281
+ readCount: Math.round((this.statCounts.readCount / total) * 10000) / 100 || 0,
282
+ ok: Math.round((this.statCounts.statBlock.ok / total) * 10000) / 100 || 0,
283
+ error: Math.round((this.statCounts.statBlock.error / total) * 10000) / 100 || 0,
284
+ missing: Math.round((this.statCounts.statBlock.missing / total) * 10000) / 100 || 0,
285
+ warnings: Math.round((this.statCounts.statBlock.warnings / total) * 10000) / 100 || 0,
286
+ deviceIdChange: Math.round((this.statCounts.statBlock.deviceIdChange / total) * 10000) / 100 || 0,
287
+ deviceIdConflict: Math.round((this.statCounts.statBlock.deviceIdConflict / total) * 10000) / 100 || 0,
288
+ unmapped: Math.round((this.statCounts.statBlock.unmapped / total) * 10000) / 100 || 0
289
289
  };
290
290
  },
291
291
  computed: {
package/treeBuilder.js CHANGED
@@ -1,6 +1,29 @@
1
1
  const { queueConfigStore } = require("./common");
2
2
  const { BacnetDevice } = require("./bacnet_device");
3
3
 
4
+ // Global state for smart caching - minimal memory overhead
5
+ let lastCacheTime = 0;
6
+ let lastDataHash = "";
7
+ let cacheInterval = 30000; // Start with 30 seconds
8
+ let consecutiveNoChangeCount = 0;
9
+ const MAX_CACHE_INTERVAL = 300000; // Max 5 minutes
10
+ const MIN_CACHE_INTERVAL = 20000; // Min 20 seconds
11
+
12
+ /**
13
+ * Simple hash function for change detection
14
+ */
15
+ function simpleHash(data) {
16
+ const str = JSON.stringify(data);
17
+ let hash = 0;
18
+ for (let i = 0; i < str.length; i++) {
19
+ const char = str.charCodeAt(i);
20
+ hash = ((hash << 5) - hash) + char;
21
+ hash = hash & hash; // Convert to 32bit integer
22
+ }
23
+
24
+ return hash.toString();
25
+ }
26
+
4
27
  /**
5
28
  * The `treeBuilder` class is responsible for building and processing the network tree structure.
6
29
  * It takes in a list of devices, a network tree object, a render list, a render list count, and an initial tree build flag.
@@ -27,17 +50,69 @@ class treeBuilder {
27
50
  }
28
51
 
29
52
  /**
30
- * Cache the current state of the network tree and other data.
53
+ * Smart cache with change detection and adaptive timing.
54
+ * Only writes to file when data actually changes, with intelligent interval adjustment.
31
55
  *
32
56
  * @returns {void}
33
57
  */
34
58
  cacheData() {
35
- // Cache the current state of the network tree and other data
59
+ const now = Date.now();
60
+
61
+ // Always allow caching on initial build
62
+ if (this.initialTreeBuild) {
63
+ this.performCache();
64
+ return;
65
+ }
66
+
67
+ // Check if enough time has passed since last cache attempt
68
+ if (now - lastCacheTime < cacheInterval) {
69
+ return; // Skip this cache attempt
70
+ }
71
+
72
+ // Prepare data for hashing (only essential data to minimize hash computation)
73
+ const cacheData = {
74
+ deviceList: this.deviceList,
75
+ pointList: this.networkTree,
76
+ };
77
+
78
+ // Generate hash of current data
79
+ const currentHash = simpleHash(cacheData);
80
+
81
+ // Check if data has actually changed
82
+ if (currentHash === lastDataHash) {
83
+ // No changes detected - increase cache interval (adaptive backing off)
84
+ consecutiveNoChangeCount++;
85
+ // Exponential backoff with cap
86
+ if (consecutiveNoChangeCount >= 3) {
87
+ cacheInterval = Math.min(cacheInterval * 1.5, MAX_CACHE_INTERVAL);
88
+ }
89
+
90
+ lastCacheTime = now;
91
+ return; // Skip caching since no changes
92
+ }
93
+
94
+ // Data has changed - perform cache and reset adaptive timing
95
+ lastDataHash = currentHash;
96
+ lastCacheTime = now;
97
+ consecutiveNoChangeCount = 0;
98
+
99
+ // Reset interval to be more responsive during active changes
100
+ cacheInterval = Math.max(cacheInterval * 0.8, MIN_CACHE_INTERVAL);
101
+
102
+ // Perform the actual cache operation
103
+ this.performCache();
104
+ }
105
+
106
+ /**
107
+ * Performs the actual cache operation
108
+ */
109
+ performCache() {
110
+ // Cache only the essential data, exclude renderList as it's too large and can be rebuilt
36
111
  queueConfigStore({
37
- renderList: this.renderList,
38
112
  deviceList: this.deviceList,
39
113
  pointList: this.networkTree,
40
- renderListCount: this.renderListCount,
114
+ // renderList: excluded to reduce file size - will be rebuilt from deviceList and networkTree
115
+ // renderListCount: excluded as it can be recalculated
41
116
  });
42
117
  }
43
118
 
@@ -364,7 +439,7 @@ class treeBuilder {
364
439
  label: `MSTP NET${mstpNetworkNumber}`,
365
440
  data: `Devices Folder (${mstpNetworkNumber})`,
366
441
  icon: 'pi pi-database',
367
- type: 'deviceFolder',
442
+ type: 'mstpfolder',
368
443
  children: [],
369
444
  };
370
445