PyVISA¤
PyVISA
(Interface)
¤
PyVISA(equipment: Equipment)
Use PyVISA as the backend to communicate with the equipment.
The backend value must be equal to
PyVISA to use this class for the communication backend.
The PYVISA_LIBRARY environment variable is used (if it exists) to create the
ResourceManager. This environment variable
can be defined in a configuration file or by defining the
environment variable in your code before connecting to the equipment using
PyVISA for the first time. The default
value is @ivi if this environment variable is not defined.
The returned object using msl-equipment to connect to the equipment is equivalent
to calling open_resource, e.g.,
from msl.equipment import Backend, Connection
connection = Connection("GPIB::12", backend=Backend.PyVISA)
inst = connection.connect()
print(inst.query("*IDN?"))
is equivalent to
import pyvisa
rm = pyvisa.ResourceManager()
inst = rm.open_resource("GPIB::12")
print(inst.query("*IDN?"))
You can also combine the packages, use msl-equipment for managing information
about the equipment and directly use pyvisa for the connection. If you use this
combination, the editor you use to develop your code may have better support for
features like code completion and type checking.
import pyvisa
from msl.equipment import Config
# config.xml contains <equipment eid="MSLE.0.063" name="dmm"/>
# and specifies where the equipment registers are and the connections file.
cfg = Config("config.xml")
equipment = cfg.equipment["dmm"]
rm = pyvisa.ResourceManager()
inst = rm.open_resource(equipment.connection.address)
data = inst.query("READ?")
# You could now use the `equipment` instance to apply a correction to the `data`
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
equipment
|
Equipment
|
An Equipment instance. |
required |
Source code in src/msl/equipment/interfaces/pyvisa.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
disconnect
¤
disconnect() -> None
Calls pyvisa.resources.Resource.close.
Source code in src/msl/equipment/interfaces/pyvisa.py
126 127 128 129 130 131 132 | |