marking.

within PNlib.Examples.Models.BicoloredPlaces;

model CPC
  Real color[numColors] "marking";
  Real t = sum(color) "total marking";
  parameter Integer nIn = 0 "number of input transitions"
  parameter Integer nOut = 0 "number of output transitions"
  parameter Real startMarks[numColors] = fill(0, numColors) "start marks"
  parameter Real minMarks[numColors] = fill(0, numColors) "minimum capacity"
  parameter Real maxMarks[numColors] = fill(PNlib.Constants.inf, numColors) "maximum capacity"
  PNlib.Interfaces.PlaceIn[nIn, numColors] inTransition
  PNlib.Interfaces.PlaceOut[nOut, numColors] outTransition
  Boolean animateMarking = settings.animateMarking "only for place animation and display (Do not change!)";
protected
  outer PNlib.Components.Settings settings "global settings for animation and display";
  PNlib.Components.PC place1(nIn = nIn, nOut = nOut, startMarks = startMarks[1], minMarks = minMarks[1], maxMarks = maxMarks[1]);
  PNlib.Components.PC place2(nIn = nIn, nOut = nOut, startMarks = startMarks[2], minMarks = minMarks[2], maxMarks = maxMarks[2]);
equation
  color = {place1.t, place2.t};
  for i in 1:nIn loop
    connect(inTransition[i, 1], place1.inTransition[i]);
    connect(inTransition[i, 2], place2.inTransition[i]);
  end for;
  for i in 1:nOut loop
    connect(outTransition[i, 1], place1.outTransition[i]);
    connect(outTransition[i, 2], place2.outTransition[i]);
  end for;
end CPC;


number of input transitions.

within PNlib.Examples.Models.BicoloredPlaces;

model CTC
  parameter Integer nIn = 0 "number of input transitions"
  parameter Integer nOut = 0 "number of output transitions"
  Real maximumSpeed = 1 "maximum speed"
  Boolean fire = transition_.fire "Does the transition fire?";
  Real instantaneousSpeed = transition_.instantaneousSpeed "instantaneous speed";
  Real actualSpeed = transition_.actualSpeed;
  Real arcWeightIn[nIn, numColors] = fill(1, nIn, numColors) "arc weights of input places"
  Real arcWeightOut[nOut, numColors] = fill(1, nOut, numColors) "arc weights of output places"
  PNlib.Interfaces.TransitionIn[nIn, numColors] inPlaces
  PNlib.Interfaces.TransitionOut[nOut, numColors] outPlaces
protected
  outer PNlib.Components.Settings settings "global settings for animation and display";
  PNlib.Components.TC transition_(nIn = numColors*nIn, nOut = numColors*nOut, maximumSpeed = maximumSpeed, arcWeightIn = arcWeightIn_flat, arcWeightOut = arcWeightOut_flat);
  Real arcWeightIn_flat[nIn*numColors];
  Real arcWeightOut_flat[nOut*numColors];
equation
  for i in 1:nIn loop
    for j in 1:numColors loop
      connect(inPlaces[i, j], transition_.inPlaces[j + (i - 1)*numColors]);
      arcWeightIn_flat[j + (i - 1)*numColors] = arcWeightIn[i, j];
    end for;
  end for;
  for i in 1:nOut loop
    for j in 1:numColors loop
      connect(outPlaces[i, j], transition_.outPlaces[j + (i - 1)*numColors]);
      arcWeightOut_flat[j + (i - 1)*numColors] = arcWeightOut[i, j];
    end for;
  end for;
end CTC;


Stunde.

within PNlib.Examples.Models.FiliP;

model AllgemeineParameter
  Real Stunde(displayUnit = "Stunde") = time/24;
  Real Tag(displayUnit = "Tag") = time;
  parameter Real BeginFruehschicht = 6;
  parameter Real BeginSpaetschicht = 12.3;
  parameter Real BeginNachtschicht = 20.25;
  parameter Real DauerFruehschicht = 8.2;
  parameter Real DauerSpaetschicht = 8.2;
  parameter Real DauerNachtschicht = 10;
end AllgemeineParameter;


Begin Urlaub.

within PNlib.Examples.Models.FiliP;

model KrankUrlaub
  parameter Real UrlaubStartTermine[:] = {10, 20, 30} "Begin Urlaub";
  parameter Real UrlaubEndTermine[:] = {15, 25, 35} "Ende Urlaub";
  PNlib.Components.TD Gesund1(nIn = 1, delay = 0, nOut = 1)
  PNlib.Examples.Models.FiliP.PNerweiterungen.PDwkeit Krankpruefer1(enablingProbOut = {WK, 1 - WK}, enablingType = PNlib.Types.EnablingType.Probability, nIn = 1, nOut = 2)
  PNlib.Components.TD Arbeitet1(nIn = 1, nOut = 1, delay = 0)
  PNlib.Components.TD T12(nIn = 1, nOut = 1, delay = 0)
  PNlib.Components.PD KannArbeiteten(nIn = 3, nOut = 1)
  PNlib.Interfaces.TransitionOut transitionOut
  PNlib.Interfaces.PlaceIn placeIn[3]
  Real WK;
  //Real WU;
  PNlib.Components.TFDS Krank(E = 1:31, P = {75/237, 41/237, 24/237, 19/237, 22/237, 10/237, 13/237, 4/237, 2/237, 3/237, 2/237, 1/237, 3/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237, 1/237}, distributionType = PNlib.Types.DistributionType.Discrete, nIn = 1, nOut = 1)
  PNlib.Components.TE TUrlaubEnde(event = UrlaubEndTermine, nIn = 1, nOut = 1)
  PNlib.Components.TE TUrlaubStart(event = UrlaubStartTermine, nOut = 1)
  PNlib.Components.PD ImUrlaub(nIn = 1, nOut = 1)
  PNlib.Components.TD Urlaubgeber(delay = 0, nIn = 2, nOut = 1)
  PNlib.Components.PD P1(nIn = 1, nOut = 2)
  PNlib.Components.TE T1(event = UrlaubEndTermine, nIn = 1)
  PNlib.Components.PD Urlaubpruefer(nIn = 3, nOut = 2)
protected
  outer PNlib.Components.Settings settings "global settings for animation and display";
equation
  connect(Urlaubpruefer.outTransition[2], Arbeitet1.inPlaces[1])
  connect(Urlaubpruefer.outTransition[1], Urlaubgeber.inPlaces[1])
  connect(Urlaubpruefer.inTransition[3], placeIn[3])
  connect(Urlaubpruefer.inTransition[2], placeIn[2])
  connect(Urlaubpruefer.inTransition[1], placeIn[1])
  connect(P1.outTransition[2], Urlaubgeber.inPlaces[2])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(TUrlaubStart.outPlaces[1], P1.inTransition[1])
  connect(ImUrlaub.inTransition[1], Urlaubgeber.outPlaces[1])
  connect(Arbeitet1.outPlaces[1], Krankpruefer1.inTransition[1])
  connect(Krank.inPlaces[1], Krankpruefer1.outTransition[1])
  connect(Krankpruefer1.outTransition[2], Gesund1.inPlaces[1])
  connect(ImUrlaub.outTransition[1], TUrlaubEnde.inPlaces[1])
  connect(KannArbeiteten.inTransition[1], Gesund1.outPlaces[1])
  connect(KannArbeiteten.inTransition[2], Krank.outPlaces[1])
  connect(KannArbeiteten.inTransition[3], TUrlaubEnde.outPlaces[1])
  connect(KannArbeiteten.outTransition[1], T12.inPlaces[1])
  connect(T12.outPlaces[1], transitionOut)
  WK = if time <= 744 then 0.0117 else if time <= 1464 then 0.008 else if time <= 2208 then 0.0196 else if time <= 2928 then 0.0325 else if time <= 3672 then 0.0276 else if time <= 4416 then 0.031 else if time <= 5088 then 0.0344 else if time <= 5832 then 0.0458 else if time <= 6552 then 0.0084 else if time <= 7296 then 0.0118 else if time <= 8016 then 0.0315 else 0.0188;
  //WU = if time <= 744 then 0.0212 else if time <= 1464 then 0.0531 else if time <= 2208 then 0.0310 else if time <= 2928 then 0.0458 else if time <= 3672 then 0.0671 else if time <= 4416 then 0.046 else if time <= 5088 then 0.0135 else if time <= 5832 then 0.0304 else if time <= 6552 then 0.03 else if time <= 7296 then 0.0446 else if time <= 8016 then 0.0372 else 0.0618;
end KrankUrlaub;


Was fuer eine Stelle.

within PNlib.Examples.Models.FiliP;

model Pflegekraft
  parameter Real Stelle = 1 "Was fuer eine Stelle"
  //parameter Integer UrlaubsTage = 36 "Anzahl der Urlaubstage"
  parameter Integer WEF = 1 "Welches Wochenende frei"
  parameter Real UrlaubStartTermine[:] = {10, 20, 30} "number of input places"
  parameter Real UrlaubEndTermine[:] = {15, 25, 35} "number of input places"
  Real HatFruehDienst = IstImFruehDienst.t;
  Real HatSpaetDienst = IstImSpaetDienst.t;
  Real HatNachtDienst = IstImNachtDienst.t;
  Boolean IstKrank = krankurlaub.Krank.fire;
  Real HatUrlaubt = krankurlaub.ImUrlaub.t;
  Real HatWochenende = ImWochenEnde.t;
  Real HatRuhezeit = Ruhe.t;
  Real Dienstfaehig = Dienstbereit.t;
  Real ArbeitszeitKontingentPlanungsPeriode = ArbeitszeitKontingent.t;
  Real GeleisteteArbeistzeitGesammt = GeleisteteArbeistzeit.t;
protected
  extends PNlib.Examples.Models.FiliP.AllgemeineParameter;
  PNlib.Components.PD IstImFruehDienst(nIn = 1, nOut = 1)
  PNlib.Components.PD IstImSpaetDienst(nIn = 1, nOut = 1)
  PNlib.Components.PD IstImNachtDienst(nIn = 1, nOut = 1)
  PNlib.Components.TT FSB(nOut = 2, nIn = 2, tactIntervall = 1, tactStart = BeginFruehschicht/24, arcWeightIn = {1, DauerFruehschicht - 0.5})
  PNlib.Components.TT SSB(nOut = 2, nIn = 2, tactIntervall = 1, tactStart = BeginSpaetschicht/24, arcWeightIn = {1, DauerSpaetschicht - 0.5})
  PNlib.Components.TT NSB(nOut = 2, nIn = 2, tactIntervall = 1, tactStart = BeginNachtschicht/24, arcWeightIn = {1, DauerNachtschicht - 0.75})
  PNlib.Components.TD FSE(nIn = 2, nOut = 2, delay = DauerFruehschicht/24, arcWeightOut = {1, DauerFruehschicht - 0.5})
  PNlib.Components.TD SSE(nIn = 2, nOut = 2, delay = DauerSpaetschicht/24, arcWeightOut = {1, DauerSpaetschicht - 0.5})
  PNlib.Components.TD NSE(nIn = 2, nOut = 2, delay = DauerNachtschicht/24, arcWeightOut = {1, DauerNachtschicht - 0.75})
  PNlib.Components.PC GeleisteteArbeistzeit(nIn = 3)
  PNlib.Components.PD Ruhe(nOut = 2, nIn = 3)
  PNlib.Components.PD Dienstbereit(nIn = 1, nOut = 5, startTokens = 1)
  PNlib.Components.TD RuheZeitEnde(nIn = 1, delay = 11/24, nOut = 1)
  PNlib.Components.PC ArbeitszeitKontingent(nIn = 1, nOut = 4, startMarks = if WEF == 2 then 57.75*Stelle else 11*Stelle)
  PNlib.Interfaces.TransitionOut transitionOut[3]
  PNlib.Interfaces.TransitionIn transitionIn[3]
  PNlib.Components.TT ArbeitszeitGeber(nOut = 1, tactIntervall = 14, tactStart = if WEF == 2 then 9 else 2, arcWeightOut = {2*38.5*Stelle}, nIn = 1, arcWeightIn = {ArbeitszeitKontingent.t})
  PNlib.Components.TT WochenEndSignal(nOut = 1, tactIntervall = if WEF == 3 then 7 else 14, tactStart = if WEF == 2 then 9 else 2)
  PNlib.Components.TD WochenEndGeber2(nIn = 2, nOut = 1, delay = 0)
  PNlib.Components.TD WochenEndGeber1(nIn = 2, nOut = 1, delay = 0)
  PNlib.Components.PD SollInsWochenEnde(nOut = 3, nIn = 1, maxTokens = 1)
  PNlib.Components.PD ImWochenEnde(nOut = 1, nIn = 2)
  PNlib.Components.TT WochenEndEnde(nIn = 1, tactIntervall = if WEF == 3 then 7 else 14, tactStart = if WEF == 2 then 11 else 4, nOut = 1)
  PNlib.Components.TD EinTagWiederholer(nOut = 1, nIn = 1, delay = 1)
  PNlib.Components.TD WEenderbeiKrank(nIn = 1, delay = 2)
  PNlib.Examples.Models.FiliP.KrankUrlaub krankurlaub(UrlaubEndTermine = UrlaubEndTermine, UrlaubStartTermine = UrlaubStartTermine)
protected
  outer PNlib.Components.Settings settings "global settings for animation and display";
