@bitpoolos/edge-bacnet 1.6.3 → 1.6.4

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/treeBuilder.js CHANGED
@@ -13,15 +13,15 @@ const MIN_CACHE_INTERVAL = 20000; // Min 20 seconds
13
13
  * Simple hash function for change detection
14
14
  */
15
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();
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
25
  }
26
26
 
27
27
  /**
@@ -41,660 +41,701 @@ function simpleHash(data) {
41
41
  * @param {boolean} initialTreeBuild - The initial tree build flag.
42
42
  */
43
43
  class treeBuilder {
44
- constructor(deviceList, networkTree, renderList, renderListCount, initialTreeBuild) {
45
- this.deviceList = deviceList;
46
- this.networkTree = networkTree;
47
- this.renderList = renderList;
48
- this.renderListCount = renderListCount;
49
- this.initialTreeBuild = initialTreeBuild;
44
+ constructor(deviceList, networkTree, renderList, renderListCount, initialTreeBuild) {
45
+ this.deviceList = deviceList;
46
+ this.networkTree = networkTree;
47
+ this.renderList = renderList;
48
+ this.renderListCount = renderListCount;
49
+ this.initialTreeBuild = initialTreeBuild;
50
+ }
51
+
52
+ /**
53
+ * Smart cache with change detection and adaptive timing.
54
+ * Only writes to file when data actually changes, with intelligent interval adjustment.
55
+ *
56
+ * @returns {void}
57
+ */
58
+ cacheData() {
59
+ const now = Date.now();
60
+
61
+ // Always allow caching on initial build
62
+ if (this.initialTreeBuild) {
63
+ this.performCache();
64
+ return;
50
65
  }
51
66
 
52
- /**
53
- * Smart cache with change detection and adaptive timing.
54
- * Only writes to file when data actually changes, with intelligent interval adjustment.
55
- *
56
- * @returns {void}
57
- */
58
- cacheData() {
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();
67
+ // Check if enough time has passed since last cache attempt
68
+ if (now - lastCacheTime < cacheInterval) {
69
+ return; // Skip this cache attempt
104
70
  }
105
71
 
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
111
- queueConfigStore({
112
- deviceList: this.deviceList,
113
- pointList: this.networkTree,
114
- // renderList: excluded to reduce file size - will be rebuilt from deviceList and networkTree
115
- // renderListCount: excluded as it can be recalculated
116
- });
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
117
92
  }
118
93
 
119
- /**
120
- * Process a device and its points.
121
- *
122
- * @param {Device} device - The device to process.
123
- * @param {number} index - The index of the device.
124
- * @returns {Promise<void>} - A promise that resolves when the device and its points have been processed.
125
- */
126
- async processDevice(device, index) {
127
- const ipAddress = this.getDeviceIpAddress(device);
128
- const deviceId = device.getDeviceId();
129
- const deviceName = this.computeDeviceName(device);
130
- const deviceKey = `${ipAddress}-${deviceId}`;
131
- const deviceObject = this.networkTree[deviceKey];
132
-
133
- // Add the root device folder to the render list
134
- if (this.initialTreeBuild) {
135
- this.addRootDeviceFolder(device, deviceName, index, ipAddress, deviceId);
136
- }
137
-
138
- // Check if the device object exists and the device name is valid
139
- if (deviceObject) {
140
- await this.processDevicePoints(device, deviceObject, deviceName, ipAddress, deviceId, index);
141
-
142
- //delete dummy object if all conditions satisfied
143
- if (deviceName !== null) {
144
- if (deviceId !== null) {
145
- let lastIndex = deviceName.lastIndexOf(deviceId);
146
- if (lastIndex) {
147
- let formattedName = deviceName.substring(0, lastIndex);
148
- formattedName = `${formattedName.trim()}_Device_${deviceId}`;
149
- if (
150
- this.networkTree[deviceKey][formattedName] &&
151
- Object.keys(this.networkTree[deviceKey][formattedName]).length > 0 &&
152
- this.networkTree[deviceKey]["device"]
153
- ) {
154
- delete this.networkTree[deviceKey]["device"];
155
- }
156
- }
157
- }
158
- }
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
111
+ queueConfigStore({
112
+ deviceList: this.deviceList,
113
+ pointList: this.networkTree,
114
+ // renderList: excluded to reduce file size - will be rebuilt from deviceList and networkTree
115
+ // renderListCount: excluded as it can be recalculated
116
+ });
117
+ }
118
+
119
+ /**
120
+ * Process a device and its points.
121
+ *
122
+ * @param {Device} device - The device to process.
123
+ * @param {number} index - The index of the device.
124
+ * @returns {Promise<void>} - A promise that resolves when the device and its points have been processed.
125
+ */
126
+ async processDevice(device, index) {
127
+ const ipAddress = this.getDeviceIpAddress(device);
128
+ const deviceId = device.getDeviceId();
129
+ const deviceName = this.computeDeviceName(device);
130
+ const deviceKey = `${ipAddress}-${deviceId}`;
131
+ const deviceObject = this.networkTree[deviceKey];
132
+
133
+ // Add the root device folder to the render list
134
+ if (this.initialTreeBuild) {
135
+ this.addRootDeviceFolder(device, deviceName, index, ipAddress, deviceId);
136
+ }
159
137
 
160
- } else {
161
- //invalid ip object, likely dumb mstp router
162
- if (device.getIsDumbMstpRouter()) {
163
- //update dumb mstp router name
164
- await this.updateDumbMstpRouterName(deviceName, ipAddress, deviceId);
138
+ // Check if the device object exists and the device name is valid
139
+ if (deviceObject) {
140
+ await this.processDevicePoints(device, deviceObject, deviceName, ipAddress, deviceId, index);
141
+
142
+ //delete dummy object if all conditions satisfied
143
+ if (deviceName !== null) {
144
+ if (deviceId !== null) {
145
+ let lastIndex = deviceName.lastIndexOf(deviceId);
146
+ if (lastIndex) {
147
+ let formattedName = deviceName.substring(0, lastIndex);
148
+ formattedName = `${formattedName.trim()}_Device_${deviceId}`;
149
+ if (
150
+ this.networkTree[deviceKey][formattedName] &&
151
+ Object.keys(this.networkTree[deviceKey][formattedName]).length > 0 &&
152
+ this.networkTree[deviceKey]["device"]
153
+ ) {
154
+ delete this.networkTree[deviceKey]["device"];
165
155
  }
156
+ }
166
157
  }
158
+ }
159
+ } else {
160
+ //invalid ip object, likely dumb mstp router
161
+
162
+ if (device.getIsDumbMstpRouter()) {
163
+ //update dumb mstp router name
164
+ await this.updateDumbMstpRouterName(deviceName, ipAddress, deviceId);
165
+ }
167
166
  }
168
-
169
- async updateDumbMstpRouterName(deviceName, ipAddress, deviceId) {
170
- return new Promise((resolve, reject) => {
171
- let listDeviceIndex = this.renderList.findIndex(item => item.deviceId == deviceId && item.ipAddr == ipAddress && item.isDumbMstpRouter == true);
172
- if (listDeviceIndex !== -1) {
173
- this.renderList[listDeviceIndex].label = deviceName;
174
- this.renderList[listDeviceIndex].data = deviceName;
175
- }
176
- resolve();
177
- });
167
+ }
168
+
169
+ async updateDumbMstpRouterName(deviceName, ipAddress, deviceId) {
170
+ return new Promise((resolve, reject) => {
171
+ let listDeviceIndex = this.renderList.findIndex(
172
+ (item) => item.deviceId == deviceId && item.ipAddr == ipAddress && item.isDumbMstpRouter == true
173
+ );
174
+ if (listDeviceIndex !== -1) {
175
+ this.renderList[listDeviceIndex].label = deviceName;
176
+ this.renderList[listDeviceIndex].data = deviceName;
177
+ }
178
+ resolve();
179
+ });
180
+ }
181
+
182
+ /**
183
+ * Add the root device folder to the render list.
184
+ *
185
+ * @param {Object} device - The device object.
186
+ * @param {string} deviceName - The name of the device.
187
+ * @param {number} index - The index of the device.
188
+ * @param {string} ipAddress - The IP address of the device.
189
+ * @param {string} deviceId - The ID of the device.
190
+ * @returns {void}
191
+ */
192
+ addRootDeviceFolder(device, deviceName, index, ipAddress, deviceId) {
193
+ if (!this.renderList) {
194
+ this.renderList = [];
178
195
  }
179
196
 
180
- /**
181
- * Add the root device folder to the render list.
182
- *
183
- * @param {Object} device - The device object.
184
- * @param {string} deviceName - The name of the device.
185
- * @param {number} index - The index of the device.
186
- * @param {string} ipAddress - The IP address of the device.
187
- * @param {string} deviceId - The ID of the device.
188
- * @returns {void}
189
- */
190
- addRootDeviceFolder(device, deviceName, index, ipAddress, deviceId) {
191
- if (!this.renderList) {
192
- this.renderList = [];
193
- }
197
+ if (!device.getIsMstpDevice()) {
198
+ let displayName = deviceName ? deviceName : `${ipAddress} - ${deviceId}`;
199
+
200
+ // Check if the device already exists in the renderList
201
+ const existingDeviceIndex = this.renderList.findIndex((item) => item.deviceId === deviceId && item.ipAddr === ipAddress);
202
+ if (existingDeviceIndex === -1) {
203
+ // Device not found, add new entry
204
+ let isDumbMstpRouter = false;
205
+ if (device.getIsDumbMstpRouter() && deviceId == null) isDumbMstpRouter = true;
206
+ const rootFolder = {
207
+ key: index,
208
+ label: displayName,
209
+ data: displayName,
210
+ icon: this.getDeviceIcon(device),
211
+ children: [
212
+ {
213
+ key: `${deviceId}-0`,
214
+ label: "Points",
215
+ data: "Points Folder",
216
+ icon: "pi pi-circle-fill",
217
+ type: "pointFolder",
218
+ children: [],
219
+ },
220
+ ],
221
+ type: "device",
222
+ lastSeen: device.getLastSeen(),
223
+ showAdded: false,
224
+ ipAddr: ipAddress,
225
+ deviceId,
226
+ isMstpDevice: device.getIsMstpDevice(),
227
+ initialName: device.getDeviceName(),
228
+ isDumbMstpRouter: isDumbMstpRouter,
229
+ };
194
230
 
195
- if (!device.getIsMstpDevice()) {
196
- let displayName = deviceName ? deviceName : `${ipAddress} - ${deviceId}`;
197
-
198
- // Check if the device already exists in the renderList
199
- const existingDeviceIndex = this.renderList.findIndex(item => item.deviceId === deviceId && item.ipAddr === ipAddress);
200
- if (existingDeviceIndex === -1) { // Device not found, add new entry
201
- let isDumbMstpRouter = false;
202
- if (device.getIsDumbMstpRouter() && deviceId == null) isDumbMstpRouter = true;
203
- const rootFolder = {
204
- key: index,
205
- label: displayName,
206
- data: displayName,
207
- icon: this.getDeviceIcon(device),
208
- children: [{ key: `${deviceId}-0`, label: 'Points', data: 'Points Folder', icon: 'pi pi-circle-fill', type: 'pointFolder', children: [] }],
209
- type: 'device',
210
- lastSeen: device.getLastSeen(),
211
- showAdded: false,
212
- ipAddr: ipAddress,
213
- deviceId,
214
- isMstpDevice: device.getIsMstpDevice(),
215
- initialName: device.getDeviceName(),
216
- isDumbMstpRouter: isDumbMstpRouter,
217
- };
218
-
219
- // Add the root folder to the render list
220
- this.renderList.push(rootFolder);
221
- }
222
- }
231
+ // Add the root folder to the render list
232
+ this.renderList.push(rootFolder);
233
+ }
223
234
  }
224
-
225
- addEmptyIpRootDevice(childDevice) {
226
- const ipAddress = this.getDeviceIpAddress(childDevice);
227
-
228
- //let deviceIndex = this.deviceList.findIndex(ele => ele.address === ipAddress && ele.deviceId === null && ele.deviceName === ipAddress && ele.displayName === ipAddress);
229
- let deviceIndex = this.deviceList.findIndex(ele => ele.address === ipAddress && ele.deviceId === null);
230
-
231
- if (deviceIndex === -1) {
232
- let newDevice = {
233
- address: ipAddress,
234
- isMstp: false,
235
- deviceId: null,
236
- maxApdu: childDevice.getMaxApdu(),
237
- segmentation: childDevice.getSegmentation(),
238
- vendorId: childDevice.getVendorId(),
239
- lastSeen: null,
240
- deviceName: ipAddress,
241
- pointsList: [],
242
- pointListUpdateTs: null,
243
- manualDiscoveryMode: false,
244
- pointListRetryCount: 0,
245
- priorityQueueIsActive: false,
246
- priorityQueue: [],
247
- lastPriorityQueueTS: null,
248
- childDevices: [childDevice.getDeviceId()],
249
- parentDeviceId: null,
250
- displayName: ipAddress,
251
- protocolServicesSupported: [],
252
- isProtocolServicesSet: false,
253
- isInitialQuery: true,
254
- isDumbMstpRouter: true,
255
- };
256
-
257
- let newBacnetDevice = new BacnetDevice(true, newDevice);
258
- this.deviceList.push(newBacnetDevice);
259
- }
235
+ }
236
+
237
+ addEmptyIpRootDevice(childDevice) {
238
+ const ipAddress = this.getDeviceIpAddress(childDevice);
239
+
240
+ //let deviceIndex = this.deviceList.findIndex(ele => ele.address === ipAddress && ele.deviceId === null && ele.deviceName === ipAddress && ele.displayName === ipAddress);
241
+ let deviceIndex = this.deviceList.findIndex((ele) => ele.address === ipAddress && ele.deviceId === null);
242
+
243
+ if (deviceIndex === -1) {
244
+ let newDevice = {
245
+ address: ipAddress,
246
+ isMstp: false,
247
+ deviceId: null,
248
+ maxApdu: childDevice.getMaxApdu(),
249
+ segmentation: childDevice.getSegmentation(),
250
+ vendorId: childDevice.getVendorId(),
251
+ lastSeen: null,
252
+ deviceName: ipAddress,
253
+ pointsList: [],
254
+ pointListUpdateTs: null,
255
+ manualDiscoveryMode: false,
256
+ pointListRetryCount: 0,
257
+ priorityQueueIsActive: false,
258
+ priorityQueue: [],
259
+ lastPriorityQueueTS: null,
260
+ childDevices: [childDevice.getDeviceId()],
261
+ parentDeviceId: null,
262
+ displayName: ipAddress,
263
+ protocolServicesSupported: [],
264
+ isProtocolServicesSet: false,
265
+ isInitialQuery: true,
266
+ isDumbMstpRouter: true,
267
+ };
268
+
269
+ let newBacnetDevice = new BacnetDevice(true, newDevice);
270
+ this.deviceList.push(newBacnetDevice);
260
271
  }
261
-
262
- /**
263
- * Process the points of a device and add them to the render list.
264
- *
265
- * @param {Device} device - The device object.
266
- * @param {Object} deviceObject - The object containing the points of the device.
267
- * @param {string} deviceName - The name of the device.
268
- * @param {string} ipAddress - The IP address of the device.
269
- * @param {string} deviceId - The ID of the device.
270
- * @param {number} index - The index of the device.
271
- * @returns {Promise<void>} - A promise that resolves when the points have been processed and added to the render list.
272
- */
273
- async processDevicePoints(device, deviceObject, deviceName, ipAddress, deviceId, index) {
274
- // Initialize the list of children points
275
- let children = [];
276
-
277
- // Process each point in the device object
278
- for (const pointName in deviceObject) {
279
- // Ensure processing should continue
280
- this.checkInterruptFlag();
281
-
282
- // Process the point and add it to the list of children
283
- const point = deviceObject[pointName];
284
- const childPoint = await this.processPoint(point, pointName, index, deviceName, device);
285
- children.push(childPoint);
286
- }
287
-
288
- // Add the device and its children to the render list
289
- this.updateRenderList(children, device, deviceName, index, ipAddress, deviceId);
272
+ }
273
+
274
+ /**
275
+ * Process the points of a device and add them to the render list.
276
+ *
277
+ * @param {Device} device - The device object.
278
+ * @param {Object} deviceObject - The object containing the points of the device.
279
+ * @param {string} deviceName - The name of the device.
280
+ * @param {string} ipAddress - The IP address of the device.
281
+ * @param {string} deviceId - The ID of the device.
282
+ * @param {number} index - The index of the device.
283
+ * @returns {Promise<void>} - A promise that resolves when the points have been processed and added to the render list.
284
+ */
285
+ async processDevicePoints(device, deviceObject, deviceName, ipAddress, deviceId, index) {
286
+ // Initialize the list of children points
287
+ let children = [];
288
+
289
+ // Process each point in the device object
290
+ for (const pointName in deviceObject) {
291
+ // Ensure processing should continue
292
+ this.checkInterruptFlag();
293
+
294
+ // Process the point and add it to the list of children
295
+ const point = deviceObject[pointName];
296
+ const childPoint = await this.processPoint(point, pointName, index, deviceName, device);
297
+ children.push(childPoint);
290
298
  }
291
299
 
292
- /**
293
- * Process a point and create a child point object.
294
- *
295
- * @param {Object} point - The point to process.
296
- * @param {string} pointName - The name of the point.
297
- * @param {number} index - The index of the point.
298
- * @param {string} deviceName - The name of the parent device.
299
- * @param {Object} device - The parent device object.
300
- * @returns {Object} - The child point object.
301
- */
302
- async processPoint(point, pointName, index, deviceName, device) {
303
- // Get the properties and data of the point
304
- const pointProperties = this.extractPointProperties(point);
305
-
306
- // Determine the point's display name and apply formatting if necessary
307
- const displayName = this.formatDisplayName(point, pointName);
308
-
309
- // Create the child point object
310
- return {
311
- key: `${index}-0-${pointName}`,
312
- label: displayName,
313
- data: displayName,
314
- pointName,
315
- icon: this.getPointIcon(point),
316
- children: pointProperties,
317
- type: 'point',
318
- parentDevice: deviceName,
319
- parentDeviceId: device.getDeviceId(),
320
- showAdded: false,
321
- bacnetType: point.meta.objectId.type,
322
- bacnetInstance: point.meta.objectId.instance,
323
- };
300
+ // Add the device and its children to the render list
301
+ this.updateRenderList(children, device, deviceName, index, ipAddress, deviceId);
302
+ }
303
+
304
+ /**
305
+ * Process a point and create a child point object.
306
+ *
307
+ * @param {Object} point - The point to process.
308
+ * @param {string} pointName - The name of the point.
309
+ * @param {number} index - The index of the point.
310
+ * @param {string} deviceName - The name of the parent device.
311
+ * @param {Object} device - The parent device object.
312
+ * @returns {Object} - The child point object.
313
+ */
314
+ async processPoint(point, pointName, index, deviceName, device) {
315
+ // Get the properties and data of the point
316
+ const pointProperties = this.extractPointProperties(point);
317
+
318
+ // Determine the point's display name and apply formatting if necessary
319
+ const displayName = this.formatDisplayName(point, pointName);
320
+
321
+ // Create the child point object
322
+ return {
323
+ key: `${index}-0-${pointName}`,
324
+ label: displayName,
325
+ data: displayName,
326
+ pointName,
327
+ icon: this.getPointIcon(point),
328
+ children: pointProperties,
329
+ type: "point",
330
+ parentDevice: deviceName,
331
+ parentDeviceId: device.getDeviceId(),
332
+ showAdded: false,
333
+ bacnetType: point.meta.objectId.type,
334
+ bacnetInstance: point.meta.objectId.instance,
335
+ };
336
+ }
337
+
338
+ /**
339
+ * Extracts the properties of a point object.
340
+ *
341
+ * @param {Object} point - The point object to extract properties from.
342
+ * @returns {Array} - An array of point properties.
343
+ */
344
+ extractPointProperties(point) {
345
+ const pointProperties = [];
346
+
347
+ // Add properties such as name, type, instance, and others
348
+ this.addPointProperty(pointProperties, "Name", point.objectName);
349
+ this.addPointProperty(pointProperties, "Object Type", point.meta.objectId.type);
350
+ this.addPointProperty(pointProperties, "Object Instance", point.meta.objectId.instance);
351
+ this.addPointProperty(pointProperties, "Description", point.description);
352
+ this.addPointProperty(pointProperties, "Units", point.units);
353
+ this.addPointProperty(pointProperties, "Present Value", point.presentValue);
354
+ this.addPointProperty(pointProperties, "System Status", point.systemStatus);
355
+ this.addPointProperty(pointProperties, "Modification Date", point.modificationDate);
356
+ this.addPointProperty(pointProperties, "Program State", point.programState);
357
+ this.addPointProperty(pointProperties, "Record Count", point.recordCount);
358
+
359
+ // Return the array of point properties
360
+ return pointProperties;
361
+ }
362
+
363
+ /**
364
+ * Adds a property to the list of point properties.
365
+ *
366
+ * @param {Array} properties - The list of point properties.
367
+ * @param {string} label - The label of the property.
368
+ * @param {any} value - The value of the property.
369
+ * @returns {void}
370
+ */
371
+ addPointProperty(properties, label, value) {
372
+ if (value !== null && value !== undefined && value !== "") {
373
+ properties.push({
374
+ label: `${label}: ${value}`,
375
+ data: value,
376
+ icon: "pi pi-cog",
377
+ children: null,
378
+ });
324
379
  }
325
-
326
- /**
327
- * Extracts the properties of a point object.
328
- *
329
- * @param {Object} point - The point object to extract properties from.
330
- * @returns {Array} - An array of point properties.
331
- */
332
- extractPointProperties(point) {
333
- const pointProperties = [];
334
-
335
- // Add properties such as name, type, instance, and others
336
- this.addPointProperty(pointProperties, 'Name', point.objectName);
337
- this.addPointProperty(pointProperties, 'Object Type', point.meta.objectId.type);
338
- this.addPointProperty(pointProperties, 'Object Instance', point.meta.objectId.instance);
339
- this.addPointProperty(pointProperties, 'Description', point.description);
340
- this.addPointProperty(pointProperties, 'Units', point.units);
341
- this.addPointProperty(pointProperties, 'Present Value', point.presentValue);
342
- this.addPointProperty(pointProperties, 'System Status', point.systemStatus);
343
- this.addPointProperty(pointProperties, 'Modification Date', point.modificationDate);
344
- this.addPointProperty(pointProperties, 'Program State', point.programState);
345
- this.addPointProperty(pointProperties, 'Record Count', point.recordCount);
346
-
347
- // Return the array of point properties
348
- return pointProperties;
380
+ }
381
+
382
+ /**
383
+ * Formats the display name for a point.
384
+ *
385
+ * If the point has a display name, it returns the display name.
386
+ * Otherwise, it removes any special characters from the point name and returns it.
387
+ *
388
+ * @param {Object} point - The point object.
389
+ * @param {string} pointName - The name of the point.
390
+ * @returns {string} - The formatted display name.
391
+ */
392
+ formatDisplayName(point, pointName) {
393
+ const reg = /[$#\/\\+]/gi;
394
+ if (point.displayName) {
395
+ return point.displayName;
349
396
  }
350
-
351
- /**
352
- * Adds a property to the list of point properties.
353
- *
354
- * @param {Array} properties - The list of point properties.
355
- * @param {string} label - The label of the property.
356
- * @param {any} value - The value of the property.
357
- * @returns {void}
358
- */
359
- addPointProperty(properties, label, value) {
360
- if (value !== null && value !== undefined && value !== '') {
361
- properties.push({
362
- label: `${label}: ${value}`,
363
- data: value,
364
- icon: 'pi pi-cog',
365
- children: null,
366
- });
367
- }
397
+ return pointName.replace(reg, "");
398
+ }
399
+
400
+ /**
401
+ * Updates the render list with the folder structure for a device.
402
+ *
403
+ * @param {Array} children - The children of the device.
404
+ * @param {Object} device - The device object.
405
+ * @param {string} deviceName - The name of the device.
406
+ * @param {number} index - The index of the device.
407
+ * @param {string} ipAddress - The IP address of the device.
408
+ * @param {string} deviceId - The ID of the device.
409
+ * @returns {void}
410
+ */
411
+ updateRenderList(children, device, deviceName, index, ipAddress, deviceId) {
412
+ // Create the folder structure for the device
413
+ const folderJson = this.createFolderJson(children, device.hasChildDevices(), deviceId);
414
+ if (!this.renderList) {
415
+ this.renderList = [];
368
416
  }
369
417
 
370
- /**
371
- * Formats the display name for a point.
372
- *
373
- * If the point has a display name, it returns the display name.
374
- * Otherwise, it removes any special characters from the point name and returns it.
375
- *
376
- * @param {Object} point - The point object.
377
- * @param {string} pointName - The name of the point.
378
- * @returns {string} - The formatted display name.
379
- */
380
- formatDisplayName(point, pointName) {
381
- const reg = /[$#\/\\+]/gi;
382
- if (point.displayName) {
383
- return point.displayName;
418
+ // Find the device's entry in the render list
419
+ let foundIndex = this.renderList.findIndex((ele) => ele.deviceId == deviceId && ele.ipAddr == ipAddress);
420
+
421
+ // If the device is not in the render list, add it as a new entry
422
+ const newDeviceEntry = {
423
+ key: index,
424
+ label: deviceName,
425
+ data: deviceName,
426
+ icon: this.getDeviceIcon(device),
427
+ children: folderJson,
428
+ type: "device",
429
+ lastSeen: device.getLastSeen(),
430
+ showAdded: false,
431
+ ipAddr: ipAddress,
432
+ deviceId,
433
+ isMstpDevice: device.getIsMstpDevice(),
434
+ initialName: device.getDeviceName(),
435
+ };
436
+
437
+ if (device.getIsMstpDevice()) {
438
+ // For child MSTP devices, find the parent device and the MSTP network folder
439
+ const parentDeviceId = device.getParentDeviceId();
440
+ const parentDeviceIndex = this.renderList.findIndex((ele) => ele.deviceId == parentDeviceId && ele.ipAddr == ipAddress);
441
+ const mstpNetworkNumber = device.getMstpNetworkNumber();
442
+
443
+ if (parentDeviceIndex !== -1) {
444
+ let parentDeviceEntry = this.renderList[parentDeviceIndex];
445
+ let mstpNetworkFolder = parentDeviceEntry.children.find((child) => child.label === `MSTP NET${mstpNetworkNumber}`);
446
+
447
+ // Create the MSTP network folder if it doesn't exist
448
+ if (!mstpNetworkFolder) {
449
+ mstpNetworkFolder = {
450
+ key: `${deviceId}-mstp-${mstpNetworkNumber}`,
451
+ label: `MSTP NET${mstpNetworkNumber}`,
452
+ data: `Devices Folder (${mstpNetworkNumber})`,
453
+ icon: "pi pi-database",
454
+ type: "mstpfolder",
455
+ children: [],
456
+ };
457
+
458
+ parentDeviceEntry.children.push(mstpNetworkFolder);
384
459
  }
385
- return pointName.replace(reg, '');
386
- }
387
460
 
388
- /**
389
- * Updates the render list with the folder structure for a device.
390
- *
391
- * @param {Array} children - The children of the device.
392
- * @param {Object} device - The device object.
393
- * @param {string} deviceName - The name of the device.
394
- * @param {number} index - The index of the device.
395
- * @param {string} ipAddress - The IP address of the device.
396
- * @param {string} deviceId - The ID of the device.
397
- * @returns {void}
398
- */
399
- updateRenderList(children, device, deviceName, index, ipAddress, deviceId) {
400
- // Create the folder structure for the device
401
- const folderJson = this.createFolderJson(children, device.hasChildDevices(), deviceId);
402
- if (!this.renderList) {
403
- this.renderList = [];
461
+ // Add or update the child MSTP device in the MSTP folder
462
+ const mstpDeviceIndex = mstpNetworkFolder.children.findIndex(
463
+ (ele) => ele.deviceId == deviceId && ele.ipAddr == ipAddress
464
+ );
465
+ if (mstpDeviceIndex === -1) {
466
+ mstpNetworkFolder.children.push(newDeviceEntry);
467
+ } else {
468
+ mstpNetworkFolder.children[mstpDeviceIndex] = newDeviceEntry;
404
469
  }
405
-
406
- // Find the device's entry in the render list
407
- let foundIndex = this.renderList.findIndex(ele => ele.deviceId == deviceId && ele.ipAddr == ipAddress);
408
-
409
- // If the device is not in the render list, add it as a new entry
410
- const newDeviceEntry = {
411
- key: index,
412
- label: deviceName,
413
- data: deviceName,
414
- icon: this.getDeviceIcon(device),
415
- children: folderJson,
416
- type: 'device',
417
- lastSeen: device.getLastSeen(),
418
- showAdded: false,
419
- ipAddr: ipAddress,
420
- deviceId,
421
- isMstpDevice: device.getIsMstpDevice(),
422
- initialName: device.getDeviceName(),
423
- };
424
-
425
- if (device.getIsMstpDevice()) {
426
- // For child MSTP devices, find the parent device and the MSTP network folder
427
- const parentDeviceId = device.getParentDeviceId();
428
- const parentDeviceIndex = this.renderList.findIndex(ele => ele.deviceId == parentDeviceId && ele.ipAddr == ipAddress);
429
- const mstpNetworkNumber = device.getMstpNetworkNumber();
430
-
431
- if (parentDeviceIndex !== -1) {
432
- let parentDeviceEntry = this.renderList[parentDeviceIndex];
433
- let mstpNetworkFolder = parentDeviceEntry.children.find(child => child.label === `MSTP NET${mstpNetworkNumber}`);
434
-
435
- // Create the MSTP network folder if it doesn't exist
436
- if (!mstpNetworkFolder) {
437
- mstpNetworkFolder = {
438
- key: `${deviceId}-mstp-${mstpNetworkNumber}`,
439
- label: `MSTP NET${mstpNetworkNumber}`,
440
- data: `Devices Folder (${mstpNetworkNumber})`,
441
- icon: 'pi pi-database',
442
- type: 'mstpfolder',
443
- children: [],
444
- };
445
-
446
- parentDeviceEntry.children.push(mstpNetworkFolder);
447
- }
448
-
449
- // Add or update the child MSTP device in the MSTP folder
450
- const mstpDeviceIndex = mstpNetworkFolder.children.findIndex(ele => ele.deviceId == deviceId && ele.ipAddr == ipAddress);
451
- if (mstpDeviceIndex === -1) {
452
- mstpNetworkFolder.children.push(newDeviceEntry);
453
- } else {
454
- mstpNetworkFolder.children[mstpDeviceIndex] = newDeviceEntry;
455
- }
456
- } else {
457
- //no parent found in render list
458
-
459
- if (parentDeviceId !== null) {
460
- let parentDeviceListIndex = this.deviceList.findIndex(ele => ele.getDeviceId == parentDeviceId);
461
-
462
- if (parentDeviceListIndex !== -1) {
463
- let parentDevice = this.deviceList[parentDeviceListIndex];
464
- this.addRootDeviceFolder(parentDevice, parentDevice.getDeviceName(), parentDeviceListIndex, parentDevice.getAddress(), parentDeviceId);
465
- }
466
- } else {
467
- this.addEmptyIpRootDevice(device);
468
- }
469
- }
470
-
470
+ } else {
471
+ //no parent found in render list
472
+
473
+ if (parentDeviceId !== null) {
474
+ let parentDeviceListIndex = this.deviceList.findIndex((ele) => ele.getDeviceId() == parentDeviceId);
475
+
476
+ if (parentDeviceListIndex !== -1) {
477
+ let parentDevice = this.deviceList[parentDeviceListIndex];
478
+ this.addRootDeviceFolder(
479
+ parentDevice,
480
+ parentDevice.getDeviceName(),
481
+ parentDeviceListIndex,
482
+ parentDevice.getAddress(),
483
+ parentDeviceId
484
+ );
485
+ }
471
486
  } else {
472
- // Add the new device entry to the root of the render list
473
- if (foundIndex === -1) {
474
- this.renderList.push(newDeviceEntry);
475
- } else {
476
- // If the device is already in the render list, update its entry
477
- this.renderList[foundIndex] = newDeviceEntry;
478
- }
487
+ this.addEmptyIpRootDevice(device);
479
488
  }
480
- }
481
-
482
- /**
483
- * Creates a folder JSON object for the network tree.
484
- *
485
- * @param {Array} children - The children nodes of the folder.
486
- * @param {boolean} hasChildDevices - Indicates if the device has child devices.
487
- * @param {string} deviceId - The ID of the device.
488
- * @returns {Array} - The folder JSON object.
489
- */
490
- createFolderJson(children, hasChildDevices, deviceId) {
491
- const folders = [
492
- {
493
- key: `${deviceId}-0`,
494
- label: 'Points',
495
- data: 'Points Folder',
496
- icon: 'pi pi-circle-fill',
497
- type: 'pointFolder',
498
- children: children.sort(this.sortPoints),
499
- }
500
- ];
489
+ }
490
+ } else {
491
+ // Add the new device entry to the root of the render list
492
+ if (foundIndex === -1) {
493
+ this.renderList.push(newDeviceEntry);
494
+ } else {
495
+ // If the device is already in the render list, preserve existing MSTP folders
496
+ const existingDevice = this.renderList[foundIndex];
497
+
498
+ // Preserve existing MSTP folders while updating the device info
499
+ const existingMstpFolders = existingDevice.children.filter(
500
+ (child) => child.type === "mstpfolder" || (child.label && child.label.includes("MSTP"))
501
+ );
502
+
503
+ // Start with the new device structure
504
+ const updatedDevice = { ...newDeviceEntry };
505
+
506
+ // Add back any existing MSTP folders
507
+ existingMstpFolders.forEach((mstpFolder) => {
508
+ const existingMstpIndex = updatedDevice.children.findIndex((child) => child.label === mstpFolder.label);
509
+ if (existingMstpIndex === -1) {
510
+ // MSTP folder doesn't exist in new structure, add it
511
+ updatedDevice.children.push(mstpFolder);
512
+ } else {
513
+ // MSTP folder exists, keep the existing one (with all its children)
514
+ updatedDevice.children[existingMstpIndex] = mstpFolder;
515
+ }
516
+ });
501
517
 
502
- return folders;
518
+ this.renderList[foundIndex] = updatedDevice;
519
+ }
503
520
  }
504
-
505
- /**
506
- * Finalize the network tree data
507
- *
508
- * @returns {Object} The finalized network tree data
509
- * - renderList: The list of devices and their points
510
- * - deviceList: The list of devices
511
- * - pointList: The list of points in the network tree
512
- * - pollFrequency: The polling schedule for discovery
513
- */
514
- finalizeNetworkTreeData() {
515
- this.renderList.sort(this.sortDevices);
516
-
517
- return {
518
- renderList: this.renderList,
519
- deviceList: this.deviceList,
520
- pointList: this.networkTree,
521
- pollFrequency: this.discover_polling_schedule,
522
- };
521
+ }
522
+
523
+ /**
524
+ * Creates a folder JSON object for the network tree.
525
+ *
526
+ * @param {Array} children - The children nodes of the folder.
527
+ * @param {boolean} hasChildDevices - Indicates if the device has child devices.
528
+ * @param {string} deviceId - The ID of the device.
529
+ * @returns {Array} - The folder JSON object.
530
+ */
531
+ createFolderJson(children, hasChildDevices, deviceId) {
532
+ const folders = [
533
+ {
534
+ key: `${deviceId}-0`,
535
+ label: "Points",
536
+ data: "Points Folder",
537
+ icon: "pi pi-circle-fill",
538
+ type: "pointFolder",
539
+ children: children.sort(this.sortPoints),
540
+ },
541
+ ];
542
+
543
+ return folders;
544
+ }
545
+
546
+ /**
547
+ * Finalize the network tree data
548
+ *
549
+ * @returns {Object} The finalized network tree data
550
+ * - renderList: The list of devices and their points
551
+ * - deviceList: The list of devices
552
+ * - pointList: The list of points in the network tree
553
+ * - pollFrequency: The polling schedule for discovery
554
+ */
555
+ finalizeNetworkTreeData() {
556
+ this.renderList.sort(this.sortDevices);
557
+
558
+ return {
559
+ renderList: this.renderList,
560
+ deviceList: this.deviceList,
561
+ pointList: this.networkTree,
562
+ pollFrequency: this.discover_polling_schedule,
563
+ };
564
+ }
565
+
566
+ /**
567
+ * Checks if the buildTreeException flag is set and throws an error if it is.
568
+ *
569
+ * @throws {Error} - Throws an error with the message 'Build tree interrupted' if the buildTreeException flag is set.
570
+ */
571
+ checkInterruptFlag() {
572
+ if (this.buildTreeException) {
573
+ throw new Error("Build tree interrupted");
523
574
  }
524
-
525
- /**
526
- * Checks if the buildTreeException flag is set and throws an error if it is.
527
- *
528
- * @throws {Error} - Throws an error with the message 'Build tree interrupted' if the buildTreeException flag is set.
529
- */
530
- checkInterruptFlag() {
531
- if (this.buildTreeException) {
532
- throw new Error('Build tree interrupted');
533
- }
575
+ }
576
+
577
+ /**
578
+ * Returns the IP address of the given device.
579
+ *
580
+ * @param {object} device - The device object.
581
+ * @returns {string} The IP address of the device.
582
+ */
583
+ getDeviceIpAddress(device) {
584
+ switch (typeof device.getAddress()) {
585
+ case "object":
586
+ return device.getAddress().address;
587
+ case "string":
588
+ return device.getAddress();
589
+ default:
590
+ return device.getAddress();
534
591
  }
535
-
536
- /**
537
- * Returns the IP address of the given device.
538
- *
539
- * @param {object} device - The device object.
540
- * @returns {string} The IP address of the device.
541
- */
542
- getDeviceIpAddress(device) {
543
- switch (typeof device.getAddress()) {
544
- case "object":
545
- return device.getAddress().address;
546
- case "string":
547
- return device.getAddress();
548
- default:
549
- return device.getAddress();
550
- }
592
+ }
593
+
594
+ /**
595
+ * Computes the device name based on the provided device object.
596
+ * If the device has a display name, it will be returned.
597
+ * Otherwise, the device name will be returned.
598
+ *
599
+ * @param {Object} device - The device object.
600
+ * @returns {string} - The computed device name.
601
+ */
602
+ computeDeviceName(device) {
603
+ if (device.getDeviceName() == null && device.getDisplayName() == null) {
604
+ return `${this.getDeviceIpAddress(device)}-${device.getDeviceId()}`;
605
+ } else if (device.getDisplayName() !== null && device.getDisplayName() !== "" && device.getDisplayName() !== undefined) {
606
+ return device.getDisplayName();
551
607
  }
552
-
553
- /**
554
- * Computes the device name based on the provided device object.
555
- * If the device has a display name, it will be returned.
556
- * Otherwise, the device name will be returned.
557
- *
558
- * @param {Object} device - The device object.
559
- * @returns {string} - The computed device name.
560
- */
561
- computeDeviceName(device) {
562
- if (device.getDeviceName() == null && device.getDisplayName() == null) {
563
- return `${this.getDeviceIpAddress(device)}-${device.getDeviceId()}`;
564
- } else if (device.getDisplayName() !== null && device.getDisplayName() !== "" && device.getDisplayName() !== undefined) {
565
- return device.getDisplayName();
566
- }
567
- return device.getDeviceName();
608
+ return device.getDeviceName();
609
+ }
610
+
611
+ /**
612
+ * Sorts the points based on their BACnet type and label.
613
+ *
614
+ * @param {Object} a - The first point object to compare.
615
+ * @param {Object} b - The second point object to compare.
616
+ * @returns {number} - A negative number if a should be sorted before b, a positive number if b should be sorted before a, or 0 if they are equal.
617
+ */
618
+ sortPoints(a, b) {
619
+ if (a.bacnetType > b.bacnetType) {
620
+ return 1;
621
+ } else if (a.bacnetType < b.bacnetType) {
622
+ return -1;
623
+ } else if (a.bacnetType == b.bacnetType) {
624
+ return 0;
568
625
  }
569
626
 
570
- /**
571
- * Sorts the points based on their BACnet type and label.
572
- *
573
- * @param {Object} a - The first point object to compare.
574
- * @param {Object} b - The second point object to compare.
575
- * @returns {number} - A negative number if a should be sorted before b, a positive number if b should be sorted before a, or 0 if they are equal.
576
- */
577
- sortPoints(a, b) {
578
- if (a.bacnetType > b.bacnetType) {
579
- return 1;
580
- } else if (a.bacnetType < b.bacnetType) {
581
- return -1;
582
- } else if (a.bacnetType == b.bacnetType) {
583
- return 0;
584
- }
585
-
586
- return a.label.localeCompare(b.label);
627
+ return a.label.localeCompare(b.label);
628
+ }
629
+
630
+ /**
631
+ * Sorts devices based on their deviceId.
632
+ *
633
+ * @param {Object} a - The first device object to compare.
634
+ * @param {Object} b - The second device object to compare.
635
+ * @returns {number} - Returns -1 if a.deviceId is less than b.deviceId, 1 if a.deviceId is greater than b.deviceId, or 0 if they are equal.
636
+ */
637
+ sortDevices(a, b) {
638
+ if (a.deviceId < b.deviceId) {
639
+ return -1;
640
+ } else if (a.deviceId > b.deviceId) {
641
+ return 1;
587
642
  }
588
-
589
- /**
590
- * Sorts devices based on their deviceId.
591
- *
592
- * @param {Object} a - The first device object to compare.
593
- * @param {Object} b - The second device object to compare.
594
- * @returns {number} - Returns -1 if a.deviceId is less than b.deviceId, 1 if a.deviceId is greater than b.deviceId, or 0 if they are equal.
595
- */
596
- sortDevices(a, b) {
597
- if (a.deviceId < b.deviceId) {
598
- return -1;
599
- } else if (a.deviceId > b.deviceId) {
600
- return 1;
601
- }
602
- return 0; // deviceIds are equal
643
+ return 0; // deviceIds are equal
644
+ }
645
+
646
+ /**
647
+ * Returns the icon class name for a given point based on its object type.
648
+ *
649
+ * @param {Object} values - The values object containing the point's metadata.
650
+ * @returns {string} - The icon class name for the point.
651
+ */
652
+ getPointIcon(values) {
653
+ const objectId = values.meta.objectId.type;
654
+ const hasPriorityArray =
655
+ values.hasPriorityArray && values.hasOwnProperty("hasPriorityArray") ? values.hasPriorityArray : false;
656
+
657
+ if (hasPriorityArray) {
658
+ return "pi writePointIcon";
659
+ } else {
660
+ switch (objectId) {
661
+ case 0:
662
+ //AI
663
+ return "pi readPointIcon";
664
+ case 1:
665
+ //AO
666
+ return "pi readPointIcon";
667
+ case 2:
668
+ //AV
669
+ return "pi readPointIcon";
670
+ case 3:
671
+ //BI
672
+ return "pi readPointIcon";
673
+ case 4:
674
+ //BO
675
+ return "pi readPointIcon";
676
+ case 5:
677
+ //BV
678
+ return "pi readPointIcon";
679
+ case 8:
680
+ //Device
681
+ return "pi pi-box";
682
+ case 13:
683
+ //MI
684
+ return "pi readPointIcon";
685
+ case 14:
686
+ //MO
687
+ return "pi readPointIcon";
688
+ case 19:
689
+ //MV
690
+ return "pi readPointIcon";
691
+ case 10:
692
+ //File
693
+ return "pi pi-file";
694
+ case 16:
695
+ //Program
696
+ return "pi pi-database";
697
+ case 20:
698
+ //Trendlog
699
+ return "pi pi-chart-line";
700
+ case 15:
701
+ //Notification Class
702
+ return "pi pi-bell";
703
+ case 56:
704
+ return "pi pi-sitemap";
705
+ case 178:
706
+ return "pi pi-lock";
707
+ case 17:
708
+ return "pi pi-calendar";
709
+ case 6:
710
+ return "pi pi-calendar";
711
+ default:
712
+ //Return circle for all other types
713
+ return "pi readPointIcon";
714
+ }
603
715
  }
604
-
605
- /**
606
- * Returns the icon class name for a given point based on its object type.
607
- *
608
- * @param {Object} values - The values object containing the point's metadata.
609
- * @returns {string} - The icon class name for the point.
610
- */
611
- getPointIcon(values) {
612
- const objectId = values.meta.objectId.type;
613
- const hasPriorityArray =
614
- values.hasPriorityArray && values.hasOwnProperty("hasPriorityArray") ? values.hasPriorityArray : false;
615
-
616
- if (hasPriorityArray) {
617
- return "pi writePointIcon";
618
- } else {
619
- switch (objectId) {
620
- case 0:
621
- //AI
622
- return "pi readPointIcon";
623
- case 1:
624
- //AO
625
- return "pi readPointIcon";
626
- case 2:
627
- //AV
628
- return "pi readPointIcon";
629
- case 3:
630
- //BI
631
- return "pi readPointIcon";
632
- case 4:
633
- //BO
634
- return "pi readPointIcon";
635
- case 5:
636
- //BV
637
- return "pi readPointIcon";
638
- case 8:
639
- //Device
640
- return "pi pi-box";
641
- case 13:
642
- //MI
643
- return "pi readPointIcon";
644
- case 14:
645
- //MO
646
- return "pi readPointIcon";
647
- case 19:
648
- //MV
649
- return "pi readPointIcon";
650
- case 10:
651
- //File
652
- return "pi pi-file";
653
- case 16:
654
- //Program
655
- return "pi pi-database";
656
- case 20:
657
- //Trendlog
658
- return "pi pi-chart-line";
659
- case 15:
660
- //Notification Class
661
- return "pi pi-bell";
662
- case 56:
663
- return "pi pi-sitemap";
664
- case 178:
665
- return "pi pi-lock";
666
- case 17:
667
- return "pi pi-calendar";
668
- case 6:
669
- return "pi pi-calendar";
670
- default:
671
- //Return circle for all other types
672
- return "pi readPointIcon";
673
- }
674
- }
675
- }
676
-
677
- /**
678
- * Returns the icon for a given device based on its properties.
679
- *
680
- * @param {Object} device - The device object.
681
- * @returns {string} - The icon class name.
682
- */
683
- getDeviceIcon(device) {
684
- const isMstp = device.getIsMstpDevice();
685
- const manualDiscoveryMode = device.getManualDiscoveryMode();
686
-
687
- if (manualDiscoveryMode == true) {
688
- return "pi pi-question-circle";
689
- } else if (manualDiscoveryMode == false) {
690
- if (isMstp == true) {
691
- return "pi pi-box";
692
- } else if (isMstp == false) {
693
- return "pi pi-server";
694
- }
695
- }
716
+ }
717
+
718
+ /**
719
+ * Returns the icon for a given device based on its properties.
720
+ *
721
+ * @param {Object} device - The device object.
722
+ * @returns {string} - The icon class name.
723
+ */
724
+ getDeviceIcon(device) {
725
+ const isMstp = device.getIsMstpDevice();
726
+ const manualDiscoveryMode = device.getManualDiscoveryMode();
727
+
728
+ if (manualDiscoveryMode == true) {
729
+ return "pi pi-question-circle";
730
+ } else if (manualDiscoveryMode == false) {
731
+ if (isMstp == true) {
732
+ return "pi pi-box";
733
+ } else if (isMstp == false) {
696
734
  return "pi pi-server";
735
+ }
697
736
  }
737
+ return "pi pi-server";
738
+ }
698
739
  }
699
740
 
700
- module.exports = { treeBuilder };
741
+ module.exports = { treeBuilder };