Browse Source

Fetch the token from any selected place; increased performance for combine_EPN

Yentl Van Tendeloo 8 years ago
parent
commit
f5dd1366be
2 changed files with 92 additions and 10 deletions
  1. 91 10
      models/combine_EPN.mvc
  2. 1 0
      models/petrinet_ports.mvc

+ 91 - 10
models/combine_EPN.mvc

@@ -74,6 +74,81 @@ A B {
             }
         }
 
+        {Contains} ForAll link {
+            LHS {
+                Pre_Encapsulated_PetriNet/Port pre_link_1 {
+                    label = "1"
+                    constraint_selected = $
+                        Boolean function constraint(value : Boolean):
+                            return value!
+                        $
+                    constraint = $
+                        Boolean function constraint(model : Element, name : String):
+                            return (read_nr_out(allOutgoingAssociationInstances(model, name, "Encapsulated_PetriNet/Related")) == 0)!
+                        $
+                }
+                Pre_Encapsulated_PetriNet/Port pre_link_2 {
+                    label = "2"
+                    constraint_selected = $
+                        Boolean function constraint(value : Boolean):
+                            return bool_not(value)!
+                        $
+                }
+                Pre_Encapsulated_PetriNet/Place pre_link_4 {
+                    label = "4"
+                }
+                Pre_Encapsulated_PetriNet/Place pre_link_5 {
+                    label = "5"
+                }
+                Pre_Encapsulated_PetriNet/PortPlace (pre_link_1, pre_link_4) {
+                    label = "6"
+                }
+                Pre_Encapsulated_PetriNet/PortPlace (pre_link_2, pre_link_5) {
+                    label = "7"
+                }
+
+                constraint = $
+                    Boolean function constraint(model : Element, mapping : Element):
+                        return value_eq(read_attribute(model, mapping["1"], "name"), read_attribute(model, mapping["2"], "name"))!
+                    $
+            }
+            RHS {
+                Post_Encapsulated_PetriNet/Port post_link_1 {
+                    label = "1"
+                }
+                Post_Encapsulated_PetriNet/Port post_link_2 {
+                    label = "2"
+                }
+                Post_Encapsulated_PetriNet/Related (post_link_1, post_link_2) {
+                    label = "3"
+                }
+
+                Post_Encapsulated_PetriNet/Place post_link_4 {
+                    label = "4"
+                    value_tokens = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            Integer tokens_4
+                            Integer tokens_5
+                            tokens_4 = read_attribute(model, mapping["4"], "tokens")
+                            tokens_5 = read_attribute(model, mapping["5"], "tokens")
+                            if (bool_or(tokens_4 > 0, tokens_5 > 0)):
+                                return 1!
+                            else:
+                                return 0!
+                        $
+                }
+                Post_Encapsulated_PetriNet/Place post_link_5 {
+                    label = "5"
+                }
+                Post_Encapsulated_PetriNet/PortPlace (post_link_1, post_link_4) {
+                    label = "6"
+                }
+                Post_Encapsulated_PetriNet/PortPlace (post_link_2, post_link_5) {
+                    label = "7"
+                }
+            }
+        }
+
         {Contains} ForAll merge_P2T {
             LHS {
                 Pre_Encapsulated_PetriNet/Place pre_p2t_1 {
@@ -108,11 +183,9 @@ A B {
                 Pre_Encapsulated_PetriNet/P2T (pre_p2t_4, pre_p2t_7) {
                     label = "8"
                 }
-
-                constraint = $
-                    Boolean function constraint(model : Element, mapping : Element):
-                        return value_eq(read_attribute(model, mapping["2"], "name"), read_attribute(model, mapping["5"], "name"))!
-                    $
+                Pre_Encapsulated_PetriNet/Related (pre_p2t_2, pre_p2t_5) {
+                    label = "10"
+                }
             }
             RHS {
                 Post_Encapsulated_PetriNet/Place post_p2t_1 {
@@ -142,6 +215,9 @@ A B {
                 Post_Encapsulated_PetriNet/P2T (post_p2t_1, post_p2t_7) {
                     label = "9"
                 }
+                Post_Encapsulated_PetriNet/Related (post_p2t_2, post_p2t_5) {
+                    label = "10"
+                }
             }
         }
 
@@ -180,10 +256,9 @@ A B {
                     label = "8"
                 }
 
-                constraint = $
-                    Boolean function constraint(model : Element, mapping : Element):
-                        return value_eq(read_attribute(model, mapping["2"], "name"), read_attribute(model, mapping["5"], "name"))!
-                    $
+                Pre_Encapsulated_PetriNet/Related (pre_t2p_2, pre_t2p_5) {
+                    label = "10"
+                }
             }
             RHS {
                 Post_Encapsulated_PetriNet/Place post_t2p_1 {
@@ -213,6 +288,9 @@ A B {
                 Post_Encapsulated_PetriNet/T2P (post_t2p_7, post_t2p_1) {
                     label = "9"
                 }
+                Post_Encapsulated_PetriNet/Related (post_t2p_2, post_t2p_5) {
+                    label = "10"
+                }
             }
         }
 
@@ -401,9 +479,12 @@ A B {
     OnSuccess (unselect_all, select) {}
     OnFailure (unselect_all, select) {}
 
-    OnSuccess (select, select) {}
+    OnSuccess (select, link) {}
     OnFailure (select, merge_P2T) {}
 
+    OnSuccess (link, select) {}
+    OnFailure (link, select) {}
+
     OnSuccess (merge_P2T, merge_T2P) {}
     OnFailure (merge_P2T, merge_T2P) {}
 

+ 1 - 0
models/petrinet_ports.mvc

@@ -37,4 +37,5 @@ SimpleClassDiagrams PetriNetsPorts {
     Association P2T (Place, Transition) {}
     Association T2P (Transition, Place) {}
     Association PortPlace (Port, Place) {}
+    Association Related (Port, Port) {}
 }