node-opcua-aggregates 2.73.1 → 2.76.0

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/minmax.js CHANGED
@@ -1,150 +1,150 @@
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
- const interval_1 = require("./interval");
8
- // eslint-disable-next-line max-statements
9
- function calculateIntervalMinOrMaxValue(interval, options, predicate) {
10
- // console.log(interval.toString());
11
- const indexStart = interval.index;
12
- let selectedValue = null;
13
- let counter = 0;
14
- let statusCode;
15
- let isPartial = interval.isPartial;
16
- let isRaw = false;
17
- let hasBad = false;
18
- for (let i = indexStart; i < indexStart + interval.count; i++) {
19
- const dataValue = interval.dataValues[i];
20
- if (dataValue.statusCode === node_opcua_status_code_1.StatusCodes.BadNoData) {
21
- isPartial = true;
22
- continue;
23
- }
24
- if (!(0, interval_1.isGood)(dataValue.statusCode)) {
25
- hasBad = true;
26
- continue;
27
- }
28
- if (!selectedValue) {
29
- selectedValue = dataValue.value;
30
- counter = 1;
31
- if (i === indexStart && dataValue.sourceTimestamp.getTime() === interval.startTime.getTime()) {
32
- isRaw = true;
33
- }
34
- continue;
35
- }
36
- const compare = predicate(selectedValue, dataValue.value);
37
- if (compare === "equal") {
38
- counter = 1;
39
- continue;
40
- }
41
- if (compare === "select") {
42
- selectedValue = dataValue.value;
43
- counter = 1;
44
- }
45
- }
46
- if (!selectedValue) {
47
- return new node_opcua_data_value_1.DataValue({
48
- sourceTimestamp: interval.startTime,
49
- statusCode: node_opcua_status_code_1.StatusCodes.BadNoData
50
- });
51
- }
52
- if (isRaw) {
53
- if (hasBad) {
54
- statusCode = node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal;
55
- }
56
- else {
57
- statusCode = node_opcua_status_code_1.StatusCodes.Good;
58
- }
59
- }
60
- else if (hasBad) {
61
- statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal, "HistorianCalculated");
62
- }
63
- else {
64
- statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.Good, "HistorianCalculated");
65
- }
66
- if (counter > 1) {
67
- statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(statusCode, "HistorianMultiValue");
68
- }
69
- if (isPartial || interval.isPartial) {
70
- statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(statusCode, "HistorianPartial");
71
- }
72
- return new node_opcua_data_value_1.DataValue({
73
- sourceTimestamp: interval.startTime,
74
- statusCode: statusCode,
75
- value: selectedValue
76
- });
77
- }
78
- function calculateIntervalMinValue(interval, options) {
79
- return calculateIntervalMinOrMaxValue(interval, options, (a, b) => a.value > b.value ? "select" : a.value === b.value ? "equal" : "reject");
80
- }
81
- exports.calculateIntervalMinValue = calculateIntervalMinValue;
82
- function calculateIntervalMaxValue(interval, options) {
83
- return calculateIntervalMinOrMaxValue(interval, options, (a, b) => a.value < b.value ? "select" : a.value === b.value ? "equal" : "reject");
84
- }
85
- exports.calculateIntervalMaxValue = calculateIntervalMaxValue;
86
- // From OPC Unified Architecture, Part 13 26 Release 1.04
87
- // 5.4.3.11 Maximum
88
- // The Maximum Aggregate defined in Table 22 retrieves the maximum Good raw value within
89
- // the interval, and returns that value with the timestamp at the start of the interval. Note that if
90
- // the same maximum exists at more than one timestamp the MultipleValues bit is set.
91
- // Unless otherwise indicated, StatusCodes are Good, Calculated. If the minimum value is on
92
- // the interval start time the status code will be Good, Raw. If only Bad quality values are
93
- // available then the status is returned as Bad_NoData.
94
- // The timestamp of the Aggregate will always be the start of the interval for every
95
- //
96
- // ProcessingInterval.
97
- //
98
- // Table 22 – Maximum Aggregate summary
99
- // Maximum Aggregate Characteristics
100
- //
101
- // Type Calculated
102
- // Data Type Same as Source
103
- // Use Bounds None
104
- // Timestamp StartTime
105
- //
106
- // Status Code Calculations
107
- // Calculation Method Custom
108
- // If no Bad values then the Status is Good. If Bad values exist then
109
- // the Status is Uncertain_SubNormal. If an Uncertain value is greater
110
- // than the maximum Good value the Status is Uncertain_SubNormal
111
- //
112
- // Partial Set Sometimes
113
- // If an interval is not a complete interval
114
- //
115
- // Calculated Set Sometimes
116
- // If the Maximum value is not on the startTime of the interval or if the
117
- // Status was set to Uncertain_SubNormal because of non-Good
118
- // values in the interval
119
- //
120
- // Interpolated Not Set
121
- //
122
- // Raw Set Sometimes
123
- // If Maximum value is on the startTime of the interval
124
- // Multi Value Set Sometimes
125
- // If multiple Good values exist with the Maximum value
126
- //
127
- // Status Code Common Special Cases
128
- // Before Start of Data Bad_NoData
129
- // After End of Data Bad_NoData
130
- // No Start Bound Not Applicable
131
- // No End Bound Not Applicable
132
- // Bound Bad Not Applicable
133
- // Bound Uncertain Not Applicable
134
- /**
135
- *
136
- * @param node
137
- * @param processingInterval
138
- * @param startDate
139
- * @param endDate
140
- * @param callback
141
- */
142
- function getMinData(node, processingInterval, startDate, endDate, callback) {
143
- return (0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculateIntervalMinValue, callback);
144
- }
145
- exports.getMinData = getMinData;
146
- function getMaxData(node, processingInterval, startDate, endDate, callback) {
147
- return (0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculateIntervalMaxValue, callback);
148
- }
149
- 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
+ const interval_1 = require("./interval");
8
+ // eslint-disable-next-line max-statements
9
+ function calculateIntervalMinOrMaxValue(interval, options, predicate) {
10
+ // console.log(interval.toString());
11
+ const indexStart = interval.index;
12
+ let selectedValue = null;
13
+ let counter = 0;
14
+ let statusCode;
15
+ let isPartial = interval.isPartial;
16
+ let isRaw = false;
17
+ let hasBad = false;
18
+ for (let i = indexStart; i < indexStart + interval.count; i++) {
19
+ const dataValue = interval.dataValues[i];
20
+ if (dataValue.statusCode === node_opcua_status_code_1.StatusCodes.BadNoData) {
21
+ isPartial = true;
22
+ continue;
23
+ }
24
+ if (!(0, interval_1.isGood)(dataValue.statusCode)) {
25
+ hasBad = true;
26
+ continue;
27
+ }
28
+ if (!selectedValue) {
29
+ selectedValue = dataValue.value;
30
+ counter = 1;
31
+ if (i === indexStart && dataValue.sourceTimestamp.getTime() === interval.startTime.getTime()) {
32
+ isRaw = true;
33
+ }
34
+ continue;
35
+ }
36
+ const compare = predicate(selectedValue, dataValue.value);
37
+ if (compare === "equal") {
38
+ counter = 1;
39
+ continue;
40
+ }
41
+ if (compare === "select") {
42
+ selectedValue = dataValue.value;
43
+ counter = 1;
44
+ }
45
+ }
46
+ if (!selectedValue) {
47
+ return new node_opcua_data_value_1.DataValue({
48
+ sourceTimestamp: interval.startTime,
49
+ statusCode: node_opcua_status_code_1.StatusCodes.BadNoData
50
+ });
51
+ }
52
+ if (isRaw) {
53
+ if (hasBad) {
54
+ statusCode = node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal;
55
+ }
56
+ else {
57
+ statusCode = node_opcua_status_code_1.StatusCodes.Good;
58
+ }
59
+ }
60
+ else if (hasBad) {
61
+ statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal, "HistorianCalculated");
62
+ }
63
+ else {
64
+ statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.Good, "HistorianCalculated");
65
+ }
66
+ if (counter > 1) {
67
+ statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(statusCode, "HistorianMultiValue");
68
+ }
69
+ if (isPartial || interval.isPartial) {
70
+ statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(statusCode, "HistorianPartial");
71
+ }
72
+ return new node_opcua_data_value_1.DataValue({
73
+ sourceTimestamp: interval.startTime,
74
+ statusCode: statusCode,
75
+ value: selectedValue
76
+ });
77
+ }
78
+ function calculateIntervalMinValue(interval, options) {
79
+ return calculateIntervalMinOrMaxValue(interval, options, (a, b) => a.value > b.value ? "select" : a.value === b.value ? "equal" : "reject");
80
+ }
81
+ exports.calculateIntervalMinValue = calculateIntervalMinValue;
82
+ function calculateIntervalMaxValue(interval, options) {
83
+ return calculateIntervalMinOrMaxValue(interval, options, (a, b) => a.value < b.value ? "select" : a.value === b.value ? "equal" : "reject");
84
+ }
85
+ exports.calculateIntervalMaxValue = calculateIntervalMaxValue;
86
+ // From OPC Unified Architecture, Part 13 26 Release 1.04
87
+ // 5.4.3.11 Maximum
88
+ // The Maximum Aggregate defined in Table 22 retrieves the maximum Good raw value within
89
+ // the interval, and returns that value with the timestamp at the start of the interval. Note that if
90
+ // the same maximum exists at more than one timestamp the MultipleValues bit is set.
91
+ // Unless otherwise indicated, StatusCodes are Good, Calculated. If the minimum value is on
92
+ // the interval start time the status code will be Good, Raw. If only Bad quality values are
93
+ // available then the status is returned as Bad_NoData.
94
+ // The timestamp of the Aggregate will always be the start of the interval for every
95
+ //
96
+ // ProcessingInterval.
97
+ //
98
+ // Table 22 – Maximum Aggregate summary
99
+ // Maximum Aggregate Characteristics
100
+ //
101
+ // Type Calculated
102
+ // Data Type Same as Source
103
+ // Use Bounds None
104
+ // Timestamp StartTime
105
+ //
106
+ // Status Code Calculations
107
+ // Calculation Method Custom
108
+ // If no Bad values then the Status is Good. If Bad values exist then
109
+ // the Status is Uncertain_SubNormal. If an Uncertain value is greater
110
+ // than the maximum Good value the Status is Uncertain_SubNormal
111
+ //
112
+ // Partial Set Sometimes
113
+ // If an interval is not a complete interval
114
+ //
115
+ // Calculated Set Sometimes
116
+ // If the Maximum value is not on the startTime of the interval or if the
117
+ // Status was set to Uncertain_SubNormal because of non-Good
118
+ // values in the interval
119
+ //
120
+ // Interpolated Not Set
121
+ //
122
+ // Raw Set Sometimes
123
+ // If Maximum value is on the startTime of the interval
124
+ // Multi Value Set Sometimes
125
+ // If multiple Good values exist with the Maximum value
126
+ //
127
+ // Status Code Common Special Cases
128
+ // Before Start of Data Bad_NoData
129
+ // After End of Data Bad_NoData
130
+ // No Start Bound Not Applicable
131
+ // No End Bound Not Applicable
132
+ // Bound Bad Not Applicable
133
+ // Bound Uncertain Not Applicable
134
+ /**
135
+ *
136
+ * @param node
137
+ * @param processingInterval
138
+ * @param startDate
139
+ * @param endDate
140
+ * @param callback
141
+ */
142
+ function getMinData(node, processingInterval, startDate, endDate, callback) {
143
+ return (0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculateIntervalMinValue, callback);
144
+ }
145
+ exports.getMinData = getMinData;
146
+ function getMaxData(node, processingInterval, startDate, endDate, callback) {
147
+ return (0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculateIntervalMaxValue, callback);
148
+ }
149
+ exports.getMaxData = getMaxData;
150
150
  //# sourceMappingURL=minmax.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;
