Browse Source

Fixed the combine_EPN transformation

Yentl Van Tendeloo 8 years ago
parent
commit
5c3d32a433
2 changed files with 56 additions and 72 deletions
  1. 47 62
      models/combine_EPN.mvc
  2. 9 10
      models/pn_print.alc

+ 47 - 62
models/combine_EPN.mvc

@@ -28,26 +28,48 @@ A B {
                 Pre_Encapsulated_PetriNet/Place pre_s_1 {
                     label = "1"
                 }
-                Pre_Encapsulated_PetriNet/Port pre_s_2 {
+                Pre_Encapsulated_PetriNet/Port pre_s_0 {
+                    label = "0"
+                    constraint_selected = $
+                        Boolean function constraint(value : Boolean):
+                            return bool_not(value)!
+                        $
+                }
+                Pre_Encapsulated_PetriNet/PortPlace (pre_s_0, pre_s_1){
                     label = "2"
                 }
-                Pre_Encapsulated_PetriNet/PortPlace (pre_s_2, pre_s_1){
+            }
+            NAC {
+                Pre_Encapsulated_PetriNet/Port nac_s_0 {
+                    label = "0"
+                }
+                Pre_Encapsulated_PetriNet/Port nac_s_3 {
                     label = "3"
+                    constraint_selected = $
+                        Boolean function constraint(value : Boolean):
+                            return value!
+                        $
                 }
+
+                constraint = $
+                    Boolean function constraint(model : Element, mapping : Element):
+                        return value_eq(read_attribute(model, mapping["0"], "name"), read_attribute(model, mapping["3"], "name"))!
+                    $
             }
             RHS {
                 Post_Encapsulated_PetriNet/Place post_s_1 {
                     label = "1"
                 }
-                Post_Encapsulated_PetriNet/Port post_s_2 {
-                    label = "2"
+                Post_Encapsulated_PetriNet/Port post_s_0 {
+                    label = "0"
                     value_selected = $
                         Boolean function value(model : Element, name : String, mapping : Element):
+                            log("Mark as selected: " + cast_v2s(read_attribute(model, name, "name")))
                             return True!
                         $
                 }
-                Post_Encapsulated_PetriNet/PortPlace (post_s_2, post_s_1){
-                    label = "3"
+                Post_Encapsulated_PetriNet/PortPlace (post_s_0, post_s_1){
+                    label = "2"
                 }
             }
         }
@@ -72,6 +94,10 @@ A B {
                 }
                 Pre_Encapsulated_PetriNet/Port pre_p2t_5 {
                     label = "5"
+                    constraint_selected = $
+                        Boolean function constraint(value : Boolean):
+                            return bool_not(value)!
+                        $
                 }
                 Pre_Encapsulated_PetriNet/PortPlace (pre_p2t_5, pre_p2t_4){
                     label = "6"
@@ -139,6 +165,10 @@ A B {
                 }
                 Pre_Encapsulated_PetriNet/Port pre_t2p_5 {
                     label = "5"
+                    constraint_selected = $
+                        Boolean function constraint(value : Boolean):
+                            return bool_not(value)!
+                        $
                 }
                 Pre_Encapsulated_PetriNet/PortPlace (pre_t2p_5, pre_t2p_4){
                     label = "6"
@@ -195,60 +225,14 @@ A B {
                     label = "2"
                     constraint_selected = $
                         Boolean function constraint(value : Boolean):
-                            return value!
+                            return bool_not(value)!
                         $
                 }
                 Pre_Encapsulated_PetriNet/PortPlace (pre_rem_2, pre_rem_1){
                     label = "3"
                 }
-                Pre_Encapsulated_PetriNet/Place pre_rem_4 {
-                    label = "4"
-                }
-                Pre_Encapsulated_PetriNet/Port pre_rem_5 {
-                    label = "5"
-                }
-                Pre_Encapsulated_PetriNet/PortPlace (pre_rem_5, pre_rem_4){
-                    label = "6"
-                }
-
-                constraint = $
-                    Boolean function constraint(model : Element, mapping : Element):
-                        return value_eq(read_attribute(model, mapping["2"], "name"), read_attribute(model, mapping["5"], "name"))!
-                    $
             }
             RHS {
-                Post_Encapsulated_PetriNet/Place post_rem_1 {
-                    label = "1"
-                }
-                Post_Encapsulated_PetriNet/Port post_rem_2 {
-                    label = "2"
-                }
-                Post_Encapsulated_PetriNet/PortPlace (post_rem_2, post_rem_1){
-                    label = "3"
-                }
-            }
-        }
-
-        {Contains} Atomic unselect {
-            LHS {
-                Pre_Encapsulated_PetriNet/Place pre_uns_1 {
-                    label = "1"
-                }
-                Pre_Encapsulated_PetriNet/Port pre_uns_2 {
-                    label = "2"
-                    constraint_selected = $
-                        Boolean function constraint(value : Boolean):
-                            return value!
-                        $
-                }
-                Pre_Encapsulated_PetriNet/PortPlace (pre_uns_2, pre_uns_1){
-                    label = "3"
-                }
-            }
-            RHS {
-                Post_Encapsulated_PetriNet/Place post_uns_1 {
-                    label = "1"
-                }
             }
         }
 
@@ -415,18 +399,19 @@ A B {
     Initial (schedule, unselect_all) {}
 
     OnSuccess (unselect_all, select) {}
-    OnSuccess (select, merge_P2T) {}
-    OnSuccess (merge_P2T, merge_T2P) {}
-    OnSuccess (merge_T2P, remove_old) {}
-    OnSuccess (remove_old, unselect) {}
-    OnSuccess (unselect, select) {}
-    OnFailure (select, copy_places) {}
-
     OnFailure (unselect_all, select) {}
+
+    OnSuccess (select, select) {}
+    OnFailure (select, merge_P2T) {}
+
+    OnSuccess (merge_P2T, merge_T2P) {}
     OnFailure (merge_P2T, merge_T2P) {}
+
+    OnSuccess (merge_T2P, remove_old) {}
     OnFailure (merge_T2P, remove_old) {}
-    OnFailure (remove_old, unselect) {}
-    OnFailure (unselect, failure) {}
+
+    OnSuccess (remove_old, copy_places) {}
+    OnFailure (remove_old, copy_places) {}
 
     OnSuccess (copy_places, copy_transitions) {}
     OnSuccess (copy_transitions, copy_P2T) {}

+ 9 - 10
models/pn_print.alc

@@ -13,8 +13,6 @@ Element function pn_print(params : Element, output_mms : Element):
 	String t
 	Element all_t
 
-	log(set_to_string(dict_keys(model["metamodel"]["model"])))
-
 	log("Places:")
 	all_places = allInstances(model, "Place")
 	while (read_nr_out(all_places) > 0):
@@ -24,21 +22,22 @@ Element function pn_print(params : Element, output_mms : Element):
 
 		log((("  " + name) + ": ") + cast_v2s(tokens))
 
+	log("Transitions:")
+	all_places = allInstances(model, "Transition")
+	while (read_nr_out(all_places) > 0):
+		place = set_pop(all_places)
+		name = read_attribute(model, place, "name")
+
+		log("  " + name)
+
 		all_t = allIncomingAssociationInstances(model, place, "P2T")
 		while (read_nr_out(all_t) > 0):
 			t = set_pop(all_t)
 			log("    <-- " + cast_v2s(read_attribute(model, readAssociationSource(model, t), "name")))
+
 		all_t = allOutgoingAssociationInstances(model, place, "T2P")
 		while (read_nr_out(all_t) > 0):
 			t = set_pop(all_t)
 			log("    --> " + cast_v2s(read_attribute(model, readAssociationDestination(model, t), "name")))
 
-	log("Transitions:")
-	all_places = allInstances(model, "Transition")
-	while (read_nr_out(all_places) > 0):
-		place = set_pop(all_places)
-		name = read_attribute(model, place, "name")
-
-		log("  " + name)
-
 	return create_node()!