diff --git a/src/configs/index.js b/src/configs/index.js index 3adb603..6c926d3 100644 --- a/src/configs/index.js +++ b/src/configs/index.js @@ -77,7 +77,7 @@ class ConfigManager { } }, functionality: { - softwareType: nodeName, + softwareType: nodeName.toLowerCase(), positionVsParent: uiConfig.positionVsParent || 'atEquipment', distance: uiConfig.hasDistance ? uiConfig.distance : undefined } diff --git a/src/configs/machineGroupControl.json b/src/configs/machineGroupControl.json index b087858..d8fc8f6 100644 --- a/src/configs/machineGroupControl.json +++ b/src/configs/machineGroupControl.json @@ -58,7 +58,7 @@ }, "functionality": { "softwareType": { - "default": "machineGroup", + "default": "machinegroupcontrol", "rules": { "type": "string", "description": "Logical name identifying the software type." diff --git a/src/configs/rotatingMachine.json b/src/configs/rotatingMachine.json index 6ef9955..573dbd2 100644 --- a/src/configs/rotatingMachine.json +++ b/src/configs/rotatingMachine.json @@ -58,7 +58,7 @@ }, "functionality": { "softwareType": { - "default": "machine", + "default": "rotatingmachine", "rules": { "type": "string", "description": "Specified software type for this configuration." diff --git a/src/configs/valveGroupControl.json b/src/configs/valveGroupControl.json index 1fd26a2..e61e4a3 100644 --- a/src/configs/valveGroupControl.json +++ b/src/configs/valveGroupControl.json @@ -60,7 +60,7 @@ }, "functionality": { "softwareType": { - "default": "valveGroupControl", + "default": "valvegroupcontrol", "rules": { "type": "string", "description": "Specified software type for this configuration." diff --git a/src/helper/validationUtils.js b/src/helper/validationUtils.js index ddbba58..7d9f801 100644 --- a/src/helper/validationUtils.js +++ b/src/helper/validationUtils.js @@ -270,15 +270,29 @@ class ValidationUtils { this.logger.warn(`Dimension '${name}' key '${key}' has mismatched x and y lengths. Ignoring this key.`); 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)) { 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 - else if (!this.isUnique(value.x)) { + // Validate that x values are unique — remove duplicates if not + if (!this.isUnique(value.x)) { 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 else if (!this.areNumbers(value.y)) { diff --git a/src/measurements/MeasurementContainer.js b/src/measurements/MeasurementContainer.js index 78d96b5..8445e1c 100644 --- a/src/measurements/MeasurementContainer.js +++ b/src/measurements/MeasurementContainer.js @@ -455,6 +455,8 @@ difference({ from = "downstream", to = "upstream", unit: requestedUnit } = {}) { this._currentType = null; this._currentVariant = null; this._currentPosition = null; + this._currentDistance = null; + this._unit = null; } // Helper method for value conversion