equation
  connect(WochenEndEnde.outPlaces[1], krankurlaub.placeIn[3])
  connect(EinTagWiederholer.outPlaces[1], krankurlaub.placeIn[2])
  connect(RuheZeitEnde.outPlaces[1], krankurlaub.placeIn[1])
  connect(krankurlaub.transitionOut, Dienstbereit.inTransition[1])
  connect(FSB.outPlaces[1], IstImFruehDienst.inTransition[1])
  connect(IstImFruehDienst.outTransition[1], FSE.inPlaces[1])
  connect(SSB.outPlaces[1], IstImSpaetDienst.inTransition[1])
  connect(SSE.inPlaces[1], IstImSpaetDienst.outTransition[1])
  connect(NSB.outPlaces[1], IstImNachtDienst.inTransition[1])
  connect(IstImNachtDienst.outTransition[1], NSE.inPlaces[1])
  connect(FSB.outPlaces[2], transitionOut[1])
  connect(SSB.outPlaces[2], transitionOut[2])
  connect(NSB.outPlaces[2], transitionOut[3])
  connect(FSE.inPlaces[2], transitionIn[1])
  connect(SSE.inPlaces[2], transitionIn[2])
  connect(NSE.inPlaces[2], transitionIn[3])
  connect(Ruhe.outTransition[1], RuheZeitEnde.inPlaces[1])
  connect(Ruhe.inTransition[1], NSE.outPlaces[1])
  connect(SSE.outPlaces[1], Ruhe.inTransition[2])
  connect(FSE.outPlaces[1], Ruhe.inTransition[3])
  connect(Dienstbereit.outTransition[1], NSB.inPlaces[1])
  connect(SSB.inPlaces[1], Dienstbereit.outTransition[2])
  connect(FSB.inPlaces[1], Dienstbereit.outTransition[3])
  connect(ArbeitszeitKontingent.outTransition[1], FSB.inPlaces[2])
  connect(ArbeitszeitKontingent.outTransition[2], SSB.inPlaces[2])
  connect(ArbeitszeitKontingent.outTransition[3], NSB.inPlaces[2])
  connect(ArbeitszeitGeber.outPlaces[1], ArbeitszeitKontingent.inTransition[1])
  connect(WochenEndEnde.inPlaces[1], ImWochenEnde.outTransition[1])
  connect(WochenEndGeber1.inPlaces[1], Dienstbereit.outTransition[4])
  connect(WochenEndGeber2.inPlaces[1], Ruhe.outTransition[2])
  connect(SollInsWochenEnde.outTransition[1], WochenEndGeber1.inPlaces[2])
  connect(SollInsWochenEnde.outTransition[2], WochenEndGeber2.inPlaces[2])
  connect(WochenEndGeber1.outPlaces[1], ImWochenEnde.inTransition[1])
  connect(WochenEndGeber2.outPlaces[1], ImWochenEnde.inTransition[2])
  connect(WochenEndSignal.outPlaces[1], SollInsWochenEnde.inTransition[1])
  connect(GeleisteteArbeistzeit.inTransition[1], FSE.outPlaces[2])
  connect(GeleisteteArbeistzeit.inTransition[2], SSE.outPlaces[2])
  connect(GeleisteteArbeistzeit.inTransition[3], NSE.outPlaces[2])
  connect(EinTagWiederholer.inPlaces[1], Dienstbereit.outTransition[5])
  connect(WEenderbeiKrank.inPlaces[1], SollInsWochenEnde.outTransition[3])
  connect(ArbeitszeitGeber.inPlaces[1], ArbeitszeitKontingent.outTransition[4])
end Pflegekraft;


Anzahl der Pflegekraefte.

within PNlib.Examples.Models.FiliP;

model Station
  parameter Integer nP = 1 "Anzahl der Pflegekraefte"
  parameter Integer APFD = 3 "Min. Anzahl Personal im Fruehedienst"
  parameter Integer APSD = 2 "Min. Anzahl Personal im Spaetdienst"
  parameter Integer APND = 2 "Min. Anzahl Personal im Nachtdienst"
  Real BesetzungFruehDienst = PersonalImFruedienst.t;
  Real BesetzungSpaetDienst = PersonalImSpaetdienst.t;
  Real BesetzungNachtDienst = PersonalImNachtdienst.t;
  Real BesetzungsDefizitFrueh = DefizitFruehschicht.t;
  Real BesetzungsDefizitSpaet = DefizitSpaetSchicht.t;
  Real BesetzungsDefizitNacht = DefizizNachtSchicht.t;
protected
  extends PNlib.Examples.Models.FiliP.AllgemeineParameter;
  PNlib.Components.PD DefizitFruehschicht(nIn = 1)
  PNlib.Components.PD DefizitSpaetSchicht(nIn = 1)
  PNlib.Components.PD DefizizNachtSchicht(nIn = 1)
  PNlib.Components.PD PersonalImFruedienst(enablingProbIn = fill(1/nP, nP), enablingProbOut = fill(1/nP, nP), enablingType = PNlib.Types.EnablingType.Probability, maxTokens = APFD, nIn = nP, nOut = nP)
  PNlib.Components.PD PersonalImSpaetdienst(enablingProbIn = fill(1/nP, nP), enablingProbOut = fill(1/nP, nP), enablingType = PNlib.Types.EnablingType.Probability, maxTokens = APSD, nIn = nP, nOut = nP)
  PNlib.Components.PD PersonalImNachtdienst(enablingProbIn = fill(1/nP, nP), enablingProbOut = fill(1/nP, nP), enablingType = PNlib.Types.EnablingType.Probability, maxTokens = APND, nIn = nP, nOut = nP)
  PNlib.Interfaces.PlaceOut placeOut[3*nP]
  PNlib.Interfaces.PlaceIn placeIn[3*nP]
  PNlib.Components.TT BeginnFrueh(nOut = 1, tactIntervall = 1, tactStart = (BeginFruehschicht + 1)/24, arcWeightOut = {APFD - PersonalImFruedienst.t})
  PNlib.Components.TT BeginnSpaet(nOut = 1, tactIntervall = 1, tactStart = (BeginSpaetschicht + 1)/24, arcWeightOut = {APSD - PersonalImSpaetdienst.t})
  PNlib.Components.TT BeginnNacht(nOut = 1, tactIntervall = 1, tactStart = (BeginNachtschicht + 1)/24, arcWeightOut = {APND - PersonalImNachtdienst.t})
  outer PNlib.Components.Settings settings "global settings for animation and display";
equation
  connect(BeginnNacht.outPlaces[1], DefizizNachtSchicht.inTransition[1])
  connect(BeginnSpaet.outPlaces[1], DefizitSpaetSchicht.inTransition[1])
  connect(BeginnFrueh.outPlaces[1], DefizitFruehschicht.inTransition[1])
  for i in 1:nP loop
    connect(PersonalImFruedienst.inTransition[i], placeIn[1 + 3*(i - 1)])
    connect(PersonalImFruedienst.outTransition[i], placeOut[1 + 3*(i - 1)])
    connect(PersonalImSpaetdienst.outTransition[i], placeOut[2 + 3*(i - 1)])
    connect(PersonalImSpaetdienst.inTransition[i], placeIn[2 + 3*(i - 1)])
    connect(PersonalImNachtdienst.outTransition[i], placeOut[3 + 3*(i - 1)])
    connect(PersonalImNachtdienst.inTransition[i], placeIn[3 + 3*(i - 1)])
  end for;
end Station;


within PNlib.Examples.Models.FiliP.ModellStationen;

model Station1
  extends Modelica.Icons.Example;
  extends PNlib.Examples.Models.FiliP.AllgemeineParameter;
  PNlib.Examples.Models.FiliP.Station station(APND = 1, nP = 1, APFD = 1, APSD = 1)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft(Dienstbereit(maxTokens = 1), WEF = 1)
  inner PNlib.Components.Settings settings
equation
  connect(station.placeOut[1], pflegekraft.transitionIn[1]);
  connect(station.placeOut[2], pflegekraft.transitionIn[2]);
  connect(station.placeOut[3], pflegekraft.transitionIn[3]);
  connect(station.placeIn[1], pflegekraft.transitionOut[1]);
  connect(station.placeIn[2], pflegekraft.transitionOut[2]);
  connect(station.placeIn[3], pflegekraft.transitionOut[3]);
end Station1;


within PNlib.Examples.Models.FiliP.ModellStationen;

model Station20
  extends Modelica.Icons.Example;
  extends PNlib.Examples.Models.FiliP.AllgemeineParameter;
  PNlib.Examples.Models.FiliP.Station station(nP = 20, APFD = 4, APSD = 3, APND = 1)
  inner PNlib.Components.Settings settings
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft1(Stelle = 0.75)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft2(Stelle = 0.9)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft3(Stelle = 0.51)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft4(Stelle = 0.5, WEF = 2)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft5(Stelle = 1, WEF = 2)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft6(Stelle = 0.41)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft7(Stelle = 0.35, WEF = 2)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft8(Stelle = 0.5)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft9(Stelle = 0.5)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft10(Stelle = 1, WEF = 2)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft11(Stelle = 0.8)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft12(Stelle = 0.75, WEF = 2)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft13(Stelle = 1, WEF = 2)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft14(Stelle = 0.5)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft15(Stelle = 0.35)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft16(Stelle = 0.75)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft17(Stelle = 1, WEF = 2)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft18(Stelle = 1)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft19(Stelle = 1, WEF = 2)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft20(Stelle = 1, WEF = 2)
equation
  connect(station.placeIn[60], pflegekraft20.transitionOut[3]);
  connect(station.placeIn[59], pflegekraft20.transitionOut[2]);
  connect(station.placeIn[58], pflegekraft20.transitionOut[1]);
  connect(station.placeIn[57], pflegekraft19.transitionOut[3]);
  connect(station.placeIn[56], pflegekraft19.transitionOut[2]);
  connect(station.placeIn[55], pflegekraft19.transitionOut[1]);
  connect(station.placeIn[54], pflegekraft18.transitionOut[3]);
  connect(station.placeIn[53], pflegekraft18.transitionOut[2]);
  connect(station.placeIn[52], pflegekraft18.transitionOut[1]);
  connect(station.placeIn[51], pflegekraft17.transitionOut[3]);
  connect(station.placeIn[50], pflegekraft17.transitionOut[2]);
  connect(station.placeIn[49], pflegekraft17.transitionOut[1]);
  connect(station.placeIn[48], pflegekraft16.transitionOut[3]);
  connect(station.placeIn[47], pflegekraft16.transitionOut[2]);
  connect(station.placeIn[46], pflegekraft16.transitionOut[1]);
  connect(station.placeIn[45], pflegekraft15.transitionOut[3]);
  connect(station.placeIn[44], pflegekraft15.transitionOut[2]);
  connect(station.placeIn[43], pflegekraft15.transitionOut[1]);
  connect(station.placeIn[42], pflegekraft14.transitionOut[3]);
  connect(station.placeIn[41], pflegekraft14.transitionOut[2]);
  connect(station.placeIn[40], pflegekraft14.transitionOut[1]);
  connect(station.placeIn[39], pflegekraft13.transitionOut[3]);
  connect(station.placeIn[38], pflegekraft13.transitionOut[2]);
  connect(station.placeIn[37], pflegekraft13.transitionOut[1]);
  connect(station.placeIn[36], pflegekraft12.transitionOut[3]);
  connect(station.placeIn[35], pflegekraft12.transitionOut[2]);
  connect(station.placeIn[34], pflegekraft12.transitionOut[1]);
  connect(station.placeIn[33], pflegekraft11.transitionOut[3]);
  connect(station.placeIn[32], pflegekraft11.transitionOut[2]);
  connect(station.placeIn[31], pflegekraft11.transitionOut[1]);
  connect(station.placeIn[30], pflegekraft10.transitionOut[3]);
  connect(station.placeIn[29], pflegekraft10.transitionOut[2]);
  connect(station.placeIn[28], pflegekraft10.transitionOut[1]);
  connect(station.placeIn[27], pflegekraft9.transitionOut[3]);
  connect(station.placeIn[26], pflegekraft9.transitionOut[2]);
  connect(station.placeIn[25], pflegekraft9.transitionOut[1]);
  connect(station.placeIn[24], pflegekraft8.transitionOut[3]);
  connect(station.placeIn[23], pflegekraft8.transitionOut[2]);
  connect(station.placeIn[22], pflegekraft8.transitionOut[1]);
  connect(station.placeIn[21], pflegekraft7.transitionOut[3]);
  connect(station.placeIn[20], pflegekraft7.transitionOut[2]);
  connect(station.placeIn[19], pflegekraft7.transitionOut[1]);
  connect(station.placeIn[18], pflegekraft6.transitionOut[3]);
  connect(station.placeIn[17], pflegekraft6.transitionOut[2]);
  connect(station.placeIn[16], pflegekraft6.transitionOut[1]);
  connect(station.placeIn[15], pflegekraft5.transitionOut[3]);
  connect(station.placeIn[14], pflegekraft5.transitionOut[2]);
  connect(station.placeIn[13], pflegekraft5.transitionOut[1]);
  connect(station.placeIn[12], pflegekraft4.transitionOut[3]);
  connect(station.placeIn[11], pflegekraft4.transitionOut[2]);
  connect(station.placeIn[10], pflegekraft4.transitionOut[1]);
  connect(station.placeIn[9], pflegekraft3.transitionOut[3]);
  connect(station.placeIn[8], pflegekraft3.transitionOut[2]);
  connect(station.placeIn[7], pflegekraft3.transitionOut[1]);
  connect(station.placeIn[6], pflegekraft2.transitionOut[3]);
  connect(station.placeIn[5], pflegekraft2.transitionOut[2]);
  connect(station.placeIn[4], pflegekraft2.transitionOut[1]);
  connect(station.placeIn[3], pflegekraft1.transitionOut[3]);
  connect(station.placeIn[2], pflegekraft1.transitionOut[2]);
  connect(station.placeIn[1], pflegekraft1.transitionOut[1]);
  connect(station.placeOut[60], pflegekraft20.transitionIn[3]);
  connect(station.placeOut[59], pflegekraft20.transitionIn[2]);
  connect(station.placeOut[58], pflegekraft20.transitionIn[1]);
  connect(station.placeOut[57], pflegekraft19.transitionIn[3]);
  connect(station.placeOut[56], pflegekraft19.transitionIn[2]);
  connect(station.placeOut[55], pflegekraft19.transitionIn[1]);
  connect(station.placeOut[54], pflegekraft18.transitionIn[3]);
  connect(station.placeOut[53], pflegekraft18.transitionIn[2]);
  connect(station.placeOut[52], pflegekraft18.transitionIn[1]);
  connect(station.placeOut[51], pflegekraft17.transitionIn[3]);
  connect(station.placeOut[50], pflegekraft17.transitionIn[2]);
  connect(station.placeOut[49], pflegekraft17.transitionIn[1]);
  connect(station.placeOut[48], pflegekraft16.transitionIn[3]);
  connect(station.placeOut[47], pflegekraft16.transitionIn[2]);
  connect(station.placeOut[46], pflegekraft16.transitionIn[1]);
  connect(station.placeOut[45], pflegekraft15.transitionIn[3]);
  connect(station.placeOut[44], pflegekraft15.transitionIn[2]);
  connect(station.placeOut[43], pflegekraft15.transitionIn[1]);
  connect(station.placeOut[42], pflegekraft14.transitionIn[3]);
  connect(station.placeOut[41], pflegekraft14.transitionIn[2]);
  connect(station.placeOut[40], pflegekraft14.transitionIn[1]);
  connect(station.placeOut[39], pflegekraft13.transitionIn[3]);
  connect(station.placeOut[38], pflegekraft13.transitionIn[2]);
  connect(station.placeOut[37], pflegekraft13.transitionIn[1]);
  connect(station.placeOut[36], pflegekraft12.transitionIn[3]);
  connect(station.placeOut[35], pflegekraft12.transitionIn[2]);
  connect(station.placeOut[34], pflegekraft12.transitionIn[1]);
  connect(station.placeOut[33], pflegekraft11.transitionIn[3]);
  connect(station.placeOut[32], pflegekraft11.transitionIn[2]);
  connect(station.placeOut[31], pflegekraft11.transitionIn[1]);
  connect(station.placeOut[30], pflegekraft10.transitionIn[3]);
  connect(station.placeOut[29], pflegekraft10.transitionIn[2]);
  connect(station.placeOut[28], pflegekraft10.transitionIn[1]);
  connect(station.placeOut[27], pflegekraft9.transitionIn[3]);
  connect(station.placeOut[26], pflegekraft9.transitionIn[2]);
  connect(station.placeOut[25], pflegekraft9.transitionIn[1]);
  connect(station.placeOut[24], pflegekraft8.transitionIn[3]);
  connect(station.placeOut[23], pflegekraft8.transitionIn[2]);
  connect(station.placeOut[22], pflegekraft8.transitionIn[1]);
  connect(station.placeOut[21], pflegekraft7.transitionIn[3]);
  connect(station.placeOut[20], pflegekraft7.transitionIn[2]);
  connect(station.placeOut[19], pflegekraft7.transitionIn[1]);
  connect(station.placeOut[18], pflegekraft6.transitionIn[3]);
  connect(station.placeOut[17], pflegekraft6.transitionIn[2]);
  connect(station.placeOut[16], pflegekraft6.transitionIn[1]);
  connect(station.placeOut[15], pflegekraft5.transitionIn[3]);
  connect(station.placeOut[14], pflegekraft5.transitionIn[2]);
  connect(station.placeOut[13], pflegekraft5.transitionIn[1]);
  connect(station.placeOut[12], pflegekraft4.transitionIn[3]);
  connect(station.placeOut[11], pflegekraft4.transitionIn[2]);
  connect(station.placeOut[10], pflegekraft4.transitionIn[1]);
  connect(station.placeOut[9], pflegekraft3.transitionIn[3]);
  connect(station.placeOut[8], pflegekraft3.transitionIn[2]);
  connect(station.placeOut[7], pflegekraft3.transitionIn[1]);
  connect(station.placeOut[6], pflegekraft2.transitionIn[3]);
  connect(station.placeOut[5], pflegekraft2.transitionIn[2]);
  connect(station.placeOut[4], pflegekraft2.transitionIn[1]);
  connect(station.placeOut[3], pflegekraft1.transitionIn[3]);
  connect(station.placeOut[2], pflegekraft1.transitionIn[2]);
  connect(station.placeOut[1], pflegekraft1.transitionIn[1]);
