Browse Source

Add in DEVS debugger

Yentl Van Tendeloo 3 years ago
parent
commit
d49fcd16a8

+ 30 - 0
examples/debug_DEVS.py

@@ -0,0 +1,30 @@
+import sys
+sys.path.append("wrappers")
+from modelverse import *
+
+init()
+login("admin", "admin")
+
+model_add("formalisms/ParallelDEVS", "formalisms/SimpleClassDiagrams", open("models/ParallelDEVS/metamodels/PDEVS.mvc", 'r').read())
+model_add("models/produce_consume_pdevs", "formalisms/ParallelDEVS", open("models/ParallelDEVS/models/produce_consume.mvc", 'r').read())
+
+transformation_add_AL({"ParallelDEVS": "formalisms/ParallelDEVS"}, {}, "models/paralleldevs_simulator", open("models/ParallelDEVS/transformations/simulate_interactive.alc", "r").read())
+
+import poll_print
+ctrl = poll_print.Controller(keep_running=False)
+
+thrd = threading.Thread(target=ctrl.start)
+thrd.daemon = True
+thrd.start()
+
+def input_thread():
+    import select
+    while thrd.is_alive():
+        if select.select([sys.stdin], [], [], 0.1)[0]:
+            ctrl.addInput(Event("raw_inp", "user_inp", [sys.stdin.readline().strip()]))
+
+thrd2 = threading.Thread(target=input_thread)
+thrd2.daemon = True
+thrd2.start()
+
+transformation_execute_AL("models/paralleldevs_simulator", {"ParallelDEVS": "models/produce_consume_pdevs"}, {}, statechart=(ctrl, "inp", "outp"))

+ 0 - 78
models/old/live_modelling.py

