import numpy as np PUs_states = [{"PU_MODE": "OFF","ploop_setpoint":0.0},{"PU_MODE": "OFF","ploop_setpoint":0.0},{"PU_MODE": "OFF","ploop_setpoint":0.0}] # data[i] is PU_i dictionnary # Placeholder for CAN backend class CANBackend: def __init__(self, eds_file=None): self.connected = False def connect(self, node_id: int, eds_path: str) -> bool: # Placeholder for connection logic self.connected = True return True def shutdown(self): self.connected = False def read_current_state(self,pu_number: int): # Placeholder for reading mode command return PUs_states[pu_number-1]["PU_MODE"] def send_thermal_loop_cleaning(self, mode: str): # Placeholder for thermal loop cleaning pass def send_state_command(self, state: str, pu_number : int, ploop_setpoint : float): # Placeholder for sending mode command PUs_states[pu_number-1] = {"PU_MODE": state, "ploop_setpoint":ploop_setpoint} def get_latest_data(self, pu_number=1, data={}): # Simulate getting the latest data with random values if pu_number ==1: return { "FM2": 1080, "FM3": 1080, "FM4": 1080, "FM5": 1080, "PS1": 6.2, "PS2": 6.2, "PS3": 6.2, "PS4": 6.2, "Cond": 1* np.random.random(), "MV02": round(100 * np.random.random(), 2), "MV02_sp": round(100 * np.random.random(), 2), "MV03": round(100 * np.random.random(), 2), "MV03_sp": round(100 * np.random.random(), 2), "MV05": round(100 * np.random.random(), 2), "MV05_sp": round(100 * np.random.random(), 2), "MV06": round(100 * np.random.random(), 2), "MV06_sp": round(100 * np.random.random(), 2), "MV07": round(100 * np.random.random(), 2), "MV07_sp": round(100 * np.random.random(), 2), "MV08": round(100 * np.random.random(), 2), "MV08_sp": round(100 * np.random.random(), 2), } else : return { "FM2": round(1000 * np.random.random(), 1), "FM3": round(1000 * np.random.random(), 1), "FM4": round(1000 * np.random.random(), 1), "FM5": round(1000 * np.random.random(), 1), "PS1": round(10 * np.random.random(), 2), "PS2": round(10 * np.random.random(), 2), "PS3": round(10 * np.random.random(), 2), "PS4": round(10 * np.random.random(), 2), "Cond": 1* np.random.random(), "MV02": round(100 * np.random.random(), 2), "MV02_sp": round(100 * np.random.random(), 2), "MV03": round(100 * np.random.random(), 2), "MV03_sp": round(100 * np.random.random(), 2), "MV05": round(100 * np.random.random(), 2), "MV05_sp": round(100 * np.random.random(), 2), "MV06": round(100 * np.random.random(), 2), "MV06_sp": round(100 * np.random.random(), 2), "MV07": round(100 * np.random.random(), 2), "MV07_sp": round(100 * np.random.random(), 2), "MV08": round(100 * np.random.random(), 2), "MV08_sp": round(100 * np.random.random(), 2), }