Skip to content
Snippets Groups Projects
Commit 5567cc83 authored by Sebastian Ebert's avatar Sebastian Ebert
Browse files

implemented flattening for services v4

parent a1d86068
No related branches found
No related tags found
No related merge requests found
...@@ -33,8 +33,8 @@ public class Main { ...@@ -33,8 +33,8 @@ public class Main {
// parse the global not flatted petri net // parse the global not flatted petri net
// pnmlPath = "../pnml-relast-nets/src/main/resources/signalFlatteningTestNets/inputsignal-simple-3.pnml"; // pnmlPath = "../pnml-relast-nets/src/main/resources/signalFlatteningTestNets/inputsignal-simple-3.pnml";
// String pnmlPath = "../pnml-relast-nets/src/main/resources/serviceTestNets/structureTestNets/service-structure-correct.pnml"; //String pnmlPath = "../pnml-relast-nets/src/main/resources/serviceTestNets/structureTestNets/service-structure-correct.pnml";
// String configPath = "src/main/config/config.json"; //String configPath = "src/main/config/config.json";
PetriNet petriNet = PnmlParser.parsePnml(pnmlPath).get(0); PetriNet petriNet = PnmlParser.parsePnml(pnmlPath).get(0);
// read config for analyzer from file // read config for analyzer from file
......
...@@ -61,4 +61,10 @@ public final class TemplateConstants { ...@@ -61,4 +61,10 @@ public final class TemplateConstants {
public static final String SERVICE_QUEUE_OUTPUT_PLACE = "ServiceQueueOutputPlace"; public static final String SERVICE_QUEUE_OUTPUT_PLACE = "ServiceQueueOutputPlace";
public static final String SERVICE_QUEUE_CAPACITY_PLACE = "ServiceQueueCapacityPlace"; public static final String SERVICE_QUEUE_CAPACITY_PLACE = "ServiceQueueCapacityPlace";
public static final String SERVICE_FEEDBACK_PLACE = "ServiceFeedbackPlace"; public static final String SERVICE_FEEDBACK_PLACE = "ServiceFeedbackPlace";
public static final String SERVICE_QUEUE_TO_SERVER_PLACE = "ServiceQueueToServerPlace";
public static final String SERVICE_TO_QUEUE_PLACE = "ServiceToQueuePlace";
public static final String SERVICE_QUEUE_CONNECTOR_TRANSITION = "ServiceQueueConnectorTransition";
public static final String SERVICE_QUEUE_OVERFLOW_TRANSITION = "ServiceQueueOverflowTransition";
} }
...@@ -589,8 +589,16 @@ public class ChannelFlatter { ...@@ -589,8 +589,16 @@ public class ChannelFlatter {
// insert channel queue template // insert channel queue template
String queue_suffix = "serverInstance-" + serverInstanceCount; String queue_suffix = "serverInstance-" + serverInstanceCount;
PetriNet serviceQueuePetriNet = ServiceTemplates.getQueueConnectionTemplate(queue_suffix); OutputSignalPlace queueCapacityPlace = PrimitiveTemplates.getOutputSignalPlace();
includeTemplateInstance(petriNet, serviceQueuePetriNet, "channel", "channel"); queueCapacityPlace.setId(TemplateConstants.SERVICE_QUEUE_CAPACITY_PLACE + "-" + queue_suffix);
PlaceInformation pi = new PlaceInformation();
pi.setSubNet("channel");
pi.setLocation("channel");
pi.setType(PnmlConstants.PLACE_TYPE_DISCRETE);
queueCapacityPlace.setMutualPlaceInformation(pi);
queueCapacityPlace.getInitialMarking().setText(16);
topPage.addObject(queueCapacityPlace);
int clientCount = 0; int clientCount = 0;
...@@ -647,48 +655,36 @@ public class ChannelFlatter { ...@@ -647,48 +655,36 @@ public class ChannelFlatter {
includeTemplateInstance(petriNet, serviceChannelPetriNet, "channel", "channel"); includeTemplateInstance(petriNet, serviceChannelPetriNet, "channel", "channel");
// link the template instance to the net via arcs // link the template instance to the net via arcs
Arc channelClientInputArc = new Arc();
channelClientInputArc.setId("channel-client-input-arc-" + channel_suffix); createAndIncludeArc(topPage, "channel-client-input-arc-" + channel_suffix, incomingPlace,
channelClientInputArc.setSource(incomingPlace); getTransitionByID(petriNet, TemplateConstants.SERVICE_CLIENT_INPUT_TRANSITION + "-" + channel_suffix));
channelClientInputArc.setTarget(getTransitionByID(petriNet, TemplateConstants.SERVICE_CLIENT_INPUT_TRANSITION + "-" + channel_suffix)); createAndIncludeArc(topPage, "channel-client-output-arc-" + channel_suffix, getTransitionByID(petriNet, TemplateConstants.SERVICE_CLIENT_OUTPUT_TRANSITION + "-" + channel_suffix),
topPage.addObject(channelClientInputArc); responseTransition.getOutArcs().get(clientCount).getTarget());
Arc channelClientOutputArc = new Arc(); // service instance input transition -> service input place
channelClientOutputArc.setId("channel-client-output-arc-" + channel_suffix); createAndIncludeArc(topPage, "channel-server-input-arc-" + channel_suffix,
channelClientOutputArc.setSource(getTransitionByID(petriNet, TemplateConstants.SERVICE_CLIENT_OUTPUT_TRANSITION + "-" + channel_suffix)); getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_INPUT_TRANSITION + "-" + channel_suffix), ioPlacePair._1);
channelClientOutputArc.setTarget(responseTransition.getOutArcs().get(clientCount).getTarget());
topPage.addObject(channelClientOutputArc); // service instance output place -> service instance output transition
createAndIncludeArc(topPage, "channel-server-output-arc-" + channel_suffix, ioPlacePair._2,
Arc channelServerInputArc = new Arc(); getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_OUTPUT_TRANSITION + "-" + channel_suffix));
channelServerInputArc.setId("channel-server-input-arc-" + channel_suffix);
channelServerInputArc.setSource(getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_INPUT_TRANSITION + "-" + channel_suffix)); createAndIncludeArc(topPage, "queue-to-server-place-arc-" + channel_suffix, getPlaceByID(petriNet, TemplateConstants.SERVICE_QUEUE_TO_SERVER_PLACE + "-" + channel_suffix),
channelServerInputArc.setTarget(ioPlacePair._1); getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_INPUT_TRANSITION + "-" + channel_suffix));
topPage.addObject(channelServerInputArc); createAndIncludeArc(topPage,"client-to-server-input" + channel_suffix, getPlaceByID(petriNet, TemplateConstants.SERVICE_TO_QUEUE_PLACE + "-" + channel_suffix),
getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_INPUT_TRANSITION + "-" + channel_suffix));
Arc channelServerOutputArc = new Arc(); createAndIncludeArc(topPage, "server-output-to-queue-cap-arc-" + channel_suffix, getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_OUTPUT_TRANSITION + "-" + channel_suffix),
channelServerOutputArc.setId("channel-server-output-arc-" + channel_suffix); getPlaceByID(petriNet, TemplateConstants.SERVICE_QUEUE_CAPACITY_PLACE + "-" + queue_suffix));
channelServerOutputArc.setSource(ioPlacePair._2); createAndIncludeArc(topPage, "client-connector-to-serviceToqueue-arc-" + channel_suffix, getTransitionByID(petriNet, TemplateConstants.SERVICE_CLIENT_CONNECTOR_TRANSITION + "-" + channel_suffix),
channelServerOutputArc.setTarget(getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_OUTPUT_TRANSITION + "-" + channel_suffix)); getPlaceByID(petriNet, TemplateConstants.SERVICE_TO_QUEUE_PLACE + "-" + channel_suffix));
topPage.addObject(channelServerOutputArc);
// Arcs integrating the capacity place
// new arcs in service v3 createAndIncludeInhibitorArc(topPage, "server-cap-to-overflow-arc-" + channel_suffix,
Arc serviceQueueInputArc = new Arc(); queueCapacityPlace, getTransitionByID(petriNet, TemplateConstants.SERVICE_QUEUE_OVERFLOW_TRANSITION + "-" + channel_suffix));
serviceQueueInputArc.setId("channel-server-queue-input-arc-" + channel_suffix); createAndIncludeArc(topPage, "server-to-queue-arc-" + channel_suffix,
serviceQueueInputArc.setSource(getTransitionByID(petriNet, TemplateConstants.SERVICE_CLIENT_CONNECTOR_TRANSITION + "-" + channel_suffix)); queueCapacityPlace, getTransitionByID(petriNet, TemplateConstants.SERVICE_QUEUE_CONNECTOR_TRANSITION + "-" + channel_suffix));
serviceQueueInputArc.setTarget(getPlaceByID(petriNet, TemplateConstants.SERVICE_QUEUE_INPUT_PLACE + "-" + queue_suffix)); createAndIncludeArc(topPage,"serveroutput-to-capacity-arc-" + channel_suffix, getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_OUTPUT_TRANSITION + "-" + channel_suffix),
topPage.addObject(serviceQueueInputArc); queueCapacityPlace);
Arc queueToServerArc = new Arc();
queueToServerArc.setId("queue-to-server-arc-" + channel_suffix);
queueToServerArc.setSource(getPlaceByID(petriNet, TemplateConstants.SERVICE_QUEUE_OUTPUT_PLACE + "-" + queue_suffix));
queueToServerArc.setTarget(getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_INPUT_TRANSITION + "-" + channel_suffix));
topPage.addObject(queueToServerArc);
Arc serverToQueueArc = new Arc();
serverToQueueArc.setId("server-to-queue-arc-" + channel_suffix);
serverToQueueArc.setSource(getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_OUTPUT_TRANSITION + "-" + channel_suffix));
serverToQueueArc.setTarget(getPlaceByID(petriNet, TemplateConstants.SERVICE_QUEUE_CAPACITY_PLACE + "-" + queue_suffix));
topPage.addObject(serverToQueueArc);
serverOutTransitions.add(getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_OUTPUT_TRANSITION + "-" + channel_suffix)); serverOutTransitions.add(getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_OUTPUT_TRANSITION + "-" + channel_suffix));
serverInTransitions.add(getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_INPUT_TRANSITION + "-" + channel_suffix)); serverInTransitions.add(getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_INPUT_TRANSITION + "-" + channel_suffix));
...@@ -703,17 +699,10 @@ public class ChannelFlatter { ...@@ -703,17 +699,10 @@ public class ChannelFlatter {
serverFeedbackPlace.getInitialMarking().setText(1); serverFeedbackPlace.getInitialMarking().setText(1);
topPage.addObject(serverFeedbackPlace); topPage.addObject(serverFeedbackPlace);
Arc feedbackToInputArc = new Arc(); createAndIncludeArc(topPage, "feedbackplace-to-inputtransition-arc-" + channel_suffix, serverFeedbackPlace,
feedbackToInputArc.setId("feedbackplace-to-inputtransition-arc-" + channel_suffix); getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_INPUT_TRANSITION + "-" + channel_suffix));
feedbackToInputArc.setSource(serverFeedbackPlace); createAndIncludeArc(topPage, "outputtransition-to-feedbackplace-arc-" + channel_suffix,
feedbackToInputArc.setTarget(getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_INPUT_TRANSITION + "-" + channel_suffix)); getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_OUTPUT_TRANSITION + "-" + channel_suffix), serverFeedbackPlace);
topPage.addObject(feedbackToInputArc);
Arc outputToFeedbackArc = new Arc();
outputToFeedbackArc.setId("outputtransition-to-feedbackplace-arc-" + channel_suffix);
outputToFeedbackArc.setSource(getTransitionByID(petriNet, TemplateConstants.SERVICE_SERVER_OUTPUT_TRANSITION + "-" + channel_suffix));
outputToFeedbackArc.setTarget(serverFeedbackPlace);
topPage.addObject(outputToFeedbackArc);
// flush // flush
petriNet.flushTreeCache(); petriNet.flushTreeCache();
......
...@@ -92,6 +92,51 @@ ...@@ -92,6 +92,51 @@
</graphics> </graphics>
</place> </place>
<!-- new places after rework -->
<place id="ServiceToQueuePlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>none</location>
<subnet>none</subnet>
<type>discretePlaceType</type>
<outputsignalbindings>
</outputsignalbindings>
</toolspecific>
<name>
<text>ServiceToQueuePlace</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<initialMarking>
<text>0</text>
</initialMarking>
<graphics>
<position x="0" y="0"/>
</graphics>
</place>
<place id="ServiceQueueToServerPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>none</location>
<subnet>none</subnet>
<type>discretePlaceType</type>
<outputsignalbindings>
</outputsignalbindings>
</toolspecific>
<name>
<text>ServiceQueueToServerPlace</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<initialMarking>
<text>0</text>
</initialMarking>
<graphics>
<position x="0" y="0"/>
</graphics>
</place>
<transition id="ServiceClientInputTransition"> <transition id="ServiceClientInputTransition">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>none</location> <location>none</location>
...@@ -172,24 +217,6 @@ ...@@ -172,24 +217,6 @@
</graphics> </graphics>
</transition> </transition>
<arc id="arc-1" source="ServiceTogglePlace" target="ServiceClientInputTransition">
</arc>
<arc id="arc-2" source="ServiceClientInputTransition" target="ClientToServicePlace">
</arc>
<!-- <arc id="arc-3" source="ClientToServicePlace" target="ServiceServerInputTransition">
</arc> -->
<arc id="arc-4" source="ServiceServerInputTransition" target="InputToOutputServicePlace">
</arc>
<arc id="arc-5" source="InputToOutputServicePlace" target="ServiceServerOutputTransition">
</arc>
<arc id="arc-6" source="ServiceServerOutputTransition" target="ServiceOutputPlace">
</arc>
<arc id="arc-7" source="ServiceOutputPlace" target="ServiceClientOutputTransition">
</arc>
<arc id="arc-8" source="ServiceClientOutputTransition" target="ServiceTogglePlace">
</arc>
<!-- Elements new in v3 -->
<transition id="ServiceClientConnectorTransition"> <transition id="ServiceClientConnectorTransition">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>none</location> <location>none</location>
...@@ -210,9 +237,77 @@ ...@@ -210,9 +237,77 @@
</graphics> </graphics>
</transition> </transition>
<!-- new transitions after rework -->
<transition id="ServiceQueueConnectorTransition">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>none</location>
<subnet>none</subnet>
<type>discreteTransitionType</type>
<inputsignalbindings>
</inputsignalbindings>
<inputsignalclause></inputsignalclause>
</toolspecific>
<name>
<text>ServiceQueueConnectorTransition</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="0" y="0"/>
</graphics>
</transition>
<transition id="ServiceQueueOverflowTransition">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>none</location>
<subnet>none</subnet>
<type>discreteTransitionType</type>
<inputsignalbindings>
</inputsignalbindings>
<inputsignalclause></inputsignalclause>
</toolspecific>
<name>
<text>ServiceQueueOverflowTransition</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="0" y="0"/>
</graphics>
</transition>
<arc id="arc-1" source="ServiceTogglePlace" target="ServiceClientInputTransition">
</arc>
<arc id="arc-2" source="ServiceClientInputTransition" target="ClientToServicePlace">
</arc>
<!-- <arc id="arc-3" source="ClientToServicePlace" target="ServiceServerInputTransition">
</arc> -->
<arc id="arc-4" source="ServiceServerInputTransition" target="InputToOutputServicePlace">
</arc>
<arc id="arc-5" source="InputToOutputServicePlace" target="ServiceServerOutputTransition">
</arc>
<arc id="arc-6" source="ServiceServerOutputTransition" target="ServiceOutputPlace">
</arc>
<arc id="arc-7" source="ServiceOutputPlace" target="ServiceClientOutputTransition">
</arc>
<arc id="arc-8" source="ServiceClientOutputTransition" target="ServiceTogglePlace">
</arc>
<!-- new arcs after rework -->
<arc id="arc-9" source="ClientToServicePlace" target="ServiceClientConnectorTransition"> <arc id="arc-9" source="ClientToServicePlace" target="ServiceClientConnectorTransition">
</arc> </arc>
<arc id="arc-10" source="ServiceQueueConnectorTransition" target="ServiceToQueuePlace">
</arc>
<arc id="arc-11" source="ServiceToQueuePlace" target="ServiceQueueConnectorTransition">
</arc>
<arc id="arc-12" source="ServiceToQueuePlace" target="ServiceQueueOverflowTransition">
</arc>
<arc id="arc-13" source="ServiceQueueConnectorTransition" target="ServiceQueueToServerPlace">
</arc>
</page> </page>
</net> </net>
</pnml> </pnml>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment