Browse Source

Merge branch 'master' into testing

Yentl Van Tendeloo 8 years ago
parent
commit
c54e4b2d61
5 changed files with 190 additions and 103 deletions
  1. 162 81
      addis/PM_to_SCCD.mvc
  2. 13 13
      addis/SCCD_Example.mvc
  3. 6 6
      addis/SCCD_MetaModel.mvc
  4. 1 1
      addis/Test_PM2SCCD.py
  5. 8 2
      models/SCCD_execute.alc

+ 162 - 81
addis/PM_to_SCCD.mvc

@@ -41,6 +41,7 @@ Composite schedule {
                         code = string_join(code, "\tlog(\"INSIDE ORCHESTRATOR CLASS CONSTRUCTOR\")\n")
                         code = string_join(code, "\treturn!")
                         result = compile_code(code)
+                        log(code)
                         if element_eq(result, read_root()):
                             return read_root()!
                         else:
@@ -84,9 +85,27 @@ Composite schedule {
                     String function value(model : Element, name : String, mapping : Element):
                         return "Running"!
                     $
+                value_onEntryScript = $
+                     Element function value(model : Element, name : String, mapping : Element):
+                        Element result
+                        String code
+                        code = "include \"primitives.alh\"\n"
+                        code = string_join(code, "Void function constructor_body (attributes : Element):\n")
+                        code = string_join(code, "\tlog(\"INSIDE PARALLEL RUNNING STATE\")\n")
+                        code = string_join(code, "\treturn!")
+                        result = compile_code(code)
+                        if element_eq(result, read_root()):
+                            return read_root()!
+                        else:
+                            return result!
+                    $
             }
             Post_SCCD/transition (post_bs_5, post_ps_7) {
                 label = "8"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
             }
             Post_SCCD/CompositeState post_cs_9 {
                 label = "9"
@@ -124,6 +143,10 @@ Composite schedule {
             }
             Post_SCCD/transition post_trans_15(post_bs_14, post_bs_14) {
                 label = "15"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_event = $
                     String function value(model : Element, name : String, mapping : Element):
                         return "spawn_exec"!
@@ -186,14 +209,17 @@ Composite schedule {
             }
             Post_SCCD/transition post_trans_23 (post_bs_19, post_bs_20) {
                 label = "23"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_cond = $
                     Element function value(model : Element, name : String, mapping : Element):
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function script(attributes : Element, parameters : Element):\n")
-                        code = string_join(code, "\tinteger_gt(list_len(attributes[\"queue\"]), 0)\n")
-                        code = string_join(code, "\treturn!")
+                        code = string_join(code, "Boolean function script(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "\treturn integer_gt(list_len(attributes[\"queue\"]), 0)!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -211,16 +237,18 @@ Composite schedule {
                     String function value(model : Element, name : String, mapping : Element):
                         return "cd"!
                     $
-                value_parameters = $
+                value_parameter = $
                     Element function raise(model : Element, name : String, mapping : Element):
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function script(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "Element function script(attributes : Element, parameters : Element):\n")
                         code = string_join(code, "\tElement param\n")
                         code = string_join(code, "\tparam = list_create()\n")
+                        code = string_join(code, "\tlist_append(param, 'association_name')\n")
                         code = string_join(code, "\tlist_append(param, list_read(attributes[\"queue\"], 0))\n")
-                        code = string_join(code, "\treturn!")
+                        code = string_join(code, "\tlist_append(param, read_root())\n")
+                        code = string_join(code, "\treturn param!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -261,6 +289,10 @@ Composite schedule {
             }
             Post_SCCD/transition post_trans_30 (post_bs_20, post_bs_19) {
                 label = "30"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_event = $
                     String function value(model : Element, name : String, mapping : Element):
                         return "instance_created"!
@@ -298,6 +330,8 @@ Composite schedule {
                         Element result
                         code = "include \"primitives.alh\"\n"
                         code = string_join(code, "String function script(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "\tlog(\"TARGET\")\n")
+                        code = string_join(code, "\tlog(parameters[0])\n")
                         code = string_join(code, "\treturn parameters[0]!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
@@ -305,17 +339,17 @@ Composite schedule {
                         else:
                             return result!
                     $
-                value_parameters = $
+                value_parameter = $
                     Element function raise(model : Element, name : String, mapping : Element):
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function script(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "Element function script(attributes : Element, parameters : Element):\n")
                         code = string_join(code, "\tElement param\n")
                         code = string_join(code, "\tparam = list_create()\n")
                         code = string_join(code, "\tlist_append(param, parameters[0])\n")
                         code = string_join(code, "\tlist_append(param, attributes[\"id\"])\n")
-                        code = string_join(code, "\treturn!")
+                        code = string_join(code, "\treturn param!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -352,6 +386,10 @@ Composite schedule {
             }
             Post_SCCD/transition post_trans_35 (post_ps_7, post_bs_33) {
                 label = "35"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_event = $
                     String function value(model : Element, name : String, mapping : Element):
                         return "process_done"!
@@ -590,12 +628,14 @@ Composite schedule {
                     Element function value(model : Element, name : String, mapping : Element):
                         String code
                         Element result
-                        String onEntryScript
-                        onEntryScript = read_attribute(model, mapping["0"], "onEntryScript")
+                        String script
+                        script = read_attribute(model, mapping["0"], "onEntryScript")
                         code = "include \"primitives.alh\"\n"
                         code = string_join(code, "Void function onEntryScript (attributes : Element):\n")
-                        code = string_join(code, onEntryScript)
-                        code = string_join(code, "\n\treturn!")
+                        code = string_join(code, "\tlog(\"INSIDE INIT STATE\")\n")
+                        code = string_join(code, script)
+                        code = string_join(code, "\tlog(\"FINISHED EXECUTING INIT ONENTRY\")\n")
+                        code = string_join(code, "\treturn!")
                         log(code)
                         result = compile_code(code)
                         if element_eq(result, read_root()):
@@ -681,6 +721,20 @@ Composite schedule {
                     Boolean function value(model : Element, name : String, mapping : Element):
                         return True!
                     $
+                value_onEntryScript = $
+                     Element function value(model : Element, name : String, mapping : Element):
+                        Element result
+                        String code
+                        code = "include \"primitives.alh\"\n"
+                        code = string_join(code, "Void function constructor_body (attributes : Element):\n")
+                        code = string_join(code, "\tlog(\"INSIDE EXEC WAITING STATE\")\n")
+                        code = string_join(code, "\treturn!")
+                        result = compile_code(code)
+                        if element_eq(result, read_root()):
+                            return read_root()!
+                        else:
+                            return result!
+                    $
             }
             Post_SCCD/BasicState post_bs_7 {
                 label = "7"
@@ -697,42 +751,45 @@ Composite schedule {
             }
             Post_SCCD/transition post_trans_10 (post_bs_6, post_bs_7) {
                 label = "10"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_cond = $
                     Element function value(model : Element, name : String, mapping : Element):
                         String type
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function cond(attributes : Element, parameters : Element):\n")
-
+                        code = string_join(code, "Boolean function cond(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "\tBoolean guard\n")
                         type = read_type(model, mapping["0"])
                         if bool_or(type == "PM/Join", type == "PM/Start"):
-                            code = string_join(code, "\tvalue_eq(attributes['token']['")
+                            code = string_join(code, "\treturn value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
-                            code = string_join(code, "'], True)")
+                            code = string_join(code, "'], True)!")
                         elif (type == "PM/Decision"):
-                            code = string_join(code, "\tbool_and(value_eq(attributes['token']['")
+                            code = string_join(code, "\treturn bool_and(value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'], True), value_eq(attributes['decision_consumes']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'],")
                             code = string_join(code, read_attribute(model, mapping["2"], "value"))
-                            code = string_join(code, "))")
+                            code = string_join(code, "))!")
                         elif (type == "PM/Exec"):
-                            code = string_join(code, "\tbool_and(value_eq(attributes['token']['")
+                            code = string_join(code, "\treturn bool_and(value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'], True) , value_eq(attributes['finish']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
-                            code = string_join(code, "'], True))")
+                            code = string_join(code, "'], True))!")
                         elif (type == "PM/Fork"):
-                            code = string_join(code, "\tbool_and(value_eq(attributes['token']['")
+                            code = string_join(code, "\treturn bool_and(value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'], True), value_eq(attributes['finish']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "']['")
                             code = string_join(code, read_attribute(model, mapping["1"], "id"))
-                            code = string_join(code, "'],False))")
-                        code = string_join(code, "\n\treturn!")
+                            code = string_join(code, "'],False))!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -754,7 +811,7 @@ Composite schedule {
                             code = string_join(code, "', False)\n")
                             code = string_join(code, "\tdict_overwrite(attributes['token'],'")
                             code = string_join(code, read_attribute(model, mapping["1"], "id"))
-                            code = string_join(code, "',True)")
+                            code = string_join(code, "',True)\n\tlog(\"START TRIGGERED\")")
                         elif (type == "PM/Fork"):
                             code = string_join(code, "\tdict_overwrite(attributes['token'],'")
                             code = string_join(code, read_attribute(model, mapping["1"], "id"))
@@ -787,18 +844,18 @@ Composite schedule {
                     String function value(model : Element, name : String, mapping : Element):
                         return "local"!
                     $
-                value_parameters = $
+                value_parameter = $
                     Element function raise(model : Element, name : String, mapping : Element):
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function script(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "Element function parameter(attributes : Element, parameters : Element):\n")
                         code = string_join(code, "\tElement param\n")
                         code = string_join(code, "\tparam = list_create()\n")
                         code = string_join(code, "\tlist_append(param,'")
                         code = string_join(code, read_attribute(model, mapping["1"], "name"))
                         code = string_join(code, "')\n")
-                        code = string_join(code, "\treturn!")
+                        code = string_join(code, "\treturn param!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -825,6 +882,10 @@ Composite schedule {
             }
             Post_SCCD/transition post_etrans_15 (post_bs_7, post_bs_6) {
                 label = "15"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_event = $
                     String function value(model : Element, name : String, mapping : Element):
                         return "terminated"!
@@ -834,11 +895,10 @@ Composite schedule {
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function cond(attributes : Element, parameters : Element):\n")
-                        code = string_join(code, "\tvalue_eq('")
+                        code = string_join(code, "Boolean function cond(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "\treturn value_eq('")
                         code = string_join(code, read_attribute(model, mapping["1"], "name"))
-                        code = string_join(code, "',parameters[0])")
-                        code = string_join(code, "\n\treturn!")
+                        code = string_join(code, "',parameters[0])!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -947,6 +1007,10 @@ Composite schedule {
             }
             Post_SCCD/transition post_trans_7 (post_pbs_5, post_pbs_5) {
                 label = "7"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_event = $
                     String function value(model : Element, name : String, mapping : Element):
                         return "save"!
@@ -956,11 +1020,10 @@ Composite schedule {
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function cond(attributes : Element, parameters : Element):\n")
-                        code = string_join(code, "\tvalue_eq('")
+                        code = string_join(code, "Boolean function cond(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "\treturn value_eq('")
                         code = string_join(code, read_attribute(model, mapping["0"], "name"))
-                        code = string_join(code, "',parameters[1])")
-                        code = string_join(code, "\n\treturn!")
+                        code = string_join(code, "',parameters[1])!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -1065,6 +1128,10 @@ Composite schedule {
             }
             Post_SCCD/transition post_trans_consumes_7 (post_bs_consumes_5, post_bs_consumes_5) {
                 label = "7"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_event = $
                     String function value(model : Element, name : String, mapping : Element):
                         return "load"!
@@ -1074,11 +1141,10 @@ Composite schedule {
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function cond(attributes : Element, parameters : Element):\n")
-                        code = string_join(code, "\tvalue_eq('")
+                        code = string_join(code, "Boolean function cond(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "\treturn value_eq('")
                         code = string_join(code, read_attribute(model, mapping["0"], "name"))
-                        code = string_join(code, "',parameters[1])")
-                        code = string_join(code, "\n\treturn!")
+                        code = string_join(code, "',parameters[1])!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -1125,15 +1191,14 @@ Composite schedule {
                         return "narrow"!
                     $
                 value_target = $
-                    Element function value(model : Element, name : String, mapping : Element):
+                    String function value(model : Element, name : String, mapping : Element):
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function target(attributes : Element, parameters : Element):\n")
-                        code = string_join(code, "\tattributes['assn_names']['")
+                        code = string_join(code, "String function target(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "\treturn attributes['assn_names']['")
                         code = string_join(code, read_attribute(model, mapping["0"], "name"))
-                        code = string_join(code, "']")
-                        code = string_join(code, "\n\treturn!")
+                        code = string_join(code, "']!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -1148,9 +1213,8 @@ Composite schedule {
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function exp(attributes : Element, parameters : Element):\n")
-                        code = string_join(code, "\tattributes['data'][parameters[0]]")
-                        code = string_join(code, "\n\treturn!")
+                        code = string_join(code, "String function exp(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "\treturn attributes['data'][parameters[0]]!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -1263,42 +1327,45 @@ Composite schedule {
             }
             Post_SCCD/transition post_10(post_8, post_8) {
                 label = "10"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_cond = $
                     Element function value(model : Element, name : String, mapping : Element):
                         String type
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function cond(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "Boolean function cond(attributes : Element, parameters : Element):\n")
 
                         type = read_type(model, mapping["0"])
                         if bool_or(type == "PM/Join", type == "PM/Start"):
-                            code = string_join(code, "\tvalue_eq(attributes['token']['")
+                            code = string_join(code, "\treturn value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
-                            code = string_join(code, "'], True)")
+                            code = string_join(code, "'], True)!")
                         elif (type == "PM/Decision"):
-                            code = string_join(code, "\tbool_and(value_eq(attributes['token']['")
+                            code = string_join(code, "\treturn bool_and(value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'], True),value_eq(attributes['decision_consumes']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'],")
                             code = string_join(code, read_attribute(model, mapping["2"], "value"))
-                            code = string_join(code, "))")
+                            code = string_join(code, "))!")
                         elif (type == "PM/Exec"):
-                            code = string_join(code, "\tbool_and(value_eq(attributes['token']['")
+                            code = string_join(code, "\treturn bool_and(value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'],True), value_eq(attributes['finish']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
-                            code = string_join(code, "'],True))")
+                            code = string_join(code, "'],True))!")
                         elif (type == "PM/Fork"):
-                            code = string_join(code, "\tbool_and(value_eq(attributes['token']['")
+                            code = string_join(code, "\treturn bool_and(value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'],True),value_eq(attributes['finish']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "']['")
                             code = string_join(code, read_attribute(model, mapping["1"], "id"))
-                            code = string_join(code, "'],False))")
-                        code = string_join(code, "\n\treturn!")
+                            code = string_join(code, "'],False))!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -1459,23 +1526,27 @@ Composite schedule {
             }
             Post_SCCD/transition post_f_12(post_f_8, post_f_9) {
                 label = "12"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_cond = $
                     String function value(model : Element, name : String, mapping : Element):
                         String type
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function cond(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "Boolean function cond(attributes : Element, parameters : Element):\n")
 
                         type = read_type(model, mapping["0"])
                         if bool_or(type == "PM/Join", type == "PM/Start"):
-                            code = string_join(code,"\tbool_and(value_eq(attributes['token']['")
+                            code = string_join(code,"\treturn bool_and(value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'],True), value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["1"], "id"))
-                            code = string_join(code, "'],False))")
+                            code = string_join(code, "'],False))!")
                         elif (type == "PM/Decision"):
-                            code = string_join(code,"\tbool_and(bool_and(value_eq(attributes['token']['")
+                            code = string_join(code,"\treturn bool_and(bool_and(value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'],True), value_eq(attributes['decision_consumes']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
@@ -1483,16 +1554,15 @@ Composite schedule {
                             code = string_join(code, read_attribute(model, mapping["2"], "value"))
                             code = string_join(code, ")), value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["1"], "id"))
-                            code = string_join(code, "'],False))")
+                            code = string_join(code, "'],False))!")
                         elif (type == "PM/Exec"):
-                            code = string_join(code,"\tbool_and(bool_and(value_eq(attributes['token']['")
+                            code = string_join(code,"\treturn bool_and(bool_and(value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'],True), value_eq(attributes['finish']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'],True)), value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["1"], "id"))
-                            code = string_join(code, "'],False))")
-                        code = string_join(code, "\n\treturn!")
+                            code = string_join(code, "'],False))!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -1535,6 +1605,10 @@ Composite schedule {
             }
             Post_SCCD/transition post_f_13(post_f_9, post_f_8) {
                 label = "13"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_cond = $
                     Element function value(model : Element, name : String, mapping : Element):
                         String joined_str
@@ -1546,7 +1620,7 @@ Composite schedule {
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function cond(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "Boolean function cond(attributes : Element, parameters : Element):\n")
 
                         last_operand = ""
                         pairs = create_node()
@@ -1603,9 +1677,9 @@ Composite schedule {
                             joined_str = string_join(joined_str, ")")
                         elif list_len(pairs) == 1:
                             joined_str = list_read(pairs, 0)
-                        code = string_join(code, "\t")
+                        code = string_join(code, "\treturn ")
                         code = string_join(code, joined_str)
-                        code = string_join(code, "\n\treturn!")
+                        code = string_join(code, "!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -1716,6 +1790,10 @@ Composite schedule {
             }
             Post_SCCD/transition post_j_10(post_j_8, post_j_8) {
                 label = "10"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_cond = $
                     Element function value(model : Element, name : String, mapping : Element):
                         String joined_str
@@ -1727,7 +1805,7 @@ Composite schedule {
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function cond(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "Boolean function cond(attributes : Element, parameters : Element):\n")
 
                         pairs = create_node()
                         incoming_assns = allIncomingAssociationInstances(model, mapping["0"], "PM/Next")
@@ -1767,7 +1845,7 @@ Composite schedule {
                             i = 0
                             while (i < list_len(pairs)):
                                 if joined_str == "":
-                                    joined_str = string_join("\tbool_and(", list_read(pairs,i))
+                                    joined_str = string_join("\treturn bool_and(", list_read(pairs,i))
                                     i = i + 1
                                     joined_str = string_join(joined_str," , ")
                                     joined_str = string_join(joined_str, list_read(pairs,i))
@@ -1780,10 +1858,10 @@ Composite schedule {
                                     i = i + 1
                                     joined_str = string_join(joined_str, ")")
                         elif value_eq(list_len(pairs), 1):
-                            joined_str = string_join("\t", list_read(pairs, 0))
+                            joined_str = string_join("\treturn ", list_read(pairs, 0))
 
                         code = string_join(code, joined_str)
-                        code = string_join(code, "\n\treturn!")
+                        code = string_join(code, "!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!
@@ -1921,34 +1999,37 @@ Composite schedule {
             }
             Post_SCCD/transition post_e_7(post_e_5, post_e_5) {
                 label = "7"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return name!
+                    $
                 value_cond = $
                     Element function value(model : Element, name : String, mapping : Element):
                         String type
                         String code
                         Element result
                         code = "include \"primitives.alh\"\n"
-                        code = string_join(code, "Void function cond(attributes : Element, parameters : Element):\n")
+                        code = string_join(code, "Boolean function cond(attributes : Element, parameters : Element):\n")
 
                         type = read_type(model, mapping["0"])
                         if bool_or(bool_or(type == "PM/Join", type == "PM/Fork"),type=="PM/Start"):
-                            code = string_join(code, "\tvalue_eq(attributes['token']['")
+                            code = string_join(code, "\treturn value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
-                            code = string_join(code, "'],True)")
+                            code = string_join(code, "'],True)!")
                         elif (type == "PM/Decision"):
-                            code = string_join(code, "\tbool_and(value_eq(attributes['token']['")
+                            code = string_join(code, "\treturn bool_and(value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'],True), value_eq(attributes['decision_consumes']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'],")
                             code = string_join(code, read_attribute(model, mapping["11"], "value"))
-                            code = string_join(code, "))")
+                            code = string_join(code, "))!")
                         elif (type == "PM/Exec"):
-                            code = string_join(code, "\tbool_and(value_eq(attributes['token']['")
+                            code = string_join(code, "\treturn bool_and(value_eq(attributes['token']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
                             code = string_join(code, "'],True), value_eq(attributes['finish']['")
                             code = string_join(code, read_attribute(model, mapping["0"], "id"))
-                            code = string_join(code, "'],True))")
-                        code = string_join(code, "\n\treturn!")
+                            code = string_join(code, "'],True))!")
                         result = compile_code(code)
                         if element_eq(result, read_root()):
                             return read_root()!

+ 13 - 13
addis/SCCD_Example.mvc

@@ -94,14 +94,14 @@ Diagram SCCD_my_PM {
             {composite_children} BasicState running_e {
                 name = "Running"
                 isInitial = False
-                {state_onentry_raises} Raise {
+                {onEntryRaise} Raise {
                     event = "save"
                     scope = "narrow"
                     target = $
                         Element function raise(attributes : Element):
                             return attributes["parent_id"]!
                         $
-                    parameters = $
+                    parameter = $
                         Element function raise(attributes : Element):
                             Element result
                             result = list_create()
@@ -196,7 +196,7 @@ transition (running_a, done_a){
             String function raise(attributes : Element):
                 return attributes["parent_id"]!
             $
-        parameters = $
+        parameter = $
             Element function raise(attributes : Element, parameters : Element):
                 Element result
                 result = list_create()
@@ -207,7 +207,7 @@ transition (running_a, done_a){
     {transition_raises} Raise {
         scope = "cd"
         event = "delete_instance"
-        parameters = $
+        parameter = $
             Element function raise(attributes : Element, parameters : Element):
                 Element result
                 result = list_create()
@@ -243,7 +243,7 @@ transition (running_b, done_b){
             Element function raise(attributes : Element):
                 return attributes["parent_id"]!
             $
-        parameters = $
+        parameter = $
             Element function raise(attributes : Element, parameters : Element):
                 Element result
                 result = list_create()
@@ -254,7 +254,7 @@ transition (running_b, done_b){
     {transition_raises} Raise {
         scope = "cd"
         event = "delete_instance"
-        parameters = $
+        parameter = $
             Element function raise(attributes : Element, parameters : Element):
                 Element result
                 result = list_create()
@@ -290,7 +290,7 @@ transition (running_c, done_c){
             Element function raise(attributes : Element):
                 return attributes["parent_id"]!
             $
-        parameters = $
+        parameter = $
             Element function raise(attributes : Element, parameters : Element):
                 Element result
                 result = list_create()
@@ -301,7 +301,7 @@ transition (running_c, done_c){
     {transition_raises} Raise {
         scope = "cd"
         event = "delete_instance"
-        parameters = $
+        parameter = $
             Element function raise(attributes : Element, parameters : Element):
                 Element result
                 result = list_create()
@@ -337,7 +337,7 @@ transition (running_e, done_e){
             Element function raise(attributes : Element):
                 return attributes["parent_id"]!
             $
-        parameters = $
+        parameter = $
             Element function raise(attributes : Element, parameters : Element):
                 Element result
                 result = list_create()
@@ -348,7 +348,7 @@ transition (running_e, done_e){
     {transition_raises} Raise {
         scope = "cd"
         event = "delete_instance"
-        parameters = $
+        parameter = $
             Element function raise(attributes : Element, parameters : Element):
                 Element result
                 result = list_create()
@@ -384,7 +384,7 @@ transition (running_f, done_f){
             Element function raise(attributes : Element):
                 return attributes["parent_id"]!
             $
-        parameters = $
+        parameter = $
             Element function raise(attributes : Element, parameters : Element):
                 Element result
                 result = list_create()
@@ -395,7 +395,7 @@ transition (running_f, done_f){
     {transition_raises} Raise {
         scope = "cd"
         event = "delete_instance"
-        parameters = $
+        parameter = $
             Element function raise(attributes : Element, parameters : Element):
                 Element result
                 result = list_create()
@@ -403,4 +403,4 @@ transition (running_f, done_f){
                 return result!
         $
     }
-}
+}

+ 6 - 6
addis/SCCD_MetaModel.mvc

@@ -51,7 +51,7 @@ SimpleAttribute EventScope {
         self = model["model"][id]
         if (bool_not(is_physical_string(self))):
             return "EventScope has no string value at " + id!
-        elif (bool_or(bool_or(bool_or(self != "broad", self != "cd"), bool_or(self != "narrow", self != "output")), self != 'local')):
+        elif (bool_and(bool_and(bool_and(self != "broad", self != "cd"), bool_and(self != "narrow", self != "output")), self != "local")):
             return "EventScope can be either 'local', 'broad', 'cd', 'narrow' or 'output' and it does not have a proper value at " + id!
         else:
             return "OK"!
@@ -170,15 +170,15 @@ Class Raise{
     scope ?: EventScope
     port ?: String
     target ?: String
-    parameters ?: Action
+    parameter ?: Action
 }
 Association raise_parameters(Raise, ActualParameter){
     order : Natural
 }
-Association state_onentry_raises(BasicState, Raise){
+Association onEntryRaise(BasicState, Raise){
     order : Natural
 }
-Association state_onexit_raises(BasicState, Raise){
+Association onExitRaise(BasicState, Raise){
     order ?: Natural
 }
 
@@ -207,7 +207,7 @@ Association transition(State, State){
     name ?: String
     cond ?: Action
     script ?: Action
-    after ?: PositiveFloat
+    after ?: Action
     event ?: String
     port ?: String
     source_upper_cardinality = 1
@@ -268,4 +268,4 @@ GlobalConstraint {
 
                 return "OK"!
         $
-    }
+    }

+ 1 - 1
addis/Test_PM2SCCD.py

@@ -41,5 +41,5 @@ print("Upload SCCD execution semantics")
 # Add SCCD execution semantics
 transformation_add_AL({"SCCD": "SCCD"}, {}, "SCCD_execute", open("models/SCCD_execute.alc", 'r').read())
 print("DONE")
-#transformation_execute_AL("SCCD_execute", {"SCCD": "PM_2_SCCD_output"}, {})
+transformation_execute_AL("SCCD_execute", {"SCCD": "PM_2_SCCD_output"}, {})
 print("Executed")

+ 8 - 2
models/SCCD_execute.alc

@@ -202,6 +202,8 @@ String function start_class(model : Element, data : Element, class : String, par
 	dict_overwrite(data, "current_class", prev_class)
 	dict_overwrite(data, "current_class_handle", data["classes"][prev_class])
 
+	log("Created class with identifier: " + cast_v2s(identifier))
+
 	return identifier!
 
 Element function get_enabled_transitions(model : Element, state : String, data : Element):
@@ -331,8 +333,11 @@ Void function process_raised_event(model : Element, event : Element, parameter_a
 
 	elif (scope == "narrow"):
 		// Send to the specified class only
-		// TODO some error checking would be nice...
-		set_add_node(data["classes"][read_attribute(model, event, "target")]["new_events"], create_tuple(read_attribute(model, event, "event"), parameter_action))
+		Element func
+		func = resolve_function(read_attribute(model, event, "target"), data)
+		String dest
+		dest = func(data["current_class_handle"]["attributes"])
+		set_add_node(data["classes"][dest]["new_events"], create_tuple(read_attribute(model, event, "event"), parameter_action))
 
 	elif (scope == "output"):
 		// Store it in the output event model
@@ -345,6 +350,7 @@ Void function process_raised_event(model : Element, event : Element, parameter_a
 
 	else:
 		// Same as local
+		log("Unknown scope, assuming local: " + scope)
 		set_add_node(data["current_class_handle"]["new_events"], create_tuple(read_attribute(model, event, "event"), parameter_action))
 
 	return !