Reset chaining context in MeasurementContainer.clear()

Closes #25

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Rene De Ren
2026-03-11 15:06:17 +01:00
parent 135dfc31d3
commit 89aec9a7eb
6 changed files with 25 additions and 9 deletions

View File

@@ -77,7 +77,7 @@ class ConfigManager {
} }
}, },
functionality: { functionality: {
softwareType: nodeName, softwareType: nodeName.toLowerCase(),
positionVsParent: uiConfig.positionVsParent || 'atEquipment', positionVsParent: uiConfig.positionVsParent || 'atEquipment',
distance: uiConfig.hasDistance ? uiConfig.distance : undefined distance: uiConfig.hasDistance ? uiConfig.distance : undefined
} }

View File

@@ -58,7 +58,7 @@
}, },
"functionality": { "functionality": {
"softwareType": { "softwareType": {
"default": "machineGroup", "default": "machinegroupcontrol",
"rules": { "rules": {
"type": "string", "type": "string",
"description": "Logical name identifying the software type." "description": "Logical name identifying the software type."

View File

@@ -58,7 +58,7 @@
}, },
"functionality": { "functionality": {
"softwareType": { "softwareType": {
"default": "machine", "default": "rotatingmachine",
"rules": { "rules": {
"type": "string", "type": "string",
"description": "Specified software type for this configuration." "description": "Specified software type for this configuration."

View File

@@ -60,7 +60,7 @@
}, },
"functionality": { "functionality": {
"softwareType": { "softwareType": {
"default": "valveGroupControl", "default": "valvegroupcontrol",
"rules": { "rules": {
"type": "string", "type": "string",
"description": "Specified software type for this configuration." "description": "Specified software type for this configuration."

View File

@@ -270,15 +270,29 @@ class ValidationUtils {
this.logger.warn(`Dimension '${name}' key '${key}' has mismatched x and y lengths. Ignoring this key.`); this.logger.warn(`Dimension '${name}' key '${key}' has mismatched x and y lengths. Ignoring this key.`);
return false; return false;
} }
// Validate that x values are in ascending order // Validate that x values are in ascending order — sort if not
else if (!this.isSorted(value.x)) { else if (!this.isSorted(value.x)) {
this.logger.warn(`Dimension '${name}' key '${key}' has unsorted x values. Sorting...`); this.logger.warn(`Dimension '${name}' key '${key}' has unsorted x values. Sorting...`);
return false; const indices = value.x.map((v, i) => i);
indices.sort((a, b) => value.x[a] - value.x[b]);
value.x = indices.map(i => value.x[i]);
value.y = indices.map(i => value.y[i]);
} }
// Validate that x values are unique // Validate that x values are unique — remove duplicates if not
else if (!this.isUnique(value.x)) { if (!this.isUnique(value.x)) {
this.logger.warn(`Dimension '${name}' key '${key}' has duplicate x values. Removing duplicates...`); this.logger.warn(`Dimension '${name}' key '${key}' has duplicate x values. Removing duplicates...`);
return false; const seen = new Set();
const uniqueX = [];
const uniqueY = [];
for (let i = 0; i < value.x.length; i++) {
if (!seen.has(value.x[i])) {
seen.add(value.x[i]);
uniqueX.push(value.x[i]);
uniqueY.push(value.y[i]);
}
}
value.x = uniqueX;
value.y = uniqueY;
} }
// Validate that y values are numbers // Validate that y values are numbers
else if (!this.areNumbers(value.y)) { else if (!this.areNumbers(value.y)) {

View File

@@ -455,6 +455,8 @@ difference({ from = "downstream", to = "upstream", unit: requestedUnit } = {}) {
this._currentType = null; this._currentType = null;
this._currentVariant = null; this._currentVariant = null;
this._currentPosition = null; this._currentPosition = null;
this._currentDistance = null;
this._unit = null;
} }
// Helper method for value conversion // Helper method for value conversion