Base Class¶
All instrument drivers inherit from DeviceManager, which handles the PyVISA connection lifecycle.
DeviceManager¶
DeviceManager ¶
Base class for SCPI instrument drivers using PyVISA.
All instrument drivers inherit from this class and gain a shared PyVISA connection lifecycle (connect / disconnect) plus thin wrappers around the two most common SCPI operations: write-only commands and query-response commands.
Attributes:
| Name | Type | Description |
|---|---|---|
resource_name |
VISA resource string passed at construction time,
e.g. |
|
instrument |
The open |
connect ¶
Open a PyVISA session to the instrument.
Sets a 5-second timeout and "\n" read termination on the
session. Prints a confirmation message on success.
Raises:
| Type | Description |
|---|---|
VisaIOError
|
If the resource cannot be opened (e.g. instrument is off, address is wrong, or no VISA driver is installed). |
disconnect ¶
Close the PyVISA session and release the instrument handle.
Safe to call even when not connected — does nothing if
self.instrument is already None.
send_command ¶
Write a SCPI command to the instrument (fire-and-forget).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
SCPI command string, e.g. |
required |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the instrument session is not open. |
query ¶
Write a SCPI command and return the instrument's response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
SCPI query string, e.g. |
required |
Returns:
| Type | Description |
|---|---|
|
The response string with leading/trailing whitespace stripped. |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the instrument session is not open. |
clear_status ¶
Send *CLS to clear the instrument's status registers.
Clears the Standard Event Status Register (SESR), the Status Byte Register (STB), and the error queue. Typically called during initialisation before issuing other commands.
reset ¶
Send *RST followed by *CLS to restore factory defaults.
Resets all instrument settings to their power-on defaults and then clears the status registers. Use at the start of a test sequence to guarantee a known instrument state.