""" wago=ch.psi.pshell.modbus.ModbusTCP|wago-mxsc-1:502||| relays=ch.psi.pshell.modbus.DigitalOutputArray|wago 0 16||1000| release_local_safety=ch.psi.pshell.modbus.DigitalOutput|wago 0||| release_psys_safety=ch.psi.pshell.modbus.DigitalOutput|wago 1||| ln2_main_power=ch.psi.pshell.modbus.DigitalOutput|wago 2||| rim_heater=ch.psi.pshell.modbus.DigitalOutput|wago 3||| phase_separator_ln2=ch.psi.pshell.modbus.DigitalOutput|wago 4||| dewar_ln2=ch.psi.pshell.modbus.DigitalOutput|wago 5|||false valve_he_chamber=ch.psi.pshell.modbus.DigitalOutput|wago 6||| gripper_dryer=ch.psi.pshell.modbus.DigitalOutput|wago 7||| valve_1=ch.psi.pshell.modbus.DigitalOutput|wago 8||| valve_2=ch.psi.pshell.modbus.DigitalOutput|wago 9||| valve_3=ch.psi.pshell.modbus.DigitalOutput|wago 10||| valve_4=ch.psi.pshell.modbus.DigitalOutput|wago 11||| #spare_do_1=ch.psi.pshell.modbus.DigitalOutput|wago 12||| #spare_do_2=ch.psi.pshell.modbus.DigitalOutput|wago 13||| #spare_do_3=ch.psi.pshell.modbus.DigitalOutput|wago 14||| #spare_do_4=ch.psi.pshell.modbus.DigitalOutput|wago 15||| phase_separator_level=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 0||1000| dewar_level=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 1||1000| rim_heater_temp=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 2||1000| air_pressure=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 3||1000| n2_pressure=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 4||1000| #spare_ai_1=ch.psi.pshell.modbus.AnalogInput|wago 5||| #spare_ai_2=ch.psi.pshell.modbus.AnalogInput|wago 6||| #spare_ai_3=ch.psi.pshell.modbus.AnalogInput|wago 7||| led_ctrl_1=ch.psi.pshell.modbus.ProcessVariable|wago 0||| led_ctrl_2=ch.psi.pshell.modbus.ProcessVariable|wago 1||| led_ctrl_3=ch.psi.pshell.modbus.ProcessVariable|wago 2||| """ ################################################################################################### # Leds ################################################################################################### def set_led_level(level): level = max(min(float(level),100.0),0.0) set_setting("led_level", level) led_ctrl_1.write(led_ctrl_1.config.maxValue * level / 100.0) led_ctrl_2.write(led_ctrl_2.config.maxValue * level / 100.0) led_ctrl_3.write(led_ctrl_3.config.maxValue * level / 100.0) def get_led_level(): level = get_setting("led_level") return float(0 if level is None else level) def set_led_state(value): """ Turn leds on and off """ if value: set_led_level(100.0) else: set_led_level(0.0) def get_led_state(): """ Returns led state (on/off) """ return led_ctrl_1.read() > 0 #TODO: The range should be set automatically reading LN2 sensor. def set_led_range(room_temp = True): """ Led range should be limitted in room temperature """ max_val = 0.40 if room_temp else 1.20 led_ctrl_1.config.maxValue = max_val led_ctrl_1.config.save() led_ctrl_2.config.maxValue = max_val led_ctrl_2.config.save() led_ctrl_3.config.maxValue = max_val led_ctrl_3.config.save() led_ctrl_1.initialize() led_ctrl_2.initialize() led_ctrl_3.initialize() if led_ctrl_1.read() > max_val: led_ctrl_1.write(max_val) if led_ctrl_2.read() > max_val: led_ctrl_2.write(max_val) if led_ctrl_3.read() > max_val: led_ctrl_3.write(max_val) set_led_level(get_led_level()) def is_led_room_temp(): return led_ctrl_1.config.maxValue <= 0.50 ################################################################################################### # Safety release ################################################################################################### def release_local(): """ Release local safety """ release_local_safety.write(False) time.sleep(0.01) release_local_safety.write(True) time.sleep(0.01) release_local_safety.write(False) def release_psys(): """ Release psys safety """ release_psys_safety.write(False) time.sleep(0.01) release_psys_safety.write(True) time.sleep(0.01) release_psys_safety.write(False)