//////////////////////////////////////////////////////////////////////////////
end Station20;


within PNlib.Examples.Models.FiliP.ModellStationen;

model Station7
  extends Modelica.Icons.Example;
  extends PNlib.Examples.Models.FiliP.AllgemeineParameter;
  PNlib.Examples.Models.FiliP.Station station(APFD = 1, APND = 1, APSD = 1, nP = 7)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft1(Dienstbereit(maxTokens = 1), UrlaubEndTermine = {25, 53, 81}, UrlaubStartTermine = {11, 39, 67}, WEF = 2)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft2(UrlaubEndTermine = {109, 137, 165}, UrlaubStartTermine = {95, 123, 151}, WEF = 2)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft3(UrlaubEndTermine = {193, 221, 249}, UrlaubStartTermine = {179, 207, 235}, WEF = 2)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft4(UrlaubEndTermine = {263, 277, 291, 305, 319, 333}, UrlaubStartTermine = {256, 270, 284, 298, 312, 326}, WEF = 3)
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft5(UrlaubEndTermine = {19, 47, 75}, UrlaubStartTermine = {5, 33, 61})
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft6(UrlaubEndTermine = {103, 131, 159}, UrlaubStartTermine = {89, 117, 145})
  PNlib.Examples.Models.FiliP.Pflegekraft pflegekraft7(UrlaubEndTermine = {187, 215, 243}, UrlaubStartTermine = {173, 201, 229})
  inner PNlib.Components.Settings settings
equation
  connect(station.placeIn[21], pflegekraft7.transitionOut[3]);
  connect(station.placeIn[20], pflegekraft7.transitionOut[2]);
  connect(station.placeIn[19], pflegekraft7.transitionOut[1]);
  connect(station.placeIn[18], pflegekraft6.transitionOut[3]);
  connect(station.placeIn[17], pflegekraft6.transitionOut[2]);
  connect(station.placeIn[16], pflegekraft6.transitionOut[1]);
  connect(station.placeIn[15], pflegekraft5.transitionOut[3]);
  connect(station.placeIn[14], pflegekraft5.transitionOut[2]);
  connect(station.placeIn[13], pflegekraft5.transitionOut[1]);
  connect(station.placeIn[12], pflegekraft4.transitionOut[3]);
  connect(station.placeIn[11], pflegekraft4.transitionOut[2]);
  connect(station.placeIn[10], pflegekraft4.transitionOut[1]);
  connect(station.placeIn[9], pflegekraft3.transitionOut[3]);
  connect(station.placeIn[8], pflegekraft3.transitionOut[2]);
  connect(station.placeIn[7], pflegekraft3.transitionOut[1]);
  connect(station.placeIn[6], pflegekraft2.transitionOut[3]);
  connect(station.placeIn[5], pflegekraft2.transitionOut[2]);
  connect(station.placeIn[4], pflegekraft2.transitionOut[1]);
  connect(station.placeOut[1], pflegekraft1.transitionIn[1]);
  connect(station.placeOut[2], pflegekraft1.transitionIn[2]);
  connect(station.placeOut[3], pflegekraft1.transitionIn[3]);
  connect(station.placeOut[21], pflegekraft7.transitionIn[3]);
  connect(station.placeOut[20], pflegekraft7.transitionIn[2]);
  connect(station.placeOut[19], pflegekraft7.transitionIn[1]);
  connect(station.placeOut[18], pflegekraft6.transitionIn[3]);
  connect(station.placeOut[17], pflegekraft6.transitionIn[2]);
  connect(station.placeOut[16], pflegekraft6.transitionIn[1]);
  connect(station.placeOut[15], pflegekraft5.transitionIn[3]);
  connect(station.placeOut[14], pflegekraft5.transitionIn[2]);
  connect(station.placeOut[13], pflegekraft5.transitionIn[1]);
  connect(station.placeOut[12], pflegekraft4.transitionIn[3]);
  connect(station.placeOut[11], pflegekraft4.transitionIn[2]);
  connect(station.placeOut[10], pflegekraft4.transitionIn[1]);
  connect(station.placeOut[9], pflegekraft3.transitionIn[3]);
  connect(station.placeOut[8], pflegekraft3.transitionIn[2]);
  connect(station.placeOut[7], pflegekraft3.transitionIn[1]);
  connect(station.placeOut[6], pflegekraft2.transitionIn[3]);
  connect(station.placeOut[5], pflegekraft2.transitionIn[2]);
  connect(station.placeOut[4], pflegekraft2.transitionIn[1]);
  connect(station.placeIn[1], pflegekraft1.transitionOut[1]);
  connect(station.placeIn[2], pflegekraft1.transitionOut[2]);
  connect(station.placeIn[3], pflegekraft1.transitionOut[3]);
end Station7;


Discrete Place.

within PNlib.Examples.Models.FiliP.PNerweiterungen;

model PDwkeit "Discrete Place"
  discrete Integer t(start = startTokens, fixed = true) "marking";
  parameter Integer nIn = 0 "number of input transitions"
  parameter Integer nOut = 0 "number of output transitions"
  //****MODIFIABLE PARAMETERS AND VARIABLES BEGIN****//
  parameter Integer startTokens = 0 "start tokens"
  parameter Integer minTokens = 0 "minimum capacity"
  parameter Integer maxTokens = PNlib.Constants.Integer_inf "maximum capacity"
  Boolean reStart(start = false, fixed = true) = false "restart condition"
  parameter Integer reStartTokens = startTokens "number of tokens at restart"
  parameter PNlib.Types.EnablingType enablingType = PNlib.Types.EnablingType.Priority "resolution type of actual conflict (type-1-conflict)"
  parameter Integer enablingPrioIn[nIn] = 1:nIn "enabling priorities of input transitions"
  parameter Integer enablingPrioOut[nOut] = 1:nOut "enabling priorities of output transitions"
  Real enablingProbIn[nIn] = fill(1/nIn, nIn) "enabling probabilities of input transitions"
  Real enablingProbOut[nOut] = fill(1/nOut, nOut) "enabling probabilities of output transitions"
  parameter Real enablingBeneIn[nIn] = 1:nIn "enabling benefit of input transitions"
  parameter Real enablingBeneOut[nOut] = 1:nOut "enabling benefit of output transitions"
  parameter PNlib.Types.BenefitType benefitType = PNlib.Types.BenefitType.Greedy "enabling strategy for benefit"
  parameter Integer N = settings.N "N+1=amount of levels"
  //****MODIFIABLE PARAMETERS AND VARIABLES END****//
  Real levelCon "conversion of tokens to level concentration according to M and N of the settings box";
  Boolean showCapacity = settings.showCapacity "only for place animation and display (Do not change!)";
  Boolean animateMarking = settings.animateMarking "only for place animation and display (Do not change!)";
  Real color[3] "only for place animation and display (Do not change!)";
  parameter Integer localSeedIn = PNlib.Functions.Random.counter() "Local seed to initialize random number generator for input conflicts"
  parameter Integer localSeedOut = PNlib.Functions.Random.counter() "Local seed to initialize random number generator for output conflicts"
  PNlib.Interfaces.PlaceIn inTransition[nIn](each t = pret, each tint = pret, each maxTokens = maxTokens, each maxTokensint = maxTokens, enable = enableIn.TEin_, each emptied = false, each decreasingFactor = 1, each disPlace = true, each speedSum = 0, fire = fireIn, disTransition = disTransitionIn, arcWeightint = arcWeightIn, active = activeIn, enabledByInPlaces = enabledByInPlaces) if nIn > 0 "connector for input transitions"
  PNlib.Interfaces.PlaceOut outTransition[nOut](each t = pret, each tint = pret, each minTokens = minTokens, each minTokensint = minTokens, enable = enableOut.TEout_, each fed = false, each decreasingFactor = 1, each disPlace = true, each arcType = PNlib.Types.ArcType.NormalArc, each speedSum = 0, each tokenInOut = pre(tokeninout), fire = fireOut, disTransition = disTransitionOut, arcWeightint = arcWeightOut, active = activeOut, each testValue = -1, each testValueint = -1, each normalArc = false) if nOut > 0 "connector for output transitions"
  Modelica.Blocks.Interfaces.IntegerOutput pd_t = t "connector for Simulink connection"
protected
  outer PNlib.Components.Settings settings "global settings for animation and display";
  Real tokenscale "only for place animation and display";
  discrete Integer pret "pre marking";
  Integer arcWeightIn[nIn] "Integer weights of input arcs";
  Integer arcWeightOut[nOut] "Integer weights of output arcs";
  Boolean tokeninout(start = false, fixed = true) "change of tokens?";
  Boolean fireIn[nIn] "Do input transtions fire?";
  Boolean fireOut[nOut] "Do output transitions fire?";
  Boolean disTransitionIn[nIn] "Are the input transitions discrete?";
  Boolean disTransitionOut[nOut] "Are the output transtions discrete?";
  Boolean activeIn[nIn] "Are delays passed of input transitions?";
  Boolean activeOut[nOut](each start = false, each fixed = true) "Are delay passed of output transitions?";
  Boolean enabledByInPlaces[nIn] "Are input transitions are enabled by all their input places?";
  //****BLOCKS BEGIN****// since no events are generated within functions!!!
  //change of activation of output transitions
  PNlib.Blocks.anyChange activeConOut(vec = pre(activeOut) and not disTransitionOut);
  //Does any delay passed of a connected transition?
  PNlib.Blocks.anyTrue delayPassedOut(vec = activeOut and disTransitionOut);
  PNlib.Blocks.anyTrue delayPassedIn(vec = activeIn and disTransitionIn);
  //firing sum calculation
  PNlib.Blocks.firingSumDis firingSumIn(fire = fireIn and disTransitionIn, arcWeight = arcWeightIn);
  PNlib.Blocks.firingSumDis firingSumOut(fire = fireOut and disTransitionOut, arcWeight = arcWeightOut);
  //Enabling process
  PNlib.Blocks.enablingOutDis enableOut(delayPassed = delayPassedOut.anytrue, activeCon = activeConOut.anychange, nOut = nOut, arcWeight = arcWeightOut, t = pret, minTokens = minTokens, TAout = activeOut, enablingType = enablingType, enablingPrio = enablingPrioOut, enablingProb = enablingProbOut, enablingBene = enablingBeneOut, benefitType = benefitType, disTransition = disTransitionOut, localSeed = localSeedOut, globalSeed = settings.globalSeed);
  PNlib.Blocks.enablingInDis enableIn(delayPassed = delayPassedIn.anytrue, active = activeIn, nIn = nIn, arcWeight = arcWeightIn, t = pret, maxTokens = maxTokens, TAein = enabledByInPlaces and activeIn, enablingType = enablingType, enablingPrio = enablingPrioIn, enablingProb = enablingProbIn, enablingBene = enablingBeneIn, benefitType = benefitType, disTransition = disTransitionIn, localSeed = localSeedIn, globalSeed = settings.globalSeed);
  //****BLOCKS END****//
