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.abc.SerialDeviceMixin Class Reference
Inheritance diagram for microscope.abc.SerialDeviceMixin:
microscope.lights.cobolt.CoboltLaser microscope.lights.deepstar.DeepstarLaser microscope.lights.obis.ObisLaser microscope.lights.sapphire.SapphireLaser

Public Member Functions

def __init__ (self, **kwargs)
 

Static Public Member Functions

def lock_comms (func)
 

Public Attributes

 connection
 

Detailed Description

Mixin for devices that are controlled via serial.

DEPRECATED: turns out that this was a bad idea.  A device that has
  a serial connection is not a serial connection.  The "has a" and
  the not "is a" should have told us that we should have been
  using composition instead of subclassing, but there you go.

Currently handles the flushing and locking of the comms channel
until a command has finished, and the passthrough to the serial
channel.

Definition at line 993 of file abc.py.

Constructor & Destructor Documentation

◆ __init__()

def microscope.abc.SerialDeviceMixin.__init__ (   self,
**  kwargs 
)

Definition at line 1007 of file abc.py.

1007 def __init__(self, **kwargs):
1008 super().__init__(**kwargs)
1009 # TODO: We should probably construct the connection here but
1010 # the Serial constructor takes a lot of arguments, and
1011 # it becomes tricky to separate those from arguments to
1012 # the constructor of other parent classes.
1013 self.connection = None # serial.Serial (to be constructed by child)
1014 self._comms_lock = threading.RLock()
1015

Member Function Documentation

◆ lock_comms()

def microscope.abc.SerialDeviceMixin.lock_comms (   func)
static
Decorator to flush input buffer and lock communications.

There have been problems with the DeepStar lasers returning
junk characters after the expected response, so it is
advisable to flush the input buffer prior to running a command
and subsequent readline.  It also locks the comms channel so
that a function must finish all its communications before
another can run.

Definition at line 1030 of file abc.py.

1030 def lock_comms(func):
1031 """Decorator to flush input buffer and lock communications.
1032
1033 There have been problems with the DeepStar lasers returning
1034 junk characters after the expected response, so it is
1035 advisable to flush the input buffer prior to running a command
1036 and subsequent readline. It also locks the comms channel so
1037 that a function must finish all its communications before
1038 another can run.
1039
1040 """
1041
1042 @functools.wraps(func)
1043 def wrapper(self, *args, **kwargs):
1044 with self._comms_lock:
1045 self.connection.flushInput()
1046 return func(self, *args, **kwargs)
1047
1048 return wrapper
1049
1050

References microscope.abc.SerialDeviceMixin._comms_lock, microscope.abc.SerialDeviceMixin.connection, microscope.filterwheels.thorlabs.ThorlabsFilterWheel.connection, microscope.lights.cobolt.CoboltLaser.connection, microscope.lights.deepstar.DeepstarLaser.connection, microscope.lights.obis.ObisLaser.connection, and microscope.lights.sapphire.SapphireLaser.connection.

Member Data Documentation

◆ connection


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