Skip to content

Commit e7b48b4

Browse files
author
jiri.strouhal
committed
Add example of module documentation into ./doc folder
1 parent 3c98bc4 commit e7b48b4

4 files changed

Lines changed: 72 additions & 29 deletions

File tree

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,54 @@
11
# Introduction
22

3-
<!-- Provide a single sentence or a short paragraph describing the module's purpose. When using the documentation inside repository, add link to the README and vice versa - link the README to this documentation.
3+
<!-- Provide a single sentence or a short paragraph describing the module's purpose. When using the documentation inside repository, add link to the README and vice versa - link the README to this documentation. -->
44

5-
Example:
6-
7-
The Test module is provides communication between car test devices and the testing application. For more details on the usage of the module, see the [README](<path-to-readme>).
8-
-->
5+
This module serves as an example for module maintainers to implement their own modules outside reserved range of modules and does not serve any role in the production environment.
96

107
# Identification and supported devices
118

12-
<!-- Provide a list of supported devices and their identification.
13-
14-
Example:
9+
<!-- Provide a list of supported devices and their identification. -->
1510

16-
The module number/ID: `0`
11+
The module number/ID: `1000`.
1712

1813
## Devices
1914

20-
| **Device Name** | **Device Type** | **Device Roles** | Comment |
21-
| --------------- | --------------- | ---------------- | ------------------------------------------------ |
22-
| Test Button 1 | 0 | test-button-1 | Button verifying that the commands can be sent to a device of this module |
23-
| Test Button 2 | 0 | test-button-2 | Button verifying that the commands can be sent to a device of this module |
24-
| Test Camera | 1 | test-camera | Camera verifying quality and rate of data transfer from car |
25-
-->
15+
| **Device Name** | **Device Type** | **Device Roles** | Comment |
16+
| --------------- | --------------- | ---------------- | ------------------------------------------- |
17+
| button1 | 0 | test | Button driving a state of a dedicated LED |
18+
| button1 | 10 | test | Button driving a state of a dedicated LED |
19+
| button2 | 0 | test2 | Button driving a state of a dedicated LED |
2620

27-
# Messages
2821

29-
<!-- Describe all types of messages handled by the module (including status, status error and command). For each type, describe the message contents, structure and example of the message.
22+
# Messages
3023

31-
Example of a status description:
24+
<!-- Describe all types of messages handled by the module (including status, status error and command). For each type, describe the message contents, structure and example of the message. -->
3225

3326
## Status
3427

35-
The status message contains information about test components with their state (`ON` or `OFF`).
28+
Each device (button) expects a status message containing a single key `pressed` with a boolean value indicating whether the button is pressed.
3629

3730
### Example
3831

3932
``` json
40-
{"state": "ON"}
33+
{
34+
"pressed": true
35+
}
36+
```
37+
## Status Error
38+
39+
Status errors are not defined for this module.
40+
41+
## Command
42+
43+
Each device (button) expects a command message containing a single key `lit_up` with a boolean value indicating whether the LED should be lit up.
44+
45+
### Example
46+
47+
``` json
48+
{
49+
"lit_up": true
50+
}
4151
```
42-
-->
4352

4453
# Details of supported devices
4554

@@ -50,3 +59,11 @@ The status message contains information about test components with their state (
5059
- how the state is affected by the received command.
5160
5261
-->
62+
63+
## Button
64+
65+
Button is a simple button device which has one LED attached to it. As status, it sends JSON with key `"pressed"` indicating whether button is pressed. As command, it expects JSON with key `"lit_up"` indicating the desired state of internal LED.
66+
67+
See the state transition diagram below:
68+
69+
![Button state diagram](./uml/exported_diagrams/button_state_transition_diagram.png)

docs/uml/button_state.puml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@startuml button_state_transition_diagram
2+
skinparam style strictuml
3+
4+
!define state_color #77cdff
5+
6+
state Pressed state_color
7+
state NotPressed state_color
8+
9+
hide empty description
10+
11+
Pressed ---> NotPressed: turn off
12+
Pressed -up-> Pressed: lit up
13+
NotPressed ---> Pressed: lit up
14+
NotPressed -up-> NotPressed: turn off
15+
16+
@enduml
7.86 KB
Loading

python_client/README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,46 @@
11
# Internal client examples
22

33
This repo contains implementation of example module device using internal client for fleet protocol v2.
4-
These devices is a virtual button which sends it's current state and expects state of it's LED as response.
4+
These devices is a virtual button which sends its current state and expects state of it's LED as response.
55

66
#### Preparing environment
7+
78
Before running example devices, it is good practice to create a virtual environment:
8-
```
9+
10+
```bash
911
python -m venv .venv
1012
source .venv/bin/activate
1113
```
14+
1215
Install dependencies:
13-
```
16+
17+
```bash
1418
pip install -r requirements.txt
1519
```
1620

1721
## Button
18-
Button is a simple button device which has one LED attached to it. As status, it sends json with key `"pressed"` indicationg wheter button is pressed. As command, it expects json with key `"lit_up"` indicating the desired state of internal LED.
22+
23+
Button is a simple button device which has one LED attached to it. As status, it sends JSON with key `"pressed"` indicating whether button is pressed. As command, it expects JSON with key `"lit_up"` indicating the desired state of internal LED.
24+
1925
### Usage
26+
2027
Fake buttons can be run with `run_buttons.py` script. It expects config in `yaml` format which specifies attributes for button or multiple buttons (see `buttons.yaml`):
28+
2129
```yaml
2230
- button1_name:
2331
type: <int> specifying module specific device type (default is 0)
2432
role: <str> device role
2533
priority: <int> device priority (default is 0)
2634

27-
- button2_name:
28-
...
35+
- button2_name: ...
2936
```
37+
3038
To run use:
31-
```
39+
40+
```bash
3241
python run_buttons.py --ip <server_ip> --port <server_port> --config <path_to_yaml>
3342
```
43+
3444
Multiple fake buttons will be created according to yaml config. They will try to connect to specified server, generate and send their statuses periodically and set their LED states according to commands.
3545

36-
> Manual mode of actual button pressing on keyboard can be specified by `--manual` argument.
46+
> Manual mode of actual button pressing on keyboard can be specified by `--manual` argument.

0 commit comments

Comments
 (0)