44
55from pydantic import BaseModel , BeforeValidator
66
7- from labthings_fastapi .descriptors .property import PropertyDescriptor
7+ from labthings_fastapi .descriptors .property import ThingProperty
88from labthings_fastapi .thing import Thing
99from labthings_fastapi .decorators import thing_action , thing_property
1010from labthings_fastapi .server import ThingServer
2424logging .basicConfig (level = logging .INFO )
2525
2626
27- class PicameraControl (PropertyDescriptor ):
27+ class PicameraControl (ThingProperty ):
2828 def __init__ (
2929 self , control_name : str , model : type = float , description : Optional [str ] = None
3030 ):
3131 """A property descriptor controlling a picamera control"""
32- PropertyDescriptor .__init__ (
33- self , model , observable = False , description = description
34- )
32+ ThingProperty .__init__ (self , model , observable = False , description = description )
3533 self .control_name = control_name
3634 self ._getter
3735
@@ -84,20 +82,20 @@ def __init__(self, device_index: int = 0):
8482 self .device_index = device_index
8583 self .camera_configs : dict [str , dict ] = {}
8684
87- stream_resolution = PropertyDescriptor (
85+ stream_resolution = ThingProperty (
8886 tuple [int , int ],
8987 initial_value = (1640 , 1232 ),
9088 description = "Resolution to use for the MJPEG stream" ,
9189 )
92- image_resolution = PropertyDescriptor (
90+ image_resolution = ThingProperty (
9391 tuple [int , int ],
9492 initial_value = (3280 , 2464 ),
9593 description = "Resolution to use for still images (by default)" ,
9694 )
97- mjpeg_bitrate = PropertyDescriptor (
95+ mjpeg_bitrate = ThingProperty (
9896 int , initial_value = 0 , description = "Bitrate for MJPEG stream (best left at 0)"
9997 )
100- stream_active = PropertyDescriptor (
98+ stream_active = ThingProperty (
10199 bool ,
102100 initial_value = False ,
103101 description = "Whether the MJPEG stream is active" ,
@@ -116,7 +114,7 @@ def __init__(self, device_index: int = 0):
116114 exposure_time = PicameraControl (
117115 "ExposureTime" , int , description = "The exposure time in microseconds"
118116 )
119- sensor_modes = PropertyDescriptor (list [SensorMode ], readonly = True )
117+ sensor_modes = ThingProperty (list [SensorMode ], readonly = True )
120118
121119 def __enter__ (self ):
122120 self ._picamera = picamera2 .Picamera2 (camera_num = self .device_index )
@@ -219,7 +217,7 @@ def exposure(self) -> float:
219217 def exposure (self , value ):
220218 raise NotImplementedError ()
221219
222- last_frame_index = PropertyDescriptor (int , initial_value = - 1 )
220+ last_frame_index = ThingProperty (int , initial_value = - 1 )
223221
224222 mjpeg_stream = MJPEGStreamDescriptor (ringbuffer_size = 10 )
225223
0 commit comments