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.toptica._iChromeConnection Class Reference

Public Member Functions

None __init__ (self, microscope._utils.SharedSerial shared_serial)
 
bytes param_ref (self, bytes name)
 
None param_set (self, bytes name, bytes value)
 
str get_serial_number (self)
 
str get_system_type (self)
 

Protected Member Functions

bytes _param_command (self, bytes command)
 

Protected Attributes

 _serial = shared_serial
 

Detailed Description

Connection to the iChrome MLE.

This is a simple wrapper to the iChrome MLE interface.  It only
supports the parameter commands which reply with a single line
which is all we need to support this on Python-Microscope.

Definition at line 45 of file toptica.py.

Constructor & Destructor Documentation

◆ __init__()

None microscope.controllers.toptica._iChromeConnection.__init__ ( self,
microscope._utils.SharedSerial shared_serial )

Definition at line 54 of file toptica.py.

54 def __init__(self, shared_serial: microscope._utils.SharedSerial) -> None:
55 self._serial = shared_serial
56
57 self._serial.readlines() # discard anything that may be on the line
58
59 if self.get_system_type() != "iChrome-MLE":
60 raise microscope.DeviceError("not an iChrome MLE device")
61

Member Function Documentation

◆ _param_command()

bytes microscope.controllers.toptica._iChromeConnection._param_command ( self,
bytes command )
protected
Run command and return raw answer (minus prompt and echo).

Definition at line 62 of file toptica.py.

62 def _param_command(self, command: bytes) -> bytes:
63 """Run command and return raw answer (minus prompt and echo)."""
64 command = command + b"\r\n"
65 with self._serial.lock:
66 self._serial.write(command)
67 answer = self._serial.read_until(b"\r\n> ")
68
69 # When we read, we are reading the whole command console
70 # including the prompt and even the command is echoed back.
71 assert answer[: len(command)] == command and answer[-4:] == b"\r\n> "
72
73 # Errors are indicated by the string "Error: " at the
74 # beginning of a new line.
75 if answer[len(command) : len(command) + 7] == b"Error: ":
76 base_command = command[:-2]
77 error_msg = answer[len(command) + 8 : -4]
79 "error on command '%s': %s"
80 % (base_command.decode(), error_msg.decode())
81 )
82
83 # Return the answer minus the "echoed" command and the prompt
84 # for the next command.
85 return answer[len(command) : -4]
86

◆ get_serial_number()

str microscope.controllers.toptica._iChromeConnection.get_serial_number ( self)

Definition at line 101 of file toptica.py.

101 def get_serial_number(self) -> str:
102 return _parse_string(self.param_ref(b"serial-number"))
103

◆ get_system_type()

str microscope.controllers.toptica._iChromeConnection.get_system_type ( self)

Definition at line 104 of file toptica.py.

104 def get_system_type(self) -> str:
105 return _parse_string(self.param_ref(b"system-type"))
106
107

◆ param_ref()

bytes microscope.controllers.toptica._iChromeConnection.param_ref ( self,
bytes name )
Get parameter value (`param-ref` operator).

Definition at line 87 of file toptica.py.

87 def param_ref(self, name: bytes) -> bytes:
88 """Get parameter value (`param-ref` operator)."""
89 return self._param_command(b"(param-ref '%s)" % name)
90

◆ param_set()

None microscope.controllers.toptica._iChromeConnection.param_set ( self,
bytes name,
bytes value )
Change parameter (`param-set!` operator).

Definition at line 91 of file toptica.py.

91 def param_set(self, name: bytes, value: bytes) -> None:
92 """Change parameter (`param-set!` operator)."""
93 answer = self._param_command(b"(param-set! '%s %s)" % (name, value))
94 status = int(answer)
95 if status < 0:
97 "Failed to set parameter %s (return value %d)"
98 % (name.decode(), status)
99 )
100

Member Data Documentation

◆ _serial

microscope.controllers.toptica._iChromeConnection._serial = shared_serial
protected

Definition at line 55 of file toptica.py.


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