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

ENH: Support (and require) pyxid2 v1.0.7 #11

Merged
merged 1 commit into from
Oct 16, 2024
Merged
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
21 changes: 1 addition & 20 deletions psychopy_cedrus/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,14 @@ class BaseXidDevice(BaseDevice):
)
# all Cedrus devices have a product ID - subclasses should specify what this is
productId = None
# keep track of instances, as pyxid2 will not show active instances
instances = []

def __init__(self, index=0):
# give error if no device connected
if not len(self.getAvailableDevices()):
raise ConnectionError("No Cedrus device is connected.")
# get xid device
self.index = index
self.xid = pyxid2.get_xid_device(index)
# store xid instance
BaseXidDevice.instances.append(self)
self.xid = pyxid2.get_xid_devices()[index]
# nodes
self.nodes = []
# dict of responses by timestamp
Expand All @@ -54,15 +50,6 @@ def __init__(self, index=0):
self._lastTimerReset = None
self.resetTimer()

def __del__(self):
# remove instance from record on deletion
i = None
for i, obj in enumerate(self.instances):
if obj is self:
break
if i is not None:
self.instances.pop(i)

@classmethod
def resolve(cls, requested):
"""
Expand Down Expand Up @@ -146,12 +133,6 @@ def getAvailableDevices(cls):
'deviceName': profile.device_name,
'index': i,
})
# get_xid_devices only shows unconnected devices, so include connected ones here
for (i, inst) in enumerate(BaseXidDevice.instances):
devices.append({
'deviceName': inst.xid.device_name,
'index': inst.index,
})

return devices

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ urls.homepage = "https://psychopy.github.io/psychopy-cedrus"
urls.changelog = "https://github.com/psychopy/psychopy-cedrus/blob/main/CHANGELOG.txt"

dependencies = [
"pyxid2"
"pyxid2>=1.0.7"
]

[project.optional-dependencies]
Expand Down
Loading