diff --git a/classCAN.py b/classCAN.py index 1fe3438..f6fbb21 100644 --- a/classCAN.py +++ b/classCAN.py @@ -20,7 +20,7 @@ class CANBackend: self.network = canopen.Network() self.network.connect(channel='can0', bustype='socketcan') - # PU mapping: PU1->0x02, PU2->0x03, PU3->0x04 + # PU mapping: PU1->0x02, PU2->0x04, PU3->0x127 node_map = { 1: 0x02, 2: 0x04, @@ -59,7 +59,7 @@ class CANBackend: with self.lock: try: # Poll only PU1 (node ID 0x02) for live monitor values - node = self.nodes.get(1) + node = self.nodes.get(2) if node: fm1 = node.sdo[0x2004][1].raw fm2 = node.sdo[0x2004][2].raw @@ -147,7 +147,7 @@ class CANBackend: raise ValueError(f"PU{pu_number} not connected") print(f"[DEBUG] Writing state {state_map[state]} to 0x2024:{pu_number}") - node.sdo[0x2024][pu_number].raw = state_map[state] + node.sdo[0x2024][0x01].raw = state_map[state] print(f"[DEBUG] Writing ploop_setpoint {ploop_setpoint} to 0x2007") node.sdo[0x2007].raw = int(ploop_setpoint * 100) diff --git a/main.py b/main.py index 4c67f79..27b754a 100644 --- a/main.py +++ b/main.py @@ -151,71 +151,95 @@ def get_monitor_data(): print(f"[MONITOR] Latest SDO: {data}") return { "PU_1": { - "Qperm": data.get("FM2", 0.0), - "Qdilute": data.get("FM3", 0.0), - "Qdrain": data.get("FM4", 0.0), - "Qrecirc": data.get("FM5", 0.0), + "Qperm": data.get("FM1", 0.0), + "Qdilute": data.get("FM2", 0.0), + "Qdrain": data.get("FM3", 0.0), + "Qrecirc": data.get("FM4", 0.0), + "Pro": data.get("PS1", 0.0), "Pdilute": data.get("PS2", 0.0), "Prentate": data.get("PS3", 0.0), + "Conductivity": data.get("Cond", 0.0), + "MV02": data.get("MV02", 0.0), "MV02_sp": data.get("MV02_sp", 0.0), + "MV03": data.get("MV03", 0.0), "MV03_sp": data.get("MV03_sp", 0.0), + "MV05": data.get("MV05", 0.0), "MV05_sp": data.get("MV05_sp", 0.0), + "MV06": data.get("MV06", 0.0), "MV06_sp": data.get("MV06_sp", 0.0), + "MV07": data.get("MV07", 0.0), "MV07_sp": data.get("MV07_sp", 0.0), + "MV08": data.get("MV08", 0.0), "MV08_sp": data.get("MV08_sp", 0.0) }, "PU_2": { - "Qperm": data.get("FM2", 0.0), - "Qdilute": data.get("FM3", 0.0), - "Qdrain": data.get("FM4", 0.0), - "Qrecirc": data.get("FM5", 0.0), + "Qperm": data.get("FM1", 0.0), + "Qdilute": data.get("FM2", 0.0), + "Qdrain": data.get("FM3", 0.0), + "Qrecirc": data.get("FM4", 0.0), + "Pro": data.get("PS1", 0.0), "Pdilute": data.get("PS2", 0.0), "Prentate": data.get("PS3", 0.0), + "Conductivity": data.get("Cond", 0.0), + "MV02": data.get("MV02", 0.0), "MV02_sp": data.get("MV02_sp", 0.0), + "MV03": data.get("MV03", 0.0), "MV03_sp": data.get("MV03_sp", 0.0), + "MV05": data.get("MV05", 0.0), "MV05_sp": data.get("MV05_sp", 0.0), + "MV06": data.get("MV06", 0.0), "MV06_sp": data.get("MV06_sp", 0.0), + "MV07": data.get("MV07", 0.0), "MV07_sp": data.get("MV07_sp", 0.0), + "MV08": data.get("MV08", 0.0), "MV08_sp": data.get("MV08_sp", 0.0) }, "PU_3": { - "Qperm": data.get("FM2", 0.0), - "Qdilute": data.get("FM3", 0.0), - "Qdrain": data.get("FM4", 0.0), - "Qrecirc": data.get("FM5", 0.0), + "Qperm": data.get("FM1", 0.0), + "Qdilute": data.get("FM2", 0.0), + "Qdrain": data.get("FM3", 0.0), + "Qrecirc": data.get("FM4", 0.0), + "Pro": data.get("PS1", 0.0), "Pdilute": data.get("PS2", 0.0), "Prentate": data.get("PS3", 0.0), + "Conductivity": data.get("Cond", 0.0), + "MV02": data.get("MV02", 0.0), "MV02_sp": data.get("MV02_sp", 0.0), + "MV03": data.get("MV03", 0.0), "MV03_sp": data.get("MV03_sp", 0.0), + "MV05": data.get("MV05", 0.0), "MV05_sp": data.get("MV05_sp", 0.0), + "MV06": data.get("MV06", 0.0), "MV06_sp": data.get("MV06_sp", 0.0), + "MV07": data.get("MV07", 0.0), "MV07_sp": data.get("MV07_sp", 0.0), + "MV08": data.get("MV08", 0.0), "MV08_sp": data.get("MV08_sp", 0.0) - } + } } @app.get("/can_status") diff --git a/templates/control.html b/templates/control.html index 5c65a96..cdb49c7 100644 --- a/templates/control.html +++ b/templates/control.html @@ -84,6 +84,21 @@ .mode-block button.in-progress { background-color: #ffcc00; color: #000; } .mode-block button.ready { background-color: #00C851; color: #fff; } .mode-block button.disabled { background-color: #777; cursor: not-allowed; } + .in-progress { + background-color: yellow !important; + color: black !important; + } + + .ready { + background-color: orange !important; + color: black !important; + } + + .production { + background-color: green !important; + color: white !important; + } + .pu-status { margin-top: 20px; } .pu-item { background-color: #333; @@ -179,23 +194,23 @@