You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"description": "Start acquisition of energy measurements. max_count: maximum number of measurements to acquire before stopping automatically.",
182
+
"input": {
183
+
"properties": {
184
+
"max_count": {
185
+
"exclusiveMinimum": 0,
186
+
"type": "integer"
187
+
}
188
+
},
189
+
"required": ["max_count"],
190
+
"title": "start_acquisition_input",
191
+
"type": "object"
192
+
},
193
+
"synchronous": True
194
+
}
195
+
```
154
196
155
197
=== "Multiple Arguments"
156
198
157
-
```py title="Input Schema with Multiple Arguments" linenums="1"
158
-
```
199
+
```py title="Input Schema with Multiple Arguments"
200
+
from typing import Literal
201
+
202
+
class Picoscope6000(Thing):
203
+
204
+
@action()
205
+
def set_channel_pydantic(
206
+
self,
207
+
channel: Literal["A", "B", "C", "D"],
208
+
enabled: bool = True,
209
+
v_range: Literal[
210
+
"10mV",
211
+
"20mV",
212
+
"50mV",
213
+
"100mV",
214
+
"200mV",
215
+
"500mV",
216
+
"1V",
217
+
"2V",
218
+
"5V",
219
+
"10V",
220
+
"20V",
221
+
"50V",
222
+
"MAX_RANGES",
223
+
] = "2V",
224
+
offset: float = 0,
225
+
coupling: Literal["AC", "DC"] = "DC_1M",
226
+
bw_limiter: Literal["full", "20MHz"] = "full",
227
+
) -> None:
228
+
```
229
+
230
+
???+ note "JSON schema seen in Thing Description"
231
+
232
+
```json
233
+
{
234
+
"description": "Set the parameter for a channel. https://www.picotech.com/download/manuals/picoscope-6000-series-a-api-programmers-guide.pdf",
235
+
"input": {
236
+
"properties": {
237
+
"channel": {
238
+
"enum": ["A", "B", "C", "D"],
239
+
"type": "string"
240
+
},
241
+
"enabled": {"default": True, "type": "boolean"},
242
+
"v_range": {
243
+
"default": "2V",
244
+
"enum": [
245
+
"10mV",
246
+
"20mV",
247
+
"50mV",
248
+
"100mV",
249
+
"200mV",
250
+
"500mV",
251
+
"1V",
252
+
"2V",
253
+
"5V",
254
+
"10V",
255
+
"20V",
256
+
"50V",
257
+
"MAX_RANGES"
258
+
],
259
+
260
+
"type": "string"
261
+
},
262
+
"offset": {"default": 0, "type": "number"},
263
+
"coupling": {
264
+
"default": "DC_1M",
265
+
"enum": ["AC", "DC"],
266
+
"type": "string"
267
+
},
268
+
"bw_limiter": {
269
+
"default": "full",
270
+
"enum": ["full", "20MHz"],
271
+
"type": "string"
272
+
}
273
+
},
274
+
"required": ["channel"],
275
+
"type": "object"
276
+
},
277
+
"synchronous": True
278
+
}
279
+
```
159
280
160
281
However, a schema is optional and it only matters that
161
282
the method signature is matching when requested from a client. To enable this, set global attribute `allow_relaxed_schema_actions=True`. This setting is used especially when a schema is useful for validation of arguments but not available - not for methods with no arguments.
@@ -197,3 +318,7 @@ client side, there is no difference between invoking a normal action and an acti
0 commit comments