pyobs-sbig 1.3.0__tar.gz → 2.0.0.dev3__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.
Files changed (37) hide show
  1. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/.github/workflows/pypi.yml +1 -1
  2. pyobs_sbig-2.0.0.dev3/.github/workflows/ruff.yml +23 -0
  3. pyobs_sbig-2.0.0.dev3/.pre-commit-config.yaml +10 -0
  4. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/PKG-INFO +2 -2
  5. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/docs/source/conf.py +0 -1
  6. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/pyproject.toml +16 -5
  7. pyobs_sbig-2.0.0.dev3/src/pyobs_sbig/__init__.py +3 -0
  8. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/src/pyobs_sbig/gui.py +7 -10
  9. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/src/pyobs_sbig/sbig6303e.py +5 -10
  10. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/src/pyobs_sbig/sbigcamera.py +52 -84
  11. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/src/pyobs_sbig/sbigfiltercamera.py +39 -67
  12. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/uv.lock +102 -185
  13. pyobs_sbig-1.3.0/.idea/encodings.xml +0 -4
  14. pyobs_sbig-1.3.0/.idea/misc.xml +0 -7
  15. pyobs_sbig-1.3.0/.idea/modules.xml +0 -8
  16. pyobs_sbig-1.3.0/.idea/pyobs-sbig.iml +0 -30
  17. pyobs_sbig-1.3.0/.idea/workspace.xml +0 -7
  18. pyobs_sbig-1.3.0/.pre-commit-config.yaml +0 -15
  19. pyobs_sbig-1.3.0/src/pyobs_sbig/__init__.py +0 -3
  20. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/.readthedocs.yml +0 -0
  21. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/CHANGELOG.rst +0 -0
  22. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/CMakeLists.txt +0 -0
  23. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/LICENSE +0 -0
  24. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/README.md +0 -0
  25. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/docs/Makefile +0 -0
  26. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/docs/make.bat +0 -0
  27. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/docs/requirements.txt +0 -0
  28. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/docs/source/_static/pyobs.gif +0 -0
  29. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/docs/source/index.rst +0 -0
  30. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/src/pyobs_sbig/sbigudrv.pxd +0 -0
  31. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/src/pyobs_sbig/sbigudrv.pyx +0 -0
  32. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/src/sbigudrv/csbigcam.cpp +0 -0
  33. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/src/sbigudrv/csbigcam.h +0 -0
  34. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/src/sbigudrv/csbigimg.cpp +0 -0
  35. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/src/sbigudrv/csbigimg.h +0 -0
  36. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/src/sbigudrv/lpardrv.h +0 -0
  37. {pyobs_sbig-1.3.0 → pyobs_sbig-2.0.0.dev3}/src/sbigudrv/sbigudrv.h +0 -0
@@ -18,7 +18,7 @@ jobs:
18
18
  python-version: "3.13"
19
19
 
20
20
  - name: Build
21
- run: uv build
21
+ run: uv build --sdist
22
22
 
23
23
  - name: Publish
24
24
  env:
@@ -0,0 +1,23 @@
1
+ name: ruff
2
+ on: push
3
+
4
+ jobs:
5
+ ruff:
6
+ runs-on: ubuntu-latest
7
+ timeout-minutes: 10
8
+
9
+ steps:
10
+ - name: Check out repository code
11
+ uses: actions/checkout@v4
12
+
13
+ - name: Set up Python
14
+ uses: astral-sh/setup-uv@v5
15
+ with:
16
+ enable-cache: true
17
+ python-version: "3.13"
18
+
19
+ - name: Install packages
20
+ run: uv sync --no-install-project --all-extras --dev
21
+
22
+ - name: Run ruff
23
+ run: uv run ruff check src/pyobs_sbig/
@@ -0,0 +1,10 @@
1
+ repos:
2
+ - repo: https://github.com/psf/black-pre-commit-mirror
3
+ rev: 25.1.0
4
+ hooks:
5
+ - id: black
6
+ language_version: python3.11
7
+ - repo: https://github.com/astral-sh/ruff-pre-commit
8
+ rev: v0.9.0
9
+ hooks:
10
+ - id: ruff
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyobs-sbig
3
- Version: 1.3.0
3
+ Version: 2.0.0.dev3
4
4
  Summary: pyobs module for SBIG cameras