@@ -1,78 +0,0 @@
-import sys
-sys.path.append("wrappers")
-from modelverse import *
-
-init()
-login("admin", "admin")
-
-### live modelling DTCBD
-
-model_add("formalisms/DTCBD/Design_MM", "formalisms/SimpleClassDiagrams", open("models/dtcbd_design.mvc", 'r').read())
-model_add("formalisms/DTCBD/PartialRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/dtcbd_partial_runtime.mvc", 'r').read())
-model_add("formalisms/DTCBD/FullRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/dtcbd_runtime.mvc", 'r').read())
-
-model_add("models/DTCBD_model", "formalisms/DTCBD/Design_MM", open("models/dtcbd_simple.mvc", 'r').read())
-
-transformation_add_MANUAL({"Design": "formalisms/DTCBD/Design_MM"}, {"Design": "formalisms/DTCBD/Design_MM"}, "models/DTCBD/edit")
-
-def trace_D2P(model):
-    instantiate(model, "Association", ("Design/Block", "PartialRuntime/Block"), ID="D2P_block")
-
-transformation_add_AL({"Design": "formalisms/DTCBD/Design_MM", "PartialRuntime": "formalisms/DTCBD/PartialRuntime_MM"}, {"PartialRuntime": "formalisms/DTCBD/PartialRuntime_MM"}, "models/DTCBD/toRuntime", open("models/dtcbd_toRuntime.alc", 'r').read(), trace_D2P)
-
-def trace_P2F(model):
-    instantiate(model, "Association", ("PartialRuntime/Block", "FullRuntime/Block"), ID="P2F_block")
-
-transformation_add_AL({"PartialRuntime": "formalisms/DTCBD/PartialRuntime_MM", "FullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, {"NewFullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, "models/DTCBD/merge", open("models/dtcbd_merge.alc", 'r').read(), trace_P2F)
-transformation_add_AL({"FullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, {"FullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, "models/DTCBD/simulate", open("models/dtcbd_simulate.alc", 'r').read())
-transformation_add_AL({}, {}, "models/DTCBD/restartSim", open("models/cbd_restartSim.alc", 'r').read())
-
-model_add("models/live_modelling_DTCBD", "formalisms/ProcessModel", open("models/pm_live_DTCBD.mvc", 'r').read())
-
-### live modelling CTCBD
-
-model_add("formalisms/CTCBD/Design_MM", "formalisms/SimpleClassDiagrams", open("models/ctcbd_design.mvc", 'r').read())
-#model_add("formalisms/DTCBD/PartialRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/dtcbd_partial_runtime.mvc", 'r').read())
-#model_add("formalisms/DTCBD/FullRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/dtcbd_runtime.mvc", 'r').read())
-
-model_add("models/CTCBD_model", "formalisms/CTCBD/Design_MM", open("models/ctcbd_spring.mvc", 'r').read())
-
-transformation_add_MANUAL({"Design": "formalisms/CTCBD/Design_MM"}, {"Design": "formalisms/CTCBD/Design_MM"}, "models/CTCBD/edit")
-
-def trace_D2P(model):
-    instantiate(model, "Association", ("Design/Block", "PartialRuntime/Block"), ID="D2P_block")
-
-transformation_add_MT({"Design": "formalisms/CTCBD/Design_MM", "PartialRuntime": "formalisms/DTCBD/PartialRuntime_MM"}, {"PartialRuntime": "formalisms/DTCBD/PartialRuntime_MM"}, "models/CTCBD/toRuntime", open("models/ctcbd_toPartialRuntime.mvc", 'r').read(), trace_D2P)
-
-def trace_P2F(model):
-    instantiate(model, "Association", ("PartialRuntime/Block", "FullRuntime/Block"), ID="P2F_block")
-
-#transformation_add_AL({"PartialRuntime": "formalisms/DTCBD/PartialRuntime_MM", "FullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, {"NewFullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, "models/DTCBD/merge", open("models/dtcbd_merge.alc", 'r').read(), trace_P2F)
-#transformation_add_AL({"FullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, {"FullRuntime": "formalisms/DTCBD/FullRuntime_MM"}, "models/DTCBD/simulate", open("models/dtcbd_simulate.alc", 'r').read())
-#transformation_add_AL({}, {}, "models/DTCBD/restartSim", open("models/cbd_restartSim.alc", 'r').read())
-
-model_add("models/live_modelling_CTCBD", "formalisms/ProcessModel", open("models/pm_live_CTCBD.mvc", 'r').read())
-
-### live modelling FSA
-
-model_add("formalisms/FSA/Design_MM", "formalisms/SimpleClassDiagrams", open("models/fsa_design.mvc", 'r').read())
-model_add("formalisms/FSA/PartialRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/fsa_partial_runtime.mvc", 'r').read())
-model_add("formalisms/FSA/FullRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/fsa_full_runtime.mvc", 'r').read())
-
-model_add("models/FSA_model", "formalisms/FSA/Design_MM", open("models/fsa_model.mvc", 'r').read())
-
-transformation_add_MANUAL({"Design": "formalisms/FSA/Design_MM"}, {"Design": "formalisms/FSA/Design_MM"}, "models/FSA/edit")
-
-def trace_D2P(model):
-    instantiate(model, "Association", ("Design/State", "PartialRuntime/State"), ID="D2P_state")
-
-transformation_add_AL({"Design": "formalisms/FSA/Design_MM", "PartialRuntime": "formalisms/FSA/PartialRuntime_MM"}, {"PartialRuntime": "formalisms/FSA/PartialRuntime_MM"}, "models/FSA/toRuntime", open("models/fsa_toRuntime.alc", 'r').read(), trace_D2P)
-
-def trace_P2F(model):
-    instantiate(model, "Association", ("PartialRuntime/State", "FullRuntime/State"), ID="P2F_state")
-
-transformation_add_AL({"PartialRuntime": "formalisms/FSA/PartialRuntime_MM", "FullRuntime": "formalisms/FSA/FullRuntime_MM"}, {"NewFullRuntime": "formalisms/FSA/FullRuntime_MM"}, "models/FSA/merge", open("models/fsa_merge.alc", 'r').read(), trace_P2F)
-transformation_add_AL({"FullRuntime": "formalisms/FSA/FullRuntime_MM"}, {"FullRuntime": "formalisms/FSA/FullRuntime_MM"}, "models/FSA/simulate", open("models/fsa_simulate.alc", 'r').read())
-transformation_add_AL({}, {}, "models/FSA/restartSim", open("models/cbd_restartSim.alc", 'r').read())
-
-model_add("models/live_modelling_FSA", "formalisms/ProcessModel", open("models/pm_live_FSA.mvc", 'r').read())

