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.
@@ -1,144 +1,144 @@
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
- const count_1 = require("./count");
11
- const percent_bad_1 = require("./percent_bad");
12
- const percent_good_1 = require("./percent_good");
13
- const duration_good_1 = require("./duration_good");
14
- const duration_bad_1 = require("./duration_bad");
15
- function _buildResult(err, dataValues, callback2) {
16
- if (err) {
17
- return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInternalError }));
18
- }
19
- const result = new node_opcua_service_history_1.HistoryReadResult({
20
- historyData: new node_opcua_service_history_1.HistoryData({
21
- dataValues
22
- }),
23
- statusCode: node_opcua_status_code_1.StatusCodes.Good
24
- });
25
- return callback2(null, result);
26
- }
27
- function applyAggregate(variable, processingInterval, startTime, endTime, aggregateType, callback2) {
28
- if (!startTime || !endTime) {
29
- return _buildResult(new Error("Invalid date time"), undefined, callback2);
30
- }
31
- const buildResult = (err, dataValues) => {
32
- _buildResult(err, dataValues, callback2);
33
- };
34
- if (aggregateType.namespace === 0) {
35
- switch (aggregateType.value) {
36
- case node_opcua_constants_1.AggregateFunction.Minimum:
37
- (0, minmax_1.getMinData)(variable, processingInterval, startTime, endTime, buildResult);
38
- break;
39
- case node_opcua_constants_1.AggregateFunction.Maximum:
40
- (0, minmax_1.getMaxData)(variable, processingInterval, startTime, endTime, buildResult);
41
- break;
42
- case node_opcua_constants_1.AggregateFunction.Interpolative:
43
- (0, interpolate_1.getInterpolatedData)(variable, processingInterval, startTime, endTime, buildResult);
44
- break;
45
- case node_opcua_constants_1.AggregateFunction.Average:
46
- (0, average_1.getAverageData)(variable, processingInterval, startTime, endTime, buildResult);
47
- break;
48
- case node_opcua_constants_1.AggregateFunction.DurationGood:
49
- (0, duration_good_1.getDurationGoodData)(variable, processingInterval, startTime, endTime, buildResult);
50
- break;
51
- case node_opcua_constants_1.AggregateFunction.DurationBad:
52
- (0, duration_bad_1.getDurationBadData)(variable, processingInterval, startTime, endTime, buildResult);
53
- break;
54
- case node_opcua_constants_1.AggregateFunction.PercentBad:
55
- (0, percent_bad_1.getPercentBadData)(variable, processingInterval, startTime, endTime, buildResult);
56
- break;
57
- case node_opcua_constants_1.AggregateFunction.PercentGood:
58
- (0, percent_good_1.getPercentGoodData)(variable, processingInterval, startTime, endTime, buildResult);
59
- break;
60
- case node_opcua_constants_1.AggregateFunction.Count:
61
- (0, count_1.getCountData)(variable, processingInterval, startTime, endTime, buildResult);
62
- break;
63
- default:
64
- // todo provide correct implementation
65
- return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadAggregateNotSupported }));
66
- }
67
- }
68
- else {
69
- // custom aggregate added by some companion specification
70
- // to do
71
- return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadAggregateNotSupported }));
72
- }
73
- }
74
- function readProcessedDetails(variable, context, historyReadDetails, indexRange, dataEncoding, continuationData, callback) {
75
- // OPC Unified Architecture, Part 11 27 Release 1.03
76
- //
77
- // This structure is used to compute Aggregate values, qualities, and timestamps from data in
78
- // the history database for the specified time domain for one or more HistoricalDataNodes. The
79
- // time domain is divided into intervals of duration ProcessingInterval. The specified Aggregate
80
- // Type is calculated for each interval beginning with startTime by using the data within the next
81
- // ProcessingInterval.
82
- // For example, this function can provide hourly statistics such as Maximum, Minimum , and
83
- // Average for each item during the specified time domain when ProcessingInterval is 1 hour.
84
- // The domain of the request is defined by startTime, endTime, and ProcessingInterval. All three
85
- // shall be specified. If endTime is less than startTime then the data shall be returned in reverse
86
- // order with the later data coming first. If startTime and endTime are the same then the Server
87
- // shall return Bad_InvalidArgument as there is no meaningful way to interpret such a case. If
88
- // the ProcessingInterval is specified as 0 then Aggregates shall be calculated using one interval
89
- // starting at startTime and ending at endTime.
90
- // The aggregateType[] parameter allows a Client to request multiple Aggregate calculations per
91
- // requested NodeId. If multiple Aggregates are requested then a corresponding number of
92
- // entries are required in the NodesToRead array.
93
- // For example, to request Min Aggregate for NodeId FIC101, FIC102, and both Min and Max
94
- // Aggregates for NodeId FIC103 would require NodeId FIC103 to appear twice in the
95
- // NodesToRead array request parameter.
96
- // aggregateType[] NodesToRead[]
97
- // Min FIC101
98
- // Min FIC102
99
- // Min FIC103
100
- // Max FIC103
101
- // If the array of Aggregates does not match the array of NodesToRead then the Server shall
102
- // return a StatusCode of Bad_AggregateListMismatch.
103
- // The aggregateConfiguration parameter allows a Client to override the Aggregate configuration
104
- // settings supplied by the AggregateConfiguration Object on a per call basis. See Part 13 for
105
- // more information on Aggregate configurations. If the Server does not support the ability to
106
- // override the Aggregate configuration settings then it shall return a StatusCode of Bad_
107
- // AggregateConfigurationRejected. If the Aggregate is not valid for the Node then the
108
- // StatusCode shall be Bad_AggregateNotSupported.
109
- // The values used in computing the Aggregate for each interval shall include any value that
110
- // falls exactly on the timestamp at the beginning of the interval, but shall not include any value
111
- // that falls directly on the timestamp ending the interval. Thus, each value shall be included
112
- // only once in the calculation. If the time domain is in reverse order then we consider the later
113
- // timestamp to be the one beginning the sub interval, and the earlier timestamp to be the one
114
- // ending it. Note that this means that simply swapping the start and end times will not result in
115
- // getting the same values back in reverse order as the intervals being requested in the two
116
- // cases are not the same.
117
- // If an Aggregate is taking a long time to calculate then the Server can return partial results
118
- // with a continuation point. This might be done if the calculation is going to take more time th an
119
- // the Client timeout hint. In some cases it may take longer than the Client timeout hint to
120
- // calculate even one Aggregate result. Then the Server may return zero results with a
121
- // continuation point that allows the Server to resume the calculation on the next Client read
122
- // call.
123
- const startTime = historyReadDetails.startTime;
124
- const endTime = historyReadDetails.endTime;
125
- if (!startTime || !endTime) {
126
- return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument }));
127
- }
128
- if (startTime.getTime() === endTime.getTime()) {
129
- // Start = End Int = Anything No intervals. Returns a Bad_InvalidArgument StatusCode,
130
- // regardless of whether there is data at the specified time or not
131
- return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument }));
132
- }
133
- const aggregateTypes = historyReadDetails.aggregateType || [];
134
- // If the ProcessingInterval is specified as 0 then Aggregates shall be calculated using one interval
135
- // starting at startTime and ending at endTime.
136
- const processingInterval = historyReadDetails.processingInterval || endTime.getTime() - startTime.getTime();
137
- // tslint:disable-next-line: prefer-for-of
138
- if (!historyReadDetails.aggregateType || historyReadDetails.aggregateType.length !== 1) {
139
- return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInternalError }));
140
- }
141
- return applyAggregate(variable, processingInterval, startTime, endTime, aggregateTypes[0], callback);
142
- }
143
- 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
+ const count_1 = require("./count");
11
+ const percent_bad_1 = require("./percent_bad");
12
+ const percent_good_1 = require("./percent_good");
13
+ const duration_good_1 = require("./duration_good");
14
+ const duration_bad_1 = require("./duration_bad");
15
+ function _buildResult(err, dataValues, callback2) {
16
+ if (err) {
17
+ return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInternalError }));
18
+ }
19
+ const result = new node_opcua_service_history_1.HistoryReadResult({
20
+ historyData: new node_opcua_service_history_1.HistoryData({
21
+ dataValues
22
+ }),
23
+ statusCode: node_opcua_status_code_1.StatusCodes.Good
24
+ });
25
+ return callback2(null, result);
26
+ }
27
+ function applyAggregate(variable, processingInterval, startTime, endTime, aggregateType, callback2) {
28
+ if (!startTime || !endTime) {
29
+ return _buildResult(new Error("Invalid date time"), undefined, callback2);
30
+ }
31
+ const buildResult = (err, dataValues) => {
32
+ _buildResult(err, dataValues, callback2);
33
+ };
34
+ if (aggregateType.namespace === 0) {
35
+ switch (aggregateType.value) {
36
+ case node_opcua_constants_1.AggregateFunction.Minimum:
37
+ (0, minmax_1.getMinData)(variable, processingInterval, startTime, endTime, buildResult);
38
+ break;
39
+ case node_opcua_constants_1.AggregateFunction.Maximum:
40
+ (0, minmax_1.getMaxData)(variable, processingInterval, startTime, endTime, buildResult);
41
+ break;
42
+ case node_opcua_constants_1.AggregateFunction.Interpolative:
43
+ (0, interpolate_1.getInterpolatedData)(variable, processingInterval, startTime, endTime, buildResult);
44
+ break;
45
+ case node_opcua_constants_1.AggregateFunction.Average:
46
+ (0, average_1.getAverageData)(variable, processingInterval, startTime, endTime, buildResult);
47
+ break;
48
+ case node_opcua_constants_1.AggregateFunction.DurationGood:
49
+ (0, duration_good_1.getDurationGoodData)(variable, processingInterval, startTime, endTime, buildResult);
50
+ break;
51
+ case node_opcua_constants_1.AggregateFunction.DurationBad:
52
+ (0, duration_bad_1.getDurationBadData)(variable, processingInterval, startTime, endTime, buildResult);
53
+ break;
54
+ case node_opcua_constants_1.AggregateFunction.PercentBad:
55
+ (0, percent_bad_1.getPercentBadData)(variable, processingInterval, startTime, endTime, buildResult);
56
+ break;
57
+ case node_opcua_constants_1.AggregateFunction.PercentGood:
58
+ (0, percent_good_1.getPercentGoodData)(variable, processingInterval, startTime, endTime, buildResult);
59
+ break;
60
+ case node_opcua_constants_1.AggregateFunction.Count:
61
+ (0, count_1.getCountData)(variable, processingInterval, startTime, endTime, buildResult);
62
+ break;
63
+ default:
64
+ // todo provide correct implementation
65
+ return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadAggregateNotSupported }));
66
+ }
67
+ }
68
+ else {
69
+ // custom aggregate added by some companion specification
70
+ // to do
71
+ return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadAggregateNotSupported }));
72
+ }
73
+ }
74
+ function readProcessedDetails(variable, context, historyReadDetails, indexRange, dataEncoding, continuationData, callback) {
75
+ // OPC Unified Architecture, Part 11 27 Release 1.03
76
+ //
77
+ // This structure is used to compute Aggregate values, qualities, and timestamps from data in
78
+ // the history database for the specified time domain for one or more HistoricalDataNodes. The
79
+ // time domain is divided into intervals of duration ProcessingInterval. The specified Aggregate
80
+ // Type is calculated for each interval beginning with startTime by using the data within the next
81
+ // ProcessingInterval.
82
+ // For example, this function can provide hourly statistics such as Maximum, Minimum , and
83
+ // Average for each item during the specified time domain when ProcessingInterval is 1 hour.
84
+ // The domain of the request is defined by startTime, endTime, and ProcessingInterval. All three
85
+ // shall be specified. If endTime is less than startTime then the data shall be returned in reverse
86
+ // order with the later data coming first. If startTime and endTime are the same then the Server
87
+ // shall return Bad_InvalidArgument as there is no meaningful way to interpret such a case. If
88
+ // the ProcessingInterval is specified as 0 then Aggregates shall be calculated using one interval
89
+ // starting at startTime and ending at endTime.
90
+ // The aggregateType[] parameter allows a Client to request multiple Aggregate calculations per
91
+ // requested NodeId. If multiple Aggregates are requested then a corresponding number of
92
+ // entries are required in the NodesToRead array.
93
+ // For example, to request Min Aggregate for NodeId FIC101, FIC102, and both Min and Max
94
+ // Aggregates for NodeId FIC103 would require NodeId FIC103 to appear twice in the
95
+ // NodesToRead array request parameter.
96
+ // aggregateType[] NodesToRead[]
97
+ // Min FIC101
98
+ // Min FIC102
99
+ // Min FIC103
100
+ // Max FIC103
101
+ // If the array of Aggregates does not match the array of NodesToRead then the Server shall
102
+ // return a StatusCode of Bad_AggregateListMismatch.
103
+ // The aggregateConfiguration parameter allows a Client to override the Aggregate configuration
104
+ // settings supplied by the AggregateConfiguration Object on a per call basis. See Part 13 for
105
+ // more information on Aggregate configurations. If the Server does not support the ability to
106
+ // override the Aggregate configuration settings then it shall return a StatusCode of Bad_
107
+ // AggregateConfigurationRejected. If the Aggregate is not valid for the Node then the
108
+ // StatusCode shall be Bad_AggregateNotSupported.
109
+ // The values used in computing the Aggregate for each interval shall include any value that
110
+ // falls exactly on the timestamp at the beginning of the interval, but shall not include any value
111
+ // that falls directly on the timestamp ending the interval. Thus, each value shall be included
112
+ // only once in the calculation. If the time domain is in reverse order then we consider the later
113
+ // timestamp to be the one beginning the sub interval, and the earlier timestamp to be the one
114
+ // ending it. Note that this means that simply swapping the start and end times will not result in
115
+ // getting the same values back in reverse order as the intervals being requested in the two
116
+ // cases are not the same.
117
+ // If an Aggregate is taking a long time to calculate then the Server can return partial results
118
+ // with a continuation point. This might be done if the calculation is going to take more time th an
119
+ // the Client timeout hint. In some cases it may take longer than the Client timeout hint to
120
+ // calculate even one Aggregate result. Then the Server may return zero results with a
121
+ // continuation point that allows the Server to resume the calculation on the next Client read
122
+ // call.
123
+ const startTime = historyReadDetails.startTime;
124
+ const endTime = historyReadDetails.endTime;
125
+ if (!startTime || !endTime) {
126
+ return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument }));
127
+ }
128
+ if (startTime.getTime() === endTime.getTime()) {
129
+ // Start = End Int = Anything No intervals. Returns a Bad_InvalidArgument StatusCode,
130
+ // regardless of whether there is data at the specified time or not
131
+ return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument }));
132
+ }
133
+ const aggregateTypes = historyReadDetails.aggregateType || [];
134
+ // If the ProcessingInterval is specified as 0 then Aggregates shall be calculated using one interval
135
+ // starting at startTime and ending at endTime.
136
+ const processingInterval = historyReadDetails.processingInterval || endTime.getTime() - startTime.getTime();
137
+ // tslint:disable-next-line: prefer-for-of
138
+ if (!historyReadDetails.aggregateType || historyReadDetails.aggregateType.length !== 1) {
139
+ return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInternalError }));
140
+ }
141
+ return applyAggregate(variable, processingInterval, startTime, endTime, aggregateTypes[0], callback);
142
+ }
143
+ exports.readProcessedDetails = readProcessedDetails;
144
144
  //# sourceMappingURL=read_processed_details.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-opcua-aggregates",
