From d5183bdca0c021b406bed03aeaf03d8a70d2c5ad Mon Sep 17 00:00:00 2001 From: "p.vanderwilt" Date: Fri, 14 Nov 2025 15:12:20 +0100 Subject: [PATCH] Implement model switcher --- settler.html | 13 +++++++++++++ src/nodeClass.js | 3 ++- src/specificClass.js | 27 ++++++++++++++++++++++++--- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/settler.html b/settler.html index 5ca254f..06ce059 100644 --- a/settler.html +++ b/settler.html @@ -6,6 +6,7 @@ color: "#e4a363", defaults: { name: { value: "" }, + model: { value: "mb-model", required: true }, enableLog: { value: false }, logLevel: { value: "error" }, @@ -34,6 +35,14 @@ type:"num", types:["num"] }); + + $("#node-input-model").typedInput({type:"model", types:[{ + value: "model", + options: [ + { value: "mb-model", label: "Mass balance" }, + { value: "t-model", label: "Takács model" } + ] + }]}); }, oneditsave: function() { // save logger fields @@ -54,6 +63,10 @@ +
+ + +
diff --git a/src/nodeClass.js b/src/nodeClass.js index 4757683..84091d1 100644 --- a/src/nodeClass.js +++ b/src/nodeClass.js @@ -66,7 +66,8 @@ class nodeClass { functionality: { positionVsParent: uiConfig.positionVsParent || 'atEquipment', // Default to 'atEquipment' if not specified softwareType: "settler" // should be set in config manager - } + }, + model: uiConfig.model } } diff --git a/src/specificClass.js b/src/specificClass.js index 5b87aef..d2b9b6b 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -20,6 +20,17 @@ class Settler { } get getEffluent() { + switch (this.config.model) { + case "mb-model": + return this._mbModel(); + case "t-model": + return this._tModel(); + default: + this.logger.error(`Unknown settler model: ${this.config.model}`); + } + } + + _mbModel() { // constrain flow to prevent negatives const F_s = Math.min((this.F_in * this.Cs_in[12]) / this.C_TS, this.F_in); const F_eff = this.F_in - F_s; @@ -53,9 +64,19 @@ class Settler { } return [ - { topic: "Fluent", payload: { inlet: 0, F: F_eff, C: Cs_eff }, timestamp: Date.now() }, - { topic: "Fluent", payload: { inlet: 1, F: F_so, C: Cs_s }, timestamp: Date.now() }, - { topic: "Fluent", payload: { inlet: 2, F: F_sr, C: Cs_s }, timestamp: Date.now() } + { topic: "Fluent", payload: { inlet: 0, F: F_eff, C: Cs_eff } }, + { topic: "Fluent", payload: { inlet: 1, F: F_so, C: Cs_s } }, + { topic: "Fluent", payload: { inlet: 2, F: F_sr, C: Cs_s } } + ]; + } + + _tModel() { + + + return [ + { topic: "Fluent", payload: { inlet: 0, F: null, C: null } }, + { topic: "Fluent", payload: { inlet: 1, F: null, C: null } }, + { topic: "Fluent", payload: { inlet: 2, F: null, C: null } } ]; }