+ 0 - 15
models/old/test.alc

@@ -1,15 +0,0 @@
-include "primitives.alh"
-
-Boolean function other(a : Boolean, b : Boolean, c : Integer, d : String, e : Integer):
-	a = 6
-	return False!
-
-Boolean function main(model : Element, c : Element):
-	log("Test")
-	Integer a
-	a = 1
-	a = 2
-	a = 3
-	log("Model: " + cast_id(model))
-	log("Model2: " + cast_id(c))
-	return True!

+ 0 - 25
models/old/test_compiler.alc

@@ -1,25 +0,0 @@
-include "compiler.alh"
-include "primitives.alh"
-
-Void function main(model : Element):
-	String code
-	code = ""
-	code = code + "include \"primitives.alh\"\n"
-	code = code + "Void function test_function():\n"
-	code = code + "    log(\"Function!\")\n"
-	code = code + "    abcd\n"
-	code = code + "    return!"
-
-	log("Got code: ")
-	log(code)
-	
-	Element result
-	result = compile_code(code)
-
-	log("Executing result: " + cast_value(result))
-	if (element_eq(result, read_root())):
-		log("ERROR: compilation error")
-	else:
-		result()
-
-	return!

+ 0 - 101
models/old/test_operations_in_SCCD.mvc

@@ -1,101 +0,0 @@
-include "primitives.alh"
-include "core_algorithm.alh"
-include "transform.alh"
-include "modelling.alh"
-
-Diagram dynamic_trafficlight {
-    name = "Dynamic Traffic Light"
-    author = "Yentl Van Tendeloo"
-}
-
-Class manager {
-    name = "Manager"
-    default = True
-    constructor_body = $
-            Void function constructor(attributes : Element, parameters : Element):
-                return !
-        $
-
-    {behaviour} CompositeState manager_main {
-        name = "main"
-        isInitial = True
-        {composite_children} BasicState manager_main_init {
-            name = "init"
-            isInitial = True
-        }
-        {composite_children} BasicState manager_main_did_transform {
-            name = "MT OK"
-            isInitial = False
-        }
-        {composite_children} BasicState manager_main_did_actionlanguage {
-            name = "AL OK"
-            isInitial = False
-        }
-    }
-}
-
-transition (manager_main_init, manager_main_did_transform) {
-    name = "model transformation"
-
-    script = $
-            Void function script(attributes : Element, parameters : Element):
-                Element m
-                Element models
-
-                // Merge models
-                models = dict_create()
-                dict_add(models, "A", "ModelA")
-                dict_add(models, "B", "ModelB")
-                m = merge_models(models, "TransformY")
-
-                // Do transformation
-                transform(m, get_model("TransformY", get_ramified_metamodel("TransformY")))
-
-                // Split up the result
-                Element metamodels
-                Element split
-                metamodels = dict_create()
-                dict_add(metamodels, "C", "MetamodelC")
-                dict_add(metamodels, "B", "MetamodelB")
-                split = split_model(m, metamodels)
-
-                // Store the results
-                store_model("ModelC", "MetamodelC", split["C"])
-                store_model("ModelB", "MetamodelB", split["B"])
-                return!
-        $
-}
-
-transition (manager_main_did_transform, manager_main_did_actionlanguage) {
-    name = "action language"
-
-    script = $
-            Void function script(attributes : Element, parameters : Element):
-                Element m
-                Element models
-
-                // Merge models
-                models = dict_create()
-                dict_add(models, "C", "ModelC")
-                dict_add(models, "B", "ModelB")
-                m = merge_models(models, "OperationZ")
-
-                // Do transformation
-                Element func
-                func = get_func_AL_model(get_model("OperationZ", "ActionLanguage"))
-                func(m)
-
-                // Split up the result
-                Element metamodels
-                Element split
-                metamodels = dict_create()
-                dict_add(metamodels, "A", "MetamodelA")
-                dict_add(metamodels, "B", "MetamodelB")
-                split = split_model(m, metamodels)
-
-                // Store the results
-                store_model("ModelA", "MetamodelA", split["A"])
-                store_model("ModelB", "MetamodelB", split["B"])
-                return!
-        $
-}

