node-opcua-service-subscription 2.85.0 → 2.86.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/dist/deadband_checker.d.ts +1 -1
- package/dist/deadband_checker.js +52 -49
- package/dist/deadband_checker.js.map +1 -1
- package/package.json +11 -11
- package/source/deadband_checker.ts +57 -51
|
@@ -24,4 +24,4 @@ export declare function isOutsideDeadbandAbsolute(variant1: Variant, variant2: V
|
|
|
24
24
|
* @method isOutsideDeadband
|
|
25
25
|
* @return true if the element is outside deadBand
|
|
26
26
|
*/
|
|
27
|
-
export declare function isOutsideDeadbandPercent(variant1: Variant, variant2: Variant,
|
|
27
|
+
export declare function isOutsideDeadbandPercent(variant1: Variant, variant2: Variant, deadbandValuePercent: number, range: PseudoRange): boolean;
|
package/dist/deadband_checker.js
CHANGED
|
@@ -45,7 +45,10 @@ function _isOutsideDeadbandScalar(value1, value2, dataType, absoluteDeadband) {
|
|
|
45
45
|
}
|
|
46
46
|
function isOutsideDeadbandVariant(v1, v2, absoluteDeadBand) {
|
|
47
47
|
(0, node_opcua_assert_1.assert)(isFinite(absoluteDeadBand));
|
|
48
|
-
if (v1.arrayType === node_opcua_variant_1.VariantArrayType.Array) {
|
|
48
|
+
if (v1.arrayType === node_opcua_variant_1.VariantArrayType.Array || v1.arrayType === node_opcua_variant_1.VariantArrayType.Matrix) {
|
|
49
|
+
// If the Value of the MonitoredItem is an array, then the deadband calculation logic shall be applied to
|
|
50
|
+
// each element of the array. If an element that requires a DataChange is found, then no further
|
|
51
|
+
// deadband checking is necessary and the entire array shall be returned.
|
|
49
52
|
if (v1.dataType !== v2.dataType) {
|
|
50
53
|
return true;
|
|
51
54
|
}
|
|
@@ -69,40 +72,46 @@ function isOutsideDeadbandVariant(v1, v2, absoluteDeadBand) {
|
|
|
69
72
|
return _isOutsideDeadbandScalar(v1.value, v2.value, v1.dataType, absoluteDeadBand);
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
|
-
function isOnEdgeOfRangeScalar(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
75
|
+
// function isOnEdgeOfRangeScalar(
|
|
76
|
+
// currentValue: NumberType,
|
|
77
|
+
// newValue: NumberType,
|
|
78
|
+
// dataType: DataType,
|
|
79
|
+
// range: PseudoRange,
|
|
80
|
+
// deadbandValue: number
|
|
81
|
+
// ): boolean {
|
|
82
|
+
// if (dataType === DataType.UInt64 || dataType === DataType.Int64) {
|
|
83
|
+
// // istanbul ignore next
|
|
84
|
+
// if (!(currentValue instanceof Array && newValue instanceof Array)) {
|
|
85
|
+
// throw new Error("Invalid");
|
|
86
|
+
// }
|
|
87
|
+
// currentValue = currentValue[1];
|
|
88
|
+
// newValue = newValue[1];
|
|
89
|
+
// }
|
|
90
|
+
// if (Array.isArray(newValue)) throw new Error("internal error");
|
|
91
|
+
// if (/*currentValue !== range.low && */ Math.abs(newValue - range.low) < deadbandValue) {
|
|
92
|
+
// return true;
|
|
93
|
+
// }
|
|
94
|
+
// if (/*currentValue !== range.high && */ Math.abs(newValue - range.high) < deadbandValue) {
|
|
95
|
+
// return true;
|
|
96
|
+
// }
|
|
97
|
+
// return false;
|
|
98
|
+
// }
|
|
99
|
+
// function isOnEdgeOfRange(currentValue: Variant, newValue: Variant, range: PseudoRange, deadbandValue: number): boolean {
|
|
100
|
+
// if (currentValue.arrayType === VariantArrayType.Array) {
|
|
101
|
+
// const n = currentValue.value.length;
|
|
102
|
+
// let i = 0;
|
|
103
|
+
// for (i = 0; i < n; i++) {
|
|
104
|
+
// if (isOnEdgeOfRangeScalar(currentValue.value[i], newValue.value[i], newValue.dataType, range, deadbandValue)) {
|
|
105
|
+
// return true;
|
|
106
|
+
// }
|
|
107
|
+
// }
|
|
108
|
+
// return false;
|
|
109
|
+
// } else {
|
|
110
|
+
// assert(currentValue.arrayType === VariantArrayType.Scalar);
|
|
111
|
+
// assert(currentValue.dataType === newValue.dataType);
|
|
112
|
+
// return isOnEdgeOfRangeScalar(currentValue.value, newValue.value, currentValue.dataType, range, deadbandValue);
|
|
113
|
+
// }
|
|
114
|
+
// }
|
|
106
115
|
/**
|
|
107
116
|
* @method isOutsideDeadbandNone
|
|
108
117
|
* @return true if the element is in deadBand
|
|
@@ -125,12 +134,7 @@ exports.isOutsideDeadbandAbsolute = isOutsideDeadbandAbsolute;
|
|
|
125
134
|
* @method isOutsideDeadband
|
|
126
135
|
* @return true if the element is outside deadBand
|
|
127
136
|
*/
|
|
128
|
-
function isOutsideDeadbandPercent(variant1, variant2,
|
|
129
|
-
// The range of the deadbandValue is from 0.0 to 100.0 Percent.
|
|
130
|
-
(0, node_opcua_assert_1.assert)(deadbandValue >= 0 && deadbandValue <= 100);
|
|
131
|
-
if (isOnEdgeOfRange(variant1, variant2, range)) {
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
137
|
+
function isOutsideDeadbandPercent(variant1, variant2, deadbandValuePercent, range) {
|
|
134
138
|
// DeadbandType = PercentDeadband
|
|
135
139
|
// For this type of deadband the deadbandValue is defined as the percentage of the EURange. That is,
|
|
136
140
|
// it applies only to AnalogItems with an EURange Property that defines the typical value range for the
|
|
@@ -140,15 +144,14 @@ function isOutsideDeadbandPercent(variant1, variant2, deadbandValue, range) {
|
|
|
140
144
|
// DataChange if (absolute value of (last cached value - current value) >
|
|
141
145
|
// (deadbandValue/100.0) * ((high-low) of EURange)))
|
|
142
146
|
//
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
// If the Value of the MonitoredItem is an array, then the deadband calculation logic shall be applied to
|
|
146
|
-
// each element of the array. If an element that requires a DataChange is found, then no further
|
|
147
|
-
// deadband checking is necessary and the entire array shall be returned.
|
|
147
|
+
// The range of the deadbandValue is from 0.0 to 100.0 Percent.
|
|
148
|
+
(0, node_opcua_assert_1.assert)(deadbandValuePercent >= 0 && deadbandValuePercent <= 100);
|
|
148
149
|
const valueRange = Math.abs(range.high - range.low);
|
|
149
|
-
(
|
|
150
|
-
|
|
151
|
-
return
|
|
150
|
+
const deadBandValueAbsolute = (deadbandValuePercent / 100.0) * valueRange;
|
|
151
|
+
// if (isOnEdgeOfRange(variant1, variant2, range, deadBandValueAbsolute)) {
|
|
152
|
+
// return true;
|
|
153
|
+
// }
|
|
154
|
+
return isOutsideDeadbandAbsolute(variant1, variant2, deadBandValueAbsolute);
|
|
152
155
|
}
|
|
153
156
|
exports.isOutsideDeadbandPercent = isOutsideDeadbandPercent;
|
|
154
157
|
//# sourceMappingURL=deadband_checker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deadband_checker.js","sourceRoot":"","sources":["../source/deadband_checker.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA2C;AAE3C,2DAAyE;AAEzE,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,+CAAW,CAAA;IACX,uDAAe,CAAA;IACf,qDAAc,CAAA;IACd,wDAAgB,CAAA;AACpB,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB;AASD;;GAEG;AACH,SAAS,wBAAwB,CAAC,MAAkB,EAAE,MAAkB,EAAE,QAAkB,EAAE,gBAAwB;IAClH,IAAI,IAAI,CAAC;IACT,IAAI,QAAQ,KAAK,6BAAQ,CAAC,MAAM,IAAI,QAAQ,KAAK,6BAAQ,CAAC,KAAK,EAAE;QAC7D,uBAAuB;QACvB,IAAI,CAAC,CAAC,MAAM,YA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E,aAAqB;IACjG,6CAA6C;IAC7C,OAAO,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;AACvE,CAAC;AAHD,8DAGC;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,QAAiB,EAAE,QAAiB,EAAE,oBAA4B,EAAE,KAAkB;IAC3H,iCAAiC;IACjC,oGAAoG;IACpG,uGAAuG;IACvG,2GAA2G;IAC3G,yGAAyG;IACzG,iBAAiB;IACjB,8EAA8E;IAC9E,6FAA6F;IAC7F,EAAE;IAEF,+DAA+D;IAC/D,IAAA,0BAAM,EAAC,oBAAoB,IAAI,CAAC,IAAI,oBAAoB,IAAI,GAAG,CAAC,CAAC;IAEjE,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACpD,MAAM,qBAAqB,GAAG,CAAC,oBAAoB,GAAG,KAAK,CAAC,GAAG,UAAU,CAAC;IAE1E,2EAA2E;IAC3E,mBAAmB;IACnB,IAAI;IAEJ,OAAO,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC;AAChF,CAAC;AAtBD,4DAsBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-service-subscription",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.86.1",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module -service-subscription",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"node-opcua-assert": "2.77.0",
|
|
15
|
-
"node-opcua-types": "2.
|
|
16
|
-
"node-opcua-variant": "2.
|
|
15
|
+
"node-opcua-types": "2.86.1",
|
|
16
|
+
"node-opcua-variant": "2.86.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"node-opcua-buffer-utils": "2.
|
|
20
|
-
"node-opcua-debug": "2.
|
|
21
|
-
"node-opcua-nodeid": "2.
|
|
22
|
-
"node-opcua-packet-analyzer": "2.
|
|
23
|
-
"node-opcua-secure-channel": "2.
|
|
24
|
-
"node-opcua-service-read": "2.
|
|
25
|
-
"node-opcua-status-code": "2.
|
|
19
|
+
"node-opcua-buffer-utils": "2.86.0",
|
|
20
|
+
"node-opcua-debug": "2.86.0",
|
|
21
|
+
"node-opcua-nodeid": "2.86.0",
|
|
22
|
+
"node-opcua-packet-analyzer": "2.86.1",
|
|
23
|
+
"node-opcua-secure-channel": "2.86.1",
|
|
24
|
+
"node-opcua-service-read": "2.86.1",
|
|
25
|
+
"node-opcua-status-code": "2.86.1",
|
|
26
26
|
"should": "^13.2.3"
|
|
27
27
|
},
|
|
28
28
|
"author": "Etienne Rossignon",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"internet of things"
|
|
41
41
|
],
|
|
42
42
|
"homepage": "http://node-opcua.github.io/",
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "389ba18585ff4b62f6fee58b69bd871a8e6b0dff"
|
|
44
44
|
}
|
|
@@ -54,7 +54,10 @@ function _isOutsideDeadbandScalar(value1: NumberType, value2: NumberType, dataTy
|
|
|
54
54
|
function isOutsideDeadbandVariant(v1: Variant, v2: Variant, absoluteDeadBand: number): boolean {
|
|
55
55
|
assert(isFinite(absoluteDeadBand));
|
|
56
56
|
|
|
57
|
-
if (v1.arrayType === VariantArrayType.Array) {
|
|
57
|
+
if (v1.arrayType === VariantArrayType.Array || v1.arrayType === VariantArrayType.Matrix) {
|
|
58
|
+
// If the Value of the MonitoredItem is an array, then the deadband calculation logic shall be applied to
|
|
59
|
+
// each element of the array. If an element that requires a DataChange is found, then no further
|
|
60
|
+
// deadband checking is necessary and the entire array shall be returned.
|
|
58
61
|
if (v1.dataType !== v2.dataType) {
|
|
59
62
|
return true;
|
|
60
63
|
}
|
|
@@ -72,46 +75,53 @@ function isOutsideDeadbandVariant(v1: Variant, v2: Variant, absoluteDeadBand: nu
|
|
|
72
75
|
return false;
|
|
73
76
|
} else {
|
|
74
77
|
assert(v1.arrayType === VariantArrayType.Scalar);
|
|
75
|
-
if(v1.dataType !== v2.dataType) {
|
|
78
|
+
if (v1.dataType !== v2.dataType) {
|
|
76
79
|
return true;
|
|
77
80
|
}
|
|
78
81
|
return _isOutsideDeadbandScalar(v1.value, v2.value, v1.dataType, absoluteDeadBand);
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
|
-
function isOnEdgeOfRangeScalar(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
// function isOnEdgeOfRangeScalar(
|
|
85
|
+
// currentValue: NumberType,
|
|
86
|
+
// newValue: NumberType,
|
|
87
|
+
// dataType: DataType,
|
|
88
|
+
// range: PseudoRange,
|
|
89
|
+
// deadbandValue: number
|
|
90
|
+
// ): boolean {
|
|
91
|
+
// if (dataType === DataType.UInt64 || dataType === DataType.Int64) {
|
|
92
|
+
// // istanbul ignore next
|
|
93
|
+
// if (!(currentValue instanceof Array && newValue instanceof Array)) {
|
|
94
|
+
// throw new Error("Invalid");
|
|
95
|
+
// }
|
|
96
|
+
// currentValue = currentValue[1];
|
|
97
|
+
// newValue = newValue[1];
|
|
98
|
+
// }
|
|
99
|
+
// if (Array.isArray(newValue)) throw new Error("internal error");
|
|
100
|
+
// if (/*currentValue !== range.low && */ Math.abs(newValue - range.low) < deadbandValue) {
|
|
101
|
+
// return true;
|
|
102
|
+
// }
|
|
103
|
+
// if (/*currentValue !== range.high && */ Math.abs(newValue - range.high) < deadbandValue) {
|
|
104
|
+
// return true;
|
|
105
|
+
// }
|
|
106
|
+
// return false;
|
|
107
|
+
// }
|
|
98
108
|
|
|
99
|
-
function isOnEdgeOfRange(currentValue: Variant, newValue: Variant, range: PseudoRange): boolean {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
109
|
+
// function isOnEdgeOfRange(currentValue: Variant, newValue: Variant, range: PseudoRange, deadbandValue: number): boolean {
|
|
110
|
+
// if (currentValue.arrayType === VariantArrayType.Array) {
|
|
111
|
+
// const n = currentValue.value.length;
|
|
112
|
+
// let i = 0;
|
|
113
|
+
// for (i = 0; i < n; i++) {
|
|
114
|
+
// if (isOnEdgeOfRangeScalar(currentValue.value[i], newValue.value[i], newValue.dataType, range, deadbandValue)) {
|
|
115
|
+
// return true;
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
// return false;
|
|
119
|
+
// } else {
|
|
120
|
+
// assert(currentValue.arrayType === VariantArrayType.Scalar);
|
|
121
|
+
// assert(currentValue.dataType === newValue.dataType);
|
|
122
|
+
// return isOnEdgeOfRangeScalar(currentValue.value, newValue.value, currentValue.dataType, range, deadbandValue);
|
|
123
|
+
// }
|
|
124
|
+
// }
|
|
115
125
|
|
|
116
126
|
/**
|
|
117
127
|
* @method isOutsideDeadbandNone
|
|
@@ -134,14 +144,7 @@ export function isOutsideDeadbandAbsolute(variant1: Variant, variant2: Variant,
|
|
|
134
144
|
* @method isOutsideDeadband
|
|
135
145
|
* @return true if the element is outside deadBand
|
|
136
146
|
*/
|
|
137
|
-
export function isOutsideDeadbandPercent(variant1: Variant, variant2: Variant,
|
|
138
|
-
// The range of the deadbandValue is from 0.0 to 100.0 Percent.
|
|
139
|
-
assert(deadbandValue >= 0 && deadbandValue <= 100);
|
|
140
|
-
|
|
141
|
-
if (isOnEdgeOfRange(variant1, variant2, range)) {
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
|
|
147
|
+
export function isOutsideDeadbandPercent(variant1: Variant, variant2: Variant, deadbandValuePercent: number, range: PseudoRange): boolean {
|
|
145
148
|
// DeadbandType = PercentDeadband
|
|
146
149
|
// For this type of deadband the deadbandValue is defined as the percentage of the EURange. That is,
|
|
147
150
|
// it applies only to AnalogItems with an EURange Property that defines the typical value range for the
|
|
@@ -151,13 +154,16 @@ export function isOutsideDeadbandPercent(variant1: Variant, variant2: Variant, d
|
|
|
151
154
|
// DataChange if (absolute value of (last cached value - current value) >
|
|
152
155
|
// (deadbandValue/100.0) * ((high-low) of EURange)))
|
|
153
156
|
//
|
|
154
|
-
|
|
155
|
-
//
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// deadband checking is necessary and the entire array shall be returned.
|
|
157
|
+
|
|
158
|
+
// The range of the deadbandValue is from 0.0 to 100.0 Percent.
|
|
159
|
+
assert(deadbandValuePercent >= 0 && deadbandValuePercent <= 100);
|
|
160
|
+
|
|
159
161
|
const valueRange = Math.abs(range.high - range.low);
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
const deadBandValueAbsolute = (deadbandValuePercent / 100.0) * valueRange;
|
|
163
|
+
|
|
164
|
+
// if (isOnEdgeOfRange(variant1, variant2, range, deadBandValueAbsolute)) {
|
|
165
|
+
// return true;
|
|
166
|
+
// }
|
|
167
|
+
|
|
168
|
+
return isOutsideDeadbandAbsolute(variant1, variant2, deadBandValueAbsolute);
|
|
163
169
|
}
|