node-opcua-aggregates 2.96.0 → 2.98.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.
Files changed (43) hide show
  1. package/package.json +15 -15
  2. package/dist/aggregates.d.ts +0 -22
  3. package/dist/aggregates.js +0 -276
  4. package/dist/aggregates.js.map +0 -1
  5. package/dist/average.d.ts +0 -3
  6. package/dist/average.js +0 -61
  7. package/dist/average.js.map +0 -1
  8. package/dist/calculate_bad_good.d.ts +0 -10
  9. package/dist/calculate_bad_good.js +0 -118
  10. package/dist/calculate_bad_good.js.map +0 -1
  11. package/dist/common.d.ts +0 -8
  12. package/dist/common.js +0 -94
  13. package/dist/common.js.map +0 -1
  14. package/dist/count.d.ts +0 -3
  15. package/dist/count.js +0 -87
  16. package/dist/count.js.map +0 -1
  17. package/dist/duration_bad.d.ts +0 -4
  18. package/dist/duration_bad.js +0 -32
  19. package/dist/duration_bad.js.map +0 -1
  20. package/dist/duration_good.d.ts +0 -4
  21. package/dist/duration_good.js +0 -32
  22. package/dist/duration_good.js.map +0 -1
  23. package/dist/index.d.ts +0 -11
  24. package/dist/index.js +0 -35
  25. package/dist/index.js.map +0 -1
  26. package/dist/interpolate.d.ts +0 -16
  27. package/dist/interpolate.js +0 -131
  28. package/dist/interpolate.js.map +0 -1
  29. package/dist/interval.d.ts +0 -62
  30. package/dist/interval.js +0 -200
  31. package/dist/interval.js.map +0 -1
  32. package/dist/minmax.d.ts +0 -18
  33. package/dist/minmax.js +0 -149
  34. package/dist/minmax.js.map +0 -1
  35. package/dist/percent_bad.d.ts +0 -4
  36. package/dist/percent_bad.js +0 -25
  37. package/dist/percent_bad.js.map +0 -1
  38. package/dist/percent_good.d.ts +0 -7
  39. package/dist/percent_good.js +0 -49
  40. package/dist/percent_good.js.map +0 -1
  41. package/dist/read_processed_details.d.ts +0 -6
  42. package/dist/read_processed_details.js +0 -144
  43. package/dist/read_processed_details.js.map +0 -1