+ 0 - 134
models/old/upload_models.py

@@ -1,134 +0,0 @@
-import sys
-sys.path.append("wrappers")
-from modelverse import *
-
-init()
-login("admin", "admin")
-
-"""
-model_add("formalisms/Trace", "formalisms/SimpleClassDiagrams", open("models/trace.mvc", 'r').read())
-model_add("models/trace", "formalisms/Trace", open("models/trace_example.mvc", 'r').read())
-
-model_add("formalisms/MM_render/plot", "formalisms/SimpleClassDiagrams", open("models/MM_rendered_plot.mvc", 'r').read())
-def add_trace_trace(model):
-    instantiate(model, "Association", ("abstract/Signal", "rendered/Dataset"), ID="TracabilityLink")
-
-transformation_add_MT({"abstract": "formalisms/Trace", "rendered": "formalisms/MM_render/plot"}, {"rendered": "formalisms/MM_render/plot"}, "models/trace_mapper", open("models/trace_mapper.mvc", 'r').read(), add_trace_trace)
-
-model_add("formalisms/MM_render/graphical", "formalisms/SimpleClassDiagrams", open("models/MM_render.mvc", 'r').read())
-
-def scd_tracability(model):
-    instantiate(model, "Association", ("abstract/Class", "rendered/Group"), ID="TracabilityClass")
-    instantiate(model, "Association", ("abstract/Association", "rendered/ConnectingLine"), ID="TracabilityAssociation")
-
-transformation_add_AL({"rendered": "formalisms/MM_render/graphical", "abstract": "formalisms/SimpleClassDiagrams"}, {"rendered": "formalisms/MM_render/graphical"}, "models/render_SCD", open("models/render_SCD.alc", 'r').read(), callback=scd_tracability)
-"""
-
-model_add("formalisms/CBD/Design_MM", "formalisms/SimpleClassDiagrams", open("models/cbd_design.mvc", 'r').read())
-model_add("formalisms/CBD/PartialRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/cbd_partial_runtime.mvc", 'r').read())
-model_add("formalisms/CBD/FullRuntime_MM", "formalisms/SimpleClassDiagrams", open("models/cbd_runtime.mvc", 'r').read())
-
-model_add("models/CBD_spring", "formalisms/CBD/Design_MM", open("models/cbd_spring.mvc", 'r').read())
-
-transformation_add_MANUAL({"Design": "formalisms/CBD/Design_MM"}, {"Design": "formalisms/CBD/Design_MM"}, "models/CBD/edit")
-
-def trace_D2P(model):
-    instantiate(model, "Association", ("Design/Block", "PartialRuntime/Block"), ID="D2P_block")
-
-transformation_add_AL({"Design": "formalisms/CBD/Design_MM", "PartialRuntime": "formalisms/CBD/PartialRuntime_MM"}, {"PartialRuntime": "formalisms/CBD/PartialRuntime_MM"}, "models/CBD/toRuntime", open("models/cbd_toRuntime.alc", 'r').read(), trace_D2P)
-
-def trace_P2F(model):
-    instantiate(model, "Association", ("PartialRuntime/Block", "FullRuntime/Block"), ID="P2F_block")
-
-transformation_add_AL({"PartialRuntime": "formalisms/CBD/PartialRuntime_MM", "FullRuntime": "formalisms/CBD/FullRuntime_MM"}, {"NewFullRuntime": "formalisms/CBD/FullRuntime_MM"}, "models/CBD/merge", open("models/cbd_merge.alc", 'r').read(), trace_P2F)
-transformation_add_AL({"FullRuntime": "formalisms/CBD/FullRuntime_MM"}, {"FullRuntime": "formalisms/CBD/FullRuntime_MM"}, "models/CBD/simulate", open("models/cbd_simulate.alc", 'r').read())
-transformation_add_AL({}, {}, "models/CBD/restartSim", open("models/cbd_restartSim.alc", 'r').read())
-
-model_add("models/live_modelling_CBD", "formalisms/ProcessModel", open("models/pm_live_CBD.mvc", 'r').read())
-
-def add_trace_CBD(model):
-    instantiate(model, "Association", ("abstract/Block", "rendered/Group"), ID="TracabilityClass")
-
-transformation_add_AL({"abstract": "formalisms/CBD/Design_MM", "rendered": "formalisms/MM_render/graphical"}, {"rendered": "formalisms/MM_render/graphical"}, "models/CBD/render_graphical", open("models/CBD_mapper.alc", 'r').read(), add_trace_CBD)
-
-"""
-def modify_model(model):
-    if len(all_instances(model, "Design/ProbeBlock")) > 2:
-        import time
-        print("Sufficient Probeblocks detected, so pausing with edits")
-        while 1:
-            time.sleep(1)
-
-    new_block = instantiate(model, "Design/ProbeBlock")
-    attr_assign(model, new_block, "name", "MyProbeBlock")
-    print("Added new probeblock: " + new_block)
-
-def idle(model):
-    import time
-    while 1:
-        time.sleep(1)
-
-#process_execute("models/live_modelling_CBD", {"design_model": "models/CBD_spring"}, {"models/CBD/edit": modify_model})
-#process_execute("models/live_modelling_CBD", {"design_model": "models/CBD_spring"}, {"models/CBD/edit": idle})
-
-model_add("formalisms/PW_Plant", "formalisms/SimpleClassDiagrams", open("models/plant_PW.mvc", 'r').read())
-model_add("models/plant", "formalisms/PW_Plant", open("models/plant_model.mvc", 'r').read().replace("PW_Plant/", ""))
-model_add("formalisms/Requirements", "formalisms/SimpleClassDiagrams", open("models/requirements.mvc", 'r').read())
-model_add("models/requirements", "formalisms/Requirements", open("models/requirements_model.mvc", 'r').read().replace("Requirements/", ""))
-model_add("formalisms/Encapsulated_PetriNet", "formalisms/SimpleClassDiagrams", open("models/petrinet_ports.mvc", 'r').read())
-transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "PW_Plant": "formalisms/PW_Plant"}, {"PW_Plant": "formalisms/PW_Plant"}, "models/revise_plant")
-
-def tracability_PLANT2EPN(model):
-    instantiate(model, "Association", ("PW_Plant/State", "Encapsulated_PetriNet/Place"), ID="PLANT2EPN_link")
-    instantiate(model, "Association", ("PW_Plant/Transition", "Encapsulated_PetriNet/Transition"), ID="PLANT2EPN_tlink")
-transformation_add_MT({"PW_Plant": "formalisms/PW_Plant"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/plant_to_EPN", open("models/plant_to_EPN.mvc", 'r').read(), tracability_PLANT2EPN)
-
-model_add("formalisms/ParallelDEVS", "formalisms/SimpleClassDiagrams", open("models/paralleldevs_design.mvc").read())
-model_add("models/produce_consume_pdevs", "formalisms/ParallelDEVS", open("models/produce_consume_PDEVS.mvc").read())
-transformation_add_AL({"ParallelDEVS": "formalisms/ParallelDEVS"}, {}, "models/paralleldevs_simulator", open("models/pdevs_client.alc", "r").read())
-
-model_add("formalisms/ReachabilityGraph", "formalisms/SimpleClassDiagrams", open("models/reachability_graph.mvc", "r").read())
-model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", 'r').read())
-model_add("formalisms/PW_Environment", "formalisms/SimpleClassDiagrams", open("models/environment_PW.mvc", 'r').read())
-model_add("formalisms/PW_Control", "formalisms/SimpleClassDiagrams", open("models/control_PW.mvc", 'r').read())
-model_add("formalisms/Query", "formalisms/SimpleClassDiagrams", open("models/query.mvc", 'r').read())
-model_add("formalisms/Architecture", "formalisms/SimpleClassDiagrams", open("models/architecture.mvc", 'r').read())
-
-model_add("models/pm_powerwindow", "formalisms/ProcessModel", open("models/pm_req_analyse.mvc", 'r').read())
-
-model_add("models/environment", "formalisms/PW_Environment", open("models/environment_model.mvc", 'r').read().replace("PW_Environment/", ""))
-model_add("models/control", "formalisms/PW_Control", open("models/control_model.mvc", 'r').read().replace("PW_Control/", ""))
-model_add("models/control_wrong", "formalisms/PW_Control", open("models/control_model_wrong.mvc", 'r').read().replace("PW_Control/", ""))
-model_add("models/query", "formalisms/Query", open("models/query_model.mvc", 'r').read().replace("Query/", ""))
-model_add("models/architecture", "formalisms/Architecture", open("models/architecture_model.mvc", 'r').read().replace("Architecture/", ""))
-
-transformation_add_MANUAL({"Requirements": "formalisms/Requirements"}, {"Requirements": "formalisms/Requirements"}, "models/revise_req")
-transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "PW_Environment": "formalisms/PW_Environment"}, {"PW_Environment": "formalisms/PW_Environment"}, "models/revise_environment")
-transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "PW_Control": "formalisms/PW_Control"}, {"PW_Control": "formalisms/PW_Control"}, "models/revise_control")
-transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "Query": "formalisms/Query"}, {"Query": "formalisms/Query"}, "models/revise_query")
-transformation_add_MANUAL({"Requirements": "formalisms/Requirements", "Architecture": "formalisms/Architecture"}, {"Architecture": "formalisms/Architecture"}, "models/revise_architecture")
-
-def tracability_CTRL2EPN(model):
-    instantiate(model, "Association", ("PW_Control/State", "Encapsulated_PetriNet/Place"), ID="CTRL2EPN_link")
-    instantiate(model, "Association", ("PW_Control/Transition", "Encapsulated_PetriNet/Transition"), ID="CTRL2EPN_tlink")
-
-def tracability_ENV2EPN(model):
-    instantiate(model, "Association", ("PW_Environment/Event", "Encapsulated_PetriNet/Place"), ID="ENV2EPN_link")
-
-def tracability_EPN2PN(model):
-    instantiate(model, "Association", ("Encapsulated_PetriNet/Place", "PetriNet/Place"), ID="EPN2PN_transition_link")
-    instantiate(model, "Association", ("Encapsulated_PetriNet/Transition", "PetriNet/Transition"), ID="EPN2PN_place_link")
-
-transformation_add_MT({}, {"PW_Plant": "formalisms/PW_Plant", "PW_Environment": "formalisms/PW_Environment", "PW_Control": "formalisms/PW_Control", "Query": "formalisms/Query", "Architecture": "formalisms/Architecture", "Requirements": "formalisms/Requirements"}, "models/make_initial_models", open("models/initialize.mvc", 'r').read())
-transformation_add_MT({"PW_Control": "formalisms/PW_Control"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/control_to_EPN", open("models/control_to_EPN.mvc", 'r').read(), tracability_CTRL2EPN)
-transformation_add_MT({"PW_Environment": "formalisms/PW_Environment"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/environment_to_EPN", open("models/environment_to_EPN.mvc", 'r').read(), tracability_ENV2EPN)
-transformation_add_MT({"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet", "Architecture": "formalisms/Architecture"}, {"PetriNet": "formalisms/PetriNet"}, "models/combine_EPN", open("models/combine_EPN.mvc", 'r').read(), tracability_EPN2PN)
-transformation_add_MT({"ReachabilityGraph": "formalisms/ReachabilityGraph", "Query": "formalisms/Query"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/match", open("models/matches.mvc", 'r').read())
-
-transformation_add_AL({"PetriNet": "formalisms/PetriNet"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/reachability", open("models/reachability.alc", 'r').read())
-transformation_add_AL({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/bfs", open("models/bfs.alc", 'r').read())
-transformation_add_AL({"EPN_Plant": "formalisms/Encapsulated_PetriNet", "EPN_Control": "formalisms/Encapsulated_PetriNet", "EPN_Environment": "formalisms/Encapsulated_PetriNet"}, {"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, "models/merge_EPN", open("models/merge_EPN.alc", 'r').read())
-
-transformation_add_AL({"Encapsulated_PetriNet": "formalisms/Encapsulated_PetriNet"}, {}, "epn_print", open("models/epn_print.alc").read())
-transformation_add_AL({"PetriNet": "formalisms/PetriNet"}, {}, "pn_print", open("models/pn_print.alc").read())
-"""

