BioImager  4.9.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
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)
 

Public Attributes

 lock
 

Protected Attributes

 _serial
 
 _lock = threading.RLock()
 

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

◆ 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

Member Data Documentation

◆ _lock

microscope.controllers.zaber._ZaberConnection._lock = threading.RLock()
protected

Definition at line 134 of file zaber.py.

◆ _serial

microscope.controllers.zaber._ZaberConnection._serial
protected
Initial value:
= serial.Serial(
port=port,
baudrate=baudrate,
timeout=timeout,
bytesize=serial.EIGHTBITS,
stopbits=serial.STOPBITS_ONE,
parity=serial.PARITY_NONE,
xonxoff=False,
rtscts=False,
dsrdtr=False,
)

Definition at line 123 of file zaber.py.

◆ lock

microscope.controllers.zaber._ZaberConnection.lock

Definition at line 151 of file zaber.py.


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