BaseInstrument module
Created on Tue Feb 27 2025
@author: Refactoring Bot
- class Instruments_Libraries.BaseInstrument.BaseInstrument(resource_str, visa_library='@py', **kwargs)[source]
Bases:
objectBase class for all instrument drivers. Handles VISA connection, communication, logging, and error handling.
- Parameters:
resource_str (str)
visa_library (str)
- Close()
Close the connection to the instrument.
- Return type:
None
- IDN()
Get the instrument identification string (
*IDN?).- Return type:
str
- OPC()
Wait until operation complete (
*OPC?).- Returns:
1 when operation is complete.
- Return type:
int
- static com_to_asrl(com_port)[source]
Convert a Windows COM port string to a PyVISA ASRL resource string.
- Parameters:
com_port (str) – Windows COM port (e.g., “COM3”).
- Returns:
VISA ASRL string (e.g., “ASRL3::INSTR”).
- Return type:
str
- get_opc()[source]
Wait until operation complete (
*OPC?).- Returns:
1 when operation is complete.
- Return type:
int
- idn()
Get the instrument identification string (
*IDN?).- Return type:
str
- opc()
Wait until operation complete (
*OPC?).- Returns:
1 when operation is complete.
- Return type:
int
- query(command)[source]
Send a query and return the response string. The instrument’s response is stripped of whitespace.
- Parameters:
command (str) – SCPI query string.
- Return type:
str
- query_ascii_values(command, **kwargs)[source]
Query for a list of ASCII values (e.g., trace data).
- Parameters:
command (str) – SCPI query command.
**kwargs (dict) – Additional arguments passed to query_ascii_values.
- Return type:
list[Any]
- query_float(command)[source]
Convenience method to query and parse a single float value.
- Parameters:
command (str) – SCPI query string.
- Return type:
float
- query_int(command)[source]
Convenience method to query and parse a single integer value.
- Parameters:
command (str) – SCPI query string.
- Return type:
int