ezmsg-peripheraldevice 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/PKG-INFO +4 -4
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/docs/source/_templates/autosummary/module.rst +1 -0
- ezmsg_peripheraldevice-0.4.0/docs/source/_templates/navbar-logo.html +18 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/docs/source/conf.py +4 -1
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/pyproject.toml +2 -2
- ezmsg_peripheraldevice-0.4.0/src/ezmsg/peripheraldevice/__version__.py +24 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/src/ezmsg/peripheraldevice/mouse.py +9 -6
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/tests/test_mouse.py +62 -1
- ezmsg_peripheraldevice-0.3.0/src/ezmsg/peripheraldevice/__version__.py +0 -34
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/.github/workflows/docs.yml +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/.github/workflows/python-publish.yml +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/.github/workflows/python-tests.yml +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/.gitignore +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/.pre-commit-config.yaml +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/LICENSE +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/README.md +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/docs/Makefile +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/docs/make.bat +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/docs/source/api/index.rst +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/docs/source/index.md +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/examples/mouse_listen.py +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/examples/mouse_poll.py +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/src/ezmsg/peripheraldevice/__init__.py +0 -0
- {ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/tests/test_example.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: ezmsg-peripheraldevice
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Modules to stream data from peripheral devices into ezmsg
|
|
5
5
|
Author-email: Chadwick Boulay <chadwick.boulay@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
License-File: LICENSE
|
|
8
8
|
Requires-Python: >=3.10
|
|
9
|
-
Requires-Dist: ezmsg-baseproc>=1.
|
|
10
|
-
Requires-Dist: ezmsg>=3.
|
|
9
|
+
Requires-Dist: ezmsg-baseproc>=1.17.0
|
|
10
|
+
Requires-Dist: ezmsg>=3.10.0b7
|
|
11
11
|
Requires-Dist: numpy>=1.26.0
|
|
12
12
|
Requires-Dist: pynput>=1.8.1
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{# Override of pydata-sphinx-theme's navbar-logo component.
|
|
2
|
+
Splits the brand into two links: the logo image goes to the ezmsg.org
|
|
3
|
+
landing page (``logo.link``) and the title text goes to this site's root. #}
|
|
4
|
+
{% set org_href = theme_logo.get("link") or pathto(root_doc) %}
|
|
5
|
+
{% set alt = theme_logo.get("alt_text", "ezmsg.org") %}
|
|
6
|
+
{% if "light" in theme_logo["image_relative"] %}
|
|
7
|
+
{% if default_mode is undefined or default_mode == "auto" %}
|
|
8
|
+
{% set default_mode = "light" %}
|
|
9
|
+
{% endif %}
|
|
10
|
+
{% set js_mode = "light" if default_mode == "dark" else "dark" %}
|
|
11
|
+
<a class="navbar-brand logo" href="{{ org_href }}" title="ezmsg.org" style="margin-right: 0.75rem;">
|
|
12
|
+
<img src="{{ theme_logo['image_relative'][default_mode] }}" class="logo__image only-{{ default_mode }}" alt="{{ alt }}"/>
|
|
13
|
+
<img src="{{ theme_logo['image_relative'][js_mode] }}" class="logo__image only-{{ js_mode }} pst-js-only" alt="{{ alt }}"/>
|
|
14
|
+
</a>
|
|
15
|
+
{% endif %}
|
|
16
|
+
<a class="navbar-brand logo" href="{{ pathto(root_doc) }}">
|
|
17
|
+
<p class="title logo__title">{{ theme_logo.get("text") or docstitle }}</p>
|
|
18
|
+
</a>
|
|
@@ -85,7 +85,10 @@ html_baseurl = "https://www.ezmsg.org/ezmsg-peripheraldevice/"
|
|
|
85
85
|
html_theme_options = {
|
|
86
86
|
"logo": {
|
|
87
87
|
"text": f"ezmsg.peripheraldevice {version}",
|
|
88
|
-
"link": "https://ezmsg.org",
|
|
88
|
+
"link": "https://www.ezmsg.org",
|
|
89
|
+
"image_light": "https://www.ezmsg.org/_static/_images/ezmsg_logo.png",
|
|
90
|
+
"image_dark": "https://www.ezmsg.org/_static/_images/ezmsg_logo.png",
|
|
91
|
+
"alt_text": "ezmsg.org",
|
|
89
92
|
},
|
|
90
93
|
"header_links_before_dropdown": 4,
|
|
91
94
|
"navbar_start": ["navbar-logo"],
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '0.4.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 4, 0)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|
{ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/src/ezmsg/peripheraldevice/mouse.py
RENAMED
|
@@ -17,7 +17,7 @@ from ezmsg.baseproc import (
|
|
|
17
17
|
ClockDrivenState,
|
|
18
18
|
processor_state,
|
|
19
19
|
)
|
|
20
|
-
from ezmsg.util.messages.axisarray import AxisArray, replace
|
|
20
|
+
from ezmsg.util.messages.axisarray import AxisArray, compute_config_id, replace
|
|
21
21
|
from pynput.mouse import Controller, Listener
|
|
22
22
|
|
|
23
23
|
# =============================================================================
|
|
@@ -138,14 +138,18 @@ class MousePollerProducer(BaseClockDrivenProducer[MousePollerSettings, MousePoll
|
|
|
138
138
|
data=np.zeros((n_time_for_template, 2), dtype=np.float64),
|
|
139
139
|
dims=["time", "ch"],
|
|
140
140
|
axes={
|
|
141
|
-
|
|
141
|
+
# Not `time_axis`, the clock tick: the outputs' time axis is 1 / fs (BaseClockDrivenProducer),
|
|
142
|
+
# and config_id digests its gain. The poll timing above still follows the tick.
|
|
143
|
+
"time": AxisArray.TimeAxis(fs=self.settings.fs),
|
|
142
144
|
"ch": AxisArray.CoordinateAxis(
|
|
143
145
|
data=np.array(["x", "y"]),
|
|
144
146
|
dims=["ch"],
|
|
145
147
|
),
|
|
146
148
|
},
|
|
147
149
|
key="mouse",
|
|
150
|
+
segment=0 if self._state.template is None else self._state.template.segment + 1,
|
|
148
151
|
)
|
|
152
|
+
self._state.template.config_id = compute_config_id(self._state.template)
|
|
149
153
|
|
|
150
154
|
def _poll_loop(self) -> None:
|
|
151
155
|
"""Background thread that polls mouse at poll_rate."""
|
|
@@ -297,11 +301,10 @@ class MouseListenerProducer(BaseStatefulProducer[MouseListenerSettings, AxisArra
|
|
|
297
301
|
),
|
|
298
302
|
},
|
|
299
303
|
key="mouse",
|
|
304
|
+
# Events have no regular rate, so only a restarted listener breaks the stream.
|
|
305
|
+
segment=0 if self._state.template is None else self._state.template.segment + 1,
|
|
300
306
|
)
|
|
301
|
-
|
|
302
|
-
def _hash_message(self) -> int:
|
|
303
|
-
# Return constant - state persists across calls
|
|
304
|
-
return 0
|
|
307
|
+
self._state.template.config_id = compute_config_id(self._state.template)
|
|
305
308
|
|
|
306
309
|
def _drain_queue(self) -> tuple[list[float], list[float], list[float]]:
|
|
307
310
|
"""Drain all events from queue."""
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"""Tests for mouse input module."""
|
|
2
2
|
|
|
3
|
+
import logging
|
|
3
4
|
import time as time_module
|
|
4
5
|
from unittest.mock import MagicMock, patch
|
|
5
6
|
|
|
7
|
+
import ezmsg.baseproc.stateful
|
|
6
8
|
import numpy as np
|
|
7
|
-
from ezmsg.util.messages.axisarray import AxisArray
|
|
9
|
+
from ezmsg.util.messages.axisarray import AxisArray, compute_config_id
|
|
8
10
|
|
|
9
11
|
from ezmsg.peripheraldevice.mouse import (
|
|
10
12
|
MouseListenerProducer,
|
|
@@ -187,6 +189,36 @@ class TestMousePollerProducer:
|
|
|
187
189
|
# No thread should be running
|
|
188
190
|
assert producer._state.use_thread is False
|
|
189
191
|
|
|
192
|
+
@patch("ezmsg.peripheraldevice.mouse.compute_config_id", wraps=compute_config_id)
|
|
193
|
+
@patch("ezmsg.peripheraldevice.mouse.Controller")
|
|
194
|
+
def test_config_id_and_segment(self, mock_controller_class, mock_compute, monkeypatch, caplog):
|
|
195
|
+
"""One declared id per layout; a new segment per reset; the tick's gain stays out of the id."""
|
|
196
|
+
mock_controller_class.return_value = MagicMock(position=(1, 2))
|
|
197
|
+
# The output check must find nothing to correct.
|
|
198
|
+
monkeypatch.setattr(ezmsg.baseproc.stateful, "_warned_unannounced", set())
|
|
199
|
+
|
|
200
|
+
# One sample per tick (no thread) from a 10 Hz clock, labelled 60 Hz as before.
|
|
201
|
+
producer = MousePollerProducer(MousePollerSettings(fs=60.0, n_time=1))
|
|
202
|
+
with caplog.at_level(logging.WARNING, logger="ezmsg.baseproc.stateful"):
|
|
203
|
+
first = [producer(AxisArray.LinearAxis(gain=0.1, offset=i * 0.1)) for i in range(3)]
|
|
204
|
+
# A new clock rate resets (restarts polling): new segment, same layout.
|
|
205
|
+
faster = [producer(AxisArray.LinearAxis(gain=0.05, offset=1 + i * 0.05)) for i in range(3)]
|
|
206
|
+
producer.update_settings(MousePollerSettings(fs=120.0, n_time=1))
|
|
207
|
+
relabelled = [producer(AxisArray.LinearAxis(gain=0.05, offset=2 + i * 0.05)) for i in range(3)]
|
|
208
|
+
assert not caplog.records
|
|
209
|
+
|
|
210
|
+
for msgs, fs in ((first, 60.0), (faster, 60.0), (relabelled, 120.0)):
|
|
211
|
+
assert msgs[0].axes["time"].gain == 1 / fs
|
|
212
|
+
assert len({m.config_id for m in msgs}) == len({m.segment for m in msgs}) == 1
|
|
213
|
+
assert all(m.config_id and m.config_id == compute_config_id(m) for m in msgs)
|
|
214
|
+
assert faster[0].config_id == first[0].config_id
|
|
215
|
+
assert relabelled[0].config_id != first[0].config_id
|
|
216
|
+
assert [first[0].segment, faster[0].segment, relabelled[0].segment] == [0, 1, 2]
|
|
217
|
+
assert mock_compute.call_count == 3 # once per reset, not per message
|
|
218
|
+
|
|
219
|
+
other = MousePollerProducer(MousePollerSettings(fs=60.0, n_time=1))
|
|
220
|
+
assert other(AxisArray.LinearAxis(gain=0.1, offset=0.0)).segment == 0 # a fresh instance starts at 0
|
|
221
|
+
|
|
190
222
|
|
|
191
223
|
class TestMouseListenerProducer:
|
|
192
224
|
"""Tests for MouseListenerProducer."""
|
|
@@ -336,3 +368,32 @@ class TestMouseListenerProducer:
|
|
|
336
368
|
assert event2[0] == 160
|
|
337
369
|
assert event2[1] == 260
|
|
338
370
|
assert isinstance(event2[2], float) # timestamp
|
|
371
|
+
|
|
372
|
+
@patch("ezmsg.peripheraldevice.mouse.compute_config_id", wraps=compute_config_id)
|
|
373
|
+
@patch("ezmsg.peripheraldevice.mouse.Listener")
|
|
374
|
+
def test_config_id_and_segment(self, mock_listener_class, mock_compute):
|
|
375
|
+
"""Every message declares the template's id; a restarted listener starts a new segment."""
|
|
376
|
+
mock_listener_class.return_value = MagicMock()
|
|
377
|
+
producer = MouseListenerProducer(MouseListenerSettings())
|
|
378
|
+
producer()
|
|
379
|
+
|
|
380
|
+
msgs = []
|
|
381
|
+
for i in range(3):
|
|
382
|
+
producer._state.event_queue.put((float(i), float(i), time_module.monotonic() + i))
|
|
383
|
+
producer._state.event_queue.put((float(i), float(i), time_module.monotonic() + i + 0.5))
|
|
384
|
+
msgs.append(producer())
|
|
385
|
+
assert len({m.config_id for m in msgs}) == len({m.segment for m in msgs}) == 1
|
|
386
|
+
assert all(m.config_id and m.config_id == compute_config_id(m) for m in msgs)
|
|
387
|
+
assert mock_compute.call_count == 1
|
|
388
|
+
|
|
389
|
+
producer._request_reset()
|
|
390
|
+
producer()
|
|
391
|
+
producer._state.event_queue.put((0.0, 0.0, time_module.monotonic()))
|
|
392
|
+
restarted = producer()
|
|
393
|
+
assert msgs[0].segment == 0
|
|
394
|
+
assert restarted.config_id == msgs[0].config_id and restarted.segment == 1
|
|
395
|
+
|
|
396
|
+
other = MouseListenerProducer(MouseListenerSettings())
|
|
397
|
+
other()
|
|
398
|
+
other._state.event_queue.put((0.0, 0.0, time_module.monotonic()))
|
|
399
|
+
assert other().segment == 0 # a fresh instance starts at 0
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# file generated by setuptools-scm
|
|
2
|
-
# don't change, don't track in version control
|
|
3
|
-
|
|
4
|
-
__all__ = [
|
|
5
|
-
"__version__",
|
|
6
|
-
"__version_tuple__",
|
|
7
|
-
"version",
|
|
8
|
-
"version_tuple",
|
|
9
|
-
"__commit_id__",
|
|
10
|
-
"commit_id",
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
TYPE_CHECKING = False
|
|
14
|
-
if TYPE_CHECKING:
|
|
15
|
-
from typing import Tuple
|
|
16
|
-
from typing import Union
|
|
17
|
-
|
|
18
|
-
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
-
COMMIT_ID = Union[str, None]
|
|
20
|
-
else:
|
|
21
|
-
VERSION_TUPLE = object
|
|
22
|
-
COMMIT_ID = object
|
|
23
|
-
|
|
24
|
-
version: str
|
|
25
|
-
__version__: str
|
|
26
|
-
__version_tuple__: VERSION_TUPLE
|
|
27
|
-
version_tuple: VERSION_TUPLE
|
|
28
|
-
commit_id: COMMIT_ID
|
|
29
|
-
__commit_id__: COMMIT_ID
|
|
30
|
-
|
|
31
|
-
__version__ = version = '0.3.0'
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 3, 0)
|
|
33
|
-
|
|
34
|
-
__commit_id__ = commit_id = None
|
|
File without changes
|
{ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/.github/workflows/python-publish.yml
RENAMED
|
File without changes
|
{ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/.github/workflows/python-tests.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ezmsg_peripheraldevice-0.3.0 → ezmsg_peripheraldevice-0.4.0}/src/ezmsg/peripheraldevice/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|