Compare commits

...

2 Commits

Author SHA1 Message Date
55ae9edaa7 Implement error logging for unimplemented _tModel method 2025-11-28 11:53:35 +01:00
d5183bdca0 Implement model switcher 2025-11-14 15:12:20 +01:00
3 changed files with 39 additions and 4 deletions

View File

@@ -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 @@
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-model"><i class="fa fa-tag"></i> Model</label>
<input type="text" id="node-input-model">
</div>
<!-- Logger fields injected here -->
<div id="logger-fields-placeholder"></div>

View File

@@ -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
}
}

View File

@@ -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() {
this.logger.error("Not implemented yet.");
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 } }
];
}