Coverage for core / src / sensorkit / std / traits.py: 100%
34 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-09-02 00:03 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-09-02 00:03 +0000
1# SPDX-License-Identifier: Apache-2.0
2import enum
4from pydantic import BaseModel
6import sensorkit.api as sk
7from sensorkit.astro.coords import Coordinates
10class TemperatureUnit(enum.StrEnum):
11 """Unit of measurement for temperature readings."""
12 FAHRENHEIT = "f"
13 CELSIUS = "c"
14 KELVIN = "k"
17@sk.declare_keyword
18class Temperature(BaseModel):
19 """Current temperature reading with its associated unit."""
20 temperature: float
21 units: TemperatureUnit
24@sk.declare_keyword
25class Connected(BaseModel):
26 """Connection status keyword for a device."""
27 is_connected: bool
30class Connect(sk.DeviceCommand):
31 """Establish a connection to a device."""
34class Disconnect(sk.DeviceCommand):
35 """Terminate an existing connection to a device."""
38MustConnect = sk.declare_trait(
39 "MustConnect",
40 required_commands=(Connect, Disconnect),
41)
44@sk.declare_keyword
45class Enabled(BaseModel):
46 is_enabled: bool
49class Enable(sk.DeviceCommand):
50 """Command to enable a device or feature."""
53class Disable(sk.DeviceCommand):
54 """Command to disable a device or feature."""
57MustEnable = sk.declare_trait(
58 "MustEnable",
59 required_commands=(Enable, Disable),
60)
63class Init(sk.DeviceCommand):
64 """Initialize a device, bringing it to an operational state."""
67class Deinit(sk.DeviceCommand):
68 """Deinitialize a device, returning it to a safe idle state."""
71class Home(sk.DeviceCommand):
72 """Move a device to its home position."""
75class Stop(sk.DeviceCommand):
76 """Stop all device motion or activity."""
79class MoveToPark(sk.DeviceCommand):
80 """Move a device to its park position."""
83class SetParkPosition(sk.DeviceCommand):
84 """Set the position a device moves to when parked."""
86 position: Coordinates
89@sk.declare_keyword
90class Opened(BaseModel):
91 """Keyword reporting whether a device (e.g., dome, mirror cover) is currently open."""
93 is_open: bool