pychemstation.control.controllers.devices
26class InjectorController(DeviceController): 27 def __init__( 28 self, controller: CommunicationController, table: Table, offline: bool 29 ): 30 super().__init__(controller, table, offline) 31 32 def turn_off(self): 33 warnings.warn("Injector has no on/off state.") 34 35 def turn_on(self): 36 warnings.warn("Injector has no on/off state.") 37 38 def change_injection_volume(self, new_injection_volume: float): 39 self._update_param( 40 param=Param( 41 ptype=PType.NUM, 42 val=new_injection_volume, 43 chemstation_key=RegisterFlag.INJECTION_VOLUME, 44 ) 45 ) 46 47 def try_vial_location(self, val: str) -> Tray: 48 try: 49 return FiftyFourVialPlate.from_str(val) 50 except Exception: 51 try: 52 return VialBar(int(val)) 53 except Exception: 54 raise ValueError("Location could not be identified.") 55 56 def get_row( 57 self, row: int 58 ) -> ( 59 Draw 60 | DrawDefaultVolume 61 | Inject 62 | Wait 63 | DrawDefault 64 | DrawDefaultLocation 65 | Remote 66 ): 67 def return_location_plus() -> Tray: 68 unit = self.get_num(row, RegisterFlag.DRAW_LOCATION_UNIT) 69 tray = self.get_num(row, RegisterFlag.DRAW_LOCATION_TRAY) 70 row_ = self.get_num(row, RegisterFlag.DRAW_LOCATION_ROW) 71 col = self.get_num(row, RegisterFlag.DRAW_LOCATION_COLUMN) 72 return LocationPlus(int(unit), int(tray), int(row_), int(col)) 73 74 function = self.get_text(row, RegisterFlag.FUNCTION) 75 if function == "Wait": 76 return Wait(duration=self.get_num(row, RegisterFlag.TIME)) 77 elif function == "Inject": 78 return Inject() 79 elif function == "Draw": 80 is_source = SourceType(self.get_text(row, RegisterFlag.DRAW_SOURCE)) 81 is_volume = Mode(self.get_text(row, RegisterFlag.DRAW_VOLUME)) 82 if is_volume is not Mode.SET: 83 if is_source == SourceType.DEFAULT: 84 return DrawDefault() 85 elif is_source is SourceType.SPECIFIC_LOCATION: 86 return DrawDefaultVolume(location=return_location_plus()) 87 elif is_source is SourceType.LOCATION: 88 return DrawDefaultVolume( 89 location=self.try_vial_location( 90 self.get_text(row, RegisterFlag.DRAW_LOCATION) 91 ) 92 ) 93 else: 94 vol = self.get_num(row, RegisterFlag.DRAW_VOLUME_VALUE) 95 if is_source == SourceType.DEFAULT: 96 return DrawDefaultLocation(amount=vol) 97 elif is_source is SourceType.SPECIFIC_LOCATION: 98 return Draw(amount=vol, location=return_location_plus()) 99 elif is_source is SourceType.LOCATION: 100 return Draw( 101 amount=vol, 102 location=self.try_vial_location( 103 self.get_text(row, RegisterFlag.DRAW_LOCATION) 104 ), 105 ) 106 elif function == "Remote": 107 return Remote( 108 command=RemoteCommand(self.get_text(row, RegisterFlag.REMOTE)), 109 duration=int(self.get_num(row, RegisterFlag.REMOTE_DUR)), 110 ) 111 raise ValueError("No valid function found.") 112 113 def load(self) -> InjectorTable | None: 114 rows = self.get_row_count_safely() 115 return InjectorTable(functions=[self.get_row(i + 1) for i in range(rows)])
Abstract controller representing tables that contain device information.
Parameters
- controller: controller for sending MACROs
- table: contains register keys for accessing table in Chemstation
- offline: whether the communication controller is online.
InjectorController( controller: pychemstation.control.controllers.CommunicationController, table: pychemstation.utils.table_types.Table, offline: bool)
def
try_vial_location( self, val: str) -> Union[pychemstation.utils.tray_types.FiftyFourVialPlate, pychemstation.utils.tray_types.VialBar, pychemstation.utils.tray_types.LocationPlus]:
def
get_row( self, row: int) -> pychemstation.utils.injector_types.Draw | pychemstation.utils.injector_types.DrawDefaultVolume | pychemstation.utils.injector_types.Inject | pychemstation.utils.injector_types.Wait | pychemstation.utils.injector_types.DrawDefault | pychemstation.utils.injector_types.DrawDefaultLocation | pychemstation.utils.injector_types.Remote:
56 def get_row( 57 self, row: int 58 ) -> ( 59 Draw 60 | DrawDefaultVolume 61 | Inject 62 | Wait 63 | DrawDefault 64 | DrawDefaultLocation 65 | Remote 66 ): 67 def return_location_plus() -> Tray: 68 unit = self.get_num(row, RegisterFlag.DRAW_LOCATION_UNIT) 69 tray = self.get_num(row, RegisterFlag.DRAW_LOCATION_TRAY) 70 row_ = self.get_num(row, RegisterFlag.DRAW_LOCATION_ROW) 71 col = self.get_num(row, RegisterFlag.DRAW_LOCATION_COLUMN) 72 return LocationPlus(int(unit), int(tray), int(row_), int(col)) 73 74 function = self.get_text(row, RegisterFlag.FUNCTION) 75 if function == "Wait": 76 return Wait(duration=self.get_num(row, RegisterFlag.TIME)) 77 elif function == "Inject": 78 return Inject() 79 elif function == "Draw": 80 is_source = SourceType(self.get_text(row, RegisterFlag.DRAW_SOURCE)) 81 is_volume = Mode(self.get_text(row, RegisterFlag.DRAW_VOLUME)) 82 if is_volume is not Mode.SET: 83 if is_source == SourceType.DEFAULT: 84 return DrawDefault() 85 elif is_source is SourceType.SPECIFIC_LOCATION: 86 return DrawDefaultVolume(location=return_location_plus()) 87 elif is_source is SourceType.LOCATION: 88 return DrawDefaultVolume( 89 location=self.try_vial_location( 90 self.get_text(row, RegisterFlag.DRAW_LOCATION) 91 ) 92 ) 93 else: 94 vol = self.get_num(row, RegisterFlag.DRAW_VOLUME_VALUE) 95 if is_source == SourceType.DEFAULT: 96 return DrawDefaultLocation(amount=vol) 97 elif is_source is SourceType.SPECIFIC_LOCATION: 98 return Draw(amount=vol, location=return_location_plus()) 99 elif is_source is SourceType.LOCATION: 100 return Draw( 101 amount=vol, 102 location=self.try_vial_location( 103 self.get_text(row, RegisterFlag.DRAW_LOCATION) 104 ), 105 ) 106 elif function == "Remote": 107 return Remote( 108 command=RemoteCommand(self.get_text(row, RegisterFlag.REMOTE)), 109 duration=int(self.get_num(row, RegisterFlag.REMOTE_DUR)), 110 ) 111 raise ValueError("No valid function found.")