-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Gpib events #175
Open
tivek
wants to merge
10
commits into
pyvisa:main
Choose a base branch
from
tivek:GPIB-events
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[WIP] Gpib events #175
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
10ecfa4
add preliminary support for event queueing
tivek 9f19bc9
add preliminary support for GPIB INSTR events
tivek 97761c5
fix GPIBSession.wait_on_event()
tivek 7f68a82
fix timeout bugs in GPIBSession.wait_on_event()
tivek 25784a5
change GPIBSession.valid_event_types to a set
tivek a218881
document PyVisaLibrary._generate_handle and corresponding VISA functions
tivek 5717e23
remove mechanism check from Session
tivek efd7bf0
add a simple GPIBEvent class
tivek fbcb51d
set basic GPIBEvent attributes
tivek 5fa23fd
introduce a generic EventData class
tivek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentionned in my review, I am not sure how to expose this since pyvisa does not expose events. We should perhaps think about how to expose this in pyvisa and how to make it compatible with pyvisa-py.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GPIBEvent
is not a user-facing class, it is an implementation detail:PyVisaLibrary
storesGPIBEvent
objects in thePyVisaLibrary.events
dict and passes anyget_attribute()
andclose()
calls down to them. Such "attribute query workers" are required pieces of the puzzle to fully conform to pyvisa's handle-based backend interface.I agree that pyvisa needs a more pythonic way to expose events, and I think it is actually quite straightforward to get there. Currently, events are actually exposed to the user as raw VISA event contexts/handles. This is not very pythonic but is nevertheless there as a public and documented API. Our user can get hold of an event handle in two main ways:
visalib
calls the installed event handlers and passes the event handle as a parameter,Resource.wait_on_event()
returns aWaitResponse
object which exposes a member calledcontext
.In both cases, the user can find out more about the event by calling
visalib.get_attribute(handle, attribute)
or close the event usingvisalib.close(handle)
. EDIT: ... and this is whyGPIBEvent
is there, to provide access-by-handle functionality forPyVisaLibrary
in order to fully emulateNIVisaLibrary
's behavior.Instead of low-level handles/contexts, pyvisa should give users some kind of an event object that can be queried and knows how to clean up when it is done. The
WaitResponse
class already fits the bill nicely: all it needs to become user-friendly areget_attribute()
andclose()
methods and renaming it eg.Event
. The remaining step is to wrap user-provided event handlers so that they are passedEvent
objects when called instead of raw event handles.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed this sounds like a plan.
For the work at hand, even if we do not implement event support right away, we can probably set up a generic class that could be used by all resources rather than an explicitly GPIB restricted class, no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Looks pretty generic actually. If any session needs to compute event attributes on the fly, they can override get_attributes(). Right now I'm struggling with bikeshedding :) I think "Event" should only be the name of the user-facing pyvisa class.