+ 10 - 3
services/DEVS/main.py

@@ -6,16 +6,20 @@ from pprint import pprint
 from multiprocessing import Process, Pipe, freeze_support
 
 sys.path.append('services/DEVS/pypdevs/src')
-sys.path.append('services/DEVS/pypdevs/examples')
+sys.path.append('services/DEVS/models')
 
 from simulator import Controller
-from ps_model import Root
 
 import threading, time
 
 def pypdevs_service(port):
-    exec(service_get(port), globals(), {})
+    code = service_get(port)
+    model_name = str(uuid.uuid4()).replace("-", "")
 
+    with open("services/DEVS/models/" + model_name + ".py", 'w') as f:
+        f.write(code)
+
+    Root = getattr(__import__(model_name), "Root")
     controller = Controller(Root())
 
     def inputter():
@@ -36,17 +40,20 @@ def pypdevs_service(port):
             except:
                 import traceback
                 traceback.print_exc()
+
     input_thread = threading.Thread(target=inputter)
     input_thread.daemon = True
     input_thread.start()
 
     output_listener = controller.addOutputListener(["reply"])
+
     def outputter():
         print("Waiting for output...")
         while 1:
             output_val = output_listener.fetch(-1)
             print("Got output from simulator: %s" % output_val)
             service_set(port, json.dumps({"name": output_val.getName(), "port": output_val.getPort(), "params": output_val.getParameters()}))
