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

fixed signal transition linkage in improved variant

parent 2d049eda
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,6 @@ aspect SignalTransforms { ...@@ -2,7 +2,6 @@ aspect SignalTransforms {
syn PetriNet PetriNet.transformSingleUseSignals(){ syn PetriNet PetriNet.transformSingleUseSignals(){
// Map<String, String> signalDefs = this.getInputSignalDefinition();
Map<String, List<DinerosTransition>> signalMapping = TransformationUtils.getSignalToUsageMapping(this); Map<String, List<DinerosTransition>> signalMapping = TransformationUtils.getSignalToUsageMapping(this);
for (Map.Entry<String, List<DinerosTransition>> entry : signalMapping.entrySet()) { for (Map.Entry<String, List<DinerosTransition>> entry : signalMapping.entrySet()) {
...@@ -18,12 +17,10 @@ aspect SignalTransforms { ...@@ -18,12 +17,10 @@ aspect SignalTransforms {
if (!p.getId().startsWith(TemplateConstants.PD_PLACE_PREFIX)) { if (!p.getId().startsWith(TemplateConstants.PD_PLACE_PREFIX)) {
if (usageCount == 0) { if (usageCount == 0) {
System.out.println("[SignalPostProcessing] Creating new linkage between " + p.getId() + " and " + toTrue.getId()); System.out.println("[SignalPostProcessing] Creating new linkage between " + p.getId() + " and " + toTrue.getId());
TransformationUtils.createAndIncludeArc(this.getPage(0), p.getId() + "-to-" + toTrue.getId(), p, toTrue); TransformationUtils.createAndIncludeBidirectionalArc(this.getPage(0), p, toTrue);
TransformationUtils.createAndIncludeArc(this.getPage(0), toTrue.getId() + "-to-" + p.getId(), toTrue, p);
System.out.println("[SignalPostProcessing] Creating new linkage between " + p.getId() + " and " + toFalse.getId()); System.out.println("[SignalPostProcessing] Creating new linkage between " + p.getId() + " and " + toFalse.getId());
TransformationUtils.createAndIncludeArc(this.getPage(0), p.getId() + "-to-" + toFalse.getId(), p, toFalse); TransformationUtils.createAndIncludeBidirectionalArc(this.getPage(0), p, toFalse);
TransformationUtils.createAndIncludeArc(this.getPage(0), toFalse.getId() + "-to-" + p.getId(), toFalse, p);
} else { } else {
DinerosTransition newToTrue = PrimitiveTemplates.getDinerosTransition(); DinerosTransition newToTrue = PrimitiveTemplates.getDinerosTransition();
long millis = System.currentTimeMillis(); long millis = System.currentTimeMillis();
...@@ -34,18 +31,45 @@ aspect SignalTransforms { ...@@ -34,18 +31,45 @@ aspect SignalTransforms {
newToFalse.getName().setText(newToFalse.getId()); newToFalse.getName().setText(newToFalse.getId());
this.getPage(0).addObject(newToTrue); this.getPage(0).addObject(newToTrue);
this.getPage(0).addObject(newToFalse); this.getPage(0).addObject(newToFalse);
TransformationUtils.createAndIncludeArc(this.getPage(0), placeTrue.getId() + "-to-" + newToFalse.getId(), placeTrue, newToFalse);
TransformationUtils.createAndIncludeArc(this.getPage(0), newToFalse.getId() + "-to-" + placeFalse.getId(), newToFalse, placeFalse); for(Place tip : toTrue.incomingPlaces()){
TransformationUtils.createAndIncludeArc(this.getPage(0), placeFalse.getId() + "-to-" + newToTrue.getId(), placeFalse, newToTrue); if (tip.getId().startsWith(TemplateConstants.PD_PLACE_PREFIX)) {
TransformationUtils.createAndIncludeArc(this.getPage(0), newToTrue.getId() + "-to-" + placeTrue.getId(), newToTrue, placeTrue); System.out.println("Relink 1: " + newToTrue.getId());
TransformationUtils.createAndIncludeArc(this.getPage(0), tip, newToTrue);
}
}
for(Place top : toTrue.outgoingPlaces()){
if (top.getId().startsWith(TemplateConstants.PD_PLACE_PREFIX)) {
System.out.println("Relink 2: " + newToTrue.getId());
TransformationUtils.createAndIncludeArc(this.getPage(0), newToTrue, top);
}
}
for(Place tip : toFalse.incomingPlaces()){
if (tip.getId().startsWith(TemplateConstants.PD_PLACE_PREFIX)) {
System.out.println("Relink 3: " + newToFalse.getId());
TransformationUtils.createAndIncludeArc(this.getPage(0), tip, newToFalse);
}
}
for(Place top : toFalse.outgoingPlaces()){
if (top.getId().startsWith(TemplateConstants.PD_PLACE_PREFIX)) {
System.out.println("Relink 4: " + newToFalse.getId());
TransformationUtils.createAndIncludeArc(this.getPage(0), newToFalse, top);
}
}
TransformationUtils.createAndIncludeArc(this.getPage(0), placeTrue, newToFalse);
TransformationUtils.createAndIncludeArc(this.getPage(0), newToFalse, placeFalse);
TransformationUtils.createAndIncludeArc(this.getPage(0), placeFalse, newToTrue);
TransformationUtils.createAndIncludeArc(this.getPage(0), newToTrue, placeTrue);
System.out.println("[SignalPostProcessing] Creating new linkage between " + p.getId() + " and " + newToTrue.getId()); System.out.println("[SignalPostProcessing] Creating new linkage between " + p.getId() + " and " + newToTrue.getId());
TransformationUtils.createAndIncludeArc(this.getPage(0), p.getId() + "-to-" + newToTrue.getId(), p, newToTrue); TransformationUtils.createAndIncludeBidirectionalArc(this.getPage(0), p, newToTrue);
TransformationUtils.createAndIncludeArc(this.getPage(0), newToTrue.getId() + "-to-" + p.getId(), newToTrue, p);
System.out.println("[SignalPostProcessing] Creating new linkage between " + p.getId() + " and " + newToFalse.getId()); System.out.println("[SignalPostProcessing] Creating new linkage between " + p.getId() + " and " + newToFalse.getId());
TransformationUtils.createAndIncludeArc(this.getPage(0), p.getId() + "-to-" + newToFalse.getId(), p, newToFalse); TransformationUtils.createAndIncludeBidirectionalArc(this.getPage(0), p, newToFalse);
TransformationUtils.createAndIncludeArc(this.getPage(0), newToFalse.getId() + "-to-" + p.getId(), newToFalse, p);
} }
} }
} }
...@@ -66,13 +90,13 @@ aspect SignalTransforms { ...@@ -66,13 +90,13 @@ 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", null); TransformationUtils.includeTemplateInstance(signalValuePage, this, pubNet, "signal", "signal", null);
} }
...@@ -122,23 +146,23 @@ aspect SignalTransforms { ...@@ -122,23 +146,23 @@ aspect SignalTransforms {
res.addObject(djRefPlace); res.addObject(djRefPlace);
// apply rule I2 // apply rule I2
if(l.isPositiveLiteral()){ if(l.isNegativeLiteral()){
TransformationUtils.createAndIncludeArc(res, toFalseRt.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()))){
pdi.getInitialMarking().setText(pdi.getInitialMarking().getText() + 1); pdi.getInitialMarking().setText(pdi.getInitialMarking().getText() + 1);
} // }
} }
// apply rule I3 // apply rule I3
if(l.isNegativeLiteral()){ if(l.isPositiveLiteral()){
TransformationUtils.createAndIncludeArc(res, toTrueRt.getId() + "-to-" + djRefPlace.getId(), toTrueRt, djRefPlace); TransformationUtils.createAndIncludeArc(res, toTrueRt.getId() + "-to-" + djRefPlace.getId(), toTrueRt, djRefPlace);
TransformationUtils.createAndIncludeArc(res, djRefPlace.getId() + "-to-" + toTrueRt.getId(), djRefPlace, toFalseRt); TransformationUtils.createAndIncludeArc(res, djRefPlace.getId() + "-to-" + toTrueRt.getId(), djRefPlace, toFalseRt);
if(Boolean.parseBoolean(net.getInputSignalDefinition().get(l.getName()))){ // if(Boolean.parseBoolean(net.getInputSignalDefinition().get(l.getName()))){
pdi.getInitialMarking().setText(pdi.getInitialMarking().getText() + 1); // pdi.getInitialMarking().setText(pdi.getInitialMarking().getText() + 1);
} // }
} }
j++; j++;
} }
......
...@@ -54,6 +54,21 @@ public class TransformationUtils { ...@@ -54,6 +54,21 @@ public class TransformationUtils {
return a; return a;
} }
public static Arc createAndIncludeArc(Page page, Node s, Node t) {
Arc a = new Arc();
a.setId(s.getId() + "-to-" + t.getId());
a.setSource(s);
a.setTarget(t);
Name n = new Name();
n.setText(a.getId());
a.setName(n);
page.addObject(a);
return a;
}
public static Arc createAndIncludeArc(Page page, String id, Node s, Node t) { public static Arc createAndIncludeArc(Page page, String id, Node s, Node t) {
Arc a = createArc(id, s, t); Arc a = createArc(id, s, t);
...@@ -61,6 +76,12 @@ public class TransformationUtils { ...@@ -61,6 +76,12 @@ public class TransformationUtils {
return a; return a;
} }
public static void createAndIncludeBidirectionalArc(Page page, Node s, Node t) {
page.addObject(createArc(s.getId() + "-to-" + t.getId(), s, t));
page.addObject(createArc(t.getId() + "-to-" + s.getId(), t, s));
}
public static Arc createAndIncludeInhibitorArc(Page page, String id, Node s, Node t) { public static Arc createAndIncludeInhibitorArc(Page page, String id, Node s, Node t) {
Arc a = createArc(id, s, t); Arc a = createArc(id, s, t);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment