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

finished implementation of updated flattener transforms

parent a12e9c1d
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ aspect ServiceChannelTransforms { ...@@ -7,6 +7,7 @@ aspect ServiceChannelTransforms {
syn Page DinerosTransition.transformServiceElement() { syn Page DinerosTransition.transformServiceElement() {
Page res = new Page(); Page res = new Page();
Map<String, PnObject> addedObjects = new HashMap<>();
System.out.println("Transforming service transition: " + this.getId()); System.out.println("Transforming service transition: " + this.getId());
ServiceTransitionInformation sti = this.getStaticTransitionInformation().asServiceTransitionInformation(); ServiceTransitionInformation sti = this.getStaticTransitionInformation().asServiceTransitionInformation();
res.setId(TemplateConstants.CHANNEL_SERVICE_PAGE_PREFIX + "-" + sti.getServiceName()); res.setId(TemplateConstants.CHANNEL_SERVICE_PAGE_PREFIX + "-" + sti.getServiceName());
...@@ -18,34 +19,35 @@ aspect ServiceChannelTransforms { ...@@ -18,34 +19,35 @@ aspect ServiceChannelTransforms {
clientMap.put(TemplateConstants.SERVICE_CAN_CALL_REF_PLACE + "-" + sti.getServiceName() + "-" + sc, petriNet().getPlaceById(clientChannel.getRequestPlaceId())); clientMap.put(TemplateConstants.SERVICE_CAN_CALL_REF_PLACE + "-" + sti.getServiceName() + "-" + sc, petriNet().getPlaceById(clientChannel.getRequestPlaceId()));
clientMap.put(TemplateConstants.SERVICE_CAN_RESP_REF_PLACE + "-" + sti.getServiceName() + "-" + sc, petriNet().getPlaceById(clientChannel.getRequestPlaceId())); clientMap.put(TemplateConstants.SERVICE_CAN_RESP_REF_PLACE + "-" + sti.getServiceName() + "-" + sc, petriNet().getPlaceById(clientChannel.getRequestPlaceId()));
PetriNet clientNet = ServiceTemplates.getServiceConnectionTemplate(sti.getServiceName() + "-" + sc); PetriNet clientNet = ServiceTemplates.getServiceConnectionTemplate(sti.getServiceName() + "-" + sc);
TransformationUtils.includeTemplateInstance(res, petriNet(), clientNet, clientMap); TransformationUtils.includeTemplateInstance(res, petriNet(), clientNet, clientMap, addedObjects);
sc++; sc++;
} }
petriNet().flushAttrAndCollectionCache();
// apply rule S3 // apply rule S3
for(int i = 0; i < sti.getServerChannel().getCapacity(); i++){ for(int i = 0; i < sti.getServerChannel().getCapacity(); i++){
Page instancePage = petriNet().getPlaceById(sti.getServerChannel().getRequestPlaceId()).ContainingPage();
PetriNet serviceInterfaceNet = ServiceTemplates.getServiceServerInterfaceTemplate(sti.getServiceName() + "-" + i); PetriNet serviceInterfaceNet = ServiceTemplates.getServiceServerInterfaceTemplate(sti.getServiceName() + "-" + i);
TransformationUtils.includeTemplateInstance(instancePage, petriNet(), serviceInterfaceNet); TransformationUtils.includeTemplateInstance(res, petriNet(), serviceInterfaceNet, addedObjects);
// apply rule S2 // apply rule S2
int sc2 = 0; int sc2 = 0;
for(ServiceChannel clientChannel: sti.getClientChannels()){ for(ServiceChannel clientChannel: sti.getClientChannels()){
Map<String, Node> multiplexerMap = new HashMap<>(); Map<String, Node> multiplexerMap = new HashMap<>();
multiplexerMap.put(TemplateConstants.SERVICE_CALL_M_REF_PLACE + multiplexerMap.put(TemplateConstants.SERVICE_CALL_M_REF_PLACE +
"-" + sti.getServiceName() + "-" + sc2, petriNet().getPlaceById(TemplateConstants.SERVICE_CON_CLIENT_CALL_PLACE + "-" + sc2)); "-" + sti.getServiceName() + "-" + i + "-" + sc2, addedObjects.get(TemplateConstants.SERVICE_CON_CLIENT_CALL_PLACE + "-" + sti.getServiceName() + "-" + sc2).asNode());
multiplexerMap.put(TemplateConstants.SERVICE_RESP_M_REF_PLACE + multiplexerMap.put(TemplateConstants.SERVICE_RESP_M_REF_PLACE +
"-" + sti.getServiceName() + "-" + sc2, petriNet().getPlaceById(TemplateConstants.SERVICE_CON_CLIENT_RESP_PLACE + "-" + sc2)); "-" + sti.getServiceName() + "-" + i + "-" + sc2, addedObjects.get(TemplateConstants.SERVICE_CON_CLIENT_RESP_PLACE + "-" + sti.getServiceName() + "-" + sc2).asNode());
multiplexerMap.put(TemplateConstants.SERVICE_ACTIVE_M_REF_PLACE + multiplexerMap.put(TemplateConstants.SERVICE_ACTIVE_M_REF_PLACE +
"-" + sti.getServiceName() + "-" + sc2, petriNet().getPlaceById(TemplateConstants.SERVICE_ACTIVE_PLACE + "-" + i)); "-" + sti.getServiceName() + "-" + i + "-" + sc2, addedObjects.get(TemplateConstants.SERVICE_ACTIVE_PLACE + "-" + sti.getServiceName() + "-" + i).asNode());
multiplexerMap.put(TemplateConstants.SERVICE_INACTIVE_M_REF_PLACE + multiplexerMap.put(TemplateConstants.SERVICE_INACTIVE_M_REF_PLACE +
"-" + sti.getServiceName() + "-" + sc2, petriNet().getPlaceById(TemplateConstants.SERVICE_INACTIVE_PLACE + "-" + i)); "-" + sti.getServiceName() + "-" + i + "-" + sc2, addedObjects.get(TemplateConstants.SERVICE_INACTIVE_PLACE + "-" + sti.getServiceName() + "-" + i).asNode());
multiplexerMap.put(TemplateConstants.SERVICE_ENTRY_M_REF_PLACE + multiplexerMap.put(TemplateConstants.SERVICE_ENTRY_M_REF_PLACE +
"-" + sti.getServiceName() + "-" + sc2, petriNet().getPlaceById(sti.getServerChannel().getRequestPlaceId())); "-" + sti.getServiceName() + "-" + i + "-" + sc2, petriNet().getPlaceById(sti.getServerChannel().getRequestPlaceId() + "-" + i + "-" + PnmlConstants.PAGE_SERVER_INSTANCE_SUFFIX));
multiplexerMap.put(TemplateConstants.SERVICE_EXIT_M_REF_PLACE + multiplexerMap.put(TemplateConstants.SERVICE_EXIT_M_REF_PLACE +
"-" + sti.getServiceName() + "-" + sc2, petriNet().getPlaceById(sti.getServerChannel().getResponsePlaceId())); "-" + sti.getServiceName() + "-" + i + "-" + sc2, petriNet().getPlaceById(sti.getServerChannel().getResponsePlaceId() + "-" + i + "-" + PnmlConstants.PAGE_SERVER_INSTANCE_SUFFIX));
PetriNet multiplexerNet = ServiceTemplates.getServiceMultiplexerTemplate(sti.getServiceName() + "-" + i + "-" + sc2); PetriNet multiplexerNet = ServiceTemplates.getServiceMultiplexerTemplate(sti.getServiceName() + "-" + i + "-" + sc2);
TransformationUtils.includeTemplateInstance(res, petriNet(), multiplexerNet, multiplexerMap); TransformationUtils.includeTemplateInstance(res, petriNet(), multiplexerNet, multiplexerMap, null);
sc2++; sc2++;
} }
} }
......
...@@ -11,14 +11,14 @@ aspect SignalTransforms { ...@@ -11,14 +11,14 @@ aspect SignalTransforms {
PetriNet pubNet = SignalTemplates.getInputSignalTemplate(entry.getKey()); PetriNet pubNet = SignalTemplates.getInputSignalTemplate(entry.getKey());
if(Boolean.parseBoolean(entry.getValue())){ if(Boolean.parseBoolean(entry.getValue())){
pubNet.getPlaceById(TemplateConstants.INPUT_SIGNAL_PLACE_TRUE + entry.getKey()).getInitialMarking().setText(1); pubNet.getPlaceById(TemplateConstants.INPUT_SIGNAL_PLACE_TRUE + "-" + entry.getKey()).getInitialMarking().setText(1);
pubNet.getPlaceById(TemplateConstants.INPUT_SIGNAL_PLACE_FALSE + entry.getKey()).getInitialMarking().setText(0); pubNet.getPlaceById(TemplateConstants.INPUT_SIGNAL_PLACE_FALSE + "-" + entry.getKey()).getInitialMarking().setText(0);
} else { } else {
pubNet.getPlaceById(TemplateConstants.INPUT_SIGNAL_PLACE_TRUE + entry.getKey()).getInitialMarking().setText(0); pubNet.getPlaceById(TemplateConstants.INPUT_SIGNAL_PLACE_TRUE + "-" + entry.getKey()).getInitialMarking().setText(0);
pubNet.getPlaceById(TemplateConstants.INPUT_SIGNAL_PLACE_FALSE + entry.getKey()).getInitialMarking().setText(1); pubNet.getPlaceById(TemplateConstants.INPUT_SIGNAL_PLACE_FALSE + "-" + entry.getKey()).getInitialMarking().setText(1);
} }
TransformationUtils.includeTemplateInstance(signalValuePage, this, pubNet, "signal", "signal"); TransformationUtils.includeTemplateInstance(signalValuePage, this, pubNet, "signal", "signal", null);
} }
return this; return this;
} }
...@@ -36,7 +36,12 @@ aspect SignalTransforms { ...@@ -36,7 +36,12 @@ aspect SignalTransforms {
pdi.getName().setText(pdi.getId()); pdi.getName().setText(pdi.getId());
RefTransition rt = PrimitiveTemplates.getReferenceTransition(t); RefTransition rt = PrimitiveTemplates.getReferenceTransition(t);
rt.setId("PD-REF-" + i + "-" + t.getId()); rt.setId("PD-REF-" + i + "-" + t.getId());
rt.getName().setText(rt.getId()); rt.setRef(t);
res.addObject(pdi);
res.addObject(rt);
TransformationUtils.createAndIncludeArc(res, pdi.getId() + "-to-" + rt.getId(), pdi, rt);
TransformationUtils.createAndIncludeArc(res, rt.getId() + "-to-" + pdi.getId(), rt, pdi);
int j = 0; int j = 0;
for(Literal l : dj.getLiterals()){ for(Literal l : dj.getLiterals()){
...@@ -47,17 +52,18 @@ aspect SignalTransforms { ...@@ -47,17 +52,18 @@ aspect SignalTransforms {
// create elements for rule I2 & I3 // create elements for rule I2 & I3
RefTransition toTrueRt = PrimitiveTemplates.getReferenceTransition(toTrue); RefTransition toTrueRt = PrimitiveTemplates.getReferenceTransition(toTrue);
toTrueRt.setId(toTrue.getId() + "REF-" + i + "-" + j); toTrueRt.setId(toTrue.getId() + "REF-" + i + "-" + j);
toTrueRt.getName().setText(toTrueRt.getId());
res.addObject(toTrueRt); res.addObject(toTrueRt);
RefTransition toFalseRt = PrimitiveTemplates.getReferenceTransition(toFalse); RefTransition toFalseRt = PrimitiveTemplates.getReferenceTransition(toFalse);
toFalseRt.setId(toFalse.getId() + "REF-" + i + "-" + j); toFalseRt.setId(toFalse.getId() + "REF-" + i + "-" + j);
toFalseRt.getName().setText(toFalseRt.getId());
res.addObject(toFalseRt); res.addObject(toFalseRt);
RefPlace djRefPlace = PrimitiveTemplates.getReferencePlace(pdi); RefPlace djRefPlace = PrimitiveTemplates.getReferencePlace(pdi);
djRefPlace.setId("DJREF-" + i + "-" + j);
djRefPlace.getName().setText(djRefPlace.getId());
res.addObject(djRefPlace);
// apply rule I2 // apply rule I2
if(l.isPositiveLiteral()){ if(l.isPositiveLiteral()){
TransformationUtils.createAndIncludeArc(res, toFalse.getId() + "-to-" + djRefPlace.getId(), toFalseRt, djRefPlace); TransformationUtils.createAndIncludeArc(res, toFalseRt.getId() + "-to-" + djRefPlace.getId(), toFalseRt, djRefPlace);
TransformationUtils.createAndIncludeArc(res, djRefPlace.getId() + "-to-" + toTrueRt.getId(), djRefPlace, toTrueRt); TransformationUtils.createAndIncludeArc(res, djRefPlace.getId() + "-to-" + toTrueRt.getId(), djRefPlace, toTrueRt);
if(Boolean.parseBoolean(net.getInputSignalDefinition().get(l.getName()))){ if(Boolean.parseBoolean(net.getInputSignalDefinition().get(l.getName()))){
......
...@@ -49,7 +49,7 @@ aspect TopicTransforms { ...@@ -49,7 +49,7 @@ aspect TopicTransforms {
pubMap.put(TemplateConstants.PLACE_TOPIC_PUBLISHER_REF + "-" + tti.getTopic() + "-" + i, petriNet().getPlaceById(pp.getPlaceId())); pubMap.put(TemplateConstants.PLACE_TOPIC_PUBLISHER_REF + "-" + tti.getTopic() + "-" + i, petriNet().getPlaceById(pp.getPlaceId()));
pubMap.put(TemplateConstants.PLACE_TOPIC_PUBLISHER_CHANNEL_REF + "-" + tti.getTopic() + "-" + i, pTopic); pubMap.put(TemplateConstants.PLACE_TOPIC_PUBLISHER_CHANNEL_REF + "-" + tti.getTopic() + "-" + i, pTopic);
PetriNet pubNet = TopicTemplates.getTopicPublisherPetriNet(tti.getTopic() + "-" + i, pp.getLimit()); PetriNet pubNet = TopicTemplates.getTopicPublisherPetriNet(tti.getTopic() + "-" + i, pp.getLimit());
TransformationUtils.includeTemplateInstance(res, petriNet(), pubNet, pubMap); TransformationUtils.includeTemplateInstance(res, petriNet(), pubNet, pubMap, null);
i++; i++;
} }
...@@ -73,7 +73,7 @@ aspect TopicTransforms { ...@@ -73,7 +73,7 @@ aspect TopicTransforms {
dispatchMap.put(TemplateConstants.TRANSITION_TOPIC_DISPATCHER_CHANNEL_REF + "-" + tti.getTopic() + "-" + j, tTopic); dispatchMap.put(TemplateConstants.TRANSITION_TOPIC_DISPATCHER_CHANNEL_REF + "-" + tti.getTopic() + "-" + j, tTopic);
// TODO: make capacity configurable // TODO: make capacity configurable
PetriNet dispatchNet = TopicTemplates.getTopicDispatcherPetriNet(tti.getTopic() + "-" + j, 16); PetriNet dispatchNet = TopicTemplates.getTopicDispatcherPetriNet(tti.getTopic() + "-" + j, 16);
Map<String, PnObject> addedObjects = TransformationUtils.includeTemplateInstance(res, petriNet(), dispatchNet, dispatchMap); Map<String, PnObject> addedObjects = TransformationUtils.includeTemplateInstance(res, petriNet(), dispatchNet, dispatchMap, null);
// apply rule T4 // apply rule T4
int k = 0; int k = 0;
...@@ -83,7 +83,7 @@ aspect TopicTransforms { ...@@ -83,7 +83,7 @@ aspect TopicTransforms {
subMap.put(TemplateConstants.TRANSITION_TOPIC_CALLBACK_INPUT_REF + "-" + tti.getTopic() + "-" + j + "-" + k, subMap.put(TemplateConstants.TRANSITION_TOPIC_CALLBACK_INPUT_REF + "-" + tti.getTopic() + "-" + j + "-" + k,
addedObjects.get(TemplateConstants.DISPATCHER_OUTPUT_TRANSITION + "-" + tti.getTopic() + "-" + j).asNode()); addedObjects.get(TemplateConstants.DISPATCHER_OUTPUT_TRANSITION + "-" + tti.getTopic() + "-" + j).asNode());
PetriNet callbackNet = TopicTemplates.getTopicCallbackQueuePetriNet(tti.getTopic() + "-" + j + "-" + k, sp.getLimit()); PetriNet callbackNet = TopicTemplates.getTopicCallbackQueuePetriNet(tti.getTopic() + "-" + j + "-" + k, sp.getLimit());
TransformationUtils.includeTemplateInstance(res, petriNet(), callbackNet, subMap); TransformationUtils.includeTemplateInstance(res, petriNet(), callbackNet, subMap, null);
k++; k++;
} }
j++; j++;
......
package de.tudresden.inf.st.pnml.flatter; package de.tudresden.inf.st.pnml.flatter;
import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpBuilder;
import de.tudresden.inf.st.jastadd.dumpAst.ast.Dumper;
import de.tudresden.inf.st.jastadd.dumpAst.ast.SkinParamBooleanSetting;
import de.tudresden.inf.st.pnml.base.constants.PnmlConstants; import de.tudresden.inf.st.pnml.base.constants.PnmlConstants;
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.tina.KtzioProxy; import de.tudresden.inf.st.pnml.flatter.tina.KtzioProxy;
import de.tudresden.inf.st.pnml.flatter.tina.SiftProxy; import de.tudresden.inf.st.pnml.flatter.tina.SiftProxy;
import de.tudresden.inf.st.pnml.flatter.tina.TinaProxy; import de.tudresden.inf.st.pnml.flatter.tina.TinaProxy;
import de.tudresden.inf.st.pnml.flatter.transform.ReferenceFlatter;
import de.tudresden.inf.st.pnml.flatter.transform.TransformationUtils; import de.tudresden.inf.st.pnml.flatter.transform.TransformationUtils;
import de.tudresden.inf.st.pnml.jastadd.model.*; 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;
...@@ -16,33 +14,29 @@ import fr.lip6.move.pnml.framework.utils.exception.InvalidIDException; ...@@ -16,33 +14,29 @@ import fr.lip6.move.pnml.framework.utils.exception.InvalidIDException;
import de.tudresden.inf.st.pnml.flatter.tina.NdrioProxy; import de.tudresden.inf.st.pnml.flatter.tina.NdrioProxy;
import de.tudresden.inf.st.pnml.jastadd.model.PetriNet; import de.tudresden.inf.st.pnml.jastadd.model.PetriNet;
import java.awt.*;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Paths;
import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
public class Main { public class Main {
public static void main(String[] args) throws InvalidIDException { public static void main(String[] args) throws InvalidIDException, IOException, InterruptedException {
String configPath = (args.length > 1) ? args[1] : null; String configPath = (args.length > 1) ? args[1] : null;
String pnmlPath = (args.length > 0) ? args[0] : null; String pnmlPath = (args.length > 0) ? args[0] : null;
/*
if (pnmlPath == null || configPath == null) { if (pnmlPath == null || configPath == null) {
System.out.println("No model found on given input path."); System.out.println("No model found on given input path.");
return; return;
}*/ }
// parse the global not flatted petri net // parse the global not flatted petri net
pnmlPath = "/home/sebastian/git/dineros/dineros-v2/dineros/pnml-relast-base/src/main/resources/nets/TestNet1.pnml"; //pnmlPath = "/home/sebastian/git/dineros/dineros-v2/dineros/pnml-relast-base/src/main/resources/nets/TestNet3.pnml";
configPath = "src/main/config/siftConfig.json"; //configPath = "src/main/config/siftConfig.json";
PetriNet petriNet = PnmlParser.parsePnml(pnmlPath).get(0); PetriNet petriNet = PnmlParser.parsePnml(pnmlPath).get(0);
// [STAGE 1] Resolve service prototype pages // [STAGE 1] Resolve service prototype pages
TransformationUtils.transformPrototypePagesRecursive(petriNet.getPage(0), null, petriNet); TransformationUtils.transformPrototypePagesRecursive(petriNet.getPage(0), null, petriNet);
petriNet.flushTreeCache(); petriNet.flushAttrAndCollectionCache();
// [STAGE 2] Transform topic transitions // [STAGE 2] Transform topic transitions
for(DinerosTransition dt : petriNet.allDinerosTransitions()){ for(DinerosTransition dt : petriNet.allDinerosTransitions()){
...@@ -57,6 +51,8 @@ public class Main { ...@@ -57,6 +51,8 @@ public class Main {
} }
} }
petriNet.flushTreeCache();
// [STAGE 3] Transform service transitions // [STAGE 3] Transform service transitions
for(DinerosTransition dt : petriNet.allDinerosTransitions()){ for(DinerosTransition dt : petriNet.allDinerosTransitions()){
if(dt.canTransformServiceTransition()){ if(dt.canTransformServiceTransition()){
...@@ -85,17 +81,8 @@ public class Main { ...@@ -85,17 +81,8 @@ public class Main {
petriNet.flushTreeCache(); petriNet.flushTreeCache();
// DumpBuilder builder = Dumper.read(petriNet).skinParam(SkinParamBooleanSetting.Shadowing, false); // [STAGE 5] make sure that we have a valid marking
// builder.dumpAsPNG(Paths.get("net.png")); System.out.println("[FLATTENER] Checking marking.");
// builder.dumpAsSVG(Paths.get("net.svg"));
// read config for analyzer from file
/* ConfigReader cr = new ConfigReader(configPath);
String[] tinaConfig = cr.getTinaConfigParams();
String[] siftConfig = cr.getSiftConfigParams();*/
// make sure that we have a valid marking
System.out.println("[FLATTER] Checking marking.");
for (Place p : petriNet.allPlaces()) { for (Place p : petriNet.allPlaces()) {
if (p.getInitialMarking() == null) { if (p.getInitialMarking() == null) {
System.out.println("[FLATTER] Found NULL-marking. Falling back to 0 ..."); System.out.println("[FLATTER] Found NULL-marking. Falling back to 0 ...");
...@@ -105,52 +92,62 @@ public class Main { ...@@ -105,52 +92,62 @@ public class Main {
} }
} }
/* // [STAGE 6] remove references / pages
// remove references / pages System.out.println("[FLATTENER] Breaking references and pages.");
System.out.println("[FLATTER] Breaking references and pages."); for(Page p : petriNet.allPages()){
ReferenceFlatter.flatReferencesAndPages(petriNet); if(p.getId().equals("top")){
*/ ReferenceFlatter.flatReferencesAndPages(petriNet,p);
// export flatted net to pnml break;
printNet(petriNet, true, false); }
System.out.println("[FLATTER] Exporting to pnml."); }
// [STAGE 7] export flatted net to pnml
// printNet(petriNet, true, false);
System.out.println("[FLATTENER] Exporting to pnml.");
String exportId = UUID.randomUUID().toString(); String exportId = UUID.randomUUID().toString();
String pnmlExportPath = PnmlExporter.serializeToPnmlFile(petriNet, "flatted-" + exportId); String pnmlExportPath = PnmlExporter.serializeToPnmlFile(petriNet, "flatted-" + exportId);
// convert and add inhibitor arcs // convert and add inhibitor arcs
/* System.out.println("[FLATTER] Converting to net format."); System.out.println("[FLATTENER] Converting to net format.");
NdrioProxy ndrioProxy = new NdrioProxy(); NdrioProxy ndrioProxy = new NdrioProxy();
String homeDirectory = System.getProperty("user.dir"); String homeDirectory = System.getProperty("user.dir");
String fid = UUID.randomUUID().toString(); String fid = UUID.randomUUID().toString();
String ndrioTargetPath = homeDirectory + "/temp/net/" + fid + "flatted-" + exportId + ".net";*/ String ndrioTargetPath = homeDirectory + "/temp/net/" + fid + "flatted-" + exportId + ".net";
// resolve inhibitor arcs // resolve inhibitor arcs
/* System.out.println("[FLATTER] Including inhibitor arcs into net format."); System.out.println("[FLATTENER] Including inhibitor arcs into net format.");
String inhibitorTargetPath = homeDirectory + "/temp/net/" + fid + "flatted-inh-" + exportId + ".net"; String inhibitorTargetPath = homeDirectory + "/temp/net/" + fid + "flatted-inh-" + exportId + ".net";
ndrioProxy.pnml2net(pnmlExportPath, ndrioTargetPath); ndrioProxy.pnml2net(pnmlExportPath, ndrioTargetPath);
ndrioProxy.includeInhibitorArcs(petriNet, ndrioTargetPath, inhibitorTargetPath);*/ ndrioProxy.includeInhibitorArcs(petriNet, ndrioTargetPath, inhibitorTargetPath);
// [STAGE 8] Analyze
// read config for analyzer from file
ConfigReader cr = new ConfigReader(configPath);
String[] tinaConfig = cr.getTinaConfigParams();
String[] siftConfig = cr.getSiftConfigParams();
// insert into tina // insert into tina
/* if (tinaConfig.length > 1) { if (tinaConfig.length > 1) {
System.out.println("[FLATTER] Inserting into tina."); System.out.println("[FLATTENER] Inserting into tina.");
TinaProxy tinaProxy = new TinaProxy(); TinaProxy tinaProxy = new TinaProxy();
String tinaTargetPath = homeDirectory + "/temp/tina/" + "tina-result-" + exportId + ".txt"; String tinaTargetPath = homeDirectory + "/temp/tina/" + "tina-result-" + exportId + ".txt";
tinaProxy.analyzePetriNet(inhibitorTargetPath, tinaTargetPath, tinaConfig); tinaProxy.analyzePetriNet(inhibitorTargetPath, tinaTargetPath, tinaConfig);
}*/ }
// insert into sift // insert into sift
/* if (siftConfig.length > 1) { if (siftConfig.length > 1) {
System.out.println("[FLATTER] Inserting into sift."); System.out.println("[FLATTENER] Inserting into sift.");
SiftProxy siftProxy = new SiftProxy(); SiftProxy siftProxy = new SiftProxy();
String siftTargetPath = homeDirectory + "/temp/sift/" + "sift-result-" + exportId + ".ktz"; String siftTargetPath = homeDirectory + "/temp/sift/" + "sift-result-" + exportId + ".ktz";
siftProxy.analyzePetriNet(inhibitorTargetPath, siftTargetPath, siftConfig); siftProxy.analyzePetriNet(inhibitorTargetPath, siftTargetPath, siftConfig);
System.out.println("[FLATTER] Converting with ktzio."); System.out.println("[FLATTENER] Converting with ktzio.");
KtzioProxy ktzioProxy = new KtzioProxy(); KtzioProxy ktzioProxy = new KtzioProxy();
String ktzioPath = homeDirectory + "/temp/sift/" + "sift-result-converted-" + exportId + ".txt"; String ktzioPath = homeDirectory + "/temp/sift/" + "sift-result-converted-" + exportId + ".txt";
ktzioProxy.convertBinaryToText(siftTargetPath, ktzioPath); ktzioProxy.convertBinaryToText(siftTargetPath, ktzioPath);
}*/ }
System.out.println("Finished."); System.out.println("[FLATTENER] Finished.");
} }
...@@ -202,13 +199,13 @@ public class Main { ...@@ -202,13 +199,13 @@ public class Main {
System.out.println("----------------- REF PLACES -----------------"); System.out.println("----------------- REF PLACES -----------------");
for (RefPlace rp : petriNet.allRefPlaces()) { for (RefPlace rp : petriNet.allRefPlaces()) {
System.out.println("--- RefPlace: " + rp.getId()); System.out.println("--- RefPlace: " + rp.getId() + " >> " + rp.getRef().getId());
} }
System.out.println("----------------- REF TRANSITIONS -----------------"); System.out.println("----------------- REF TRANSITIONS -----------------");
for (RefTransition rt : petriNet.allRefTransitions()) { for (RefTransition rt : petriNet.allRefTransitions()) {
System.out.println("--- RefTransition: " + rt.getId()); System.out.println("--- RefTransition: " + rt.getId() + " >> " + rt.getRef().getId());
} }
if (withArcs) { if (withArcs) {
......
...@@ -38,14 +38,14 @@ public final class TemplateConstants { ...@@ -38,14 +38,14 @@ public final class TemplateConstants {
public static final String CHANNEL_TOPIC_PLACE = "ChannelConnectorPlace"; public static final String CHANNEL_TOPIC_PLACE = "ChannelConnectorPlace";
public static final String CHANNEL_TOPIC_TRANSITION = "ChannelConnectorTransition"; public static final String CHANNEL_TOPIC_TRANSITION = "ChannelConnectorTransition";
public static final String CHANNEL_TOPIC_PAGE_PREFIX = "ChannelTopicPage"; public static final String CHANNEL_TOPIC_PAGE_PREFIX = "ChannelTopicPage";
public static final String CHANNEL_SERVICE_PAGE_PREFIX = "SIGNAL-PAGE-"; public static final String CHANNEL_SERVICE_PAGE_PREFIX = "CHANNEL-SERVICE-PAGE-";
// signal elements // signal elements
public static final String INPUT_SIGNAL_PLACE_TRUE = "InputSignalTruePlace"; public static final String INPUT_SIGNAL_PLACE_TRUE = "InputSignalTruePlace";
public static final String INPUT_SIGNAL_PLACE_FALSE = "InputSignalFalsePlace"; public static final String INPUT_SIGNAL_PLACE_FALSE = "InputSignalFalsePlace";
public static final String INPUT_SIGNAL_TRANSITION_TO_TRUE = "InputSignalToTrueTransition"; public static final String INPUT_SIGNAL_TRANSITION_TO_TRUE = "InputSignalToTrueTransition";
public static final String INPUT_SIGNAL_TRANSITION_TO_FALSE = "InputSignalToFalseTransition"; public static final String INPUT_SIGNAL_TRANSITION_TO_FALSE = "InputSignalToFalseTransition";
public static final String INPUT_SIGNAL_PAGE_PREFIX = "InputSignalTruePlace"; public static final String INPUT_SIGNAL_PAGE_PREFIX = "InputSignalPage";
// services // services
// S3 // S3
......
...@@ -25,12 +25,13 @@ public class ReferenceFlatter { ...@@ -25,12 +25,13 @@ public class ReferenceFlatter {
} }
} }
public static void flatReferencesAndPages(PetriNet petriNet){ public static void flatReferencesAndPages(PetriNet petriNet, Page page){
excludeAllPages(petriNet); excludeAllPages(petriNet, page);
resolvePlaceReferences(petriNet); resolvePlaceReferences(petriNet);
resolveTransitionReferences(petriNet); resolveTransitionReferences(petriNet);
petriNet.flushTreeCache(); petriNet.flushTreeCache();
petriNet.flushAttrAndCollectionCache();
} }
private static void resolvePlaceReferences(PetriNet petriNet){ private static void resolvePlaceReferences(PetriNet petriNet){
...@@ -66,7 +67,6 @@ public class ReferenceFlatter { ...@@ -66,7 +67,6 @@ public class ReferenceFlatter {
for(PlaceNode placeNode : nodesToDelete){ for(PlaceNode placeNode : nodesToDelete){
placeNode.removeSelf(); placeNode.removeSelf();
} }
// petriNet.flushTreeCache();
} }
private static void resolveTransitionReferences(PetriNet petriNet){ private static void resolveTransitionReferences(PetriNet petriNet){
...@@ -102,14 +102,13 @@ public class ReferenceFlatter { ...@@ -102,14 +102,13 @@ public class ReferenceFlatter {
for(TransitionNode transitionNode : nodesToDelete){ for(TransitionNode transitionNode : nodesToDelete){
transitionNode.removeSelf(); transitionNode.removeSelf();
} }
// petriNet.flushTreeCache();
} }
/** /**
* Excludes all but the top level page. * Excludes all but the top level page.
* @param petriNet * @param petriNet
*/ */
private static void excludeAllPages(PetriNet petriNet){ private static void excludeAllPages(PetriNet petriNet, Page targetPage){
Page topLevelPage = null; Page topLevelPage = null;
...@@ -122,17 +121,14 @@ public class ReferenceFlatter { ...@@ -122,17 +121,14 @@ public class ReferenceFlatter {
for (PnObject pnObject : petriNet.allObjects()){ for (PnObject pnObject : petriNet.allObjects()){
assert topLevelPage != null; assert topLevelPage != null;
if(pnObject.ContainingPage() != null && !pnObject.isPageNode()){ if(pnObject.ContainingPage() != null && !pnObject.isPageNode()){
// System.out.println("Moving: " + pnObject.getId());
topLevelPage.addObject(pnObject); topLevelPage.addObject(pnObject);
} }
} }
for (Page p : petriNet.allPages()){ for (Page p : petriNet.allPages()){
if(p.ContainingPage() != null){ if(!p.getId().equals(targetPage.getId())){
p.removeSelf(); p.removeSelf();
} }
} }
// petriNet.flushTreeCache();
} }
} }
...@@ -40,23 +40,25 @@ public class TransformationUtils { ...@@ -40,23 +40,25 @@ public class TransformationUtils {
return a; return a;
} }
public static Map<String, PnObject> includeTemplateInstance(Page page, PetriNet petriNet, PetriNet templateInstance, Map<String, Node> refs) { public static Map<String, PnObject> includeTemplateInstance(Page page, PetriNet petriNet, PetriNet templateInstance, Map<String, Node> refs, Map<String, PnObject> addedObjects) {
return includeTemplateInstance(page, petriNet, templateInstance, "channel", "channel", refs); return includeTemplateInstance(page, petriNet, templateInstance, "channel", "channel", refs, addedObjects);
} }
public static Map<String, PnObject> includeTemplateInstance(Page page, PetriNet petriNet, PetriNet templateInstance) { public static Map<String, PnObject> includeTemplateInstance(Page page, PetriNet petriNet, PetriNet templateInstance, Map<String, PnObject> addedObjects) {
Map<String, Node> refs = new HashMap<>(); Map<String, Node> refs = new HashMap<>();
return includeTemplateInstance(page, petriNet, templateInstance, "channel", "channel", refs); return includeTemplateInstance(page, petriNet, templateInstance, "channel", "channel", refs, addedObjects);
} }
public static Map<String, PnObject> includeTemplateInstance(Page page, PetriNet petriNet, PetriNet templateInstance, String subnet, String node) { public static Map<String, PnObject> includeTemplateInstance(Page page, PetriNet petriNet, PetriNet templateInstance, String subnet, String node, Map<String, PnObject> addedObjects) {
Map<String, Node> refs = new HashMap<>(); Map<String, Node> refs = new HashMap<>();
return includeTemplateInstance(page, petriNet, templateInstance, subnet, node, refs); return includeTemplateInstance(page, petriNet, templateInstance, subnet, node, refs, addedObjects);
} }
public static Map<String, PnObject> includeTemplateInstance(Page page, PetriNet petriNet, PetriNet templateInstance, String subnet, String node, Map<String, Node> refs) { public static Map<String, PnObject> includeTemplateInstance(Page page, PetriNet petriNet, PetriNet templateInstance, String subnet, String node, Map<String, Node> refs, Map<String, PnObject> addedObjects) {
Map<String, PnObject> addedObjects = new HashMap<>(); if(addedObjects == null){
addedObjects = new HashMap<>();
}
for(RefTransition rt : templateInstance.allRefTransitions()){ for(RefTransition rt : templateInstance.allRefTransitions()){
if(refs.containsKey(rt.getId())){ if(refs.containsKey(rt.getId())){
......
...@@ -162,13 +162,13 @@ ...@@ -162,13 +162,13 @@
</graphics> </graphics>
</referencePlace> </referencePlace>
<arc id="arc-1" source="ServiceCallMultiCallRefPlace" target="ServiceCallMultiInTransition"> <arc id="arc-1" source="ServiceCallMultiCallRefPlace" target="ServiceCallMultiEntryTransition">
</arc> </arc>
<arc id="arc-2" source="ServiceCallMultiEntryTransition" target="ServiceCallMultiActiveRefPlace"> <arc id="arc-2" source="ServiceCallMultiEntryTransition" target="ServiceCallMultiActiveRefPlace">
</arc> </arc>
<arc id="arc-3" source="ServiceCallMultiActiveRefPlace" target="ServiceCallMultiExitTransition"> <arc id="arc-3" source="ServiceCallMultiEntryTransition" target="ServiceCallMultiFlagPlace">
</arc> </arc>
<arc id="arc-4" source="ServiceCallMultiEntryTransition" target="ServiceCallMultiFlagPlace"> <arc id="arc-4" source="ServiceCallMultiActiveRefPlace" target="ServiceCallMultiExitTransition">
</arc> </arc>
<arc id="arc-5" source="ServiceCallMultiFlagPlace" target="ServiceCallMultiExitTransition"> <arc id="arc-5" source="ServiceCallMultiFlagPlace" target="ServiceCallMultiExitTransition">
</arc> </arc>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment