test_SCCD.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import sys
  2. sys.path.append("wrappers")
  3. from modelverse import *
  4. init()
  5. login("admin", "admin")
  6. # Assume that we don't change the SCCD MM
  7. try:
  8. model_add("formalisms/SCCD", "formalisms/SimpleClassDiagrams", open("models/SCCD.mvc", 'r').read())
  9. except ModelExists:
  10. pass
  11. try:
  12. model_add("formalisms/SCCD_Trace", "formalisms/SimpleClassDiagrams", open("models/SCCD_Trace.mvc", 'r').read())
  13. except ModelExists:
  14. pass
  15. # Update the model of the traffic light
  16. if "my_SCCD" in [i[0] for i in model_list("models")]:
  17. model_delete("models/my_SCCD")
  18. #model_add("models/my_SCCD", "formalisms/SCCD", open("models/dynamic_trafficlight.mvc", 'r').read())
  19. model_add("models/my_SCCD", "formalisms/SCCD", open("integration/code/SCCD_all.mvc", 'r').read())
  20. # Add SCCD execution semantics
  21. transformation_add_AL({"SCCD": "formalisms/SCCD"}, {"trace": "formalisms/SCCD_Trace"}, "models/SCCD_execute", open("models/SCCD_execute.alc", 'r').read())
  22. # Execute it, while interacting through the console
  23. def callback(inp):
  24. print(inp)
  25. inp = raw_input()
  26. if inp == "":
  27. return None
  28. else:
  29. return inp
  30. transformation_execute_AL("models/SCCD_execute", {"SCCD": "models/my_SCCD"}, {"trace": "models/my_trace"}, callback=callback)