5
5
  Author-Email: Tim-Oliver Husser <thusser@uni-goettingen.de>
6
6
  License-Expression: MIT
7
7
  Requires-Python: <3.15,>=3.11
8
8
  Requires-Dist: astropy<8,>=7.0.1
9
9
  Requires-Dist: numpy<3,>=2.2.5
10
- Requires-Dist: pyobs-core<2,>=1
10
+ Requires-Dist: pyobs-core<3,>=2.0.0.dev6
11
11
  Provides-Extra: gui
12
12
  Requires-Dist: qfitswidget>=0.13.1; extra == "gui"
13
13
  Requires-Dist: pyside6>=6.11.0; extra == "gui"
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  #
3
2
  # Configuration file for the Sphinx documentation builder.
4
3
  #
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyobs-sbig"
3
- version = "1.3.0"
3
+ version = "2.0.0.dev3"
4
4
  description = "pyobs module for SBIG cameras"
5
5
  authors = [{ name = "Tim-Oliver Husser", email = "thusser@uni-goettingen.de" }]
6
6
  requires-python = ">=3.11,<3.15"
@@ -8,7 +8,7 @@ license = "MIT"
8
8
  dependencies = [
9
9
  "astropy>=7.0.1,<8",
10
10
  "numpy>=2.2.5,<3",
11
- "pyobs-core>=1,<2",
11
+ "pyobs-core>=2.0.0.dev6,<3",
12
12
  ]
13
13
 
14
14
  [project.optional-dependencies]