+
     output_thread = threading.Thread(target=outputter)
     output_thread.daemon = True
     output_thread.start()

+ 1 - 0
services/DEVS_batch/main.py

@@ -16,6 +16,7 @@ def pypdevs_service(port):
 
     main = getattr(__import__(model_name), "main")
     service_set(port, main())
+
 try:
     init(sys.argv[1])
     login("pypdevs_batch_service", "my_password")

+ 0 - 26
unit/test_all.py

@@ -94,9 +94,7 @@ class TestModelverse(unittest.TestCase):
     @classmethod
     def tearDownClass(self):
         try:
-            print("Killing " + str(TestModelverse.proc))
             kill(TestModelverse.proc)
-            print("Killed " + str(TestModelverse.proc))
         except:
             print("Got exception during teardown.")
 
@@ -148,7 +146,6 @@ class TestModelverse(unittest.TestCase):
         # Check that an instantiate of "A" fails
         try:
             res = instantiate("test/my_empty", "A")
-            print("RESULT: " + str(res))
             assert False
         except UnknownIdentifier:
             assert verify("test/Empty", "formalisms/SimpleClassDiagrams") == "OK"
@@ -228,21 +225,14 @@ class TestModelverse(unittest.TestCase):
         thrd.start()
 
         assert transformation_execute_MT("test/print_pn", {"PetriNet": "test/my_pn"}, {}, (ctrl, "inp", "outp")) == True
