Skip to content

Lecrapouille/TimedPetriNetEditor

Repository files navigation

Timed Petri Net Editor

TimedPetriNetEditor is a graphical interface for editing and running Petri nets. It offers some mathematics tools for timed event graphs which are a subclass of timed Petri nets with good mathematics properties for modeling discrete event systems with (max,+) algebra.

Note: An online version is in gestation. Here is the link.

What are Petri nets, timed Petri nets, timed event graph, GRAFCET?

You can read this internal document for more information. Else you can go to Related lectures and projects.

Application Overview

The following picture is an overview of the look of the application. You can click on it to watch a YouTube showing an example of timed Petri net running simulating emergency operators (French 911 call center) responding to people in distress. Operators of level 1 filter non-critical cases (advice). Operators of level 2 manage other cases: urgency and critical cases. For urgency cases, the operator of level 1 hangs up when he makes the victim wait the operator of level 2. For critical cases, the operator of level 1 waits with the victim until an operator of level 2 pick up before hanging up.

TimedPetri

Fig 1 - A timed Petri net (made with this editor).

Why developing another Petri editor? Because:

  • This project has started as a continuation of ScicosLab's (max,+) toolbox developed at INRIA (which is no longer developed) which missed a graphical Petri editor associated with (max,+) algebra.
  • Many Petri net editors in GitHub are no longer maintained (> 7 years) or that I cannot personally compile or use (Windows system, Visual Studio compiler, C#, Java ..) or the code is too complex (no comments) to add my own extensions. This editor can be used for Julia language.

Prerequisites

The editor can use ZeroMQ for remote control (JSON commands over TCP). This is enabled by default (TPNE_ZEROMQ=1 in Makefile.common). To build without ZeroMQ:

make TPNE_ZEROMQ=0

When ZeroMQ is enabled, install the development package for your system before building:

Fedora / RHEL / CentOS:

sudo dnf install zeromq-devel

Debian / Ubuntu:

sudo apt install libzmq3-dev

Arch Linux:

sudo pacman -S zeromq

macOS (Homebrew):

brew install zeromq

You can verify that pkg-config finds the library with:

pkg-config --exists libzmq && echo "ZeroMQ OK"

Compilation, Installation

git clone https://github.com/Lecrapouille/TimedPetriNetEditor --depth=1 --recursive
cd TimedPetriNetEditor/
make download-external-libs
make compile-external-libs
make -j8
sudo make install

Developer note: -ffast-math and NaN/Inf

This project may be compiled with -ffast-math (see PERFORMANCE_FLAGS in .makefile/rules/Makefile), which implies -ffinite-math-only. Under this assumption the compiler considers that NaN and ±Inf never occur, so std::isnan() / std::isinf() are constant-folded to false and direct comparisons such as x == -inf become unreliable. When you need to detect a special floating-point value (the (max,+) zero -inf, the NaN "no duration" sentinel of Place -> Transition arcs, ...), use the bit-pattern based helpers from src/PetriNet/SafeFloat.hpp (safeIsNaN, safeIsNegInf, safeIsPosInf, safeIsInf) instead of the standard library functions.

Usage

You can pass a Petri net file to the command line. See this document concerning the description of the file format used for saving Petri net.

./build/TimedPetriNetEditor [data/examples/AppelsDurgence.json]

See:

  • this document showing some examples offered with this repo.
  • this document describing the mouse and key bindings for the graphical interface.
  • this document describing how to control the editor through MQTT commands.
  • this document Explaining how to export/import the net to/from other applications.

Debug inside Visual Studio Code

Type F5 key to launch the application with a debugger. You can modify the .vscode/launch.json to indicate

Julia integration

The C++ files in src/julia (Julia.cpp / Julia.hpp) build the C ABI shared library used by Julia. The Julia wrapper itself will live in its own package, TimedPetriNetEditor.jl, which drives this build (Pkg.build) and exposes the API:

using TimedPetriNetEditor
pn = petri_net()
petri_editor!(pn)

TimedPetriNetEditor.jl resolves the produced shared library automatically (no hard-coded path) and also adds the ScicosLab flowshop functions (import_flowshop!, find_critical_cycle, show_cr_graph) on top of MaxPlus.jl.

You can read this cheatsheet concerning the API for Julia.

About

[Application][Version 0.4.0][Functional] A timed Petri net and graph event editor and simulator combined to (max,+) algebra with wrapped API for Julia lang

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors