Compare commits

...

23 Commits

Author SHA1 Message Date
f93603c182 Merge pull request 'Add distance float position handling with backward compatibility' (#1) from p.vanderwilt/generalFunctions:main into main
Reviewed-on: #1
2025-09-26 11:41:53 +00:00
c261335df5 Fix comparison operator in _convertPositionNum2Str method 2025-09-25 13:54:12 +02:00
a41f053d5d Merge branch 'position-float' 2025-09-24 13:38:50 +02:00
8d7d98f126 Fix inversion bug 2025-09-23 14:31:09 +02:00
3f90685834 Enhance position handling by adding utility methods for conversion 2025-09-23 14:17:42 +02:00
6d30e25daa Add string handling for position 2025-09-17 14:52:25 +02:00
16e202e841 Refactor position handling in MeasurementContainer to use position values instead of names 2025-09-17 13:21:35 +02:00
3876f86530 Merge branch 'main' into fix-missing-references 2025-09-15 15:11:39 +02:00
56be0f1840 Merge remote-tracking branch 'upstream/main' 2025-09-15 15:10:34 +02:00
302e122387 Fixing the same bug in reference, again 2025-09-05 13:39:15 +02:00
6dcd3c3d26 Merge pull request 'implement-reactor-child' (#2) from implement-reactor-child into main
Reviewed-on: p.vanderwilt/generalFunctions#2
2025-09-03 10:18:21 +00:00
958ec2269c Print reactors state after configuration 2025-09-03 11:13:00 +02:00
0bccad05f8 Added error message to node registration 2025-08-01 12:30:12 +02:00
7191e57aea Improved reactor registration 2025-07-31 14:57:38 +02:00
aec2d3692d Fixed missing reference to position 2025-07-31 11:36:42 +02:00
71643375fc Added additional reactor handling 2025-07-24 15:09:04 +02:00
f13ee68938 merge upstream 2025-07-22 11:00:42 +00:00
475caa90db Fixed bugs in connectReactor 2025-07-21 17:32:00 +02:00
9aa38f9000 Merge pull request 'Implement Reactor parent-child' (#1) from implement-reactor-child into main
Reviewed-on: p.vanderwilt/generalFunctions#1
2025-07-21 12:29:42 +00:00
4a6273b037 Merge branch 'main' into implement-reactor-child 2025-07-21 14:15:51 +02:00
8c9301b128 Remove undefined reference to 'desc' 2025-07-21 14:14:30 +02:00
7cdfc87c83 Add state update on recieving child signal 2025-07-16 16:04:32 +02:00
839ae2f3da feat: add reactor registration and handling in ChildRegistrationUtils 2025-07-16 15:34:58 +02:00
2 changed files with 50 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ const outputUtils = require('./src/helper/outputUtils.js');
const logger = require('./src/helper/logger.js'); const logger = require('./src/helper/logger.js');
const validation = require('./src/helper/validationUtils.js'); const validation = require('./src/helper/validationUtils.js');
const configUtils = require('./src/helper/configUtils.js'); const configUtils = require('./src/helper/configUtils.js');
const assertions = require('./src/helper/assertionUtils.js')
// Domain-specific modules // Domain-specific modules
const { MeasurementContainer } = require('./src/measurements/index.js'); const { MeasurementContainer } = require('./src/measurements/index.js');
@@ -34,6 +35,7 @@ module.exports = {
configUtils, configUtils,
logger, logger,
validation, validation,
assertions,
MeasurementContainer, MeasurementContainer,
nrmse, nrmse,
state, state,

View File

@@ -88,11 +88,18 @@ class MeasurementContainer {
return this; return this;
} }
position(positionName) { position(positionValue) {
if (!this._currentVariant) { if (!this._currentVariant) {
throw new Error('Variant must be specified before position'); throw new Error('Variant must be specified before position');
} }
this._currentPosition = positionName;
// Turn string positions into numeric values
if (typeof positionValue == "string") {
positionValue = this._convertPositionStr2Num(positionValue);
}
this._currentPosition = positionValue;
return this; return this;
} }
@@ -243,10 +250,12 @@ class MeasurementContainer {
const savedPosition = this._currentPosition; const savedPosition = this._currentPosition;
// Get upstream and downstream measurements // Get upstream and downstream measurements
this._currentPosition = 'upstream'; const positions = this.getPositions();
this._currentPosition = Math.min(...positions);
const upstream = this.get(); const upstream = this.get();
this._currentPosition = 'downstream'; this._currentPosition = Math.max(...positions);
const downstream = this.get(); const downstream = this.get();
this._currentPosition = savedPosition; this._currentPosition = savedPosition;
@@ -319,7 +328,7 @@ class MeasurementContainer {
Object.keys(this.measurements[this._currentType]) : []; Object.keys(this.measurements[this._currentType]) : [];
} }
getPositions() { getPositions(asNumber = false) {
if (!this._currentType || !this._currentVariant) { if (!this._currentType || !this._currentVariant) {
throw new Error('Type and variant must be specified before listing positions'); throw new Error('Type and variant must be specified before listing positions');
} }
@@ -329,9 +338,13 @@ class MeasurementContainer {
return []; return [];
} }
if (asNumber) {
return Object.keys(this.measurements[this._currentType][this._currentVariant]); return Object.keys(this.measurements[this._currentType][this._currentVariant]);
} }
return Object.keys(this.measurements[this._currentType][this._currentVariant]).map(this._convertPositionNum2Str);
}
clear() { clear() {
this.measurements = {}; this.measurements = {};
this._currentType = null; this._currentType = null;
@@ -404,6 +417,34 @@ class MeasurementContainer {
} }
} }
_convertPositionStr2Num(positionString) {
switch(positionString) {
case "atEquipment":
return 0;
case "upstream":
return Number.POSITIVE_INFINITY;
case "downstream":
return Number.NEGATIVE_INFINITY;
default:
this.logger.error(`Invalid positionVsParent provided: ${positionString}`);
return;
}
}
_convertPositionNum2Str(positionValue) {
if (positionValue === 0) {
return "atEquipment";
}
if (positionValue < 0) {
return "upstream";
}
if (positionValue > 0) {
return "downstream";
}
this.logger.error(`Invalid position provided: ${positionValue}`);
}
} }
module.exports = MeasurementContainer; module.exports = MeasurementContainer;