[docs]classCryomagneticsModelTM620(VisaInstrument):""" Driver for the Cryomagnetics TM 620 temperature monitor. Units are kG right now Args: name: a name for the instrument address: VISA address of the device """float_pattern=re.compile(r"[0-9]+\.[0-9]+")def__init__(self,name:str,address:str,**kwargs:"Unpack[VisaInstrumentKWArgs]",)->None:super().__init__(name,address,**kwargs)self.shield:Parameter=self.add_parameter(name="shield",unit="K",get_cmd=self._get_A,get_parser=float,docstring="55K Shield Temp",)"""55K shield temperature"""self.magnet:Parameter=self.add_parameter(name="magnet",unit="K",get_cmd=self._get_B,get_parser=float,docstring="4K Magnet Temp",)"""4K magnet temperature"""self.operating_mode()self.connect_message()
[docs]defoperating_mode(self,remote:bool=True)->None:""" Sets the device's operating mode to either remote or local. Args: remote: If True, sets to remote mode, otherwise sets to local mode. """ifremote:self.write("REMOTE")else:self.write("LOCAL")
def_get_A(self)->float:"""Get 55k shield temperature Returns: Temperature in Kelvin """output=self.ask("MEAS? A")output=self._parse_output(output)numeric_output=self._convert_to_numeric(output)returnnumeric_outputdef_get_B(self)->float:"""Get 4k magnet temp Returns: Temperature in Kelvin """output=self.ask("MEAS? B")output=self._parse_output(output)numeric_output=self._convert_to_numeric(output)returnnumeric_outputdef_parse_output(self,output:str)->str:"""Extract floating point number from the instrument output string. Args: output: the string returned from the instrument. Returns: parsed string containing extracted floating point number. """match=self.float_pattern.search(output)ifmatch:returnmatch.group(0)self.log.error(f"No floating point number found in output: '{output}'")raiseValueError(f"No floating point number found in output: '{output}'")def_convert_to_numeric(self,raw_value:str)->float:""" Convert a raw string value to a numeric float. Args: raw_value: The raw string value to convert. Returns: The converted float value. """try:numeric_value=float(raw_value)returnnumeric_valueexceptValueError:self.log.error(f"Error converting '{raw_value}' to float")raiseValueError(f"Unable to convert '{raw_value}' to float")