equation
  //****MAIN BEGIN****//
  //recalculation of tokens
  pret = pre(t);
  tokeninout = firingSumIn.firingSum > 0 or firingSumOut.firingSum > 0;
  when tokeninout or pre(reStart) then
    t = if tokeninout then pret + firingSumIn.firingSum - firingSumOut.firingSum else reStartTokens;
  end when;
  //Conversion of tokens to level concentrations
  levelCon = t*settings.M/N;
  //****MAIN END****//
  //****ANIMATION BEGIN****//
  tokenscale = t*settings.scale;
  color = if settings.animatePlace then if tokenscale < 100 then {255, 255 - 2.55*tokenscale, 255 - 2.55*tokenscale} else {255, 0, 0} else {255, 255, 255};
  //****ANIMATION END****//
  //****ERROR MESSENGES BEGIN****//
  assert(PNlib.Functions.OddsAndEnds.prioCheck(enablingPrioIn, nIn) or nIn == 0 or enablingType == PNlib.Types.EnablingType.Probability, "The priorities of the input priorities may be given only once and must be selected from 1 to nIn");
  assert(PNlib.Functions.OddsAndEnds.prioCheck(enablingPrioOut, nOut) or nOut == 0 or enablingType == PNlib.Types.EnablingType.Probability, "The priorities of the output priorities may be given only once and must be selected from 1 to nOut");
  assert(PNlib.Functions.OddsAndEnds.isEqual(sum(enablingProbIn), 1.0, 1e-6) or nIn == 0 or enablingType == PNlib.Types.EnablingType.Priority, "The sum of input enabling probabilities has to be equal to 1");
  assert(PNlib.Functions.OddsAndEnds.isEqual(sum(enablingProbOut), 1.0, 1e-6) or nOut == 0 or enablingType == PNlib.Types.EnablingType.Priority, "The sum of output enabling probabilities has to be equal to 1");
  assert(startTokens >= minTokens and startTokens <= maxTokens, "minTokens<=startTokens<=maxTokens");
  //****ERROR MESSENGES END****//
end PDwkeit;


Top Model.

within PNlib.Examples.Models.PNproBP;

model Model "Top Model"
  extends Modelica.Icons.Example;
  parameter Integer Nr_Consultant = 2 "Number of consultants";
  parameter Integer Nr_Advisor1 = 2 "Number of advisor type 1";
  parameter Integer Nr_Advisor2 = 1 "Number of advisor type 2";
  parameter Integer Nr_Controller = 1 "Number of Controllers";
  parameter Integer Nr_Installer = 2 "Number of installers";
  parameter Integer Nr_Accountant = 2 "Number of accountants";
  parameter Real time_between_requests = 1.5 "Expected time between two requests";
  parameter Real time_consulting = 1 "Time for consulting";
  parameter Real time_preparing = 3 "Time for offer preparing";
  parameter Real time_planning = 1.5 "Time for order planning";
  parameter Real time_controlling = 2 "Time for offer controlling";
  parameter Real time_installation = 4 "Time for installation";
  parameter Real time_accounting = 1 "Time for order accounting";
  PNlib.Components.TDS RaiseRequest(nOut = 1, h = 1/time_between_requests) "a request is raised from a customer"
  PNlib.Components.PD Request(nIn = 1, enablingType = PNlib.Types.EnablingType.Probability, nOut = 1) "Request of a custumer is available"
  PNlib.Components.PD Consultants(enablingType = PNlib.Types.EnablingType.Probability, nOut = 1, nIn = 1, startTokens = Nr_Consultant, maxTokens = Nr_Consultant)
  PNlib.Components.PD Solution(nOut = 1, nIn = 1) "A solution for the customer wish has been found"
  PNlib.Components.PD Complete(nIn = 1, nOut = 1) "Consulting is completed"
  PNlib.Components.PD Offer(nOut = 1, nIn = 1) "The offer is complete"
  PNlib.Components.PD No_Solution(nIn = 1) "No solution for the costumer wish has been found"
  PNlib.Components.PD Advisor1(nOut = 1, enablingType = PNlib.Types.EnablingType.Probability, nIn = 1, startTokens = Nr_Advisor1)
  PNlib.Components.TD Offer_to_Customer(nOut = 1, delay = 8, nIn = 1, arcWeightIn = {pre(Offer.t)}, arcWeightOut = {pre(Offer.t)}) "The offers of a day are sent to the customer"
  PNlib.Components.PD Offer_at_Customer(nIn = 1, nOut = 1) "The offer has arrived the customer"
  PNproBP.XOR Replying(upperProb = 0.8, lowerProb = 0.2) "Does the customer answer to the offer?"
  PNlib.Components.PD Answer(nOut = 1, nIn = 1) "Answer from the customer"
  PNlib.Components.PD Order(nIn = 2, nOut = 1) "The customer gives the order"
  PNlib.Components.PD No_Order(nIn = 2) "no order"
  PNlib.Components.PD Advisor2(enablingType = PNlib.Types.EnablingType.Probability, startTokens = Nr_Advisor2, nOut = 1, nIn = 1)
  PNlib.Components.PD planned_order(nIn = 1, nOut = 1) "The order is planned"
  PNlib.Components.PD material_order(nIn = 1, nOut = 1) "The planning is complete and the material can be ordered"
  PNlib.Components.PD Material_supplied(nIn = 1, nOut = 1) "The required material is supplied"
  PNlib.Components.PD Installation_possible(nIn = 1, nOut = 1) "the installation is possible"
  PNlib.Components.PD Installer(startTokens = Nr_Installer, nOut = 1, nIn = 1)
  PNlib.Components.PD Installation_complete(nIn = 1, nOut = 1) "The installtion is complete"
  PNlib.Components.PD Invoice(nIn = 1, nOut = 1) "the invoice is complete and is sent to the customer"
  PNlib.Components.PD Order_complete(nIn = 1) "the order is completed"
  inner PNlib.Components.Settings settings(scale = 10)
  PNproBP.Parallel Consulting(nIn = 2, nOut = 2, delay = time_consulting, noParallel = Nr_Consultant) "the customer is coundeled"
  PNproBP.XOR Resluting(upperProb = 0.9, lowerProb = 0.1) "Result of the Consulting"
  PNproBP.Parallel Preparation(nIn = 2, nOut = 2, delay = time_preparing, noParallel = Nr_Advisor1) "Preparation of an offer"
  PNproBP.XOR Resulting2(upperProb = 0.5, lowerProb = 0.5) "Result of the answer"
  PNproBP.Parallel Accounting(noParallel = Nr_Accountant, nIn = 2, nOut = 2, delay = time_accounting) "Accounting of the order"
  PNproBP.Parallel Planning(noParallel = Nr_Advisor2, nIn = 2, nOut = 3, delay = time_planning) "The order is planned"
  PNproBP.Parallel Controlling(noParallel = Nr_Controller, nIn = 3, nOut = 2, delay = time_controlling) "Control the order"
  PNproBP.Parallel Installation(arcWeightIn = {1, 2}, nIn = 2, nOut = 2, delay = time_installation, noParallel = 2, arcWeightOut = {2, 1})
  PNproBP.Workload w_Consultants
  PNproBP.Workload w_Advisor
  PNproBP.Workload w_Advisor2
  PNproBP.Workload w_Installer
  PNproBP.TotalNumber t_Auftraege
  PNproBP.TotalNumber t_Order
  PNproBP.TotalNumber t_solution
  PNproBP.TotalNumber t_Offer
  PNlib.Components.PD No_Answer(nOut = 1, nIn = 1) "Nor answer from the customer"
  PNproBP.XOR Calling(upperProb = 0.8, lowerProb = 0.2) "Call the customer to get the answer"
  PNlib.Components.PD WaitingTime_over(nOut = 1, nIn = 1) "The waiting time of the answer is over"
  PNproBP.Waiting Waiting(delay = 40) "Waiting of the answer from the customer"
  PNproBP.Waiting Supply(delay = 40) "Waitin on the required material"
  PNproBP.Waiting Payment(delay = 40) "Wait for payment"
  PNlib.Components.PD Accountant(startTokens = Nr_Accountant, nOut = 1, nIn = 1)
  PNproBP.Workload w_Accountant
  PNlib.Components.PD Controller(enablingType = PNlib.Types.EnablingType.Probability, nOut = 1, nIn = 1, startTokens = Nr_Controller)
  PNproBP.Workload w_Advisor1
equation
  connect(RaiseRequest.outPlaces[1], Request.inTransition[1])
  connect(Offer_to_Customer.outPlaces[1], Offer_at_Customer.inTransition[1])
  connect(Offer.outTransition[1], Offer_to_Customer.inPlaces[1])
  connect(Request.outTransition[1], Consulting.inPlaces1[1])
  connect(Consultants.outTransition[1], Consulting.inPlaces1[2])
  connect(Consulting.outPlaces1[1], Complete.inTransition[1])
  connect(Consulting.outPlaces1[2], Consultants.inTransition[1])
  connect(Complete.outTransition[1], Resluting.inPlaces1)
  connect(Solution.outTransition[1], Preparation.inPlaces1[1])
  connect(Advisor1.outTransition[1], Preparation.inPlaces1[2])
  connect(Preparation.outPlaces1[1], Offer.inTransition[1])
  connect(Answer.outTransition[1], Resulting2.inPlaces1)
  connect(Preparation.outPlaces1[2], Advisor1.inTransition[1])
  connect(Resulting2.outPlaces1, No_Order.inTransition[1])
  connect(Resulting2.outPlaces2, Order.inTransition[1])
  connect(Consultants.pd_t, w_Consultants.u)
  connect(No_Answer.outTransition[1], Calling.inPlaces1)
  connect(Calling.outPlaces1, No_Order.inTransition[2])
  connect(Calling.outPlaces2, Order.inTransition[2])
  connect(WaitingTime_over.outTransition[1], Replying.inPlaces1)
  connect(Replying.outPlaces1, Answer.inTransition[1])
  connect(Replying.outPlaces2, No_Answer.inTransition[1])
  connect(Offer_at_Customer.outTransition[1], Waiting.inPlaces1)
  connect(Waiting.outPlaces1, WaitingTime_over.inTransition[1])
  connect(Resluting.outPlaces1, Solution.inTransition[1])
  connect(Resluting.outPlaces2, No_Solution.inTransition[1])
  connect(Advisor2.pd_t, w_Advisor2.u)
  connect(w_Installer.u, Installer.pd_t)
  connect(t_Auftraege.u, Request.pd_t)
  connect(t_solution.u, Solution.pd_t)
  connect(w_Advisor.u, Advisor1.pd_t)
  connect(t_Offer.u, Offer.pd_t)
  connect(Accountant.pd_t, w_Accountant.u)
  connect(Order.outTransition[1], Planning.inPlaces1[1])
  connect(Advisor2.outTransition[1], Planning.inPlaces1[2])
  connect(Planning.outPlaces1[1], Advisor2.inTransition[1])
  connect(Planning.outPlaces1[2], material_order.inTransition[1])
  connect(material_order.outTransition[1], Supply.inPlaces1)
  connect(Supply.outPlaces1, Material_supplied.inTransition[1])
  connect(Planning.outPlaces1[3], planned_order.inTransition[1])
  connect(Material_supplied.outTransition[1], Controlling.inPlaces1[1])
  connect(Controlling.outPlaces1[1], Installation_possible.inTransition[1])
  connect(planned_order.outTransition[1], Controlling.inPlaces1[2])
  connect(Installation_possible.outTransition[1], Installation.inPlaces1[1])
  connect(Installer.outTransition[1], Installation.inPlaces1[2])
  connect(Installation.outPlaces1[1], Installer.inTransition[1])
  connect(Installation.outPlaces1[2], Installation_complete.inTransition[1])
  connect(Installation_complete.outTransition[1], Accounting.inPlaces1[1])
  connect(Accountant.outTransition[1], Accounting.inPlaces1[2])
  connect(Accounting.outPlaces1[1], Accountant.inTransition[1])
  connect(Accounting.outPlaces1[2], Invoice.inTransition[1])
  connect(Invoice.outTransition[1], Payment.inPlaces1)
  connect(Payment.outPlaces1, Order_complete.inTransition[1])
  connect(Controller.pd_t, w_Advisor1.u)
  connect(Controller.outTransition[1], Controlling.inPlaces1[3])
  connect(Controlling.outPlaces1[2], Controller.inTransition[1])
  connect(Order.pd_t, t_Order.u)
end Model;


within PNlib.Examples.Models;

package PNproBP "Petri Nets for Modeling Business Processes"
  extends Modelica.Icons.ExamplesPackage;
end PNproBP;


arc weights of input place.

within PNlib.Examples.Models.PNproBP;

model Parallel
  parameter Real delay = 1;
  parameter Real noParallel = 2;
  Real arcWeightIn[nIn] = fill(1, nIn) "arc weights of input place"
  Real arcWeightOut[nOut] = fill(1, nOut) "arc weights of output place"
  parameter Integer nIn = 0 "number of input places"
  parameter Integer nOut = 0 "number of output places"
  Boolean fire "firability of continuous transition";
  Integer fireColor[3] "for animation";
  PNlib.Components.TD T1(delay = delay, nIn = 1, nOut = 1)
  PNlib.Components.TD puffern(nOut = 1, nIn = nIn, arcWeightIn = arcWeightIn, delay = 0.001)
  PNlib.Components.PD Puffer(nIn = 1, nOut = 6)
  PNlib.Components.TD T2(delay = delay, nIn = 1, nOut = 1, firingCon = noParallel > 1)
  PNlib.Components.TD T3(delay = delay, nIn = 1, nOut = 1, firingCon = noParallel > 2)
  PNlib.Components.TD T4(delay = delay, nIn = 1, nOut = 1, firingCon = noParallel > 3)
  PNlib.Components.TD T5(delay = delay, nIn = 1, nOut = 1, firingCon = noParallel > 4)
  PNlib.Components.TD T6(delay = delay, nIn = 1, nOut = 1, firingCon = noParallel > 5)
  Interfaces.TransitionIn inPlaces1[nIn]
  PNlib.Components.PD P1(nIn = 6, nOut = 1)
  PNlib.Components.TD T7(nOut = nOut, nIn = 1, arcWeightOut = arcWeightOut, delay = 0.0001)
  Interfaces.TransitionOut outPlaces1[nOut]
  Boolean ani "for transition animation";
protected
  outer PNlib.Components.Settings settings "global settings for animation and display";
  discrete Real fireTime;