@@ -1,119 +1,119 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readProcessedDetails = void 0;
4
- const node_opcua_constants_1 = require("node-opcua-constants");
5
- const node_opcua_status_code_1 = require("node-opcua-status-code");
6
- const node_opcua_service_history_1 = require("node-opcua-service-history");
7
- const minmax_1 = require("./minmax");
8
- const interpolate_1 = require("./interpolate");
9
- const average_1 = require("./average");
10
- function _buildResult(err, dataValues, callback2) {
11
- if (err) {
12
- return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInternalError }));
13
- }
14
- const result = new node_opcua_service_history_1.HistoryReadResult({
15
- historyData: new node_opcua_service_history_1.HistoryData({
16
- dataValues
17
- }),
18
- statusCode: node_opcua_status_code_1.StatusCodes.Good
19
- });
20
- return callback2(null, result);
21
- }
22
- function applyAggregate(variable, processingInterval, startTime, endTime, aggregateType, callback2) {
23
- if (!startTime || !endTime) {
24
- return _buildResult(new Error("Invalid date time"), undefined, callback2);
25
- }
26
- const buildResult = (err, dataValues) => {
27
- _buildResult(err, dataValues, callback2);
28
- };
29
- switch (aggregateType.value) {
30
- case node_opcua_constants_1.AggregateFunction.Minimum:
31
- (0, minmax_1.getMinData)(variable, processingInterval, startTime, endTime, buildResult);
32
- break;
33
- case node_opcua_constants_1.AggregateFunction.Maximum:
34
- (0, minmax_1.getMaxData)(variable, processingInterval, startTime, endTime, buildResult);
35
- break;
36
- case node_opcua_constants_1.AggregateFunction.Interpolative:
37
- (0, interpolate_1.getInterpolatedData)(variable, processingInterval, startTime, endTime, buildResult);
38
- break;
39
- case node_opcua_constants_1.AggregateFunction.Average:
40
- (0, average_1.getAverageData)(variable, processingInterval, startTime, endTime, buildResult);
41
- break;
42
- case node_opcua_constants_1.AggregateFunction.Count:
43
- default:
44
- // todo provide correct implementation
45
- return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadAggregateNotSupported }));
46
- }
47
- }
48
- function readProcessedDetails(variable, context, historyReadDetails, indexRange, dataEncoding, continuationData, callback) {
49
- var _a;
50
- // OPC Unified Architecture, Part 11 27 Release 1.03
51
- //
52
- // This structure is used to compute Aggregate values, qualities, and timestamps from data in
53
- // the history database for the specified time domain for one or more HistoricalDataNodes. The
54
- // time domain is divided into intervals of duration ProcessingInterval. The specified Aggregate
55
- // Type is calculated for each interval beginning with startTime by using the data within the next
56
- // ProcessingInterval.
57
- // For example, this function can provide hourly statistics such as Maximum, Minimum , and
58
- // Average for each item during the specified time domain when ProcessingInterval is 1 hour.
59
- // The domain of the request is defined by startTime, endTime, and ProcessingInterval. All three
60
- // shall be specified. If endTime is less than startTime then the data shall be returned in reverse
61
- // order with the later data coming first. If startTime and endTime are the same then the Server
62
- // shall return Bad_InvalidArgument as there is no meaningful way to interpret such a case. If
63
- // the ProcessingInterval is specified as 0 then Aggregates shall be calculated using one interval
64
- // starting at startTime and ending at endTime.
65
- // The aggregateType[] parameter allows a Client to request multiple Aggregate calculations per
66
- // requested NodeId. If multiple Aggregates are requested then a corresponding number of
67
- // entries are required in the NodesToRead array.
68
- // For example, to request Min Aggregate for NodeId FIC101, FIC102, and both Min and Max
69
- // Aggregates for NodeId FIC103 would require NodeId FIC103 to appear twice in the
70
- // NodesToRead array request parameter.
71
- // aggregateType[] NodesToRead[]
72
- // Min FIC101
73
- // Min FIC102
74
- // Min FIC103
75
- // Max FIC103
76
- // If the array of Aggregates does not match the array of NodesToRead then the Server shall
77
- // return a StatusCode of Bad_AggregateListMismatch.
78
- // The aggregateConfiguration parameter allows a Client to override the Aggregate configuration
79
- // settings supplied by the AggregateConfiguration Object on a per call basis. See Part 13 for
80
- // more information on Aggregate configurations. If the Server does not support the ability to
81
- // override the Aggregate configuration settings then it shall return a StatusCode of Bad_
82
- // AggregateConfigurationRejected. If the Aggregate is not valid for the Node then the
83
- // StatusCode shall be Bad_AggregateNotSupported.
84
- // The values used in computing the Aggregate for each interval shall include any value that
85
- // falls exactly on the timestamp at the beginning of the interval, but shall not include any value
86
- // that falls directly on the timestamp ending the interval. Thus, each value shall be included
87
- // only once in the calculation. If the time domain is in reverse order then we consider the later
88
- // timestamp to be the one beginning the sub interval, and the earlier timestamp to be the one
89
- // ending it. Note that this means that simply swapping the start and end times will not result in
90
- // getting the same values back in reverse order as the intervals being requested in the two
91
- // cases are not the same.
92
- // If an Aggregate is taking a long time to calculate then the Server can return partial results
93
- // with a continuation point. This might be done if the calculation is going to take more time th an
94
- // the Client timeout hint. In some cases it may take longer than the Client timeout hint to
95
- // calculate even one Aggregate result. Then the Server may return zero results with a
96
- // continuation point that allows the Server to resume the calculation on the next Client read
97
- // call.
98
- const startTime = historyReadDetails.startTime;
99
- const endTime = historyReadDetails.endTime;
100
- if (!startTime || !endTime) {
101
- return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument }));
102
- }
103
- if (startTime.getTime() === endTime.getTime()) {
104
- // Start = End Int = Anything No intervals. Returns a Bad_InvalidArgument StatusCode,
105
- // regardless of whether there is data at the specified time or not
106
- return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument }));
107
- }
108
- const aggregateTypes = historyReadDetails.aggregateType || [];
109
- // If the ProcessingInterval is specified as 0 then Aggregates shall be calculated using one interval
110
- // starting at startTime and ending at endTime.
111
- const processingInterval = historyReadDetails.processingInterval || endTime.getTime() - startTime.getTime();
112
- // tslint:disable-next-line: prefer-for-of
113
- if (((_a = historyReadDetails.aggregateType) === null || _a === void 0 ? void 0 : _a.length) !== 1) {
114
- return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInternalError }));
115
- }
116
- return applyAggregate(variable, processingInterval, startTime, endTime, aggregateTypes[0], callback);
117
- }
118
- exports.readProcessedDetails = readProcessedDetails;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readProcessedDetails = void 0;
4
+ const node_opcua_constants_1 = require("node-opcua-constants");
5
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
6
+ const node_opcua_service_history_1 = require("node-opcua-service-history");
7
+ const minmax_1 = require("./minmax");
8
+ const interpolate_1 = require("./interpolate");
9
+ const average_1 = require("./average");
10
+ function _buildResult(err, dataValues, callback2) {
11
+ if (err) {
12
+ return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInternalError }));
13
+ }
14
+ const result = new node_opcua_service_history_1.HistoryReadResult({
15
+ historyData: new node_opcua_service_history_1.HistoryData({
16
+ dataValues
17
+ }),
18
+ statusCode: node_opcua_status_code_1.StatusCodes.Good
19
+ });
20
+ return callback2(null, result);
21
+ }
22
+ function applyAggregate(variable, processingInterval, startTime, endTime, aggregateType, callback2) {
23
+ if (!startTime || !endTime) {
24
+ return _buildResult(new Error("Invalid date time"), undefined, callback2);
25
+ }
26
+ const buildResult = (err, dataValues) => {
27
+ _buildResult(err, dataValues, callback2);
28
+ };
29
+ switch (aggregateType.value) {
30
+ case node_opcua_constants_1.AggregateFunction.Minimum:
31
+ (0, minmax_1.getMinData)(variable, processingInterval, startTime, endTime, buildResult);
32
+ break;
33
+ case node_opcua_constants_1.AggregateFunction.Maximum:
34
+ (0, minmax_1.getMaxData)(variable, processingInterval, startTime, endTime, buildResult);
35
+ break;
36
+ case node_opcua_constants_1.AggregateFunction.Interpolative:
37
+ (0, interpolate_1.getInterpolatedData)(variable, processingInterval, startTime, endTime, buildResult);
38
+ break;
39
+ case node_opcua_constants_1.AggregateFunction.Average:
40
+ (0, average_1.getAverageData)(variable, processingInterval, startTime, endTime, buildResult);
41
+ break;
42
+ case node_opcua_constants_1.AggregateFunction.Count:
43
+ default:
44
+ // todo provide correct implementation
45
+ return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadAggregateNotSupported }));
46
+ }
47
+ }
48
+ function readProcessedDetails(variable, context, historyReadDetails, indexRange, dataEncoding, continuationData, callback) {
49
+ var _a;
50
+ // OPC Unified Architecture, Part 11 27 Release 1.03
51
+ //
52
+ // This structure is used to compute Aggregate values, qualities, and timestamps from data in
53
+ // the history database for the specified time domain for one or more HistoricalDataNodes. The
54
+ // time domain is divided into intervals of duration ProcessingInterval. The specified Aggregate
55
+ // Type is calculated for each interval beginning with startTime by using the data within the next
56
+ // ProcessingInterval.
57
+ // For example, this function can provide hourly statistics such as Maximum, Minimum , and
58
+ // Average for each item during the specified time domain when ProcessingInterval is 1 hour.
59
+ // The domain of the request is defined by startTime, endTime, and ProcessingInterval. All three
60
+ // shall be specified. If endTime is less than startTime then the data shall be returned in reverse
61
+ // order with the later data coming first. If startTime and endTime are the same then the Server
62
+ // shall return Bad_InvalidArgument as there is no meaningful way to interpret such a case. If
63
+ // the ProcessingInterval is specified as 0 then Aggregates shall be calculated using one interval
64
+ // starting at startTime and ending at endTime.
65
+ // The aggregateType[] parameter allows a Client to request multiple Aggregate calculations per
66
+ // requested NodeId. If multiple Aggregates are requested then a corresponding number of
67
+ // entries are required in the NodesToRead array.
68
+ // For example, to request Min Aggregate for NodeId FIC101, FIC102, and both Min and Max
69
+ // Aggregates for NodeId FIC103 would require NodeId FIC103 to appear twice in the
70
+ // NodesToRead array request parameter.
71
+ // aggregateType[] NodesToRead[]
72
+ // Min FIC101
73
+ // Min FIC102
74
+ // Min FIC103
75
+ // Max FIC103
76
+ // If the array of Aggregates does not match the array of NodesToRead then the Server shall
77
+ // return a StatusCode of Bad_AggregateListMismatch.
78
+ // The aggregateConfiguration parameter allows a Client to override the Aggregate configuration
79
+ // settings supplied by the AggregateConfiguration Object on a per call basis. See Part 13 for
80
+ // more information on Aggregate configurations. If the Server does not support the ability to
81
+ // override the Aggregate configuration settings then it shall return a StatusCode of Bad_
82
+ // AggregateConfigurationRejected. If the Aggregate is not valid for the Node then the
83
+ // StatusCode shall be Bad_AggregateNotSupported.
84
+ // The values used in computing the Aggregate for each interval shall include any value that
85
+ // falls exactly on the timestamp at the beginning of the interval, but shall not include any value
86
+ // that falls directly on the timestamp ending the interval. Thus, each value shall be included
87
+ // only once in the calculation. If the time domain is in reverse order then we consider the later
88
+ // timestamp to be the one beginning the sub interval, and the earlier timestamp to be the one
89
+ // ending it. Note that this means that simply swapping the start and end times will not result in
90
+ // getting the same values back in reverse order as the intervals being requested in the two
91
+ // cases are not the same.
92
+ // If an Aggregate is taking a long time to calculate then the Server can return partial results
93
+ // with a continuation point. This might be done if the calculation is going to take more time th an
94
+ // the Client timeout hint. In some cases it may take longer than the Client timeout hint to
95
+ // calculate even one Aggregate result. Then the Server may return zero results with a
96
+ // continuation point that allows the Server to resume the calculation on the next Client read
97
+ // call.
98
+ const startTime = historyReadDetails.startTime;
99
+ const endTime = historyReadDetails.endTime;
100
+ if (!startTime || !endTime) {
101
+ return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument }));
102
+ }
103
+ if (startTime.getTime() === endTime.getTime()) {
104
+ // Start = End Int = Anything No intervals. Returns a Bad_InvalidArgument StatusCode,
105
+ // regardless of whether there is data at the specified time or not
106
+ return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument }));
107
+ }
108
+ const aggregateTypes = historyReadDetails.aggregateType || [];
109
+ // If the ProcessingInterval is specified as 0 then Aggregates shall be calculated using one interval
110
+ // starting at startTime and ending at endTime.
111
+ const processingInterval = historyReadDetails.processingInterval || endTime.getTime() - startTime.getTime();
112
+ // tslint:disable-next-line: prefer-for-of
113
+ if (((_a = historyReadDetails.aggregateType) === null || _a === void 0 ? void 0 : _a.length) !== 1) {
114
+ return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInternalError }));
115
+ }
116
+ return applyAggregate(variable, processingInterval, startTime, endTime, aggregateTypes[0], callback);
117
+ }
118
+ exports.readProcessedDetails = readProcessedDetails;
119
119
  //# sourceMappingURL=read_processed_details.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read_processed_details.js","sourceRoot":"","sources":["../source/read_processed_details.ts"],"names":[],"mappings":";;;AACA,+DAAyD;AAIzD,mEAAgE;AAIhE,2EAOoC;AAEpC,qCAAkD;AAElD,+CAAoD;AACpD,uCAA2C;AAE3C,SAAS,YAAY,CAAC,GAAiB,EAAE,UAAmC,EAAE,SAAuC;IACjH,IAAI,GAAG,EAAE;QACL,OAAO,SAAS,CAAC,IAAI,EAAE,IAAI,8CAAiB,CAAC,EAAE,UAAU,EAAE,oCAAW,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;KAC/F;IACD,MAAM,MAAM,GAAG,IAAI,8CAAiB,CAAC;QACjC,WAAW,EAAE,IAAI,wCAAW,CAAC;YACzB,UAAU;SACb,CAAC;QACF,UAAU,EAAE,oCAAW,CAAC,IAAI;KAC/B,CAAC,CAAC;IACH,OAAO,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,cAAc,CACnB,QAAoB,EACpB,kBAA0B,EAC1B,SAAe,EACf,OAAa,EACb,aAAqB,EACrB,SAAuC;IAEvC,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE;QACxB,OAAO,YAAY,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;KAC7E;IACD,MAAM,WAAW,GAAG,CAAC,GAAiB,EAAE,UAAmC,EAAE,EAAE;QAC3E,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,CAAC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AAE,IAAI,8CAAiB,CAAC,EAAE,UAAU,EAAE,oCAAW,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;KAC9F;IACD,OAAO,cAAc,CAAC,QAAQ,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AACzG,CAAC;AA/ED,oDA+EC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-aggregates",
