Petri Nets are bipartite graphs that only allow connection of different kinds of nodes, places to transitions or transitions to places. The Modelica type system can ensure that only legal connections are made if we define two different connector classes, one class PTPort for for places to transitions-with class prefix and variable suffixes PT, and another class TPPort for transitions for places - with class prefix and variable suffixes TP. Since variable names are different, the connector types are different in the Modelica type system, even though the connector classes in both cases represent the same kind of variables:state and firing information.
In order to have slightly different connector icons for the input version (filled triangle) and the output version (unfilled triangle), we also define otherwise identical input and output versions of these connector classes, see below. There is also a ConditionPort connector class for specifying an optional input condition to a Transition.
We now define Place and Transition classes.
We also need utility Boolean reduction functions anyTrue and allTrue.
All classes and functions are collected into a package called NormalPetriNet:
encapsulated package NormalPetriNet
connector PTPort ...;
connector PTPortIn ...;
connector PTPortOut ...;
connector TPPort ...;
connector TPPortIn ...;
connector TPPortOut ...;
connector ConditionPort ...;
class Place ...;
class Transition ...;
function anyTrue ...;
function allTrue ...;
end NormalPetriNet;
We now return to our job shop system example. Its Petri net graph is shown once more below in Figure 1, with the difference that the token has advanced, representing the condition C3 that a job is currently being processed.
Figure 1: The job shop system Petri Net graph once more. The job is in the stage of being processed.
We would now like to build a Modelica Petri net model of the job shop system, using our recently developed NormalPetriNet package. We need modified instances of the general Place and Transition classes in order to reflect the different numbers of input and output ports.The JobShopSystem model follows below, containing these modified instances of places and transitions, as well as connection equations.
Finally we simulate the job shop system model using the above default settings, for a job that passes through the system and is processed.
Simulation of the model fails as of October 2015, Will be fixed in the near future