equation
  fire = T1.fire or T2.fire or T3.fire or T4.fire or T5.fire or T6.fire;
  when fire then
    fireTime = time;
    ani = true;
  end when;
  fireColor = if (fireTime + settings.timeFire >= time and settings.animateTransition and ani) then {255, 255, 0} else {128, 255, 0};
  connect(puffern.outPlaces[1], Puffer.inTransition[1])
  connect(Puffer.outTransition[1], T1.inPlaces[1])
  connect(Puffer.outTransition[2], T2.inPlaces[1])
  connect(Puffer.outTransition[3], T3.inPlaces[1])
  connect(Puffer.outTransition[4], T4.inPlaces[1])
  connect(Puffer.outTransition[5], T5.inPlaces[1])
  connect(Puffer.outTransition[6], T6.inPlaces[1])
  for i in 1:nIn loop
    connect(puffern.inPlaces[i], inPlaces1[i])
  end for;
  connect(T1.outPlaces[1], P1.inTransition[1])
  connect(T2.outPlaces[1], P1.inTransition[2])
  connect(T3.outPlaces[1], P1.inTransition[3])
  connect(T4.outPlaces[1], P1.inTransition[4])
  connect(T5.outPlaces[1], P1.inTransition[5])
  connect(T6.outPlaces[1], P1.inTransition[6])
  for i in 1:nOut loop
    connect(T7.outPlaces[i], outPlaces1[i])
  end for;
  connect(P1.outTransition[1], T7.inPlaces[1])
end Parallel;


number of input places.

within PNlib.Examples.Models.PNproBP;

model Puffer
  parameter Real delay = 1;
  parameter Integer nIn = 0 "number of input places"
  parameter Integer nOut = 0 "number of output places"
  Real arcWeightIn[nIn] = fill(1, nIn) "arc weights of input place"
  Real arcWeightOut[nOut] = fill(1, nOut) "arc weights of output place"
  PNlib.Components.TD T1(nIn = 1, nOut = nOut, delay = delay, arcWeightOut = arcWeightOut)
  PNlib.Components.PD P1(nIn = 1, nOut = 1)
  PNlib.Components.TD T3(nOut = 1, nIn = nIn, arcWeightIn = arcWeightIn, delay = 0.0001)
  Interfaces.TransitionIn inPlaces1[nIn]
  Interfaces.TransitionOut outPlaces1[nOut]
  Boolean fire "firability of continuous transition";
  Integer fireColor[3] "for animation";
  Boolean ani "for transition animation";
protected
  outer PNlib.Components.Settings settings "global settings for animation and display";
  discrete Real fireTime;
equation
  fire = T1.fire;
  when fire then
    fireTime = time;
    ani = true;
  end when;
  fireColor = if (fireTime + settings.timeFire >= time and settings.animateTransition and ani) then {255, 255, 0} else {255, 128, 8};
  connect(T3.outPlaces[1], P1.inTransition[1])
  for i in 1:nIn loop
    connect(T3.inPlaces[i], inPlaces1[i])
  end for;
  connect(P1.outTransition[1], T1.inPlaces[1])
  for i in 1:nOut loop
    connect(T1.outPlaces[i], outPlaces1[i])
  end for;
end Puffer;


within PNlib.Examples.Models.PNproBP;

model TotalNumber
  Integer total;
  Modelica.Blocks.Interfaces.IntegerInput u
algorithm
  when u > pre(u) then
    total := total + (u - pre(u));
  end when;
end TotalNumber;


firability of continuous transition.

within PNlib.Examples.Models.PNproBP;

model Waiting
  parameter Real delay = 1;
  Integer arcWeight = 1;
  Boolean fire "firability of continuous transition";
  Integer fireColor[3] "for animation";
  PNlib.Components.TD T1(nIn = 1, nOut = 1, delay = 0.001, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P1.t) == 0)
  PNlib.Components.PD Puffer(nOut = 24, nIn = 1)
  PNlib.Components.TD T2(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P2.t) == 0)
  PNlib.Components.TD T3(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P3.t) == 0)
  PNlib.Components.TD T4(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P4.t) == 0)
  PNlib.Components.TD T5(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P5.t) == 0)
  PNlib.Components.TD T6(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P6.t) == 0)
  PNlib.Components.PD P1(nOut = 1, nIn = 1)
  PNlib.Components.TD T7(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P1.t)}, arcWeightOut = {pre(P1.t)}, firingCon = pre(P1.t) > 0)
  Boolean ani "for transition animation";
  PNlib.Components.PD P2(nOut = 1, nIn = 1)
  PNlib.Components.PD P3(nOut = 1, nIn = 1)
  PNlib.Components.PD P4(nOut = 1, nIn = 1)
  PNlib.Components.PD P5(nOut = 1, nIn = 1)
  PNlib.Components.PD P6(nOut = 1, nIn = 1)
  PNlib.Components.TD T8(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P2.t)}, arcWeightOut = {pre(P2.t)}, firingCon = pre(P2.t) > 0)
  PNlib.Components.TD T9(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P3.t)}, arcWeightOut = {pre(P3.t)}, firingCon = pre(P3.t) > 0)
  PNlib.Components.TD T10(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P4.t)}, arcWeightOut = {pre(P4.t)}, firingCon = pre(P4.t) > 0)
  PNlib.Components.TD T11(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P5.t)}, arcWeightOut = {pre(P5.t)}, firingCon = pre(P5.t) > 0)
  PNlib.Components.TD T12(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P6.t)}, arcWeightOut = {pre(P6.t)}, firingCon = pre(P6.t) > 0)
  PNlib.Components.PD P7(nIn = 24, nOut = 1)
  PNlib.Components.TD T13(nOut = 1, nIn = 1, arcWeightIn = {arcWeight}, arcWeightOut = {arcWeight}, delay = 0.001, firingCon = pre(arcWeight) > 0)
  Interfaces.TransitionIn inPlaces1
  PNlib.Components.TD T14(nIn = 1, delay = 0.001, arcWeightIn = {pre(P7.t)}, nOut = 1, arcWeightOut = {pre(P7.t)}, firingCon = pre(P7.t) > 0)
  Interfaces.TransitionOut outPlaces1
  PNlib.Components.TD T15(nIn = 1, nOut = 1, delay = 0.001, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P8.t) == 0)
  PNlib.Components.PD P8(nOut = 1, nIn = 1)
  PNlib.Components.TD T16(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P8.t)}, arcWeightOut = {pre(P8.t)}, firingCon = pre(P8.t) > 0)
  PNlib.Components.TD T17(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P9.t) == 0)
  PNlib.Components.PD P9(nOut = 1, nIn = 1)
  PNlib.Components.TD T18(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P9.t)}, arcWeightOut = {pre(P9.t)}, firingCon = pre(P9.t) > 0)
  PNlib.Components.TD T19(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P10.t) == 0)
  PNlib.Components.TD T20(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P11.t) == 0)
  PNlib.Components.TD T21(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P12.t) == 0)
  PNlib.Components.TD T22(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P13.t) == 0)
  PNlib.Components.PD P10(nOut = 1, nIn = 1)
  PNlib.Components.PD P11(nOut = 1, nIn = 1)
  PNlib.Components.PD P12(nOut = 1, nIn = 1)
  PNlib.Components.PD P13(nOut = 1, nIn = 1)
  PNlib.Components.TD T23(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P10.t)}, arcWeightOut = {pre(P10.t)}, firingCon = pre(P10.t) > 0)
  PNlib.Components.TD T24(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P11.t)}, arcWeightOut = {pre(P11.t)}, firingCon = pre(P11.t) > 0)
  PNlib.Components.TD T25(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P12.t)}, arcWeightOut = {pre(P12.t)}, firingCon = pre(P12.t) > 0)
  PNlib.Components.TD T26(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P13.t)}, arcWeightOut = {pre(P13.t)}, firingCon = pre(P13.t) > 0)
  PNlib.Components.TD T27(nIn = 1, nOut = 1, delay = 0.001, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P14.t) == 0)
  PNlib.Components.TD T28(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P15.t) == 0)
  PNlib.Components.TD T29(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P16.t) == 0)
  PNlib.Components.TD T30(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P17.t) == 0)
  PNlib.Components.TD T31(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P18.t) == 0)
  PNlib.Components.TD T32(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P19.t) == 0)
  PNlib.Components.PD P14(nOut = 1, nIn = 1)
  PNlib.Components.TD T33(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P14.t)}, arcWeightOut = {pre(P14.t)}, firingCon = pre(P14.t) > 0)
  PNlib.Components.PD P15(nOut = 1, nIn = 1)
  PNlib.Components.PD P16(nOut = 1, nIn = 1)
  PNlib.Components.PD P17(nOut = 1, nIn = 1)
  PNlib.Components.PD P18(nOut = 1, nIn = 1)
  PNlib.Components.PD P19(nOut = 1, nIn = 1)
  PNlib.Components.TD T34(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P15.t)}, arcWeightOut = {pre(P15.t)}, firingCon = pre(P15.t) > 0)
  PNlib.Components.TD T35(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P16.t)}, arcWeightOut = {pre(P16.t)}, firingCon = pre(P16.t) > 0)
  PNlib.Components.TD T36(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P17.t)}, arcWeightOut = {pre(P17.t)}, firingCon = pre(P17.t) > 0)
  PNlib.Components.TD T37(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P18.t)}, arcWeightOut = {pre(P18.t)}, firingCon = pre(P18.t) > 0)
  PNlib.Components.TD T38(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P19.t)}, arcWeightOut = {pre(P19.t)}, firingCon = pre(P19.t) > 0)
  PNlib.Components.TD T39(nIn = 1, nOut = 1, delay = 0.001, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P20.t) == 0)
  PNlib.Components.PD P20(nOut = 1, nIn = 1)
  PNlib.Components.TD T40(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P20.t)}, arcWeightOut = {pre(P20.t)}, firingCon = pre(P20.t) > 0)
  PNlib.Components.TD T41(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P21.t) == 0)
  PNlib.Components.PD P21(nOut = 1, nIn = 1)
  PNlib.Components.TD T42(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P21.t)}, arcWeightOut = {pre(P21.t)}, firingCon = pre(P21.t) > 0)
  PNlib.Components.PD P22(nOut = 1, nIn = 1)
  PNlib.Components.PD P23(nOut = 1, nIn = 1)
  PNlib.Components.PD P24(nOut = 1, nIn = 1)
  PNlib.Components.PD P25(nOut = 1, nIn = 1)
  PNlib.Components.TD T43(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P22.t)}, arcWeightOut = {pre(P22.t)}, firingCon = pre(P22.t) > 0)
  PNlib.Components.TD T44(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P23.t)}, arcWeightOut = {pre(P23.t)}, firingCon = pre(P23.t) > 0)
  PNlib.Components.TD T45(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P24.t)}, arcWeightOut = {pre(P24.t)}, firingCon = pre(P24.t) > 0)
  PNlib.Components.TD T46(nOut = 1, nIn = 1, delay = delay, arcWeightIn = {pre(P25.t)}, arcWeightOut = {pre(P25.t)}, firingCon = pre(P25.t) > 0)
  PNlib.Components.TD T47(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P22.t) == 0)
  PNlib.Components.TD T48(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P23.t) == 0)
  PNlib.Components.TD T49(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P24.t) == 0)
  PNlib.Components.TD T50(nIn = 1, delay = 0.001, nOut = 1, arcWeightIn = {pre(Puffer.t)}, arcWeightOut = {pre(Puffer.t)}, firingCon = pre(Puffer.t) > 0 and pre(P25.t) == 0)
protected
  outer PNlib.Components.Settings settings "global settings for animation and display";
  discrete Real fireTime;
equation
  fire = T1.fire or T2.fire or T3.fire or T4.fire or T5.fire or T6.fire;
  when fire then
    fireTime = time;
    ani = true;
  end when;
  fireColor = if (fireTime + settings.timeFire >= time and settings.animateTransition and ani) then {255, 255, 0} else {128, 255, 0};
  connect(Puffer.outTransition[1], T1.inPlaces[1])
  connect(Puffer.outTransition[2], T2.inPlaces[1])
  connect(Puffer.outTransition[3], T3.inPlaces[1])
  connect(Puffer.outTransition[4], T4.inPlaces[1])
  connect(Puffer.outTransition[5], T5.inPlaces[1])
  connect(Puffer.outTransition[6], T6.inPlaces[1])
  connect(P1.outTransition[1], T7.inPlaces[1])
  connect(T1.outPlaces[1], P1.inTransition[1])
  connect(T2.outPlaces[1], P2.inTransition[1])
  connect(T3.outPlaces[1], P3.inTransition[1])
  connect(T4.outPlaces[1], P4.inTransition[1])
  connect(T5.outPlaces[1], P5.inTransition[1])
  connect(T6.outPlaces[1], P6.inTransition[1])
  connect(P2.outTransition[1], T8.inPlaces[1])
  connect(P3.outTransition[1], T9.inPlaces[1])
  connect(P4.outTransition[1], T10.inPlaces[1])
  connect(P5.outTransition[1], T11.inPlaces[1])
  connect(P6.outTransition[1], T12.inPlaces[1])
  connect(T7.outPlaces[1], P7.inTransition[1])
  connect(T8.outPlaces[1], P7.inTransition[2])
  connect(T9.outPlaces[1], P7.inTransition[3])
  connect(T10.outPlaces[1], P7.inTransition[4])
  connect(T11.outPlaces[1], P7.inTransition[5])
  connect(T12.outPlaces[1], P7.inTransition[6])
  connect(T13.outPlaces[1], Puffer.inTransition[1])
  connect(T13.inPlaces[1], inPlaces1)
  connect(P7.outTransition[1], T14.inPlaces[1])
  connect(T14.outPlaces[1], outPlaces1)
  connect(T15.outPlaces[1], P8.inTransition[1])
  connect(P8.outTransition[1], T16.inPlaces[1])
  connect(T17.outPlaces[1], P9.inTransition[1])
  connect(P9.outTransition[1], T18.inPlaces[1])
  connect(T19.outPlaces[1], P10.inTransition[1])
  connect(T20.outPlaces[1], P11.inTransition[1])
  connect(T21.outPlaces[1], P12.inTransition[1])
  connect(T22.outPlaces[1], P13.inTransition[1])
  connect(P13.outTransition[1], T26.inPlaces[1])
  connect(P12.outTransition[1], T25.inPlaces[1])
  connect(P11.outTransition[1], T24.inPlaces[1])
  connect(P10.outTransition[1], T23.inPlaces[1])
  connect(Puffer.outTransition[7], T15.inPlaces[1])
  connect(Puffer.outTransition[8], T17.inPlaces[1])
  connect(Puffer.outTransition[9], T19.inPlaces[1])
  connect(Puffer.outTransition[10], T20.inPlaces[1])
  connect(Puffer.outTransition[11], T21.inPlaces[1])
  connect(Puffer.outTransition[12], T22.inPlaces[1])
  connect(T16.outPlaces[1], P7.inTransition[7])
  connect(T18.outPlaces[1], P7.inTransition[8])
  connect(T23.outPlaces[1], P7.inTransition[9])
  connect(T24.outPlaces[1], P7.inTransition[10])
  connect(T25.outPlaces[1], P7.inTransition[11])
  connect(T26.outPlaces[1], P7.inTransition[12])
  connect(P14.outTransition[1], T33.inPlaces[1])
  connect(T27.outPlaces[1], P14.inTransition[1])
  connect(T28.outPlaces[1], P15.inTransition[1])
  connect(T29.outPlaces[1], P16.inTransition[1])
  connect(T30.outPlaces[1], P17.inTransition[1])
  connect(T31.outPlaces[1], P18.inTransition[1])
  connect(T32.outPlaces[1], P19.inTransition[1])
  connect(P15.outTransition[1], T34.inPlaces[1])
  connect(P16.outTransition[1], T35.inPlaces[1])
  connect(P17.outTransition[1], T36.inPlaces[1])
  connect(P18.outTransition[1], T37.inPlaces[1])
  connect(P19.outTransition[1], T38.inPlaces[1])
  connect(T39.outPlaces[1], P20.inTransition[1])
  connect(P20.outTransition[1], T40.inPlaces[1])
  connect(T41.outPlaces[1], P21.inTransition[1])
  connect(P21.outTransition[1], T42.inPlaces[1])
  connect(T47.outPlaces[1], P22.inTransition[1])
  connect(T48.outPlaces[1], P23.inTransition[1])
  connect(T49.outPlaces[1], P24.inTransition[1])
  connect(T50.outPlaces[1], P25.inTransition[1])
  connect(P25.outTransition[1], T46.inPlaces[1])
  connect(P24.outTransition[1], T45.inPlaces[1])
  connect(P23.outTransition[1], T44.inPlaces[1])
  connect(P22.outTransition[1], T43.inPlaces[1])
  connect(Puffer.outTransition[13], T27.inPlaces[1])
  connect(Puffer.outTransition[14], T28.inPlaces[1])
  connect(Puffer.outTransition[15], T29.inPlaces[1])
  connect(Puffer.outTransition[16], T30.inPlaces[1])
  connect(Puffer.outTransition[17], T31.inPlaces[1])
  connect(Puffer.outTransition[18], T32.inPlaces[1])
  connect(Puffer.outTransition[19], T39.inPlaces[1])
  connect(Puffer.outTransition[20], T41.inPlaces[1])
  connect(Puffer.outTransition[21], T47.inPlaces[1])
  connect(Puffer.outTransition[22], T48.inPlaces[1])
  connect(Puffer.outTransition[23], T49.inPlaces[1])
  connect(Puffer.outTransition[24], T50.inPlaces[1])
  connect(T33.outPlaces[1], P7.inTransition[13])
  connect(T34.outPlaces[1], P7.inTransition[14])
  connect(T35.outPlaces[1], P7.inTransition[15])
  connect(T36.outPlaces[1], P7.inTransition[16])
  connect(T37.outPlaces[1], P7.inTransition[17])
  connect(T38.outPlaces[1], P7.inTransition[18])
  connect(T40.outPlaces[1], P7.inTransition[19])
  connect(T42.outPlaces[1], P7.inTransition[20])
  connect(T43.outPlaces[1], P7.inTransition[21])
  connect(T44.outPlaces[1], P7.inTransition[22])
  connect(T45.outPlaces[1], P7.inTransition[23])
  connect(T46.outPlaces[1], P7.inTransition[24])
