Browse Source

Various bugfixes to transformations and internals

Yentl Van Tendeloo 8 years ago
parent
commit
8ded411292

+ 13 - 4
bootstrap/transform.alc

@@ -113,19 +113,28 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 
 		ic = allIncomingAssociationInstances(schedule_model, current_element, "PreElement")
 		oc = allOutgoingAssociationInstances(schedule_model, current_element, "PreElement")
+		log("Finding throughout ")
+		log(set_to_string(ic))
+		log(set_to_string(oc))
 
-		while (bool_and(read_nr_out(ic) > 0, read_nr_out(options) == 0)):
+		String value
+		while (bool_and(read_nr_out(ic) > 0, read_nr_out(options) < 2)):
 			poll = set_pop(ic)
 			if (dict_in(map, read_attribute(schedule_model, poll, "label"))):
 				// This incoming link is already defined, so we just have one option: the destination of the link we matched
-				set_add(options, readAssociationDestination(host_model, map[read_attribute(schedule_model, poll, "label")]))
+				value = readAssociationDestination(host_model, map[read_attribute(schedule_model, poll, "label")])
+				if (bool_not(set_in(options, value))):
+					set_add(options, value)
 			
-		while (bool_and(read_nr_out(oc) > 0, read_nr_out(options) == 0)):
+		while (bool_and(read_nr_out(oc) > 0, read_nr_out(options) < 2)):
 			poll = set_pop(oc)
 			if (dict_in(map, read_attribute(schedule_model, poll, "label"))):
 				// This incoming link is already defined, so we just have one option: the destination of the link we matched
-				set_add(options, readAssociationSource(host_model, map[read_attribute(schedule_model, poll, "label")]))
+				value = readAssociationSource(host_model, map[read_attribute(schedule_model, poll, "label")]))
+				if (bool_not(set_in(options, value))):
+					set_add(options, value)
 
+		log("Result: " + set_to_string(options))
 		if (read_nr_out(options) == 0):
 			// Is a node and no connections, so we just pick all options
 			options = allInstances(host_model, original_typename)

+ 15 - 3
kernel/modelverse_kernel/primitives.py

@@ -431,8 +431,20 @@ def read_root(root, **remainder):
     raise PrimitiveFinished(root)
 
 def set_add(a, b, **remainder):
-    yield [("CE", [a, b])]
-    raise PrimitiveFinished(a)
+    #yield [("CE", [a, b])]
+    #raise PrimitiveFinished(a)
+    outgoing, b_value = yield [("RO", [a]), ("RV", [b])]
+    if outgoing:
+        elements = yield [("RE", [i]) for i in outgoing]
+        values = yield [("RV", [i[1]]) for i in elements]
+        if b_value in values:
+            raise PrimitiveFinished(a)
+        else:
+            yield [("CE", [a, b])]
+            raise PrimitiveFinished(a)
+    else:
+        yield [("CE", [a, b])]
+        raise PrimitiveFinished(a)
 
 def set_pop(a, **remainder):
     outgoing, = yield [("RO", [a])]
@@ -458,7 +470,7 @@ def set_in(a, b, **remainder):
     if outgoing:
         elements = yield [("RE", [i]) for i in outgoing]
         values = yield [("RV", [i[1]]) for i in elements]
-        if b_value in [v for v in values]:
+        if b_value in values:
             result, = yield [("CNV", [True])]
         else:
             result, = yield [("CNV", [False])]

+ 4 - 4
models/control_to_EPN.mvc

@@ -347,7 +347,7 @@ All_RAM Control2EPN {
                 Post_PW_Control/State post_ct_1 {
                     label = "1"
                 }
-                Post_PW_Control/Transition (post_ct_0, post_ct_1) {
+                Post_PW_Control/Transition post_ct_2 (post_ct_0, post_ct_1) {
                     label = "2"
                 }
                 Post_Encapsulated_PetriNet/Place post_ct_3 {
@@ -416,7 +416,7 @@ All_RAM Control2EPN {
                     label = "22"
                 }
 
-                Post_CTRL2EPN_tlink (post_ct_2, post_ct16) {
+                Post_CTRL2EPN_tlink (post_ct_2, post_ct_16) {
                     label = "100"
                 }
             }
@@ -430,7 +430,7 @@ All_RAM Control2EPN {
                 Pre_PW_Control/State pre_co_1 {
                     label = "1"
                 }
-                Pre_PW_Control/Transition (pre_co_0, pre_co_1) {
+                Pre_PW_Control/Transition pre_co_2 (pre_co_0, pre_co_1) {
                     label = "2"
                     constraint_objDetected = $
                         Boolean function constraint(value : String):
@@ -498,7 +498,7 @@ All_RAM Control2EPN {
                 Post_PW_Control/State post_co_1 {
                     label = "1"
                 }
-                Post_PW_Control/Transition (post_co_0, post_co_1) {
+                Post_PW_Control/Transition post_co_2 (post_co_0, post_co_1) {
                     label = "2"
                 }
                 Post_Encapsulated_PetriNet/Place post_co_3 {

+ 1 - 1
models/plant_to_EPN.mvc

@@ -316,7 +316,7 @@ A B {
                     label = "10"
                     value_name = $
                         String function value(model : Element, name : String, mapping : Element):
-                            return read_type(model, mapping["2"])!
+                            return string_join(read_attribute(model, mapping["0"], "name"), read_type(model, mapping["2"]))!
                         $
                 }
                 Post_Encapsulated_PetriNet/P2T (post_ct_3, post_ct_10) {