Updated distance in measurement helper so its a settable compoment. See example.js file in measurement helper folder
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
const convertModule = require('../convert/index');
|
||||
|
||||
class Measurement {
|
||||
constructor(type, variant, position, windowSize) {
|
||||
constructor(type, variant, position, windowSize, distance = null) {
|
||||
this.type = type; // e.g. 'pressure', 'flow', etc.
|
||||
this.variant = variant; // e.g. 'predicted' or 'measured', etc..
|
||||
this.position = position; // Downstream or upstream of parent object
|
||||
this.windowSize = windowSize; // Rolling window size
|
||||
this.distance = distance; // Distance from parent, if applicable
|
||||
|
||||
// Place all data inside an array
|
||||
this.values = []; // Array to store all values
|
||||
@@ -36,13 +37,12 @@ class Measurement {
|
||||
return this;
|
||||
}
|
||||
|
||||
setDistance(distance) {
|
||||
this.distance = distance;
|
||||
return this;
|
||||
}
|
||||
|
||||
setValue(value, timestamp = Date.now()) {
|
||||
/*
|
||||
if (value === undefined || value === null) {
|
||||
value = null ;
|
||||
//throw new Error('Value cannot be null or undefined');
|
||||
}
|
||||
*/
|
||||
|
||||
//shift the oldest value
|
||||
if(this.values.length >= this.windowSize){
|
||||
@@ -168,7 +168,8 @@ class Measurement {
|
||||
this.type,
|
||||
this.variant,
|
||||
this.position,
|
||||
this.windowSize
|
||||
this.windowSize,
|
||||
this.distance
|
||||
);
|
||||
|
||||
// Copy values and timestamps
|
||||
|
||||
Reference in New Issue
Block a user