end Waiting;


within PNlib.Examples.Models.PNproBP;

model Workload
  Real cap;
  Modelica.Blocks.Interfaces.IntegerInput u
  Integer[3] color;
protected
  Real help1;
algorithm
  when u == 0 then
    help1 := time;
    color := {255, 0, 0};
  elsewhen u > 0 then
    cap := cap + time - help1;
    color := {128, 255, 0};
  end when;
end Workload;


arc weights of output place.

within PNlib.Examples.Models.PNproBP;

model XOR
  parameter Real upperProb = 0.5;
  parameter Real lowerProb = 0.5;
  Real arcWeightOut1 = 1 "arc weights of output place"
  Real arcWeightOut2 = 1 "arc weights of output place"
  PNlib.Components.TD T1(nIn = 1, nOut = 1, arcWeightOut = {arcWeightOut1}, delay = 0.0001)
  PNlib.Components.TD T2(nIn = 1, nOut = 1, arcWeightOut = {arcWeightOut2}, delay = 0.0001)
  PNlib.Components.PD P1(nIn = 1, nOut = 2, enablingType = PNlib.Types.EnablingType.Probability, enablingProbOut = {upperProb, lowerProb}, maxTokens = 1)
  PNlib.Components.TD T3(nOut = 1, nIn = 1, delay = 0.0001)
  Interfaces.TransitionIn inPlaces1
  Interfaces.TransitionOut outPlaces1
  Interfaces.TransitionOut outPlaces2
  Boolean fire "firability of continuous transition";
  Integer fireColor[3] "for animation";
  Boolean ani "for transition animation";
protected
  outer PNlib.Components.Settings settings "global settings for animation and display";
  discrete Real fireTime;
equation
  fire = T1.fire or T2.fire;
  when fire then
    fireTime = time;
    ani = true;
  end when;
  fireColor = if (fireTime + settings.timeFire >= time and settings.animateTransition and ani) then {255, 255, 0} else {85, 170, 255};
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(T3.inPlaces[1], inPlaces1)
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(P1.outTransition[2], T2.inPlaces[1])
  connect(T1.outPlaces[1], outPlaces1)
  connect(T2.outPlaces[1], outPlaces2)
end XOR;


counter for paper, examples, maculations, ....

within PNlib.Examples.Models.Printing;

model Counter "counter for paper, examples, maculations, ..."
  parameter String text = "counter";
  parameter Real color[3] = {255, 0, 0};
  Modelica.Blocks.Interfaces.RealInput levelSensor
  Real count;
  parameter Integer hmax = 1000000;
  Real levelSensor_ = if levelSensor > 0 then levelSensor else 0;
equation
  count = levelSensor_/hmax;
end Counter;


maculation of the printing process.

within PNlib.Examples.Models.Printing;

model Maculation "maculation of the printing process"
  parameter Real time_between_macus = 18000 "expected time between two maculations";
  parameter Real time_channel_out = 1000 "Time from pressing the button to the first channel out";
  parameter Real time_macu = 600 "expected time of the maculation (button press)";
  parameter Real time_macu_roleChange = 300 "expected time of the maculation (role chnage)";
  Real NumberMacu = Bundle_in_macu_press.t;
  Boolean macu = bundle_channelOut.t > 0;
  Real color[3] = if macu then {255, 0, 0} else {0, 255, 0};
  // Real h=if pre(bundle_channelOut.t) > 1 then 1/time_macu else 1/time_macu_roleChange;
  parameter Real h = 1/time_macu_roleChange;
  PNlib.Components.TD channelOut1(nIn = 2, arcWeightOut = {1}, nOut = 1, delay = time_channel_out)
  PNlib.Components.TD channelOut(nIn = 2, arcWeightOut = {2}, nOut = 1, delay = 1)
  PNlib.Components.PD start_channelOut(nIn = 1, nOut = 1, maxTokens = 1)
  PNlib.Components.TDS pressing_button(nOut = 1, firingCon = start, nIn = 1, h = 1/time_between_macus)
  PNlib.Components.PD bundle_channelOut(nOut = 4, nIn = 2, maxTokens = 2)
  PNlib.Components.TDS Stop_macu(nIn = 1, nOut = 1, h = h, arcWeightIn = {pre(bundle_channelOut.t)})
  PNlib.Components.PD bundle_not_channelOut(startTokens = 1, maxTokens = 1, nOut = 3, nIn = 2)
  PNlib.Components.TA TA4(testValue = 0)
  PNlib.Components.TA TA3(testValue = 0)
  PNlib.Components.TC Macu_press(nIn = 2, nOut = 1, maximumSpeed = speed, arcWeightIn = {0, 1})
  PNlib.Components.PC Bundle_in_macu_press(nIn = 1, reStart = reStart)
  Interfaces.TransitionIn ausschleussen_[2]
  Interfaces.PlaceOut makulatur_
  Interfaces.TransitionIn buendelinMakuPresse_
  Modelica.Blocks.Interfaces.RealOutput macuBundle_
  PNlib.Components.TD T1(nIn = 2, nOut = 2, arcWeightIn = {pre(bundle_channelOut.t), 1})
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PD P1(nIn = 2, nOut = 1)
  PNlib.Components.IA IA1(testValue = 1)
protected
  outer Boolean start;
  outer Boolean reStart;
  outer Real speed;
equation
  connect(pressing_button.outPlaces[1], start_channelOut.inTransition[1])
  connect(start_channelOut.outTransition[1], channelOut.inPlaces[1])
  connect(bundle_channelOut.outTransition[1], Stop_macu.inPlaces[1])
  connect(Stop_macu.outPlaces[1], bundle_not_channelOut.inTransition[1])
  connect(bundle_not_channelOut.outTransition[1], channelOut1.inPlaces[1])
  connect(bundle_not_channelOut.outTransition[2], channelOut.inPlaces[2])
  connect(bundle_not_channelOut.outTransition[3], TA4.inPlace)
  connect(TA4.outTransition, makulatur_)
  connect(bundle_channelOut.outTransition[2], TA3.inPlace)
  connect(TA3.outTransition, Macu_press.inPlaces[1])
  connect(Macu_press.outPlaces[1], Bundle_in_macu_press.inTransition[1])
  connect(Macu_press.inPlaces[2], buendelinMakuPresse_)
  connect(Bundle_in_macu_press.pc_t, macuBundle_)
  connect(channelOut1.outPlaces[1], bundle_channelOut.inTransition[1])
  connect(channelOut.outPlaces[1], bundle_channelOut.inTransition[2])
  connect(bundle_channelOut.outTransition[3], T1.inPlaces[1])
  connect(T1.outPlaces[1], bundle_not_channelOut.inTransition[2])
  connect(ausschleussen_[1], T1.inPlaces[2])
  connect(ausschleussen_[2], T2.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], channelOut1.inPlaces[2])
  connect(T1.outPlaces[2], P1.inTransition[2])
  connect(bundle_channelOut.outTransition[4], IA1.inPlace)
  connect(IA1.outTransition, pressing_button.inPlaces[1])
end Maculation;


Top model.

within PNlib.Examples.Models.Printing;

model Model "Top model"
  extends Modelica.Icons.Example;
  inner Real speed = start_Stop.speed;
  inner Boolean reStart = start_Stop.reStart;
  inner Boolean start = start_Stop.Start.t > 0;
  Real orders__;
  Real exemplars__;
  Real maculation__;
  Real paper__;
  Real duration__;
  PNlib.Examples.Models.Printing.PrintingMachine printing_machine
  PNlib.Examples.Models.Printing.Start_Stop start_Stop(number_exemplars = 30000)
  PNlib.Examples.Models.Printing.Maculation maculation(time_between_macus = 9000, time_macu = 1200)
  PNlib.Examples.Models.Printing.Counter maculation_(hmax = 40000, text = "maculation")
  PNlib.Examples.Models.Printing.Counter exemplars_(color = {0, 255, 0}, text = "exemplars", hmax = start_Stop.number_exemplars)
  PNlib.Examples.Models.Printing.Role_change role_change(display_time = 200)
  PNlib.Examples.Models.Printing.Counter orders_(color = {0, 255, 0}, hmax = 25, text = "orders")
  PNlib.Examples.Models.Printing.Counter role_(hmax = 20000, color = {85, 170, 255}, text = "meters on role")
  PNlib.Examples.Models.Printing.Counter paper_(hmax = 60000, color = {85, 170, 255}, text = " paper")
  PNlib.Examples.Models.Printing.Counter duration_(color = {0, 255, 0}, hmax = 15000, text = "duration")
  inner PNlib.Components.Settings settings
equation
  when reStart then
    orders__ = orders_.levelSensor_;
    exemplars__ = exemplars_.levelSensor_;
    maculation__ = maculation_.levelSensor_;
    paper__ = paper_.levelSensor_;
    duration__ = duration_.levelSensor_;
  end when;
  connect(maculation.macuBundle_, maculation_.levelSensor)
  connect(printing_machine.number_exemplars_, exemplars_.levelSensor)
  connect(role_change.rolle_, printing_machine.drucken_)
  connect(role_change.rollenwechsel_, maculation.ausschleussen_)
  connect(maculation.makulatur_, printing_machine.maku_)
  connect(printing_machine.ausschleussen, maculation.buendelinMakuPresse_)
  connect(orders_.levelSensor, start_Stop.orders_)
  connect(role_change.meter_role_, role_.levelSensor)
  connect(start_Stop.rollen_wechsel_, role_change.start_)
  connect(printing_machine.papier_total_, paper_.levelSensor)
  connect(start_Stop.time_counter_, duration_.levelSensor)
  connect(printing_machine.exemplare_, start_Stop.exemplare_)
end Model;


Model of a printing production process

within PNlib.Examples.Models;

package Printing "Model of a printing production process"
  extends Modelica.Icons.ExamplesPackage;
end Printing;


printing machine.

within PNlib.Examples.Models.Printing;

