6 Commits

Author SHA1 Message Date
znetsixe
108d2e23ca bug fixes 2025-11-30 09:24:37 +01:00
znetsixe
446ef81f24 adjusted input for measurement container 2025-11-28 09:59:51 +01:00
znetsixe
966ba06faa some minor addons to measurement container 2025-11-27 17:46:56 +01:00
znetsixe
e8c96c4b1e removed useless parameter 2025-11-25 16:19:23 +01:00
znetsixe
f083e7596a update 2025-11-20 22:29:24 +01:00
znetsixe
6ca6e536a5 fixed dropdown speed selection 2025-11-20 11:09:44 +01:00
3 changed files with 40 additions and 23 deletions

View File

@@ -24,6 +24,7 @@
warmup: { value: 0 }, warmup: { value: 0 },
shutdown: { value: 0 }, shutdown: { value: 0 },
cooldown: { value: 0 }, cooldown: { value: 0 },
movementMode : { value: "staticspeed" }, // static or dynamic
machineCurve : { value: {}}, machineCurve : { value: {}},
//define asset properties //define asset properties
@@ -74,6 +75,10 @@
document.getElementById("node-input-warmup"); document.getElementById("node-input-warmup");
document.getElementById("node-input-shutdown"); document.getElementById("node-input-shutdown");
document.getElementById("node-input-cooldown"); document.getElementById("node-input-cooldown");
const movementMode = document.getElementById("node-input-movementMode");
if (movementMode) {
movementMode.value = this.movementMode || "staticspeed";
}
}, },
oneditsave: function() { oneditsave: function() {
@@ -99,6 +104,9 @@
node[field] = value; node[field] = value;
}); });
node.movementMode = document.getElementById("node-input-movementMode").value;
console.log(`----------------> Saving movementMode: ${node.movementMode}`);
} }
}); });
</script> </script>
@@ -127,6 +135,13 @@
<label for="node-input-cooldown"><i class="fa fa-clock-o"></i> Cooldown Time</label> <label for="node-input-cooldown"><i class="fa fa-clock-o"></i> Cooldown Time</label>
<input type="number" id="node-input-cooldown" style="width:60%;" /> <input type="number" id="node-input-cooldown" style="width:60%;" />
</div> </div>
<div class="form-row">
<label for="node-input-movementMode"><i class="fa fa-exchange"></i> Movement Mode</label>
<select id="node-input-movementMode" style="width:60%;">
<option value="staticspeed">Static</option>
<option value="dynspeed">Dynamic</option>
</select>
</div>
<!-- Asset fields injected here --> <!-- Asset fields injected here -->
<div id="asset-fields-placeholder"></div> <div id="asset-fields-placeholder"></div>

View File

@@ -76,6 +76,8 @@ class nodeClass {
_setupSpecificClass(uiConfig) { _setupSpecificClass(uiConfig) {
const machineConfig = this.config; const machineConfig = this.config;
console.log(`----------------> Loaded movementMode in nodeClass: ${uiConfig.movementMode}`);
// need extra state for this // need extra state for this
const stateConfig = { const stateConfig = {
general: { general: {
@@ -85,7 +87,8 @@ class nodeClass {
} }
}, },
movement: { movement: {
speed: Number(uiConfig.speed) speed: Number(uiConfig.speed),
mode: uiConfig.movementMode
}, },
time: { time: {
starting: Number(uiConfig.startup), starting: Number(uiConfig.startup),

View File

@@ -1,6 +1,5 @@
const EventEmitter = require('events'); const EventEmitter = require('events');
const {loadCurve,gravity,logger,configUtils,configManager,state, nrmse, MeasurementContainer, predict, interpolation , childRegistrationUtils,coolprop} = require('generalFunctions'); const {loadCurve,gravity,logger,configUtils,configManager,state, nrmse, MeasurementContainer, predict, interpolation , childRegistrationUtils,coolprop} = require('generalFunctions');
const pressure = require('../../generalFunctions/src/convert/definitions/pressure');
class Machine { class Machine {
@@ -17,7 +16,7 @@ class Machine {
// Load a specific curve // Load a specific curve
this.model = machineConfig.asset.model; // Get the model from the machineConfig this.model = machineConfig.asset.model; // Get the model from the machineConfig
this.curve = this.model ? loadCurve(this.model) : null; this.curve = this.model ? loadCurve(this.model) : null; // we need to convert the curve and add units to the curve information
//Init config and check if it is valid //Init config and check if it is valid
this.config = this.configUtils.initConfig(machineConfig); this.config = this.configUtils.initConfig(machineConfig);
@@ -97,14 +96,18 @@ class Machine {
this.measurements.type('temperature').variant('measured').position('atEquipment').value(15).unit('C'); this.measurements.type('temperature').variant('measured').position('atEquipment').value(15).unit('C');
//assume standard atm pressure is at sea level //assume standard atm pressure is at sea level
this.measurements.type('atmPressure').variant('measured').position('atEquipment').value(101325).unit('Pa'); this.measurements.type('atmPressure').variant('measured').position('atEquipment').value(101325).unit('Pa');
//populate min and max
const flowunit = this.config.general.unit;
this.measurements.type('flow').variant('predicted').position('max').value(this.predictFlow.currentFxyYMax, Date.now() , flowunit)
this.measurements.type('flow').variant('predicted').position('min').value(this.predictFlow.currentFxyYMin).unit(this.config.general.unit);
} }
_updateState(){ _updateState(){
const isOperational = this._isOperationalState(); const isOperational = this._isOperationalState();
if(!isOperational){ if(!isOperational){
//overrule the last prediction this should be 0 now //overrule the last prediction this should be 0 now
this.measurements.type("flow").variant("predicted").position("downstream").value(0); this.measurements.type("flow").variant("predicted").position("downstream").value(0,Date.now(),this.config.general.unit);
this.measurements.type("flow").variant("predicted").position("atEquipment").value(0); this.measurements.type("flow").variant("predicted").position("atEquipment").value(0,Date.now(),this.config.general.unit);
} }
} }
@@ -345,23 +348,23 @@ _callMeasurementHandler(measurementType, value, position, context) {
calcFlow(x) { calcFlow(x) {
if(this.hasCurve) { if(this.hasCurve) {
if (!this._isOperationalState()) { if (!this._isOperationalState()) {
this.measurements.type("flow").variant("predicted").position("downstream").value(0); this.measurements.type("flow").variant("predicted").position("downstream").value(0,Date.now(),this.config.general.unit);
this.measurements.type("flow").variant("predicted").position("atEquipment").value(0); this.measurements.type("flow").variant("predicted").position("atEquipment").value(0,Date.now(),this.config.general.unit);
this.logger.debug(`Machine is not operational. Setting predicted flow to 0.`); this.logger.debug(`Machine is not operational. Setting predicted flow to 0.`);
return 0; return 0;
} }
const cFlow = this.predictFlow.y(x); const cFlow = this.predictFlow.y(x);
this.measurements.type("flow").variant("predicted").position("downstream").value(cFlow); this.measurements.type("flow").variant("predicted").position("downstream").value(cFlow,Date.now(),this.config.general.unit);
this.measurements.type("flow").variant("predicted").position("atEquipment").value(cFlow); this.measurements.type("flow").variant("predicted").position("atEquipment").value(cFlow,Date.now(),this.config.general.unit);
//this.logger.debug(`Calculated flow: ${cFlow} for pressure: ${this.getMeasuredPressure()} and position: ${x}`); //this.logger.debug(`Calculated flow: ${cFlow} for pressure: ${this.getMeasuredPressure()} and position: ${x}`);
return cFlow; return cFlow;
} }
// If no curve data is available, log a warning and return 0 // If no curve data is available, log a warning and return 0
this.logger.warn(`No curve data available for flow calculation. Returning 0.`); this.logger.warn(`No curve data available for flow calculation. Returning 0.`);
this.measurements.type("flow").variant("predicted").position("downstream").value(0); this.measurements.type("flow").variant("predicted").position("downstream").value(0, Date.now(),this.config.general.unit);
this.measurements.type("flow").variant("predicted").position("atEquipment").value(0); this.measurements.type("flow").variant("predicted").position("atEquipment").value(0, Date.now(),this.config.general.unit);
return 0; return 0;
} }
@@ -479,6 +482,9 @@ _callMeasurementHandler(measurementType, value, position, context) {
const efficiency = this.calcEfficiency(this.predictPower.outputY, this.predictFlow.outputY, "predicted"); const efficiency = this.calcEfficiency(this.predictPower.outputY, this.predictFlow.outputY, "predicted");
//update the distance from peak //update the distance from peak
this.calcDistanceBEP(efficiency,cog,minEfficiency); this.calcDistanceBEP(efficiency,cog,minEfficiency);
//place min and max flow capabilities in containerthis.predictFlow.currentFxyYMax - this.predictFlow.currentFxyYMin
this.measurements.type('flow').variant('predicted').position('max').value(this.predictFlow.currentFxyYMax).unit(this.config.general.unit);
this.measurements.type('flow').variant('predicted').position('min').value(this.predictFlow.currentFxyYMin).unit(this.config.general.unit);
return 0; return 0;
} }
@@ -598,8 +604,6 @@ _callMeasurementHandler(measurementType, value, position, context) {
} }
} }
calcDistanceFromPeak(currentEfficiency,peakEfficiency){ calcDistanceFromPeak(currentEfficiency,peakEfficiency){
@@ -639,7 +643,7 @@ _callMeasurementHandler(measurementType, value, position, context) {
const {efficiencyCurve, peak, peakIndex, minEfficiency } = this.calcEfficiencyCurve(powerCurve, flowCurve); const {efficiencyCurve, peak, peakIndex, minEfficiency } = this.calcEfficiencyCurve(powerCurve, flowCurve);
// Calculate the normalized center of gravity // Calculate the normalized center of gravity
const NCog = (flowCurve.y[peakIndex] - this.predictFlow.currentFxyYMin) / (this.predictFlow.currentFxyYMax - this.predictFlow.currentFxyYMin); const NCog = (flowCurve.y[peakIndex] - this.predictFlow.currentFxyYMin) / (this.predictFlow.currentFxyYMax - this.predictFlow.currentFxyYMin); //
//store in object for later retrieval //store in object for later retrieval
this.currentEfficiencyCurve = efficiencyCurve; this.currentEfficiencyCurve = efficiencyCurve;
@@ -695,6 +699,8 @@ _callMeasurementHandler(measurementType, value, position, context) {
const g = gravity.getStandardGravity(); const g = gravity.getStandardGravity();
const temp = this.measurements.type('temperature').variant('measured').position('atEquipment').getCurrentValue('K'); const temp = this.measurements.type('temperature').variant('measured').position('atEquipment').getCurrentValue('K');
const atmPressure = this.measurements.type('atmPressure').variant('measured').position('atEquipment').getCurrentValue('Pa'); const atmPressure = this.measurements.type('atmPressure').variant('measured').position('atEquipment').getCurrentValue('Pa');
console.log(`--------------------calc efficiency : Pressure diff:${pressureDiff},${temp}, ${g} `);
const rho = coolprop.PropsSI('D', 'T', temp, 'P', atmPressure, 'WasteWater'); const rho = coolprop.PropsSI('D', 'T', temp, 'P', atmPressure, 'WasteWater');
@@ -765,15 +771,8 @@ _callMeasurementHandler(measurementType, value, position, context) {
getOutput() { getOutput() {
// Improved output object generation // Improved output object generation
const output = {};
Object.entries(this.measurements.measurements).forEach(([type, variants]) => { const output = this.measurements.getFlattenedOutput();
Object.entries(variants).forEach(([variant, positions]) => {
Object.entries(positions).forEach(([position, measurement]) => {
output[`${type}.${variant}.${position}`] = measurement.getCurrentValue();
});
});
});
//fill in the rest of the output object //fill in the rest of the output object
output["state"] = this.state.getCurrentState(); output["state"] = this.state.getCurrentState();