Skip to content

Commit

Permalink
Merge pull request #11 from psychopy/stimtracker
Browse files Browse the repository at this point in the history
ENH: Support (and require) pyxid2 v1.0.7
  • Loading branch information
TEParsons authored Oct 16, 2024
2 parents b5e37b6 + 1e5d111 commit a288412
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
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

0 comments on commit a288412

Please sign in to comment.