Skip to content

Commit ab32cfb

Browse files
authored
Merge pull request #7 from bringauto/BAIP-239/module-documentation-template
Baip 239/module documentation template
2 parents 0e1f6c0 + 5c2ea52 commit ab32cfb

5 files changed

Lines changed: 109 additions & 12 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ This is the implementation of Example module. Repo contains example_module libra
33
This module serves as an example for module maintainers to implement their own modules outside reserved range of modules. It is not intended to be used in production.
44
Module number of this module is 1000.
55

6+
For more details on the module, see [module documentation](./docs/module_documentation_template.md).
7+
68
# Requirements
79

810
- fleet protocol library - [v2.0.0](https://github.com/bringauto/fleet-protocol/releases/tag/v2.0.0)

docs/example_module.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Introduction
2+
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. -->
4+
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. For usage of this module, see the [README](../README.md).
6+
7+
# Identification and supported devices
8+
9+
<!-- Provide a list of supported devices and their identification. -->
10+
11+
The module number/ID: `1000`.
12+
13+
## Devices
14+
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 |
20+
21+
22+
# Messages
23+
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. -->
25+
26+
## Status
27+
28+
Each device (button) expects a status message containing a single key `pressed` with a boolean value indicating whether the button is pressed.
29+
30+
### Example
31+
32+
``` json
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+
}
51+
```
52+
53+
# Details of supported devices
54+
55+
<!-- In this section, list all supported devices. Describe their purpose on the car and their behavior relevant to the application accessing the devices through the module. This includes mainly
56+
57+
- the device state machine,
58+
- how the status machine reflects the state machine's state,
59+
- how the state is affected by the received command.
60+
61+
-->
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: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,46 @@
11
# Internal client examples
22

3-
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.
3+
This repo contains an implementation of the Example Module using the Internal Client for Fleet Protocol v2.
4+
The devices supported by this module are virtual buttons which send their current state and expect state of their 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 with 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
20-
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`):
26+
27+
Fake buttons can be run with the `run_buttons.py` script. It expects config in `yaml` format which specifies attributes for a button or multiple buttons (see `buttons.yaml`):
28+
2129
```yaml
2230
- button1_name:
23-
type: <int> specifying module specific device type (default is 0)
31+
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
```
34-
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.
3543

36-
> Manual mode of actual button pressing on keyboard can be specified by `--manual` argument.
44+
Multiple fake buttons will be created according to yaml config. They will try to connect to the specified server, generate and send their statuses periodically, and set their LED states according to commands.
45+
46+
> The manual mode of the actual button pressing on the keyboard can be specified by `--manual` argument.

0 commit comments

Comments
 (0)