node-opcua-aggregates 2.54.0 → 2.57.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/.mocharc.yml +7 -7
- package/LICENSE +20 -20
- package/bin/sample_aggregate_server.js +14 -14
- package/dist/aggregates.js +2 -2
- package/dist/aggregates.js.map +1 -1
- package/dist/average.js +6 -5
- package/dist/average.js.map +1 -1
- package/dist/common.js +12 -2
- package/dist/common.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interpolate.d.ts +1 -1
- package/dist/interpolate.js +8 -12
- package/dist/interpolate.js.map +1 -1
- package/dist/minmax.js +3 -2
- package/dist/minmax.js.map +1 -1
- package/dist/read_processed_details.d.ts +2 -2
- package/dist/read_processed_details.js +41 -38
- package/dist/read_processed_details.js.map +1 -1
- package/nyc.config.js +16 -16
- package/package.json +17 -15
- package/source/aggregates.ts +284 -277
- package/source/average.ts +71 -74
- package/source/common.ts +23 -10
- package/source/index.ts +11 -17
- package/source/interpolate.ts +14 -20
- package/source/interval.ts +3 -3
- package/source/minmax.ts +231 -231
- package/source/read_processed_details.ts +149 -139
- package/dist2/aggregates.d.ts +0 -7
- package/dist2/aggregates.js +0 -201
- package/dist2/aggregates.js.map +0 -1
- package/dist2/average.d.ts +0 -3
- package/dist2/average.js +0 -61
- package/dist2/average.js.map +0 -1
- package/dist2/common.d.ts +0 -8
- package/dist2/common.js +0 -89
- package/dist2/common.js.map +0 -1
- package/dist2/index.d.ts +0 -11
- package/dist2/index.js +0 -29
- package/dist2/index.js.map +0 -1
- package/dist2/interpolate.d.ts +0 -16
- package/dist2/interpolate.js +0 -135
- package/dist2/interpolate.js.map +0 -1
- package/dist2/interval.d.ts +0 -49
- package/dist2/interval.js +0 -165
- package/dist2/interval.js.map +0 -1
- package/dist2/minmax.d.ts +0 -18
- package/dist2/minmax.js +0 -149
- package/dist2/minmax.js.map +0 -1
- package/dist2/read_processed_details.d.ts +0 -6
- package/dist2/read_processed_details.js +0 -116
- package/dist2/read_processed_details.js.map +0 -1
|
@@ -1,139 +1,149 @@
|
|
|
1
|
-
import * as async from "async";
|
|
2
|
-
import { AggregateFunction } from "node-opcua-constants";
|
|
3
|
-
import { ISessionContext, ContinuationPoint, UAVariable } from "node-opcua-address-space";
|
|
4
|
-
import { NumericRange } from "node-opcua-numeric-range";
|
|
5
|
-
import { QualifiedNameLike } from "node-opcua-data-model";
|
|
6
|
-
import { CallbackT, StatusCodes } from "node-opcua-status-code";
|
|
7
|
-
import { DataValue } from "node-opcua-data-value";
|
|
8
|
-
import { ObjectIds } from "node-opcua-constants";
|
|
9
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
1
|
+
import * as async from "async";
|
|
2
|
+
import { AggregateFunction } from "node-opcua-constants";
|
|
3
|
+
import { ISessionContext, ContinuationPoint, UAVariable, ContinuationData } from "node-opcua-address-space";
|
|
4
|
+
import { NumericRange } from "node-opcua-numeric-range";
|
|
5
|
+
import { QualifiedNameLike } from "node-opcua-data-model";
|
|
6
|
+
import { CallbackT, StatusCodes } from "node-opcua-status-code";
|
|
7
|
+
import { DataValue } from "node-opcua-data-value";
|
|
8
|
+
import { ObjectIds } from "node-opcua-constants";
|
|
9
|
+
import { NodeId } from "node-opcua-nodeid";
|
|
10
|
+
import {
|
|
11
|
+
HistoryData,
|
|
12
|
+
HistoryReadResult,
|
|
13
|
+
ReadAtTimeDetails,
|
|
14
|
+
ReadEventDetails,
|
|
15
|
+
ReadProcessedDetails,
|
|
16
|
+
ReadRawModifiedDetails
|
|
17
|
+
} from "node-opcua-service-history";
|
|
18
|
+
|
|
19
|
+
import { getMinData, getMaxData } from "./minmax";
|
|
20
|
+
|
|
21
|
+
import { getInterpolatedData } from "./interpolate";
|
|
22
|
+
import { getAverageData } from "./average";
|
|
23
|
+
|
|
24
|
+
function _buildResult(err: Error | null, dataValues: DataValue[] | undefined, callback2: CallbackT<HistoryReadResult>) {
|
|
25
|
+
if (err) {
|
|
26
|
+
return callback2(null, new HistoryReadResult({ statusCode: StatusCodes.BadInternalError }));
|
|
27
|
+
}
|
|
28
|
+
const result = new HistoryReadResult({
|
|
29
|
+
historyData: new HistoryData({
|
|
30
|
+
dataValues
|
|
31
|
+
}),
|
|
32
|
+
statusCode: StatusCodes.Good
|
|
33
|
+
});
|
|
34
|
+
return callback2(null, result);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function applyAggregate(
|
|
38
|
+
variable: UAVariable,
|
|
39
|
+
processingInterval: number,
|
|
40
|
+
startTime: Date,
|
|
41
|
+
endTime: Date,
|
|
42
|
+
aggregateType: NodeId,
|
|
43
|
+
callback2: CallbackT<HistoryReadResult>
|
|
44
|
+
) {
|
|
45
|
+
if (!startTime || !endTime) {
|
|
46
|
+
return _buildResult(new Error("Invalid date time"), undefined, callback2);
|
|
47
|
+
}
|
|
48
|
+
const buildResult = (err: Error | null, dataValues: DataValue[] | undefined) => {
|
|
49
|
+
_buildResult(err, dataValues, callback2);
|
|
50
|
+
};
|
|
51
|
+
switch (aggregateType.value) {
|
|
52
|
+
case AggregateFunction.Minimum:
|
|
53
|
+
getMinData(variable, processingInterval, startTime, endTime, buildResult);
|
|
54
|
+
break;
|
|
55
|
+
case AggregateFunction.Maximum:
|
|
56
|
+
getMaxData(variable, processingInterval, startTime, endTime, buildResult);
|
|
57
|
+
break;
|
|
58
|
+
case AggregateFunction.Interpolative:
|
|
59
|
+
getInterpolatedData(variable, processingInterval, startTime, endTime, buildResult);
|
|
60
|
+
break;
|
|
61
|
+
case AggregateFunction.Average:
|
|
62
|
+
getAverageData(variable, processingInterval, startTime, endTime, buildResult);
|
|
63
|
+
break;
|
|
64
|
+
case AggregateFunction.Count:
|
|
65
|
+
default:
|
|
66
|
+
// todo provide correct implementation
|
|
67
|
+
return callback2(null, new HistoryReadResult({ statusCode: StatusCodes.BadAggregateNotSupported }));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export function readProcessedDetails(
|
|
71
|
+
variable: UAVariable,
|
|
72
|
+
context: ISessionContext,
|
|
73
|
+
historyReadDetails: ReadProcessedDetails,
|
|
74
|
+
indexRange: NumericRange | null,
|
|
75
|
+
dataEncoding: QualifiedNameLike | null,
|
|
76
|
+
continuationData: ContinuationData,
|
|
77
|
+
callback: CallbackT<HistoryReadResult>
|
|
78
|
+
): void {
|
|
79
|
+
// OPC Unified Architecture, Part 11 27 Release 1.03
|
|
80
|
+
//
|
|
81
|
+
// This structure is used to compute Aggregate values, qualities, and timestamps from data in
|
|
82
|
+
// the history database for the specified time domain for one or more HistoricalDataNodes. The
|
|
83
|
+
// time domain is divided into intervals of duration ProcessingInterval. The specified Aggregate
|
|
84
|
+
// Type is calculated for each interval beginning with startTime by using the data within the next
|
|
85
|
+
// ProcessingInterval.
|
|
86
|
+
// For example, this function can provide hourly statistics such as Maximum, Minimum , and
|
|
87
|
+
// Average for each item during the specified time domain when ProcessingInterval is 1 hour.
|
|
88
|
+
// The domain of the request is defined by startTime, endTime, and ProcessingInterval. All three
|
|
89
|
+
// shall be specified. If endTime is less than startTime then the data shall be returned in reverse
|
|
90
|
+
// order with the later data coming first. If startTime and endTime are the same then the Server
|
|
91
|
+
// shall return Bad_InvalidArgument as there is no meaningful way to interpret such a case. If
|
|
92
|
+
// the ProcessingInterval is specified as 0 then Aggregates shall be calculated using one interval
|
|
93
|
+
// starting at startTime and ending at endTime.
|
|
94
|
+
// The aggregateType[] parameter allows a Client to request multiple Aggregate calculations per
|
|
95
|
+
// requested NodeId. If multiple Aggregates are requested then a corresponding number of
|
|
96
|
+
// entries are required in the NodesToRead array.
|
|
97
|
+
// For example, to request Min Aggregate for NodeId FIC101, FIC102, and both Min and Max
|
|
98
|
+
// Aggregates for NodeId FIC103 would require NodeId FIC103 to appear twice in the
|
|
99
|
+
// NodesToRead array request parameter.
|
|
100
|
+
// aggregateType[] NodesToRead[]
|
|
101
|
+
// Min FIC101
|
|
102
|
+
// Min FIC102
|
|
103
|
+
// Min FIC103
|
|
104
|
+
// Max FIC103
|
|
105
|
+
// If the array of Aggregates does not match the array of NodesToRead then the Server shall
|
|
106
|
+
// return a StatusCode of Bad_AggregateListMismatch.
|
|
107
|
+
// The aggregateConfiguration parameter allows a Client to override the Aggregate configuration
|
|
108
|
+
// settings supplied by the AggregateConfiguration Object on a per call basis. See Part 13 for
|
|
109
|
+
// more information on Aggregate configurations. If the Server does not support the ability to
|
|
110
|
+
// override the Aggregate configuration settings then it shall return a StatusCode of Bad_
|
|
111
|
+
// AggregateConfigurationRejected. If the Aggregate is not valid for the Node then the
|
|
112
|
+
// StatusCode shall be Bad_AggregateNotSupported.
|
|
113
|
+
// The values used in computing the Aggregate for each interval shall include any value that
|
|
114
|
+
// falls exactly on the timestamp at the beginning of the interval, but shall not include any value
|
|
115
|
+
// that falls directly on the timestamp ending the interval. Thus, each value shall be included
|
|
116
|
+
// only once in the calculation. If the time domain is in reverse order then we consider the later
|
|
117
|
+
// timestamp to be the one beginning the sub interval, and the earlier timestamp to be the one
|
|
118
|
+
// ending it. Note that this means that simply swapping the start and end times will not result in
|
|
119
|
+
// getting the same values back in reverse order as the intervals being requested in the two
|
|
120
|
+
// cases are not the same.
|
|
121
|
+
// If an Aggregate is taking a long time to calculate then the Server can return partial results
|
|
122
|
+
// with a continuation point. This might be done if the calculation is going to take more time th an
|
|
123
|
+
// the Client timeout hint. In some cases it may take longer than the Client timeout hint to
|
|
124
|
+
// calculate even one Aggregate result. Then the Server may return zero results with a
|
|
125
|
+
// continuation point that allows the Server to resume the calculation on the next Client read
|
|
126
|
+
// call.
|
|
127
|
+
const startTime = historyReadDetails.startTime;
|
|
128
|
+
const endTime = historyReadDetails.endTime;
|
|
129
|
+
if (!startTime || !endTime) {
|
|
130
|
+
return callback(null, new HistoryReadResult({ statusCode: StatusCodes.BadInvalidArgument }));
|
|
131
|
+
}
|
|
132
|
+
if (startTime.getTime() === endTime.getTime()) {
|
|
133
|
+
// Start = End Int = Anything No intervals. Returns a Bad_InvalidArgument StatusCode,
|
|
134
|
+
// regardless of whether there is data at the specified time or not
|
|
135
|
+
return callback(null, new HistoryReadResult({ statusCode: StatusCodes.BadInvalidArgument }));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const aggregateTypes: NodeId[] = historyReadDetails.aggregateType || [];
|
|
139
|
+
|
|
140
|
+
// If the ProcessingInterval is specified as 0 then Aggregates shall be calculated using one interval
|
|
141
|
+
// starting at startTime and ending at endTime.
|
|
142
|
+
const processingInterval = historyReadDetails.processingInterval || endTime.getTime() - startTime.getTime();
|
|
143
|
+
|
|
144
|
+
// tslint:disable-next-line: prefer-for-of
|
|
145
|
+
if (historyReadDetails.aggregateType?.length !== 1) {
|
|
146
|
+
return callback(null, new HistoryReadResult({ statusCode: StatusCodes.BadInternalError }));
|
|
147
|
+
}
|
|
148
|
+
return applyAggregate(variable, processingInterval, startTime, endTime, aggregateTypes[0], callback);
|
|
149
|
+
}
|
package/dist2/aggregates.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AddressSpace, BaseNode, UAObject, UAServerCapabilities, UAVariable } from "node-opcua-address-space";
|
|
2
|
-
import { AggregateConfigurationOptionsEx } from "./interval";
|
|
3
|
-
export declare function createHistoryServerCapabilities(addressSpace: AddressSpace, serverCapabilities: UAServerCapabilities): UAObject;
|
|
4
|
-
export declare type AggregateFunctionName = "AnnotationCount" | "Average" | "Count" | "Delta" | "DeltaBounds" | "DurationBad" | "DurationGood" | "DurationInStateNonZero" | "DurationInStateZero" | "EndBound" | "Interpolative" | "Maximum" | "Maximum2" | "MaximumActualTime" | "MaximumActualTime2" | "Minimum" | "Minimum2" | "MinimumActualTime" | "MinimumActualTime2" | "NumberOfTransitions" | "PercentBad" | "PercentGood" | "Range" | "Range2" | "StandardDeviationPopulation" | "StandardDeviationSample" | "Start" | "StartBound" | "TimeAverage" | "TimeAverage2" | "Total" | "Total2" | "VariancePopulation" | "VarianceSample" | "WorstQuality" | "WorstQuality2";
|
|
5
|
-
export declare function addAggregateSupport(addressSpace: AddressSpace): void;
|
|
6
|
-
export declare function installAggregateConfigurationOptions(node: UAVariable, options: AggregateConfigurationOptionsEx): void;
|
|
7
|
-
export declare function getAggregateConfiguration(node: BaseNode): AggregateConfigurationOptionsEx;
|
package/dist2/aggregates.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAggregateConfiguration = exports.installAggregateConfigurationOptions = exports.addAggregateSupport = exports.createHistoryServerCapabilities = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @module node-opcua-aggregates
|
|
6
|
-
*/
|
|
7
|
-
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
8
|
-
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
9
|
-
const utils = require("node-opcua-utils");
|
|
10
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
11
|
-
const read_processed_details_1 = require("./read_processed_details");
|
|
12
|
-
// import { HistoryServerCapabilities } from "node-opcua-server";
|
|
13
|
-
/*
|
|
14
|
-
HasProperty Variable AccessHistoryDataCapability Boolean PropertyType Mandatory
|
|
15
|
-
HasProperty Variable AccessHistoryEventsCapability Boolean PropertyType Mandatory
|
|
16
|
-
HasProperty Variable MaxReturnDataValues UInt32 PropertyType Mandatory
|
|
17
|
-
HasProperty Variable MaxReturnEventValues UInt32 PropertyType Mandatory
|
|
18
|
-
HasProperty Variable InsertDataCapability Boolean PropertyType Mandatory
|
|
19
|
-
HasProperty Variable ReplaceDataCapability Boolean PropertyType Mandatory
|
|
20
|
-
HasProperty Variable UpdateDataCapability Boolean PropertyType Mandatory
|
|
21
|
-
HasProperty Variable DeleteRawCapability Boolean PropertyType Mandatory
|
|
22
|
-
HasProperty Variable DeleteAtTimeCapability Boolean PropertyType Mandatory
|
|
23
|
-
HasProperty Variable InsertEventCapability Boolean PropertyType Mandatory
|
|
24
|
-
HasProperty Variable ReplaceEventCapability Boolean PropertyType Mandatory
|
|
25
|
-
HasProperty Variable UpdateEventCapability Boolean PropertyType Mandatory
|
|
26
|
-
HasProperty Variable DeleteEventCapability Boolean PropertyType Mandatory
|
|
27
|
-
HasProperty Variable InsertAnnotationsCapability Boolean PropertyType Mandatory
|
|
28
|
-
*/
|
|
29
|
-
const historicalCapabilitiesDefaultProperties /*: HistoryServerCapabilities */ = {
|
|
30
|
-
accessHistoryDataCapability: true,
|
|
31
|
-
accessHistoryEventsCapability: true,
|
|
32
|
-
deleteAtTimeCapability: false,
|
|
33
|
-
deleteEventCapability: false,
|
|
34
|
-
deleteRawCapability: false,
|
|
35
|
-
insertAnnotationCapability: false,
|
|
36
|
-
insertDataCapability: false,
|
|
37
|
-
insertEventCapability: false,
|
|
38
|
-
maxReturnDataValues: 0,
|
|
39
|
-
maxReturnEventValues: 0,
|
|
40
|
-
replaceDataCapability: false,
|
|
41
|
-
replaceEventCapability: false,
|
|
42
|
-
updateDataCapability: false,
|
|
43
|
-
updateEventCapability: false // Boolean PropertyType Mandatory
|
|
44
|
-
};
|
|
45
|
-
function createHistoryServerCapabilities(addressSpace, serverCapabilities) {
|
|
46
|
-
/* istanbul ignore next */
|
|
47
|
-
if (serverCapabilities.browseName.toString() !== "ServerCapabilities") {
|
|
48
|
-
throw new Error("Expecting server Capabilities");
|
|
49
|
-
}
|
|
50
|
-
const historyServerCapabilitiesType = addressSpace.getNamespace(0).findObjectType("HistoryServerCapabilitiesType");
|
|
51
|
-
/* istanbul ignore next */
|
|
52
|
-
if (!historyServerCapabilitiesType) {
|
|
53
|
-
throw new Error("Cannot find HistoryServerCapabilitiesType");
|
|
54
|
-
}
|
|
55
|
-
return historyServerCapabilitiesType.instantiate({
|
|
56
|
-
browseName: "HistoryServerCapabilities",
|
|
57
|
-
componentOf: serverCapabilities
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
exports.createHistoryServerCapabilities = createHistoryServerCapabilities;
|
|
61
|
-
function setHistoricalServerCapabilities(historyServerCapabilities, defaultProperties) {
|
|
62
|
-
function setBoolean(propName) {
|
|
63
|
-
const lowerCase = utils.lowerFirstLetter(propName);
|
|
64
|
-
/* istanbul ignore next */
|
|
65
|
-
if (!defaultProperties.hasOwnProperty(lowerCase)) {
|
|
66
|
-
throw new Error("cannot find " + lowerCase);
|
|
67
|
-
}
|
|
68
|
-
const value = defaultProperties[lowerCase];
|
|
69
|
-
const prop = historyServerCapabilities.getChildByName(propName);
|
|
70
|
-
/* istanbul ignore next */
|
|
71
|
-
if (!prop) {
|
|
72
|
-
throw new Error(" Cannot find property " + propName);
|
|
73
|
-
}
|
|
74
|
-
prop.setValueFromSource({ dataType: node_opcua_variant_1.DataType.Boolean, value });
|
|
75
|
-
}
|
|
76
|
-
function setUInt32(propName) {
|
|
77
|
-
const lowerCase = utils.lowerFirstLetter(propName);
|
|
78
|
-
/* istanbul ignore next */
|
|
79
|
-
if (!historyServerCapabilities.hasOwnProperty(lowerCase)) {
|
|
80
|
-
throw new Error("cannot find " + lowerCase);
|
|
81
|
-
}
|
|
82
|
-
const value = defaultProperties[lowerCase];
|
|
83
|
-
const prop = historyServerCapabilities.getChildByName(propName);
|
|
84
|
-
prop.setValueFromSource({ dataType: node_opcua_variant_1.DataType.UInt32, value });
|
|
85
|
-
}
|
|
86
|
-
setBoolean("AccessHistoryDataCapability");
|
|
87
|
-
setBoolean("AccessHistoryEventsCapability");
|
|
88
|
-
setUInt32("MaxReturnDataValues");
|
|
89
|
-
setUInt32("MaxReturnEventValues");
|
|
90
|
-
setBoolean("InsertDataCapability");
|
|
91
|
-
setBoolean("ReplaceDataCapability");
|
|
92
|
-
setBoolean("UpdateDataCapability");
|
|
93
|
-
setBoolean("DeleteRawCapability");
|
|
94
|
-
setBoolean("DeleteAtTimeCapability");
|
|
95
|
-
setBoolean("InsertEventCapability");
|
|
96
|
-
setBoolean("ReplaceEventCapability");
|
|
97
|
-
setBoolean("UpdateEventCapability");
|
|
98
|
-
setBoolean("DeleteEventCapability");
|
|
99
|
-
/// FOUND A BUG HERE spec says InsertAnnotationsCapability
|
|
100
|
-
/// Standard nodeset2 says InsertAnnotationCapability ( without s )
|
|
101
|
-
// xx setBoolean("InsertAnnotationsCapability");
|
|
102
|
-
}
|
|
103
|
-
function addAggregateFunctionSupport(addressSpace, functionName) {
|
|
104
|
-
/* istanbul ignore next */
|
|
105
|
-
if (!functionName) {
|
|
106
|
-
throw new Error("Invalid function name");
|
|
107
|
-
}
|
|
108
|
-
const serverCapabilities = addressSpace.rootFolder.objects.server.serverCapabilities;
|
|
109
|
-
/* istanbul ignore next */
|
|
110
|
-
if (!serverCapabilities.historyServerCapabilities) {
|
|
111
|
-
throw new Error("missing serverCapabilities.historyServerCapabilities");
|
|
112
|
-
}
|
|
113
|
-
const aggregateFunctions = serverCapabilities.aggregateFunctions;
|
|
114
|
-
const aggregateFunctionsInHist = serverCapabilities.historyServerCapabilities.aggregateFunctions;
|
|
115
|
-
const functionNodeId = node_opcua_nodeid_1.makeNodeId(functionName);
|
|
116
|
-
const functionNode = addressSpace.getNamespace(0).findNode(functionNodeId);
|
|
117
|
-
/* istanbul ignore next */
|
|
118
|
-
if (!functionNode) {
|
|
119
|
-
throw new Error("Cannot find node " + functionName + " in addressSpace");
|
|
120
|
-
}
|
|
121
|
-
aggregateFunctions.addReference({
|
|
122
|
-
nodeId: functionNode.nodeId,
|
|
123
|
-
referenceType: "Organizes"
|
|
124
|
-
});
|
|
125
|
-
aggregateFunctionsInHist.addReference({
|
|
126
|
-
nodeId: functionNode.nodeId,
|
|
127
|
-
referenceType: "Organizes"
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
function addAggregateSupport(addressSpace) {
|
|
131
|
-
const aggregateConfigurationType = addressSpace.getNamespace(0).findObjectType("AggregateConfigurationType");
|
|
132
|
-
/* istanbul ignore next */
|
|
133
|
-
if (!aggregateConfigurationType) {
|
|
134
|
-
throw new Error("addressSpace do not expose AggregateConfigurationType");
|
|
135
|
-
}
|
|
136
|
-
const aggregateFunctionType = addressSpace.getNamespace(0).findObjectType("AggregateFunctionType");
|
|
137
|
-
/* istanbul ignore next */
|
|
138
|
-
if (!aggregateFunctionType) {
|
|
139
|
-
throw new Error("addressSpace do not expose AggregateFunctionType");
|
|
140
|
-
}
|
|
141
|
-
const serverObject = addressSpace.rootFolder.objects.getFolderElementByName("Server");
|
|
142
|
-
/* istanbul ignore next */
|
|
143
|
-
if (!serverObject) {
|
|
144
|
-
throw new Error("addressSpace do not expose a ServerObject");
|
|
145
|
-
}
|
|
146
|
-
// xx serverObject.
|
|
147
|
-
const serverCapabilities = serverObject.getChildByName("ServerCapabilities");
|
|
148
|
-
// Let see if HistoryServer Capabilities object exists
|
|
149
|
-
let historyServerCapabilities = serverCapabilities.getChildByName("HistoryServerCapabilities");
|
|
150
|
-
/* istanbul ignore next */
|
|
151
|
-
if (!historyServerCapabilities) {
|
|
152
|
-
historyServerCapabilities = createHistoryServerCapabilities(addressSpace, serverCapabilities);
|
|
153
|
-
}
|
|
154
|
-
setHistoricalServerCapabilities(historyServerCapabilities, historicalCapabilitiesDefaultProperties);
|
|
155
|
-
addAggregateFunctionSupport(addressSpace, node_opcua_constants_1.AggregateFunction.Interpolative);
|
|
156
|
-
addAggregateFunctionSupport(addressSpace, node_opcua_constants_1.AggregateFunction.Minimum);
|
|
157
|
-
addAggregateFunctionSupport(addressSpace, node_opcua_constants_1.AggregateFunction.Maximum);
|
|
158
|
-
addAggregateFunctionSupport(addressSpace, node_opcua_constants_1.AggregateFunction.Average);
|
|
159
|
-
const addressSpaceInternal = addressSpace;
|
|
160
|
-
addressSpaceInternal._readProcessedDetails = read_processed_details_1.readProcessedDetails;
|
|
161
|
-
}
|
|
162
|
-
exports.addAggregateSupport = addAggregateSupport;
|
|
163
|
-
function installAggregateConfigurationOptions(node, options) {
|
|
164
|
-
const nodePriv = node;
|
|
165
|
-
const aggregateConfiguration = nodePriv.$historicalDataConfiguration.aggregateConfiguration;
|
|
166
|
-
aggregateConfiguration.percentDataBad.setValueFromSource({ dataType: "Byte", value: options.percentDataBad });
|
|
167
|
-
aggregateConfiguration.percentDataGood.setValueFromSource({ dataType: "Byte", value: options.percentDataGood });
|
|
168
|
-
aggregateConfiguration.treatUncertainAsBad.setValueFromSource({
|
|
169
|
-
dataType: "Boolean",
|
|
170
|
-
value: options.treatUncertainAsBad
|
|
171
|
-
});
|
|
172
|
-
aggregateConfiguration.useSlopedExtrapolation.setValueFromSource({
|
|
173
|
-
dataType: "Boolean",
|
|
174
|
-
value: options.useSlopedExtrapolation
|
|
175
|
-
});
|
|
176
|
-
nodePriv.$historicalDataConfiguration.stepped.setValueFromSource({
|
|
177
|
-
dataType: "Boolean",
|
|
178
|
-
value: options.stepped
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
exports.installAggregateConfigurationOptions = installAggregateConfigurationOptions;
|
|
182
|
-
function getAggregateConfiguration(node) {
|
|
183
|
-
const nodePriv = node;
|
|
184
|
-
/* istanbul ignore next */
|
|
185
|
-
if (!nodePriv.$historicalDataConfiguration) {
|
|
186
|
-
throw new Error("internal error");
|
|
187
|
-
}
|
|
188
|
-
const aggregateConfiguration = nodePriv.$historicalDataConfiguration.aggregateConfiguration;
|
|
189
|
-
// Beware ! Stepped value comes from Historical Configuration !
|
|
190
|
-
const stepped = nodePriv.$historicalDataConfiguration.stepped.readValue().value.value;
|
|
191
|
-
return {
|
|
192
|
-
percentDataBad: aggregateConfiguration.percentDataBad.readValue().value.value,
|
|
193
|
-
percentDataGood: aggregateConfiguration.percentDataGood.readValue().value.value,
|
|
194
|
-
stepped,
|
|
195
|
-
treatUncertainAsBad: aggregateConfiguration.treatUncertainAsBad.readValue().value.value,
|
|
196
|
-
// xx stepped: aggregateConfiguration.stepped.readValue().value,
|
|
197
|
-
useSlopedExtrapolation: aggregateConfiguration.useSlopedExtrapolation.readValue().value.value
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
exports.getAggregateConfiguration = getAggregateConfiguration;
|
|
201
|
-
//# sourceMappingURL=aggregates.js.map
|
package/dist2/aggregates.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aggregates.js","sourceRoot":"","sources":["../source/aggregates.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,+DAAyD;AACzD,yDAA+C;AAC/C,0CAA0C;AAC1C,2DAA8C;AAK9C,qEAAgE;AAEhE,iEAAiE;AAEjE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,uCAAuC,CAAC,gCAAgC,GAAG;IAC7E,2BAA2B,EAAE,IAAI;IACjC,6BAA6B,EAAE,IAAI;IACnC,sBAAsB,EAAE,KAAK;IAC7B,qBAAqB,EAAE,KAAK;IAC5B,mBAAmB,EAAE,KAAK;IAC1B,0BAA0B,EAAE,KAAK;IACjC,oBAAoB,EAAE,KAAK;IAC3B,qBAAqB,EAAE,KAAK;IAC5B,mBAAmB,EAAE,CAAC;IACtB,oBAAoB,EAAE,CAAC;IACvB,qBAAqB,EAAE,KAAK;IAC5B,sBAAsB,EAAE,KAAK;IAC7B,oBAAoB,EAAE,KAAK;IAC3B,qBAAqB,EAAE,KAAK,CAAC,iCAAiC;CACjE,CAAC;AAEF,SAAgB,+BAA+B,CAAC,YAA0B,EAAE,kBAAwC;IAChH,0BAA0B;IAC1B,IAAI,kBAAkB,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,oBAAoB,EAAE;QACnE,MAAM,IAA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import { UAVariable } from "node-opcua-address-space";
|
|
2
|
-
import { DataValue } from "node-opcua-data-value";
|
|
3
|
-
export declare function getAverageData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
package/dist2/average.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAverageData = 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 interval_1 = require("./interval");
|
|
8
|
-
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
9
|
-
function calculateIntervalAverageValue(interval, options) {
|
|
10
|
-
const indexStart = interval.index;
|
|
11
|
-
let statusCode;
|
|
12
|
-
let isPartial = interval.isPartial;
|
|
13
|
-
let isRaw = false;
|
|
14
|
-
let hasBad = false;
|
|
15
|
-
const values = [];
|
|
16
|
-
for (let i = indexStart; i < indexStart + interval.count; i++) {
|
|
17
|
-
const dataValue = interval.dataValues[i];
|
|
18
|
-
if (dataValue.statusCode === node_opcua_status_code_1.StatusCodes.BadNoData) {
|
|
19
|
-
isPartial = true;
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
if (!interval_1.isGood(dataValue.statusCode)) {
|
|
23
|
-
hasBad = true;
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
values.push(dataValue.value.value);
|
|
27
|
-
}
|
|
28
|
-
if (isRaw) {
|
|
29
|
-
if (hasBad) {
|
|
30
|
-
statusCode = node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
else if (hasBad) {
|
|
37
|
-
statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal, "HistorianCalculated");
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.Good, "HistorianCalculated");
|
|
41
|
-
}
|
|
42
|
-
if (values.length === 0) {
|
|
43
|
-
return new node_opcua_data_value_1.DataValue({
|
|
44
|
-
sourceTimestamp: interval.startTime,
|
|
45
|
-
statusCode: node_opcua_status_code_1.StatusCodes.BadNoData,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
const mean = values.reduce((p, c) => p + c, 0) / values.length;
|
|
49
|
-
return new node_opcua_data_value_1.DataValue({
|
|
50
|
-
sourceTimestamp: interval.startTime,
|
|
51
|
-
statusCode: statusCode,
|
|
52
|
-
value: {
|
|
53
|
-
dataType: node_opcua_variant_1.DataType.Double, value: mean
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
function getAverageData(node, processingInterval, startDate, endDate, callback) {
|
|
58
|
-
return common_1.getAggregateData(node, processingInterval, startDate, endDate, calculateIntervalAverageValue, callback);
|
|
59
|
-
}
|
|
60
|
-
exports.getAverageData = getAverageData;
|
|
61
|
-
//# sourceMappingURL=average.js.map
|
package/dist2/average.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"average.js","sourceRoot":"","sources":["../source/average.ts"],"names":[],"mappings":";;;AACA,iEAAkD;AAClD,2DAAuD;AACvD,qCAA4C;AAC5C,yCAA6E;AAC7E,mEAAiE;AAEjE,SAAS,6BAA6B,CAClC,QAAkB,EAClB,OAAsC;IAGtC,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC;IAClC,IAAI,UAAsB,CAAC;IAC3B,IAAI,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;IAEnC,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IA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AC,MAAM,CAAC;IAE/D,OAAO,IAAI,iCAAS,CAAC;QACjB,eAAe,EAAE,QAAQ,CAAC,SAAS;QACnC,UAAU,EAAE,UAAwB;QACpC,KAAK,EAAE;YACH,QAAQ,EAAE,6BAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI;SACzC;KACJ,CAAC,CAAC;AACP,CAAC;AAED,SAAgB,cAAc,CAC1B,IAAgB,EAChB,kBAA0B,EAC1B,SAAe,EACf,OAAa,EACb,QAA+D;IAE/D,OAAO,yBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,EAAE,6BAA6B,EAAE,QAAQ,CAAC,CAAC;AACnH,CAAC;AARD,wCAQC"}
|
package/dist2/common.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module node-opca-aggregates
|
|
3
|
-
*/
|
|
4
|
-
import { UAVariable } from "node-opcua-address-space";
|
|
5
|
-
import { DataValue } from "node-opcua-data-value";
|
|
6
|
-
import { Interval, AggregateConfigurationOptionsEx } from "./interval";
|
|
7
|
-
export declare function getAggregateData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, lambda: (interval: Interval, aggregateConfiguration: AggregateConfigurationOptionsEx) => DataValue, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
|
8
|
-
export declare function interpolateValue(dataValue1: DataValue, dataValue2: DataValue, date: Date): DataValue;
|