/
test_aggregates.ts
490 lines (435 loc) · 24.2 KB
/
test_aggregates.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
import { DataValue } from "node-opcua-data-value";
import { getInterpolatedData } from "../source";
import { addAggregateSupport, getAggregateConfiguration } from "../source/aggregates";
import {
createHistorian1,
createHistorian2,
createHistorian3,
createHistorian4
} from "./helpers/create_historizing_variables";
import * as opcua from "node-opcua";
import { makeDate } from "./helpers/helpers";
import * as should from "should";
import { getMaxData, getMinData } from "../source";
const _should = should;
describe("Aggregates ", () => {
let addressSpace: any;
beforeEach((done) => {
addressSpace = opcua.AddressSpace.create();
const nodesets: string[] = [
opcua.nodesets.standard_nodeset_file
];
opcua.generateAddressSpace(addressSpace, nodesets, (err?: Error) => {
done(err);
});
});
it("should augment the addressSpace with aggregate function support", (done) => {
addAggregateSupport(addressSpace);
done();
});
});
describe("Aggregates - Function ", () => {
let addressSpace: any;
let h1: any;
let h2: any;
let h3: any;
let h4: any;
before((done: (err: Error | null) => void) => {
addressSpace = opcua.AddressSpace.create();
const nodesets: string[] = [
opcua.nodesets.standard_nodeset_file
];
opcua.generateAddressSpace(addressSpace, nodesets, (err?: Error) => {
const namespace = addressSpace.registerNamespace("PRIVATENAMESPACE");
namespace.index.should.eql(1);
should.exist(addressSpace.getOwnNamespace());
addAggregateSupport(addressSpace);
h1 = createHistorian1(addressSpace);
h2 = createHistorian2(addressSpace);
h3 = createHistorian3(addressSpace);
h4 = createHistorian4(addressSpace);
done(err!);
});
});
after((done) => {
addressSpace.dispose();
done();
});
function n(num: number): string {
const s1 = num.toString();
const s2 = num.toFixed(3);
return (s1.length <= s2.length) ? s1 : s2;
}
function getInfo(dataValue: DataValue): string {
const d = dataValue.sourceTimestamp!;
const s = d.toISOString().split("T")[1];
const v = (dataValue.value && dataValue.value.value !== undefined && dataValue.value.value !== null)
? n(dataValue.value.value) + " " : "";
const retVal = s + " " + v + dataValue.statusCode.toString().split(" ")[0];
// console.log(retVal);
return retVal;
}
it("Aggregate Interpolate with History1 use case", (done) => {
const startDate = makeDate("12:00:00");
const endDate = makeDate("12:01:40");
getInterpolatedData(h1, 5000, startDate, endDate,
(err: Error | null, dataValues?: DataValue[]) => {
if (err) {
return done(err);
}
dataValues = dataValues!;
// Timestamp Value StatusCode Notes
// 12:00:00.000 BadNoData
getInfo(dataValues[0]).should.eql("12:00:00.000Z BadNoData");
// 12:00:05.000 BadNoData
getInfo(dataValues[1]).should.eql("12:00:05.000Z BadNoData");
// 12:00:10.000 10 Good
getInfo(dataValues[2]).should.eql("12:00:10.000Z 10 Good");
// 12:00:15.000 15 Good, Interpolated
getInfo(dataValues[3]).should.eql("12:00:15.000Z 15 Good#HistorianInterpolated");
// 12:00:20.000 20 Good
getInfo(dataValues[4]).should.eql("12:00:20.000Z 20 Good");
// 12:00:25.000 25 Good, Interpolated
getInfo(dataValues[5]).should.eql("12:00:25.000Z 25 Good#HistorianInterpolated");
// 12:00:30.000 30 Good
getInfo(dataValues[6]).should.eql("12:00:30.000Z 30 Good");
// 12:00:35.000 35 UncertainDataSubNormal, Interpolated
getInfo(dataValues[7]).should.eql("12:00:35.000Z 35 UncertainDataSubNormal#HistorianInterpolated");
// 12:00:40.000 40 UncertainDataSubNormal, Interpolated
getInfo(dataValues[8]).should.eql("12:00:40.000Z 40 UncertainDataSubNormal#HistorianInterpolated");
// 12:00:45.000 45 UncertainDataSubNormal, Interpolated
getInfo(dataValues[9]).should.eql("12:00:45.000Z 45 UncertainDataSubNormal#HistorianInterpolated");
// 12:00:50.000 50 Good
getInfo(dataValues[10]).should.eql("12:00:50.000Z 50 Good");
// 12:00:55.000 55 Good, Interpolated
getInfo(dataValues[11]).should.eql("12:00:55.000Z 55 Good#HistorianInterpolated");
// 12:01:00.000 60 Good
getInfo(dataValues[12]).should.eql("12:01:00.000Z 60 Good");
// 12:01:05.000 65 UncertainDataSubNormal, Interpolated
getInfo(dataValues[13]).should.eql("12:01:05.000Z 65 UncertainDataSubNormal#HistorianInterpolated");
// 12:01:10.000 70 Uncertain
getInfo(dataValues[14]).should.eql("12:01:10.000Z 70 Uncertain");
// 12:01:15.000 75 UncertainDataSubNormal, Interpolated
getInfo(dataValues[15]).should.eql("12:01:15.000Z 75 UncertainDataSubNormal#HistorianInterpolated");
// 12:01:20.000 80 Good
getInfo(dataValues[16]).should.eql("12:01:20.000Z 80 Good");
// 12:01:25.000 85 Good, Interpolated
getInfo(dataValues[17]).should.eql("12:01:25.000Z 85 Good#HistorianInterpolated");
// 12:01:30.000 90 Good
getInfo(dataValues[18]).should.eql("12:01:30.000Z 90 Good");
// 12:01:35.000 90 UncertainDataSubNormal, Interpolated
getInfo(dataValues[19]).should.eql("12:01:35.000Z 90 UncertainDataSubNormal#HistorianInterpolated");
done();
});
});
it("Aggregate Interpolate with History2 use case", (done) => {
const startDate = makeDate("12:00:00");
const endDate = makeDate("12:01:40");
getInterpolatedData(h2, 5000, startDate, endDate,
(err: Error | null, dataValues?: DataValue[]) => {
if (err) {
return done(err);
}
dataValues = dataValues!;
// Timestamp Value StatusCode Notes
// 12:00:00.000 BadNoData
getInfo(dataValues[0]).should.eql("12:00:00.000Z BadNoData");
// 12:00:05.000 11.304 Good, Interpolated
getInfo(dataValues[1]).should.eql("12:00:05.000Z 11.304 Good#HistorianInterpolated");
// 12:00:10.000 13.478 Good, Interpolated
getInfo(dataValues[2]).should.eql("12:00:10.000Z 13.478 Good#HistorianInterpolated");
// 12:00:15.000 15.652 Good, Interpolated
getInfo(dataValues[3]).should.eql("12:00:15.000Z 15.652 Good#HistorianInterpolated");
// 12:00:20.000 17.826 Good, Interpolated
getInfo(dataValues[4]).should.eql("12:00:20.000Z 17.826 Good#HistorianInterpolated");
// 12:00:25.000 20 Good
getInfo(dataValues[5]).should.eql("12:00:25.000Z 20 Good");
// 12:00:30.000 25.909 Good, Interpolated
getInfo(dataValues[6]).should.eql("12:00:30.000Z 25.909 Good#HistorianInterpolated");
// 12:00:35.000 28.182 Good, Interpolated
getInfo(dataValues[7]).should.eql("12:00:35.000Z 28.182 Good#HistorianInterpolated");
// 12:00:40.000 31.111 UncertainDataSubNormal, Interpolated
getInfo(dataValues[8]).should.eql("12:00:40.000Z 31.111 UncertainDataSubNormal#HistorianInterpolated");
// 12:00:45.000 36.667 UncertainDataSubNormal, Interpolated
getInfo(dataValues[9]).should.eql("12:00:45.000Z 36.667 UncertainDataSubNormal#HistorianInterpolated");
// 12:00:50.000 45 Good, Interpolated
getInfo(dataValues[10]).should.eql("12:00:50.000Z 45 Good#HistorianInterpolated");
// 12:00:55.000 51.500 Good, Interpolated
getInfo(dataValues[11]).should.eql("12:00:55.000Z 51.5 Good#HistorianInterpolated");
// 12:01:00.000 54 Good, Interpolated
getInfo(dataValues[12]).should.eql("12:01:00.000Z 54 Good#HistorianInterpolated");
// 12:01:05.000 56.500 Good, Interpolated
getInfo(dataValues[13]).should.eql("12:01:05.000Z 56.5 Good#HistorianInterpolated");
// 12:01:10.000 59 Good, Interpolated
getInfo(dataValues[14]).should.eql("12:01:10.000Z 59 Good#HistorianInterpolated");
// 12:01:15.000 62.727 UncertainDataSubNormal, Interpolated
getInfo(dataValues[15]).should.eql("12:01:15.000Z 62.727 UncertainDataSubNormal#HistorianInterpolated");
// 12:01:20.000 67.273 UncertainDataSubNormal, Interpolated
getInfo(dataValues[16]).should.eql("12:01:20.000Z 67.273 UncertainDataSubNormal#HistorianInterpolated");
// 12:01:25.000 76.667 Good, Interpolated
getInfo(dataValues[17]).should.eql("12:01:25.000Z 76.667 Good#HistorianInterpolated");
// 12:01:30.000 90 Good
getInfo(dataValues[18]).should.eql("12:01:30.000Z 90 Good");
// 12:01:35.000 90 UncertainDataSubNormal, Interpolated
getInfo(dataValues[19]).should.eql("12:01:35.000Z 90 UncertainDataSubNormal#HistorianInterpolated");
done();
});
});
it("Aggregate Interpolate with History3 use case", (done) => {
const startDate = makeDate("12:00:00");
const endDate = makeDate("12:01:40");
const configuration = getAggregateConfiguration(h3);
configuration.treatUncertainAsBad!.should.eql(true);
configuration.stepped!.should.eql(true);
configuration.useSlopedExtrapolation!.should.eql(false);
// xx configuration.percentDataBad.should.eql(50);
// xx configuration.percentDataGood.should.eql(50);
getInterpolatedData(h3, 5000, startDate, endDate,
(err: Error | null, dataValues?: DataValue[]) => {
if (err) {
return done(err);
}
dataValues = dataValues!;
// Timestamp Value StatusCode Notes
// 12:00:00.000 BadNoData
// 12:00:00.000 BadNoData
getInfo(dataValues[0]).should.eql("12:00:00.000Z BadNoData");
// 12:00:05.000 10 Good, Interpolated
getInfo(dataValues[1]).should.eql("12:00:05.000Z 10 Good#HistorianInterpolated");
// 12:00:10.000 10 Good, Interpolated
getInfo(dataValues[2]).should.eql("12:00:10.000Z 10 Good#HistorianInterpolated");
// 12:00:15.000 10 Good, Interpolated
getInfo(dataValues[3]).should.eql("12:00:15.000Z 10 Good#HistorianInterpolated");
// 12:00:20.000 10 Good, Interpolated
getInfo(dataValues[4]).should.eql("12:00:20.000Z 10 Good#HistorianInterpolated");
// 12:00:25.000 20 Good
getInfo(dataValues[5]).should.eql("12:00:25.000Z 20 Good");
// 12:00:30.000 25 Good, Interpolated
getInfo(dataValues[6]).should.eql("12:00:30.000Z 25 Good#HistorianInterpolated");
// 12:00:35.000 25 Good, Interpolated
getInfo(dataValues[7]).should.eql("12:00:35.000Z 25 Good#HistorianInterpolated");
// 12:00:40.000 30 Good, Interpolated
getInfo(dataValues[8]).should.eql("12:00:40.000Z 30 Good#HistorianInterpolated");
// 12:00:45.000 30 UncertainDataSubNormal, Interpolated
getInfo(dataValues[9]).should.eql("12:00:45.000Z 30 UncertainDataSubNormal#HistorianInterpolated");
// 12:00:50.000 40 Good, Interpolated
getInfo(dataValues[10]).should.eql("12:00:50.000Z 40 Good#HistorianInterpolated");
// 12:00:55.000 50 Good, Interpolated
getInfo(dataValues[11]).should.eql("12:00:55.000Z 50 Good#HistorianInterpolated");
// 12:01:00.000 50 Good, Interpolated
getInfo(dataValues[12]).should.eql("12:01:00.000Z 50 Good#HistorianInterpolated");
// 12:01:05.000 50 Good, Interpolated
getInfo(dataValues[13]).should.eql("12:01:05.000Z 50 Good#HistorianInterpolated");
// 12:01:10.000 50 Good, Interpolated
getInfo(dataValues[14]).should.eql("12:01:10.000Z 50 Good#HistorianInterpolated");
// 12:01:15.000 60 Good, Interpolated
getInfo(dataValues[15]).should.eql("12:01:15.000Z 60 Good#HistorianInterpolated");
// 12:01:20.000 60 UncertainDataSubNormal, Interpolated
getInfo(dataValues[16]).should.eql("12:01:20.000Z 60 UncertainDataSubNormal#HistorianInterpolated");
// 12:01:25.000 70 Good, Interpolated
getInfo(dataValues[17]).should.eql("12:01:25.000Z 70 Good#HistorianInterpolated");
// 12:01:30.000 90 Good
getInfo(dataValues[18]).should.eql("12:01:30.000Z 90 Good");
// 12:01:35.000 90 UncertainDataSubNormal, Interpolated
getInfo(dataValues[19]).should.eql("12:01:35.000Z 90 UncertainDataSubNormal#HistorianInterpolated");
done();
});
});
it("Aggregate Min with History1 use case", (done) => {
const startDate = makeDate("12:00:00");
const endDate = makeDate("12:01:40");
getMinData(h1, 16 * 1000, startDate, endDate,
(err: Error | null, dataValues?: DataValue[]) => {
if (err) {
return done(err);
}
dataValues = dataValues!;
// Timestamp Value StatusCode Notes
// 12:00:00.000 10 Good, Calculated, Partial
getInfo(dataValues[0]).should.eql("12:00:00.000Z 10 Good#HistorianCalculated|HistorianPartial");
// 12:00:16.000 20 Good, Calculated
getInfo(dataValues[1]).should.eql("12:00:16.000Z 20 Good#HistorianCalculated");
// 12:00:32.000 BadNoData
getInfo(dataValues[2]).should.eql("12:00:32.000Z BadNoData");
// 12:00:48.000 50 Good, Calculated
getInfo(dataValues[3]).should.eql("12:00:48.000Z 50 Good#HistorianCalculated");
// 12:01:04.000 BadNoData
getInfo(dataValues[4]).should.eql("12:01:04.000Z BadNoData");
// 12:01:20.000 80 Good, Partial
getInfo(dataValues[5]).should.eql("12:01:20.000Z 80 Good#HistorianPartial");
// 12:01:36.000 BadNoData
getInfo(dataValues[6]).should.eql("12:01:36.000Z BadNoData");
done();
});
});
it("Aggregate Min with History2 use case", (done) => {
const startDate = makeDate("12:00:00");
const endDate = makeDate("12:01:40");
getMinData(h2, 16 * 1000, startDate, endDate,
(err: Error | null, dataValues?: DataValue[]) => {
if (err) {
return done(err);
}
dataValues = dataValues!;
// 12:00:00.000 10 Good, Calculated, Partial
getInfo(dataValues[0]).should.eql("12:00:00.000Z 10 Good#HistorianCalculated|HistorianPartial");
// 12:00:16.000 20 Good, Calculated
getInfo(dataValues[1]).should.eql("12:00:16.000Z 20 Good#HistorianCalculated");
// 12:00:32.000 30 UncertainDataSubNormal, Calculated
getInfo(dataValues[2]).should.eql("12:00:32.000Z 30 UncertainDataSubNormal#HistorianCalculated");
// 12:00:48.000 40 Good
getInfo(dataValues[3]).should.eql("12:00:48.000Z 40 Good");
// 12:01:04.000 60 UncertainDataSubNormal, Calculated
getInfo(dataValues[4]).should.eql("12:01:04.000Z 60 UncertainDataSubNormal#HistorianCalculated");
// 12:01:20.000 70 Good, Calculated, Partial
getInfo(dataValues[5]).should.eql("12:01:20.000Z 70 Good#HistorianCalculated|HistorianPartial");
// 12:01:36.000 BadNoData
getInfo(dataValues[6]).should.eql("12:01:36.000Z BadNoData");
done();
});
});
it("Aggregate Min with History3 use case", (done) => {
const startDate = makeDate("12:00:00");
const endDate = makeDate("12:01:40");
getMinData(h3, 16 * 1000, startDate, endDate,
(err: Error | null, dataValues?: DataValue[]) => {
if (err) {
return done(err);
}
dataValues = dataValues!;
// 12:00:00.000 10 Good, Calculated, Partial
getInfo(dataValues[0]).should.eql("12:00:00.000Z 10 Good#HistorianCalculated|HistorianPartial");
// 12:00:16.000 20 Good, Calculated
getInfo(dataValues[1]).should.eql("12:00:16.000Z 20 Good#HistorianCalculated");
// 12:00:32.000 30 UncertainDataSubNormal, Calculated
getInfo(dataValues[2]).should.eql("12:00:32.000Z 30 UncertainDataSubNormal#HistorianCalculated");
// 12:00:48.000 40 Good
getInfo(dataValues[3]).should.eql("12:00:48.000Z 40 Good");
// 12:01:04.000 60 UncertainDataSubNormal, Calculated
getInfo(dataValues[4]).should.eql("12:01:04.000Z 60 UncertainDataSubNormal#HistorianCalculated");
// 12:01:20.000 70 Good, Calculated, Partial
getInfo(dataValues[5]).should.eql("12:01:20.000Z 70 Good#HistorianCalculated|HistorianPartial");
// 12:01:36.000 BadNoData
getInfo(dataValues[6]).should.eql("12:01:36.000Z BadNoData");
done();
});
});
it("Aggregate Max with History1 use case", (done) => {
const startDate = makeDate("12:00:00");
const endDate = makeDate("12:01:40");
getMaxData(h1, 16 * 1000, startDate, endDate,
(err: Error | null, dataValues?: DataValue[]) => {
if (err) {
return done(err);
}
dataValues = dataValues!;
// Timestamp Value StatusCode Notes
// 12:00:00.000 10 Good, Calculated, Partial
getInfo(dataValues[0]).should.eql("12:00:00.000Z 10 Good#HistorianCalculated|HistorianPartial");
// 12:00:16.000 30 Good, Calculated
getInfo(dataValues[1]).should.eql("12:00:16.000Z 30 Good#HistorianCalculated");
// 12:00:32.000 BadNoData
getInfo(dataValues[2]).should.eql("12:00:32.000Z BadNoData");
// 12:00:48.000 60 Good, Calculated
getInfo(dataValues[3]).should.eql("12:00:48.000Z 60 Good#HistorianCalculated");
// 12:01:04.000 BadNoData
getInfo(dataValues[4]).should.eql("12:01:04.000Z BadNoData");
// 12:01:20.000 90 Good, Calculated, Partial
getInfo(dataValues[5]).should.eql("12:01:20.000Z 90 Good#HistorianPartial");
// 12:01:36.000 BadNoData
getInfo(dataValues[6]).should.eql("12:01:36.000Z BadNoData");
done();
});
});
it("Aggregate Max with History2 use case", (done) => {
const startDate = makeDate("12:00:00");
const endDate = makeDate("12:01:40");
getMaxData(h2, 16 * 1000, startDate, endDate,
(err: Error | null, dataValues?: DataValue[]) => {
if (err) {
return done(err);
}
dataValues = dataValues!;
// 12:00:00.000 10 Good, Calculated, Partial
getInfo(dataValues[0]).should.eql("12:00:00.000Z 10 Good#HistorianCalculated|HistorianPartial");
// 12:00:16.000 25 Good, Calculated
getInfo(dataValues[1]).should.eql("12:00:16.000Z 25 Good#HistorianCalculated");
// 12:00:32.000 30 UncertainDataSubNormal, Calculated
getInfo(dataValues[2]).should.eql("12:00:32.000Z 30 UncertainDataSubNormal#HistorianCalculated");
// 12:00:48.000 50 Good, Calculated
getInfo(dataValues[3]).should.eql("12:00:48.000Z 50 Good");
// 12:01:04.000 60 UncertainDataSubNormal, Calculated
getInfo(dataValues[4]).should.eql("12:01:04.000Z 60 UncertainDataSubNormal#HistorianCalculated");
// 12:01:20.000 90 Good, Calculated, Partial
getInfo(dataValues[5]).should.eql("12:01:20.000Z 90 Good#HistorianCalculated|HistorianPartial");
// 12:01:36.000 BadNoData
getInfo(dataValues[6]).should.eql("12:01:36.000Z BadNoData");
done();
});
});
it("Aggregate Max with History3 use case", (done) => {
const startDate = makeDate("12:00:00");
const endDate = makeDate("12:01:40");
getMaxData(h3, 16 * 1000, startDate, endDate,
(err: Error | null, dataValues?: DataValue[]) => {
if (err) {
return done(err);
}
dataValues = dataValues!;
// 12:00:00.000 10 Good, Calculated, Partial
getInfo(dataValues[0]).should.eql("12:00:00.000Z 10 Good#HistorianCalculated|HistorianPartial");
// 12:00:16.000 25 Good, Calculated
getInfo(dataValues[1]).should.eql("12:00:16.000Z 25 Good#HistorianCalculated");
// 12:00:32.000 30 UncertainDataSubNormal, Calculated
getInfo(dataValues[2]).should.eql("12:00:32.000Z 30 UncertainDataSubNormal#HistorianCalculated");
// 12:00:48.000 50 Good, Calculated
getInfo(dataValues[3]).should.eql("12:00:48.000Z 50 Good");
// 12:01:04.000 60 UncertainDataSubNormal, Calculated
getInfo(dataValues[4]).should.eql("12:01:04.000Z 60 UncertainDataSubNormal#HistorianCalculated");
// 12:01:20.000 90 Good, Calculated, Partial
getInfo(dataValues[5]).should.eql("12:01:20.000Z 90 Good#HistorianCalculated|HistorianPartial");
// 12:01:36.000 BadNoData
getInfo(dataValues[6]).should.eql("12:01:36.000Z BadNoData");
done();
});
});
});
// bounding values
// values at the startTime and endTime needed for Aggregates to compute the result
//
// Note 1 to entry: If Raw data does not exist at the startTime and endTime a value shall be estimated. There are
// two ways to determine Bounding Values for an interval. One way (called Interpolated Bounding Values) uses the
// first non-Bad data points found before and after the timestamp to estimate the bound. The other (called Simple
// Bounding Values) uses the data points immediately before and after the boundary timestamps to estimate the
// bound even if these points are Bad. Subclauses 3.1.8 and 3.1.9 describe the two different approaches in more
// detail.
// In all cases the TreatUncertainAsBad (see 4.2.1.2) flag is used to determine whether Uncertain values are Bad or
// non-Bad.
// If a Raw value was not found and a non-Bad bounding value exists the Aggregate Bits (see 5.3.3) are set to
// ‘Interpolated’
// When calculating bounding values, the value portion of Raw data that has Bad status is set to null. This means the
// value portion is not used in any calculation and a null is returned if the raw value is returned.
// The status portion is determined by the rules specified by the bound or Aggregate.
// The Interpolated Bounding Values approach (see 3.1.8) is the same as what is used in Classic OPC Historical Data
// Access (HDA) and is important for applications such as advanced process control where having useful value s at all
// times is important. The Simple Bounding Values approach (see 3.1.9) is new in this standard and is important for
// applications which shall produce regulatory reports and cannot use estimated values in place of Bad data.
//
// const RegionColor = {Red: "Red", Orane: "Orange", Green: "Green"};
// class Region {
//
// constructor(options) {
// this.parentInterval = options.parentInterval;
// this.dataValue1 = options.dataValue1;
// this.dataValue2 = options.dataValue2;
//
// }
// public isUncertain() {
// // A region is Uncertain if a region ends in a Bad or Uncertain value and SlopedInterpolation is
// // used. The end point has no effect on the region if SteppedInterpolation is used.
//
// }
// public duration() {
// // duration of the region within it's parent interval
// }
// }