debug_DEVS.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. import sys
  2. sys.path.append("wrappers")
  3. from modelverse import *
  4. init()
  5. login("admin", "admin")
  6. model_add("formalisms/ParallelDEVS", "formalisms/SimpleClassDiagrams", open("models/ParallelDEVS/metamodels/PDEVS.mvc", 'r').read())
  7. model_add("models/produce_consume_pdevs", "formalisms/ParallelDEVS", open("models/ParallelDEVS/models/produce_consume.mvc", 'r').read())
  8. transformation_add_AL({"ParallelDEVS": "formalisms/ParallelDEVS"}, {}, "models/paralleldevs_simulator", open("models/ParallelDEVS/transformations/simulate_interactive.alc", "r").read())
  9. import poll_print
  10. ctrl = poll_print.Controller(keep_running=False)
  11. thrd = threading.Thread(target=ctrl.start)
  12. thrd.daemon = True
  13. thrd.start()
  14. def input_thread():
  15. import select
  16. while thrd.is_alive():
  17. if select.select([sys.stdin], [], [], 0.1)[0]:
  18. ctrl.addInput(Event("raw_inp", "user_inp", [sys.stdin.readline().strip()]))
  19. thrd2 = threading.Thread(target=input_thread)
  20. thrd2.daemon = True
  21. thrd2.start()
  22. transformation_execute_AL("models/paralleldevs_simulator", {"ParallelDEVS": "models/produce_consume_pdevs"}, {}, statechart=(ctrl, "inp", "outp"))