@@ -72,23 +72,17 @@ def average_data(self, n: int):
72
72
"""
73
73
74
74
75
- # Define the data we're going to output (get), and what to expect in (post)
75
+ # Wrap in a semantic annotation to autmatically set schema and args
76
76
@semantics .moz .LevelProperty (100 , 500 , example = 200 )
77
77
class DenoiseProperty (PropertyView ):
78
78
"""Value of magic_denoise"""
79
79
80
- # Main function to handle GET requests (read)
81
80
def get (self ):
82
- """Show the current magic_denoise value"""
83
-
84
81
# When a GET request is made, we'll find our attached component
85
82
my_component = find_component ("org.labthings.example.mycomponent" )
86
83
return my_component .magic_denoise
87
84
88
- # Main function to handle PUT requests (write)
89
85
def put (self , new_property_value ):
90
- """Change the current magic_denoise value"""
91
-
92
86
# Find our attached component
93
87
my_component = find_component ("org.labthings.example.mycomponent" )
94
88
@@ -104,12 +98,12 @@ def put(self, new_property_value):
104
98
105
99
106
100
class QuickDataProperty (PropertyView ):
101
+ """Show the current data value"""
102
+
103
+ # Marshal the response as a list of floats
107
104
schema = fields .List (fields .Float ())
108
105
109
- # Main function to handle GET requests
110
106
def get (self ):
111
- """Show the current data value"""
112
-
113
107
# Find our attached component
114
108
my_component = find_component ("org.labthings.example.mycomponent" )
115
109
return my_component .data
@@ -128,7 +122,7 @@ class MeasurementAction(ActionView):
128
122
missing = 20 , example = 20 , description = "Number of data sets to average over" ,
129
123
)
130
124
}
131
-
125
+ # Marshal the response as a list of numbers
132
126
schema = fields .List (fields .Number )
133
127
134
128
# Main function to handle POST requests
0 commit comments