-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2244692
commit 6578376
Showing
5 changed files
with
178 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,56 @@ | ||
# Controlling the editor through MQTT commands | ||
|
||
When opening a petri json file (i.e. `foobar.json`). The editor will listening | ||
the MQTT topic `"pneditor/foobar"` on localhost with port 1883 for MQTT | ||
commands such as `"T0"` for triggering the transition T0 or `"P0"` for incrementing | ||
of one the number of tokens in the place P0. Dummy file have their topic named | ||
`"editor/petri.json"`. | ||
The editor starts a MQTT client, with by default localhost with port 1883 (you can change | ||
them from the Makefile. Search for `MQTT_BROKER_ADDR` and `MQTT_BROKER_PORT`). | ||
|
||
TODO: implement commands such as `"T0;T1;T2"` or `"P4+2"` or `"P4-1"` or `"P4=2"`. | ||
TBD: topics such as `"pneditor/foobar/T0"` with value `true/false` or | ||
`"pneditor/foobar/P0"` with values such as `1`? | ||
For more information concerning MQTT, read this | ||
[document](https://www.howtoforge.com/how-to-install-mosquitto-mqtt-message-broker-on-debian-11/). | ||
|
||
## Load a new Petri net | ||
|
||
For example, you can type on your console: | ||
Note: if you want to control the net through MQTT commands, better to avoid creating "timed" net | ||
(timed event graph and timed Petri net), create instead Petri net or GRAFCET. | ||
|
||
The message content is the same JSON format than the one used for saving/loading files. See [here](save.md) | ||
for more information. | ||
|
||
Example: | ||
``` | ||
sudo mosquitto_pub -h localhost -t "pneditor/foobar" -m "T0" | ||
mosquitto_pub -h localhost -t "tpne/load" -m '{ "revision": 3, "type": | ||
"Petri net", "nets": [ { "name": "Petri net", | ||
"places": [ { "id": 0, "caption": "P0", "tokens": 1, "x": 244, "y": 153 }, | ||
{ "id": 1, "caption": "P1", "tokens": 0, "x": 356, "y": 260 } ], | ||
"transitions": [ { "id": 0, "caption": "T0", "x": 298, "y": 207, "angle": 0 } ], | ||
"arcs": [ { "from": "P0", "to": "T0" }, { "from": "T0", "to": "P1", "duration": 3 } | ||
] } ] }' | ||
``` | ||
|
||
For more information concerning MQTT, read this | ||
[document](https://www.howtoforge.com/how-to-install-mosquitto-mqtt-message-broker-on-debian-11/). | ||
Constrain: the simulation shall not running when loading the net. | ||
|
||
## Start/Stop simulation | ||
|
||
Before firing transitions, you have to start the simulation. | ||
|
||
``` | ||
mosquitto_pub -h localhost -t "tpne/start" -m '' | ||
``` | ||
|
||
For stopping: | ||
``` | ||
mosquitto_pub -h localhost -t "tpne/stop" -m '' | ||
``` | ||
|
||
## Firing transitions | ||
|
||
The message to send is a list of '1' or '0' characters (string). One character by transitions. | ||
|
||
Let suppose, you have 2 transitions in your net. The message length shall be 2. Let suppose you want | ||
to fire transition 1 but not the second. The message will be "10". | ||
|
||
``` | ||
mosquitto_pub -h localhost -t "tpne/fire" -m '10' | ||
``` | ||
|
||
Constrain: | ||
- The simulation shall running. | ||
- The message length shall match the number of transitions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters