Browse Source

Merge branch 'master' into stable

Yentl Van Tendeloo 8 years ago
parent
commit
6fc727a845

+ 159 - 78
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()!
@@ -216,11 +242,13 @@ Composite schedule {
                         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()):
@@ -310,12 +344,12 @@ Composite schedule {
                         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"))
@@ -792,13 +849,13 @@ Composite schedule {
                         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!
         $
     }
-}
+}

+ 5 - 5
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"!
@@ -175,10 +175,10 @@ Class Raise{
 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")

+ 1 - 0
bootstrap/bootstrap.py

@@ -75,6 +75,7 @@ def bootstrap():
                     "create_edge": ["Element", "Element", "Element"],
                     "create_value": ["Element", "Element"],
                     "is_edge": ["Boolean", "Element"],
+                    "is_error": ["Boolean", "Element"],
                     "read_nr_out": ["Integer", "Element"],
                     "read_out": ["Element", "Element", "Integer"],
                     "read_nr_in": ["Integer", "Element"],

+ 1 - 9
bootstrap/compiler.alc

@@ -9,14 +9,9 @@ Element function generic_compile(code : String, port : String):
 	String response
 	response = comm_get(port)
 	if (response == "OK"):
-		Integer count
 		Element lst
 
-		lst = list_create()
-		count = comm_get(port)
-		while (count > 0):
-			list_append(lst, comm_get(port))
-			count = count - 1
+		lst = comm_get_list(port)
 
 		comm_close(port)
 		return lst!
@@ -26,9 +21,6 @@ Element function generic_compile(code : String, port : String):
 		return read_root()!
 
 Element function compile_code(code : String):
-	// TODO to test performance impact
-	return code!
-
 	String port
 	port = comm_connect("compiler")
 	comm_set(port, "code")

+ 1 - 0
bootstrap/core_algorithm.alc

@@ -281,6 +281,7 @@ String function get_entry_id(name : String):
 	return ""!
 
 String function get_service_id(name : String):
+	core = import_node(core_model_location)
 	Element services
 	String service
 

+ 1 - 0
bootstrap/primitives.alc

@@ -67,3 +67,4 @@ Boolean function is_physical_action(a: Element) = ?primitives/is_physical_action
 Float function time() = ?primitives/time
 String function hash(a : String) = ?primitives/hash
 Float function __sleep(a : Float, b : Boolean) = ?primitives/__sleep
+Boolean function is_error() = ?primitives/is_error

+ 16 - 0
bootstrap/services.alc

@@ -68,6 +68,10 @@ Element function comm_get(comm : String):
 String function comm_connect(service : String):
 	// Connect to an existing service
 	service = get_service_id(service)
+
+	if (service == ""):
+		return ""!
+
 	service = read_attribute(core, service, "port")
 
 	String port
@@ -79,3 +83,15 @@ Void function comm_close(comm : String):
 	if (string_startswith(comm, "__")):
 		dict_delete(read_root(), comm)
 	return!
+
+Element function comm_get_list(comm : String):
+	Integer length
+	Element result
+
+	length = comm_get(comm)
+	result = list_create()
+	while (length > 0):
+		list_append(result, comm_get(comm))
+		length = length - 1
+
+	return result!

+ 3 - 0
bootstrap/transform.alc

@@ -437,6 +437,9 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 				elif (has_value(result)):
 					// New value defined, so assign!
 					instantiate_attribute(host_model, new_mapping[label], string_substr(attribute, string_len("value_"), string_len(attribute) + 1), result)
+				elif (is_error(result)):
+					log("Error in evaluation of attribute " + attribute)
+					log("On element with label " + label)
 				else:
 					// Try to interpret as code
 					instantiate_attribute_code(host_model, new_mapping[label], string_substr(attribute, string_len("value_"), string_len(attribute) + 1), result)

+ 1 - 0
interface/HUTN/includes/primitives.alh

@@ -123,3 +123,4 @@ Element function dict_create()
 String function reverseKeyLookup(a: Element, b: Element)
 Element function reverseKeyLookupMulti(a: Element, b: Element)
 Element function dict_values(dict : Element)
+Boolean function is_error(a : Element)

+ 1 - 0
interface/HUTN/includes/services.alh

@@ -4,3 +4,4 @@ Void function comm_set(comm : String, value : Element)
 Element function comm_get(comm : String)
 String function comm_connect(service : String)
 Void function comm_close(comm : String)
+Element function comm_get_list(comm : String)

+ 13 - 6
kernel/modelverse_kernel/primitives.py

@@ -1,4 +1,5 @@
 import time as python_time
+import json
 
 class PrimitiveFinished(Exception):
     """Exception to indicate the result value of a primitive, as a return cannot be used."""
@@ -209,13 +210,12 @@ def cast_e2s(a, **remainder):
 
 def cast_v2s(a, **remainder):
     a_value, = yield [("RV", [a])]
-    if isinstance(a_value, (str, unicode)):
-        # String should be encoded to distinguish between 3 and "3"
-        a_value = '"%s"' % a_value
-    elif isinstance(a_value, dict):
+    if isinstance(a_value, dict):
         # Action or type
-        a_value = a_value["value"]
-    result, = yield [("CNV", ["%s" % (a_value)])]
+        value = a_value["value"]
+    else:
+        value = json.dumps(a_value)
+    result, = yield [("CNV", [value])]
     raise PrimitiveFinished(result)
 
 def cast_id2s(a, **remainder):
@@ -409,3 +409,10 @@ def __sleep(a, b, **remainder):
     timeout, interruptable = yield [("RV", [a]), ("RV", [b])]
     yield [("SLEEP", [timeout, interruptable])]
     raise PrimitiveFinished(a)
+
+def is_error(a, **remainder):
+    if a is None:
+        result, = yield [("CNV", [True])]
+    else:
+        result, = yield [("CNV", [False])]
+    raise PrimitiveFinished(result)

+ 1 - 1
kernel/test/primitives/test_cast.py

@@ -107,7 +107,7 @@ class TestCast(unittest.TestCase):
         self.helper_primitives_1_params("cast_v2s", "3", "\"3\"")
 
     def test_cast_v2s_bool(self):
-        self.helper_primitives_1_params("cast_v2s", True, "True")
+        self.helper_primitives_1_params("cast_v2s", True, "true")
 
     def test_cast_v2s_action(self):
         self.helper_primitives_1_params("cast_v2s", {"value": "call"}, "call")

+ 9 - 2
models/SCCD_execute.alc

@@ -196,6 +196,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):
@@ -321,10 +323,15 @@ Void function process_raised_event(model : Element, event : Element, parameter_a
 			set_add_node(data["classes"][set_pop(classes)]["new_events"], create_tuple(read_attribute(model, event, "event"), parameter_action))
 	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"])
+		log("Narrowcasting to " + cast_v2s(dest))
+		set_add_node(data["classes"][dest]["new_events"], create_tuple(read_attribute(model, event, "event"), parameter_action))
 	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 !

+ 6 - 2
scripts/HUTN_service.py

@@ -11,6 +11,7 @@ init()
 login("HUTN", "HUTN")
 
 def compile_service(port):
+    start = time.time()
     temp_file = ".tmp_%s" % port
     def compile_AL(code):
         code_fragments = code.split("\n")
@@ -25,7 +26,9 @@ def compile_service(port):
             f.write(code)
             f.flush()
 
+        ss = time.time()
         compiled = do_compile(temp_file, COMPILER_PATH + "/grammars/actionlanguage.g", "CS")
+        print("    Compile: %ss" % (time.time() - ss))
         os.remove(temp_file)
         return compiled
 
@@ -53,16 +56,17 @@ def compile_service(port):
         if mode == "code":
             compiled = compile_AL(code)
             service_set(port, "OK")
-            [service_set(port, i) for i in compiled]
+            service_set(port, compiled)
         elif mode == "model":
             compiled = compile_model(code)
             service_set(port, "OK")
-            [service_set(port, i) for i in compiled]
+            service_set(port, compiled)
         else:
             raise Exception("No such mode: " + mode)
     except Exception as e:
         service_set(port, str(e))
         raise
+    print("Compile took %ss" % (time.time() - start))
 
 service_register("compiler", compile_service)
 try:

+ 7 - 1
wrappers/modelverse.py

@@ -78,6 +78,12 @@ def _check_type(value):
     if not isinstance(value, (int, long, float, str, unicode, bool)):
         raise UnsupportedValue("%s : %s" % (value, str(type(value))))
 
+def _check_type_list(value):
+    if isinstance(value, list):
+        [_check_type(i) for i in value]
+    else:
+        _check_type(value)
+
 def _dict_to_list(python_dict):
     lst = []
     for k, v in python_dict.items():
@@ -913,7 +919,7 @@ def service_get(port):
 
 def service_set(port, value):
     """Set a value on a specified port."""
-    _check_type(value)
+    _check_type_list(value)
     _goto_mode(MODE_SERVICE)
 
     _input(value, port=port)