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

1# SPDX-License-Identifier: Apache-2.0 

2import enum 

3 

4from pydantic import BaseModel 

5 

6import sensorkit.api as sk 

7from sensorkit.astro.coords import Coordinates 

8 

9 

10class TemperatureUnit(enum.StrEnum): 

11 """Unit of measurement for temperature readings.""" 

12 FAHRENHEIT = "f" 

13 CELSIUS = "c" 

14 KELVIN = "k" 

15 

16 

17@sk.declare_keyword 

18class Temperature(BaseModel): 

19 """Current temperature reading with its associated unit.""" 

20 temperature: float 

21 units: TemperatureUnit 

22 

23 

24@sk.declare_keyword 

25class Connected(BaseModel): 

26 """Connection status keyword for a device.""" 

27 is_connected: bool 

28 

29 

30class Connect(sk.DeviceCommand): 

31 """Establish a connection to a device.""" 

32 

33 

34class Disconnect(sk.DeviceCommand): 

35 """Terminate an existing connection to a device.""" 

36 

37 

38MustConnect = sk.declare_trait( 

39 "MustConnect", 

40 required_commands=(Connect, Disconnect), 

41) 

42 

43 

44@sk.declare_keyword 

45class Enabled(BaseModel): 

46 is_enabled: bool 

47 

48 

49class Enable(sk.DeviceCommand): 

50 """Command to enable a device or feature.""" 

51 

52 

53class Disable(sk.DeviceCommand): 

54 """Command to disable a device or feature.""" 

55 

56 

57MustEnable = sk.declare_trait( 

58 "MustEnable", 

59 required_commands=(Enable, Disable), 

60) 

61 

62 

63class Init(sk.DeviceCommand): 

64 """Initialize a device, bringing it to an operational state.""" 

65 

66 

67class Deinit(sk.DeviceCommand): 

68 """Deinitialize a device, returning it to a safe idle state.""" 

69 

70 

71class Home(sk.DeviceCommand): 

72 """Move a device to its home position.""" 

73 

74 

75class Stop(sk.DeviceCommand): 

76 """Stop all device motion or activity.""" 

77 

78 

79class MoveToPark(sk.DeviceCommand): 

80 """Move a device to its park position.""" 

81 

82 

83class SetParkPosition(sk.DeviceCommand): 

84 """Set the position a device moves to when parked.""" 

85 

86 position: Coordinates 

87 

88 

89@sk.declare_keyword 

90class Opened(BaseModel): 

91 """Keyword reporting whether a device (e.g., dome, mirror cover) is currently open.""" 

92 

93 is_open: bool