|
@@ -1,73 +1,15 @@
|
|
|
from modelverse import *
|
|
|
import random
|
|
|
|
|
|
-def print_mv_with_input(value):
|
|
|
- if value.startswith("#"):
|
|
|
- print_mv(value[1:])
|
|
|
- return
|
|
|
- if value.startswith("%"):
|
|
|
- if (value[1:] == "construct_function"):
|
|
|
- print("Enter your code...")
|
|
|
- code = \
|
|
|
- """
|
|
|
- include "primitives.alh"
|
|
|
-
|
|
|
- Boolean function bp_1():
|
|
|
- log("Breakpoint check!")
|
|
|
- return True!
|
|
|
- """
|
|
|
- upload_code(code)
|
|
|
- return
|
|
|
- print(value)
|
|
|
- return raw_input()
|
|
|
-
|
|
|
-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("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("models/petrinets.mvc").read())
|
|
|
-except ModelExists:
|
|
|
- pass
|
|
|
-
|
|
|
-try:
|
|
|
- model_add("formalisms/ReachabilityGraph", "formalisms/SimpleClassDiagrams", open("models/reachability_graph.mvc").read())
|
|
|
-except ModelExists:
|
|
|
- pass
|
|
|
-
|
|
|
-print("Add model")
|
|
|
-try:
|
|
|
- model_add("models/my_pn", "formalisms/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": "formalisms/PetriNet"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/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({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/printReachability", open("models/reachabilitygraph_print.mvc").read())
|
|
|
-except ModelExists:
|
|
|
- pass
|
|
|
-
|
|
|
-# Do the reachability graph generation
|
|
|
-print("Execute AL")
|
|
|
-status = transformation_execute_AL("models/analyseReachability", {"PetriNet": "models/my_pn"}, {"ReachabilityGraph": "models/my_reachability"}, callback=print_mv)
|
|
|
-print("Reachability generation success: " + str(status))
|
|
|
-
|
|
|
-print("Execute MT")
|
|
|
-status = transformation_execute_MT("models/printReachability", {"ReachabilityGraph": "models/my_reachability"}, {}, callback=print_mv)
|
|
|
-print("Reachability printing success: " + str(status))
|
|
|
+model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("models/petrinets.mvc").read())
|
|
|
+model_add("formalisms/ReachabilityGraph", "formalisms/SimpleClassDiagrams", open("models/reachability_graph.mvc").read())
|
|
|
+model_add("models/my_pn", "formalisms/PetriNet", open("models/my_pn.mvc").read())
|
|
|
+transformation_add_AL({"PetriNet": "formalisms/PetriNet"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/analyseReachability", open("models/reachability.alc", "r").read())
|
|
|
+transformation_add_MT({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/printReachability", open("models/reachabilitygraph_print.mvc").read())
|
|
|
+transformation_execute_AL("models/analyseReachability", {"PetriNet": "models/my_pn"}, {"ReachabilityGraph": "models/my_reachability"}, tracability_model="trac")
|
|
|
+transformation_execute_MT("models/printReachability", {"ReachabilityGraph": "models/my_reachability"}, {})
|
|
|
+
|
|
|
+time.sleep(5)
|
|
|
+print(model_list(""))
|