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