@@ -21,10 +21,10 @@ gui = [
21
21
  [dependency-groups]
22
22
  dev = [
23
23
  "black>=25.1.0,<26",
24
+ "ruff>=0.9.0",
25
+ "pyrefly>=1.1.1",
24
26
  "pre-commit>=4.2.0,<5",
25
- "flake8>=7.3.0",
26
27
  "cython>=3.0.0,<4",
27
- "pyside6-stubs>=6.7.3.0",
28
28
  ]
29
29
 
30
30
  [project.scripts]
@@ -42,4 +42,15 @@ build-backend = "scikit_build_core.build"
42
42
 
43
43
  [tool.black]
44
44
  line-length = 120
45
- target-version = ['py314']
45
+ target-version = ['py313']
46
+
47
+ [tool.ruff]
48
+ target-version = "py311"
49
+ line-length = 120
50
+
51
+ [tool.ruff.lint]
52
+ select = ["E", "F", "W", "I", "UP", "G"]
53
+
54
+ [tool.pyrefly]
55
+ python-version = "3.11"
56
+ ignore-missing-imports = ["PySide6.*", "qasync.*"]
@@ -0,0 +1,3 @@
1
+ from .sbig6303e import Sbig6303eCamera as Sbig6303eCamera
2
+ from .sbigcamera import SbigCamera as SbigCamera
3
+ from .sbigfiltercamera import SbigFilterCamera as SbigFilterCamera
@@ -1,21 +1,18 @@
1
+ import asyncio
2
+ import sys
3
+
4
+ import qasync # type: ignore
1
5
  from astropy.io import fits
2
- from pyobs.utils.enums import ImageFormat
3
6
  from pyobs.utils.gui.camera import (
4
- DataDisplayWidget,
5
7
  BinningWidget,
6
- ImageFormatWidget,
7
- ExposureTimeWidget,
8
+ DataDisplayWidget,
8
9
  ExposeWidget,
9
- ListPickerDialog,
10
+ ExposureTimeWidget,
10
11
  )
11
12
  from pyobs.utils.gui.camera.windowingwidget import WindowingWidget
12
- from pyobs.utils.parallel import event_wait
13
- import asyncio
14
- import sys
15
- import qasync # type: ignore
16
13
  from PySide6 import QtWidgets
17
14
 
18
- from .sbigudrv import SBIGImg, SBIGCam # type: ignore
15
+ from .sbigudrv import SBIGCam, SBIGImg # type: ignore
19
16
 
20
17
 
21
18
  class MainWindow(QtWidgets.QMainWindow):
@@ -1,10 +1,10 @@
1
1
  import asyncio
2
2
  import logging
3
- from typing import Any, Optional
3
+ from typing import Any
4
4
 
5
5
  from pyobs.images import Image
6
- from .sbigfiltercamera import SbigFilterCamera
7
6
 
7
+ from .sbigfiltercamera import SbigFilterCamera
8
8
 
9
9
  log = logging.getLogger(__name__)
10
10
 
@@ -29,13 +29,11 @@ class Sbig6303eCamera(SbigFilterCamera):
29
29
  GrabImageError: If exposure was not successful.
30
30
  """
31
31
 
32
- # do expsure
32
+ # do exposure
33
33
  img = await SbigFilterCamera._expose(self, exposure_time, open_shutter, abort_event)
34
34
 
35
- # get binning
36
- xbin, ybin = await self.get_binning()
37
-
38
35
  # gain is different in binned images
36
+ xbin, ybin = self._binning
39
37
  gain = (1.4, "Detector gain [e-/ADU]") if xbin == ybin == 1 else (2.3, "Detector gain [e-/ADU]")
40
38
  img.header["DET-GAIN"] = gain
41
39
 
@@ -48,11 +46,8 @@ class Sbig6303eCamera(SbigFilterCamera):
48
46
  async def park(self, **kwargs: Any) -> None:
49
47
  pass
50
48
 
51
- async def stop_motion(self, device: Optional[str] = None, **kwargs: Any) -> None:
49
+ async def stop_motion(self, device: str | None = None, **kwargs: Any) -> None:
52
50
  pass
53
51
 
54
- async def is_ready(self, **kwargs: Any) -> bool:
55
- return True
56
-
57
52
 
58
53
  __all__ = ["Sbig6303eCamera"]
@@ -1,16 +1,19 @@
1
1
  import asyncio
2
2
  import logging
3
3
  import math
4
- from datetime import datetime, timezone
5
- from typing import Any, Tuple, Dict, List
6
- import numpy as np
4
+ from datetime import UTC, datetime
5
+ from typing import Any
7
6
 
7
+ import numpy as np
8
8
  from pyobs.images import Image
9
- from pyobs.interfaces import ICamera, IWindow, IBinning, ITemperatures, IAbortable, ICooling
9
+ from pyobs.interfaces import IAbortable, IBinning, ICamera, ICooling, ITemperatures, IWindow
10
+ from pyobs.interfaces.IBinning import BinningCapabilities, BinningState
11
+ from pyobs.interfaces.ICooling import CoolingState
12
+ from pyobs.interfaces.ITemperatures import SensorReading, TemperaturesState
13
+ from pyobs.interfaces.IWindow import WindowCapabilities, WindowState
10
14
  from pyobs.modules.camera.basecamera import BaseCamera
11
15
  from pyobs.utils.enums import ExposureStatus
12
16
 
13
-
14
17
  log = logging.getLogger(__name__)
15
18
 
16
19
 
@@ -27,7 +30,7 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
27
30
 
28
31
  """
29
32
  BaseCamera.__init__(self, **kwargs)
30
- from .sbigudrv import SBIGImg, SBIGCam # type: ignore
33
+ from .sbigudrv import SBIGCam, SBIGImg # type: ignore
31
34
 
32
35
  # create image and cam
33
36
  self._img = SBIGImg()
@@ -38,13 +41,15 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
38
41
 
39
42
  # cooling
40
43
  self._setpoint = setpoint
41
- self._cooling = (False, 0.0, 0.0)
42
44
 
43
45
  # window and binning
44
46
  self._full_frame = (0, 0, 0, 0)
45
47
  self._window = (0, 0, 0, 0)
46
48
  self._binning = (1, 1)
47
49
 
50
+ # background task for polling cooling/temperature
51
+ self.add_background_task(self._poll_cooling)
52
+
48
53
  async def open(self) -> None:
49
54
  """Open module.
50
55
 
@@ -58,7 +63,7 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
58
63
  try:
59
64
  self._cam.establish_link()
60
65
  except ValueError as e:
61
- raise ValueError("Could not establish link: %s" % str(e))
66
+ raise ValueError(f"Could not establish link: {e}")
62
67
 
63
68
  # cooling
64
69
  await self.set_cooling(self._setpoint is not None, self._setpoint)
@@ -66,25 +71,26 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
66
71
  # get full frame
67
72
  self._cam.binning = (1, 1)
68
73
  self._full_frame = self._cam.full_frame
69
-
70
- # get window
71
74
  self._window = self._full_frame
72
75
 
73
- async def get_full_frame(self, **kwargs: Any) -> Tuple[int, int, int, int]:
74
- """Returns full size of CCD.
75
-
76
- Returns:
77
- Tuple with left, top, width, and height set.
78
- """
79
- return self._full_frame
80
-
81
- async def get_window(self, **kwargs: Any) -> Tuple[int, int, int, int]:
82
- """Returns the camera window.
83
-
84
- Returns:
85
- Tuple with left, top, width, and height set.
86
- """
87
- return self._window
76
+ # publish capabilities and initial state
77
+ await self.comm.set_capabilities(
78
+ IWindow,
79
+ WindowCapabilities(
80
+ full_frame_x=self._full_frame[0],
81
+ full_frame_y=self._full_frame[1],
82
+ full_frame_width=self._full_frame[2],
83
+ full_frame_height=self._full_frame[3],
84
+ ),
85
+ )
86
+ await self.comm.set_state(
87
+ IWindow, WindowState(x=self._window[0], y=self._window[1], width=self._window[2], height=self._window[3])
88
+ )
89
+ await self.comm.set_capabilities(
90
+ IBinning,
91
+ BinningCapabilities(binnings=[BinningState(x=1, y=1), BinningState(x=2, y=2), BinningState(x=3, y=3)]),
92
+ )
93
+ await self.comm.set_state(IBinning, BinningState(x=self._binning[0], y=self._binning[1]))
88
94
 
89
95
  async def set_window(self, left: int, top: int, width: int, height: int, **kwargs: Any) -> None:
90
96
  """Set the camera window.
@@ -97,6 +103,7 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
97
103
  """
98
104
  self._window = (left, top, width, height)
99
105
  log.info("Setting window to %dx%d at %d,%d...", width, height, left, top)
106
+ await self.comm.set_state(IWindow, WindowState(x=left, y=top, width=width, height=height))
100
107
 
101
108
  async def _expose(self, exposure_time: float, open_shutter: bool, abort_event: asyncio.Event) -> Image:
102
109
  """Actually do the exposure, should be implemented by derived classes.
@@ -135,7 +142,7 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
135
142
 
136
143
  # get date obs
137
144
  log.info("Starting exposure with for %.2f seconds...", exposure_time)
138
- date_obs = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%f")
145
+ date_obs = datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%S.%f")
139
146
 
140
147
  # init image
141
148
  self._img.image_can_close = False
@@ -210,17 +217,6 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
210
217
  """
211
218
  await self._change_exposure_status(ExposureStatus.IDLE)
212
219
 
213
- async def list_binnings(self, **kwargs: Any) -> List[Tuple[int, int]]:
214
- return [(1, 1), (2, 2), (3, 3)]
215
-
216
- async def get_binning(self, **kwargs: Any) -> Tuple[int, int]:
217
- """Returns the camera binning.
218
-
219
- Returns:
220
- Dictionary with x and y.
221
- """
222
- return self._binning
223
-
224
220
  async def set_binning(self, x: int, y: int, **kwargs: Any) -> None:
225
221
  """Set the camera binning.
226
222
 
@@ -230,6 +226,7 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
230
226
  """
231
227
  self._binning = (x, y)
232
228
  log.info("Setting binning to %dx%d...", x, y)
229
+ await self.comm.set_state(IBinning, BinningState(x=x, y=y))
233
230
 
234
231
  async def set_cooling(self, enabled: bool, setpoint: float, **kwargs: Any) -> None:
235
232
  """Enables/disables cooling and sets setpoint.
@@ -252,53 +249,24 @@ class SbigCamera(BaseCamera, ICamera, IWindow, IBinning, ICooling, ITemperatures
252
249
  async with self._lock_active:
253
250
  self._cam.set_cooling(enabled, setpoint)
254
251
 
255
- async def get_cooling(self, **kwargs: Any) -> Tuple[bool, float, float]:
256
- """Returns the current status for the cooling.
257
-
258
- Returns:
259
- (tuple): Tuple containing:
260
- Enabled: Whether the cooling is enabled
261
- SetPoint: Setpoint for the cooling in celsius.
262
- Power: Current cooling power in percent or None.
263
- """
264
-
265
- async with self._lock_active:
266
- enabled, _, setpoint, power = self._cam.get_cooling()
267
- return enabled, setpoint, power
268
-
269
- async def get_cooling_status(self, **kwargs: Any) -> Tuple[bool, float, float]:
270
- """Returns the current status for the cooling.
271
-
272
- Returns:
273
- Tuple containing:
274
- Enabled (bool): Whether the cooling is enabled
275
- SetPoint (float): Setpoint for the cooling in celsius.
276
- Power (float): Current cooling power in percent or None.
277
- """
278
-
279
- try:
280
- async with self._lock_active:
281
- enabled, temp, setpoint, power = self._cam.get_cooling()
282
- self._cooling = enabled is True, setpoint, power * 100.0
283
- except ValueError:
284
- # use existing cooling
285
- pass
286
- return self._cooling
287
-
288
- async def get_temperatures(self, **kwargs: Any) -> Dict[str, float]:
289
- """Returns all temperatures measured by this module.
290
-
291
- Returns:
292
- Dict containing temperatures.
293
- """
294
-
295
- try:
296
- async with self._lock_active:
297
- _, temp, _, _ = self._cam.get_cooling()
298
- return {"CCD": temp}
299
- except ValueError:
300
- # use existing temps
301
- return {}
252
+ # publish state (power unknown until next poll)
253
+ await self.comm.set_state(ICooling, CoolingState(setpoint=setpoint, power=None, enabled=enabled))
254
+
255
+ async def _poll_cooling(self) -> None:
256
+ """Background task: periodically reads cooling status and publishes ICooling and ITemperatures state."""
257
+ while True:
258
+ try:
259
+ async with self._lock_active:
260
+ enabled, temp, setpoint, power = self._cam.get_cooling()
261
+ await self.comm.set_state(
262
+ ICooling, CoolingState(setpoint=setpoint, power=round(power * 100), enabled=enabled)
263
+ )
264
+ await self.comm.set_state(
265
+ ITemperatures, TemperaturesState(readings=[SensorReading(name="CCD", value=temp)])
266
+ )
267
+ except Exception:
268
+ pass
269
+ await asyncio.sleep(10)
302
270
 
303
271
 
304
272
  __all__ = ["SbigCamera"]
@@ -1,15 +1,17 @@
1
1
  import asyncio
2
2
  import logging
3
- from typing import List, Optional, Any
3
+ from typing import Any
4
4
 
5
+ from pyobs.events import FilterChangedEvent
5
6
  from pyobs.images import Image
7
+ from pyobs.interfaces import IFilters, IReady
8
+ from pyobs.interfaces.IFilters import FiltersCapabilities, FilterState
9
+ from pyobs.interfaces.IReady import ReadyState
6
10
  from pyobs.mixins import MotionStatusMixin
7
- from pyobs.events import FilterChangedEvent
8
- from pyobs.interfaces import IFilters
9
11
  from pyobs.utils.enums import MotionStatus
10
12
  from pyobs.utils.threads import LockWithAbort
11
- from .sbigcamera import SbigCamera
12
13
 
14
+ from .sbigcamera import SbigCamera
13
15
 
14
16
  log = logging.getLogger(__name__)
15
17
 
@@ -19,14 +21,14 @@ class SbigFilterCamera(MotionStatusMixin, SbigCamera, IFilters):
19
21
 
20
22
  __module__ = "pyobs_sbig"
21
23
 
22
- def __init__(self, filter_wheel: str, filter_names: Optional[List[str]] = None, **kwargs: Any):
24
+ def __init__(self, filter_wheel: str, filter_names: list[str] | None = None, **kwargs: Any):
23
25
  """Initializes a new SbigCamera.
24
26
 
25
27
  Args:
26
28
  filter_names: List of filter names.
27
29
  """
28
30
  SbigCamera.__init__(self, **kwargs)
29
- from .sbigudrv import FilterWheelPosition, FilterWheelModel # type: ignore
31
+ from .sbigudrv import FilterWheelModel, FilterWheelPosition # type: ignore
30
32
 
31
33
  # filter wheel
32
34
  self.filter_wheel = FilterWheelModel[filter_wheel]
@@ -62,19 +64,36 @@ class SbigFilterCamera(MotionStatusMixin, SbigCamera, IFilters):
62
64
  try:
63
65
  self._cam.set_filter_wheel(self.filter_wheel)
64
66
  except ValueError as e:
65
- raise ValueError("Could not set filter wheel: %s" % str(e))
67
+ raise ValueError(f"Could not set filter wheel: {e}")
66
68
 
67
- # open camera
69
+ # open camera (connects to hardware, publishes IWindow/IBinning states)
68
70
  await SbigCamera.open(self)
69
71
 
70
- # init status of filter wheel
71
- if self.filter_wheel != FilterWheelModel.UNKNOWN:
72
- await self._change_motion_status(MotionStatus.POSITIONED, interface="IFilters")
72
+ # init mixin — registers events and publishes initial IMotion state
73
+ await MotionStatusMixin.open(self)
73
74
 
74
75
  # subscribe to events
75
- if self.comm:
76
+ if self._comm:
76
77
  await self.comm.register_event(FilterChangedEvent)
77
78
 
79
+ if self.filter_wheel != FilterWheelModel.UNKNOWN:
80
+ # set motion status to positioned
81
+ await self._change_motion_status(MotionStatus.POSITIONED, interface="IFilters")
82
+
83
+ # publish filter capabilities
84
+ filter_list = [name for name in self._filter_names.values() if name != "UNKNOWN"]
85
+ await self.comm.set_capabilities(IFilters, FiltersCapabilities(filters=filter_list))
86
+
87
+ # query and publish current filter position
88
+ try:
89
+ self._position, _ = self._cam.get_filter_position_and_status()
90
+ except (ValueError, Exception):
91
+ pass
92
+ await self.comm.set_state(IFilters, FilterState(filter=self._filter_names[self._position]))
93
+
94
+ # camera is ready once open
95
+ await self.comm.set_state(IReady, ReadyState(ready=True))
96
+
78
97
  async def _expose(self, exposure_time: float, open_shutter: bool, abort_event: asyncio.Event) -> Image:
79
98
  """Actually do the exposure, should be implemented by derived classes.
80
99
 
@@ -91,12 +110,12 @@ class SbigFilterCamera(MotionStatusMixin, SbigCamera, IFilters):
91
110
  """
92
111
  from .sbigudrv import FilterWheelModel
93
112
 
94
- # do expsure
113
+ # do exposure
95
114
  img = await SbigCamera._expose(self, exposure_time, open_shutter, abort_event)
96
115
 
97
116
  # add filter to FITS headers
98
117
  if self.filter_wheel != FilterWheelModel.UNKNOWN:
99
- img.header["FILTER"] = (await self.get_filter(), "Current filter")
118
+ img.header["FILTER"] = (self._filter_names[self._position], "Current filter")
100
119
 
101
120
  # finished
102
121
  return img
@@ -120,7 +139,7 @@ class SbigFilterCamera(MotionStatusMixin, SbigCamera, IFilters):
120
139
  # reverse dict and search for name
121
140
  filters = {y: x for x, y in self._filter_names.items()}
122
141
  if filter_name not in filters:
123
- raise ValueError("Unknown filter: %s" % filter_name)
142
+ raise ValueError(f"Unknown filter: {filter_name}")
124
143
 
125
144
  # there already?
126
145
  position, status = self._cam.get_filter_position_and_status()
@@ -151,54 +170,15 @@ class SbigFilterCamera(MotionStatusMixin, SbigCamera, IFilters):
151
170
  # sleep a little
152
171
  await asyncio.sleep(0.1)
153
172
 
154
- # send event
173
+ # update cached position and publish new state
174
+ self._position = filters[filter_name]
155
175
  log.info("Filter changed.")
156
- self.comm.send_event(FilterChangedEvent(filter_name))
176
+ await self.comm.send_event(FilterChangedEvent(filter_name))
177
+ await self.comm.set_state(IFilters, FilterState(filter=filter_name))
157
178
 
158
179
  # set status
159
180
  await self._change_motion_status(MotionStatus.POSITIONED, interface="IFilters")
160
181
 
161
- async def get_filter(self, **kwargs: Any) -> str:
162
- """Get currently set filter.
163
-
164
- Returns:
165
- Name of currently set filter.
166
-
167
- Raises:
168
- ValueError: If filter could not be fetched.
169
- NotImplementedError: If camera doesn't have a filter wheel.
170
- """
171
- from .sbigudrv import FilterWheelModel
172
-
173
- # do we have a filter wheel?
174
- if self.filter_wheel == FilterWheelModel.UNKNOWN:
175
- raise NotImplementedError
176
-
177
- try:
178
- self._position, _ = self._cam.get_filter_position_and_status()
179
- except ValueError:
180
- # use existing position
181
- pass
182
- return self._filter_names[self._position]
183
-
184
- async def list_filters(self, **kwargs: Any) -> List[str]:
185
- """List available filters.
186
-
187
- Returns:
188
- List of available filters.
189
-
190
- Raises:
191
- NotImplementedError: If camera doesn't have a filter wheel.
192
- """
193
- from .sbigudrv import FilterWheelModel
194
-
195
- # do we have a filter wheel?
196
- if self.filter_wheel == FilterWheelModel.UNKNOWN:
197
- raise NotImplementedError
198
-
199
- # return names
200
- return [f for f in self._filter_names.values() if f is not None]
201
-
202
182
  async def init(self, **kwargs: Any) -> None:
203
183
  """Initialize device.
204
184
 
@@ -215,7 +195,7 @@ class SbigFilterCamera(MotionStatusMixin, SbigCamera, IFilters):
215
195
  """
216
196
  pass
217
197
 
218
- async def stop_motion(self, device: Optional[str] = None, **kwargs: Any) -> None:
198
+ async def stop_motion(self, device: str | None = None, **kwargs: Any) -> None:
219
199
  """Stop the motion.
220
200
 
221
201
  Args:
@@ -223,13 +203,5 @@ class SbigFilterCamera(MotionStatusMixin, SbigCamera, IFilters):
223
203
  """
224
204
  pass
225
205
 
226
- async def is_ready(self, **kwargs: Any) -> bool:
227
- """Returns the device is "ready", whatever that means for the specific device.
228
-
229
- Returns:
230
- Whether device is ready
231
- """
232
- return True
233
-
234
206
 
235
207
  __all__ = ["SbigFilterCamera"]