-        print("Joining")
         thrd.join()
-        print("Joined")
-        print("Got log: " + str(log))
         assert set(log) == set(['"p1" --> 1',
                                 '"p2" --> 2',
                                 '"p3" --> 3'])
 
-        print("MAN")
         assert transformation_execute_MANUAL("test/pn_design_to_runtime", {"PetriNet": "test/my_pn"}, {"PetriNet_Runtime": "test/my_pn_RT"}, manual_callback) == True
-        print("OK")
         assert transformation_execute_AL("test/pn_simulate", {"PetriNet_Runtime": "test/my_pn_RT"}, {"PetriNet_Runtime": "test/my_pn_RT"}) == True
-        print("Exec AL OK")
         assert transformation_execute_MT("test/pn_runtime_to_design", {"PetriNet_Runtime": "test/my_pn_RT"}, {"PetriNet": "test/my_pn"}) == True
-        print("MT OK")
 
         log = []
         ctrl = log_output.Controller(log, keep_running=False)
@@ -273,7 +263,6 @@ class TestModelverse(unittest.TestCase):
         transformation_add_MT({"ReachabilityGraph": "test/ReachabilityGraph"}, {}, "test/reachability_print", open("integration/code/reachabilitygraph_print.mvc", 'r').read())
 
         def callback_refine_PN(model):
