Skip to content
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

Open_timeout stored in Session #43

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyvisa-sim/highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def open(self, session, resource_name,
# Loops through all session types, tries to parse the resource name and if ok, open it.
cls = sessions.Session.get_session_class(parsed.interface_type_const, parsed.resource_class)

sess = cls(session, resource_name, parsed)
sess = cls(session, resource_name, parsed, open_timeout)

try:
sess.device = self.devices[sess.attrs[constants.VI_ATTR_RSRC_NAME]]
Expand Down
3 changes: 2 additions & 1 deletion pyvisa-sim/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ def _internal(python_class):
return python_class
return _internal

def __init__(self, resource_manager_session, resource_name, parsed=None):
def __init__(self, resource_manager_session, resource_name, parsed=None, open_timeout=None):
if parsed is None:
parsed = rname.parse_resource_name(resource_name)
self.parsed = parsed
self.open_timeout = open_timeout
self.attrs = {constants.VI_ATTR_RM_SESSION: resource_manager_session,
constants.VI_ATTR_RSRC_NAME: str(parsed),
constants.VI_ATTR_RSRC_CLASS: parsed.resource_class,
Expand Down
8 changes: 4 additions & 4 deletions pyvisa-sim/usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
@sessions.Session.register(constants.InterfaceType.usb, 'INSTR')
class USBInstrumentSession(sessions.Session):

def __init__(self, resource_manager_session, resource_name, parsed):
super(USBInstrumentSession, self).__init__(resource_manager_session, resource_name, parsed)
def __init__(self, resource_manager_session, resource_name, parsed, open_timeout):
super(USBInstrumentSession, self).__init__(resource_manager_session, resource_name, parsed, open_timeout)

def after_parsing(self):
self.attrs[constants.VI_ATTR_INTF_NUM] = int(self.parsed.board)
Expand Down Expand Up @@ -78,8 +78,8 @@ def write(self, data):
@sessions.Session.register(constants.InterfaceType.usb, 'RAW')
class USBRawSession(sessions.Session):

def __init__(self, resource_manager_session, resource_name, parsed):
super(USBRawSession, self).__init__(resource_manager_session, resource_name, parsed)
def __init__(self, resource_manager_session, resource_name, parsed, open_timeout):
super(USBRawSession, self).__init__(resource_manager_session, resource_name, parsed, open_timeout)

def after_parsing(self):
self.attrs[constants.VI_ATTR_INTF_NUM] = int(self.parsed.board)
Expand Down