model PrintingMachine "printing machine"
  PNlib.Components.TC printing(nOut = 2, maximumSpeed = speed, nIn = 1)
  PNlib.Components.PC printed_paper(nIn = 1, nOut = 1, reStart = reStart) "[m]"
  PNlib.Components.TC cutting(nIn = 1, nOut = 1, maximumSpeed = speed, arcWeightIn = {1.2})
  PNlib.Components.PC Sections(nIn = 1, nOut = 1, reStart = reStart) "m"
  PNlib.Components.TC fold(nIn = 1, nOut = 1, arcWeightOut = {2}, maximumSpeed = speed)
  PNlib.Components.PC FoldedSections(nIn = 1, nOut = 1, reStart = reStart)
  PNlib.Components.TC bundle(nIn = 1, nOut = 1, arcWeightIn = {2}, maximumSpeed = speed)
  PNlib.Components.PC Bundle(nIn = 1, nOut = 1, reStart = reStart)
  PNlib.Components.TC chainUp(nIn = 1, nOut = 2, maximumSpeed = speed)
  PNlib.Components.PC Bundle_on_chain(nIn = 1, nOut = 1, reStart = reStart)
  PNlib.Components.TC Chain_to_macu_press(nIn = 2, nOut = 1, arcWeightIn = {1, 999}, maximumSpeed = speed)
  PNlib.Components.PC bundle_at_macu_press(nIn = 1, nOut = 2, reStart = reStart)
  PNlib.Components.PC Chain_full(nOut = 1, nIn = 1, reStart = reStart)
  PNlib.Components.TA TA1(testValue = 999)
  PNlib.Components.TC chain_up2(nOut = 2, maximumSpeed = speed, arcWeightIn = {1, 0}, nIn = 2)
  PNlib.Components.PC Bundle_on_chain2(nIn = 1, nOut = 1, reStart = reStart)
  PNlib.Components.TC chain1(nIn = 2, nOut = 2, arcWeightIn = {1, 999}, maximumSpeed = speed)
  PNlib.Components.PC Chain_full2(nIn = 1, nOut = 1, reStart = reStart)
  PNlib.Components.TA TA2(testValue = 999)
  PNlib.Components.PC Counter_exemplars(nIn = 1, nOut = 1, reStart = reStart)
  PNlib.Components.PC Exemplars(nIn = 1, nOut = 1, reStart = reStart)
  PNlib.Components.TC Exemplars_Packets(nIn = 1, nOut = 1, arcWeightIn = {240}, maximumSpeed = 1)
  PNlib.Components.PC Packets(nIn = 1, nOut = 1, reStart = reStart)
  PNlib.Components.TC Packets_Pallet(nIn = 1, nOut = 1, arcWeightIn = {100})
  PNlib.Components.PC Pallets(nIn = 1, reStart = reStart)
  Interfaces.TransitionIn drucken_
  Interfaces.TransitionIn maku_
  Interfaces.PlaceOut ausschleussen
  Modelica.Blocks.Interfaces.RealOutput number_exemplars_
  Interfaces.PlaceOut exemplare_
  PNlib.Components.PC Counter_paper(nIn = 1, reStart = reStart)
  Modelica.Blocks.Interfaces.RealOutput papier_total_
protected
  outer Real speed;
  outer Boolean reStart;
equation
  connect(printing.outPlaces[1], printed_paper.inTransition[1])
  connect(printed_paper.outTransition[1], cutting.inPlaces[1])
  connect(cutting.outPlaces[1], Sections.inTransition[1])
  connect(Sections.outTransition[1], fold.inPlaces[1])
  connect(fold.outPlaces[1], FoldedSections.inTransition[1])
  connect(FoldedSections.outTransition[1], bundle.inPlaces[1])
  connect(bundle.outPlaces[1], Bundle.inTransition[1])
  connect(Bundle.outTransition[1], chainUp.inPlaces[1])
  connect(chainUp.outPlaces[1], Bundle_on_chain.inTransition[1])
  connect(Bundle_on_chain.outTransition[1], Chain_to_macu_press.inPlaces[1])
  connect(Chain_to_macu_press.outPlaces[1], bundle_at_macu_press.inTransition[1])
  connect(TA1.outTransition, Chain_to_macu_press.inPlaces[2])
  connect(TA1.inPlace, Chain_full.outTransition[1])
  connect(Chain_full.inTransition[1], chainUp.outPlaces[2])
  connect(chain_up2.outPlaces[1], Bundle_on_chain2.inTransition[1])
  connect(Bundle_on_chain2.outTransition[1], chain1.inPlaces[1])
  connect(Chain_full2.inTransition[1], chain_up2.outPlaces[2])
  connect(Chain_full2.outTransition[1], TA2.inPlace)
  connect(TA2.outTransition, chain1.inPlaces[2])
  connect(chain1.outPlaces[2], Counter_exemplars.inTransition[1])
  connect(Exemplars.outTransition[1], Exemplars_Packets.inPlaces[1])
  connect(Exemplars_Packets.outPlaces[1], Packets.inTransition[1])
  connect(Packets.outTransition[1], Packets_Pallet.inPlaces[1])
  connect(Packets_Pallet.outPlaces[1], Pallets.inTransition[1])
  connect(chain1.outPlaces[1], Exemplars.inTransition[1])
  connect(printing.inPlaces[1], drucken_)
  connect(bundle_at_macu_press.outTransition[1], chain_up2.inPlaces[1])
  connect(chain_up2.inPlaces[2], maku_)
  connect(bundle_at_macu_press.outTransition[2], ausschleussen)
  connect(Counter_exemplars.pc_t, number_exemplars_)
  connect(Counter_exemplars.outTransition[1], exemplare_)
  connect(printing.outPlaces[2], Counter_paper.inTransition[1])
  connect(Counter_paper.pc_t, papier_total_)
end PrintingMachine;


change of the paper role.

within PNlib.Examples.Models.Printing;

model Role_change "change of the paper role"
  import PNlib;
  parameter Real Role_length = 20000 "length of paper on role in meters";
  parameter Real cutting_at = 500 "length by which the rest is cut";
  parameter Real display_time = 100 "for animation";
  PNlib.Components.TD new_role(nOut = 2, delay = 1, nIn = 1, arcWeightIn = {1}, firingCon = pre(start), arcWeightOut = {Role_length, 1})
  PNlib.Components.TD cutting_rest(nIn = 1, nOut = 1, delay = 2, firingCon = pre(start))
  PNlib.Components.PD P1(maxTokens = 1, nIn = 2, nOut = 1)
  PNlib.Components.TD T1(nIn = 2, nOut = 1, firingCon = pre(start), arcWeightIn = {1, Role.t})
  PNlib.Components.PD P2(nIn = 1, nOut = 1, maxTokens = 1)
  PNlib.Components.IA IA2(testValue = cutting_at)
  PNlib.Components.TD Role_change(nIn = 1, maxTokens = 1, nOut = 2)
  PNlib.Components.PC Role(nIn = 1, nOut = 3, minMarks = 0, maxMarks = PNlib.Constants.inf, startMarks = 0, reStart = reStart) "[m]"
  PNlib.Interfaces.PlaceOut rollenwechsel_[2]
  PNlib.Interfaces.PlaceOut rolle_
  Real fireAni[3];
  Modelica.Blocks.Interfaces.RealOutput meter_role_
  PNlib.Interfaces.PlaceIn start_
protected
  outer Boolean start;
  outer Boolean reStart;
equation
  fireAni = if (new_role.fireTime + display_time >= time and new_role.ani) then {255, 255, 0} else {255, 255, 255};
  connect(new_role.outPlaces[1], Role.inTransition[1])
  connect(Role.outTransition[1], IA2.inPlace)
  connect(IA2.outTransition, cutting_rest.inPlaces[1])
  connect(cutting_rest.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P2.outTransition[1], new_role.inPlaces[1])
  connect(new_role.outPlaces[2], Role_change.inTransition[1])
  connect(Role_change.outTransition[1], rollenwechsel_[1])
  connect(Role.outTransition[2], T1.inPlaces[2])
  connect(Role.outTransition[3], rolle_)
  connect(Role.pc_t, meter_role_)
  connect(P1.inTransition[2], start_)
  connect(Role_change.outTransition[2], rollenwechsel_[2])
end Role_change;


starting and stop the printing machine.

within PNlib.Examples.Models.Printing;

model Start_Stop "starting and stop the printing machine"
  import PNlib;
  parameter Integer number_exemplars = 100000 "Number of exemplares that has to be produced";
  parameter Real timeStopping = 300 "Time that is needed to shut down the machine when it is stopped";
  parameter Real setupTime = 3600 "Set-up time";
  parameter Real max_Speed = 15 "Maximum speed of the machine in m/s";
  Real speed;
  Real stopTime;
  Real stopTime2;
  Real startTime;
  Boolean reStart;
  PNlib.Components.PD Start(nIn = 1, nOut = 1, maxTokens = 1, startTokens = 0)
  PNlib.Components.TD starting(nOut = 2, nIn = 1, delay = setupTime)
  PNlib.Components.PD Stop(nIn = 1, maxTokens = 1, nOut = 1, startTokens = 0)
  PNlib.Components.PD Counter_Orders(nIn = 1)
  PNlib.Components.TD stopping(nIn = 2, nOut = 1, arcWeightIn = {1, 1})
  PNlib.Components.TA TA5(testValue = number_exemplars)
  Interfaces.TransitionIn exemplare_
  Boolean start = Start.t > 0;
  Real color[3] = if start then {0, 255, 0} else {255, 0, 0};
  Modelica.Blocks.Interfaces.RealOutput orders_
  Interfaces.TransitionOut rollen_wechsel_
  Modelica.Blocks.Interfaces.RealOutput time_counter_
  PNlib.Components.TD shutDown(nIn = 1, nOut = 2, delay = timeStopping)
  PNlib.Components.PD Stop2(nIn = 1, nOut = 1, startTokens = 1, maxTokens = 1)
  Modelica.Blocks.Math.IntegerToReal integerToReal
equation
  reStart = Stop2.t > 0;
  when Stop.t > 0 then
    stopTime = time;
  end when;
  when pre(Stop2.t) > 0 then
    stopTime2 = time;
  end when;
  when start then
    startTime = time;
  end when;
  time_counter_ = time - stopTime2;
  connect(TA5.inPlace, exemplare_)
  connect(TA5.outTransition, stopping.inPlaces[1])
  connect(stopping.outPlaces[1], Stop.inTransition[1])
  connect(starting.outPlaces[1], Start.inTransition[1])
  connect(Start.outTransition[1], stopping.inPlaces[2])
  connect(starting.outPlaces[2], rollen_wechsel_)
algorithm
  if Stop.t > 0 then
    if (Stop2.t < 1 and (max_Speed - max_Speed/timeStopping*(time - stopTime)) > 0) then
      speed := max_Speed - max_Speed/timeStopping*(time - stopTime);
    else
      speed := 0;
    end if;
  else
    if Start.t > 0 then
      if (time - startTime < timeStopping and (max_Speed/timeStopping*(time - startTime)) < max_Speed) then
        speed := max_Speed/timeStopping*(time - startTime);
      else
        speed := 15;
      end if;
    else
      speed := 0;
    end if;
  end if;
equation
  connect(Stop.outTransition[1], shutDown.inPlaces[1])
  connect(shutDown.outPlaces[1], Stop2.inTransition[1])
  connect(Stop2.outTransition[1], starting.inPlaces[1])
  connect(shutDown.outPlaces[2], Counter_Orders.inTransition[1])
  connect(Counter_Orders.pd_t, integerToReal.u)
  connect(integerToReal.y, orders_)
end Start_Stop;


Animation of coffee cup.

within PNlib.Examples.Models.Senseo;

model coffee_cup "Animation of coffee cup"
  Modelica.Blocks.Interfaces.RealInput levelSensor
  Real level "Tank level in % of max height";
  parameter Real hmax = 0.7 "Max volume of tank in l";
  parameter Real color[3] = {0, 0, 255};
equation
  level = levelSensor/hmax;
end coffee_cup;


Integer Counter.

within PNlib.Examples.Models.Senseo;

model Counter "Integer Counter"
  Modelica.Blocks.Interfaces.IntegerInput levelSensor
  Real count;
  parameter Integer hmax = 20;
equation
  count = if levelSensor/hmax < 1 then levelSensor/hmax else 1;
end Counter;


Real Counter.

within PNlib.Examples.Models.Senseo;

model Counter_real "Real Counter"
  parameter String text = "counter";
  parameter Real color[3] = {255, 0, 0};
  Modelica.Blocks.Interfaces.RealInput levelSensor
  Real count;
  parameter Integer hmax = 1000000;
  Real levelSensor_ = if levelSensor > 0 then levelSensor else 0;
equation
  count = levelSensor_/hmax;
end Counter_real;


Insert pad: coffee pads are inserted to the Senseo machine (step 5)..

within PNlib.Examples.Models.Senseo;

model Insert_Pad "Insert pad: coffee pads are inserted to the Senseo machine (step 5)."
  import PNlib.Components.*;
  TDS inserting2(nIn = 1, nOut = 1, arcWeightOut = {1}, h = 1/20)
  PD puffer(nOut = 1, maxTokens = 1, nIn = 1)
  Interfaces.TransitionOut insertpad_
  Real color[3] = if fac < 1 then {80, 0, 0} else {255, 255, 255};
  Real startTime;
  Real fac = if (time - startTime)/60 < 1 and startTime > 0 then (time - startTime)/60 else 0;
  Real recsize[2, 2] = {{-100, 80}, {-100 + 200*fac, -80}};
  Interfaces.PlaceIn insert_
equation
  when puffer.t > 0 then
    startTime = time;
  end when;
  connect(puffer.outTransition[1], inserting2.inPlaces[1])
  connect(inserting2.outPlaces[1], insertpad_)
  connect(puffer.inTransition[1], insert_)
end Insert_Pad;


Model of a Senseo coffee machine

within PNlib.Examples.Models;

package Senseo "Model of a Senseo coffee machine"
  extends Modelica.Icons.ExamplesPackage;
end Senseo;


Refilling water: the water tank of the Senseo machine is refilled (step 3)..

within PNlib.Examples.Models.Senseo;

model Refill_Water "Refilling water: the water tank of the Senseo machine is refilled (step 3)."
  import PNlib.Components.*;
  TD refilling2(nIn = 1, nOut = 2, arcWeightOut = {1, 0.7 - watertank_.t}, delay = 30)
  PD puffer(nIn = 1, nOut = 1, maxTokens = 1)
  TD refilling1(delay = 1, arcWeightOut = {1}, nOut = 1, nIn = 2, arcWeightIn = {1, 0.36})
  IA IA1(testValue = 0.36)
  Interfaces.TransitionIn watertank_
  Interfaces.TransitionOut refill_[2]
  Interfaces.TransitionIn start_
  Real color[3] = if fac < 1 then {0, 0, 255} else {255, 255, 255};
  Real startTime;
  Real fac = if (time - startTime)/60 < 1 and startTime > 0 then (time - startTime)/60 else 0;
  Real recsize[2, 2] = {{-100, 80}, {-100 + 200*fac, -80}};
equation
  when puffer.t > 0 then
    startTime = time;
  end when;
  connect(IA1.inPlace, watertank_)
  connect(refilling1.outPlaces[1], puffer.inTransition[1])
  connect(puffer.outTransition[1], refilling2.inPlaces[1])
  connect(refilling2.outPlaces, refill_)
  connect(refilling1.inPlaces[1], start_)
  connect(IA1.outTransition, refilling1.inPlaces[2])
end Refill_Water;


Senseo machine: the functionality of the Senseo machine (step 4, 6, 7, 8, 9, 10)..

within PNlib.Examples.Models.Senseo;

model Senseo_Maschine "Senseo machine: the functionality of the Senseo machine (step 4, 6, 7, 8, 9, 10)."
  parameter Real Psenseo = 1.450 "power of senseo machine [kW]";
  parameter Real c = 4.182 "specific heat capacity [kJ/(kg*K)]";
  parameter Real k = 0.01177 "proportionality factor for cooling water";
  parameter Real TE = 20 "Environment temperature [°C]";
  parameter Real TC = 10 "Temperature of new water [°C]";
  PNlib.Components.TC heating(nIn = 3, nOut = 1, maximumSpeed = Psenseo/(c*water_hc.t))
  PNlib.Components.TA TA1(testValue = 0)
  PNlib.Components.TA TA2(testValue = 0.34)
  PNlib.Components.PC TW(nIn = 2, nOut = 3, maxMarks = 90, startMarks = 20) "water temperature"
  PNlib.Components.TC pumping(maximumSpeed = 0.1, nOut = 2, nIn = 1, arcWeightOut = {1, TC/water_hc.t})
  PNlib.Components.TC cooling(nIn = 2, maximumSpeed = k*(TW.t - TE), firingCon = TW.t > TE)
  PNlib.Components.TD stopornext(nIn = 2, firingCon = true, delay = 1, nOut = 1)
  PNlib.Components.PC water_hc(nIn = 1, nOut = 2, startMarks = 0.25, maxMarks = 0.25) "water in heating chamber"
  PNlib.Components.TD T1(nIn = 2, nOut = 1, arcWeightIn = {90, 1}, delay = 1)
  PNlib.Components.TA TA3(testValue = 90)
  PNlib.Components.PD decision(nIn = 1, maxTokens = 1, nOut = 2, enablingType = PNlib.Types.EnablingType.Probability, enablingProbOut = {0.7, 0.3})
  PNlib.Components.TD T2(nIn = 1, nOut = 1, delay = 1)
  PNlib.Components.TD T3(nIn = 1, nOut = 1, delay = 1)
  PNlib.Components.PD onecup(nIn = 1, nOut = 1, maxTokens = 1)
  PNlib.Components.PD twocups(nIn = 1, nOut = 1, maxTokens = 1)
  PNlib.Components.TD T4(nIn = 1, nOut = 1, arcWeightOut = {1})
  PNlib.Components.TD T5(nIn = 1, nOut = 1, arcWeightOut = {2})
  PNlib.Components.TC scalding(maximumSpeed = 0.003125, nIn = 3, nOut = 2, arcWeightIn = {1, 1, TW.t/water_hc.t})
  PNlib.Components.TA RA1(testValue = 0)
  PNlib.Components.PC coffee_cup(nIn = 1, nOut = 1)
  inner PNlib.Components.Settings settings
  PNlib.Components.PD ready(maxTokens = 1, nIn = 1, nOut = 1, startTokens = 0)
  PNlib.Components.TD T7(nIn = 2, nOut = 2, firingCon = pre(disamount.t) > 0, arcWeightIn = {pre(disamount.t)*0.125, pre(disamount.t)}, arcWeightOut = {pre(disamount.t), 1}, delay = 1)
  PNlib.Components.PD amountCups(nIn = 1)
  PNlib.Components.PD disamount(nIn = 3, nOut = 2)
  PNlib.Components.PD P1(nOut = 3, maxTokens = 1, nIn = 1)
  PNlib.Components.PD P3(nOut = 1, nIn = 1, maxTokens = 1)
  Modelica.Blocks.Interfaces.RealOutput coffee_cup_
  Modelica.Blocks.Interfaces.IntegerOutput amount_cups_
  Interfaces.TransitionIn watertank_[2]
  Interfaces.TransitionOut stopornext_
  Interfaces.PlaceIn startheating_
  Interfaces.PlaceIn padinsert_
  Modelica.Blocks.Interfaces.RealOutput tw_
  PNlib.Components.IA IA1(testValue = 1)
equation
  connect(TA1.outTransition, heating.inPlaces[1])
  connect(TA2.outTransition, heating.inPlaces[2])
  connect(heating.outPlaces[1], TW.inTransition[1])
  connect(TW.outTransition[1], cooling.inPlaces[1])
  connect(pumping.outPlaces[1], water_hc.inTransition[1])
  connect(TW.outTransition[2], TA3.inPlace)
  connect(TA3.outTransition, T1.inPlaces[1])
  connect(T1.outPlaces[1], decision.inTransition[1])
  connect(decision.outTransition[1], T2.inPlaces[1])
  connect(decision.outTransition[2], T3.inPlaces[1])
  connect(T2.outPlaces[1], onecup.inTransition[1])
  connect(T3.outPlaces[1], twocups.inTransition[1])
  connect(onecup.outTransition[1], T4.inPlaces[1])
  connect(twocups.outTransition[1], T5.inPlaces[1])
  connect(water_hc.outTransition[1], scalding.inPlaces[1])
  connect(RA1.outTransition, heating.inPlaces[3])
  connect(water_hc.outTransition[2], RA1.inPlace)
  connect(scalding.outPlaces[1], coffee_cup.inTransition[1])
  connect(coffee_cup.outTransition[1], T7.inPlaces[1])
  connect(T7.outPlaces[1], amountCups.inTransition[1])
  connect(T7.outPlaces[2], ready.inTransition[1])
  connect(T4.outPlaces[1], disamount.inTransition[1])
  connect(T5.outPlaces[1], disamount.inTransition[2])
  connect(disamount.outTransition[1], T7.inPlaces[2])
  connect(disamount.outTransition[2], scalding.inPlaces[2])
  connect(scalding.outPlaces[2], disamount.inTransition[3])
  connect(P1.outTransition[1], TA1.inPlace)
  connect(P1.outTransition[2], stopornext.inPlaces[1])
  connect(ready.outTransition[1], stopornext.inPlaces[2])
  connect(P3.outTransition[1], T1.inPlaces[2])
  connect(coffee_cup.pc_t, coffee_cup_)
  connect(amountCups.pd_t, amount_cups_)
  connect(stopornext.outPlaces[1], stopornext_)
  connect(watertank_[1], TA2.inPlace)
  connect(watertank_[2], pumping.inPlaces[1])
  connect(P1.inTransition[1], startheating_)
  connect(P3.inTransition[1], padinsert_)
  connect(pumping.outPlaces[2], TW.inTransition[2])
  connect(TW.outTransition[3], scalding.inPlaces[3])
  connect(TW.pc_t, tw_)
  connect(P1.outTransition[3], IA1.inPlace)
  connect(IA1.outTransition, cooling.inPlaces[2])
end Senseo_Maschine;


Top Model.

within PNlib.Examples.Models.Senseo;

model Senseo_Model "Top Model"
  extends Modelica.Icons.Example;
  PNlib.Examples.Models.Senseo.Senseo_Maschine senseo_Maschine
  Water_Tank water_tank
  PNlib.Examples.Models.Senseo.coffee_cup coffe_cup(color = {80, 0, 0}, hmax = 0.25)
  PNlib.Examples.Models.Senseo.Counter amount_cups
  PNlib.Examples.Models.Senseo.Start start(EV_time = 1200)
  PNlib.Examples.Models.Senseo.Refill_Water refill_Water
  PNlib.Examples.Models.Senseo.Insert_Pad insert_Pad
  PNlib.Examples.Models.Senseo.Counter_real counter_real(text = "Temperature", hmax = 90)
  inner PNlib.Components.Settings settings
equation
  connect(senseo_Maschine.amount_cups_, amount_cups.levelSensor)
  connect(refill_Water.refill_[2], water_tank.inTransition1)
  connect(water_tank.refill_, refill_Water.watertank_)
  connect(water_tank.outTransition1, senseo_Maschine.watertank_)
  connect(refill_Water.refill_[1], start.refillstart_)
  connect(start.refill_, refill_Water.start_)
  connect(senseo_Maschine.stopornext_, start.stopornext_)
  connect(start.start_[1], senseo_Maschine.startheating_)
  connect(start.start_[2], insert_Pad.insert_)
  connect(insert_Pad.insertpad_, senseo_Maschine.padinsert_)
  connect(senseo_Maschine.coffee_cup_, coffe_cup.levelSensor)
  connect(senseo_Maschine.tw_, counter_real.levelSensor)
end Senseo_Model;


User action: starting and stopping the machine (step 1, 2, 11), initiating the insertion of coffee pads (step 5) and the refill of water (step 3)..

within PNlib.Examples.Models.Senseo;

model Start "User action: starting and stopping the machine (step 1, 2, 11), initiating the insertion of coffee pads (step 5) and the refill of water (step 3)."
  import PNlib.Components.*;
  parameter Real EV_time = 600;
  TDS starting(h = 1/EV_time, nIn = 1, nOut = 1)
  Real colorHead[3] = if stop.t > 0 then {255, 0, 0} else {0, 255, 0};
  PD start(nOut = 2, nIn = 3, maxTokens = 1)
  PD stop(nIn = 1, startTokens = 1, nOut = 1, maxTokens = 1)
  Interfaces.PlaceOut refill_
  TD T8(nIn = 1, nOut = 1, delay = 1)
  TD T6(nOut = 1, nIn = 1, delay = 1)
  PD nextcoffee(nIn = 1, maxTokens = 1, startTokens = 0, nOut = 1)
  TD T10(nIn = 1, nOut = 1)
  PD P1(nIn = 1, nOut = 2, enablingType = PNlib.Types.EnablingType.Probability, enablingProbOut = {0.2, 0.8}, maxTokens = 1)
  Interfaces.PlaceIn stopornext_
  Interfaces.PlaceIn refillstart_
  TD T1(nIn = 1, nOut = 2)
  Interfaces.TransitionOut start_[2]
equation
  connect(stop.outTransition[1], starting.inPlaces[1])
  connect(start.outTransition[1], refill_)
  connect(P1.outTransition[1], T6.inPlaces[1])
  connect(P1.outTransition[2], T8.inPlaces[1])
  connect(T6.outPlaces[1], nextcoffee.inTransition[1])
  connect(T8.outPlaces[1], stop.inTransition[1])
  connect(P1.inTransition[1], stopornext_)
  connect(nextcoffee.outTransition[1], T10.inPlaces[1])
  connect(T10.outPlaces[1], start.inTransition[1])
  connect(starting.outPlaces[1], start.inTransition[2])
  connect(start.inTransition[3], refillstart_)
  connect(start.outTransition[2], T1.inPlaces[1])
  connect(T1.outPlaces[1], start_[1])
  connect(T1.outPlaces[2], start_[2])
end Start;


Water tank: the water tank of the Senseo machine..

within PNlib.Examples.Models.Senseo;

model Water_Tank "Water tank: the water tank of the Senseo machine."
  import PNlib.Components.*;
  Real level "Tank level in % of max height";
  parameter Real color[3] = {0, 0, 255};
  PC water_tank(nOut = 3, startMarks = 0.5, maxMarks = 0.75, nIn = 1) "cold water in tank"
  Interfaces.PlaceOut outTransition1[2]
  Interfaces.PlaceIn inTransition1
  Interfaces.PlaceOut refill_
equation
  level = water_tank.t/water_tank.maxMarks;
  connect(water_tank.outTransition[1], outTransition1[1])
  connect(water_tank.outTransition[2], outTransition1[2]);
  connect(water_tank.inTransition[1], inTransition1)
  connect(water_tank.outTransition[3], refill_)
end Water_Tank;


within PNlib;

package Functions "contains functions with specific algorithmic procedures which are used in the Petri net component models"
end Functions;


enabling functions

within PNlib.Functions;

package Enabling "enabling functions"
end Enabling;


help functions

within PNlib.Functions;

package OddsAndEnds "help functions"
end OddsAndEnds;


random functions

within PNlib.Functions;

package Random "random functions"
end Random;


within PNlib;

package Interfaces "contains the connectors for the Petri net component models"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


part of place model to connect places to input transitions.

within PNlib.Interfaces;

connector PlaceIn "part of place model to connect places to input transitions"
  input Boolean active "Are the input transitions active?"
  input Boolean fire "Do the input transitions fire?"
  input Real arcWeight "Arc weights of input transitions"
  input Integer arcWeightint "Integer arc weights of input transitions"
  input Boolean enabledByInPlaces "Are the input transitions enabled by all theier input places?"
  input Boolean disTransition "Types of input transitions (discrete/stochastic or continuous)"
  input Real instSpeed "Instantaneous speeds of continuous input transitions"
  input Real prelimSpeed "Preliminary speeds of continuous input transitions"
  input Real maxSpeed "Maximum speeds of continuous input transitions"
  output Real t "Marking of the place"
  output Integer tint "Integer marking of the place"
  output Real maxTokens "Maximum capacity of the place"
  output Integer maxTokensint "Integer maximum capacity of the place"
  output Boolean enable "Which of the input transitions are enabled by the place?"
  output Real decreasingFactor "Factor for decreasing the speed of continuous input transitions"
  output Boolean disPlace "Type of the place (discrete or continuous)"
  output Boolean emptied "Is the continuous place emptied by output transitions?"
  output Real speedSum "Output speed of a continuous place"
end PlaceIn;


part of place model to connect places to output transitions.

within PNlib.Interfaces;

connector PlaceOut "part of place model to connect places to output transitions"
  import PNlib.Types.ArcType;
  input Boolean active "Are the output transitions active?"
  input Boolean fire "Do the output transitions fire?"
  input Real arcWeight "Arc weights of output transitions"
  input Integer arcWeightint "Integer arc weights of output transitions"
  input Boolean disTransition "Are the output transitions discrete?"
  input Real instSpeed "Instantaneous speeds of continuous output transitions"
  input Real prelimSpeed "Preliminary speeds of continuous output transitions"
  input Real maxSpeed "Maximum speeds of continuous output transitions"
  output Real t "Marking of the place"
  output Integer tint "Integer marking of the place"
  output Real minTokens "Minimum capacity of the place"
  output Integer minTokensint "Integer minimum capacity of the place"
  output Boolean enable "Which of the output transitions are enabled by the place?"
  output Real decreasingFactor "Factor for decreasing the speed of continuous input transitions"
  output Boolean disPlace "Type of the place (discrete or continuous)"
  output ArcType arcType "Type of output arcs (normal, test, inhibition, or read)"
  output Boolean fed "Is the continuous place fed by input transitions?"
  output Real speedSum "Input speed of a continuous place"
  output Boolean tokenInOut "Does the place have a discrete token change?"
  output Real testValue "Test value of a test or inhibitor arc"
  output Integer testValueint "Integer test value of a test or inhibitor arc"
  output Boolean normalArc "Double arc: test and normal arc or inhibitor and normal arc"
end PlaceOut;