Merge commit '12fce6c' into HEAD
# Conflicts: # index.js # src/configs/index.js # src/configs/machineGroupControl.json # src/helper/assetUtils.js # src/helper/childRegistrationUtils.js # src/helper/configUtils.js # src/helper/logger.js # src/helper/menuUtils.js # src/helper/menuUtils_DEPRECATED.js # src/helper/outputUtils.js # src/helper/validationUtils.js # src/measurements/Measurement.js # src/measurements/MeasurementContainer.js # src/measurements/examples.js # src/outliers/outlierDetection.js
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const MeasurementBuilder = require('./MeasurementBuilder');
|
||||
const EventEmitter = require('events');
|
||||
const convertModule = require('../convert/index');
|
||||
const { POSITIONS } = require('../constants/positions');
|
||||
|
||||
class MeasurementContainer {
|
||||
constructor(options = {},logger) {
|
||||
@@ -478,7 +479,7 @@ class MeasurementContainer {
|
||||
getLaggedSample(lag = 1,requestedUnit = null ){
|
||||
const measurement = this.get();
|
||||
if (!measurement) return null;
|
||||
|
||||
|
||||
let sample = measurement.getLaggedSample(lag);
|
||||
if (sample === null) return null;
|
||||
|
||||
@@ -554,7 +555,7 @@ class MeasurementContainer {
|
||||
}
|
||||
|
||||
// Difference calculations between positions
|
||||
difference({ from = "downstream", to = "upstream", unit: requestedUnit } = {}) {
|
||||
difference({ from = POSITIONS.DOWNSTREAM, to = POSITIONS.UPSTREAM, unit: requestedUnit } = {}) {
|
||||
if (!this._currentType || !this._currentVariant) {
|
||||
if (this.logger) {
|
||||
this.logger.warn('difference() ignored: type and variant must be specified');
|
||||
@@ -682,6 +683,8 @@ class MeasurementContainer {
|
||||
this._currentType = null;
|
||||
this._currentVariant = null;
|
||||
this._currentPosition = null;
|
||||
this._currentDistance = null;
|
||||
this._unit = null;
|
||||
}
|
||||
|
||||
// Helper method for value conversion
|
||||
@@ -739,11 +742,11 @@ class MeasurementContainer {
|
||||
|
||||
_convertPositionStr2Num(positionString) {
|
||||
switch(positionString) {
|
||||
case "atEquipment":
|
||||
case POSITIONS.AT_EQUIPMENT:
|
||||
return 0;
|
||||
case "upstream":
|
||||
case POSITIONS.UPSTREAM:
|
||||
return Number.POSITIVE_INFINITY;
|
||||
case "downstream":
|
||||
case POSITIONS.DOWNSTREAM:
|
||||
return Number.NEGATIVE_INFINITY;
|
||||
|
||||
default:
|
||||
@@ -756,13 +759,13 @@ class MeasurementContainer {
|
||||
|
||||
_convertPositionNum2Str(positionValue) {
|
||||
if (positionValue === 0) {
|
||||
return "atEquipment";
|
||||
return POSITIONS.AT_EQUIPMENT;
|
||||
}
|
||||
if (positionValue < 0) {
|
||||
return "upstream";
|
||||
return POSITIONS.UPSTREAM;
|
||||
}
|
||||
if (positionValue > 0) {
|
||||
return "downstream";
|
||||
return POSITIONS.DOWNSTREAM;
|
||||
}
|
||||
if (this.logger) {
|
||||
this.logger.warn(`Invalid position provided: ${positionValue}`);
|
||||
|
||||
Reference in New Issue
Block a user