@@ -7824,6 +7824,112 @@ async def send_hhs_command(self, index: int, command: str, **kwargs) -> str:
78247824 assert isinstance (resp , str )
78257825 return resp
78267826
7827+ # ------------ STAR(RS-232/TCC1/2)-connected Hamilton Heater Cooler (HHS) -------------
7828+
7829+ async def check_type_is_hhc (self , device_number : int ):
7830+ """
7831+ Convenience method to check that connected device is an HHC.
7832+ Executed through firmware query
7833+ """
7834+
7835+ firmware_version = await self .send_command (module = f"T{ device_number } " , command = "RF" )
7836+ if "Hamilton Heater Cooler" not in firmware_version :
7837+ raise ValueError (
7838+ f"Device number { device_number } does not connect to a Hamilton"
7839+ f" Heater-Cooler, found { firmware_version } instead."
7840+ f"Have you called the wrong device number?"
7841+ )
7842+
7843+ async def initialize_hhc (self , device_number : int ) -> str :
7844+ """Initialize Hamilton Heater Cooler (HHC) at specified TCC port
7845+
7846+ Args:
7847+ device_number: TCC connect number to the HHC
7848+ """
7849+
7850+ module_pointer = f"T{ device_number } "
7851+
7852+ # Request module configuration
7853+ try :
7854+ await self .send_command (module = module_pointer , command = "QU" )
7855+ except TimeoutError as exc :
7856+ error_message = (
7857+ f"No Hamilton Heater Cooler found at device_number { device_number } "
7858+ f", have you checked your connections? Original error: { exc } "
7859+ )
7860+ raise ValueError (error_message ) from exc
7861+
7862+ await self .check_type_is_hhc (device_number )
7863+
7864+ # Request module configuration
7865+ hhc_init_status = await self .send_command (module = module_pointer , command = "QW" , fmt = "qw#" )
7866+ hhc_init_status = hhc_init_status ["qw" ]
7867+
7868+ info = "HHC already initialized"
7869+ # Initializing HHS if necessary
7870+ if hhc_init_status != 1 :
7871+ # Initialize device
7872+ await self .send_command (module = module_pointer , command = "LI" )
7873+ info = f"HHS at device number { device_number } initialized."
7874+
7875+ return info
7876+
7877+ async def start_temperature_control_at_hhc (
7878+ self ,
7879+ device_number : int ,
7880+ temp : Union [float , int ],
7881+ ):
7882+ """Start temperature regulation of specified HHC"""
7883+
7884+ await self .check_type_is_hhc (device_number )
7885+ assert 0 < temp <= 105
7886+
7887+ # Ensure proper temperature input handling
7888+ if isinstance (temp , (float , int )):
7889+ safe_temp_str = f"{ round (temp * 10 ):04d} "
7890+ else :
7891+ safe_temp_str = str (temp )
7892+
7893+ return await self .send_command (
7894+ module = f"T{ device_number } " ,
7895+ command = "TA" , # temperature adjustment
7896+ ta = safe_temp_str ,
7897+ tb = "1800" , # TODO: identify precise purpose?
7898+ tc = "0020" , # TODO: identify precise purpose?
7899+ )
7900+
7901+ async def get_temperature_at_hhc (self , device_number : int ) -> dict :
7902+ """Query current temperatures of both sensors of specified HHC"""
7903+
7904+ await self .check_type_is_hhc (device_number )
7905+
7906+ request_temperature = await self .send_command (module = f"T{ device_number } " , command = "RT" )
7907+ processed_t_info = [int (x ) / 10 for x in request_temperature .split ("+" )[- 2 :]]
7908+
7909+ return {
7910+ "middle_T" : processed_t_info [0 ],
7911+ "edge_T" : processed_t_info [- 1 ],
7912+ }
7913+
7914+ async def query_whether_temperature_reached_at_hhc (self , device_number : int ):
7915+ """Stop temperature regulation of specified HHC"""
7916+
7917+ await self .check_type_is_hhc (device_number )
7918+ query_current_control_status = await self .send_command (
7919+ module = f"T{ device_number } " , command = "QD" , fmt = "qd#"
7920+ )
7921+
7922+ return query_current_control_status ["qd" ] == 0
7923+
7924+ async def stop_temperature_control_at_hhc (self , device_number : int ):
7925+ """Stop temperature regulation of specified HHC"""
7926+
7927+ await self .check_type_is_hhc (device_number )
7928+
7929+ return await self .send_command (module = f"T{ device_number } " , command = "TO" )
7930+
7931+ # -------------- Extra - Probing labware with STAR - making STAR into a CMM --------------
7932+
78277933
78287934class UnSafe :
78297935 """
0 commit comments