-            print("MANUAL CODE")
             p1 = instantiate(model, "PetriNet/Place")
             attr_assign(model, p1, "name", "p1")
             attr_assign(model, p1, "tokens", 1)
@@ -283,7 +272,6 @@ class TestModelverse(unittest.TestCase):
 
             p2t = instantiate(model, "PetriNet/P2T", (p1, t1))
             attr_assign(model, p2t, "weight", 1)
-            print("END MANUAL CODE")
 
         log = []
         ctrl = log_output.Controller(log, keep_running=False)
@@ -334,9 +322,7 @@ class TestModelverse(unittest.TestCase):
         transformation_add_AL({"SCCD": "test/SCCD"}, {"trace": "test/SCCD_Trace"}, "test/SCCD_execute_afap", open("integration/code/SCCD_execute.alc", 'r').read().replace("afap = False", "afap = True"))
         transformation_execute_AL("test/SCCD_execute_afap", {"SCCD": "test/my_SCCD"}, {"trace": "test/my_SCCD_trace"})
 
-        print("Executed AL")
         alter_context("test/my_SCCD_trace", "test/SCCD_Trace")
-        print("Altered context")
         lst = element_list_nice("test/my_SCCD_trace")
 
         model_delete("merged")
@@ -344,7 +330,6 @@ class TestModelverse(unittest.TestCase):
 
         lst.sort(key=lambda i: (i["timestamp"], i["name"]))
         result = [(i["timestamp"], str(i["name"])) for i in lst if i["name"] not in ["updateTimerValue", "updateTimerColour", "resetTimer"]]
-        print(result)
 
         assert result == [(5.0, "displayRed"),
                           (20.0, "displayYellow"),
@@ -468,14 +453,3 @@ class TestModelverse(unittest.TestCase):
             self.fail()
         except:
             pass
-
-
-if __name__== "__main__":
-
-    tmv = TestModelverse()
-    print("Setting up class")
-    tmv.setUpClass()
-    print("Setting up")
-    tmv.setUp()
-    print("Start test")
-    tmv.test_operations()

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Fri May 18 15:00:59 2018
+Date:   Fri May 18 15:41:18 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server