This is a program to view and edit petri nets. It's possible to model other kinds of graphs, like state machines. It's based on pnrs, a (hopefully) safe rust wrapper for pns, which can load, edit and simulate petri nets generated by simple-petri-net.
In case the program runs slow, try to compile using the --release
option for Cargo.
Here an example of how the editor looks like:
Ctrl + L
: Load petri net from fileCtrl + S
: Save petri net to fileCtrl + R
: Reset and use empty petri netCtrl + P
: Start simulation (switches to simulation mode)Ctrl + 1
: Set view mode to default; see and edit everythingCtrl + 2
: Set view mode to state; see and edit only placesCtrl + 3
: Set view mode to actions; see and edit only transitionsWhen you want to save or load a petri net, you have to enter the path and confirm.
The specified path /path/to/file
needs to contain for loading or will contain after saving two files: /path/to/file.pns
and /path/to/file.pnk
.
The .pns
-file stores the petri net (structure and initial state), the .pnk
-file stores names for the transitions.
When using this for the first time, you may want to press Ctrl + L
and write examples/example
, in order to load the example.
While editing, the keys Shift
, Ctrl
and Alt
have the following meaning:
* Shift
: Edit multiple objects
* Ctrl
: Create objects
* Alt
: Remove objects
Both mouse buttons also are used for different tasks:
* Left
: Edit nodes
* Right
: Edit connections
When pressing Ctrl+Left
, a new transition node is created.
When pressing Ctrl+Right
, a new place node is created.
When clicking a node, it will be selected. Selected nodes can be moved around. When clicking at some other node or at empty space, the selected nodes will be deselected.
When Shift
is pressed while clicking a node, it will be selected additionally.
When a new node is created while holding Shift
, the previously selected nodes won't be deselected.
When clicking Alt
+Left
above a node, it will be removed from the currently selected bides.
When clicking a node with Ctrl+Left
, it will be duplicated. Both nodes will use the same input and output connections.
When clicking a node with Right
and releasing it above another node, both nodes will be connected.
If multiple nodes are selected, all will be connected to the last node.
If both nodes are of the same type, a new node of the other type will be inserted between them.
When also holding Ctrl
, releasing in empty space will create a new node of the other type there, when releasing on the same node, a bidirectional connecton to a new node will be created.
Alt+Right
will remove connections between two nodes. If both nodes are of the same type, all connections to all nodes between them will be removed.
Pressing Tab
will switch to simulation mode. In simulation mode editing is limited.
Press Tab
again to go back to edit mode.
When in simulation mode, to play and pause the simulation, press Ctrl + P
.
When the simulation is active, pressing Tab
does not go back to edit mode. Instead it just selects the next simulation state.
Also Ctrl + L
and Ctrl + S
loads and saves the currently active state as /path/to/file.pni
instead of the net itself. Loading will add a new state.
Adding a new state is possible using Ctrl + A
in simulation mode.
When the simulation is started, click left on some transition to fire it, if possible. Click right to unfire transitions again. Unfireing is possible in any order, that does not create invalid state.
There are three modes: * default mode * state mode * actions mode
Default mode is the most powerful mode, since it gives access to the full petri net. The other modes are restricted, but they have specific features.
Both restricted modes hide one of the node types, so it's easier to overview it. When creating a connected place or transition, the end node will always be of the same type and the hidden node type will be inserted implicitly.
State mode only gives access to the state of the petri net, represented by the places. It's bascially a state machine. It's mostly useful for switching between alternative states or stories with multiple alternatives.
Actions mode only gives access to the actions of the petri net, represented by transitions. It's mostly useful, when things are never alternative, and calling actions only allows new actions, never removes old ones.