3
- "version": "2.97.0",
4
- "description": "pure nodejs OPCUA SDK - module -end2end-test",
3
+ "version": "2.98.1",
4
+ "description": "pure nodejs OPCUA SDK - module aggregates",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "scripts": {
@@ -12,23 +12,23 @@
12
12
  "clean": "npx rimraf node_modules dist *.tsbuildinfo"
13
13
  },
14
14
  "dependencies": {
15
- "node-opcua-address-space": "2.97.0",
16
- "node-opcua-assert": "2.88.0",
17
- "node-opcua-constants": "2.88.0",
18
- "node-opcua-data-model": "2.97.0",
19
- "node-opcua-data-value": "2.97.0",
20
- "node-opcua-nodeid": "2.97.0",
21
- "node-opcua-numeric-range": "2.97.0",
22
- "node-opcua-server": "2.97.0",
23
- "node-opcua-service-history": "2.97.0",
24
- "node-opcua-status-code": "2.90.1",
25
- "node-opcua-types": "2.97.0",
26
- "node-opcua-utils": "2.90.1",
27
- "node-opcua-variant": "2.97.0"
15
+ "node-opcua-address-space": "2.98.1",
16
+ "node-opcua-assert": "2.98.1",
17
+ "node-opcua-constants": "2.98.1",
18
+ "node-opcua-data-model": "2.98.1",
19
+ "node-opcua-data-value": "2.98.1",
20
+ "node-opcua-nodeid": "2.98.1",
21
+ "node-opcua-numeric-range": "2.98.1",
22
+ "node-opcua-server": "2.98.1",
23
+ "node-opcua-service-history": "2.98.1",
24
+ "node-opcua-status-code": "2.98.1",
25
+ "node-opcua-types": "2.98.1",
26
+ "node-opcua-utils": "2.98.1",
27
+ "node-opcua-variant": "2.98.1"
28
28
  },
29
29
  "devDependencies": {
30
- "node-opcua-leak-detector": "2.90.1",
31
- "node-opcua-nodesets": "2.96.0",
30
+ "node-opcua-leak-detector": "2.98.1",
31
+ "node-opcua-nodesets": "2.98.1",
32
32
  "should": "^13.2.3"
33
33
  },
34
34
  "author": "Etienne Rossignon",
@@ -46,5 +46,9 @@
46
46
  "internet of things"
47
47
  ],
48
48
  "homepage": "http://node-opcua.github.io/",
49
- "gitHead": "19c96bda0810d2dec73dd1c2427546be40908646"
49
+ "gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c",
50
+ "files": [
51
+ "dist",
52
+ "source"
53
+ ]
50
54
  }
package/.mocharc.yml DELETED
@@ -1,7 +0,0 @@
1
- require:
2
- - ts-node/register
3
- extension:
4
- - ts
5
- - js
6
- recursive: true
7
- timeout: 10000
@@ -1,15 +0,0 @@
1
- const path = require("path");
2
- const {OPCUAServer} = require("node-opcua-server");
3
-
4
- const server = new OPCUAServer({
5
- });
6
-
7
- const { addAggregateSupport } = require("..");
8
-
9
- server.start(function(err){
10
-
11
- addAggregateSupport(server.engine.addressSpace);
12
-
13
- console.log("err= ",err);
14
-
15
- });
package/nyc.config.js DELETED
@@ -1,16 +0,0 @@
1
- module.exports = {
2
- "extension": [
3
- ".ts",
4
- ".tsx"
5
- ],
6
- "all": true,
7
- "include": [
8
- "dist/**/*.js",
9
- "source/**/*.ts",
10
-
11
- ],
12
- "exclude": [
13
- "**/*.spec.js"
14
- ],
15
- "check-coverage": true
16
- };