@bitpoolos/edge-bacnet 1.2.8 → 1.3.1

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_read.js CHANGED
@@ -5,96 +5,80 @@
5
5
 
6
6
 
7
7
  module.exports = function (RED) {
8
- const http = require("http");
9
- const { ReadCommandConfig } = require('./common');
10
- const baEnum = require('./resources/node-bacstack-ts/dist/index.js').enum;
11
-
12
- function BitpoolBacnetReadDevice (config) {
13
- RED.nodes.createNode(this, config);
14
- var node = this;
15
-
16
- this.json = config.json;
17
- this.mqtt = config.mqtt;
18
- this.roundDecimal = config.roundDecimal;
19
- this.pointsToRead = config.pointsToRead;
20
- this.readDevices = config.readDevices;
21
- this.id = config.id;
22
- this.nodeName = config.name;
23
-
24
- this.object_property_simplePayload = config.object_property_simplePayload;
25
- this.object_property_fullObject = config.object_property_fullObject;
26
-
27
-
28
-
29
- this.object_props = getObjectProps(this);
8
+ const http = require("http");
9
+ const { ReadCommandConfig } = require('./common');
10
+ const baEnum = require('./resources/node-bacstack-ts/dist/index.js').enum;
11
+
12
+ function BitpoolBacnetReadDevice(config) {
13
+ RED.nodes.createNode(this, config);
14
+ var node = this;
15
+
16
+ this.json = config.json;
17
+ this.mqtt = config.mqtt;
18
+ this.roundDecimal = config.roundDecimal;
19
+ this.pointsToRead = config.pointsToRead;
20
+ this.readDevices = config.readDevices;
21
+ this.id = config.id;
22
+ this.nodeName = config.name;
23
+
24
+ this.object_property_simplePayload = config.object_property_simplePayload;
25
+ this.object_property_fullObject = config.object_property_fullObject;
26
+
27
+
28
+
29
+ this.object_props = getObjectProps(this);
30
+
31
+ function getObjectProps(node) {
32
+ var propArr = [];
33
+ if (node.object_property_simplePayload == true) {
34
+ propArr.push({ id: baEnum.PropertyIdentifier.PRESENT_VALUE });
35
+ }
36
+ if (node.object_property_fullObject == true) {
37
+ propArr.push(
38
+ { id: baEnum.PropertyIdentifier.PRESENT_VALUE },
39
+ { id: baEnum.PropertyIdentifier.DESCRIPTION },
40
+ { id: baEnum.PropertyIdentifier.STATUS_FLAGS },
41
+ { id: baEnum.PropertyIdentifier.RELIABILITY },
42
+ { id: baEnum.PropertyIdentifier.OUT_OF_SERVICE },
43
+ { id: baEnum.PropertyIdentifier.UNITS }
44
+
45
+ );
46
+ }
47
+
48
+ //add object name for every request as its used in formatting
49
+ propArr.push({ id: baEnum.PropertyIdentifier.OBJECT_NAME });
50
+
51
+ return propArr;
52
+ };
30
53
 
31
- function getObjectProps(node) {
32
- var propArr = [];
33
- if(node.object_property_simplePayload == true){
34
- propArr.push({ id: baEnum.PropertyIdentifier.PRESENT_VALUE });
35
- }
36
- if(node.object_property_fullObject == true){
37
- propArr.push(
38
- { id: baEnum.PropertyIdentifier.PRESENT_VALUE },
39
- { id: baEnum.PropertyIdentifier.DESCRIPTION },
40
- { id: baEnum.PropertyIdentifier.STATUS_FLAGS },
41
- { id: baEnum.PropertyIdentifier.RELIABILITY },
42
- { id: baEnum.PropertyIdentifier.OUT_OF_SERVICE },
43
- { id: baEnum.PropertyIdentifier.UNITS }
44
-
45
- );
54
+ node.on('input', function (msg) {
55
+ node.status({ fill: "blue", shape: "dot", text: "Reading values" });
56
+
57
+ let readConfig = new ReadCommandConfig(node.pointsToRead, node.object_props, node.roundDecimal);
58
+ let output = {
59
+ type: "Read",
60
+ id: node.id,
61
+ readNodeName: node.nodeName,
62
+ options: readConfig,
63
+ objectPropertyType: {
64
+ simplePayload: node.object_property_simplePayload,
65
+ fullObject: node.object_property_fullObject
66
+ },
67
+ outputType: {
68
+ json: node.json,
69
+ mqtt: node.mqtt
46
70
  }
47
-
48
- //add object name for every request as its used in formatting
49
- propArr.push({ id: baEnum.PropertyIdentifier.OBJECT_NAME});
50
-
51
- return propArr;
52
- };
53
-
54
- //send point list status for device priority queue
55
- let headers = {
56
- 'Content-Type' : "application/json"
57
71
  };
58
72
 
59
- const agent = new http.Agent({
60
- rejectUnauthorized: false
61
- });
73
+ node.send(output);
62
74
 
63
- let priorityDevicesMsg = {
64
- doUpdatePriorityDevices: true,
65
- priorityDevices: node.pointsToRead
66
- };
75
+ setTimeout(() => {
76
+ node.status({});
77
+ }, 3000);
67
78
 
68
- node.send(priorityDevicesMsg);
69
-
70
- node.on('input', function(msg) {
71
- node.status({ fill: "blue", shape: "dot", text: "Reading values" });
72
-
73
- let readConfig = new ReadCommandConfig(node.pointsToRead, node.object_props, node.roundDecimal);
74
- let output = {
75
- type: "Read",
76
- id: node.id,
77
- readNodeName: node.nodeName,
78
- options: readConfig,
79
- objectPropertyType: {
80
- simplePayload: node.object_property_simplePayload,
81
- fullObject: node.object_property_fullObject
82
- },
83
- outputType: {
84
- json: node.json,
85
- mqtt: node.mqtt
86
- }
87
- };
88
-
89
- node.send(output);
90
-
91
- setTimeout(() => {
92
- node.status({});
93
- }, 3000);
94
-
95
- });
79
+ });
96
80
 
97
- };
81
+ };
98
82
 
99
- RED.nodes.registerType('Bacnet-Discovery', BitpoolBacnetReadDevice);
83
+ RED.nodes.registerType('Bacnet-Discovery', BitpoolBacnetReadDevice);
100
84
  };