This project used webgme to implement the Petri-Net Design Studio. This studio create a petri-net with finite places, transitions, and arcs. Places are used to store tokens. Transition are used to transfer tokens from source places (inplace) to target places (outplace). Arcs are the links between places and transitions to achieve sending. With different designs, the nets have four different classifications, which are Free-choice petri-net, state machine, marked graph, and workflow net.
Petri-Net is a low-level model, which is used to describe systems. It can quickly express concurrency, conflict, and causality, etc. For instance, the team statebox have plans to generate Rholang programs directly with Petri-Nets. The places can represent states, conditions, or resources. The transitions can be actions. The tokens can represent that the places have amounts of resources and these resources can be transfered to other with the action named "fire".
In this studio, a project seed with the Petri-Net metamodel has already created. You can design your example using "composition" tab and create a simulator in "Demo" tab. In "Demo", you can click buttons to see the net classification and refresh the net. You can drag or click the components in the graph for interaction.
The main codes are in
(1)src/plugins/ModelicaCodeGenerator/ModelicaCodeGenerator/init.py
(2)src/visualizers/panels/Demo/DemoControl.js
(3)src/visualizers/widgets/Demo/DemoWidget.js
(1) Get the information from the metamodel example and check the classification. Send all the information to simulator through messages.
(2) Create bottons to display the classification and refresh the simulator; Receive the messages and organize the information.
(3) Design the interaction and draw the network.
- Install the mini-project following:
-
Download the source code and go to the main folder in Terminal.
-
In terminal, install webgme
npm install -g webgme-cli
python -m pip install webgme-bindings
npm install webgme-bindings --save
-
fire up the server
node ./app.js -
Go to the listening webpage. Open the seed object.
- Due to my system which contains python2 and python3. I've change the line 28 in MIC/src/plugins/ModelicaCodeGenerator/ModelicaCodeGenerator.js from "python" to "python3".
- The token display should use jointjs@2.2.0.
In the seed object. Go to the "Composition" tab. There are already four networks you can use with the classifications on their names.
If you want to create your network, drag a "Petri-Net" from the left workspace to the main sheet. You can change the name of this network. Then, double click the network to go to the inside sheet. You can drag places and transitions to this sheet and create arcs between places and transitions. All places should be set up markings with non-zero numbers.
Click "Demo" to create a simulator for this network. Click "Search" button on the top to see the classification. Click the "Refresh" button to reset the network. Click each transition to fire tokens. If the transition reaches a deadlock, this transition will become gray and freezed. Then, there is an alert to notify you.