@bitpoolos/edge-bacnet 1.2.5 → 1.2.7

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/bacnet_device.js CHANGED
@@ -20,6 +20,18 @@ class BacnetDevice {
20
20
  that.priorityQueue = config.priorityQueue;
21
21
  that.lastPriorityQueueTS = config.lastPriorityQueueTS;
22
22
 
23
+ if(config.childDevices) {
24
+ that.childDevices = config.childDevices;
25
+ } else {
26
+ that.childDevices = [];
27
+ }
28
+
29
+ if(config.parentDeviceId) {
30
+ that.parentDeviceId = config.parentDeviceId;
31
+ } else {
32
+ that.parentDeviceId = null;
33
+ }
34
+
23
35
  } else if(fromImport == false) {
24
36
  if(config.net && config.adr) {
25
37
  that.address = {address: config.address, net: config.net, adr: config.adr};
@@ -42,9 +54,49 @@ class BacnetDevice {
42
54
  that.priorityQueueIsActive = false;
43
55
  that.priorityQueue = [];
44
56
  that.lastPriorityQueueTS = null;
57
+ that.childDevices = [];
58
+ that.parentDeviceId = null;
59
+ }
60
+ }
61
+
62
+ setParentDeviceId(deviceId) {
63
+ this.parentDeviceId = deviceId;
64
+ }
65
+
66
+ getParentDeviceId() {
67
+ return this.parentDeviceId;
68
+ }
69
+
70
+ hasChildDevices() {
71
+ if(this.childDevices.length > 0) {
72
+ return true;
73
+ } else if(this.childDevices.length == 0) {
74
+ return false;
75
+ }
76
+ }
77
+
78
+ addChildDevice(deviceId) {
79
+ let foundIndex = this.childDevices.findIndex(ele => ele == deviceId);
80
+
81
+ if(foundIndex == -1) {
82
+ this.childDevices.push(deviceId);
83
+ } else {
84
+ this.childDevices[foundIndex] = deviceId
45
85
  }
46
86
  }
47
87
 
88
+ getChildDevice(deviceId) {
89
+ let foundIndex = this.childDevices.findIndex(ele => ele == deviceId);
90
+
91
+ if(foundIndex !== -1) return this.childDevices[foundIndex];
92
+
93
+ return null;
94
+ }
95
+
96
+ getChildDevices() {
97
+ return this.childDevices;
98
+ }
99
+
48
100
  setLastPriorityQueueTS() {
49
101
  this.lastPriorityQueueTS = Date.now();
50
102
  }