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
package/dist2/common.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.interpolateValue = exports.getAggregateData = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @module node-opca-aggregates
|
|
6
|
-
*/
|
|
7
|
-
const node_opcua_address_space_1 = require("node-opcua-address-space");
|
|
8
|
-
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
9
|
-
const node_opcua_service_history_1 = require("node-opcua-service-history");
|
|
10
|
-
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
11
|
-
const aggregates_1 = require("./aggregates");
|
|
12
|
-
const interval_1 = require("./interval");
|
|
13
|
-
/**
|
|
14
|
-
* @internal
|
|
15
|
-
* @param node
|
|
16
|
-
* @param processingInterval
|
|
17
|
-
* @param startDate
|
|
18
|
-
* @param endDate
|
|
19
|
-
* @param dataValues
|
|
20
|
-
* @param lambda
|
|
21
|
-
* @param callback
|
|
22
|
-
*/
|
|
23
|
-
function processAggregateData(node, processingInterval, startDate, endDate, dataValues, lambda, callback) {
|
|
24
|
-
const aggregateConfiguration = aggregates_1.getAggregateConfiguration(node);
|
|
25
|
-
const results = [];
|
|
26
|
-
const tstart = startDate.getTime();
|
|
27
|
-
const tend = endDate.getTime();
|
|
28
|
-
const indexHint = 0;
|
|
29
|
-
for (let t = tstart; t < tend; t += processingInterval) {
|
|
30
|
-
const sourceTimestamp = new Date();
|
|
31
|
-
sourceTimestamp.setTime(t);
|
|
32
|
-
const interval = interval_1.getInterval(sourceTimestamp, processingInterval, indexHint, dataValues);
|
|
33
|
-
const dataValue = lambda(interval, aggregateConfiguration);
|
|
34
|
-
/* istanbul ignore next */
|
|
35
|
-
if (!dataValue || !dataValue.sourceTimestamp) {
|
|
36
|
-
// const dataValue = interval.interpolatedValue(aggregateConfiguration);
|
|
37
|
-
throw Error("invalid DataValue");
|
|
38
|
-
}
|
|
39
|
-
results.push(dataValue);
|
|
40
|
-
}
|
|
41
|
-
setImmediate(() => {
|
|
42
|
-
callback(null, results);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function getAggregateData(node, processingInterval, startDate, endDate, lambda, callback) {
|
|
46
|
-
/* istanbul ignore next */
|
|
47
|
-
if (!(node.constructor.name === "UAVariable")) {
|
|
48
|
-
throw new Error("node must be UAVariable");
|
|
49
|
-
}
|
|
50
|
-
/* istanbul ignore next */
|
|
51
|
-
if (processingInterval <= 0) {
|
|
52
|
-
throw new Error("Invalid processing interval, shall be greater than 0");
|
|
53
|
-
}
|
|
54
|
-
const context = new node_opcua_address_space_1.SessionContext();
|
|
55
|
-
const historyReadDetails = new node_opcua_service_history_1.ReadRawModifiedDetails({
|
|
56
|
-
endTime: endDate,
|
|
57
|
-
startTime: startDate,
|
|
58
|
-
});
|
|
59
|
-
const indexRange = null;
|
|
60
|
-
const dataEncoding = null;
|
|
61
|
-
const continuationPoint = null;
|
|
62
|
-
node.historyRead(context, historyReadDetails, indexRange, dataEncoding, continuationPoint, (err, result) => {
|
|
63
|
-
/* istanbul ignore next */
|
|
64
|
-
if (err) {
|
|
65
|
-
return callback(err);
|
|
66
|
-
}
|
|
67
|
-
const historyData = result.historyData;
|
|
68
|
-
const dataValues = historyData.dataValues || [];
|
|
69
|
-
processAggregateData(node, processingInterval, startDate, endDate, dataValues, lambda, callback);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
exports.getAggregateData = getAggregateData;
|
|
73
|
-
function interpolateValue(dataValue1, dataValue2, date) {
|
|
74
|
-
const t0 = dataValue1.sourceTimestamp.getTime();
|
|
75
|
-
const t = date.getTime();
|
|
76
|
-
const t1 = dataValue2.sourceTimestamp.getTime();
|
|
77
|
-
const coef1 = (t - t0) / (t1 - t0);
|
|
78
|
-
const coef2 = (t1 - t) / (t1 - t0);
|
|
79
|
-
const value = dataValue1.value.clone();
|
|
80
|
-
value.value = coef2 * dataValue1.value.value + coef1 * dataValue2.value.value;
|
|
81
|
-
const statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(dataValue1.statusCode, "HistorianInterpolated");
|
|
82
|
-
return new node_opcua_data_value_1.DataValue({
|
|
83
|
-
sourceTimestamp: date,
|
|
84
|
-
statusCode,
|
|
85
|
-
value
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
exports.interpolateValue = interpolateValue;
|
|
89
|
-
//# sourceMappingURL=common.js.map
|
package/dist2/common.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../source/common.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,uEAAsE;AACtE,iEAAkD;AAClD,2EAAoG;AACpG,mEAAoD;AAEpD,6CAAyD;AACzD,yCAAoF;AAEpF;;;;;;;;;GASG;AACH,SAAS,oBAAoB,CACzB,IAAgB,EAChB,kBAA0B,EAC1B,SAAe,EACf,OAAa,EACb,UAAuB,EACvB,MAAkG,EAClG,QAA+D;IAE/D,MAAM,sBAAsB,GAAG,sCAAyB,CAAC,IAAI,CAAC,CAAC;IAE/D,MAAM,OAAO,GAAgB,EAAE,CAAC;IAEhC,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAE/B,MAAM,SAAS,GAAG,CAAC,CAAC;IACpB,KAAK,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,kBAAkB,EAAE;QACpD,MAAM,eAAe,GAAG,IAAI,IAAI,EAAE,CAAC;QACnC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAE3B,MAAM,QAAQ,GAAG,sBAAW,CAAC,eAAe,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QAEzF,MAAM,SAAS,GAAG,MAAM,C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upport, installAggregateConfigurationOptions, getAggregateConfiguration, } from "./aggregates";
|
|
5
|
-
export * from "./interpolate";
|
|
6
|
-
export * from "./minmax";
|
|
7
|
-
export * from "./interval";
|
|
8
|
-
export * from "./common";
|
|
9
|
-
export * from "./average";
|
|
10
|
-
export * from "./read_processed_details";
|
|
11
|
-
export { AggregateFunction } from "node-opcua-constants";
|
package/dist2/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.AggregateFunction = exports.getAggregateConfiguration = exports.installAggregateConfigurationOptions = exports.addAggregateSupport = void 0;
|
|
14
|
-
/**
|
|
15
|
-
* @module node-opca-aggregates
|
|
16
|
-
*/
|
|
17
|
-
var aggregates_1 = require("./aggregates");
|
|
18
|
-
Object.defineProperty(exports, "addAggregateSupport", { enumerable: true, get: function () { return aggregates_1.addAggregateSupport; } });
|
|
19
|
-
Object.defineProperty(exports, "installAggregateConfigurationOptions", { enumerable: true, get: function () { return aggregates_1.installAggregateConfigurationOptions; } });
|
|
20
|
-
Object.defineProperty(exports, "getAggregateConfiguration", { enumerable: true, get: function () { return aggregates_1.getAggregateConfiguration; } });
|
|
21
|
-
__exportStar(require("./interpolate"), exports);
|
|
22
|
-
__exportStar(require("./minmax"), exports);
|
|
23
|
-
__exportStar(require("./interval"), exports);
|
|
24
|
-
__exportStar(require("./common"), exports);
|
|
25
|
-
__exportStar(require("./average"), exports);
|
|
26
|
-
__exportStar(require("./read_processed_details"), exports);
|
|
27
|
-
var node_opcua_constants_1 = require("node-opcua-constants");
|
|
28
|
-
Object.defineProperty(exports, "AggregateFunction", { enumerable: true, get: function () { return node_opcua_constants_1.AggregateFunction; } });
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
package/dist2/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;;GAEG;AACH,2CAIsB;AAHlB,iHAAA,mBAAmB,OAAA;AACnB,kIAAA,oCAAoC,OAAA;AACpC,uHAAA,yBAAyB,OAAA;AAE7B,gDAA8B;AAC9B,2CAAyB;AACzB,6CAA2B;AAC3B,2CAAyB;AACzB,4CAA0B;AAC1B,2DAAyC;AACzC,6DAE8B;AAD1B,yHAAA,iBAAiB,OAAA"}
|
package/dist2/interpolate.d.ts
DELETED
|
@@ -1,16 +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 { AggregateConfigurationOptionsEx, Interval } from "./interval";
|
|
7
|
-
export declare function interpolatedValue(interval: Interval, options: AggregateConfigurationOptionsEx): DataValue;
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param node
|
|
11
|
-
* @param processingInterval
|
|
12
|
-
* @param startDate
|
|
13
|
-
* @param endDate
|
|
14
|
-
* @param callback
|
|
15
|
-
*/
|
|
16
|
-
export declare function getInterpolatedData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
package/dist2/interpolate.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInterpolatedData = exports.interpolatedValue = void 0;
|
|
4
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
5
|
-
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
6
|
-
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
7
|
-
const common_1 = require("./common");
|
|
8
|
-
const interval_1 = require("./interval");
|
|
9
|
-
/*
|
|
10
|
-
For any intervals containing regions where the StatusCodes are Bad,
|
|
11
|
-
the total duration of all Bad regions is calculated and divided by the width of the interval.
|
|
12
|
-
The resulting ratio is multiplied by 100 and compared to the PercentDataBad parameter.
|
|
13
|
-
The StatusCode for the interval is Bad if the ratio is greater than or equal to the PercentDataBad parameter.
|
|
14
|
-
For any interval which is not Bad, the total duration of all Good regions is then calculated and divided by
|
|
15
|
-
the width of the interval. The resulting ratio is multiplied by 100 and compared to the PercentDataGood parameter.
|
|
16
|
-
The StatusCode for the interval is Good if the ratio is greater than or equal to the PercentDataGood parameter.
|
|
17
|
-
If for an interval neither ratio applies then that interval is Uncertain_DataSubNormal.
|
|
18
|
-
*/
|
|
19
|
-
function interpolatedValue(interval, options) {
|
|
20
|
-
options = interval_1.adjustProcessingOptions(options);
|
|
21
|
-
node_opcua_assert_1.assert(options.hasOwnProperty("useSlopedExtrapolation"));
|
|
22
|
-
node_opcua_assert_1.assert(options.hasOwnProperty("treatUncertainAsBad"));
|
|
23
|
-
const bTreatUncertainAsBad = options.treatUncertainAsBad;
|
|
24
|
-
const steppedValue = (previousDataValue) => {
|
|
25
|
-
if (!previousDataValue.statusCode) {
|
|
26
|
-
throw new Error("Expecting statusCode");
|
|
27
|
-
}
|
|
28
|
-
const interpValue = new node_opcua_data_value_1.DataValue({
|
|
29
|
-
sourceTimestamp: interval.startTime,
|
|
30
|
-
statusCode: node_opcua_status_code_1.StatusCodes.Bad,
|
|
31
|
-
value: previousDataValue.value,
|
|
32
|
-
});
|
|
33
|
-
interpValue.statusCode =
|
|
34
|
-
node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal, "HistorianInterpolated");
|
|
35
|
-
return interpValue;
|
|
36
|
-
};
|
|
37
|
-
if (interval.index === -1) {
|
|
38
|
-
// the interval is beyond end Data
|
|
39
|
-
// we need to find previous good value
|
|
40
|
-
// and second previous good value to extrapolate
|
|
41
|
-
const prev1 = interval_1._findGoodDataValueBefore(interval.dataValues, interval.dataValues.length, bTreatUncertainAsBad);
|
|
42
|
-
if (prev1.index <= 0) {
|
|
43
|
-
return new node_opcua_data_value_1.DataValue({
|
|
44
|
-
sourceTimestamp: interval.startTime,
|
|
45
|
-
statusCode: node_opcua_status_code_1.StatusCodes.BadNoData,
|
|
46
|
-
value: undefined,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
if (!options.useSlopedExtrapolation) {
|
|
50
|
-
return steppedValue(prev1.dataValue);
|
|
51
|
-
}
|
|
52
|
-
const prev2 = interval_1._findGoodDataValueBefore(interval.dataValues, prev1.index, bTreatUncertainAsBad);
|
|
53
|
-
if (prev2.index <= 0) {
|
|
54
|
-
// use step value
|
|
55
|
-
return steppedValue(prev1.dataValue);
|
|
56
|
-
}
|
|
57
|
-
// else interpolate
|
|
58
|
-
const interpVal = common_1.interpolateValue(prev2.dataValue, prev1.dataValue, interval.startTime);
|
|
59
|
-
// tslint:disable:no-bitwise
|
|
60
|
-
if (prev2.index + 1 < prev1.index || prev1.index < interval.dataValues.length - 1) {
|
|
61
|
-
// some bad data exist in between = change status code
|
|
62
|
-
const mask = 0x0000FFFFFF;
|
|
63
|
-
const extraBits = interpVal.statusCode.value & mask;
|
|
64
|
-
interpVal.statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal, extraBits);
|
|
65
|
-
}
|
|
66
|
-
return interpVal;
|
|
67
|
-
}
|
|
68
|
-
/* istanbul ignore next */
|
|
69
|
-
if (interval.index < 0 && interval.count === 0) {
|
|
70
|
-
return new node_opcua_data_value_1.DataValue({
|
|
71
|
-
sourceTimestamp: interval.startTime,
|
|
72
|
-
statusCode: node_opcua_status_code_1.StatusCodes.BadNoData
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const dataValue1 = interval.dataValues[interval.index];
|
|
76
|
-
// if a non-Bad Raw value exists at the timestamp then it is the bounding value;
|
|
77
|
-
if (!interval_1.isBad(dataValue1.statusCode) && interval.hasRawDataAsStart()) {
|
|
78
|
-
return dataValue1;
|
|
79
|
-
}
|
|
80
|
-
// find the first non-Bad Raw value before the timestamp;
|
|
81
|
-
// find previous good value
|
|
82
|
-
const before = interval.beforeStartDataValue(bTreatUncertainAsBad);
|
|
83
|
-
if (interval_1.isBad(before.dataValue.statusCode)) {
|
|
84
|
-
return new node_opcua_data_value_1.DataValue({
|
|
85
|
-
sourceTimestamp: interval.startTime,
|
|
86
|
-
statusCode: node_opcua_status_code_1.StatusCodes.BadNoData
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
if (options.stepped) {
|
|
90
|
-
if (before.index + 1 === interval.index) {
|
|
91
|
-
return new node_opcua_data_value_1.DataValue({
|
|
92
|
-
sourceTimestamp: interval.startTime,
|
|
93
|
-
statusCode: node_opcua_status_code_1.StatusCode.makeStatusCode(before.dataValue.statusCode, "HistorianInterpolated"),
|
|
94
|
-
value: before.dataValue.value
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
return steppedValue(before.dataValue);
|
|
98
|
-
}
|
|
99
|
-
// find the first non-Bad Raw value after the timestamp;
|
|
100
|
-
const next = interval.nextStartDataValue(bTreatUncertainAsBad);
|
|
101
|
-
// draw a line between before value and after value;
|
|
102
|
-
// use point where the line crosses the timestamp as an estimate of the bounding value.
|
|
103
|
-
// The calculation can be expressed with the following formula:
|
|
104
|
-
// V bound = (T bound – T before)x( V after – V before)/( T after – T before) + V before
|
|
105
|
-
// where V
|
|
106
|
-
// x is a value at ‘x’ and Tx is the timestamp associated with Vx.
|
|
107
|
-
const interpolatedDataValue = common_1.interpolateValue(before.dataValue, next.dataValue, interval.startTime);
|
|
108
|
-
if (before.index + 1 < next.index
|
|
109
|
-
|| !interval_1.isGood(next.dataValue.statusCode)
|
|
110
|
-
|| !interval_1.isGood(before.dataValue.statusCode)) {
|
|
111
|
-
// tslint:disable:no-bitwise
|
|
112
|
-
// some bad data exist in between = change status code
|
|
113
|
-
const mask = 0x0000FFFFFF;
|
|
114
|
-
const extraBits = interpolatedDataValue.statusCode.value & mask;
|
|
115
|
-
interpolatedDataValue.statusCode =
|
|
116
|
-
node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal, extraBits);
|
|
117
|
-
}
|
|
118
|
-
// check if uncertain or bad value exist between before/next
|
|
119
|
-
// todo
|
|
120
|
-
return interpolatedDataValue;
|
|
121
|
-
}
|
|
122
|
-
exports.interpolatedValue = interpolatedValue;
|
|
123
|
-
/**
|
|
124
|
-
*
|
|
125
|
-
* @param node
|
|
126
|
-
* @param processingInterval
|
|
127
|
-
* @param startDate
|
|
128
|
-
* @param endDate
|
|
129
|
-
* @param callback
|
|
130
|
-
*/
|
|
131
|
-
function getInterpolatedData(node, processingInterval, startDate, endDate, callback) {
|
|
132
|
-
return common_1.getAggregateData(node, processingInterval, startDate, endDate, interpolatedValue, callback);
|
|
133
|
-
}
|
|
134
|
-
exports.getInterpolatedData = getInterpolatedData;
|
|
135
|
-
//# sourceMappingURL=interpolate.js.map
|
package/dist2/interpolate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interpolate.js","sourceRoot":"","sources":["../source/interpolate.ts"],"names":[],"mappings":";;;AAwCA,yDAA2C;AAC3C,iEAAkD;AAClD,mEAAiE;AAEjE,qCAA8D;AAC9D,yCAMoB;AAEpB;;;;;;;;;IASI;AACJ,SAAgB,iBAAiB,CA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CAAC,EACzC;QACE,4BAA4B;QAC5B,sDAAsD;QACtD,MAAM,IAAI,GAAG,YAAY,CAAC;QAC1B,MAAM,SAAS,GAAG,qBAAqB,CAAC,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC;QAChE,qBAAqB,CAAC,UAAU;YAC5B,mCAAU,CAAC,cAAc,CAAC,oCAAW,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC;KAChF;IACD,4DAA4D;IAC5D,OAAO;IACP,OAAO,qBAAqB,CAAC;AACjC,CAAC;AAvHD,8CAuHC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAC/B,IAAgB,EAChB,kBAA0B,EAC1B,SAAe,EACf,OAAa,EACb,QAA+D;IAE/D,OAAO,yBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAC;AACvG,CAAC;AARD,kDAQC"}
|
package/dist2/interval.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module node-opca-aggregates
|
|
3
|
-
*/
|
|
4
|
-
import { DataValue } from "node-opcua-data-value";
|
|
5
|
-
import { StatusCode } from "node-opcua-status-code";
|
|
6
|
-
import { AggregateConfigurationOptions } from "node-opcua-types";
|
|
7
|
-
export { AggregateConfigurationOptions } from "node-opcua-types";
|
|
8
|
-
export interface AggregateConfigurationOptionsEx extends AggregateConfigurationOptions {
|
|
9
|
-
stepped?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare function isGoodish(statusCode: StatusCode): boolean;
|
|
12
|
-
export declare function isBad(statusCode: StatusCode): boolean;
|
|
13
|
-
export declare function isGood(statusCode: StatusCode): boolean;
|
|
14
|
-
export interface IntervalOptions {
|
|
15
|
-
startTime: Date;
|
|
16
|
-
dataValues: DataValue[];
|
|
17
|
-
index: number;
|
|
18
|
-
count: number;
|
|
19
|
-
isPartial: boolean;
|
|
20
|
-
}
|
|
21
|
-
interface DataValueWithIndex {
|
|
22
|
-
index: number;
|
|
23
|
-
dataValue: DataValue;
|
|
24
|
-
}
|
|
25
|
-
export declare function _findGoodDataValueBefore(dataValues: DataValue[], index: number, bTreatUncertainAsBad: boolean): DataValueWithIndex;
|
|
26
|
-
export declare function _findGoodDataValueAfter(dataValues: DataValue[], index: number, bTreatUncertainAsBad: boolean): DataValueWithIndex;
|
|
27
|
-
export declare function adjustProcessingOptions(options: AggregateConfigurationOptionsEx | null): AggregateConfigurationOptionsEx;
|
|
28
|
-
export declare class Interval {
|
|
29
|
-
startTime: Date;
|
|
30
|
-
dataValues: DataValue[];
|
|
31
|
-
index: number;
|
|
32
|
-
count: number;
|
|
33
|
-
isPartial: boolean;
|
|
34
|
-
constructor(options: IntervalOptions);
|
|
35
|
-
getPercentBad(): number;
|
|
36
|
-
/**
|
|
37
|
-
* returns true if a raw data exists at start
|
|
38
|
-
*/
|
|
39
|
-
hasRawDataAsStart(): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Find the first good or uncertain dataValue
|
|
42
|
-
* just preceding this interval
|
|
43
|
-
* @returns {*}
|
|
44
|
-
*/
|
|
45
|
-
beforeStartDataValue(bTreatUncertainAsBad: boolean): DataValueWithIndex;
|
|
46
|
-
nextStartDataValue(bTreatUncertainAsBad: boolean): DataValueWithIndex;
|
|
47
|
-
toString(): string;
|
|
48
|
-
}
|
|
49
|
-
export declare function getInterval(startTime: Date, duration: number, indexHint: number, dataValues: DataValue[]): Interval;
|
package/dist2/interval.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInterval = exports.Interval = exports.adjustProcessingOptions = exports._findGoodDataValueAfter = exports._findGoodDataValueBefore = exports.isGood = exports.isBad = exports.isGoodish = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @module node-opca-aggregates
|
|
6
|
-
*/
|
|
7
|
-
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
8
|
-
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
9
|
-
function isGoodish(statusCode) {
|
|
10
|
-
return statusCode.value < 0x40000000;
|
|
11
|
-
}
|
|
12
|
-
exports.isGoodish = isGoodish;
|
|
13
|
-
function isBad(statusCode) {
|
|
14
|
-
return statusCode.value >= 0x80000000;
|
|
15
|
-
}
|
|
16
|
-
exports.isBad = isBad;
|
|
17
|
-
function isGood(statusCode) {
|
|
18
|
-
return statusCode.value === 0x0;
|
|
19
|
-
}
|
|
20
|
-
exports.isGood = isGood;
|
|
21
|
-
function _findGoodDataValueBefore(dataValues, index, bTreatUncertainAsBad) {
|
|
22
|
-
index--;
|
|
23
|
-
while (index >= 0) {
|
|
24
|
-
const dataValue1 = dataValues[index];
|
|
25
|
-
if (!bTreatUncertainAsBad && !isBad(dataValue1.statusCode)) {
|
|
26
|
-
return { index, dataValue: dataValue1 };
|
|
27
|
-
}
|
|
28
|
-
if (bTreatUncertainAsBad && isGood(dataValue1.statusCode)) {
|
|
29
|
-
return { index, dataValue: dataValue1 };
|
|
30
|
-
}
|
|
31
|
-
index -= 1;
|
|
32
|
-
}
|
|
33
|
-
// not found
|
|
34
|
-
return {
|
|
35
|
-
dataValue: new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadNoData }),
|
|
36
|
-
index: -1
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
exports._findGoodDataValueBefore = _findGoodDataValueBefore;
|
|
40
|
-
function _findGoodDataValueAfter(dataValues, index, bTreatUncertainAsBad) {
|
|
41
|
-
while (index < dataValues.length) {
|
|
42
|
-
const dataValue1 = dataValues[index];
|
|
43
|
-
if (!bTreatUncertainAsBad && !isBad(dataValue1.statusCode)) {
|
|
44
|
-
return {
|
|
45
|
-
dataValue: dataValue1,
|
|
46
|
-
index
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (bTreatUncertainAsBad && isGood(dataValue1.statusCode)) {
|
|
50
|
-
return {
|
|
51
|
-
dataValue: dataValue1,
|
|
52
|
-
index
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
index += 1;
|
|
56
|
-
}
|
|
57
|
-
// not found
|
|
58
|
-
return {
|
|
59
|
-
dataValue: new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadNoData }),
|
|
60
|
-
index: -1
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
exports._findGoodDataValueAfter = _findGoodDataValueAfter;
|
|
64
|
-
function adjustProcessingOptions(options) {
|
|
65
|
-
options = options || {};
|
|
66
|
-
options.treatUncertainAsBad = options.treatUncertainAsBad || false;
|
|
67
|
-
options.useSlopedExtrapolation = options.useSlopedExtrapolation || false;
|
|
68
|
-
options.stepped = options.stepped || false;
|
|
69
|
-
options.percentDataBad = parseInt(options.percentDataBad, 10);
|
|
70
|
-
options.percentDataGood = parseInt(options.percentDataGood, 10);
|
|
71
|
-
return options;
|
|
72
|
-
}
|
|
73
|
-
exports.adjustProcessingOptions = adjustProcessingOptions;
|
|
74
|
-
class Interval {
|
|
75
|
-
// startTime
|
|
76
|
-
// dataValues
|
|
77
|
-
// index: index of first dataValue inside the interval
|
|
78
|
-
// count: number of dataValue inside the interval
|
|
79
|
-
constructor(options) {
|
|
80
|
-
this.startTime = options.startTime;
|
|
81
|
-
this.dataValues = options.dataValues;
|
|
82
|
-
this.index = options.index;
|
|
83
|
-
this.count = options.count;
|
|
84
|
-
this.isPartial = options.isPartial;
|
|
85
|
-
}
|
|
86
|
-
getPercentBad() {
|
|
87
|
-
return 100;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* returns true if a raw data exists at start
|
|
91
|
-
*/
|
|
92
|
-
hasRawDataAsStart() {
|
|
93
|
-
const index = this.index;
|
|
94
|
-
if (index < 0) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
const dataValue1 = this.dataValues[index];
|
|
98
|
-
return this.startTime.getTime() === dataValue1.sourceTimestamp.getTime();
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Find the first good or uncertain dataValue
|
|
102
|
-
* just preceding this interval
|
|
103
|
-
* @returns {*}
|
|
104
|
-
*/
|
|
105
|
-
beforeStartDataValue(bTreatUncertainAsBad) {
|
|
106
|
-
return _findGoodDataValueBefore(this.dataValues, this.index, bTreatUncertainAsBad);
|
|
107
|
-
}
|
|
108
|
-
nextStartDataValue(bTreatUncertainAsBad) {
|
|
109
|
-
return _findGoodDataValueAfter(this.dataValues, this.index, bTreatUncertainAsBad);
|
|
110
|
-
}
|
|
111
|
-
toString() {
|
|
112
|
-
let str = "";
|
|
113
|
-
str += "startTime " + this.startTime.toUTCString() + "\n";
|
|
114
|
-
str += "start " + this.index + " ";
|
|
115
|
-
str += "count " + this.count + " ";
|
|
116
|
-
str += "isPartial " + this.isPartial + "\n";
|
|
117
|
-
if (this.index >= 0) {
|
|
118
|
-
for (let i = this.index; i < this.index + this.count; i++) {
|
|
119
|
-
const dataValue = this.dataValues[i];
|
|
120
|
-
str += " " + dataValue.sourceTimestamp.toUTCString() + dataValue.statusCode.toString();
|
|
121
|
-
str += dataValue.value ? dataValue.value.toString() : "";
|
|
122
|
-
str += "\n";
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return str;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
exports.Interval = Interval;
|
|
129
|
-
function getInterval(startTime, duration, indexHint, dataValues) {
|
|
130
|
-
let count = 0;
|
|
131
|
-
let index = -1;
|
|
132
|
-
for (let i = indexHint; i < dataValues.length; i++) {
|
|
133
|
-
if (dataValues[i].sourceTimestamp.getTime() < startTime.getTime()) {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
index = i;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
if (index >= 0) {
|
|
140
|
-
for (let i = index; i < dataValues.length; i++) {
|
|
141
|
-
if (dataValues[i].sourceTimestamp.getTime() >= startTime.getTime() + duration) {
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
count++;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
// check if interval is complete or partial (end or start)
|
|
148
|
-
let isPartial = false;
|
|
149
|
-
if (index + count >= dataValues.length &&
|
|
150
|
-
dataValues[dataValues.length - 1].sourceTimestamp.getTime() < startTime.getTime() + duration) {
|
|
151
|
-
isPartial = true;
|
|
152
|
-
}
|
|
153
|
-
if (index <= 0 && dataValues[0].sourceTimestamp.getTime() > startTime.getTime()) {
|
|
154
|
-
isPartial = true;
|
|
155
|
-
}
|
|
156
|
-
return new Interval({
|
|
157
|
-
count,
|
|
158
|
-
dataValues,
|
|
159
|
-
index,
|
|
160
|
-
isPartial,
|
|
161
|
-
startTime
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
exports.getInterval = getInterval;
|
|
165
|
-
//# sourceMappingURL=interval.js.map
|
package/dist2/interval.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interval.js","sourceRoot":"","sources":["../source/interval.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,iEAAkD;AAClD,mEAAiE;AAOjE,SAAgB,SAAS,CAAC,UAAsB;IAC5C,OAAO,UAAU,CAAC,KAAK,GAAG,UAAU,CAAC;AACzC,CAAC;AAFD,8BAEC;AAED,SAAgB,KAAK,CAAC,UAAsB;IACxC,OAAO,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC;AAC1C,CAAC;AAFD,sBAEC;AAED,SAAgB,MAAM,CAAC,UAAsB;IACzC,OAAO,UAAU,CAAC,KAAK,KAAK,GAAG,CAAC;AACpC,CAAC;AAFD,wBAEC;AAeD,SAAgB,wBAAwB,CACpC,UAAuB,EACvB,KAAa,EACb,oBAA6B;IAE7B,KAAK,EAAE,CAAC;IACR,OAAO,KAAK,IAAI,CAAC,EAAE;QACf,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QACrC,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
-
/**
|
|
2
|
-
* @module node-opca-aggregates
|
|
3
|
-
*/
|
|
4
|
-
import { UAVariable } from "node-opcua-address-space";
|
|
5
|
-
import { DataValue } from "node-opcua-data-value";
|
|
6
|
-
import { AggregateConfigurationOptions, Interval } from "./interval";
|
|
7
|
-
export declare function calculateIntervalMinValue(interval: Interval, options: AggregateConfigurationOptions): DataValue;
|
|
8
|
-
export declare function calculateIntervalMaxValue(interval: Interval, options: AggregateConfigurationOptions): DataValue;
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param node
|
|
12
|
-
* @param processingInterval
|
|
13
|
-
* @param startDate
|
|
14
|
-
* @param endDate
|
|
15
|
-
* @param callback
|
|
16
|
-
*/
|
|
17
|
-
export declare function getMinData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
|
18
|
-
export declare function getMaxData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|