The PetriNets library allows to model discrete components by a special kind of Petri nets with at most one token on a place, as well as by state transition diagrams (which are special kinds of Petri nets). Petri nets and state transition diagrams are "higher level" constructs for the description of switching elements, parallel activities or syncronization. For several kinds of applications it is much easier and clearer to use these components instead of modeling the discrete behaviour directly with the basic language constructs of Modelica ("if" or "when" statements). A typical Petri net is shown in the following figure:
A Petri net is defined in the following way:
The method used in this library to realize Petri nets in Modelica is described in detail in:
This package is not part of the Modelica standard library, because it is planned to realize a package with only one place and one transition component, once vector connectors with unknown length have better support in Modelica.
Release Notes:
Copyright (C) 2000, DLR.
The ModelicaAdditions.PetriNets package is free software; it can be redistributed and/or modified under the terms of the Modelica license, see the license conditions and the accompanying disclaimer in the documentation of package Modelica in file "Modelica/package.mo".
Name | Default | Description |
---|---|---|
initialState | false | Initial value of state |
model Place01 "Place with one output transition" parameter Boolean initialState=false "Initial value of state"; Boolean state(final start=initialState) "State of place"; protected Boolean newState(final start=initialState); public PetriNets.Interfaces.FirePortOut outTransition; equation // Set new state for next iteration state = pre(newState); newState = state and not outTransition.fire; // Report state to output transition outTransition.state = state; end Place01;
Name | Default | Description |
---|---|---|
initialState | false | Initial value of state |
model Place10 "Place with one input transition" parameter Boolean initialState=false "Initial value of state"; Boolean state(final start=initialState) "State of place"; protected Boolean newState(final start=initialState); public PetriNets.Interfaces.SetPortIn inTransition; equation // Set new state for next iteration state = pre(newState); newState = inTransition.set or state; // Report state to input transition inTransition.state = state; end Place10;
Name | Default | Description |
---|---|---|
initialState | false | Initial value of state |
model Place11 "Place with one input and one output transition" parameter Boolean initialState=false "Initial value of state"; Boolean state(final start=initialState) "State of place"; protected Boolean newState(final start=initialState); public PetriNets.Interfaces.SetPortIn inTransition; PetriNets.Interfaces.FirePortOut outTransition; equation // Set new state for next iteration state = pre(newState); newState = inTransition.set or state and not outTransition.fire; // Report state to input and output transitions inTransition.state = state; outTransition.state = state; end Place11;
Name | Default | Description |
---|---|---|
initialState | false | Initial value of state |
model Place21 "Place with two input and one output transition" parameter Boolean initialState=false "Initial value of state"; Boolean state(final start=initialState) "State of place"; protected Boolean newState(final start=initialState); public PetriNets.Interfaces.FirePortOut outTransition; PetriNets.Interfaces.SetPortIn inTransition1; PetriNets.Interfaces.SetPortIn inTransition2; equation // Set new state for next iteration state = pre(newState); newState = inTransition1.set or inTransition2.set or state and not outTransition.fire; // Report state to input and output transitions inTransition1.state = state; inTransition2.state = inTransition1.state or inTransition1.set; outTransition.state = state; end Place21;
Name | Default | Description |
---|---|---|
initialState | false | Initial value of state |
model Place12 "Place with one input and two output transitions" parameter Boolean initialState=false "Initial value of state"; Boolean state(final start=initialState) "State of place"; protected Boolean newState(final start=initialState); public PetriNets.Interfaces.SetPortIn inTransition; PetriNets.Interfaces.FirePortOut outTransition1; PetriNets.Interfaces.FirePortOut outTransition2; equation // Set new state for next iteration state = pre(newState); newState = inTransition.set or state and not (outTransition1.fire or outTransition2.fire); // Report state to input and output transitions inTransition.state = state; outTransition1.state = state; outTransition2.state = outTransition1.state and not outTransition1.fire; end Place12;
Name | Default | Description |
---|---|---|
initialState | false | Initial value of state |
model Place22 "Place with two input and two output transitions" parameter Boolean initialState=false "Initial value of state"; Boolean state(final start=initialState) "State of place"; protected Boolean newState(final start=initialState); public PetriNets.Interfaces.FirePortOut outTransition1; PetriNets.Interfaces.FirePortOut outTransition2; PetriNets.Interfaces.SetPortIn inTransition1; PetriNets.Interfaces.SetPortIn inTransition2; equation // Set new state for next iteration state = pre(newState); newState = inTransition1.set or inTransition2.set or state and not ( outTransition1.fire or outTransition2.fire); // Report state to input and output transitions inTransition1.state = state; inTransition2.state = inTransition1.state or inTransition1.set; outTransition1.state = state; outTransition2.state = outTransition1.state and not outTransition1.fire; end Place22;
Name | Default | Description |
---|---|---|
condLabel | " " | Condition as string (e.g. "x > 0") |
model Transition "Transition with one input and one output connection" parameter String condLabel=" " "Condition as string (e.g. \"x > 0\")"; Boolean condition; Boolean fire; PetriNets.Interfaces.FirePortIn inTransition; PetriNets.Interfaces.SetPortOut outTransition; Modelica.Blocks.Interfaces.BooleanInPort conditionPort(final n=1); equation condition = conditionPort.signal[1]; fire = condition and inTransition.state and not outTransition.state; inTransition.fire = fire; outTransition.set = fire; end Transition;
Name | Default | Description |
---|---|---|
condLabel | " " | Condition as string (e.g. "x > 0") |
model Parallel "Transition with one input and two output connections" parameter String condLabel=" " "Condition as string (e.g. \"x > 0\")"; Boolean fire; Boolean condition; PetriNets.Interfaces.FirePortIn inTransition; PetriNets.Interfaces.SetPortOut outTransition1; PetriNets.Interfaces.SetPortOut outTransition2; Modelica.Blocks.Interfaces.BooleanInPort conditionPort(final n=1); equation condition = conditionPort.signal[1]; fire = condition and inTransition.state and not (outTransition1.state or outTransition2.state); inTransition.fire = fire; outTransition1.set = fire; outTransition2.set = fire; end Parallel;
Name | Default | Description |
---|---|---|
condLabel | " " | Condition as string (e.g. "x > 0") |
model Synchronize "Transition with two input and one output connections" parameter String condLabel=" " "Condition as string (e.g. \"x > 0\")"; Boolean condition; Boolean fire; PetriNets.Interfaces.FirePortIn inTransition1; PetriNets.Interfaces.FirePortIn inTransition2; PetriNets.Interfaces.SetPortOut outTransition; Modelica.Blocks.Interfaces.BooleanInPort conditionPort(final n=1); equation condition = conditionPort.signal[1]; fire = condition and inTransition1.state and inTransition2.state and not outTransition.state; inTransition1.fire = fire; inTransition2.fire = fire; outTransition.set = fire; end Synchronize;