SCCD_execute.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import sys
  2. sys.path.append("wrappers")
  3. from modelverse import *
  4. init()
  5. login("admin", "admin")
  6. model_add("test/SCCD", "formalisms/SimpleClassDiagrams", open("models/SCCD/metamodels/SCCD.mvc", 'r').read())
  7. model_add("test/SCCD_Trace", "formalisms/SimpleClassDiagrams", open("models/DiscreteEventTrace/metamodels/trace.mvc", 'r').read())
  8. model_add("test/my_SCCD", "test/SCCD", open("models/SCCD/models/dynamic_trafficlight.mvc", 'r').read())
  9. #transformation_add_AL({"SCCD": "test/SCCD"}, {"trace": "test/SCCD_Trace"}, "test/SCCD_execute_afap", open("models/SCCD/transformations/execute.alc", 'r').read().replace("afap = False", "afap = True"))
  10. transformation_add_AL({"SCCD": "test/SCCD"}, {"trace": "test/SCCD_Trace"}, "test/SCCD_execute_afap", open("models/SCCD/transformations/execute.alc", 'r').read())
  11. import poll_print
  12. ctrl = poll_print.Controller(keep_running=False)
  13. thrd = threading.Thread(target=ctrl.start)
  14. thrd.daemon = True
  15. thrd.start()
  16. def input_thread():
  17. import select
  18. while thrd.is_alive():
  19. if select.select([sys.stdin], [], [], 0.1)[0]:
  20. ctrl.addInput(Event("raw_inp", "user_inp", [sys.stdin.readline().strip()]))
  21. thrd2 = threading.Thread(target=input_thread)
  22. thrd2.daemon = True
  23. thrd2.start()
  24. transformation_execute_AL("test/SCCD_execute_afap", {"SCCD": "test/my_SCCD"}, {"trace": "test/my_SCCD_trace"}, statechart=(ctrl, "inp", "outp"))
  25. alter_context("test/my_SCCD_trace", "test/SCCD_Trace")
  26. lst = element_list_nice("test/my_SCCD_trace")
  27. lst.sort(key=lambda i: (i["timestamp"], i["name"]))
  28. result = [(i["timestamp"], str(i["name"])) for i in lst if i["name"] not in ["updateTimerValue", "updateTimerColour", "resetTimer"]]
  29. print(result)