From fa7c59fcabf56e4cd8865ddbc246f8fc200e4f8b Mon Sep 17 00:00:00 2001 From: znetsixe <73483679+znetsixe@users.noreply.github.com> Date: Thu, 24 Jul 2025 13:15:33 +0200 Subject: [PATCH] updates --- rotatingMachine.html | 10 +++++----- src/nodeClass.js | 14 ++++++-------- src/specificClass.js | 25 +++++++++++++++++++------ 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/rotatingMachine.html b/rotatingMachine.html index adbc9eb..258a99c 100644 --- a/rotatingMachine.html +++ b/rotatingMachine.html @@ -57,11 +57,11 @@ waitForMenuData(); // your existing project‐settings & asset dropdown logic can remain here - document.getElementById("node-input-speed"), - document.getElementById("node-input-startup"), - document.getElementById("node-input-warmup"), - document.getElementById("node-input-shutdown"), - document.getElementById("node-input-cooldown") + document.getElementById("node-input-speed"); + document.getElementById("node-input-startup"); + document.getElementById("node-input-warmup"); + document.getElementById("node-input-shutdown"); + document.getElementById("node-input-cooldown"); }, oneditsave: function() { diff --git a/src/nodeClass.js b/src/nodeClass.js index f41b025..2e007e3 100644 --- a/src/nodeClass.js +++ b/src/nodeClass.js @@ -25,7 +25,7 @@ class nodeClass { // Load default & UI config this._loadConfig(uiConfig,this.node); - // Instantiate core Measurement class + // Instantiate core class this._setupSpecificClass(uiConfig); // Wire up event and lifecycle handlers @@ -107,9 +107,7 @@ class nodeClass { * Bind events to Node-RED status updates. Using internal emitter. --> REMOVE LATER WE NEED ONLY COMPLETE CHILDS AND THEN CHECK FOR UPDATES */ _bindEvents() { - this.source.emitter.on('mAbs', (val) => { - this.node.status({ fill: 'green', shape: 'dot', text: `${val} ${this.config.general.unit}` }); - }); + } _updateNodeStatus() { @@ -205,7 +203,7 @@ class nodeClass { } /** - * Start the periodic tick loop to drive the Measurement class. + * Start the periodic tick loop. */ _startTickLoop() { setTimeout(() => { @@ -268,9 +266,9 @@ class nodeClass { const { source: esSource, action: esAction } = msg.payload; m.handleInput(esSource, esAction); break; - case 'showCompleteCurve': - m.showCompleteCurve(); - send({ topic : "Showing curve" , payload: m.showCompleteCurve() }); + case 'showWorkingCurves': + m.showWorkingCurves(); + send({ topic : "Showing curve" , payload: m.showWorkingCurves() }); break; case 'CoG': m.showCoG(); diff --git a/src/specificClass.js b/src/specificClass.js index 0a716c4..5584a29 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -63,7 +63,7 @@ class Machine { this.model = machineConfig.asset.model; // Get the model from the machineConfig this.curve = this.model ? loadCurve(this.model) : null; - //Always initialize config first + //Init config and check if it is valid this.config = this.configUtils.initConfig(machineConfig); if (!this.model || !this.curve) { @@ -85,8 +85,6 @@ class Machine { this.predictCtrl = new predict({ curve: this.reverseCurve(this.config.asset.machineCurve.nq) }); // load reversed nq (x: flow, y: ctrl relationship) } - - this.state = new state(stateConfig, this.logger); // Init State manager and pass logger this.errorMetrics = new nrmse(errorMetricsConfig, this.logger); @@ -111,8 +109,6 @@ class Machine { this.updatePosition(); }); - //this.calcCog(); - this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility } @@ -204,7 +200,7 @@ class Machine { } setMode(newMode) { - const availableModes = defaultConfig.mode.current.rules.values.map(v => v.value); + const availableModes = this.defaultConfig.mode.current.rules.values.map(v => v.value); if (!availableModes.includes(newMode)) { this.logger.warn(`Invalid mode '${newMode}'. Allowed modes are: ${availableModes.join(', ')}`); return; @@ -549,6 +545,23 @@ class Machine { return distance; } + showWorkingCurves() { + // Show the current curves for debugging + const { powerCurve, flowCurve } = this.getCurrentCurves(); + return { + powerCurve: powerCurve, + flowCurve: flowCurve, + cog: this.cog, + cogIndex: this.cogIndex, + NCog: this.NCog, + minEfficiency: this.minEfficiency, + currentEfficiencyCurve: this.currentEfficiencyCurve, + absDistFromPeak: this.absDistFromPeak, + relDistFromPeak: this.relDistFromPeak + }; + } + + // Calculate the center of gravity for current pressure calcCog() {