3
- "version": "2.73.1",
3
+ "version": "2.76.0",
4
4
  "description": "pure nodejs OPCUA SDK - module -end2end-test",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,27 +12,23 @@
12
12
  "clean": "npx rimraf dist *.tsbuildinfo"
13
13
  },
14
14
  "dependencies": {
15
- "@types/async": "^3.2.13",
16
- "node-opcua-address-space": "2.73.1",
17
- "node-opcua-constants": "2.70.0",
18
- "node-opcua-data-model": "2.73.1",
19
- "node-opcua-data-value": "2.73.1",
20
- "node-opcua-nodeid": "2.71.0",
21
- "node-opcua-nodesets": "2.73.0",
22
- "node-opcua-numeric-range": "2.73.1",
23
- "node-opcua-service-history": "2.73.1",
24
- "node-opcua-status-code": "2.73.0",
25
- "node-opcua-types": "2.73.1",
26
- "node-opcua-utils": "2.71.0",
27
- "node-opcua-variant": "2.73.1"
15
+ "node-opcua-address-space": "2.76.0",
16
+ "node-opcua-assert": "2.76.0",
17
+ "node-opcua-constants": "2.74.0",
18
+ "node-opcua-data-model": "2.76.0",
19
+ "node-opcua-data-value": "2.76.0",
20
+ "node-opcua-nodeid": "2.76.0",
21
+ "node-opcua-numeric-range": "2.76.0",
22
+ "node-opcua-service-history": "2.76.0",
23
+ "node-opcua-status-code": "2.76.0",
24
+ "node-opcua-types": "2.76.0",
25
+ "node-opcua-utils": "2.76.0",
26
+ "node-opcua-variant": "2.76.0"
28
27
  },
29
28
  "devDependencies": {
30
- "delayed": "^2.0.0",
31
- "node-opcua-assert": "2.66.0",
32
- "node-opcua-leak-detector": "2.71.0",
33
- "should": "^13.2.3",
34
- "sinon": "^14.0.0",
35
- "yargs": "15.4.1"
29
+ "node-opcua-leak-detector": "2.76.0",
30
+ "node-opcua-nodesets": "2.74.0",
31
+ "should": "^13.2.3"
36
32
  },
37
33
  "author": "Etienne Rossignon",
38
34
  "license": "MIT",
@@ -49,5 +45,5 @@
49
45
  "internet of things"
50
46
  ],
51
47
  "homepage": "http://node-opcua.github.io/",
52
- "gitHead": "684a796e88e1732f418f2ada6aca2808e0115de8"
48
+ "gitHead": "75d9b8cf894c8fbadf77d2c4a48a730d055465e7"
53
49
  }