Skip to content

Commit

Permalink
Make dynamic data requested instead of published (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
oschusler authored Aug 10, 2023
1 parent 725713d commit b8dd566
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 110 deletions.
30 changes: 0 additions & 30 deletions docs/publish/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,3 @@ published message.
"version": "0.1.0"
}
```

#### Publish dynamic

Dynamic information is generated by 2300. This information can for example constitute calibration data like T1 and T2*.
This dynamic metadata is shared with the rest of the system via a broadcasting message.

The schemas for validation inherit from the **base schema** and can be found in:

* [`/schemas/publish_dynamic/message.schema.json`](../../schemas/publish_dynamic/message.schema.json)

##### Publish dynamic payload

The payload for the message is still under advicement. The appropriate key-value pairs will be filled in when they are
determined.

| Key | Type | Value |
| --- | --- | --- |
| - | - | - |

##### Publish dynamic example

```jsonc
{
"command": "publish_dynamic",
"payload": {
// to be determined
},
"version": "0.1.0"
}
```
31 changes: 19 additions & 12 deletions docs/request/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,39 +236,46 @@ This message does not require any additional information in the payload section.
}
```

#### Trigger publish
#### Get dynamic

System 2300 publishes dynamic information for 2200 to read. It might happen that 2300 broadcasted a message while 2200
wasn't ready yet, resulting in relevant information being missed. In such a case, 2200 can request 2300 to publish the
information again.
Dynamic information is generated by 2300. This information can for example constitute calibration data like T1 and T2*.
This dynamic metadata fetched on a status change from `CALIBRATING`/`OFFLINE` to `IDLE` or on startup of 2200.

The schemas for validation inherit from the **base schema** and can be found in:

* [`/schemas/trigger_publish/request.schema.json`](../../schemas/trigger_publish/request.schema.json)
* [`/schemas/trigger_publish/reply.schema.json`](../../schemas/trigger_publish/reply.schema.json)
* [`/schemas/get_dynamic/request.schema.json`](../../schemas/get_dynamic/request.schema.json)
* [`/schemas/get_dynamic/reply.schema.json`](../../schemas/get_dynamic/reply.schema.json)

##### Set publish request payload
##### Get dynamic request payload

This message does not require any additional information in the payload section.

##### Set publish request example
##### Get dynamic request example

```jsonc
{
"command": "trigger_publish",
"command": "get_dynamic",
"version": "0.1.0"
}
```

##### Set publish reply payload
##### Get dynamic reply payload

This message does not require any additional information in the payload section.
The payload for the message is still under advisement. The appropriate key-value pairs will be filled in when they are
determined.

| Key | Type | Value |
| --- | --- | --- |
| - | - | - |

##### Set publish reply example
##### Get dynamic reply example

```jsonc
{
"status": "success",
"payload": {
// to be determined
},
"version": "0.1.0"
}
```
37 changes: 37 additions & 0 deletions schemas/get_dynamic/reply.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"title": "Get dynamic reply",
"description": "The reply containing dynamic information for 2300.",
"type": "object",
"allOf": [
{
"$ref": "../base_reply.schema.json"
}
],
"properties": {
"payload": {
"description": "The return value(s) of the executed command.",
"type": "object",
"properties": {}
}
},
"required": [
"payload"
],
"if": {
"properties": {
"status": {
"const": "success"
}
},
"required": [
"status"
]
},
"then": {
"properties": {
"payload": {
"required": []
}
}
}
}
15 changes: 15 additions & 0 deletions schemas/get_dynamic/request.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"title": "Get dynamic request",
"description": "Get dynamic information from 2300. This information is retrieved on startup for 2200 or on a state change from CALIBRATING/OFFLINE to IDLE.",
"type": "object",
"allOf": [
{
"$ref": "../base_request.schema.json"
}
],
"properties": {
"command": {
"const": "get_dynamic"
}
}
}
24 changes: 0 additions & 24 deletions schemas/publish_dynamic/message.schema.json

This file was deleted.

10 changes: 0 additions & 10 deletions schemas/trigger_publish/reply.schema.json

This file was deleted.

15 changes: 0 additions & 15 deletions schemas/trigger_publish/request.schema.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"session_id": "eb4fdc2c-755b-47d8-af76-bbca2dce554d",
"status": "failure",
"payload": {
"error_msg": "Lorem ipsum"
},
"version": "0.1.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"status": "success",
"payload": {},
"version": "0.1.0"
}
4 changes: 4 additions & 0 deletions tests/data/get_dynamic/request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"command": "get_dynamic",
"version": "0.1.0"
}
3 changes: 1 addition & 2 deletions tests/data/get_static/reply.failure.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"session_id": "eb4fdc2c-755b-47d8-af76-bbca2dce554d",
"status": "failure",
"payload": {
"error_msg": "Lorem ipsum"
},
"version": "0.1.0"
}
}
5 changes: 0 additions & 5 deletions tests/data/publish_dynamic/message.json

This file was deleted.

4 changes: 0 additions & 4 deletions tests/data/trigger_publish/request.json

This file was deleted.

9 changes: 3 additions & 6 deletions tests/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ echo Test get_static
check-jsonschema --schemafile ../schemas/get_static/request.schema.json ./data/get_static/request.json
check-jsonschema --schemafile ../schemas/get_static/reply.schema.json ./data/get_static/reply.success.json ./data/get_static/reply.failure.json

echo Test trigger_publish
check-jsonschema --schemafile ../schemas/trigger_publish/request.schema.json ./data/trigger_publish/request.json
check-jsonschema --schemafile ../schemas/trigger_publish/reply.schema.json ./data/trigger_publish/reply.success.json ./data/trigger_publish/reply.failure.json
echo Test get_dynamic
check-jsonschema --schemafile ../schemas/get_dynamic/request.schema.json ./data/get_dynamic/request.json
check-jsonschema --schemafile ../schemas/get_dynamic/reply.schema.json ./data/get_dynamic/reply.success.json ./data/get_dynamic/reply.failure.json

echo Test publish_state
check-jsonschema --schemafile ../schemas/publish_state/message.schema.json ./data/publish_state/message.json

echo Test publish_dynamic
check-jsonschema --schemafile ../schemas/publish_dynamic/message.schema.json ./data/publish_dynamic/message.json

0 comments on commit b8dd566

Please sign in to comment.