Sfoglia il codice sorgente

Updated partial control_to_EPN (very buggy)

Yentl Van Tendeloo 8 anni fa
parent
commit
9a7041ea39
1 ha cambiato i file con 405 aggiunte e 65 eliminazioni
  1. 405 65
      models/control_to_EPN.mvc

+ 405 - 65
models/control_to_EPN.mvc

@@ -5,169 +5,509 @@ All_RAM Control2EPN {
     Composite schedule {
         {Contains} Failure failure {}
         {Contains} Success success {}
-        {Contains} ForAll copy_transitions {
-            LHS {
-                Pre_PW_Control/Transition {
-                    label = "0"
-                }
-            }
+        {Contains} Atomic init_ports {
+            LHS {}
             RHS {
-                Post_PW_Control/Transition ct1 {
-                    label = "0"
+                Post_Encapsulated_PetriNet/Place init_place_0 {
+                    label = "00"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "cmdDown"!
+                        $
+                    value_tokens = #
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
                 }
-                Post_Encapsulated_PetriNet/Transition ct2 {
-                    label = "1"
+                Post_Encapsulated_PetriNet/Port init_port_0 {
+                    label = "10"
                     value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "cmdDown"!
+                        $
+                }
+                Post_Encapsulated_PetriNet/PortPlace (init_port_0, init_place_0) {
+                    label = "20"
+                }
+
+                Post_Encapsulated_PetriNet/Place init_place_1 {
+                    label = "01"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "cmdNeutral"!
+                        $
+                    value_tokens = #
                         Integer function value(model : Element, name : String, mapping : Element):
-                            return read_attribute(model, mapping["0"], "name")!
+                            return 0!
                         $
                 }
-                Post_C2P_TransitionLink (ct1, ct2){
-                    label = "2"
+                Post_Encapsulated_PetriNet/Port init_port_1 {
+                    label = "11"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "cmdNeutral"!
+                        $
+                }
+                Post_Encapsulated_PetriNet/PortPlace (init_port_1, init_place_1) {
+                    label = "21"
+                }
+                Post_Encapsulated_PetriNet/Place init_place_2 {
+                    label = "02"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "cmdUp"!
+                        $
+                    value_tokens = #
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                }
+                Post_Encapsulated_PetriNet/Port init_port_2 {
+                    label = "12"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "cmdUp"!
+                        $
+                }
+                Post_Encapsulated_PetriNet/PortPlace (init_port_2, init_place_2) {
+                    label = "22"
+                }
+                Post_Encapsulated_PetriNet/Place init_place_3 {
+                    label = "03"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "objDetected"!
+                        $
+                    value_tokens = #
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                }
+                Post_Encapsulated_PetriNet/Port init_port_3 {
+                    label = "13"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "objDetected"!
+                        $
+                }
+                Post_Encapsulated_PetriNet/PortPlace (init_port_3, init_place_3) {
+                    label = "23"
+                }
+                Post_Encapsulated_PetriNet/Place init_place_4 {
+                    label = "04"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "no_objDetected"!
+                        $
+                    value_tokens = #
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                }
+                Post_Encapsulated_PetriNet/Port init_port_4 {
+                    label = "14"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "no_objDetected"!
+                        $
+                }
+                Post_Encapsulated_PetriNet/PortPlace (init_port_4, init_place_4) {
+                    label = "24"
+                }
+                Post_Encapsulated_PetriNet/Place init_place_5 {
+                    label = "05"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "up"!
+                        $
+                    value_tokens = #
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                }
+                Post_Encapsulated_PetriNet/Port init_port_5 {
+                    label = "15"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "up"!
+                        $
+                }
+                Post_Encapsulated_PetriNet/PortPlace (init_port_5, init_place_5) {
+                    label = "25"
+                }
+                Post_Encapsulated_PetriNet/Place init_place_6 {
+                    label = "06"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "neutral"!
+                        $
+                    value_tokens = #
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                }
+                Post_Encapsulated_PetriNet/Port init_port_6 {
+                    label = "16"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "neutral"!
+                        $
+                }
+                Post_Encapsulated_PetriNet/PortPlace (init_port_6, init_place_6) {
+                    label = "26"
+                }
+                Post_Encapsulated_PetriNet/Place init_place_7 {
+                    label = "07"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "down"!
+                        $
+                    value_tokens = #
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                }
+                Post_Encapsulated_PetriNet/Port init_port_7 {
+                    label = "17"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "down"!
+                        $
+                }
+                Post_Encapsulated_PetriNet/PortPlace (init_port_7, init_place_7) {
+                    label = "27"
+                }
+
+                Post_Encapsulated_PetriNet/Place init_place_8 {
+                    label = "08"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "interrupt"!
+                        $
+                    value_tokens = #
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                }
+                Post_Encapsulated_PetriNet/Port init_port_8 {
+                    label = "18"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "interrupt"!
+                        $
+                }
+                Post_Encapsulated_PetriNet/PortPlace (init_port_8, init_place_8) {
+                    label = "28"
                 }
             }
         }
-        {Contains} ForAll copy_places {
+        {Contains} ForAll create_states {
             LHS {
-                Pre_PW_Control/State {
+                Pre_Control_PW/State {
                     label = "0"
                 }
             }
             RHS {
-                Post_PW_Control/State cp1 {
+                Post_Control_PW/State cs_s {
                     label = "0"
                 }
-                Post_Encapsulated_PetriNet/Place cp2 {
+                Post_Encapsulated_PetriNet/Place cs_p {
                     label = "1"
-                    value_nbTokens = $
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["0"], "name")!
+                        $
+                    value_tokens = $
                         Integer function value(model : Element, name : String, mapping : Element):
-                            if (value_eq(read_attribute(model, mapping["0"], "initial"), True)):
+                            if (value_eq(read_attribute(model, mapping["0"], "isInitial"), True)):
                                 return 1!
                             else:
                                 return 0!
                         $
-                    value_name = $
-                        Integer function value(model : Element, name : String, mapping : Element):
-                            return read_attribute(model, mapping["0"], "name")!
-                        $
                 }
-                Post_C2P_PlaceLink (cp1, cp2){
+                Post_CTRL2EPN_link (cs_s, cs_p) {
                     label = "2"
                 }
             }
         }
-        {Contains} ForAll copy_P2T {
+
+        {Contains} ForAll create_transitions {
             LHS {
-                Pre_PW_Control/State cp2t_p{
+                Pre_Control_PW/State pre_ct_s1 {
                     label = "0"
                 }
-                Pre_PW_Control/Transition cp2t_t{
+                Pre_Control_PW/State pre_ct_s2 {
                     label = "1"
                 }
-                Pre_PW_Control/From (cp2t_p, cp2t_t){
+                Pre_Control_PW/Transition (pre_ct_s1, pre_ct_s2) {
                     label = "2"
                 }
-                Pre_Encapsulated_PetriNet/Place cp2t_p2{
+                Pre_Encapsulated_PetriNet/Place pre_ct_p1 {
                     label = "3"
                 }
-                Pre_Encapsulated_PetriNet/Transition cp2t_t2{
+                Pre_Encapsulated_PetriNet/Place pre_ct_p2 {
                     label = "4"
                 }
-                Pre_C2P_PlaceLink (cp2t_p, cp2t_p2){
+                Pre_CTRL2EPN_link (pre_ct_s1, pre_ct_p1) {
                     label = "5"
                 }
-                Pre_C2P_TransitionLink (cp2t_t, cp2t_t2){
+                Pre_CTRL2EPN_link (pre_ct_s2, pre_ct_p2) {
                     label = "6"
                 }
+                Pre_Encapsulated_PetriNet/Place pre_ps1 {
+                    label = "7"
+                }
+                Pre_Encapsulated_PetriNet/Place pre_ps2 {
+                    label = "8"
+                }
+                Pre_Encapsulated_PetriNet/Port pre_pp1 {
+                    label = "9"
+                    constraint_name = $
+                        Boolean constraint(host_model : Element, name : String):
+                            String t
+                            t = read_attribute(host_model, name, "name")
+                            if (bool_or(bool_or(t == "up", t == "neutral"), t == "down")):
+                                return True:
+                        $
+                }
+                Pre_Encapsulated_PetriNet/Port pre_pp2 {
+                    label = "10"
+                    constraint_name = $
+                        Boolean constraint(host_model : Element, name : String):
+                            String t
+                            t = read_attribute(host_model, name, "name")
+                            if (bool_or(bool_or(t == "up", t == "neutral"), t == "down")):
+                                return True:
+                        $
+                }
+                Pre_Encapsulated_PetriNet/PortPlace (pre_pp1, pre_ps1) {
+                    label = "11"
+                }
+                Pre_Encapsulated_PetriNet/PortPlace (pre_pp2, pre_ps2) {
+                    label = "12"
+                }
+
+                constraint = $
+                    Boolean constraint (host_model : Element, mapping : Element):
+                        // Check whether the bound primary places match with the state
+                        String s1_type
+                        String s2_type
+                        String ps1_type
+                        String ps2_type
+                        s1_type = read_type(host_model, mapping["0"])
+                        s2_type = read_type(host_model, mapping["1"])
+                        ps1_type = read_attribute(host_model, mapping["9"], "name")
+                        ps2_type = read_attribute(host_model, mapping["10"], "name")
+
+                        if (s1_type == "Up"):
+                            if (ps1_type != "up"):
+                                return False!
+                        elif (s1_type == "Down"):
+                            if (ps1_type != "down"):
+                                return False!
+                        elif (s1_type == "Neutral"):
+                            if (ps1_type != "neutral"):
+                                return False!
+
+                        if (s2_type == "Up"):
+                            if (ps2_type != "up"):
+                                return False!
+                        elif (s2_type == "Down"):
+                            if (ps2_type != "down"):
+                                return False!
+                        elif (s2_type == "Neutral"):
+                            if (ps2_type != "neutral"):
+                                return False!
+
+                        return True!
+                    $
             }
             RHS {
-                Post_PW_Control/State rhs_cp2t_p{
+                Post_Control_PW/State post_ct_s1 {
                     label = "0"
                 }
-                Post_PW_Control/Transition rhs_cp2t_t{
+                Post_Control_PW/State post_ct_s2 {
                     label = "1"
                 }
-                Post_PW_Control/From rhs_cp2t_p2t (rhs_cp2t_p, rhs_cp2t_t){
+                Post_Control_PW/Transition (post_ct_s1, post_ct_s2) {
                     label = "2"
                 }
-                Post_Encapsulated_PetriNet/Place rhs_cp2t_p2 {
+                Post_Encapsulated_PetriNet/Place post_ct_p1 {
                     label = "3"
                 }
-                Post_Encapsulated_PetriNet/Transition rhs_cp2t_t2 {
+                Post_Encapsulated_PetriNet/Place post_ct_p2 {
                     label = "4"
                 }
-                Post_C2P_PlaceLink (rhs_cp2t_p, rhs_cp2t_p2){
+                Post_CTRL2EPN_link (post_ct_s1, post_ct_p1) {
                     label = "5"
                 }
-                Post_C2P_TransitionLink (rhs_cp2t_t, rhs_cp2t_t2){
+                Post_CTRL2EPN_link (post_ct_s2, post_ct_p2) {
                     label = "6"
                 }
-                Post_Encapsulated_PetriNet/P2T rhs_cp2t_p2t2(rhs_cp2t_p2, rhs_cp2t_t2) {
+                Post_Encapsulated_PetriNet/Place post_ps1 {
                     label = "7"
                 }
+                Post_Encapsulated_PetriNet/Place post_ps2 {
+                    label = "8"
+                }
+                Post_Encapsulated_PetriNet/Port post_pp1 {
+                    label = "9"
+                }
+                Post_Encapsulated_PetriNet/Port post_pp2 {
+                    label = "10"
+                }
+                Post_Encapsulated_PetriNet/PortPlace (post_pp1, post_ps1) {
+                    label = "11"
+                }
+                Post_Encapsulated_PetriNet/PortPlace (post_pp2, post_ps2) {
+                    label = "12"
+                }
+                Post_Encapsulated_PetriNet/Transition post_ct_t {
+                    label = "13"
+                }
+                Post_Encapsulated_PetriNet/P2T (post_ps1, post_ct_t) {
+                    label = "14"
+                }
+                Post_Encapsulated_PetriNet/T2P (post_ct_t, post_ps2) {
+                    label = "15"
+                }
+                Post_Encapsulated_PetriNet/P2T (post_ct_p1, post_ct_t) {
+                    label = "16"
+                }
+                Post_Encapsulated_PetriNet/T2P (post_ct_t, post_ct_p2) {
+                    label = "17"
+                }
             }
         }
-        {Contains} ForAll copy_T2P {
+
+        {Contains} ForAll check_object_present {
             LHS {
-                Pre_PW_Control/State ct2p_p{
+                Pre_Control_PW/State pre_cop_s1 {
                     label = "0"
                 }
-                Pre_PW_Control/Transition ct2p_t{
+                Pre_Control_PW/State pre_cop_s2 {
                     label = "1"
                 }
-                Pre_PW_Control/To (ct2p_t, ct2p_p){
+                Pre_Control_PW/Transition (pre_cop_s1, pre_cop_s2) {
                     label = "2"
+                    constraint_objDetected = $
+                        Boolean constraint(host_model : Element, name : String):
+                            String t
+                            t = read_attribute(host_model, name, "objDetected")
+                            if (bool_or(t == "Y", t == "N")):
+                                return True!
+                            else:
+                                return False!
+                        $
                 }
-                Pre_Encapsulated_PetriNet/Place ct2p_p2{
+                Pre_Encapsulated_PetriNet/Place pre_cop_p1 {
                     label = "3"
                 }
-                Pre_Encapsulated_PetriNet/Transition ct2p_t2{
+                Pre_Encapsulated_PetriNet/Place pre_cop_p2 {
                     label = "4"
                 }
-                Pre_C2P_PlaceLink (ct2p_p, ct2p_p2){
+                Pre_CTRL2EPN_link (pre_cop_s1, pre_cop_p1) {
                     label = "5"
                 }
-                Pre_C2P_TransitionLink (ct2p_t, ct2p_t2){
+                Pre_CTRL2EPN_link (pre_cop_s2, pre_cop_p2) {
                     label = "6"
                 }
+                Pre_Encapsulated_PetriNet/Place pre_cop_ps1 {
+                    label = "7"
+                }
+                Pre_Encapsulated_PetriNet/Port pre_pp1 {
+                    label = "9"
+                    constraint_name = $
+                        Boolean constraint(host_model : Element, name : String):
+                            String t
+                            t = read_attribute(host_model, name, "name")
+                            if (bool_or(t == "objDetected", t == "no_objDetected")):
+                                return True!
+                            else:
+                                return False!
+                        $
+                }
+                Pre_Encapsulated_PetriNet/PortPlace (pre_pp1, pre_ps1) {
+                    label = "11"
+                }
+                Pre_Encapsulated_PetriNet/Transition pre_cop_t {
+                    label = "13"
+                }
+                Pre_Encapsulated_PetriNet/P2T (pre_ps1, pre_cop_t) {
+                    label = "14"
+                }
+                Pre_Encapsulated_PetriNet/T2P (pre_cop_t, pre_ps2) {
+                    label = "15"
+                }
+
+                constraint = $
+                    Boolean constraint (host_model : Element, mapping : Element):
+                        // Check whether the bound primary places match with the state
+                        String s1_value
+                        String ps1_type
+                        s1_value = read_attribute(host_model, mapping["2"], "objDetected")
+                        ps1_type = read_attribute(host_model, mapping["9"], "name")
+
+                        if (s1_value == "Y"):
+                            if (ps1_type == "objDetected"):
+                                return True!
+                        elif (s1_value == "N"):
+                            if (ps1_type != "no_objDetected"):
+                                return True!
+
+                        return False!
+                    $
             }
             RHS {
-                Post_PW_Control/State rhs_ct2p_p{
+                Post_Control_PW/State post_ct_s1 {
                     label = "0"
                 }
-                Post_PW_Control/Transition rhs_ct2p_t{
+                Post_Control_PW/State post_ct_s2 {
                     label = "1"
                 }
-                Post_PW_Control/To (rhs_ct2p_t, rhs_ct2p_p){
+                Post_Control_PW/Transition (post_ct_s1, post_ct_s2) {
                     label = "2"
                 }
-                Post_Encapsulated_PetriNet/Place rhs_ct2p_p2 {
+                Post_Encapsulated_PetriNet/Place post_ct_p1 {
                     label = "3"
                 }
-                Post_Encapsulated_PetriNet/Transition rhs_ct2p_t2 {
+                Post_Encapsulated_PetriNet/Place post_ct_p2 {
                     label = "4"
                 }
-                Post_C2P_PlaceLink (rhs_ct2p_p, rhs_ct2p_p2){
+                Post_CTRL2EPN_link (post_ct_s1, post_ct_p1) {
                     label = "5"
                 }
-                Post_C2P_TransitionLink (rhs_ct2p_t, rhs_ct2p_t2){
+                Post_CTRL2EPN_link (post_ct_s2, post_ct_p2) {
                     label = "6"
                 }
-                Post_Encapsulated_PetriNet/T2P (rhs_ct2p_t2, rhs_ct2p_p2) {
+                Post_Encapsulated_PetriNet/Place post_ps1 {
                     label = "7"
                 }
+                Post_Encapsulated_PetriNet/Port post_pp1 {
+                    label = "9"
+                }
+                Post_Encapsulated_PetriNet/PortPlace (post_pp1, post_ps1) {
+                    label = "11"
+                }
+                Post_Encapsulated_PetriNet/Transition post_ct_t {
+                    label = "13"
+                }
+                Post_Encapsulated_PetriNet/P2T (post_ps1, post_ct_t) {
+                    label = "14"
+                }
+                Post_Encapsulated_PetriNet/T2P (post_ct_t, post_ps2) {
+                    label = "15"
+                }
+                Post_Encapsulated_PetriNet/P2T (post_cop_obj, post_cop_t) {
+                    label = "16"
+                }
+                Post_Encapsulated_PetriNet/T2P (post_cop_t, post_cop_obj) {
+                    label = "17"
+                }
             }
         }
     }
-    OnSuccess (copy_places, copy_transitions) {}
-    OnSuccess (copy_transitions, copy_P2T) {}
-    OnSuccess (copy_P2T, copy_T2P) {}
-    OnSuccess (copy_T2P, success) {}
-    OnFailure (copy_places, copy_transitions) {}
-    OnFailure (copy_transitions, copy_P2T) {}
-    OnFailure (copy_P2T, copy_T2P) {}
-    OnFailure (copy_T2P, success) {}
-    Initial (schedule, copy_places) {}
+    Initial (schedule, init_ports) {}
 }
 
 export annotate to models/pn_annotate