node-opcua-aggregates 2.97.0 → 2.98.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/aggregates.d.ts +22 -22
- package/dist/aggregates.js +275 -275
- package/dist/average.d.ts +3 -3
- package/dist/average.js +60 -60
- package/dist/calculate_bad_good.d.ts +10 -10
- package/dist/calculate_bad_good.js +117 -117
- package/dist/common.d.ts +8 -8
- package/dist/common.js +93 -93
- package/dist/count.d.ts +3 -3
- package/dist/count.js +86 -86
- package/dist/duration_bad.d.ts +4 -4
- package/dist/duration_bad.js +31 -31
- package/dist/duration_good.d.ts +4 -4
- package/dist/duration_good.js +31 -31
- package/dist/index.d.ts +11 -11
- package/dist/index.js +34 -34
- package/dist/interpolate.d.ts +16 -16
- package/dist/interpolate.js +130 -130
- package/dist/interval.d.ts +62 -62
- package/dist/interval.js +199 -199
- package/dist/minmax.d.ts +18 -18
- package/dist/minmax.js +148 -148
- package/dist/percent_bad.d.ts +4 -4
- package/dist/percent_bad.js +24 -24
- package/dist/percent_good.d.ts +7 -7
- package/dist/percent_good.js +48 -48
- package/dist/read_processed_details.d.ts +6 -6
- package/dist/read_processed_details.js +143 -143
- package/package.json +22 -18
- package/.mocharc.yml +0 -7
- package/bin/sample_aggregate_server.js +0 -15
- package/nyc.config.js +0 -16
package/dist/minmax.js
CHANGED
|
@@ -1,149 +1,149 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMaxData = exports.getMinData = exports.calculateIntervalMaxValue = exports.calculateIntervalMinValue = void 0;
|
|
4
|
-
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
5
|
-
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
6
|
-
const common_1 = require("./common");
|
|
7
|
-
// eslint-disable-next-line max-statements
|
|
8
|
-
function calculateIntervalMinOrMaxValue(interval, options, predicate) {
|
|
9
|
-
// console.log(interval.toString());
|
|
10
|
-
const indexStart = interval.index;
|
|
11
|
-
let selectedValue = null;
|
|
12
|
-
let counter = 0;
|
|
13
|
-
let statusCode;
|
|
14
|
-
let isPartial = interval.isPartial;
|
|
15
|
-
let isRaw = false;
|
|
16
|
-
let hasBad = false;
|
|
17
|
-
for (let i = indexStart; i < indexStart + interval.count; i++) {
|
|
18
|
-
const dataValue = interval.dataValues[i];
|
|
19
|
-
if (dataValue.statusCode.equals(node_opcua_status_code_1.StatusCodes.BadNoData)) {
|
|
20
|
-
isPartial = true;
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
if (!dataValue.statusCode.isGood()) {
|
|
24
|
-
hasBad = true;
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
if (!selectedValue) {
|
|
28
|
-
selectedValue = dataValue.value;
|
|
29
|
-
counter = 1;
|
|
30
|
-
if (i === indexStart && dataValue.sourceTimestamp.getTime() === interval.startTime.getTime()) {
|
|
31
|
-
isRaw = true;
|
|
32
|
-
}
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
const compare = predicate(selectedValue, dataValue.value);
|
|
36
|
-
if (compare === "equal") {
|
|
37
|
-
counter = 1;
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (compare === "select") {
|
|
41
|
-
selectedValue = dataValue.value;
|
|
42
|
-
counter = 1;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (!selectedValue) {
|
|
46
|
-
return new node_opcua_data_value_1.DataValue({
|
|
47
|
-
sourceTimestamp: interval.startTime,
|
|
48
|
-
statusCode: node_opcua_status_code_1.StatusCodes.BadNoData
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (isRaw) {
|
|
52
|
-
if (hasBad) {
|
|
53
|
-
statusCode = node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else if (hasBad) {
|
|
60
|
-
statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal, "HistorianCalculated");
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.Good, "HistorianCalculated");
|
|
64
|
-
}
|
|
65
|
-
if (counter > 1) {
|
|
66
|
-
statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(statusCode, "HistorianMultiValue");
|
|
67
|
-
}
|
|
68
|
-
if (isPartial || interval.isPartial) {
|
|
69
|
-
statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(statusCode, "HistorianPartial");
|
|
70
|
-
}
|
|
71
|
-
return new node_opcua_data_value_1.DataValue({
|
|
72
|
-
sourceTimestamp: interval.startTime,
|
|
73
|
-
statusCode: statusCode,
|
|
74
|
-
value: selectedValue
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
function calculateIntervalMinValue(interval, options) {
|
|
78
|
-
return calculateIntervalMinOrMaxValue(interval, options, (a, b) => a.value > b.value ? "select" : a.value === b.value ? "equal" : "reject");
|
|
79
|
-
}
|
|
80
|
-
exports.calculateIntervalMinValue = calculateIntervalMinValue;
|
|
81
|
-
function calculateIntervalMaxValue(interval, options) {
|
|
82
|
-
return calculateIntervalMinOrMaxValue(interval, options, (a, b) => a.value < b.value ? "select" : a.value === b.value ? "equal" : "reject");
|
|
83
|
-
}
|
|
84
|
-
exports.calculateIntervalMaxValue = calculateIntervalMaxValue;
|
|
85
|
-
// From OPC Unified Architecture, Part 13 26 Release 1.04
|
|
86
|
-
// 5.4.3.11 Maximum
|
|
87
|
-
// The Maximum Aggregate defined in Table 22 retrieves the maximum Good raw value within
|
|
88
|
-
// the interval, and returns that value with the timestamp at the start of the interval. Note that if
|
|
89
|
-
// the same maximum exists at more than one timestamp the MultipleValues bit is set.
|
|
90
|
-
// Unless otherwise indicated, StatusCodes are Good, Calculated. If the minimum value is on
|
|
91
|
-
// the interval start time the status code will be Good, Raw. If only Bad quality values are
|
|
92
|
-
// available then the status is returned as Bad_NoData.
|
|
93
|
-
// The timestamp of the Aggregate will always be the start of the interval for every
|
|
94
|
-
//
|
|
95
|
-
// ProcessingInterval.
|
|
96
|
-
//
|
|
97
|
-
// Table 22 – Maximum Aggregate summary
|
|
98
|
-
// Maximum Aggregate Characteristics
|
|
99
|
-
//
|
|
100
|
-
// Type Calculated
|
|
101
|
-
// Data Type Same as Source
|
|
102
|
-
// Use Bounds None
|
|
103
|
-
// Timestamp StartTime
|
|
104
|
-
//
|
|
105
|
-
// Status Code Calculations
|
|
106
|
-
// Calculation Method Custom
|
|
107
|
-
// If no Bad values then the Status is Good. If Bad values exist then
|
|
108
|
-
// the Status is Uncertain_SubNormal. If an Uncertain value is greater
|
|
109
|
-
// than the maximum Good value the Status is Uncertain_SubNormal
|
|
110
|
-
//
|
|
111
|
-
// Partial Set Sometimes
|
|
112
|
-
// If an interval is not a complete interval
|
|
113
|
-
//
|
|
114
|
-
// Calculated Set Sometimes
|
|
115
|
-
// If the Maximum value is not on the startTime of the interval or if the
|
|
116
|
-
// Status was set to Uncertain_SubNormal because of non-Good
|
|
117
|
-
// values in the interval
|
|
118
|
-
//
|
|
119
|
-
// Interpolated Not Set
|
|
120
|
-
//
|
|
121
|
-
// Raw Set Sometimes
|
|
122
|
-
// If Maximum value is on the startTime of the interval
|
|
123
|
-
// Multi Value Set Sometimes
|
|
124
|
-
// If multiple Good values exist with the Maximum value
|
|
125
|
-
//
|
|
126
|
-
// Status Code Common Special Cases
|
|
127
|
-
// Before Start of Data Bad_NoData
|
|
128
|
-
// After End of Data Bad_NoData
|
|
129
|
-
// No Start Bound Not Applicable
|
|
130
|
-
// No End Bound Not Applicable
|
|
131
|
-
// Bound Bad Not Applicable
|
|
132
|
-
// Bound Uncertain Not Applicable
|
|
133
|
-
/**
|
|
134
|
-
*
|
|
135
|
-
* @param node
|
|
136
|
-
* @param processingInterval
|
|
137
|
-
* @param startDate
|
|
138
|
-
* @param endDate
|
|
139
|
-
* @param callback
|
|
140
|
-
*/
|
|
141
|
-
function getMinData(node, processingInterval, startDate, endDate, callback) {
|
|
142
|
-
return (0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculateIntervalMinValue, callback);
|
|
143
|
-
}
|
|
144
|
-
exports.getMinData = getMinData;
|
|
145
|
-
function getMaxData(node, processingInterval, startDate, endDate, callback) {
|
|
146
|
-
return (0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculateIntervalMaxValue, callback);
|
|
147
|
-
}
|
|
148
|
-
exports.getMaxData = getMaxData;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMaxData = exports.getMinData = exports.calculateIntervalMaxValue = exports.calculateIntervalMinValue = void 0;
|
|
4
|
+
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
5
|
+
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
// eslint-disable-next-line max-statements
|
|
8
|
+
function calculateIntervalMinOrMaxValue(interval, options, predicate) {
|
|
9
|
+
// console.log(interval.toString());
|
|
10
|
+
const indexStart = interval.index;
|
|
11
|
+
let selectedValue = null;
|
|
12
|
+
let counter = 0;
|
|
13
|
+
let statusCode;
|
|
14
|
+
let isPartial = interval.isPartial;
|
|
15
|
+
let isRaw = false;
|
|
16
|
+
let hasBad = false;
|
|
17
|
+
for (let i = indexStart; i < indexStart + interval.count; i++) {
|
|
18
|
+
const dataValue = interval.dataValues[i];
|
|
19
|
+
if (dataValue.statusCode.equals(node_opcua_status_code_1.StatusCodes.BadNoData)) {
|
|
20
|
+
isPartial = true;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (!dataValue.statusCode.isGood()) {
|
|
24
|
+
hasBad = true;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (!selectedValue) {
|
|
28
|
+
selectedValue = dataValue.value;
|
|
29
|
+
counter = 1;
|
|
30
|
+
if (i === indexStart && dataValue.sourceTimestamp.getTime() === interval.startTime.getTime()) {
|
|
31
|
+
isRaw = true;
|
|
32
|
+
}
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const compare = predicate(selectedValue, dataValue.value);
|
|
36
|
+
if (compare === "equal") {
|
|
37
|
+
counter = 1;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (compare === "select") {
|
|
41
|
+
selectedValue = dataValue.value;
|
|
42
|
+
counter = 1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!selectedValue) {
|
|
46
|
+
return new node_opcua_data_value_1.DataValue({
|
|
47
|
+
sourceTimestamp: interval.startTime,
|
|
48
|
+
statusCode: node_opcua_status_code_1.StatusCodes.BadNoData
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (isRaw) {
|
|
52
|
+
if (hasBad) {
|
|
53
|
+
statusCode = node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (hasBad) {
|
|
60
|
+
statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal, "HistorianCalculated");
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.Good, "HistorianCalculated");
|
|
64
|
+
}
|
|
65
|
+
if (counter > 1) {
|
|
66
|
+
statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(statusCode, "HistorianMultiValue");
|
|
67
|
+
}
|
|
68
|
+
if (isPartial || interval.isPartial) {
|
|
69
|
+
statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(statusCode, "HistorianPartial");
|
|
70
|
+
}
|
|
71
|
+
return new node_opcua_data_value_1.DataValue({
|
|
72
|
+
sourceTimestamp: interval.startTime,
|
|
73
|
+
statusCode: statusCode,
|
|
74
|
+
value: selectedValue
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function calculateIntervalMinValue(interval, options) {
|
|
78
|
+
return calculateIntervalMinOrMaxValue(interval, options, (a, b) => a.value > b.value ? "select" : a.value === b.value ? "equal" : "reject");
|
|
79
|
+
}
|
|
80
|
+
exports.calculateIntervalMinValue = calculateIntervalMinValue;
|
|
81
|
+
function calculateIntervalMaxValue(interval, options) {
|
|
82
|
+
return calculateIntervalMinOrMaxValue(interval, options, (a, b) => a.value < b.value ? "select" : a.value === b.value ? "equal" : "reject");
|
|
83
|
+
}
|
|
84
|
+
exports.calculateIntervalMaxValue = calculateIntervalMaxValue;
|
|
85
|
+
// From OPC Unified Architecture, Part 13 26 Release 1.04
|
|
86
|
+
// 5.4.3.11 Maximum
|
|
87
|
+
// The Maximum Aggregate defined in Table 22 retrieves the maximum Good raw value within
|
|
88
|
+
// the interval, and returns that value with the timestamp at the start of the interval. Note that if
|
|
89
|
+
// the same maximum exists at more than one timestamp the MultipleValues bit is set.
|
|
90
|
+
// Unless otherwise indicated, StatusCodes are Good, Calculated. If the minimum value is on
|
|
91
|
+
// the interval start time the status code will be Good, Raw. If only Bad quality values are
|
|
92
|
+
// available then the status is returned as Bad_NoData.
|
|
93
|
+
// The timestamp of the Aggregate will always be the start of the interval for every
|
|
94
|
+
//
|
|
95
|
+
// ProcessingInterval.
|
|
96
|
+
//
|
|
97
|
+
// Table 22 – Maximum Aggregate summary
|
|
98
|
+
// Maximum Aggregate Characteristics
|
|
99
|
+
//
|
|
100
|
+
// Type Calculated
|
|
101
|
+
// Data Type Same as Source
|
|
102
|
+
// Use Bounds None
|
|
103
|
+
// Timestamp StartTime
|
|
104
|
+
//
|
|
105
|
+
// Status Code Calculations
|
|
106
|
+
// Calculation Method Custom
|
|
107
|
+
// If no Bad values then the Status is Good. If Bad values exist then
|
|
108
|
+
// the Status is Uncertain_SubNormal. If an Uncertain value is greater
|
|
109
|
+
// than the maximum Good value the Status is Uncertain_SubNormal
|
|
110
|
+
//
|
|
111
|
+
// Partial Set Sometimes
|
|
112
|
+
// If an interval is not a complete interval
|
|
113
|
+
//
|
|
114
|
+
// Calculated Set Sometimes
|
|
115
|
+
// If the Maximum value is not on the startTime of the interval or if the
|
|
116
|
+
// Status was set to Uncertain_SubNormal because of non-Good
|
|
117
|
+
// values in the interval
|
|
118
|
+
//
|
|
119
|
+
// Interpolated Not Set
|
|
120
|
+
//
|
|
121
|
+
// Raw Set Sometimes
|
|
122
|
+
// If Maximum value is on the startTime of the interval
|
|
123
|
+
// Multi Value Set Sometimes
|
|
124
|
+
// If multiple Good values exist with the Maximum value
|
|
125
|
+
//
|
|
126
|
+
// Status Code Common Special Cases
|
|
127
|
+
// Before Start of Data Bad_NoData
|
|
128
|
+
// After End of Data Bad_NoData
|
|
129
|
+
// No Start Bound Not Applicable
|
|
130
|
+
// No End Bound Not Applicable
|
|
131
|
+
// Bound Bad Not Applicable
|
|
132
|
+
// Bound Uncertain Not Applicable
|
|
133
|
+
/**
|
|
134
|
+
*
|
|
135
|
+
* @param node
|
|
136
|
+
* @param processingInterval
|
|
137
|
+
* @param startDate
|
|
138
|
+
* @param endDate
|
|
139
|
+
* @param callback
|
|
140
|
+
*/
|
|
141
|
+
function getMinData(node, processingInterval, startDate, endDate, callback) {
|
|
142
|
+
return (0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculateIntervalMinValue, callback);
|
|
143
|
+
}
|
|
144
|
+
exports.getMinData = getMinData;
|
|
145
|
+
function getMaxData(node, processingInterval, startDate, endDate, callback) {
|
|
146
|
+
return (0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculateIntervalMaxValue, callback);
|
|
147
|
+
}
|
|
148
|
+
exports.getMaxData = getMaxData;
|
|
149
149
|
//# sourceMappingURL=minmax.js.map
|
package/dist/percent_bad.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UAVariable } from "node-opcua-address-space";
|
|
2
|
-
import { DataValue } from "node-opcua-data-value";
|
|
3
|
-
/**Retrieve the percentage of data (0 to 100) in the interval which has Bad StatusCode. */
|
|
4
|
-
export declare function getPercentBadData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
|
1
|
+
import { UAVariable } from "node-opcua-address-space";
|
|
2
|
+
import { DataValue } from "node-opcua-data-value";
|
|
3
|
+
/**Retrieve the percentage of data (0 to 100) in the interval which has Bad StatusCode. */
|
|
4
|
+
export declare function getPercentBadData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
package/dist/percent_bad.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPercentBadData = void 0;
|
|
4
|
-
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
5
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
6
|
-
const common_1 = require("./common");
|
|
7
|
-
const calculate_bad_good_1 = require("./calculate_bad_good");
|
|
8
|
-
function calculatePercentBad(interval, options) {
|
|
9
|
-
const { percentBad, statusCode } = (0, calculate_bad_good_1.calculateBadAndGood)(interval, options);
|
|
10
|
-
const value = percentBad;
|
|
11
|
-
if (statusCode.isGoodish()) {
|
|
12
|
-
return new node_opcua_data_value_1.DataValue({
|
|
13
|
-
sourceTimestamp: interval.startTime,
|
|
14
|
-
statusCode,
|
|
15
|
-
value: { dataType: node_opcua_variant_1.DataType.Double, value }
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return new node_opcua_data_value_1.DataValue({ sourceTimestamp: interval.startTime, statusCode, value: { dataType: node_opcua_variant_1.DataType.Null } });
|
|
19
|
-
}
|
|
20
|
-
/**Retrieve the percentage of data (0 to 100) in the interval which has Bad StatusCode. */
|
|
21
|
-
function getPercentBadData(node, processingInterval, startDate, endDate, callback) {
|
|
22
|
-
(0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculatePercentBad, callback);
|
|
23
|
-
}
|
|
24
|
-
exports.getPercentBadData = getPercentBadData;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPercentBadData = void 0;
|
|
4
|
+
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
5
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
const calculate_bad_good_1 = require("./calculate_bad_good");
|
|
8
|
+
function calculatePercentBad(interval, options) {
|
|
9
|
+
const { percentBad, statusCode } = (0, calculate_bad_good_1.calculateBadAndGood)(interval, options);
|
|
10
|
+
const value = percentBad;
|
|
11
|
+
if (statusCode.isGoodish()) {
|
|
12
|
+
return new node_opcua_data_value_1.DataValue({
|
|
13
|
+
sourceTimestamp: interval.startTime,
|
|
14
|
+
statusCode,
|
|
15
|
+
value: { dataType: node_opcua_variant_1.DataType.Double, value }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return new node_opcua_data_value_1.DataValue({ sourceTimestamp: interval.startTime, statusCode, value: { dataType: node_opcua_variant_1.DataType.Null } });
|
|
19
|
+
}
|
|
20
|
+
/**Retrieve the percentage of data (0 to 100) in the interval which has Bad StatusCode. */
|
|
21
|
+
function getPercentBadData(node, processingInterval, startDate, endDate, callback) {
|
|
22
|
+
(0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculatePercentBad, callback);
|
|
23
|
+
}
|
|
24
|
+
exports.getPercentBadData = getPercentBadData;
|
|
25
25
|
//# sourceMappingURL=percent_bad.js.map
|
package/dist/percent_good.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { UAVariable } from "node-opcua-address-space";
|
|
2
|
-
import { DataValue } from "node-opcua-data-value";
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param node Retrieve the percentage of data (0 to 100) in the interval which has Good StatusCode.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getPercentGoodData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
|
1
|
+
import { UAVariable } from "node-opcua-address-space";
|
|
2
|
+
import { DataValue } from "node-opcua-data-value";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param node Retrieve the percentage of data (0 to 100) in the interval which has Good StatusCode.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getPercentGoodData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
package/dist/percent_good.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPercentGoodData = void 0;
|
|
4
|
-
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
5
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
6
|
-
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
7
|
-
const common_1 = require("./common");
|
|
8
|
-
const calculate_bad_good_1 = require("./calculate_bad_good");
|
|
9
|
-
function calculatePercentGood(interval, options) {
|
|
10
|
-
//
|
|
11
|
-
// The PercentGood Aggregate defined in Table 44 performs the following calculation:
|
|
12
|
-
//
|
|
13
|
-
// PercentGood = DurationGood / ProcessingInterval x 100
|
|
14
|
-
// where:
|
|
15
|
-
//
|
|
16
|
-
// DurationGood is the result from the DurationGood *Aggregate*, calculated using the *ProcessingInterval* supplied to *PercentGood* call.
|
|
17
|
-
// ProcessingInterval is the duration of interval.
|
|
18
|
-
// If the last interval is a partial interval then the duration of the partial interval is used in the
|
|
19
|
-
// calculation.
|
|
20
|
-
// Each Aggregate is returned with timestamp of the start of the interval. StatusCodes are Good, Calculated.
|
|
21
|
-
//
|
|
22
|
-
const { percentGood, statusCode } = (0, calculate_bad_good_1.calculateBadAndGood)(interval, options);
|
|
23
|
-
if (percentGood < 0) {
|
|
24
|
-
// special case ! to indicate that no good pointhas been found in the interval
|
|
25
|
-
return new node_opcua_data_value_1.DataValue({
|
|
26
|
-
sourceTimestamp: interval.startTime,
|
|
27
|
-
statusCode: node_opcua_status_code_1.StatusCodes.Bad,
|
|
28
|
-
value: { dataType: node_opcua_variant_1.DataType.Null }
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
const value = percentGood;
|
|
32
|
-
if (statusCode.isGoodish()) {
|
|
33
|
-
return new node_opcua_data_value_1.DataValue({
|
|
34
|
-
sourceTimestamp: interval.startTime,
|
|
35
|
-
statusCode,
|
|
36
|
-
value: { dataType: node_opcua_variant_1.DataType.Double, value }
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return new node_opcua_data_value_1.DataValue({ sourceTimestamp: interval.startTime, statusCode, value: { dataType: node_opcua_variant_1.DataType.Null } });
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
* @param node Retrieve the percentage of data (0 to 100) in the interval which has Good StatusCode.
|
|
44
|
-
*/
|
|
45
|
-
function getPercentGoodData(node, processingInterval, startDate, endDate, callback) {
|
|
46
|
-
(0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculatePercentGood, callback);
|
|
47
|
-
}
|
|
48
|
-
exports.getPercentGoodData = getPercentGoodData;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPercentGoodData = void 0;
|
|
4
|
+
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
5
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
6
|
+
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
7
|
+
const common_1 = require("./common");
|
|
8
|
+
const calculate_bad_good_1 = require("./calculate_bad_good");
|
|
9
|
+
function calculatePercentGood(interval, options) {
|
|
10
|
+
//
|
|
11
|
+
// The PercentGood Aggregate defined in Table 44 performs the following calculation:
|
|
12
|
+
//
|
|
13
|
+
// PercentGood = DurationGood / ProcessingInterval x 100
|
|
14
|
+
// where:
|
|
15
|
+
//
|
|
16
|
+
// DurationGood is the result from the DurationGood *Aggregate*, calculated using the *ProcessingInterval* supplied to *PercentGood* call.
|
|
17
|
+
// ProcessingInterval is the duration of interval.
|
|
18
|
+
// If the last interval is a partial interval then the duration of the partial interval is used in the
|
|
19
|
+
// calculation.
|
|
20
|
+
// Each Aggregate is returned with timestamp of the start of the interval. StatusCodes are Good, Calculated.
|
|
21
|
+
//
|
|
22
|
+
const { percentGood, statusCode } = (0, calculate_bad_good_1.calculateBadAndGood)(interval, options);
|
|
23
|
+
if (percentGood < 0) {
|
|
24
|
+
// special case ! to indicate that no good pointhas been found in the interval
|
|
25
|
+
return new node_opcua_data_value_1.DataValue({
|
|
26
|
+
sourceTimestamp: interval.startTime,
|
|
27
|
+
statusCode: node_opcua_status_code_1.StatusCodes.Bad,
|
|
28
|
+
value: { dataType: node_opcua_variant_1.DataType.Null }
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const value = percentGood;
|
|
32
|
+
if (statusCode.isGoodish()) {
|
|
33
|
+
return new node_opcua_data_value_1.DataValue({
|
|
34
|
+
sourceTimestamp: interval.startTime,
|
|
35
|
+
statusCode,
|
|
36
|
+
value: { dataType: node_opcua_variant_1.DataType.Double, value }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return new node_opcua_data_value_1.DataValue({ sourceTimestamp: interval.startTime, statusCode, value: { dataType: node_opcua_variant_1.DataType.Null } });
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param node Retrieve the percentage of data (0 to 100) in the interval which has Good StatusCode.
|
|
44
|
+
*/
|
|
45
|
+
function getPercentGoodData(node, processingInterval, startDate, endDate, callback) {
|
|
46
|
+
(0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculatePercentGood, callback);
|
|
47
|
+
}
|
|
48
|
+
exports.getPercentGoodData = getPercentGoodData;
|
|
49
49
|
//# sourceMappingURL=percent_good.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ISessionContext, UAVariable, ContinuationData } from "node-opcua-address-space";
|
|
2
|
-
import { NumericRange } from "node-opcua-numeric-range";
|
|
3
|
-
import { QualifiedNameLike } from "node-opcua-data-model";
|
|
4
|
-
import { CallbackT } from "node-opcua-status-code";
|
|
5
|
-
import { HistoryReadResult, ReadProcessedDetails } from "node-opcua-service-history";
|
|
6
|
-
export declare function readProcessedDetails(variable: UAVariable, context: ISessionContext, historyReadDetails: ReadProcessedDetails, indexRange: NumericRange | null, dataEncoding: QualifiedNameLike | null, continuationData: ContinuationData, callback: CallbackT<HistoryReadResult>): void;
|
|
1
|
+
import { ISessionContext, UAVariable, ContinuationData } from "node-opcua-address-space";
|
|
2
|
+
import { NumericRange } from "node-opcua-numeric-range";
|
|
3
|
+
import { QualifiedNameLike } from "node-opcua-data-model";
|
|
4
|
+
import { CallbackT } from "node-opcua-status-code";
|
|
5
|
+
import { HistoryReadResult, ReadProcessedDetails } from "node-opcua-service-history";
|
|
6
|
+
export declare function readProcessedDetails(variable: UAVariable, context: ISessionContext, historyReadDetails: ReadProcessedDetails, indexRange: NumericRange | null, dataEncoding: QualifiedNameLike | null, continuationData: ContinuationData, callback: CallbackT<HistoryReadResult>): void;
|