A command line utility for generating animated gifs of petri nets. This tool is designed to support living documentation and test-driven development of systems that can be modelled with petri nets.
An X-Ray machine in a hospital, taken from Modeling Business Processes - A Petri Net-Oriented Approach.
The input for generating this gif is two files:
- a PNML file, for example created with PIPE or other petri net diagramming tool.
- a marking-transition script
This is a simple text file to specify the initial marking of the net, and transitions to fire. The animation above was generated from the following marking file:
wait:3
free:1
enter
make_photo
leave
enter
make_photo
leave
enter
make_photo
leave
This file can be written by hand, or it can be generated.
There are two typical ways to generate a marking-transition script - either via controlled automated tests, or from a running production system. Both of them require the system to log internal events and commands.
A specialised (but simple) tool could parse those logs and generate a marking-transition script, which can then
be fed to petrinet
for validation and generation of living documentation in the form of animated petri nets.
You need the following tools installed:
- Graphviz - the
dot
executable must be on yourPATH
- ImageMagick - the
convert
executable must be on yourPATH
- Ruby
Then run the following from the command line:
gem install petrinet
You need a .pnml
file that describes your net, and a .txt
marking-transition file. Generate an animated gif:
petrinet --script my-marking-transition.txt my-petri-net-pnml.xml
This will generate a file named my-marking-transition.gif
(the name is derived from the .txt
file)
Bug reports and pull requests are welcome on GitHub at https://github.com/aslakhellesoy/petrinet.
The gem is available as open source under the terms of the MIT License.