planktoscope/docs/mqtt_messages.md

232 lines
4.4 KiB
Markdown
Raw Normal View History

2022-11-03 15:31:27 +01:00
<!--
SPDX-License-Identifier: CC-BY-SA-4.0
-->
2020-09-28 14:18:14 +02:00
# Details about used MQTT messages
## Topic lists
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
- [`actuator`](#actuator)
2022-11-03 14:16:53 +01:00
- [`actuator/pump`](#actuatorpump)
- [`actuator/focus`](#actuatorfocus)
2020-09-28 14:18:14 +02:00
- [`imager/image`](#imagerimage)
- [`segmenter/segment`](#segmentersegment)
- [`status`](#status)
2022-11-03 14:16:53 +01:00
- [`status/pump`](#statuspump)
- [`status/focus`](#statusfocus)
- [`status/imager`](#statusimager)
- [`status/segmenter`](#statussegmenter)
- [`status/segmenter/name`](#statussegmentername)
- [`status/segmenter/object_id`](#statussegmenterobject_id)
- [`status/segmenter/metric`](#statussegmentermetric)
2020-09-28 14:18:14 +02:00
## Topic details
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
### `actuator`
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
#### `actuator/pump`
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
Control the movement of the pump. The message is a JSON object:
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"action": "move",
"direction": "FORWARD",
"volume": 10,
"flowrate": 1
}
```
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
This messages make the pump move 10mL forward at 1mL/min.
Another supported message is:
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"action": "stop"
}
```
- Receive only
#### `actuator/focus`
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
Control of the focus stage. The message is a JSON object, speed is optional:
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"action": "move",
"direction": "UP",
"distance": 0.26,
"speed": 1
}
```
This message makes the stage move up by 10mm.
Another supported message is:
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"action": "stop"
}
```
- Receive only
### `imager/image`
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
This topic controls the camera and capture. The message allowed is a JSON message:
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"action": "image",
2020-11-25 16:58:32 +01:00
"pump_direction": "FORWARD",
2020-09-28 14:18:14 +02:00
"volume": 1,
"nb_frame": 200
}
```
2020-11-25 16:58:32 +01:00
Volume is in mL.
2020-09-28 14:18:14 +02:00
This topic can also receive a config update message:
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"action": "config",
"config": {...}
}
```
2021-09-03 15:53:16 +02:00
A camera settings message can also be received here. The fields `iso`, `shutter_speed`, `white_balance_gain`, `white_balance` and `image_gain` are optionals:
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"action": "settings",
2021-09-03 15:53:16 +02:00
"settings":{
"iso": 100,
"shutter_speed": 40,
"white_balance_gain": {"red": 100, "blue": 100},
"white_balance": "auto",
"image_gain": {"analog": 100, "digital": 100}
}
2020-09-28 14:18:14 +02:00
}
```
- Receive only
### `segmenter/segment`
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
This topic controls the segmentation process. The message is a JSON object:
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"action": "segment",
"path": "/path/to/segment",
"settings": {
"force": False,
"recursive": True,
"ecotaxa": True,
"keep": True
}
2020-09-28 14:18:14 +02:00
}
```
`action` can also be `stop`.
The `action` element is the only element required. If no `path` is supplied, the whole images repository is segmented recursively (this is very long!).
2021-09-03 15:53:16 +02:00
`force` is going to overcome the presence of the file `done` that is here to prevent for resegmenting a folder already segmented.
2021-09-03 15:53:16 +02:00
`recursive` will force parsing all folders below `path`.
2021-09-03 15:53:16 +02:00
`ecotaxa` activates the export of an ecotaxa compatible archive.
2021-09-03 15:53:16 +02:00
`keep` allows to remove or keep the roi (when you do an ecotaxa export, no effects otherwise, the roi are kept).
2020-09-28 14:18:14 +02:00
- Receive only
### `status`
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
This high-level topic is used to send information to the Node-Red process. There is no publication or receive at this level.
#### `status/pump`
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
State of the pump. It's a JSON object with:
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"status": "Started",
"duration": 25
}
```
Duration is a best guess estimate. It should not be used to control the other events. If you want to wait for a movement to finish, the best thing to do is to wait for the message `Done`.
Status can be `Started`, `Ready`, `Done`, `Interrupted`, `Error`, `Dead`.
- Publish only
#### `status/focus`
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
State of the focus stage. It's a JSON object with:
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"status": "Started",
"duration": 25
}
```
Duration is a best guess estimate. It should not be used to control the other events. If you want to wait for a movement to finish, the best thing to do is to wait for the message `Done`.
Status is one of `Started`, `Ready`, `Done`, `Interrupted`, `Error`, `Dead`.
- Publish only
#### `status/imager`
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
State of the imager. It's a JSON object with:
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"status": "Started",
"time_left": 25
}
```
Status is one of `Started`, `Ready`, `Completed` or `12_11_15_0.1.jpg has been imaged`.
- Publish only
#### `status/segmenter`
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
Status of the segmentation. It's a JSON object with:
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"status": "Started",
}
```
`status` is one of `Started`, `Done`, `Interrupted`, `Busy`, `Ready` or `Dead`.
- Publish only
#### `status/segmenter/object_id`
2022-11-03 14:16:53 +01:00
2020-09-28 14:18:14 +02:00
```json
{
"object_id": "13449"
}
```
#### `status/segmenter/metric`
2022-11-03 14:16:53 +01:00
```json
{
"name": "01_13_28_232066_0",
"metadata": {
"label": 0, "width": 29, "height": 80, ....
}
2022-11-03 14:16:53 +01:00
```