diff --git a/classCAN.py b/classCAN.py index 8042320..f3935ec 100644 --- a/classCAN.py +++ b/classCAN.py @@ -127,7 +127,6 @@ class CANBackend: "MV06": data[4], "MV07": data[5], "MV08": data[6], - "MV09": data[7], }) elif cob_id == 0x2AB and len(data) >= 1: diff --git a/main.py b/main.py index 8ce8360..dc3160d 100644 --- a/main.py +++ b/main.py @@ -51,6 +51,8 @@ latest_data: Dict[str, Any] = { "PatientSkid": {"QSkid": 0.0}, } +active_PUs : list[int] = [] + DEFAULT_FEED_VALVE = 0.0 # RECORDER @@ -77,7 +79,9 @@ def format_data(data): "Pro": np.round(data.get("PS2", 0.0), 2), "Pdilute": np.round(data.get("PS3", 0.0), 2), "Pretentate": np.round(data.get("PS1", 0.0), 2), - "Conductivity": np.round(data.get("Cond", 0.0), 1), + "Cfeed": np.round(data.get("Conductivity_Feed", 0.0), 1), + "Cperm": np.round(data.get("Conductivity_Permeate", 0.0), 1), + "Cdilute": np.round(data.get("Conductivity_Product", 0.0), 1), "MV02": np.round(data.get("MV02", 0.0), 1), "MV02_sp": np.round(data.get("MV02_sp", 0.0), 1), "MV03": np.round(data.get("MV03", 0.0), 1), @@ -213,6 +217,7 @@ def send_command(state: str, pu_number: int, ploop_setpoint: float = Query(...)) @app.get("/api/pu_status") def get_pu_status(): + global active_PUs states = { "PU1": can_backend.read_current_state(1), "PU2": can_backend.read_current_state(2), @@ -220,15 +225,16 @@ def get_pu_status(): } logging.info(f"[PU STATUS] {states}") + active_PUs = [pu for pu, status in states.items() if status != 'OFF'] + logging.info(f"[ACTIVE PU] {active_PUs}") + return JSONResponse(content=states) async def update_latest_data(): + global active_PUs while True: - for pu in [ - 1, - 2, - ]: # TODO: REPLACE THIS WITH CONNECTED PUs, IS GET PU STATUS SLOW? + for pu in active_PUs: # TODO: test data = can_backend.get_latest_data(pu_number=pu) latest_data[f"PU_{pu}"] = format_data(data) current_data = latest_data[f"PU_{pu}"] diff --git a/templates/control.html b/templates/control.html index 5b5ea39..3d527ff 100644 --- a/templates/control.html +++ b/templates/control.html @@ -320,8 +320,8 @@
-

Conductivity

-
+

Cdilute

+
#1
0.0 µS/cm
#2
0.0 µS/cm
#3
0.0 µS/cm
@@ -479,7 +479,7 @@
P_ro
${puData.Pro.toFixed(1)} bar
P_dilute
${puData.Pdilute.toFixed(1)} bar
P_retentate
${puData.Pretentate.toFixed(1)} bar
-
Conductivity
${puData.Conductivity.toFixed(1)} µS/cm
+
Cdilute
${puData.Cdilute.toFixed(1)} µS/cm
`; } } @@ -500,7 +500,7 @@ async function fetchMonitorData() { const fields = { "Qperm": "L/h", "Pdilute": "bar", - "Conductivity": "µS/cm", + "Cdilute": "µS/cm", "Pro": "bar" };