Source code for device.trap_probe
from types import SimpleNamespace
from . import base
[docs]
class TrapProbe(base.ArduinoProbeBase):
"""Arduino controller that handles a Langmuir probe (Magnetic trap).
Communication:
- serial interface to Arduino
"""
def __init__(self, bus, **kwargs):
"""Constructor
:param str bus: Name of serial bus where Arduino is connected,
e.g. '/dev/ttyUSB0'
"""
super().__init__(bus=bus, start_msg="START Past Langmuir + ventil", **kwargs)
self._last = SimpleNamespace(
valve_open=False,
board_enabled=False,
)
# ==== Commands ====
[docs]
def is_valve_open(self):
"""Status of the valve."""
return self._last.valve_open
[docs]
@base.base_command
def open_valve(self):
"""Open the valve."""
if not self._last.valve_open:
self._write("v")
self._last.valve_open = True
[docs]
@base.base_command
def close_valve(self):
"""Close the valve."""
if self._last.valve_open:
self._write("v")
self._last.valve_open = False
[docs]
def is_board_enabled(self):
"""Status of the board."""
return self._last.board_enabled
[docs]
@base.base_command
def switch_board_on(self):
"""Turn on the board."""
if not self._last.board_enabled:
self._write("i")
self._last.board_enabled = True
[docs]
@base.base_command
def switch_board_off(self):
"""Turn off the board."""
if self._last.board_enabled:
self._write("i")
self._last.board_enabled = False