package/dist/interval.js DELETED
@@ -1,200 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInterval = exports.Interval = exports.adjustProcessingOptions = exports._findGoodDataValueAfter = exports._findGoodDataValueBefore = exports.isUncertain = exports.isGoodish2 = 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 isGoodish2(statusCode, { treatUncertainAsBad }) {
10
- if (statusCode.isGoodish())
11
- return true;
12
- if (isUncertain(statusCode))
13
- return !treatUncertainAsBad;
14
- return false;
15
- }
16
- exports.isGoodish2 = isGoodish2;
17
- function isUncertain(statusCode) {
18
- return (statusCode.value & 0x40000000) === 0x40000000 && statusCode.value !== node_opcua_status_code_1.StatusCodes.BadNoData.value;
19
- }
20
- exports.isUncertain = isUncertain;
21
- function _findGoodDataValueBefore(dataValues, index, bTreatUncertainAsBad) {
22
- index--;
23
- while (index >= 0) {
24
- const dataValue1 = dataValues[index];
25
- if (!bTreatUncertainAsBad && !dataValue1.statusCode.isBad()) {
26
- return { index, dataValue: dataValue1 };
27
- }
28
- if (bTreatUncertainAsBad && dataValue1.statusCode.isGood()) {
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 && !dataValue1.statusCode.isBad()) {
44
- return {
45
- dataValue: dataValue1,
46
- index
47
- };
48
- }
49
- if (bTreatUncertainAsBad && dataValue1.statusCode.isGood()) {
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
- this.processingInterval = options.processingInterval;
86
- }
87
- getPercentBad() {
88
- return 100;
89
- }
90
- /**
91
- * returns true if a raw data exists at start
92
- */
93
- hasRawDataAsStart() {
94
- const index = this.index;
95
- if (index < 0) {
96
- return false;
97
- }
98
- const dataValue1 = this.dataValues[index];
99
- return this.startTime.getTime() === dataValue1.sourceTimestamp.getTime();
100
- }
101
- /**
102
- * Find the first good or uncertain dataValue
103
- * just preceding this interval
104
- * @returns {*}
105
- */
106
- beforeStartDataValue(bTreatUncertainAsBad) {
107
- return _findGoodDataValueBefore(this.dataValues, this.index, bTreatUncertainAsBad);
108
- }
109
- nextStartDataValue(bTreatUncertainAsBad) {
110
- return _findGoodDataValueAfter(this.dataValues, this.index, bTreatUncertainAsBad);
111
- }
112
- toString() {
113
- let str = "";
114
- str += "startTime " + this.startTime.toUTCString() + "\n";
115
- str += "start " + this.index + " ";
116
- str += "count " + this.count + " ";
117
- str += "isPartial " + this.isPartial + "\n";
118
- if (this.index >= 0) {
119
- for (let i = this.index; i < this.index + this.count; i++) {
120
- const dataValue = this.dataValues[i];
121
- str += " " + dataValue.sourceTimestamp.toUTCString() + dataValue.statusCode.toString();
122
- str += dataValue.value ? dataValue.value.toString() : "";
123
- str += "\n";
124
- }
125
- }
126
- return str;
127
- }
128
- getEffectiveEndTime() {
129
- const e = this.startTime.getTime() + this.processingInterval;
130
- if (!this.dataValues || this.dataValues.length === 0) {
131
- return e;
132
- }
133
- let i = this.dataValues.length - 1;
134
- while (i >= 0 && this.dataValues[i].statusCode.equals(node_opcua_status_code_1.StatusCodes.BadNoData)) {
135
- i--;
136
- }
137
- if (i < 0) {
138
- return e;
139
- }
140
- const lastTimestamp = this.dataValues[i].sourceTimestamp;
141
- return Math.min(e, lastTimestamp.getTime() + 1);
142
- }
143
- /**
144
- *
145
- * @returns the interval duration
146
- */
147
- duration() {
148
- const t1 = this.dataValues[this.index].sourceTimestamp.getTime();
149
- const e = this.getEffectiveEndTime();
150
- return e - t1;
151
- }
152
- /**
153
- * returns the region duration starting at index and finishing at index+1 or end limit of the interval
154
- */
155
- regionDuration(index) {
156
- const t1 = this.dataValues[index].sourceTimestamp.getTime();
157
- const e = this.getEffectiveEndTime();
158
- const t2 = index < this.dataValues.length - 1 ? Math.min(this.dataValues[index + 1].sourceTimestamp.getTime(), e) : e;
159
- return t2 - t1;
160
- }
161
- }
162
- exports.Interval = Interval;
163
- function getInterval(startTime, processingInterval, indexHint, dataValues) {
164
- let count = 0;
165
- let index = -1;
166
- for (let i = indexHint; i < dataValues.length; i++) {
167
- if (dataValues[i].sourceTimestamp.getTime() < startTime.getTime()) {
168
- continue;
169
- }
170
- index = i;
171
- break;
172
- }
173
- if (index >= 0) {
174
- for (let i = index; i < dataValues.length; i++) {
175
- if (dataValues[i].sourceTimestamp.getTime() >= startTime.getTime() + processingInterval) {
176
- break;
177
- }
178
- count++;
179
- }
180
- }
181
- // check if interval is complete or partial (end or start)
182
- let isPartial = false;
183
- if (index + count >= dataValues.length &&
184
- dataValues[dataValues.length - 1].sourceTimestamp.getTime() < startTime.getTime() + processingInterval) {
185
- isPartial = true;
186
- }
187
- if (index <= 0 && dataValues[0].sourceTimestamp.getTime() > startTime.getTime()) {
188
- isPartial = true;
189
- }
190
- return new Interval({
191
- count,
192
- dataValues,
193
- index,
194
- isPartial,
195
- startTime,
196
- processingInterval
197
- });
198
- }
199
- exports.getInterval = getInterval;
200
- //# sourceMappingURL=interval.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interval.js","sourceRoot":"","sources":["../source/interval.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,iEAAkD;AAClD,mEAAiE;AASjE,SAAgB,UAAU,CAAC,UAAsB,EAAE,EAAE,mBAAmB,EAAqC;IACzG,IAAI,UAAU,CAAC,SAAS,EAAE;QAAE,OAAO,IAAI,CAAC;IACxC,IAAI,WAAW,CAAC,UAAU,CAAC;QAAE,OAAO,CAAC,mBAAmB,CAAC;IACzD,OAAO,KAAK,CAAC;AACjB,CAAC;AAJD,gCAIC;AAGD,SAAgB,WAAW,CAAC,UAAsB;IAC9C,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,UAAU,IAAI,UAAU,CAAC,KAAK,KAAK,oCAAW,CAAC,SAAS,CAAC,KAAK,CAAC;AAC9G,CAAC;AAFD,kCAEC;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,IAAI,CAAC,oBAAoB,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE;YACzD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;SAC3C;QACD,IAAI,oBAAoB,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE;YACxD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU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,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 { 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;
package/dist/minmax.js DELETED
@@ -1,149 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMaxData = exports.getMinData = exports.calculateIntervalMaxValue = exports.calculateIntervalMinValue = void 0;
4
- const node_opcua_data_value_1 = require("node-opcua-data-value");
5
- const node_opcua_status_code_1 = require("node-opcua-status-code");
6
- const common_1 = require("./common");
7
- // eslint-disable-next-line max-statements
8
- function calculateIntervalMinOrMaxValue(interval, options, predicate) {
9
- // console.log(interval.toString());
10
- const indexStart = interval.index;
11
- let selectedValue = null;
12
- let counter = 0;
13
- let statusCode;
14
- let isPartial = interval.isPartial;
15
- let isRaw = false;
16
- let hasBad = false;
17
- for (let i = indexStart; i < indexStart + interval.count; i++) {
18
- const dataValue = interval.dataValues[i];
19
- if (dataValue.statusCode.equals(node_opcua_status_code_1.StatusCodes.BadNoData)) {
20
- isPartial = true;
21
- continue;
22
- }
23
- if (!dataValue.statusCode.isGood()) {
24
- hasBad = true;
25
- continue;
26
- }
27
- if (!selectedValue) {
28
- selectedValue = dataValue.value;
29
- counter = 1;
30
- if (i === indexStart && dataValue.sourceTimestamp.getTime() === interval.startTime.getTime()) {
31
- isRaw = true;
32
- }
33
- continue;
34
- }
35
- const compare = predicate(selectedValue, dataValue.value);
36
- if (compare === "equal") {
37
- counter = 1;
38
- continue;
39
- }
40
- if (compare === "select") {
41
- selectedValue = dataValue.value;
42
- counter = 1;
43
- }
44
- }
45
- if (!selectedValue) {
46
- return new node_opcua_data_value_1.DataValue({
47
- sourceTimestamp: interval.startTime,
48
- statusCode: node_opcua_status_code_1.StatusCodes.BadNoData
49
- });
50
- }
51
- if (isRaw) {
52
- if (hasBad) {
53
- statusCode = node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal;
54
- }
55
- else {
56
- statusCode = node_opcua_status_code_1.StatusCodes.Good;
57
- }
58
- }
59
- else if (hasBad) {
60
- statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.UncertainDataSubNormal, "HistorianCalculated");
61
- }
62
- else {
63
- statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(node_opcua_status_code_1.StatusCodes.Good, "HistorianCalculated");
64
- }
65
- if (counter > 1) {
66
- statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(statusCode, "HistorianMultiValue");
67
- }
68
- if (isPartial || interval.isPartial) {
69
- statusCode = node_opcua_status_code_1.StatusCode.makeStatusCode(statusCode, "HistorianPartial");
70
- }
71
- return new node_opcua_data_value_1.DataValue({
72
- sourceTimestamp: interval.startTime,
73
- statusCode: statusCode,
74
- value: selectedValue
75
- });
76
- }
77
- function calculateIntervalMinValue(interval, options) {
78
- return calculateIntervalMinOrMaxValue(interval, options, (a, b) => a.value > b.value ? "select" : a.value === b.value ? "equal" : "reject");
79
- }
80
- exports.calculateIntervalMinValue = calculateIntervalMinValue;
81
- function calculateIntervalMaxValue(interval, options) {
82
- return calculateIntervalMinOrMaxValue(interval, options, (a, b) => a.value < b.value ? "select" : a.value === b.value ? "equal" : "reject");
83
- }
84
- exports.calculateIntervalMaxValue = calculateIntervalMaxValue;
85
- // From OPC Unified Architecture, Part 13 26 Release 1.04
86
- // 5.4.3.11 Maximum
87
- // The Maximum Aggregate defined in Table 22 retrieves the maximum Good raw value within
88
- // the interval, and returns that value with the timestamp at the start of the interval. Note that if
89
- // the same maximum exists at more than one timestamp the MultipleValues bit is set.
90
- // Unless otherwise indicated, StatusCodes are Good, Calculated. If the minimum value is on
91
- // the interval start time the status code will be Good, Raw. If only Bad quality values are
92
- // available then the status is returned as Bad_NoData.
93
- // The timestamp of the Aggregate will always be the start of the interval for every
94
- //
95
- // ProcessingInterval.
96
- //
97
- // Table 22 – Maximum Aggregate summary
98
- // Maximum Aggregate Characteristics
99
- //
100
- // Type Calculated
101
- // Data Type Same as Source
102
- // Use Bounds None
103
- // Timestamp StartTime
104
- //
105
- // Status Code Calculations
106
- // Calculation Method Custom
107
- // If no Bad values then the Status is Good. If Bad values exist then
108
- // the Status is Uncertain_SubNormal. If an Uncertain value is greater
109
- // than the maximum Good value the Status is Uncertain_SubNormal
110
- //
111
- // Partial Set Sometimes
112
- // If an interval is not a complete interval
113
- //
114
- // Calculated Set Sometimes
115
- // If the Maximum value is not on the startTime of the interval or if the
116
- // Status was set to Uncertain_SubNormal because of non-Good
117
- // values in the interval
118
- //
119
- // Interpolated Not Set
120
- //
121
- // Raw Set Sometimes
122
- // If Maximum value is on the startTime of the interval
123
- // Multi Value Set Sometimes
124
- // If multiple Good values exist with the Maximum value
125
- //
126
- // Status Code Common Special Cases
127
- // Before Start of Data Bad_NoData
128
- // After End of Data Bad_NoData
129
- // No Start Bound Not Applicable
130
- // No End Bound Not Applicable
131
- // Bound Bad Not Applicable
132
- // Bound Uncertain Not Applicable
133
- /**
134
- *
135
- * @param node
136
- * @param processingInterval
137
- * @param startDate
138
- * @param endDate
139
- * @param callback
140
- */
141
- function getMinData(node, processingInterval, startDate, endDate, callback) {
142
- return (0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculateIntervalMinValue, callback);
143
- }
144
- exports.getMinData = getMinData;
145
- function getMaxData(node, processingInterval, startDate, endDate, callback) {
146
- return (0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculateIntervalMaxValue, callback);
147
- }
148
- exports.getMaxData = getMaxData;
149
- //# sourceMappingURL=minmax.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"minmax.js","sourceRoot":"","sources":["../source/minmax.ts"],"names":[],"mappings":";;;AAuDA,iEAAkD;AAClD,mEAAiE;AAGjE,qCAA4C;AAG5C,0CAA0C;AAC1C,SAAS,8BAA8B,CACnC,QAAkB,EAClB,OAAsC,EACtC,SAAoE;IAEpE,sCAAsC;IAEtC,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC;IAClC,IAAI,aAAa,GAAmB,IAAI,CAAC;IAEzC,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,UAAsB,CAAC;IAC3B,IAAI,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;IAEnC,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,KAAK,IAAI,CAAC,GAAG,UAAU,EAAE,CAAC,GAAG,UAAU,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;QAC3D,MAAM,SAAS,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAEzC,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,oCAAW,CAAC,SAAS,CAAC,EAAE;YACpD,SAAS,GAAG,IAAI,CAAC;YACjB,SAAS;SACZ;QAED,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE;YAChC,MAAM,GAAG,IAAI,CAAC;YACd,SAAS;SACZ;QAED,IAAI,CAAC,aAAa,EAAE;YAChB,aAAa,GAAG,SAAS,CAAC,KAAK,CAAC;YAChC,OAAO,GAAG,CAAC,CAAC;YACZ,IAAI,CAAC,KAAK,UAAU,IAAI,SAAS,CAAC,eAAgB,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAC,SAAS,CAAC,OA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ACF,mCAAmC;AACnC,EAAE;AACF,yCAAyC;AACzC,uDAAuD;AACvD,4BAA4B;AAC5B,uDAAuD;AACvD,EAAE;AACF,mCAAmC;AACnC,sCAAsC;AACtC,sCAAsC;AACtC,0CAA0C;AAC1C,0CAA0C;AAC1C,0CAA0C;AAC1C,6CAA6C;AAC7C;;;;;;;GAOG;AACH,SAAgB,UAAU,CACtB,IAAgB,EAChB,kBAA0B,EAC1B,SAAe,EACf,OAAa,EACb,QAA+D;IAE/D,OAAO,IAAA,yBAAgB,EAAC,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,EAAE,yBAAyB,EAAE,QAAQ,CAAC,CAAC;AAC/G,CAAC;AARD,gCAQC;AAED,SAAgB,UAAU,CACtB,IAAgB,EAChB,kBAA0B,EAC1B,SAAe,EACf,OAAa,EACb,QAA+D;IAE/D,OAAO,IAAA,yBAAgB,EAAC,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,EAAE,yBAAyB,EAAE,QAAQ,CAAC,CAAC;AAC/G,CAAC;AARD,gCAQC"}
@@ -1,4 +0,0 @@
1
- import { UAVariable } from "node-opcua-address-space";
2
- import { DataValue } from "node-opcua-data-value";
3
- /**Retrieve the percentage of data (0 to 100) in the interval which has Bad StatusCode. */
4
- export declare function getPercentBadData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPercentBadData = 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 calculate_bad_good_1 = require("./calculate_bad_good");
8
- function calculatePercentBad(interval, options) {
9
- const { percentBad, statusCode } = (0, calculate_bad_good_1.calculateBadAndGood)(interval, options);
10
- const value = percentBad;
11
- if (statusCode.isGoodish()) {
12
- return new node_opcua_data_value_1.DataValue({
13
- sourceTimestamp: interval.startTime,
14
- statusCode,
15
- value: { dataType: node_opcua_variant_1.DataType.Double, value }
16
- });
17
- }
18
- return new node_opcua_data_value_1.DataValue({ sourceTimestamp: interval.startTime, statusCode, value: { dataType: node_opcua_variant_1.DataType.Null } });
19
- }
20
- /**Retrieve the percentage of data (0 to 100) in the interval which has Bad StatusCode. */
21
- function getPercentBadData(node, processingInterval, startDate, endDate, callback) {
22
- (0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculatePercentBad, callback);
23
- }
24
- exports.getPercentBadData = getPercentBadData;
25
- //# sourceMappingURL=percent_bad.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"percent_bad.js","sourceRoot":"","sources":["../source/percent_bad.ts"],"names":[],"mappings":";;;AACA,iEAAkD;AAClD,2DAA8C;AAE9C,qCAA4C;AAE5C,6DAA2D;AAE3D,SAAS,mBAAmB,CAAC,QAAkB,EAAE,OAAsC;IACnF,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAA,wCAAmB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC1E,MAAM,KAAK,GAAG,UAAU,CAAC;IACzB,IAAI,UAAU,CAAC,SAAS,EAAE,EAAE;QACxB,OAAO,IAAI,iCAAS,CAAC;YACjB,eAAe,EAAE,QAAQ,CAAC,SAAS;YACnC,UAAU;YACV,KAAK,EAAE,EAAE,QAAQ,EAAE,6BAAQ,CAAC,MAAM,EAAE,KAAK,EAAE;SAC9C,CAAC,CAAC;KACN;IACD,OAAO,IAAI,iCAAS,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,6BAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAClH,CAAC;AACD,0FAA0F;AAC1F,SAAgB,iBAAiB,CAC7B,IAAgB,EAChB,kBAA0B,EAC1B,SAAe,EACf,OAAa,EACb,QAA+D;IAE/D,IAAA,yBAAgB,EAAC,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;AAClG,CAAC;AARD,8CAQC"}
@@ -1,7 +0,0 @@
1
- import { UAVariable } from "node-opcua-address-space";
2
- import { DataValue } from "node-opcua-data-value";
3
- /**
4
- *
5
- * @param node Retrieve the percentage of data (0 to 100) in the interval which has Good StatusCode.
6
- */
7
- export declare function getPercentGoodData(node: UAVariable, processingInterval: number, startDate: Date, endDate: Date, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPercentGoodData = 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 node_opcua_status_code_1 = require("node-opcua-status-code");
7
- const common_1 = require("./common");
8
- const calculate_bad_good_1 = require("./calculate_bad_good");
9
- function calculatePercentGood(interval, options) {
10
- //
11
- // The PercentGood Aggregate defined in Table 44 performs the following calculation:
12
- //
13
- // PercentGood = DurationGood / ProcessingInterval x 100
14
- // where:
15
- //
16
- // DurationGood is the result from the DurationGood *Aggregate*, calculated using the *ProcessingInterval* supplied to *PercentGood* call.
17
- // ProcessingInterval is the duration of interval.
18
- // If the last interval is a partial interval then the duration of the partial interval is used in the
19
- // calculation.
20
- // Each Aggregate is returned with timestamp of the start of the interval. StatusCodes are Good, Calculated.
21
- //
22
- const { percentGood, statusCode } = (0, calculate_bad_good_1.calculateBadAndGood)(interval, options);
23
- if (percentGood < 0) {
24
- // special case ! to indicate that no good pointhas been found in the interval
25
- return new node_opcua_data_value_1.DataValue({
26
- sourceTimestamp: interval.startTime,
27
- statusCode: node_opcua_status_code_1.StatusCodes.Bad,
28
- value: { dataType: node_opcua_variant_1.DataType.Null }
29
- });
30
- }
31
- const value = percentGood;
32
- if (statusCode.isGoodish()) {
33
- return new node_opcua_data_value_1.DataValue({
34
- sourceTimestamp: interval.startTime,
35
- statusCode,
36
- value: { dataType: node_opcua_variant_1.DataType.Double, value }
37
- });
38
- }
39
- return new node_opcua_data_value_1.DataValue({ sourceTimestamp: interval.startTime, statusCode, value: { dataType: node_opcua_variant_1.DataType.Null } });
40
- }
41
- /**
42
- *
43
- * @param node Retrieve the percentage of data (0 to 100) in the interval which has Good StatusCode.
44
- */
45
- function getPercentGoodData(node, processingInterval, startDate, endDate, callback) {
46
- (0, common_1.getAggregateData)(node, processingInterval, startDate, endDate, calculatePercentGood, callback);
47
- }
48
- exports.getPercentGoodData = getPercentGoodData;
49
- //# sourceMappingURL=percent_good.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"percent_good.js","sourceRoot":"","sources":["../source/percent_good.ts"],"names":[],"mappings":";;;AACA,iEAAkD;AAClD,2DAAuD;AACvD,mEAAsF;AAEtF,qCAA4C;AAE5C,6DAA2D;AAE3D,SAAS,oBAAoB,CAAC,QAAkB,EAAE,OAAsC;IACpF,EAAE;IACF,oFAAoF;IACpF,EAAE;IACF,4DAA4D;IAC5D,SAAS;IACT,EAAE;IACF,0IAA0I;IAC1I,kDAAkD;IAClD,sGAAsG;IACtG,eAAe;IACf,4GAA4G;IAC5G,EAAE;IACF,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,IAAA,wCAAmB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3E,IAAI,WAAW,GAAG,CAAC,EAAE;QACjB,8EAA8E;QAC9E,OAAO,IAAI,iCAAS,CAAC;YACjB,eAAe,EAAE,QAAQ,CAAC,SAAS;YACnC,UAAU,EAAE,oCAAW,CAAC,GAAG;YAC3B,KAAK,EAAE,EAAE,QAAQ,EAAE,6BAAQ,CAAC,IAAI,EAAE;SACrC,CAAC,CAAC;KACN;IACD,MAAM,KAAK,GAAG,WAAW,CAAC;IAC1B,IAAI,UAAU,CAAC,SAAS,EAAE,EAAE;QACxB,OAAO,IAAI,iCAAS,CAAC;YACjB,eAAe,EAAE,QAAQ,CAAC,SAAS;YACnC,UAAU;YACV,KAAK,EAAE,EAAE,QAAQ,EAAE,6BAAQ,CAAC,MAAM,EAAE,KAAK,EAAE;SAC9C,CAAC,CAAC;KACN;IACD,OAAO,IAAI,iCAAS,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,6BAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAClH,CAAC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAC9B,IAAgB,EAChB,kBAA0B,EAC1B,SAAe,EACf,OAAa,EACb,QAA+D;IAE/D,IAAA,yBAAgB,EAAC,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,EAAE,oBAAoB,EAAE,QAAQ,CAAC,CAAC;AACnG,CAAC;AARD,gDAQC"}
@@ -1,6 +0,0 @@
1
- import { ISessionContext, UAVariable, ContinuationData } from "node-opcua-address-space";
2
- import { NumericRange } from "node-opcua-numeric-range";
3
- import { QualifiedNameLike } from "node-opcua-data-model";
4
- import { CallbackT } from "node-opcua-status-code";
5
- import { HistoryReadResult, ReadProcessedDetails } from "node-opcua-service-history";
6
- export declare function readProcessedDetails(variable: UAVariable, context: ISessionContext, historyReadDetails: ReadProcessedDetails, indexRange: NumericRange | null, dataEncoding: QualifiedNameLike | null, continuationData: ContinuationData, callback: CallbackT<HistoryReadResult>): void;
@@ -1,144 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readProcessedDetails = void 0;
4
- const node_opcua_constants_1 = require("node-opcua-constants");
5
- const node_opcua_status_code_1 = require("node-opcua-status-code");
6
- const node_opcua_service_history_1 = require("node-opcua-service-history");
7
- const minmax_1 = require("./minmax");
8
- const interpolate_1 = require("./interpolate");
9
- const average_1 = require("./average");
10
- const count_1 = require("./count");
11
- const percent_bad_1 = require("./percent_bad");
12
- const percent_good_1 = require("./percent_good");
13
- const duration_good_1 = require("./duration_good");
14
- const duration_bad_1 = require("./duration_bad");
15
- function _buildResult(err, dataValues, callback2) {
16
- if (err) {
17
- return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInternalError }));
18
- }
19
- const result = new node_opcua_service_history_1.HistoryReadResult({
20
- historyData: new node_opcua_service_history_1.HistoryData({
21
- dataValues
22
- }),
23
- statusCode: node_opcua_status_code_1.StatusCodes.Good
24
- });
25
- return callback2(null, result);
26
- }
27
- function applyAggregate(variable, processingInterval, startTime, endTime, aggregateType, callback2) {
28
- if (!startTime || !endTime) {
29
- return _buildResult(new Error("Invalid date time"), undefined, callback2);
30
- }
31
- const buildResult = (err, dataValues) => {
32
- _buildResult(err, dataValues, callback2);
33
- };
34
- if (aggregateType.namespace === 0) {
35
- switch (aggregateType.value) {
36
- case node_opcua_constants_1.AggregateFunction.Minimum:
37
- (0, minmax_1.getMinData)(variable, processingInterval, startTime, endTime, buildResult);
38
- break;
39
- case node_opcua_constants_1.AggregateFunction.Maximum:
40
- (0, minmax_1.getMaxData)(variable, processingInterval, startTime, endTime, buildResult);
41
- break;
42
- case node_opcua_constants_1.AggregateFunction.Interpolative:
43
- (0, interpolate_1.getInterpolatedData)(variable, processingInterval, startTime, endTime, buildResult);
44
- break;
45
- case node_opcua_constants_1.AggregateFunction.Average:
46
- (0, average_1.getAverageData)(variable, processingInterval, startTime, endTime, buildResult);
47
- break;
48
- case node_opcua_constants_1.AggregateFunction.DurationGood:
49
- (0, duration_good_1.getDurationGoodData)(variable, processingInterval, startTime, endTime, buildResult);
50
- break;
51
- case node_opcua_constants_1.AggregateFunction.DurationBad:
52
- (0, duration_bad_1.getDurationBadData)(variable, processingInterval, startTime, endTime, buildResult);
53
- break;
54
- case node_opcua_constants_1.AggregateFunction.PercentBad:
55
- (0, percent_bad_1.getPercentBadData)(variable, processingInterval, startTime, endTime, buildResult);
56
- break;
57
- case node_opcua_constants_1.AggregateFunction.PercentGood:
58
- (0, percent_good_1.getPercentGoodData)(variable, processingInterval, startTime, endTime, buildResult);
59
- break;
60
- case node_opcua_constants_1.AggregateFunction.Count:
61
- (0, count_1.getCountData)(variable, processingInterval, startTime, endTime, buildResult);
62
- break;
63
- default:
64
- // todo provide correct implementation
65
- return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadAggregateNotSupported }));
66
- }
67
- }
68
- else {
69
- // custom aggregate added by some companion specification
70
- // to do
71
- return callback2(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadAggregateNotSupported }));
72
- }
73
- }
74
- function readProcessedDetails(variable, context, historyReadDetails, indexRange, dataEncoding, continuationData, callback) {
75
- // OPC Unified Architecture, Part 11 27 Release 1.03
76
- //
77
- // This structure is used to compute Aggregate values, qualities, and timestamps from data in
78
- // the history database for the specified time domain for one or more HistoricalDataNodes. The
79
- // time domain is divided into intervals of duration ProcessingInterval. The specified Aggregate
80
- // Type is calculated for each interval beginning with startTime by using the data within the next
81
- // ProcessingInterval.
82
- // For example, this function can provide hourly statistics such as Maximum, Minimum , and
83
- // Average for each item during the specified time domain when ProcessingInterval is 1 hour.
84
- // The domain of the request is defined by startTime, endTime, and ProcessingInterval. All three
85
- // shall be specified. If endTime is less than startTime then the data shall be returned in reverse
86
- // order with the later data coming first. If startTime and endTime are the same then the Server
87
- // shall return Bad_InvalidArgument as there is no meaningful way to interpret such a case. If
88
- // the ProcessingInterval is specified as 0 then Aggregates shall be calculated using one interval
89
- // starting at startTime and ending at endTime.
90
- // The aggregateType[] parameter allows a Client to request multiple Aggregate calculations per
91
- // requested NodeId. If multiple Aggregates are requested then a corresponding number of
92
- // entries are required in the NodesToRead array.
93
- // For example, to request Min Aggregate for NodeId FIC101, FIC102, and both Min and Max
94
- // Aggregates for NodeId FIC103 would require NodeId FIC103 to appear twice in the
95
- // NodesToRead array request parameter.
96
- // aggregateType[] NodesToRead[]
97
- // Min FIC101
98
- // Min FIC102
99
- // Min FIC103
100
- // Max FIC103
101
- // If the array of Aggregates does not match the array of NodesToRead then the Server shall
102
- // return a StatusCode of Bad_AggregateListMismatch.
103
- // The aggregateConfiguration parameter allows a Client to override the Aggregate configuration
104
- // settings supplied by the AggregateConfiguration Object on a per call basis. See Part 13 for
105
- // more information on Aggregate configurations. If the Server does not support the ability to
106
- // override the Aggregate configuration settings then it shall return a StatusCode of Bad_
107
- // AggregateConfigurationRejected. If the Aggregate is not valid for the Node then the
108
- // StatusCode shall be Bad_AggregateNotSupported.
109
- // The values used in computing the Aggregate for each interval shall include any value that
110
- // falls exactly on the timestamp at the beginning of the interval, but shall not include any value
111
- // that falls directly on the timestamp ending the interval. Thus, each value shall be included
112
- // only once in the calculation. If the time domain is in reverse order then we consider the later
113
- // timestamp to be the one beginning the sub interval, and the earlier timestamp to be the one
114
- // ending it. Note that this means that simply swapping the start and end times will not result in
115
- // getting the same values back in reverse order as the intervals being requested in the two
116
- // cases are not the same.
117
- // If an Aggregate is taking a long time to calculate then the Server can return partial results
118
- // with a continuation point. This might be done if the calculation is going to take more time th an
119
- // the Client timeout hint. In some cases it may take longer than the Client timeout hint to
120
- // calculate even one Aggregate result. Then the Server may return zero results with a
121
- // continuation point that allows the Server to resume the calculation on the next Client read
122
- // call.
123
- const startTime = historyReadDetails.startTime;
124
- const endTime = historyReadDetails.endTime;
125
- if (!startTime || !endTime) {
126
- return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument }));
127
- }
128
- if (startTime.getTime() === endTime.getTime()) {
129
- // Start = End Int = Anything No intervals. Returns a Bad_InvalidArgument StatusCode,
130
- // regardless of whether there is data at the specified time or not
131
- return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument }));
132
- }
133
- const aggregateTypes = historyReadDetails.aggregateType || [];
134
- // If the ProcessingInterval is specified as 0 then Aggregates shall be calculated using one interval
135
- // starting at startTime and ending at endTime.
136
- const processingInterval = historyReadDetails.processingInterval || endTime.getTime() - startTime.getTime();
137
- // tslint:disable-next-line: prefer-for-of
138
- if (!historyReadDetails.aggregateType || historyReadDetails.aggregateType.length !== 1) {
139
- return callback(null, new node_opcua_service_history_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadInternalError }));
140
- }
141
- return applyAggregate(variable, processingInterval, startTime, endTime, aggregateTypes[0], callback);
142
- }
143
- exports.readProcessedDetails = readProcessedDetails;
144
- //# sourceMappingURL=read_processed_details.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"read_processed_details.js","sourceRoot":"","sources":["../source/read_processed_details.ts"],"names":[],"mappings":";;;AAAA,+DAAyD;AAIzD,mEAAgE;AAGhE,2EAAkG;AAElG,qCAAkD;AAElD,+CAAoD;AACpD,uCAA2C;AAC3C,mCAAuC;AACvC,+CAAkD;AAClD,iDAAoD;AACpD,mDAAsD;AACtD,iDAAoD;AAEpD,SAAS,YAAY,CAAC,GAAiB,EAAE,UAAmC,EAAE,SAAuC;IACjH,IAAI,GAAG,EAAE;QACL,OAAO,SAAS,CAAC,IAAI,EAAE,IAAI,8CAAiB,CAAC,EAAE,UAAU,EAAE,oCAAW,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;KAC/F;IACD,MAAM,MAAM,GAAG,IAAI,8CAAiB,CAAC;QACjC,WAAW,EAAE,IAAI,wCAAW,CAAC;YACzB,UAAU;SACb,CAAC;QACF,UAAU,EAAE,oCAAW,CAAC,IAAI;KAC/B,CAAC,CAAC;IACH,OAAO,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,cAAc,CACnB,QAAoB,EACpB,kBAA0B,EAC1B,SAAe,EACf,OAAa,EACb,aAAqB,EACrB,SAAuC;IAEvC,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE;QACxB,OAAO,YAAY,CAAC,IAAI,KAAK,CAAC,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