node-opcua-aggregates 2.183.0 → 2.184.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/aggregates.d.ts +1 -0
- package/dist/aggregates.d.ts.map +1 -0
- package/dist/aggregates.js +34 -43
- package/dist/aggregates.js.map +1 -1
- package/dist/average.d.ts +1 -0
- package/dist/average.d.ts.map +1 -0
- package/dist/average.js +15 -18
- package/dist/average.js.map +1 -1
- package/dist/calculate_bad_good.d.ts +1 -0
- package/dist/calculate_bad_good.d.ts.map +1 -0
- package/dist/calculate_bad_good.js +22 -25
- package/dist/calculate_bad_good.js.map +1 -1
- package/dist/common.d.ts +1 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +19 -23
- package/dist/common.js.map +1 -1
- package/dist/count.d.ts +1 -0
- package/dist/count.d.ts.map +1 -0
- package/dist/count.js +19 -22
- package/dist/count.js.map +1 -1
- package/dist/duration_bad.d.ts +1 -0
- package/dist/duration_bad.d.ts.map +1 -0
- package/dist/duration_bad.js +13 -16
- package/dist/duration_bad.js.map +1 -1
- package/dist/duration_good.d.ts +1 -0
- package/dist/duration_good.d.ts.map +1 -0
- package/dist/duration_good.js +13 -16
- package/dist/duration_good.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -41
- package/dist/index.js.map +1 -1
- package/dist/interpolate.d.ts +1 -0
- package/dist/interpolate.d.ts.map +1 -0
- package/dist/interpolate.js +28 -32
- package/dist/interpolate.js.map +1 -1
- package/dist/interval.d.ts +1 -0
- package/dist/interval.d.ts.map +1 -0
- package/dist/interval.js +13 -23
- package/dist/interval.js.map +1 -1
- package/dist/minmax.d.ts +1 -0
- package/dist/minmax.d.ts.map +1 -0
- package/dist/minmax.js +19 -25
- package/dist/minmax.js.map +1 -1
- package/dist/percent_bad.d.ts +1 -0
- package/dist/percent_bad.d.ts.map +1 -0
- package/dist/percent_bad.js +10 -13
- package/dist/percent_bad.js.map +1 -1
- package/dist/percent_good.d.ts +1 -0
- package/dist/percent_good.d.ts.map +1 -0
- package/dist/percent_good.js +14 -17
- package/dist/percent_good.js.map +1 -1
- package/dist/read_processed_details.d.ts +1 -0
- package/dist/read_processed_details.d.ts.map +1 -0
- package/dist/read_processed_details.js +39 -42
- package/dist/read_processed_details.js.map +1 -1
- package/distHelpers/create_historizing_variables.d.ts +1 -0
- package/distHelpers/create_historizing_variables.d.ts.map +1 -0
- package/distHelpers/create_historizing_variables.js +60 -66
- package/distHelpers/create_historizing_variables.js.map +1 -1
- package/distHelpers/helpers.d.ts +1 -0
- package/distHelpers/helpers.d.ts.map +1 -0
- package/distHelpers/helpers.js +9 -13
- package/distHelpers/helpers.js.map +1 -1
- package/distHelpers/index.d.ts +1 -0
- package/distHelpers/index.d.ts.map +1 -0
- package/distHelpers/index.js +2 -18
- package/distHelpers/index.js.map +1 -1
- package/package.json +18 -17
- package/testHelpers.js +1 -1
package/dist/count.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
7
|
-
const common_js_1 = require("./common.js");
|
|
8
|
-
const interval_js_1 = require("./interval.js");
|
|
1
|
+
import { DataValue } from "node-opcua-data-value";
|
|
2
|
+
import { extraStatusCodeBits, StatusCode, StatusCodes } from "node-opcua-status-code";
|
|
3
|
+
import { DataType } from "node-opcua-variant";
|
|
4
|
+
import { getAggregateData } from "./common.js";
|
|
5
|
+
import { isUncertain } from "./interval.js";
|
|
9
6
|
/**
|
|
10
7
|
* The Count Aggregate retrieves a count of all the raw values within an interval.
|
|
11
8
|
* If one or more raw values are non-Good, they are not included in the count, and the Aggregate
|
|
@@ -14,7 +11,7 @@ const interval_js_1 = require("./interval.js");
|
|
|
14
11
|
*/
|
|
15
12
|
function calculateCountValue(interval, options) {
|
|
16
13
|
const indexStart = interval.index;
|
|
17
|
-
let statusCode =
|
|
14
|
+
let statusCode = StatusCodes.Good;
|
|
18
15
|
let isPartial = interval.isPartial;
|
|
19
16
|
let nbBad = 0;
|
|
20
17
|
let nbGood = 0;
|
|
@@ -24,7 +21,7 @@ function calculateCountValue(interval, options) {
|
|
|
24
21
|
let _goodDuration = 0;
|
|
25
22
|
for (let i = indexStart; i < indexStart + interval.count; i++) {
|
|
26
23
|
const dataValue = interval.dataValues[i];
|
|
27
|
-
if (dataValue.statusCode.equals(
|
|
24
|
+
if (dataValue.statusCode.equals(StatusCodes.BadNoData)) {
|
|
28
25
|
isPartial = true;
|
|
29
26
|
continue;
|
|
30
27
|
}
|
|
@@ -33,7 +30,7 @@ function calculateCountValue(interval, options) {
|
|
|
33
30
|
nbBad++;
|
|
34
31
|
badDuration += regionDuration;
|
|
35
32
|
}
|
|
36
|
-
else if (
|
|
33
|
+
else if (isUncertain(dataValue.statusCode)) {
|
|
37
34
|
nbUncertain++;
|
|
38
35
|
uncertainDuration += regionDuration;
|
|
39
36
|
}
|
|
@@ -42,7 +39,7 @@ function calculateCountValue(interval, options) {
|
|
|
42
39
|
_goodDuration += regionDuration;
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
|
-
const partialFlag = isPartial ?
|
|
42
|
+
const partialFlag = isPartial ? extraStatusCodeBits.HistorianPartial : 0;
|
|
46
43
|
// debugLog(" ", goodDuration, uncertainDuration, badDuration);
|
|
47
44
|
if (nbBad > 0) {
|
|
48
45
|
const duration = interval.duration();
|
|
@@ -52,35 +49,35 @@ function calculateCountValue(interval, options) {
|
|
|
52
49
|
const actualPercentDataBad = (badDuration / duration) * 100.0;
|
|
53
50
|
const percentDataBad = options.percentDataBad === undefined ? 100 : options.percentDataBad;
|
|
54
51
|
if (actualPercentDataBad >= percentDataBad) {
|
|
55
|
-
return new
|
|
52
|
+
return new DataValue({
|
|
56
53
|
sourceTimestamp: interval.startTime,
|
|
57
|
-
statusCode:
|
|
54
|
+
statusCode: StatusCodes.Bad
|
|
58
55
|
});
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
58
|
if (nbUncertain > 0 || nbBad > 0) {
|
|
62
|
-
statusCode =
|
|
59
|
+
statusCode = StatusCode.makeStatusCode(StatusCodes.UncertainDataSubNormal, extraStatusCodeBits.HistorianCalculated | partialFlag);
|
|
63
60
|
}
|
|
64
61
|
else {
|
|
65
|
-
statusCode =
|
|
62
|
+
statusCode = StatusCode.makeStatusCode(StatusCodes.Good, extraStatusCodeBits.HistorianCalculated | partialFlag);
|
|
66
63
|
}
|
|
67
64
|
if (nbUncertain === 0 && nbGood === 0) {
|
|
68
|
-
statusCode =
|
|
69
|
-
return new
|
|
65
|
+
statusCode = StatusCodes.BadNoData;
|
|
66
|
+
return new DataValue({
|
|
70
67
|
sourceTimestamp: interval.startTime,
|
|
71
68
|
statusCode: statusCode
|
|
72
69
|
});
|
|
73
70
|
}
|
|
74
|
-
return new
|
|
71
|
+
return new DataValue({
|
|
75
72
|
sourceTimestamp: interval.startTime,
|
|
76
73
|
statusCode: statusCode,
|
|
77
74
|
value: {
|
|
78
|
-
dataType:
|
|
75
|
+
dataType: DataType.UInt32,
|
|
79
76
|
value: nbGood
|
|
80
77
|
}
|
|
81
78
|
});
|
|
82
79
|
}
|
|
83
|
-
function getCountData(node, processingInterval, startDate, endDate, callback) {
|
|
84
|
-
|
|
80
|
+
export function getCountData(node, processingInterval, startDate, endDate, callback) {
|
|
81
|
+
getAggregateData(node, processingInterval, startDate, endDate, calculateCountValue, callback);
|
|
85
82
|
}
|
|
86
83
|
//# sourceMappingURL=count.js.map
|
package/dist/count.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"count.js","sourceRoot":"","sources":["../source/count.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"count.js","sourceRoot":"","sources":["../source/count.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,m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KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC;QACnC,OAAO,IAAI,SAAS,CAAC;YACjB,eAAe,EAAE,QAAQ,CAAC,SAAS;YACnC,UAAU,EAAE,UAAwB;SACvC,CAAC,CAAC;IACP,CAAC;IAED,OAAO,IAAI,SAAS,CAAC;QACjB,eAAe,EAAE,QAAQ,CAAC,SAAS;QACnC,UAAU,EAAE,UAAwB;QACpC,KAAK,EAAE;YACH,QAAQ,EAAE,QAAQ,CAAC,MAAM;YACzB,KAAK,EAAE,MAAM;SAChB;KACJ,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,YAAY,CACxB,IAAgB,EAChB,kBAA0B,EAC1B,SAAe,EACf,OAAa,EACb,QAA+D;IAE/D,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;AAClG,CAAC"}
|
package/dist/duration_bad.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ import type { UAVariable } from "node-opcua-address-space";
|
|
|
2
2
|
import { DataValue } from "node-opcua-data-value";
|
|
3
3
|
/**Retrieve the percentage of data (0 to 100) in the interval which has Bad StatusCode. */
|
|
4
4
|
export declare function getDurationBadData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
|
5
|
+
//# sourceMappingURL=duration_bad.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration_bad.d.ts","sourceRoot":"","sources":["../source/duration_bad.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAyBlD,0FAA0F;AAC1F,wBAAgB,kBAAkB,CAC9B,IAAI,EAAE,UAAU,EAChB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,IAAI,EACb,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,SAAS,EAAE,KAAK,IAAI,GAChE,IAAI,CAEN"}
|
package/dist/duration_bad.js
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
7
|
-
const calculate_bad_good_js_1 = require("./calculate_bad_good.js");
|
|
8
|
-
const common_js_1 = require("./common.js");
|
|
1
|
+
import { DataValue } from "node-opcua-data-value";
|
|
2
|
+
import { StatusCodes } from "node-opcua-status-code";
|
|
3
|
+
import { DataType } from "node-opcua-variant";
|
|
4
|
+
import { calculateBadAndGood } from "./calculate_bad_good.js";
|
|
5
|
+
import { getAggregateData } from "./common.js";
|
|
9
6
|
function calculateDurationBad(interval, options) {
|
|
10
|
-
const { durationBad, durationUnknown, statusCode } =
|
|
7
|
+
const { durationBad, durationUnknown, statusCode } = calculateBadAndGood(interval, options);
|
|
11
8
|
if (durationUnknown > 0 && durationBad === 0) {
|
|
12
|
-
return new
|
|
9
|
+
return new DataValue({
|
|
13
10
|
sourceTimestamp: interval.startTime,
|
|
14
|
-
statusCode:
|
|
11
|
+
statusCode: StatusCodes.Bad
|
|
15
12
|
});
|
|
16
13
|
}
|
|
17
14
|
const value = durationBad;
|
|
18
15
|
if (statusCode.isGoodish()) {
|
|
19
|
-
return new
|
|
16
|
+
return new DataValue({
|
|
20
17
|
sourceTimestamp: interval.startTime,
|
|
21
18
|
statusCode,
|
|
22
|
-
value: { dataType:
|
|
19
|
+
value: { dataType: DataType.Double, value }
|
|
23
20
|
});
|
|
24
21
|
}
|
|
25
|
-
return new
|
|
22
|
+
return new DataValue({ sourceTimestamp: interval.startTime, statusCode, value: { dataType: DataType.Null } });
|
|
26
23
|
}
|
|
27
24
|
/**Retrieve the percentage of data (0 to 100) in the interval which has Bad StatusCode. */
|
|
28
|
-
function getDurationBadData(node, processingInterval, startDate, endDate, callback) {
|
|
29
|
-
|
|
25
|
+
export function getDurationBadData(node, processingInterval, startDate, endDate, callback) {
|
|
26
|
+
getAggregateData(node, processingInterval, startDate, endDate, calculateDurationBad, callback);
|
|
30
27
|
}
|
|
31
28
|
//# sourceMappingURL=duration_bad.js.map
|
package/dist/duration_bad.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duration_bad.js","sourceRoot":"","sources":["../source/duration_bad.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"duration_bad.js","sourceRoot":"","sources":["../source/duration_bad.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,SAAS,oBAAoB,CAAC,QAAkB,EAAE,OAAsC;IACpF,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC5F,IAAI,eAAe,GAAG,CAAC,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAI,SAAS,CAAC;YACjB,eAAe,EAAE,QAAQ,CAAC,SAAS;YACnC,UAAU,EAAE,WAAW,CAAC,GAAG;SAC9B,CAAC,CAAC;IACP,CAAC;IACD,MAAM,KAAK,GAAG,WAAW,CAAC;IAC1B,IAAI,UAAU,CAAC,SAAS,EAAE,EAAE,CAAC;QACzB,OAAO,IAAI,SAAS,CAAC;YACjB,eAAe,EAAE,QAAQ,CAAC,SAAS;YACnC,UAAU;YACV,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE;SAC9C,CAAC,CAAC;IACP,CAAC;IACD,OAAO,IAAI,SAAS,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAClH,CAAC;AACD,0FAA0F;AAC1F,MAAM,UAAU,kBAAkB,CAC9B,IAAgB,EAChB,kBAA0B,EAC1B,SAAe,EACf,OAAa,EACb,QAA+D;IAE/D,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,EAAE,oBAAoB,EAAE,QAAQ,CAAC,CAAC;AACnG,CAAC"}
|
package/dist/duration_good.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ import type { UAVariable } from "node-opcua-address-space";
|
|
|
2
2
|
import { DataValue } from "node-opcua-data-value";
|
|
3
3
|
/**Retrieve the percentage of data (0 to 100) in the interval which has Bad StatusCode. */
|
|
4
4
|
export declare function getDurationGoodData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
|
5
|
+
//# sourceMappingURL=duration_good.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration_good.d.ts","sourceRoot":"","sources":["../source/duration_good.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAyBlD,0FAA0F;AAC1F,wBAAgB,mBAAmB,CAC/B,IAAI,EAAE,UAAU,EAChB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,IAAI,EACb,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,SAAS,EAAE,KAAK,IAAI,GAChE,IAAI,CAEN"}
|
package/dist/duration_good.js
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
7
|
-
const calculate_bad_good_js_1 = require("./calculate_bad_good.js");
|
|
8
|
-
const common_js_1 = require("./common.js");
|
|
1
|
+
import { DataValue } from "node-opcua-data-value";
|
|
2
|
+
import { StatusCodes } from "node-opcua-status-code";
|
|
3
|
+
import { DataType } from "node-opcua-variant";
|
|
4
|
+
import { calculateBadAndGood } from "./calculate_bad_good.js";
|
|
5
|
+
import { getAggregateData } from "./common.js";
|
|
9
6
|
function calculateDurationGood(interval, options) {
|
|
10
|
-
const { durationGood, durationUnknown, statusCode } =
|
|
7
|
+
const { durationGood, durationUnknown, statusCode } = calculateBadAndGood(interval, options);
|
|
11
8
|
if (durationUnknown > 0 && durationGood === 0) {
|
|
12
|
-
return new
|
|
9
|
+
return new DataValue({
|
|
13
10
|
sourceTimestamp: interval.startTime,
|
|
14
|
-
statusCode:
|
|
11
|
+
statusCode: StatusCodes.Bad
|
|
15
12
|
});
|
|
16
13
|
}
|
|
17
14
|
const value = durationGood;
|
|
18
15
|
if (statusCode.isGoodish()) {
|
|
19
|
-
return new
|
|
16
|
+
return new DataValue({
|
|
20
17
|
sourceTimestamp: interval.startTime,
|
|
21
18
|
statusCode,
|
|
22
|
-
value: { dataType:
|
|
19
|
+
value: { dataType: DataType.Double, value }
|
|
23
20
|
});
|
|
24
21
|
}
|
|
25
|
-
return new
|
|
22
|
+
return new DataValue({ sourceTimestamp: interval.startTime, statusCode, value: { dataType: DataType.Null } });
|
|
26
23
|
}
|
|
27
24
|
/**Retrieve the percentage of data (0 to 100) in the interval which has Bad StatusCode. */
|
|
28
|
-
function getDurationGoodData(node, processingInterval, startDate, endDate, callback) {
|
|
29
|
-
|
|
25
|
+
export function getDurationGoodData(node, processingInterval, startDate, endDate, callback) {
|
|
26
|
+
getAggregateData(node, processingInterval, startDate, endDate, calculateDurationGood, callback);
|
|
30
27
|
}
|
|
31
28
|
//# sourceMappingURL=duration_good.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duration_good.js","sourceRoot":"","sources":["../source/duration_good.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"duration_good.js","sourceRoot":"","sources":["../source/duration_good.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,SAAS,qBAAqB,CAAC,QAAkB,EAAE,OAAsC;IACrF,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7F,IAAI,eAAe,GAAG,CAAC,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;QAC5C,OAAO,IAAI,SAAS,CAAC;YACjB,eAAe,EAAE,QAAQ,CAAC,SAAS;YACnC,UAAU,EAAE,WAAW,CAAC,GAAG;SAC9B,CAAC,CAAC;IACP,CAAC;IACD,MAAM,KAAK,GAAG,YAAY,CAAC;IAC3B,IAAI,UAAU,CAAC,SAAS,EAAE,EAAE,CAAC;QACzB,OAAO,IAAI,SAAS,CAAC;YACjB,eAAe,EAAE,QAAQ,CAAC,SAAS;YACnC,UAAU;YACV,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE;SAC9C,CAAC,CAAC;IACP,CAAC;IACD,OAAO,IAAI,SAAS,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAClH,CAAC;AACD,0FAA0F;AAC1F,MAAM,UAAU,mBAAmB,CAC/B,IAAgB,EAChB,kBAA0B,EAC1B,SAAe,EACf,OAAa,EACb,QAA+D;IAE/D,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,EAAE,qBAAqB,EAAE,QAAQ,CAAC,CAAC;AACpG,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EACH,2BAA2B,EAC3B,mCAAmC,EACnC,mBAAmB,EACnB,yBAAyB,EACzB,oCAAoC,EACvC,MAAM,iBAAiB,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,cAAc,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module node-opca-aggregates
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.getPercentGoodData = exports.getPercentBadData = exports.getDurationGoodData = exports.getDurationBadData = exports.getCountData = exports.installAggregateConfigurationOptions = exports.getAggregateConfiguration = exports.addAggregateSupport = exports.addAggregateStandardFunctionSupport = exports.addAggregateFunctionSupport = exports.AggregateFunction = void 0;
|
|
21
|
-
var node_opcua_constants_1 = require("node-opcua-constants");
|
|
22
|
-
Object.defineProperty(exports, "AggregateFunction", { enumerable: true, get: function () { return node_opcua_constants_1.AggregateFunction; } });
|
|
23
|
-
var aggregates_js_1 = require("./aggregates.js");
|
|
24
|
-
Object.defineProperty(exports, "addAggregateFunctionSupport", { enumerable: true, get: function () { return aggregates_js_1.addAggregateFunctionSupport; } });
|
|
25
|
-
Object.defineProperty(exports, "addAggregateStandardFunctionSupport", { enumerable: true, get: function () { return aggregates_js_1.addAggregateStandardFunctionSupport; } });
|
|
26
|
-
Object.defineProperty(exports, "addAggregateSupport", { enumerable: true, get: function () { return aggregates_js_1.addAggregateSupport; } });
|
|
27
|
-
Object.defineProperty(exports, "getAggregateConfiguration", { enumerable: true, get: function () { return aggregates_js_1.getAggregateConfiguration; } });
|
|
28
|
-
Object.defineProperty(exports, "installAggregateConfigurationOptions", { enumerable: true, get: function () { return aggregates_js_1.installAggregateConfigurationOptions; } });
|
|
29
|
-
__exportStar(require("./average.js"), exports);
|
|
30
|
-
__exportStar(require("./common.js"), exports);
|
|
31
|
-
var count_js_1 = require("./count.js");
|
|
32
|
-
Object.defineProperty(exports, "getCountData", { enumerable: true, get: function () { return count_js_1.getCountData; } });
|
|
33
|
-
var duration_bad_js_1 = require("./duration_bad.js");
|
|
34
|
-
Object.defineProperty(exports, "getDurationBadData", { enumerable: true, get: function () { return duration_bad_js_1.getDurationBadData; } });
|
|
35
|
-
var duration_good_js_1 = require("./duration_good.js");
|
|
36
|
-
Object.defineProperty(exports, "getDurationGoodData", { enumerable: true, get: function () { return duration_good_js_1.getDurationGoodData; } });
|
|
37
|
-
__exportStar(require("./interpolate.js"), exports);
|
|
38
|
-
__exportStar(require("./interval.js"), exports);
|
|
39
|
-
__exportStar(require("./minmax.js"), exports);
|
|
40
|
-
var percent_bad_js_1 = require("./percent_bad.js");
|
|
41
|
-
Object.defineProperty(exports, "getPercentBadData", { enumerable: true, get: function () { return percent_bad_js_1.getPercentBadData; } });
|
|
42
|
-
var percent_good_js_1 = require("./percent_good.js");
|
|
43
|
-
Object.defineProperty(exports, "getPercentGoodData", { enumerable: true, get: function () { return percent_good_js_1.getPercentGoodData; } });
|
|
44
|
-
__exportStar(require("./read_processed_details.js"), exports);
|
|
4
|
+
export { AggregateFunction } from "node-opcua-constants";
|
|
5
|
+
export { addAggregateFunctionSupport, addAggregateStandardFunctionSupport, addAggregateSupport, getAggregateConfiguration, installAggregateConfigurationOptions } from "./aggregates.js";
|
|
6
|
+
export * from "./average.js";
|
|
7
|
+
export * from "./common.js";
|
|
8
|
+
export { getCountData } from "./count.js";
|
|
9
|
+
export { getDurationBadData } from "./duration_bad.js";
|
|
10
|
+
export { getDurationGoodData } from "./duration_good.js";
|
|
11
|
+
export * from "./interpolate.js";
|
|
12
|
+
export * from "./interval.js";
|
|
13
|
+
export * from "./minmax.js";
|
|
14
|
+
export { getPercentBadData } from "./percent_bad.js";
|
|
15
|
+
export { getPercentGoodData } from "./percent_good.js";
|
|
16
|
+
export * from "./read_processed_details.js";
|
|
45
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EACH,2BAA2B,EAC3B,mCAAmC,EACnC,mBAAmB,EACnB,yBAAyB,EACzB,oCAAoC,EACvC,MAAM,iBAAiB,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,cAAc,6BAA6B,CAAC"}
|
package/dist/interpolate.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export declare function interpolatedValue(interval: Interval, options: Aggregate
|
|
|
14
14
|
* @param callback
|
|
15
15
|
*/
|
|
16
16
|
export declare function getInterpolatedData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
|
17
|
+
//# sourceMappingURL=interpolate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../source/interpolate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAqCH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,OAAO,EAEH,KAAK,+BAA+B,EAEpC,KAAK,QAAQ,EAChB,MAAM,eAAe,CAAC;AAYvB,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,+BAA+B,GAAG,SAAS,CA8GzG;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAC/B,IAAI,EAAE,UAAU,EAChB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,IAAI,EACb,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,SAAS,EAAE,KAAK,IAAI,GAChE,IAAI,CAEN"}
|
package/dist/interpolate.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
7
|
-
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
8
|
-
const common_js_1 = require("./common.js");
|
|
9
|
-
const interval_js_1 = require("./interval.js");
|
|
1
|
+
import { assert } from "node-opcua-assert";
|
|
2
|
+
import { DataValue } from "node-opcua-data-value";
|
|
3
|
+
import { StatusCode, StatusCodes } from "node-opcua-status-code";
|
|
4
|
+
import { getAggregateData, interpolateValue } from "./common.js";
|
|
5
|
+
import { _findGoodDataValueBefore, adjustProcessingOptions } from "./interval.js";
|
|
10
6
|
/*
|
|
11
7
|
For any intervals containing regions where the StatusCodes are Bad,
|
|
12
8
|
the total duration of all Bad regions is calculated and divided by the width of the interval.
|
|
@@ -17,58 +13,58 @@ const interval_js_1 = require("./interval.js");
|
|
|
17
13
|
The StatusCode for the interval is Good if the ratio is greater than or equal to the PercentDataGood parameter.
|
|
18
14
|
If for an interval neither ratio applies then that interval is Uncertain_DataSubNormal.
|
|
19
15
|
*/
|
|
20
|
-
function interpolatedValue(interval, options) {
|
|
21
|
-
options =
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
export function interpolatedValue(interval, options) {
|
|
17
|
+
options = adjustProcessingOptions(options);
|
|
18
|
+
assert(Object.hasOwn(options, "useSlopedExtrapolation"));
|
|
19
|
+
assert(Object.hasOwn(options, "treatUncertainAsBad"));
|
|
24
20
|
const bTreatUncertainAsBad = options.treatUncertainAsBad || false;
|
|
25
21
|
const steppedValue = (previousDataValue) => {
|
|
26
22
|
if (!previousDataValue.statusCode) {
|
|
27
23
|
throw new Error("Expecting statusCode");
|
|
28
24
|
}
|
|
29
|
-
const interpValue = new
|
|
25
|
+
const interpValue = new DataValue({
|
|
30
26
|
sourceTimestamp: interval.startTime,
|
|
31
|
-
statusCode:
|
|
27
|
+
statusCode: StatusCodes.Bad,
|
|
32
28
|
value: previousDataValue.value
|
|
33
29
|
});
|
|
34
|
-
interpValue.statusCode =
|
|
30
|
+
interpValue.statusCode = StatusCode.makeStatusCode(StatusCodes.UncertainDataSubNormal, "HistorianInterpolated");
|
|
35
31
|
return interpValue;
|
|
36
32
|
};
|
|
37
33
|
if (interval.index === -1) {
|
|
38
34
|
// the interval is beyond end Data
|
|
39
35
|
// we need to find previous good value
|
|
40
36
|
// and second previous good value to extrapolate
|
|
41
|
-
const prev1 =
|
|
37
|
+
const prev1 = _findGoodDataValueBefore(interval.dataValues, interval.dataValues.length, bTreatUncertainAsBad);
|
|
42
38
|
if (prev1.index <= 0) {
|
|
43
|
-
return new
|
|
39
|
+
return new DataValue({
|
|
44
40
|
sourceTimestamp: interval.startTime,
|
|
45
|
-
statusCode:
|
|
41
|
+
statusCode: StatusCodes.BadNoData,
|
|
46
42
|
value: undefined
|
|
47
43
|
});
|
|
48
44
|
}
|
|
49
45
|
if (!options.useSlopedExtrapolation) {
|
|
50
46
|
return steppedValue(prev1.dataValue);
|
|
51
47
|
}
|
|
52
|
-
const prev2 =
|
|
48
|
+
const prev2 = _findGoodDataValueBefore(interval.dataValues, prev1.index, bTreatUncertainAsBad);
|
|
53
49
|
if (prev2.index <= 0) {
|
|
54
50
|
// use step value
|
|
55
51
|
return steppedValue(prev1.dataValue);
|
|
56
52
|
}
|
|
57
53
|
// else interpolate
|
|
58
|
-
const interpVal =
|
|
54
|
+
const interpVal = interpolateValue(prev2.dataValue, prev1.dataValue, interval.startTime);
|
|
59
55
|
if (prev2.index + 1 < prev1.index || prev1.index < interval.dataValues.length - 1) {
|
|
60
56
|
// some bad data exist in between = change status code
|
|
61
57
|
const mask = 0x0000ffffff;
|
|
62
58
|
const extraBits = interpVal.statusCode.value & mask;
|
|
63
|
-
interpVal.statusCode =
|
|
59
|
+
interpVal.statusCode = StatusCode.makeStatusCode(StatusCodes.UncertainDataSubNormal, extraBits);
|
|
64
60
|
}
|
|
65
61
|
return interpVal;
|
|
66
62
|
}
|
|
67
63
|
/* c8 ignore next */
|
|
68
64
|
if (interval.index < 0 && interval.count === 0) {
|
|
69
|
-
return new
|
|
65
|
+
return new DataValue({
|
|
70
66
|
sourceTimestamp: interval.startTime,
|
|
71
|
-
statusCode:
|
|
67
|
+
statusCode: StatusCodes.BadNoData
|
|
72
68
|
});
|
|
73
69
|
}
|
|
74
70
|
const dataValue1 = interval.dataValues[interval.index];
|
|
@@ -80,16 +76,16 @@ function interpolatedValue(interval, options) {
|
|
|
80
76
|
// find previous good value
|
|
81
77
|
const before = interval.beforeStartDataValue(bTreatUncertainAsBad);
|
|
82
78
|
if (before.dataValue.statusCode.isBad()) {
|
|
83
|
-
return new
|
|
79
|
+
return new DataValue({
|
|
84
80
|
sourceTimestamp: interval.startTime,
|
|
85
|
-
statusCode:
|
|
81
|
+
statusCode: StatusCodes.BadNoData
|
|
86
82
|
});
|
|
87
83
|
}
|
|
88
84
|
if (options.stepped) {
|
|
89
85
|
if (before.index + 1 === interval.index) {
|
|
90
|
-
return new
|
|
86
|
+
return new DataValue({
|
|
91
87
|
sourceTimestamp: interval.startTime,
|
|
92
|
-
statusCode:
|
|
88
|
+
statusCode: StatusCode.makeStatusCode(before.dataValue.statusCode, "HistorianInterpolated"),
|
|
93
89
|
value: before.dataValue.value
|
|
94
90
|
});
|
|
95
91
|
}
|
|
@@ -103,12 +99,12 @@ function interpolatedValue(interval, options) {
|
|
|
103
99
|
// V bound = (T bound – T before)x( V after – V before)/( T after – T before) + V before
|
|
104
100
|
// where V
|
|
105
101
|
// x is a value at ‘x’ and Tx is the timestamp associated with Vx.
|
|
106
|
-
const interpolatedDataValue =
|
|
102
|
+
const interpolatedDataValue = interpolateValue(before.dataValue, next.dataValue, interval.startTime);
|
|
107
103
|
if (before.index + 1 < next.index || !next.dataValue.statusCode.isGood() || !before.dataValue.statusCode.isGood()) {
|
|
108
104
|
// some bad data exist in between = change status code
|
|
109
105
|
const mask = 0x0000ffffff;
|
|
110
106
|
const extraBits = interpolatedDataValue.statusCode.value & mask;
|
|
111
|
-
interpolatedDataValue.statusCode =
|
|
107
|
+
interpolatedDataValue.statusCode = StatusCode.makeStatusCode(StatusCodes.UncertainDataSubNormal, extraBits);
|
|
112
108
|
}
|
|
113
109
|
// check if uncertain or bad value exist between before/next
|
|
114
110
|
// todo
|
|
@@ -122,7 +118,7 @@ function interpolatedValue(interval, options) {
|
|
|
122
118
|
* @param endDate
|
|
123
119
|
* @param callback
|
|
124
120
|
*/
|
|
125
|
-
function getInterpolatedData(node, processingInterval, startDate, endDate, callback) {
|
|
126
|
-
|
|
121
|
+
export function getInterpolatedData(node, processingInterval, startDate, endDate, callback) {
|
|
122
|
+
getAggregateData(node, processingInterval, startDate, endDate, interpolatedValue, callback);
|
|
127
123
|
}
|
|
128
124
|
//# sourceMappingURL=interpolate.js.map
|
package/dist/interpolate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolate.js","sourceRoot":"","sources":["../source/interpolate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interpolate.js","sourceRoot":"","sources":["../source/interpolate.ts"],"names":[],"mappings":"AAwCA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,C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;IACI,oBAAoB,CAAC,oBAAoB,EAAE,OAAO,GAAG,kBAAkB,CAE7E;IAEM,kBAAkB,CAAC,oBAAoB,EAAE,OAAO,GAAG,kBAAkB,CAE3E;IAEM,QAAQ,IAAI,MAAM,CAexB;IACM,mBAAmB,IAAI,MAAM,CAcnC;IAED;;;OAGG;IACH,QAAQ,WAIP;IAED;;OAEG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKpC;CACJ;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,QAAQ,CAwC7H"}
|
package/dist/interval.js
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Interval = void 0;
|
|
4
|
-
exports.isGoodish2 = isGoodish2;
|
|
5
|
-
exports.isUncertain = isUncertain;
|
|
6
|
-
exports._findGoodDataValueBefore = _findGoodDataValueBefore;
|
|
7
|
-
exports._findGoodDataValueAfter = _findGoodDataValueAfter;
|
|
8
|
-
exports.adjustProcessingOptions = adjustProcessingOptions;
|
|
9
|
-
exports.getInterval = getInterval;
|
|
10
1
|
/**
|
|
11
2
|
* @module node-opca-aggregates
|
|
12
3
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function isGoodish2(statusCode, { treatUncertainAsBad }) {
|
|
4
|
+
import { DataValue } from "node-opcua-data-value";
|
|
5
|
+
import { StatusCodes } from "node-opcua-status-code";
|
|
6
|
+
export function isGoodish2(statusCode, { treatUncertainAsBad }) {
|
|
16
7
|
if (statusCode.isGoodish())
|
|
17
8
|
return true;
|
|
18
9
|
if (isUncertain(statusCode))
|
|
19
10
|
return !treatUncertainAsBad;
|
|
20
11
|
return false;
|
|
21
12
|
}
|
|
22
|
-
function isUncertain(statusCode) {
|
|
23
|
-
return (statusCode.value & 0x40000000) === 0x40000000 && statusCode.value !==
|
|
13
|
+
export function isUncertain(statusCode) {
|
|
14
|
+
return (statusCode.value & 0x40000000) === 0x40000000 && statusCode.value !== StatusCodes.BadNoData.value;
|
|
24
15
|
}
|
|
25
16
|
function sourceTimestampMs(dataValue) {
|
|
26
17
|
if (!dataValue.sourceTimestamp) {
|
|
@@ -28,7 +19,7 @@ function sourceTimestampMs(dataValue) {
|
|
|
28
19
|
}
|
|
29
20
|
return dataValue.sourceTimestamp.getTime();
|
|
30
21
|
}
|
|
31
|
-
function _findGoodDataValueBefore(dataValues, index, bTreatUncertainAsBad) {
|
|
22
|
+
export function _findGoodDataValueBefore(dataValues, index, bTreatUncertainAsBad) {
|
|
32
23
|
index--;
|
|
33
24
|
while (index >= 0) {
|
|
34
25
|
const dataValue1 = dataValues[index];
|
|
@@ -42,11 +33,11 @@ function _findGoodDataValueBefore(dataValues, index, bTreatUncertainAsBad) {
|
|
|
42
33
|
}
|
|
43
34
|
// not found
|
|
44
35
|
return {
|
|
45
|
-
dataValue: new
|
|
36
|
+
dataValue: new DataValue({ statusCode: StatusCodes.BadNoData }),
|
|
46
37
|
index: -1
|
|
47
38
|
};
|
|
48
39
|
}
|
|
49
|
-
function _findGoodDataValueAfter(dataValues, index, bTreatUncertainAsBad) {
|
|
40
|
+
export function _findGoodDataValueAfter(dataValues, index, bTreatUncertainAsBad) {
|
|
50
41
|
while (index < dataValues.length) {
|
|
51
42
|
const dataValue1 = dataValues[index];
|
|
52
43
|
if (!bTreatUncertainAsBad && !dataValue1.statusCode.isBad()) {
|
|
@@ -65,11 +56,11 @@ function _findGoodDataValueAfter(dataValues, index, bTreatUncertainAsBad) {
|
|
|
65
56
|
}
|
|
66
57
|
// not found
|
|
67
58
|
return {
|
|
68
|
-
dataValue: new
|
|
59
|
+
dataValue: new DataValue({ statusCode: StatusCodes.BadNoData }),
|
|
69
60
|
index: -1
|
|
70
61
|
};
|
|
71
62
|
}
|
|
72
|
-
function adjustProcessingOptions(options) {
|
|
63
|
+
export function adjustProcessingOptions(options) {
|
|
73
64
|
options = options || {};
|
|
74
65
|
options.treatUncertainAsBad = options.treatUncertainAsBad || false;
|
|
75
66
|
options.useSlopedExtrapolation = options.useSlopedExtrapolation || false;
|
|
@@ -78,7 +69,7 @@ function adjustProcessingOptions(options) {
|
|
|
78
69
|
options.percentDataGood = parseInt(String(options.percentDataGood ?? 0), 10);
|
|
79
70
|
return options;
|
|
80
71
|
}
|
|
81
|
-
class Interval {
|
|
72
|
+
export class Interval {
|
|
82
73
|
startTime;
|
|
83
74
|
dataValues;
|
|
84
75
|
index;
|
|
@@ -144,7 +135,7 @@ class Interval {
|
|
|
144
135
|
return e;
|
|
145
136
|
}
|
|
146
137
|
let i = this.dataValues.length - 1;
|
|
147
|
-
while (i >= 0 && this.dataValues[i].statusCode.equals(
|
|
138
|
+
while (i >= 0 && this.dataValues[i].statusCode.equals(StatusCodes.BadNoData)) {
|
|
148
139
|
i--;
|
|
149
140
|
}
|
|
150
141
|
if (i < 0) {
|
|
@@ -172,8 +163,7 @@ class Interval {
|
|
|
172
163
|
return t2 - t1;
|
|
173
164
|
}
|
|
174
165
|
}
|
|
175
|
-
|
|
176
|
-
function getInterval(startTime, processingInterval, indexHint, dataValues) {
|
|
166
|
+
export function getInterval(startTime, processingInterval, indexHint, dataValues) {
|
|
177
167
|
let count = 0;
|
|
178
168
|
let index = -1;
|
|
179
169
|
for (let i = indexHint; i < dataValues.length; i++) {
|