Browse Source

Added test file for Simon

Yentl Van Tendeloo 6 years ago
parent
commit
e120d53144
2 changed files with 58 additions and 2 deletions
  1. 0 2
      state/modelverse_state/main.py
  2. 58 0
      wrappers/test.py

+ 0 - 2
state/modelverse_state/main.py

@@ -445,5 +445,3 @@ class ModelverseState(object):
                 v = values.pop()
                 if v in self.nodes:
                     self.delete_node(v)
-
-        #print("Remaining nodes: " + str(len(self.nodes)))

+ 58 - 0
wrappers/test.py

@@ -0,0 +1,58 @@
+from modelverse import *
+import random
+
+def print_mv(value):
+    print(value)
+    return None
+
+print("Init")
+init()
+print("Login")
+#login(str(random.random()), str(random.random()))
+login("admin", "admin")
+
+# Add the metamodels for PetriNet and ReachabilityGraph
+print("Add metamodels")
+try:
+    model_add("PetriNet", "SimpleClassDiagrams", open("models/petrinets.mvc").read())
+except ModelExists:
+    pass
+
+try:
+    model_add("ReachabilityGraph", "SimpleClassDiagrams", open("models/reachability_graph.mvc").read())
+except ModelExists:
+    pass
+
+print("Add model")
+try:
+    model_add("my_pn", "PetriNet", open("models/my_pn.mvc").read())
+except ModelExists:
+    pass
+
+# Add the action language code to transform between them
+print("Add AL model")
+try:
+    transformation_add_AL(["PetriNet"], ["ReachabilityGraph"], "analyseReachability", open("models/reachability.alc", "r").read())
+except ModelExists:
+    pass
+
+# Add an example model transformation to print the reachability graph
+print("Add MT model")
+try:
+    transformation_add_MT_language(["ReachabilityGraph"], "RAMified_ReachabilityGraph")
+except ModelExists:
+    pass
+
+try:
+    transformation_add_MT("RAMified_ReachabilityGraph", ["ReachabilityGraph"], [], "printReachability", open("models/reachabilitygraph_print.mvc").read())
+except ModelExists:
+    pass
+
+# Do the reachability graph generation
+print("Execute AL")
+status = transformation_execute_AL("analyseReachability", {"PetriNet": "my_pn"}, {"ReachabilityGraph": "my_reachability"}, callback=print_mv)
+print("Reachability generation success: " + str(status))
+
+print("Execute MT")
+status = transformation_execute_MT("printReachability", {"ReachabilityGraph": "my_reachability"}, {}, callback=print_mv)
+print("Reachability printing success: " + str(status))