Open tivek opened 6 years ago
I am not familiar with events in VISA I must say so I have no idea how difficult it would be to provide support for them. However as I suspect this will be quite dependent on the session (I assume it will not imply the same low level manipulations) so we can probably just add the required indirection in PyVisaLibrary and implement them on a per session basis. If you are interested on working on this you are welcome.
Also not too familiar with VISA events but I will give it a try. I hope to get back to you soon with some basic GPIB event queue functionality, timing depends on how often I manage to get access to instruments.
@tivek the enable_event is correspond to viEnableEvent which is a function in the NI-VISA library, and the pyvisa provides wrapping to NI_VISA library but that is only available on "@ni" backend. Otherwise you can find these functions in "pyvisa/highlevel.py"
After a long while without regular access to a GPIB board and instruments, I started working on per-session event support a separate branch. Will post updates here.
Sounds great @tivek ! Please keep us posted.
@MatthieuDartiailh, I'm slowly hacking away on this. The GPIB-events branch is still not ready but event-related calls from PyVisaLib to Session objects have been wired through. Also, some preliminary support for GPIB events is in with some timeout-related bugs left to squash. Next is making events proper objects with .close(), .get_attribute() etc.
This seems to be a good time to ask for some feedback.
In particular, I wonder about storing event objects in its separate dict, PyVisaLibrary.events, as opposed to .sessions with which they share the pool of handles: https://github.com/tivek/pyvisa-py/blob/9f19bc992e89ae9c16f0a8af1090027cbb54edbd/pyvisa-py/highlevel.py#L103.
Also, I would like to hear your thoughts on ways to implement Attribute.in_resource() for event-related attributes. As it is now, attributes seem to expect sessions only.
Could you open a [WIP] PR to make the changes easier to review and comment on ? I should be able to review it tonight.
pyvisa.resources.gpib.GPIBInstrument.wait_for_srq()
callsenable_event()
,wait_on_event()
, anddiscard_events()
of the underlying visalib. However,PyVisaLibrary
does not implement those methods soNotImplementedError
is raised.One way to go about this is to delegate the missing methods to underlying pyvisa-py session objects and implement event support there.
Another possibility is to notice that
wait_for_srq()
is quite universal - in particular, VISA Service Request events should be supported by GPIB INSTR, GPIB INTFC, GPIB-VXI INSTR, TCPIP INSTR, USB INSTR, and VXI INSTR. So,wait_for_srq()
could be moved topyvisa.highlevel.VisaLibraryBase
. This would make it easier to implement an overload inPyVisaLibrary
before full-blown event support in pyvisa-py is ready.