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("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": "PetriNet"}, {"ReachabilityGraph": "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({"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))