pyopticon.majumdar_lab_widgets.valco_2_way_valve_widget module

class pyopticon.majumdar_lab_widgets.valco_2_way_valve_widget.Valco2WayValveWidget(parent_dashboard, name, nickname, default_serial_port, valve_positions, valve_id='1')

Bases: GenericWidget

Widget for a VICI Valco 2-position valve, like this: https://www.vici.com/vval/vval_2pos.php . These valves have two positions that are internally referred to as ‘A’ and ‘B’. In the widget, the positions can be labeled whatever you want.

Valco produces many other valves, e.g. 9-way selector valves. To control one of them, you could probably copy-paste the source code of this module and make pretty minor modifications to on_serial_query, on_serial_read, on_confirm, and the serial emulator class. Refer to the valve’s documentation and/or mess around manually with a serial connection (Pyserial in a shell like IDLE is probably easiest) to figure out the serial protocol for controlling a different type of Valco valve – e.g., valves with more than 2 positions may label the positions with numbers rather than letters in the serial protocol.

Parameters:
  • parent_dashboard (pyopticon.dashboard.PyOpticonDashboard) – The dashboard object to which this device will be added

  • name (str) – The name that the widget will be labeled with, and under which its data will be logged, e.g. “Methane Mass Flow Controller”

  • nickname (str) – A shortened nickname that can be used to identify the widget in automation scripts, e.g. “CH4 MFC”

  • default_serial_port (str) – The name of the default selected serial port, e.g. ‘COM9’

  • valve_positions (list) – A list of strings with which to label the valve positions. For a 2-way valve, this should be a 2-element list with the labels for valve positions A and B respectively.

  • valve_id – A string representing the ID of the valve, which goes at the beginning of each command. This seems to always be ‘1’. However, if there are issues, going into a serial shell

(e.g. Pyserial in IDLE) and sending the message b’*IDr’ to the valve should cause it to respond with its ID.

on_failed_serial_open(success)

Set fields to no reading if serial failed to open.

on_update()

Update the widget by querying and reading the serial port.

on_serial_query()

Send a query to the valve asking for its current position.

on_serial_read()

Parse the responses from the previous serial query and update the display. Return True if the response is valid and an error string if not.

on_serial_close()

When serial is closed, set all readouts to ‘None’.

on_confirm()

When ‘confirm’ is pressed, send the appropriate commands to the valve.