Skip to content

Commit e326208

Browse files
committed
reread design docs and update
1 parent 93ca6fa commit e326208

17 files changed

Lines changed: 203 additions & 363 deletions

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
docs/index.md
1+
docs/index.md
2+
docs/design/action-descriptors.md

docs/api-reference/namespaces.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Import Namespaces
2+
3+
| Namespace | Description |
4+
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5+
| `hololinked.core` | Definition of [`Thing`](thing/index.md) class, [`Property`](property/index.md), [`Action`](action/index.md) and [`Event`](event/index.md) classes, [`StateMachine`](state-machine/state-machine.md), [`Logger`](thing/logger.md) & [`RPCServer`](rpc-server/rpc-server.md) |
6+
| `hololinked.serializers` | Serializers for different data formats (JSON, MessagePack, etc.) and [`Serializers`](serializers/index.md) singleton. |
7+
| `hololinked.server` | Protocol specific server implementations |
8+
| `hololinked.client` | [`ObjectProxy`](clients/object-proxy.md) and protocol specific client implementations, client abstractions and [`ClientFactory`](clients/base.md). |
9+
| `hololinked.param` | Copy of `param` library with implementation specific modifications. |
10+
| `hololinked.storage` | Database clients for data persistence. |
11+
| `hololinked.td` | Thing Description/[ThingModel](td/tm.md) parsing and generation. |

docs/beginners-guide/code/eventloop/import.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/beginners-guide/code/eventloop/list_of_devices.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

docs/beginners-guide/code/eventloop/run_eq.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

docs/beginners-guide/code/eventloop/threaded.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

docs/blog/index.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/design/action-descriptors.md

Lines changed: 42 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ This is useful for quick prototyping, or when the action does not require strict
99

1010
The most expressive way to define payload validation to use type annotations in the action method signature:
1111

12-
```python
12+
```python linenums="1"
1313
class Picoscope(Thing):
1414

1515
@action()
16-
def run_block(self,
17-
pre_trigger_samples: int,
18-
post_trigger_samples: int,
16+
def run_block(self,
17+
pre_trigger_samples: int,
18+
post_trigger_samples: int,
1919
timebase: int,
20-
oversample: int = 0,
20+
oversample: int = 0,
2121
seg_index: int = 0
2222
) -> float:
2323
"""Run a single block capture on the Picoscope device"""
@@ -31,73 +31,60 @@ class Picoscope(Thing):
3131

3232
If one generates the Thing Model fragment for the action, the `input` (schema) field will be defined:
3333

34-
```python
34+
```python linenums="1"
3535
Picoscope.run_block.to_affordance()
3636
```
3737

3838
```json
3939
{
40-
"run_block": {
41-
"title": "run_block",
42-
"description": "Run a single block capture on the Picoscope device",
43-
"input": {
44-
"type": "object",
45-
"properties": {
46-
"pre_trigger_samples": {
47-
"type": "integer"
48-
},
49-
"post_trigger_samples": {
50-
"type": "integer"
51-
},
52-
"timebase": {
53-
"type": "integer"
54-
},
55-
"oversample": {
56-
"type": "integer",
57-
"default": 0
58-
},
59-
"seg_index": {
60-
"type": "integer",
61-
"default": 0
62-
}
63-
},
64-
"required": [
65-
"pre_trigger_samples",
66-
"post_trigger_samples",
67-
"timebase"
68-
]
40+
"run_block": {
41+
"title": "run_block",
42+
"description": "Run a single block capture on the Picoscope device",
43+
"input": {
44+
"type": "object",
45+
"properties": {
46+
"pre_trigger_samples": {
47+
"type": "integer"
6948
},
70-
"output": {
71-
"type": "number"
49+
"post_trigger_samples": {
50+
"type": "integer"
51+
},
52+
"timebase": {
53+
"type": "integer"
54+
},
55+
"oversample": {
56+
"type": "integer",
57+
"default": 0
58+
},
59+
"seg_index": {
60+
"type": "integer",
61+
"default": 0
7262
}
63+
},
64+
"required": ["pre_trigger_samples", "post_trigger_samples", "timebase"]
65+
},
66+
"output": {
67+
"type": "number"
7368
}
69+
}
7470
}
7571
```
7672

7773
This type of validation is made possible by constructing a pydantic model from the type annotations.
7874

79-
For more complex payload validation, one can use JSON schema or pydantic models (directly).
80-
81-
=== "JSON Schema"
82-
83-
```python
84-
```
85-
86-
=== "Pydantic Model"
87-
88-
```python
89-
```
75+
For more complex payload validation, one can use JSON schema or pydantic models (directly). Examples are already included
76+
in the [handbook](../beginners-guide/articles/actions.md#payload-validation).
9077

9178
The output payload is not validated.
9279

9380
## Execution Control
9481

95-
Execution control of operations (like `invokeAction`) can be offered in three different ways:
82+
Execution control of operations (like `invokeaction`) can be offered in three different ways:
9683

9784
- synchronous - queued one after another, default behaviour of **both** properties and actions
9885
- `Thing` object is not manipulated simultaneously by multiple operations in multiple threads by a remote client, its a fundamental assumption based on the OOP paradigm
99-
- prevents incompatible physical actions in the world from running at the same time on the same device
10086
- maximizes thread safety increasing suitability of runtime for hardware engineers
87+
- prevents incompatible physical actions in the world from running at the same time on the same device
10188
- threaded actions
10289
- not queued, runs immediately when action is called
10390
- allows multiple actions to run simultaneously
@@ -113,9 +100,9 @@ flowchart TD
113100
B -- No --> D[Bind to instance]
114101
C --> E{Action type}
115102
D --> E
116-
E -- Synchronous --> F[Queue action,<br/>run sequentially]
117-
E -- Threaded --> G[Run action in a new thread]
118-
E -- Async --> H[Create asyncio task<br/>if requested]
103+
E -- synchronous --> F[Queue action,<br/>run sequentially]
104+
E -- threaded --> G[Run action in a new thread]
105+
E -- asyncio --> H[Create asyncio task]
119106
F --> I[Validate payload<br/> against the action schema, <br/>Spread payload as arguments]
120107
G --> J[Validate payload<br/> against the action schema, <br/>Spread payload as arguments]
121108
H --> K[Validate payload<br/> against the action schema, <br/>Spread payload as arguments]
@@ -126,5 +113,5 @@ flowchart TD
126113
```
127114

128115
This scheduling control may need to be implemented in a separate RPC layer or similar. See the [ZMQ RPC layer](zmq.md) for more details.
129-
130-
116+
The payload validation step comes after the scheduling decision, as schedulers have higher precedence in the RPC call stack, although
117+
the logic is common.

docs/design/client.py

Whitespace-only changes.

0 commit comments

Comments
 (0)