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

fixed configuration reader, fixed flattening of topics

parent 2bba6dfb
No related branches found
No related tags found
No related merge requests found
No preview for this file type
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
{
"tina" : "-R -s 1 -c 0 -t 0 -b 0 -m 0 -v -PNML -bcg",
"pathto" : "",
"sift" : "",
"struct" : ""
}
\ No newline at end of file
...@@ -3,6 +3,7 @@ package de.tudresden.inf.st.pnml.flatter; ...@@ -3,6 +3,7 @@ package de.tudresden.inf.st.pnml.flatter;
import de.tudresden.inf.st.pnml.flatter.config.ConfigReader; import de.tudresden.inf.st.pnml.flatter.config.ConfigReader;
import de.tudresden.inf.st.pnml.flatter.transform.ChannelFlatter; import de.tudresden.inf.st.pnml.flatter.transform.ChannelFlatter;
import de.tudresden.inf.st.pnml.flatter.transform.ReferenceFlatter; import de.tudresden.inf.st.pnml.flatter.transform.ReferenceFlatter;
import de.tudresden.inf.st.pnml.jastadd.model.*;
import de.tudresden.inf.st.pnml.jastadd.model.PnmlParser; import de.tudresden.inf.st.pnml.jastadd.model.PnmlParser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -28,7 +29,8 @@ public class Main { ...@@ -28,7 +29,8 @@ public class Main {
}*/ }*/
// parse the global not flatted petri net // parse the global not flatted petri net
pnmlPath = "pnml-relast-flatter/src/main/resources/minimal.pnml"; pnmlPath = "../pnml-relast-nets/src/main/resources/topicTestNets/structureTestNets/topic-structure-correct-3.pnml";
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
...@@ -46,10 +48,12 @@ public class Main { ...@@ -46,10 +48,12 @@ public class Main {
// flat topic publishers / subscribers to instance based semantics // flat topic publishers / subscribers to instance based semantics
logger.info("[FLATTER] Breaking down topic channels."); logger.info("[FLATTER] Breaking down topic channels.");
PetriNet topicFlattedPetriNet = ChannelFlatter.flatTopicChannels(petriNet); PetriNet topicFlattedPetriNet = ChannelFlatter.flatTopicChannels(petriNet);
printNet(topicFlattedPetriNet);
// flat service clients / servers to instance based semantics // flat service clients / servers to instance based semantics
logger.info("[FLATTER] Breaking down service channels."); logger.info("[FLATTER] Breaking down service channels.");
PetriNet serviceFlattedPetriNet = ChannelFlatter.flatTopicChannels(topicFlattedPetriNet); // PetriNet serviceFlattedPetriNet = ChannelFlatter.flatServiceChannels(topicFlattedPetriNet);
// flat input signals // flat input signals
...@@ -60,8 +64,8 @@ public class Main { ...@@ -60,8 +64,8 @@ public class Main {
// TODO // TODO
// convert and add inhibitor arcs // convert and add inhibitor arcs
NdrioProxy ndrioProxy = new NdrioProxy(); // NdrioProxy ndrioProxy = new NdrioProxy();
ndrioProxy.pnml2net(pnmlPath, "pnml-relast-flatter/src/main/resources/minimal.net"); // ndrioProxy.pnml2net(pnmlPath, "pnml-relast-flatter/src/main/resources/minimal.net");
// insert into tina // insert into tina
...@@ -84,4 +88,91 @@ public class Main { ...@@ -84,4 +88,91 @@ public class Main {
// TODO // TODO
} }
public static void printNet(PetriNet petriNet) {
logger.error("--------------- STRUCTURE ---------------");
logger.error("----------------- PLACES ----------------");
for (Place p : petriNet.allPlaces()) {
//logger.error("id: " + p.getId());
logger.error("Place " + p.asOutputSignalPlace().getId() + " -- " + p.asOutputSignalPlace().getStaticPlaceInformation().getSubNet());
}
logger.error("-------------- TRANSITIONS --------------");
for (Transition t : petriNet.allTransitions()) {
if (t.asInputSignalTransition().getStaticTransitionInformation().isServiceTransitionInformation()) {
logger.error("--- Transition: " + t.getId() + " subnet: " + t.asInputSignalTransition().getStaticTransitionInformation().getSubNet()
+ " service: " + t.asInputSignalTransition().getStaticTransitionInformation().asServiceTransitionInformation().getServiceName() + " ---------");
} else if(t.asInputSignalTransition().getStaticTransitionInformation().isTopicTransitionInformation()){
logger.error("--- Transition: " + t.getId() + " subnet: " + t.asInputSignalTransition().getStaticTransitionInformation().getSubNet()
+ " topic: " + t.asInputSignalTransition().getStaticTransitionInformation().asTopicTransitionInformation().getTopic() + " ---------");
}else{
logger.error("--- Transition: " + t.getId());
}
if(t.asInputSignalTransition().getInputSignalClause() != null && t.asInputSignalTransition().getInputSignalClause().getNumChild() > 0){
// logger.error("------ Clause: " + t.asInputSignalTransition().getInputSignalClause().printExp());
}
for (Place p : t.asInputSignalTransition().incomingPlaces()) {
logger.error("------ Inputplace: " + p.getId() + " subnet: " + p.asOutputSignalPlace().getStaticPlaceInformation().getSubNet() + " ---------");
}
for (Place p : t.asInputSignalTransition().outgoingPlaces()) {
logger.error("------ Outputplace: " + p.getId() + " subnet: " + p.asOutputSignalPlace().getStaticPlaceInformation().getSubNet() + " ---------");
}
}
logger.error("----------------- REF PLACES -----------------");
for (RefPlace rp : petriNet.allRefPlaces()){
logger.error("--- RefPlace: " + rp.getId());
}
logger.error("----------------- REF TRANSITIONS -----------------");
for (RefTransition rt : petriNet.allRefTransitions()){
logger.error("--- RefTransition: " + rt.getId());
}
logger.error("----------------- ARCS -----------------");
for (Arc a : petriNet.allArcs()) {
logger.error("Arc: " + a.getId() + " -- source: " + a.getSource().getId() + " -- target: " + a.getTarget().getId());
}
logger.error("--------------- T SIGNALS (STATIC)---------------");
for (Transition t : petriNet.allTransitions()) {
InputSignalTransition ist = t.asInputSignalTransition();
if (ist != null && ist.getStaticInputSignalBindingList() != null) {
ist.getStaticInputSignalBindingList().forEach(inputSignalBinding -> logger.error(" (" + t.getName().getText() + ") Signal: " + inputSignalBinding.getInputSignalID()));
}
}
logger.error("--------------- T SIGNALS (MUTUAL)---------------");
for (Transition t : petriNet.allTransitions()) {
InputSignalTransition ist = t.asInputSignalTransition();
if (ist != null && ist.getMutualInputSignalBindingList() != null) {
ist.getMutualInputSignalBindingList().forEach(inputSignalBinding -> logger.error(" (" + t.getName().getText() + ") Signal: " + inputSignalBinding.getInputSignalID()));
}
}
// logger.error("--------------- TOOL SPECIFIC ---------------");
for (Transition t : petriNet.allTransitions()) {
InputSignalTransition ist = t.asInputSignalTransition();
if(ist != null && ist.getNumToolspecific() > 0) {
// logger.error("ToolSpecific: (" + ist.getName().getText() + ") " + ist.getToolspecific(0).getFormattedXMLBuffer().toString());
}
}
}
} }
...@@ -49,6 +49,7 @@ public class ConfigReader { ...@@ -49,6 +49,7 @@ public class ConfigReader {
public String[] getTinaConfigParams(){ public String[] getTinaConfigParams(){
Gson gson = new Gson(); Gson gson = new Gson();
System.out.println("Content " + getConfigFileContent());
FlatterConfig fc = gson.fromJson(getConfigFileContent(), FlatterConfig.class); FlatterConfig fc = gson.fromJson(getConfigFileContent(), FlatterConfig.class);
return fc.tina.split(" "); return fc.tina.split(" ");
} }
......
...@@ -7,11 +7,13 @@ public final class TemplateConstants { ...@@ -7,11 +7,13 @@ public final class TemplateConstants {
public static final String PUBLISHER_CONNECTOR_PLACE = "PublisherConnectorPlace"; public static final String PUBLISHER_CONNECTOR_PLACE = "PublisherConnectorPlace";
public static final String PUBLISHER_INPUT_TRANSITION = "PublisherInputTransition"; public static final String PUBLISHER_INPUT_TRANSITION = "PublisherInputTransition";
public static final String PUBLISHER_OVERFLOW_TRANSITION = "PublisherOverflowTransition"; public static final String PUBLISHER_OVERFLOW_TRANSITION = "PublisherOverflowTransition";
public static final String PUBLISHER_OUTPUT_TRANSITION = "PublisherOverflowTransition"; public static final String PUBLISHER_OUTPUT_TRANSITION = "PublisherOutputTransition";
// topic dispatcher // topic dispatcher
public static final String DISPATCHER_INPUT_TRANSITION = "DispatcherInputTransition"; public static final String DISPATCHER_INPUT_TRANSITION = "DispatcherInputTransition";
public static final String DISPATCHER_OUTPUT_TRANSITION = "DispatcherOutputTransition"; public static final String DISPATCHER_OUTPUT_TRANSITION = "DispatcherOutputTransition";
public static final String DISPATCHER_INPUT_PLACE = "DispatcherInputPlace";
public static final String DISPATCHER_OVERFLOW_TRANSITION = "DispatcherOverflowTransition";
// topic callback // topic callback
public static final String CALLBACK_INPUT_PLACE = "CallbackInputPlace"; public static final String CALLBACK_INPUT_PLACE = "CallbackInputPlace";
...@@ -26,4 +28,5 @@ public final class TemplateConstants { ...@@ -26,4 +28,5 @@ public final class TemplateConstants {
// channel elements // channel elements
public static final String CHANNEL_CONNECTOR_PLACE = "ChannelConnectorPlace"; public static final String CHANNEL_CONNECTOR_PLACE = "ChannelConnectorPlace";
public static final String CHANNEL_CONNECTOR_TRANSITION = "ChannelConnectorTransition"; public static final String CHANNEL_CONNECTOR_TRANSITION = "ChannelConnectorTransition";
} }
package de.tudresden.inf.st.pnml.flatter.template; package de.tudresden.inf.st.pnml.flatter.template;
import de.tudresden.inf.st.pnml.jastadd.model.Name;
import de.tudresden.inf.st.pnml.jastadd.model.PetriNet; import de.tudresden.inf.st.pnml.jastadd.model.PetriNet;
import de.tudresden.inf.st.pnml.jastadd.model.PnObject; import de.tudresden.inf.st.pnml.jastadd.model.PnObject;
import de.tudresden.inf.st.pnml.jastadd.model.PnmlParser; import de.tudresden.inf.st.pnml.jastadd.model.PnmlParser;
...@@ -8,12 +9,14 @@ public class TopicTemplates extends PnmlTemplate { ...@@ -8,12 +9,14 @@ public class TopicTemplates extends PnmlTemplate {
public static PetriNet getTopicPublisherPetriNet(String idSuffix){ public static PetriNet getTopicPublisherPetriNet(String idSuffix){
PetriNet templateNet = PnmlParser.parsePnml(homeDirectory + "/src/main/resources/TopicPublisherTemplate.pnml").get(0); PetriNet templateNet = PnmlParser.parsePnml(homeDirectory + "/src/main/resources/templates/TopicPublisherTemplate.pnml").get(0);
for(PnObject po : templateNet.allObjects()){ for(PnObject po : templateNet.allObjects()){
if(!po.getId().equals(TemplateConstants.PUBLISHER_TEMPLATE_PAGE)){ if(!po.getId().equals(TemplateConstants.PUBLISHER_TEMPLATE_PAGE)){
po.setId(po.getId() + "-" + idSuffix); po.setId(po.getId() + "-" + idSuffix);
po.getName().setText(po.getName().getText() + "-" + idSuffix); Name name = new Name();
name.setText(po.getId() + "-" + idSuffix);
po.setName(name);
} }
} }
...@@ -22,12 +25,14 @@ public class TopicTemplates extends PnmlTemplate { ...@@ -22,12 +25,14 @@ public class TopicTemplates extends PnmlTemplate {
public static PetriNet getTopicDispatcherPetriNet(String idSuffix){ public static PetriNet getTopicDispatcherPetriNet(String idSuffix){
PetriNet templateNet = PnmlParser.parsePnml(homeDirectory + "/src/main/resources/TopicSubDispatcherTemplate.pnml").get(0); PetriNet templateNet = PnmlParser.parsePnml(homeDirectory + "/src/main/resources/templates/TopicSubDispatcherTemplate.pnml").get(0);
for(PnObject po : templateNet.allObjects()){ for(PnObject po : templateNet.allObjects()){
if(!po.getId().equals(TemplateConstants.DISPATCHER_TEMPLATE_PAGE)){ if(!po.getId().equals(TemplateConstants.DISPATCHER_TEMPLATE_PAGE)){
po.setId(po.getId() + "-" + idSuffix); po.setId(po.getId() + "-" + idSuffix);
po.getName().setText(po.getName().getText() + "-" + idSuffix); Name name = new Name();
name.setText(po.getId() + "-" + idSuffix);
po.setName(name);
} }
} }
...@@ -36,12 +41,14 @@ public class TopicTemplates extends PnmlTemplate { ...@@ -36,12 +41,14 @@ public class TopicTemplates extends PnmlTemplate {
public static PetriNet getTopicCallbackQueuePetriNet(String idSuffix){ public static PetriNet getTopicCallbackQueuePetriNet(String idSuffix){
PetriNet templateNet = PnmlParser.parsePnml(homeDirectory + "/src/main/resources/TopicSubCallbackQueueTemplate.pnml").get(0); PetriNet templateNet = PnmlParser.parsePnml(homeDirectory + "/src/main/resources/templates/TopicSubCallbackQueueTemplate.pnml").get(0);
for(PnObject po : templateNet.allObjects()){ for(PnObject po : templateNet.allObjects()){
if(!po.getId().equals(TemplateConstants.CALLBACK_QUEUE_TEMPLATE_PAGE)){ if(!po.getId().equals(TemplateConstants.CALLBACK_QUEUE_TEMPLATE_PAGE)){
po.setId(po.getId() + "-" + idSuffix); po.setId(po.getId() + "-" + idSuffix);
po.getName().setText(po.getName().getText() + "-" + idSuffix); Name name = new Name();
name.setText(po.getId() + "-" + idSuffix);
po.setName(name);
} }
} }
......
package de.tudresden.inf.st.pnml.flatter.transform; package de.tudresden.inf.st.pnml.flatter.transform;
import de.tudresden.inf.st.pnml.base.constants.PnmlConstants;
import de.tudresden.inf.st.pnml.flatter.template.TemplateConstants; import de.tudresden.inf.st.pnml.flatter.template.TemplateConstants;
import de.tudresden.inf.st.pnml.flatter.template.TopicTemplates; import de.tudresden.inf.st.pnml.flatter.template.TopicTemplates;
import de.tudresden.inf.st.pnml.jastadd.model.*; import de.tudresden.inf.st.pnml.jastadd.model.*;
...@@ -22,6 +23,8 @@ public class ChannelFlatter { ...@@ -22,6 +23,8 @@ public class ChannelFlatter {
int channelCount = 0; int channelCount = 0;
List<Transition> topicTransitions = new ArrayList<>(); List<Transition> topicTransitions = new ArrayList<>();
List<Arc> arcsToRemove = new ArrayList<>();
List<Transition> transitionsToRemove = new ArrayList<>();
// process topic transitions // process topic transitions
for(Transition t : petriNet.allTransitions()){ for(Transition t : petriNet.allTransitions()){
...@@ -61,13 +64,17 @@ public class ChannelFlatter { ...@@ -61,13 +64,17 @@ public class ChannelFlatter {
for (Map.Entry<String, Place> entry : inputMapping.entrySet()) { for (Map.Entry<String, Place> entry : inputMapping.entrySet()) {
// include the template publisher // include the template publisher
PetriNet publisherPetriNet = TopicTemplates.getTopicPublisherPetriNet("-" + publisherCount); PetriNet publisherPetriNet = TopicTemplates.getTopicPublisherPetriNet(String.valueOf(publisherCount));
includeTemplateInstance(petriNet, publisherPetriNet, entry.getKey(), entry.getValue().asOutputSignalPlace().getStaticPlaceInformation().getLocation()); includeTemplateInstance(petriNet, publisherPetriNet, entry.getKey(), entry.getValue().asOutputSignalPlace().getStaticPlaceInformation().getLocation());
// connect the publisher inputs // connect the publisher inputs
Arc inputArc = new Arc(); Arc inputArc = new Arc();
Arc overFlowArc = new Arc(); Arc overFlowArc = new Arc();
Arc outArc = new Arc(); Arc outArc = new Arc();
inputArc.setId("pub-inputArc-" + publisherCount);
overFlowArc.setId("pub-overFlowArc-" + publisherCount);
outArc.setId("pub-outArc-" + publisherCount);
inputArc.setSource(entry.getValue()); inputArc.setSource(entry.getValue());
inputArc.setTarget((Node) getPnObjectByID(petriNet, TemplateConstants.PUBLISHER_INPUT_TRANSITION + "-" + publisherCount)); inputArc.setTarget((Node) getPnObjectByID(petriNet, TemplateConstants.PUBLISHER_INPUT_TRANSITION + "-" + publisherCount));
...@@ -92,12 +99,13 @@ public class ChannelFlatter { ...@@ -92,12 +99,13 @@ public class ChannelFlatter {
for (Map.Entry<String, List<Place>> entry : outputMapping.entrySet()) { for (Map.Entry<String, List<Place>> entry : outputMapping.entrySet()) {
// include dispatcher queues // include dispatcher queues
PetriNet dispatcherNet = TopicTemplates.getTopicDispatcherPetriNet("-" + dispatcherCount); PetriNet dispatcherNet = TopicTemplates.getTopicDispatcherPetriNet(String.valueOf(dispatcherCount));
includeTemplateInstance(petriNet, dispatcherNet, entry.getKey(), entry.getValue().get(0).asOutputSignalPlace().getStaticPlaceInformation().getLocation()); includeTemplateInstance(petriNet, dispatcherNet, entry.getKey(), entry.getValue().get(0).asOutputSignalPlace().getStaticPlaceInformation().getLocation());
Arc channelToDispatcherArc = new Arc(); Arc channelToDispatcherArc = new Arc();
channelToDispatcherArc.setId("channelToDispatcherArc-" + dispatcherCount);
channelToDispatcherArc.setSource((Node) getPnObjectByID(petriNet, TemplateConstants.CHANNEL_CONNECTOR_TRANSITION + "-" + channelCount)); channelToDispatcherArc.setSource((Node) getPnObjectByID(petriNet, TemplateConstants.CHANNEL_CONNECTOR_TRANSITION + "-" + channelCount));
channelToDispatcherArc.setTarget((Node) getPnObjectByID(petriNet, TemplateConstants.DISPATCHER_INPUT_TRANSITION + "-" + dispatcherCount)); channelToDispatcherArc.setTarget((Node) getPnObjectByID(petriNet, TemplateConstants.DISPATCHER_INPUT_PLACE + "-" + dispatcherCount));
topPage.addObject(channelToDispatcherArc); topPage.addObject(channelToDispatcherArc);
petriNet.flushTreeCache(); petriNet.flushTreeCache();
...@@ -105,15 +113,19 @@ public class ChannelFlatter { ...@@ -105,15 +113,19 @@ public class ChannelFlatter {
// include subscriber queues // include subscriber queues
for(Place p : entry.getValue()){ for(Place p : entry.getValue()){
PetriNet subscriberNet = TopicTemplates.getTopicCallbackQueuePetriNet("-" + callbackCount); PetriNet subscriberNet = TopicTemplates.getTopicCallbackQueuePetriNet(String.valueOf(callbackCount));
includeTemplateInstance(petriNet, subscriberNet, entry.getKey(), p.asOutputSignalPlace().getStaticPlaceInformation().getLocation()); includeTemplateInstance(petriNet, subscriberNet, entry.getKey(), p.asOutputSignalPlace().getStaticPlaceInformation().getLocation());
Arc callbackInputArc = new Arc(); Arc callbackInputArc = new Arc();
Arc callbackOverFlowArc = new Arc(); Arc callbackOverFlowArc = new Arc();
Arc callbackOutArc = new Arc(); Arc callbackOutArc = new Arc();
callbackInputArc.setId("callbackInputArc-" + dispatcherCount);
callbackOverFlowArc.setId("callbackOverFlowArc-" + dispatcherCount);
callbackOutArc.setId("callbackOutArc-" + dispatcherCount);
callbackInputArc.setSource((Node) getPnObjectByID(petriNet, TemplateConstants.DISPATCHER_OUTPUT_TRANSITION + "-" + dispatcherCount)); callbackInputArc.setSource((Node) getPnObjectByID(petriNet, TemplateConstants.DISPATCHER_OUTPUT_TRANSITION + "-" + dispatcherCount));
callbackOverFlowArc.setSource((Node) getPnObjectByID(petriNet, TemplateConstants.DISPATCHER_OUTPUT_TRANSITION + "-" + dispatcherCount)); callbackOverFlowArc.setSource((Node) getPnObjectByID(petriNet, TemplateConstants.CALLBACK_INPUT_PLACE + "-" + dispatcherCount));
callbackInputArc.setTarget((Node) getPnObjectByID(petriNet, TemplateConstants.CALLBACK_INPUT_PLACE + "-" + callbackCount)); callbackInputArc.setTarget((Node) getPnObjectByID(petriNet, TemplateConstants.CALLBACK_INPUT_PLACE + "-" + callbackCount));
callbackOverFlowArc.setTarget((Node) getPnObjectByID(petriNet, TemplateConstants.CALLBACK_OVERFLOW_TRANSITION + "-" + callbackCount)); callbackOverFlowArc.setTarget((Node) getPnObjectByID(petriNet, TemplateConstants.CALLBACK_OVERFLOW_TRANSITION + "-" + callbackCount));
...@@ -129,22 +141,45 @@ public class ChannelFlatter { ...@@ -129,22 +141,45 @@ public class ChannelFlatter {
petriNet.flushTreeCache(); petriNet.flushTreeCache();
// clean up old channel // objects to be cleaned up
arcsToRemove.addAll(t.getInArcs());
// TODO arcsToRemove.addAll(t.getOutArcs());
transitionsToRemove.add(t);
} }
channelCount++; channelCount++;
} }
return null; // clean up old channel data
for(Arc a : arcsToRemove){
a.removeSelf();
}
for(Transition t : transitionsToRemove){
t.removeSelf();
}
petriNet.flushTreeCache();
return petriNet;
} }
private static void insertChannelElements(PetriNet petriNet, int channelCount) { private static void insertChannelElements(PetriNet petriNet, int channelCount) {
Place channelPlace = new Place(); OutputSignalPlace channelPlace = new OutputSignalPlace();
Transition channelTransition = new Transition(); PlaceInformation newPi = new PlaceInformation();
newPi.setLocation("channel");
newPi.setSubNet("channel");
newPi.setType(PnmlConstants.PLACE_TYPE_DISCRETE);
channelPlace.setMutualPlaceInformation(newPi);
InputSignalTransition channelTransition = new InputSignalTransition();
TransitionInformation newTi = new DefaultTransitionInformation();
newTi.setLocation("channel");
newTi.setSubNet("channel");
newTi.setType(PnmlConstants.TRANSITION_TYPE_DISCRETE);
channelTransition.setMutualTransitionInformation(newTi);
channelPlace.setId(TemplateConstants.CHANNEL_CONNECTOR_PLACE + "-" + channelCount); channelPlace.setId(TemplateConstants.CHANNEL_CONNECTOR_PLACE + "-" + channelCount);
channelTransition.setId(TemplateConstants.CHANNEL_CONNECTOR_TRANSITION + "-" + channelCount); channelTransition.setId(TemplateConstants.CHANNEL_CONNECTOR_TRANSITION + "-" + channelCount);
...@@ -153,6 +188,12 @@ public class ChannelFlatter { ...@@ -153,6 +188,12 @@ public class ChannelFlatter {
topPage.addObject(channelPlace); topPage.addObject(channelPlace);
topPage.addObject(channelTransition); topPage.addObject(channelTransition);
Arc channelArc = new Arc();
channelArc.setId("ChannelArc-" + channelCount);
channelArc.setTarget(channelTransition);
channelArc.setSource(channelPlace);
topPage.addObject(channelArc);
petriNet.flushTreeCache(); petriNet.flushTreeCache();
} }
...@@ -168,22 +209,47 @@ public class ChannelFlatter { ...@@ -168,22 +209,47 @@ public class ChannelFlatter {
// include places, transitions // include places, transitions
for(Transition t : templateInstance.allTransitions()){ for(Transition t : templateInstance.allTransitions()){
t.asInputSignalTransition().getMutualTransitionInformation().setSubNet(subnet);
t.asInputSignalTransition().getMutualTransitionInformation().setLocation(location); System.out.println("Adding: " + t.getId());
TransitionInformation newTi = new DefaultTransitionInformation();
newTi.setLocation(location);
newTi.setSubNet(subnet);
newTi.setType(t.asInputSignalTransition().getStaticTransitionInformation().getType());
t.asInputSignalTransition().setMutualTransitionInformation(newTi);
topPage.addObject(t); topPage.addObject(t);
} }
for(Place p : templateInstance.allPlaces()){ for(Place p : templateInstance.allPlaces()){
p.asOutputSignalPlace().getMutualPlaceInformation().setSubNet(subnet);
p.asOutputSignalPlace().getMutualPlaceInformation().setLocation(location); PlaceInformation newPi = new PlaceInformation();
newPi.setLocation(location);
newPi.setSubNet(subnet);
newPi.setType(p.asOutputSignalPlace().getStaticPlaceInformation().getType());
p.asOutputSignalPlace().setMutualPlaceInformation(newPi);
topPage.addObject(p); topPage.addObject(p);
} }
petriNet.flushTreeCache();
// connect elements by arcs // connect elements by arcs
for(Arc a : templateInstance.allArcs()){ for(Arc a : templateInstance.allArcs()){
Arc newArc = new Arc(); Arc newArc = new Arc();
newArc.setId("arc-" + a.getSource().getId() + "-" + a.getTarget().getId());
System.out.println("Target: " + a.getTarget().getId());
newArc.setTarget((Node) getPnObjectByID(petriNet, a.getTarget().getId())); newArc.setTarget((Node) getPnObjectByID(petriNet, a.getTarget().getId()));
newArc.setSource((Node) getPnObjectByID(petriNet, a.getSource().getId())); newArc.setSource((Node) getPnObjectByID(petriNet, a.getSource().getId()));
if(a.getNumToolspecific() > 0) {
ToolInfo ti = new ToolInfo();
ti.setFormattedXMLBuffer(a.getToolspecific(0).getFormattedXMLBuffer());
ti.setTool(a.getToolspecific(0).getTool());
ti.setVersion(a.getToolspecific(0).getVersion());
newArc.addToolspecific(ti);
}
topPage.addObject(newArc); topPage.addObject(newArc);
} }
......
...@@ -142,6 +142,8 @@ ...@@ -142,6 +142,8 @@
</arc> </arc>
<arc id="arc-6" source="DispatcherInputPlace" target="DispatcherInputTransition"> <arc id="arc-6" source="DispatcherInputPlace" target="DispatcherInputTransition">
</arc> </arc>
<arc id="arc-7" source="DispatcherInputPlace" target="DispatcherOverflowTransition">
</arc>
</page> </page>
</net> </net>
</pnml> </pnml>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment