From 4bc590d8cc38ad27a7f13a67b875c8b30d45d99c Mon Sep 17 00:00:00 2001 From: SebastianEbert <sebastian.ebert@tu-dresden.de> Date: Thu, 28 Oct 2021 18:00:05 +0200 Subject: [PATCH] added ref-place and ref-transition execution support --- src/main/jastadd/Navigation.jrag | 76 ++++++++++-- .../java/de/tudresden/inf/st/pnml/Main.java | 5 +- src/main/resources/placeRefNet.pnml | 114 ++++++++++++++++++ src/main/resources/transitionRefNet.pnml | 92 ++++++++++++++ 4 files changed, 273 insertions(+), 14 deletions(-) create mode 100644 src/main/resources/placeRefNet.pnml create mode 100644 src/main/resources/transitionRefNet.pnml diff --git a/src/main/jastadd/Navigation.jrag b/src/main/jastadd/Navigation.jrag index 444a59e..fdc3380 100644 --- a/src/main/jastadd/Navigation.jrag +++ b/src/main/jastadd/Navigation.jrag @@ -2,22 +2,40 @@ aspect Navigation { inh PetriNet PnObject.petriNet(); eq PetriNet.getChild().petriNet() = this; - syn java.util.Collection<Place> Transition.incomingPlaces() { - java.util.Set<Place> incomingPlaces = new java.util.HashSet<>(); - for (Arc incomingArc : getInArcList()) { - incomingPlaces.add(incomingArc.getSource().asPlaceNode().place()); - } - return incomingPlaces; + syn java.util.Collection<Place> TransitionNode.incomingPlaces() { + + java.util.Set<Place> s = new java.util.HashSet<>(); + + for (Arc incomingArc : getInArcList()) { + s.add(incomingArc.getSource().asPlaceNode().place()); + } + + for (TransitionNode ref : getReferencingTransitions()) { + s.addAll(ref.incomingPlaces()); + } + + return s; } + + syn java.util.Collection<Place> TransitionNode.outgoingPlaces() { + + java.util.Set<Place> s = new java.util.HashSet<>(); - syn java.util.Collection<Place> Transition.outgoingPlaces() { - java.util.Set<Place> outgoingPlaces = new java.util.HashSet<>(); - for (Arc outgoingArc : getOutArcList()) { - outgoingPlaces.add(outgoingArc.getTarget().asPlaceNode().place()); + for (Arc outgoing : getOutArcList()) { + s.add(outgoing.getTarget().asPlaceNode().place()); } - return outgoingPlaces; + + for (TransitionNode ref : getReferencingTransitions()) { + s.addAll(ref.outgoingPlaces()); + } + + return s; } + inh Page PnObject.ContainingPage(); + eq Page.getObject().ContainingPage() = this; + eq PetriNet.getPage().ContainingPage() = null; + syn boolean Node.isPlaceNode() = false; eq PlaceNode.isPlaceNode() = true; @@ -38,6 +56,21 @@ aspect Navigation { eq Transition.transition() = this; eq RefTransition.transition() = getRef().transition(); + syn boolean PlaceNode.isRefPlace() = false; + eq RefPlace.isRefPlace() = true; + + syn boolean TransitionNode.isTransition() = false; + eq Transition.isTransition() = true; + + syn boolean TransitionNode.isRefTransition() = false; + eq RefTransition.isRefTransition() = true; + + syn RefTransition TransitionNode.asRefTransition() = null; + eq RefTransition.asRefTransition() = this; + + syn Transition TransitionNode.asTransition() = null; + eq Transition.asTransition() = this; + coll java.util.Set<PnObject> PetriNet.allObjects() [new java.util.HashSet()] root PetriNet; PnObject contributes this to PetriNet.allObjects() @@ -57,4 +90,25 @@ aspect Navigation { Arc contributes this to PetriNet.allArcs() for petriNet(); + + coll java.util.Set<Page> PetriNet.allPages() [new java.util.HashSet()] root PetriNet; + Page contributes this + to PetriNet.allPages() + for petriNet(); + + coll java.util.Set<TransitionNode> PetriNet.allTransitionNodes() [new java.util.HashSet()] root PetriNet; + TransitionNode contributes this + to PetriNet.allTransitionNodes() + for petriNet(); + + coll java.util.Set<RefTransition> PetriNet.allRefTransitions() [new java.util.HashSet()] root PetriNet; + RefTransition contributes this + to PetriNet.allRefTransitions() + for petriNet(); + + coll java.util.Set<RefPlace> PetriNet.allRefPlaces() [new java.util.HashSet()] root PetriNet; + RefPlace contributes this + to PetriNet.allRefPlaces() + for petriNet(); + } diff --git a/src/main/java/de/tudresden/inf/st/pnml/Main.java b/src/main/java/de/tudresden/inf/st/pnml/Main.java index 7ea32cc..859b831 100644 --- a/src/main/java/de/tudresden/inf/st/pnml/Main.java +++ b/src/main/java/de/tudresden/inf/st/pnml/Main.java @@ -1,7 +1,6 @@ package de.tudresden.inf.st.pnml; -import de.tudresden.inf.st.pnml.jastadd.model.Marking; -import de.tudresden.inf.st.pnml.jastadd.model.PetriNet; +import de.tudresden.inf.st.pnml.jastadd.model.*; import fr.lip6.move.pnml.framework.general.PNType; import fr.lip6.move.pnml.framework.hlapi.HLAPIRootClass; import fr.lip6.move.pnml.framework.utils.ModelRepository; @@ -27,7 +26,7 @@ public class Main { // String fileName = "src/main/resources/minimal.pnml"; // String fileName = "src/main/resources/philo.pnml"; - String fileName = "src/main/resources/haddadin_automaton_flat.pnml"; + String fileName = "src/main/resources/placeRefNet.pnml"; List<PetriNet> petriNets = parsePnml(fileName); diff --git a/src/main/resources/placeRefNet.pnml b/src/main/resources/placeRefNet.pnml new file mode 100644 index 0000000..c7e40a5 --- /dev/null +++ b/src/main/resources/placeRefNet.pnml @@ -0,0 +1,114 @@ +<pnml xmlns="http://www.pnml.org/version-2009/grammar/pnml"> + <net id="n-E2D0-BCF46-0" type ="http://www.pnml.org/version-2009/grammar/ptnet"> + <name> + <text>minimal</text> + </name> + + <page id="top"> + <page id="p1"> + <place id="p4"> + <name> + <text>p4</text> + <graphics> + <offset x="0" y="-10" /> + </graphics> + </name> + <initialMarking> + <text>1</text> + </initialMarking> + <graphics> + <position x="30" y="50"/> + </graphics> + </place> + <transition id="tRefIn"> + <name> + <text>tRefIn</text> + <graphics> + <offset x="0" y="0" /> + </graphics> + </name> + <graphics> + <position x="285" y="205"/> + </graphics> + </transition> + <referencePlace id="rp1" ref="p-E2D0-BCF6F-2"> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + <location>loc1</location> + <subnet>s1</subnet> + </toolspecific> + <name> + <text>rp1</text> + <graphics> + <offset x="0" y="0" /> + </graphics> + </name> + <graphics> + <position x="20" y="20"/> + </graphics> + </referencePlace> + <arc id="rin" source="tRefIn" target="rp1"> + </arc> + <arc id="arc-p4-TRefIn" source="p4" target="tRefIn"> + </arc> + </page> + + <page id="p2"> + <place id="p-E2D0-BCF6F-2"> + <name> + <text>p0</text> + <graphics> + <offset x="0" y="-10" /> + </graphics> + </name> + <initialMarking> + <text>0</text> + </initialMarking> + <graphics> + <position x="30" y="50"/> + </graphics> + </place> + <place id="p-E2D0-BCF9D-3"> + <name> + <text>p1</text> + <graphics> + <offset x="0" y="-10" /> + </graphics> + </name> + <graphics> + <position x="635" y="90"/> + </graphics> + </place> + <transition id="t-E2D0-BCFAC-4"> + <name> + <text>t0</text> + <graphics> + <offset x="0" y="0" /> + </graphics> + </name> + <graphics> + <position x="300" y="50"/> + </graphics> + </transition> + <transition id="t-E2D0-BCFBD-5"> + <name> + <text>t1</text> + <graphics> + <offset x="0" y="0" /> + </graphics> + </name> + <graphics> + <position x="285" y="205"/> + </graphics> + </transition> + <arc id="e-E2D0-BCFCD-6" source="t-E2D0-BCFBD-5" target="p-E2D0-BCF6F-2"> + </arc> + <arc id="e-E2D0-BCFDB-7" source="p-E2D0-BCF9D-3" target="t-E2D0-BCFBD-5"> + </arc> + <arc id="e-E2D0-BCFF3-8" source="t-E2D0-BCFAC-4" target="p-E2D0-BCF9D-3"> + </arc> + <arc id="e-E2D0-BCFFB-9" source="p-E2D0-BCF6F-2" target="t-E2D0-BCFAC-4"> + </arc> + </page> + </page> + </net> +</pnml> diff --git a/src/main/resources/transitionRefNet.pnml b/src/main/resources/transitionRefNet.pnml new file mode 100644 index 0000000..4fccb61 --- /dev/null +++ b/src/main/resources/transitionRefNet.pnml @@ -0,0 +1,92 @@ +<pnml xmlns="http://www.pnml.org/version-2009/grammar/pnml"> + <net id="n-E2D0-BCF46-0" type ="http://www.pnml.org/version-2009/grammar/ptnet"> + <name> + <text>minimal</text> + </name> + + <page id="top"> + <page id="p1"> + <place id="pRefSrc"> + <name> + <text>pRefSrc</text> + <graphics> + <offset x="0" y="-10" /> + </graphics> + </name> + <initialMarking> + <text>1</text> + </initialMarking> + <graphics> + <position x="30" y="50"/> + </graphics> + </place> + <referenceTransition id="rt1" ref="t-E2D0-BCFAC-4"> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + <location>loc1</location> + <subnet>s1</subnet> + </toolspecific> + </referenceTransition> + <arc id="rin" source="pRefSrc" target="rt1"> + </arc> + </page> + + <page id="p2"> + <place id="p-E2D0-BCF6F-2"> + <name> + <text>p0</text> + <graphics> + <offset x="0" y="-10" /> + </graphics> + </name> + <initialMarking> + <text>1</text> + </initialMarking> + <graphics> + <position x="30" y="50"/> + </graphics> + </place> + <place id="p-E2D0-BCF9D-3"> + <name> + <text>p1</text> + <graphics> + <offset x="0" y="-10" /> + </graphics> + </name> + <graphics> + <position x="635" y="90"/> + </graphics> + </place> + <transition id="t-E2D0-BCFAC-4"> + <name> + <text>t0</text> + <graphics> + <offset x="0" y="0" /> + </graphics> + </name> + <graphics> + <position x="300" y="50"/> + </graphics> + </transition> + <transition id="t-E2D0-BCFBD-5"> + <name> + <text>t1</text> + <graphics> + <offset x="0" y="0" /> + </graphics> + </name> + <graphics> + <position x="285" y="205"/> + </graphics> + </transition> + <arc id="e-E2D0-BCFCD-6" source="t-E2D0-BCFBD-5" target="p-E2D0-BCF6F-2"> + </arc> + <arc id="e-E2D0-BCFDB-7" source="p-E2D0-BCF9D-3" target="t-E2D0-BCFBD-5"> + </arc> + <arc id="e-E2D0-BCFF3-8" source="t-E2D0-BCFAC-4" target="p-E2D0-BCF9D-3"> + </arc> + <arc id="e-E2D0-BCFFB-9" source="p-E2D0-BCF6F-2" target="t-E2D0-BCFAC-4"> + </arc> + </page> + </page> + </net> +</pnml> -- GitLab