|
@@ -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))
|