BioImager  3.9.1
A .NET microscopy imaging library. Supports various microscopes by using imported libraries & GUI automation. Supported libraries include PriorĀ® & ZeissĀ® & all devices supported by Micromanager 2.0 and python-microscope.
Loading...
Searching...
No Matches
microscope.controllers.zaber._ZaberConnection Class Reference

Public Member Functions

None __init__ (self, str port, int baudrate, float timeout)
 
threading.RLock lock (self)
 
int write (self, bytes data)
 
bytes readline (self, int size=-1)
 

Detailed Description

Wraps a serial connection with a reentrant lock.

This class is just the wrap to :class:`serial.Serial`.  The class
exposing the Zaber commands interface is
:class:`_ZaberDeviceConnection`.

.. todo: replace with microscope._utils.SharedSerial

Definition at line 112 of file zaber.py.

Constructor & Destructor Documentation

◆ __init__()

None microscope.controllers.zaber._ZaberConnection.__init__ (   self,
str  port,
int  baudrate,
float  timeout 
)

Definition at line 122 of file zaber.py.

122 def __init__(self, port: str, baudrate: int, timeout: float) -> None:
123 self._serial = serial.Serial(
124 port=port,
125 baudrate=baudrate,
126 timeout=timeout,
127 bytesize=serial.EIGHTBITS,
128 stopbits=serial.STOPBITS_ONE,
129 parity=serial.PARITY_NONE,
130 xonxoff=False,
131 rtscts=False,
132 dsrdtr=False,
133 )
134 self._lock = threading.RLock()
135 with self._lock:
136 # The command / does nothing other than getting a response
137 # from all devices in the chain. This seems to be the
138 # most innocent command we can use.
139 self._serial.write(b"/\n")
140 lines = self._serial.readlines()
141 if not all([l.startswith(b"@") for l in lines]):
142 raise RuntimeError(
143 "'%s' does not respond like a Zaber device" % port
144 )
145

Member Function Documentation

◆ lock()

threading.RLock microscope.controllers.zaber._ZaberConnection.lock (   self)

Definition at line 147 of file zaber.py.

147 def lock(self) -> threading.RLock:
148 return self._lock
149

◆ readline()

bytes microscope.controllers.zaber._ZaberConnection.readline (   self,
int   size = -1 
)

Definition at line 154 of file zaber.py.

154 def readline(self, size: int = -1) -> bytes:
155 with self.lock:
156 return self._serial.readline(size)
157
158

Referenced by microscope.controllers.prior._ProScanIIIConnection.get_command(), microscope.stages.ludl._LudlController.get_command(), and microscope.stages.ludl._LudlController.readline().

◆ write()

int microscope.controllers.zaber._ZaberConnection.write (   self,
bytes  data 
)

Definition at line 150 of file zaber.py.

150 def write(self, data: bytes) -> int:
151 with self.lock:
152 return self._serial.write(data)
153

The documentation for this class was generated from the following file: