From 65d2c74054a1e1e34dc74c5a790e0a88752bcd87 Mon Sep 17 00:00:00 2001 From: SebastianEbert <sebastian.ebert@tu-dresden.de> Date: Fri, 1 Oct 2021 17:20:03 +0200 Subject: [PATCH] service example, service keys, documentation --- README.md | 31 ++- .../inf/st/constants/PnmlConstants.java | 31 ++- .../inf/st/pnml/ToolSpecificsParser.java | 5 +- .../GlobalToLocalNetsPostProcessor.java | 16 +- .../IoPetriNetPostProcessor.java | 2 +- src/main/nets/serviceTestNet1.pnml | 182 ++++++++++++++++++ 6 files changed, 248 insertions(+), 19 deletions(-) create mode 100644 src/main/nets/serviceTestNet1.pnml diff --git a/README.md b/README.md index bc523cb..422eeb4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,30 @@ -# pnml-relast-splitter +# Petri Net Splitter Tool -* Currently not supported: reference-places and reference transitions \ No newline at end of file +This is the 3rd tool of the DiNeROS model driven tool chain. The input of this tool as an (extended) PNML-described Global ROS Petri Net. +Based on the localization information contained in the corresponding subnets for target ROS node is created, theses subnets are containing special transitions and places respresenting the inputs and outputs of ROS publishers/subscribers or and service clients and servers. + +## The Programflow + +1. Global ROS Petri Net (**PNML**) +2. Parsed Representation (**Jastadd**) +3. Splitted Local ROS Petri Net (**Jastadd**) +4. Splitted Local ROS Petri Net (**PNML**) + +## How Publisher and subscribers are transformed + +1. Get location/subnet of source/target - places +2. Create new source and target Transition +3. Attributized infos need to be written back to XML +4. Reconnect Input Signals +5. Get all incoming arcs and connect them to new output transition +6. Gel all outgoing arcs and connect them to new input transition +7. Add new transitions to net +8. Remove "old transition" + +## How Service Clients and Servers are tranformed + +TBD + +## Currently not supported pnml features + +* reference-places and reference transitions \ No newline at end of file diff --git a/src/main/java/de/tudresden/inf/st/constants/PnmlConstants.java b/src/main/java/de/tudresden/inf/st/constants/PnmlConstants.java index 1c87660..dcbf9ad 100644 --- a/src/main/java/de/tudresden/inf/st/constants/PnmlConstants.java +++ b/src/main/java/de/tudresden/inf/st/constants/PnmlConstants.java @@ -2,27 +2,48 @@ package de.tudresden.inf.st.constants; public final class PnmlConstants { + // general transitions public static final String TRANSITION_TYPE_DISCRETE = "discreteTransitionType"; public static final String TRANSITION_TYPE_CONTINUOUS = "continuousTransitionType"; + // topic transitions public static final String TRANSITION_TYPE_TOPIC = "topicTransitionType"; - public static final String TRANSITION_TOPIC_TYPE_LIMITED_IN = "limitedChannelInType"; - public static final String TRANSITION_TOPIC_TYPE_UNLIMITED_IN = "unlimitedChannelInType"; + public static final String TRANSITION_TYPE_TOPIC_LIMITED_IN = "limitedChannelInType"; + public static final String TRANSITION_TYPE_TOPIC_UNLIMITED_IN = "unlimitedChannelInType"; - public static final String TRANSITION_TOPIC_TYPE_LIMITED_OUT = "limitedChannelOutType"; - public static final String TRANSITION_TOPIC_TYPE_UNLIMITED_OUT = "unlimitedChannelOutType"; + public static final String TRANSITION_TYPE_TOPIC_LIMITED_OUT = "limitedChannelOutType"; + public static final String TRANSITION_TYPE_TOPIC_UNLIMITED_OUT = "unlimitedChannelOutType"; + // service transitions + public static final String TRANSITION_TYPE_SERVICE_REQUEST = "serviceTransitionTypeRequest"; + public static final String TRANSITION_TYPE_SERVICE_RESPONSE = "serviceTransitionTypeResponse"; + + public static final String TRANSITION_TYPE_SERVICE_REQUEST_IN = "serviceTransitionRequestIn"; + public static final String TRANSITION_TYPE_SERVICE_REQUEST_OUT = "serviceTransitionRequestOut"; + + public static final String TRANSITION_TYPE_SERVICE_RESPONSE_IN = "serviceTransitionResponseIn"; + public static final String TRANSITION_TYPE_SERVICE_RESPONSE_OUT = "serviceTransitionResponseOut"; + + // place types public static final String PLACE_TYPE_DISCRETE = "discretePlaceType"; public static final String PLACE_TYPE_CONTINUOUS = "continuousPlaceType"; + // general properties public static final String LOCATION_KEY = "location"; public static final String TYPE_KEY = "type"; + + // service related keys + public static final String SERVICE_NAME = "serviceName"; + public static final String SERVICE_INSTANCE = "serviceInstance"; + + // pub-sub related keys public static final String INPUT_LIMIT_KEY = "inputlimit"; public static final String OUTPUT_LIMIT_KEY = "outputlimit"; public static final String SUBNET_KEY = "subnet"; public static final String TOPIC_KEY = "topic"; + // bindings public static final String INPUT_SIGNAL_BINDINGS_KEY = "inputsignalbindings"; public static final String OUTPUT_SIGNAL_BINDINGS_KEY = "outputsignalbindings"; @@ -37,7 +58,7 @@ public final class PnmlConstants { public static final String EQUAL_OS_KEY = "equal"; public static final String RANGE_OS_KEY = "range"; - public static final String TRESHOLD_KEY = "threshold"; + public static final String THRESHOLD_KEY = "threshold"; public static final String VALUE_KEY = "value"; public static final String RESULT_KEY = "result"; diff --git a/src/main/java/de/tudresden/inf/st/pnml/ToolSpecificsParser.java b/src/main/java/de/tudresden/inf/st/pnml/ToolSpecificsParser.java index a0bc6f5..34d132b 100644 --- a/src/main/java/de/tudresden/inf/st/pnml/ToolSpecificsParser.java +++ b/src/main/java/de/tudresden/inf/st/pnml/ToolSpecificsParser.java @@ -5,7 +5,6 @@ import de.tudresden.inf.st.pnml.jastadd.model.JastAddList; import de.tudresden.inf.st.pnml.jastadd.model.PlaceInformation; import de.tudresden.inf.st.pnml.jastadd.model.ToolInfo; -import javax.tools.Tool; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; @@ -78,8 +77,8 @@ public class ToolSpecificsParser { if (typeList.getLength() > 0 && typeList.item(0) != null) { String type = typeList.item(0).getTextContent(); - if (type.equals(PnmlConstants.TRANSITION_TOPIC_TYPE_LIMITED_IN) || type.equals(PnmlConstants.TRANSITION_TOPIC_TYPE_LIMITED_OUT) - || type.equals(PnmlConstants.TRANSITION_TOPIC_TYPE_UNLIMITED_IN) || type.equals(PnmlConstants.TRANSITION_TOPIC_TYPE_UNLIMITED_OUT) + if (type.equals(PnmlConstants.TRANSITION_TYPE_TOPIC_LIMITED_IN) || type.equals(PnmlConstants.TRANSITION_TYPE_TOPIC_LIMITED_OUT) + || type.equals(PnmlConstants.TRANSITION_TYPE_TOPIC_UNLIMITED_IN) || type.equals(PnmlConstants.TRANSITION_TYPE_TOPIC_UNLIMITED_OUT) || type.equals(PnmlConstants.TRANSITION_TYPE_TOPIC)) { NodeList topicList = doc.getElementsByTagName(PnmlConstants.TOPIC_KEY); diff --git a/src/main/java/de/tudresden/inf/st/postprocessing/GlobalToLocalNetsPostProcessor.java b/src/main/java/de/tudresden/inf/st/postprocessing/GlobalToLocalNetsPostProcessor.java index 0270e96..896faef 100644 --- a/src/main/java/de/tudresden/inf/st/postprocessing/GlobalToLocalNetsPostProcessor.java +++ b/src/main/java/de/tudresden/inf/st/postprocessing/GlobalToLocalNetsPostProcessor.java @@ -138,13 +138,13 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> { if (channelIst.getStaticTransitionInformation().getInputLimit() >= 0) { - tInfoSource.setType(PnmlConstants.TRANSITION_TOPIC_TYPE_LIMITED_OUT); - inputToolInfoJastAddList.add(buildToolSpecifics(PnmlConstants.TRANSITION_TOPIC_TYPE_LIMITED_OUT, inLocation, inSubNet, tInfoSource.getTopic(), + tInfoSource.setType(PnmlConstants.TRANSITION_TYPE_TOPIC_LIMITED_OUT); + inputToolInfoJastAddList.add(buildToolSpecifics(PnmlConstants.TRANSITION_TYPE_TOPIC_LIMITED_OUT, inLocation, inSubNet, tInfoSource.getTopic(), channelIst.getStaticTransitionInformation().getInputLimit(), channelIst.getStaticTransitionInformation().getOutputLimit(), channelIst.getStaticInputSignalBindingList())); } else { - tInfoSource.setType(PnmlConstants.TRANSITION_TOPIC_TYPE_UNLIMITED_OUT); - inputToolInfoJastAddList.add(buildToolSpecifics(PnmlConstants.TRANSITION_TOPIC_TYPE_UNLIMITED_OUT, inLocation, inSubNet, tInfoSource.getTopic(), + tInfoSource.setType(PnmlConstants.TRANSITION_TYPE_TOPIC_UNLIMITED_OUT); + inputToolInfoJastAddList.add(buildToolSpecifics(PnmlConstants.TRANSITION_TYPE_TOPIC_UNLIMITED_OUT, inLocation, inSubNet, tInfoSource.getTopic(), channelIst.getStaticTransitionInformation().getInputLimit(), channelIst.getStaticTransitionInformation().getOutputLimit(), channelIst.getStaticInputSignalBindingList())); } @@ -164,12 +164,12 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> { JastAddList<ToolInfo> outputToolInfoJastAddList = new JastAddList<>(); if (channelIst.getStaticTransitionInformation().getOutputLimit() >= 0) { - tInfoTarget.setType(PnmlConstants.TRANSITION_TOPIC_TYPE_LIMITED_IN); - outputToolInfoJastAddList.add(buildToolSpecifics(PnmlConstants.TRANSITION_TOPIC_TYPE_LIMITED_IN, outLocation, outSubNet, tInfoTarget.getTopic(), + tInfoTarget.setType(PnmlConstants.TRANSITION_TYPE_TOPIC_LIMITED_IN); + outputToolInfoJastAddList.add(buildToolSpecifics(PnmlConstants.TRANSITION_TYPE_TOPIC_LIMITED_IN, outLocation, outSubNet, tInfoTarget.getTopic(), channelIst.getStaticTransitionInformation().getInputLimit(), channelIst.getStaticTransitionInformation().getOutputLimit(), null)); } else { - tInfoTarget.setType(PnmlConstants.TRANSITION_TOPIC_TYPE_UNLIMITED_IN); - outputToolInfoJastAddList.add(buildToolSpecifics(PnmlConstants.TRANSITION_TOPIC_TYPE_UNLIMITED_IN, outLocation, outSubNet, tInfoTarget.getTopic(), + tInfoTarget.setType(PnmlConstants.TRANSITION_TYPE_TOPIC_UNLIMITED_IN); + outputToolInfoJastAddList.add(buildToolSpecifics(PnmlConstants.TRANSITION_TYPE_TOPIC_UNLIMITED_IN, outLocation, outSubNet, tInfoTarget.getTopic(), channelIst.getStaticTransitionInformation().getInputLimit(), channelIst.getStaticTransitionInformation().getOutputLimit(), null)); } diff --git a/src/main/java/de/tudresden/inf/st/postprocessing/IoPetriNetPostProcessor.java b/src/main/java/de/tudresden/inf/st/postprocessing/IoPetriNetPostProcessor.java index 74d8811..a262bd7 100644 --- a/src/main/java/de/tudresden/inf/st/postprocessing/IoPetriNetPostProcessor.java +++ b/src/main/java/de/tudresden/inf/st/postprocessing/IoPetriNetPostProcessor.java @@ -129,7 +129,7 @@ public class IoPetriNetPostProcessor implements PostProcessor<PetriNet> { osb.setPlaceID(pID); NodeList eqMappingNodeList = osBindingElement.getElementsByTagName(PnmlConstants.EQUAL_OS_KEY); - NodeList thresholdMappingNodeList = osBindingElement.getElementsByTagName(PnmlConstants.TRESHOLD_KEY); + NodeList thresholdMappingNodeList = osBindingElement.getElementsByTagName(PnmlConstants.THRESHOLD_KEY); NodeList rangeMappingNodeList = osBindingElement.getElementsByTagName(PnmlConstants.RANGE_OS_KEY); for (int j = 0; j < eqMappingNodeList.getLength(); j++) { diff --git a/src/main/nets/serviceTestNet1.pnml b/src/main/nets/serviceTestNet1.pnml new file mode 100644 index 0000000..f4c0f14 --- /dev/null +++ b/src/main/nets/serviceTestNet1.pnml @@ -0,0 +1,182 @@ +<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> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + </toolspecific> + <page id="g-E2D0-BCF68-1"> + <place id="p1"> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + <location>node-1</location> + <subnet>subnet-1</subnet> + <type>discretePlaceType</type> + <outputsignalbindings> + <outputsignalbinding> + <placeID>p1</placeID> + <outputsignalID>os2</outputsignalID> + <initialvalue>1</initialvalue> <!-- -1 = undefined --> + <outputmappings> + <equal> + <value>1</value> + <result>3</result> + </equal> + <equal> + <value>0</value> + <result>2</result> + </equal> + <threshold> + <value>6</value> + <result>0</result> + </threshold> + <range> + <upperbound>5</upperbound> + <lowerbound>3</lowerbound> + <result>1</result> + </range> + </outputmappings> + </outputsignalbinding> + </outputsignalbindings> + </toolspecific> + <name> + <text>p1</text> + <graphics> + <offset x="0" y="-10" /> + </graphics> + </name> + <initialMarking> + <text>1</text> + </initialMarking> + <graphics> + <position x="30" y="50"/> + </graphics> + </place> + <place id="p2"> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + <location>node-2</location> + <subnet>subnet-2</subnet> + <type>discretePlaceType</type> + <outputsignalbindings> + <outputsignalbinding> + <placeID>p2</placeID> + <outputsignalID>os1</outputsignalID> + <initialvalue>4</initialvalue> <!-- -1 = undefined --> + <outputmappings> + <equal> + <value>1</value> + <result>1</result> + </equal> + <threshold> + <value>6</value> + <result>0</result> + </threshold> + <range> + <upperbound>5</upperbound> + <lowerbound>3</lowerbound> + <result>1</result> + </range> + </outputmappings> + </outputsignalbinding> + </outputsignalbindings> + </toolspecific> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + </toolspecific> + <name> + <text>p2</text> + <graphics> + <offset x="0" y="-10" /> + </graphics> + </name> + <initialMarking> + <text>0</text> + </initialMarking> + <graphics> + <position x="635" y="90"/> + </graphics> + </place> + + <place id="p3"> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + <location>node-2</location> + <subnet>subnet-2</subnet> + <type>discretePlaceType</type> + </toolspecific> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + </toolspecific> + <name> + <text>p2</text> + <graphics> + <offset x="0" y="-10" /> + </graphics> + </name> + <initialMarking> + <text>0</text> + </initialMarking> + <graphics> + <position x="635" y="90"/> + </graphics> + </place> + + <place id="p4"> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + <location>node-1</location> + <subnet>subnet-1</subnet> + <type>discretePlaceType</type> + </toolspecific> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + </toolspecific> + <name> + <text>p4</text> + <graphics> + <offset x="0" y="-10" /> + </graphics> + </name> + <initialMarking> + <text>0</text> + </initialMarking> + <graphics> + <position x="635" y="90"/> + </graphics> + </place> + + <transition id="t1"> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + <location>channel</location> + <subnet>channel</subnet> + <type>serviceTransitionTypeRequest</type> + <serviceName>sampleService</serviceName> + </toolspecific> + <name> + <text>t1</text> + <graphics> + <offset x="0" y="0" /> + </graphics> + </name> + <graphics> + <position x="300" y="50"/> + </graphics> + </transition> + <transition id="t2"> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + <location>channel</location> + <subnet>channel</subnet> + <type>serviceTransitionTypeResponse</type> + <serviceName>sampleService</serviceName> + </toolspecific> + <name> + <text>t2</text> + <graphics> + <offset x="0" y="0" /> + </graphics> + </name> + <graphics> + <position x="300" y="50"/> + </graphics> + </transition> + <arc id="arc-p3-t2" source="p3" target="t2"> + </arc> + <arc id="arc-t2-p4" source="t2" target="p4"> + </arc> + </page> + </net> +</pnml> \ No newline at end of file -- GitLab