|
|
@@ -367,7 +367,7 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
|
|
|
|
|
|
return SearchState["matches"]
|
|
|
|
|
|
-Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Element, tf_er_model: Element):
|
|
|
+Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Element, tf_er_model: Element, pivots : Element):
|
|
|
//TODO support for multiple ruleTypes
|
|
|
|
|
|
//find LHS
|
|
|
@@ -420,6 +420,31 @@ Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Elemen
|
|
|
if (allow_match):
|
|
|
list_append(final_matches, lhs_match)
|
|
|
log(string_join("number of allowed matches: ", cast_i2s(list_len(final_matches))))
|
|
|
+
|
|
|
+ //extract pivots from the matches
|
|
|
+ Integer match_index
|
|
|
+ match_index = 0
|
|
|
+ Element pattern_match_node
|
|
|
+ Element host_match_node
|
|
|
+ String pivotOutName
|
|
|
+ Element pivotSet
|
|
|
+ pivotSet = create_node()
|
|
|
+ while (match_index < read_nr_out(final_matches)):
|
|
|
+ lhs_match = list_read(final_matches, match_index)//reuse lhs_match variable
|
|
|
+ match_index = match_index +1
|
|
|
+ lhs_match_keys = dict_keys(lhs_match) // reuse lhs_match_keys variable
|
|
|
+ while (read_nr_out(lhs_match_keys) > 0):
|
|
|
+ lhs_match_key = set_pop(lhs_match_keys)
|
|
|
+ pattern_match_node = lhs_match[lhs_match_key]["pn"]
|
|
|
+ host_match_node = lhs_match[lhs_match_key]["hn"]
|
|
|
+ pivotOutName = read_attribute(tf_er_transformation, getName(tf_er_transformation, pattern_match_node), "pivotOut")
|
|
|
+ if(pivotOutName != ""):
|
|
|
+ if ( bool_not(set_in(pivotSet, pivotOutName))):
|
|
|
+ set_add(pivotSet, pivotOutName)
|
|
|
+ if (dict_in(pivots, pivotOutName)):
|
|
|
+ dict_delete(pivots, pivotOutName)
|
|
|
+ dict_add(pivots, pivotOutName, create_node())
|
|
|
+ set_add(pivots[pivotOutName], host_match_node)
|
|
|
|
|
|
//TODO RHS
|
|
|
|
|
|
@@ -432,17 +457,20 @@ Element function tf_transform(tf_tf_transformation: Element, tf_tf_model: Elemen
|
|
|
//TODO give order to rules
|
|
|
//execute rules in random order
|
|
|
Element tf_tf_rule
|
|
|
+ Element pivots
|
|
|
+ pivots = create_node()
|
|
|
while (integer_lt(0, read_nr_out(tf_tf_rules))):
|
|
|
tf_tf_rule = set_pop(tf_tf_rules)
|
|
|
//tf_printNode(tf_tf_transformation, tf_tf_rule)
|
|
|
- tf_executeRule(tf_tf_transformation, tf_tf_rule, tf_tf_model)
|
|
|
+ tf_executeRule(tf_tf_transformation, tf_tf_rule, tf_tf_model, pivots)
|
|
|
return 0
|
|
|
|
|
|
Element function test_simple_petrinet1(root:Element):
|
|
|
//create a petrinet for testing purposes
|
|
|
|
|
|
// P1 -> T1 -> P2 -> T2
|
|
|
- // 1 1 2 0 1
|
|
|
+ // m:1 w:1 w:2 m:0 w:1
|
|
|
+ // l1 l2 l3
|
|
|
|
|
|
//////////////////////////////////
|
|
|
//initialise an empty petrinet
|
|
|
@@ -509,6 +537,7 @@ Element function petrinet_transformation(root: Element):
|
|
|
instantiate_node(my_model, "Transition_LHS","lhs_find_all")
|
|
|
instantiate_attribute(my_model, "lhs_find_all", "plabel", 1)
|
|
|
instantiate_attribute(my_model, "lhs_find_all", "function", "always_true")
|
|
|
+ instantiate_attribute(my_model, "lhs_find_all", "pivotOut", "enabled")
|
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "lhs_precondition", "lhs_find_all")
|
|
|
|
|
|
@@ -521,6 +550,7 @@ Element function petrinet_transformation(root: Element):
|
|
|
instantiate_node(my_model, "Transition_LHS","nac_transition_before")
|
|
|
instantiate_attribute(my_model, "nac_transition_before", "plabel", 1)
|
|
|
instantiate_attribute(my_model, "nac_transition_before", "function", "always_true")
|
|
|
+ instantiate_attribute(my_model, "nac_transition_before", "pivotOut", "")
|
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_transition_before")
|
|
|
|
|
|
@@ -528,6 +558,7 @@ Element function petrinet_transformation(root: Element):
|
|
|
instantiate_node(my_model, "Place_LHS","nac_place_before")
|
|
|
instantiate_attribute(my_model, "nac_place_before", "plabel", 2)
|
|
|
instantiate_attribute(my_model, "nac_place_before", "function", "always_true")
|
|
|
+ instantiate_attribute(my_model, "nac_place_before", "pivotOut", "")
|
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_place_before")
|
|
|
|
|
|
@@ -535,6 +566,7 @@ Element function petrinet_transformation(root: Element):
|
|
|
instantiate_link(my_model, "P2T_LHS", "nac_p2tlhs_before", "nac_place_before", "nac_transition_before")
|
|
|
instantiate_attribute(my_model, "nac_p2tlhs_before", "plabel", 3)
|
|
|
instantiate_attribute(my_model, "nac_p2tlhs_before", "function", "is_not_consumable")
|
|
|
+ instantiate_attribute(my_model, "nac_p2tlhs_before", "pivotOut", "")
|
|
|
//connect to rule
|
|
|
instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_p2tlhs_before")
|
|
|
|