|
|
@@ -55,7 +55,15 @@ Element function printNode(tf_pn_model: Element, tf_pn_node: Element):
|
|
|
return 0
|
|
|
|
|
|
|
|
|
-Element function tf_recursive_matchAll():
|
|
|
+Element function transf_vf2(SearchState: Element):
|
|
|
+ // get the current match from the search-state
|
|
|
+ Element current_match
|
|
|
+ current_match = SearchState["curmatch"]
|
|
|
+ //if match is complete: add to matches and return
|
|
|
+ //try and grow match from Nout
|
|
|
+ //try and grow match from Nin
|
|
|
+ //try and grow match from V
|
|
|
+ return 0
|
|
|
|
|
|
|
|
|
// given a pattern, this function will return all matches in a model
|
|
|
@@ -63,6 +71,7 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
|
|
|
|
|
|
//find all nodes in the pattern
|
|
|
|
|
|
+ log("=== finding all nodes in pattern")
|
|
|
Element tf_ma_metamodelTransf //transformation metamodel
|
|
|
tf_ma_metamodelTransf = tf_ma_transformation["metamodel"]["model"]
|
|
|
Element pre2ram_et // type of the pre2ram edge
|
|
|
@@ -71,13 +80,21 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
|
|
|
tf_ma_pattern_edges = allOutgoingAssociationInstances(tf_ma_transformation, tf_ma_pattern, pre2ram_et)
|
|
|
Element tf_ma_ramified_nodes //dict in the form plabel->node
|
|
|
Element tf_ma_ramified_node
|
|
|
- while (integer_lt(0, read_nr_out(tf_ma_pattern_nodes))):
|
|
|
- tf_ma_ramified_node = read_edge_dst(set_pop(tf_ma_pattern_nodes))
|
|
|
+ while (integer_lt(0, list_len(tf_ma_pattern_edges))):
|
|
|
+ tf_ma_ramified_node = read_edge_dst(set_pop(tf_ma_pattern_edges))
|
|
|
set_add(tf_ma_ramified_nodes, tf_ma_ramified_node)
|
|
|
|
|
|
//find all nodes in the graph
|
|
|
- //TODO is this necessary (is it not easier to use allinstance to create the initial Vh_Vg pair)?
|
|
|
+ //TODO: solve attributes
|
|
|
+ // 1) allow them as a separate node
|
|
|
+ // --> add them in the pattern too
|
|
|
+ // --> increases complexity
|
|
|
+ // 2) don't allow them as a separate node
|
|
|
+ // --> make sure only classes and edges are included below
|
|
|
+ // --> hard: how to check if an element is an attribute or a link to an attribute?
|
|
|
+ // --> breaks generality
|
|
|
|
|
|
+ log("=== finding nodes in host")
|
|
|
Element hostmodel_mm //metamodel of hostgraph
|
|
|
hostmodel_mm = tf_ma_model["metamodel"]["model"]
|
|
|
Element hostmodel_keys //keys of all elements in the model
|
|
|
@@ -90,6 +107,7 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
|
|
|
|
|
|
// initialise the start-state
|
|
|
|
|
|
+ log("=== creating searchstate")
|
|
|
//initialise an start state
|
|
|
Element SearchState
|
|
|
SearchState = create_node()
|
|
|
@@ -103,8 +121,10 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
|
|
|
dict_add(SearchState, "V_host", host_nodes)
|
|
|
|
|
|
//call vf2 for the matching
|
|
|
+ log("calling vf2")
|
|
|
+ SearchState = transf_vf2(SearchState)
|
|
|
|
|
|
- return transf_vf2(SearchState)["matches"]
|
|
|
+ return dict_read(SearchState,"matches")
|
|
|
|
|
|
Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Element, tf_er_model: Element):
|
|
|
Element tf_er_lhs
|
|
|
@@ -126,6 +146,37 @@ Element function tf_transform(tf_tf_transformation: Element, tf_tf_model: Elemen
|
|
|
tf_executeRule(tf_tf_transformation, tf_tf_rule, tf_tf_model)
|
|
|
return 0
|
|
|
|
|
|
+Element function test_simple_petrinet1(root:Element):
|
|
|
+ //create a petrinet for testing purposes
|
|
|
+
|
|
|
+ // P1 -> T1 -> P2
|
|
|
+ // 1 1 2 0
|
|
|
+
|
|
|
+ //////////////////////////////////
|
|
|
+ //initialise an empty petrinet
|
|
|
+ Element my_model
|
|
|
+ my_model = instantiate_model(root["PetriNets"])
|
|
|
+ dict_add(root, "pnt_test1", my_model)
|
|
|
+
|
|
|
+ // init t1
|
|
|
+ instantiate_node(my_model, "Transition", "t1")
|
|
|
+ // init p1
|
|
|
+ instantiate_node(my_model, "Place", "p1")
|
|
|
+ instantiate_attribute(my_model, "p1","tokens",1)
|
|
|
+ // init link1
|
|
|
+ instantiate_link(my_model, "P2T", "l1", "p1", "t1")
|
|
|
+ instantiate_attribute(my_model, "l1", "weight", 1)
|
|
|
+ //init p2
|
|
|
+ instantiate_node(my_model, "Place", "p2")
|
|
|
+ instantiate_attribute(my_model, "p2","tokens",0)
|
|
|
+ //init link2
|
|
|
+ instantiate_link(my_model, "T2P", "l2", "p1", "t1")
|
|
|
+ instantiate_attribute(my_model, "l2", "weight", 2)
|
|
|
+
|
|
|
+ return my_model
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
Element function petrinet_transformation(root: Element):
|
|
|
// Create A transformation model for petrinets (useful for testing)
|
|
|
|
|
|
@@ -624,10 +675,13 @@ Void function main():
|
|
|
log("=== load instantiation of transformation metamodel")
|
|
|
Element transf
|
|
|
transf = petrinet_transformation(root)
|
|
|
+ log("=== load test1")
|
|
|
+ Element test1
|
|
|
+ test1 = test_simple_petrinet1(root)
|
|
|
log("=== check conformance of transformation")
|
|
|
log(conformance_scd(transf))
|
|
|
log("=== run transform")
|
|
|
- tf_transform(transf, create_node())
|
|
|
+ tf_transform(transf, test1)
|
|
|
log("=== done")
|
|
|
log("==========================================================================")
|
|
|
return
|