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

fixed several bugs

parent e5dcc30e
Branches
No related tags found
No related merge requests found
......@@ -7,8 +7,10 @@ aspect Navigation {
java.util.Set<Place> s = new java.util.HashSet<>();
for (Arc incomingArc : getInArcList()) {
if(!incomingArc.getSource().asPlaceNode().isRefPlace()){
s.add(incomingArc.getSource().asPlaceNode().place());
}
}
for (TransitionNode ref : getReferencingTransitions()) {
s.addAll(ref.incomingPlaces());
......@@ -17,6 +19,23 @@ aspect Navigation {
return s;
}
syn java.util.Collection<RefPlace> TransitionNode.incomingRefPlaces() {
java.util.Set<RefPlace> s = new java.util.HashSet<>();
for (Arc incomingArc : getInArcList()) {
if(incomingArc.getSource().asPlaceNode().isRefPlace()){
s.add(incomingArc.getSource().asPlaceNode().asRefPlace());
}
}
for (TransitionNode ref : getReferencingTransitions()) {
s.addAll(ref.incomingRefPlaces());
}
return s;
}
syn java.util.Collection<Place> TransitionNode.outgoingPlaces() {
java.util.Set<Place> s = new java.util.HashSet<>();
......@@ -41,6 +60,9 @@ aspect Navigation {
syn boolean PnObject.isPageNode() = false;
eq Page.isPageNode() = true;
syn boolean PnObject.isPlaceObject() = false;
eq Place.isPlaceObject() = true;
syn boolean Node.isPlaceNode() = false;
eq PlaceNode.isPlaceNode() = true;
......@@ -119,6 +141,11 @@ aspect Navigation {
to PetriNet.allPlaces()
for petriNet();
coll java.util.Set<PlaceNode> PetriNet.allPlaceNodes() [new java.util.HashSet()] root PetriNet;
PlaceNode contributes this
to PetriNet.allPlaceNodes()
for petriNet();
coll java.util.Set<Transition> PetriNet.allTransitions() [new java.util.HashSet()] root PetriNet;
Transition contributes this
to PetriNet.allTransitions()
......@@ -181,6 +208,17 @@ aspect Navigation {
return null;
}
syn Transition PetriNet.getTransitionById(String id) {
for (Transition t : this.allTransitions()) {
if (t.getId().equals(id)) {
return t;
}
}
return null;
}
syn RefTransition PetriNet.getRefTransitionFromTransitionNode(TransitionNode tNode) {
if (tNode.isRefTransition()) {
......
......@@ -4,7 +4,7 @@ aspect PnDistribution {
syn TransitionInformation InputSignalTransition.getStaticTransitionInformation() {
if(this.getMutualTransitionInformation() == null){
if(!this.hasMutualTransitionInformation()){
TransitionInformation tInfo = ToolSpecificsParser.getTransitionInformation(this.getToolspecificList());
return tInfo;
}
......@@ -14,7 +14,7 @@ aspect PnDistribution {
syn PlaceInformation OutputSignalPlace.getStaticPlaceInformation() {
if(this.getMutualPlaceInformation() == null){
if(!this.hasMutualPlaceInformation()){
PlaceInformation tInfo = ToolSpecificsParser.getPlaceInformationInformation(this.getToolspecificList());
return tInfo;
}
......
......@@ -6,6 +6,12 @@ aspect IoPnExtension{
eq Marking.getPetriNet().marking() = this;
inh BalloonMarking OutputSignalPlace.balloonMarking();
eq PetriNetDoc.getChild().balloonMarking() = null;
eq BalloonMarking.getPetriNet().balloonMarking() = this;
inh Place OutputSignalBinding.containingPlace();
eq OutputSignalPlace.getOutputSignalBinding().containingPlace() = this;
......@@ -36,6 +42,56 @@ aspect IoPnExtension{
// updates automatically based on dependencies to the corresponding place
syn String OutputSignalBinding.getOutputSignalValue(){
OutputSignalPlace osp = this.containingPlace().asOutputSignalPlace();
BalloonMarking marking = osp.balloonMarking();
BalloonMarkedPlace markedPlace = marking.resolveBalloonPlaceById(this.getPlaceID());
JastAddList<EqualityOutputMapping> eomList = this.getEqualityOMListNoTransform();
JastAddList<ThresholdOutputMapping> tomList = this.getThresholdOMListNoTransform();
JastAddList<RangeOutputMapping> romList = this.getRangeOMListNoTransform();
// eom
int result = -1;
for (EqualityOutputMapping eom : eomList) {
if ((eom.getValue() == markedPlace.getNumBalloonMarking()) && result == -1) {
result = eom.getResult();
break;
}
}
// tom
if (result > -1) {
for (ThresholdOutputMapping tom : tomList) {
if (tom.getValue() <= markedPlace.getNumBalloonMarking()) {
result = tom.getResult();
break;
}
}
}
// rom
if (result > -1) {
for (RangeOutputMapping rom : romList) {
if ((rom.getLowerBound() <= markedPlace.getNumBalloonMarking()) && (rom.getUpperBound() >= markedPlace.getNumBalloonMarking())) {
result = rom.getResult();
break;
}
}
}
// 0 (disabled Signal) is default
if (result == -1) {
result = 0;
}
String output = String.valueOf(result) + "-" + this.getOutputSignalID();
return output;
}
syn String OutputSignalBinding.getOutputSignalValueForDefaultMarking(){
OutputSignalPlace osp = this.containingPlace().asOutputSignalPlace();
Marking marking = osp.marking();
MarkedPlace markedPlace = marking.resolvePlaceById(this.getPlaceID());
......
......@@ -16,4 +16,3 @@ OutputMapping;
EqualityOutputMapping : OutputMapping ::= <Value:java.lang.Integer> <Result:java.lang.Integer>;
ThresholdOutputMapping : OutputMapping ::= <Value:java.lang.Integer> <Result:java.lang.Integer>;
RangeOutputMapping : OutputMapping ::= <UpperBound:java.lang.Integer> <LowerBound:java.lang.Integer> <Result:java.lang.Integer>;
\ No newline at end of file
......@@ -33,7 +33,7 @@ aspect Marking {
syn MarkedPlace Marking.resolvePlace(Place place) = placeMap().get(place);
syn lazy java.util.Map<Place, MarkedPlace> Marking.placeMap() {
syn java.util.Map<Place, MarkedPlace> Marking.placeMap() {
java.util.Map<Place, MarkedPlace> map = new java.util.HashMap<>();
for (MarkedPlace markedPlace : getPlaceList()) {
map.put(markedPlace.getPlace(), markedPlace);
......
......@@ -267,7 +267,11 @@ aspect ToolSpecificsParser{
Document doc = parseToolSpecifics(toolInfos);
String transitionType = getTransitionTypeFromToolSpecifics(toolInfos);
if (transitionType != null && (transitionType.equals(PnmlConstants.TRANSITION_TYPE_TOPIC))) {
if ((transitionType != null && (transitionType.equals(PnmlConstants.TRANSITION_TYPE_TOPIC))) ||
(transitionType != null && (transitionType.equals(PnmlConstants.TRANSITION_TYPE_TOPIC_LIMITED_IN))) ||
(transitionType != null && (transitionType.equals(PnmlConstants.TRANSITION_TYPE_TOPIC_LIMITED_OUT))) ||
(transitionType != null && (transitionType.equals(PnmlConstants.TRANSITION_TYPE_TOPIC_UNLIMITED_IN))) ||
(transitionType != null && (transitionType.equals(PnmlConstants.TRANSITION_TYPE_TOPIC_UNLIMITED_OUT)))) {
org.w3c.dom.NodeList limList = doc.getElementsByTagName(limitType);
......
aspect PnmlTransitionInputResolver {
public Set<Place> Transition.resolveInputPlaces(){
Set<Place> inputs = (Set<Place>) this.incomingPlaces();
Set<RefPlace> refPlaces = (Set<RefPlace>) this.incomingRefPlaces();
for(RefPlace rp : refPlaces){
Place root = null;
RefPlace iterRef = rp;
while (root == null){
if(iterRef.getRef().isPlace()){
root = iterRef.getRef().asPlace();
}else {
iterRef = rp.getRef().asRefPlace();
}
}
if(root != null){
inputs.add(root);
}
}
return inputs;
}
public Set<Place> Transition.resolveOutputPlaces(){
Set<Place> outputs = (Set<Place>) this.outgoingPlaces();
for (Arc outgoing : this.getOutArcList()) {
if(outgoing.getTarget() != null && outgoing.getTarget().asRefPlace() != null){
Place root = null;
RefPlace iterRef = outgoing.getTarget().asRefPlace();
while (root == null){
if(iterRef.getRef().isPlace()){
root = iterRef.getRef().asPlace();
}else {
iterRef = iterRef.getRef().asRefPlace();
}
}
if(root != null){
outputs.add(root);
}
}
}
return outputs;
}
}
\ 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