Implement pump flow monitoring and UI normalization enhancements
- Rust: Add `MIN_PUMP_FLOW_ML` constant and logging for insufficient pump flow with fault handling. - UI: Normalize config fields to maintain consistency and prevent false dirty flags after round-trips. - KiCad: Update board zone settings for `PlantCtrlESP32` and `MPPT`. - IntelliJ: Add `.idea` configurations for project setup and inspections.
This commit is contained in:
@@ -321,6 +321,10 @@ pub enum LogMessage {
|
||||
serialize = "Trace: a: ${number_a} b: ${number_b} txt_s ${txt_short} long ${txt_long}"
|
||||
)]
|
||||
Trace,
|
||||
#[strum(
|
||||
serialize = "Pump insufficient flow, pump: ${number_a} measured ${number_b} ml, minimum is ${txt_short} ml"
|
||||
)]
|
||||
PumpInsufficientFlow,
|
||||
#[strum(serialize = "Parsing error reading message")]
|
||||
UnknownMessage,
|
||||
#[strum(serialize = "Going to deep sleep for ${number_a} minutes")]
|
||||
|
||||
@@ -478,6 +478,17 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> {
|
||||
state.flow_value_ml,
|
||||
)
|
||||
.await;
|
||||
if !dry_run && state.flow_value_ml < MIN_PUMP_FLOW_ML {
|
||||
log(
|
||||
LogMessage::PumpInsufficientFlow,
|
||||
(plant_id + 1) as u32,
|
||||
state.flow_value_ml as u32,
|
||||
&(MIN_PUMP_FLOW_ML as u32).to_string(),
|
||||
"",
|
||||
);
|
||||
board.board_hal.general_fault(true).await;
|
||||
board.board_hal.fault(plant_id, true).await?;
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
mqtt::pump_info(
|
||||
@@ -700,6 +711,8 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> {
|
||||
}
|
||||
}
|
||||
|
||||
const MIN_PUMP_FLOW_ML: f32 = 200.0;
|
||||
|
||||
pub async fn do_secure_pump(
|
||||
board: &mut MutexGuard<'_, CriticalSectionRawMutex, HAL<'_>>,
|
||||
plant_id: usize,
|
||||
|
||||
@@ -36,10 +36,10 @@ export interface BackupHeader {
|
||||
|
||||
export interface NetworkConfig {
|
||||
ap_ssid: string,
|
||||
ssid: string,
|
||||
password: string,
|
||||
mqtt_url: string,
|
||||
base_topic: string,
|
||||
ssid: string | null,
|
||||
password: string | null,
|
||||
mqtt_url: string | null,
|
||||
base_topic: string | null,
|
||||
mqtt_user: string | null,
|
||||
mqtt_password: string | null,
|
||||
max_wait: number
|
||||
|
||||
@@ -246,8 +246,11 @@ export class Controller {
|
||||
const response = await fetch(PUBLIC_URL + "/get_config");
|
||||
const loaded = await response.json();
|
||||
const currentConfig = loaded as PlantControllerConfig;
|
||||
controller.setInitialConfig(currentConfig);
|
||||
controller.setConfig(currentConfig);
|
||||
// Store the config after the UI round-trip so null fields that the UI
|
||||
// normalises (e.g. null → "" → null, null timezone → "UTC") are
|
||||
// represented consistently and don't trigger a false dirty flag.
|
||||
controller.setInitialConfig(controller.getConfig());
|
||||
//sync json view initially
|
||||
controller.configChanged();
|
||||
controller.progressview.removeProgress("get_config");
|
||||
|
||||
@@ -102,25 +102,25 @@ export class NetworkConfigView {
|
||||
|
||||
setConfig(network: NetworkConfig) {
|
||||
this.ap_ssid.value = network.ap_ssid;
|
||||
this.ssid.value = network.ssid;
|
||||
this.password.value = network.password;
|
||||
this.mqtt_url.value = network.mqtt_url;
|
||||
this.base_topic.value = network.base_topic;
|
||||
this.ssid.value = network.ssid ?? "";
|
||||
this.password.value = network.password ?? "";
|
||||
this.mqtt_url.value = network.mqtt_url ?? "";
|
||||
this.base_topic.value = network.base_topic ?? "";
|
||||
this.mqtt_user.value = network.mqtt_user ?? "";
|
||||
this.mqtt_password.value = network.mqtt_password ?? "";
|
||||
this.max_wait.value = network.max_wait.toString();
|
||||
}
|
||||
|
||||
|
||||
getConfig(): NetworkConfig {
|
||||
return {
|
||||
max_wait: +this.max_wait.value,
|
||||
ap_ssid: this.ap_ssid.value,
|
||||
ssid: this.ssid.value ?? null,
|
||||
password: this.password.value ?? null,
|
||||
mqtt_url: this.mqtt_url.value ?? null,
|
||||
mqtt_user: this.mqtt_user.value ? this.mqtt_user.value : null,
|
||||
mqtt_password: this.mqtt_password.value ? this.mqtt_password.value : null,
|
||||
base_topic: this.base_topic.value ?? null
|
||||
ssid: this.ssid.value || null,
|
||||
password: this.password.value || null,
|
||||
mqtt_url: this.mqtt_url.value || null,
|
||||
mqtt_user: this.mqtt_user.value || null,
|
||||
mqtt_password: this.mqtt_password.value || null,
|
||||
base_topic: this.base_topic.value || null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user