pdevs_client.alc 946 B

12345678910111213141516171819202122232425262728293031
  1. include "primitives.alh"
  2. include "services.alh"
  3. include "modelling.alh"
  4. include "object_operations.alh"
  5. Boolean function main(model : Element):
  6. String port
  7. String the_input
  8. String devs_model
  9. port = comm_connect("pypdevs_simulator")
  10. log("Sending model...")
  11. comm_set(port, read_attribute(model, set_pop(allInstances(model, "MyString/MyString")), "value"))
  12. log(port)
  13. while (True):
  14. if (comm_hasInput(port)):
  15. log(cast_v2s(has_input()))
  16. the_input = comm_get(port)
  17. log("Got input from simulator!")
  18. log(the_input)
  19. output(the_input)
  20. if (has_input()):
  21. the_input = input()
  22. log("Got input from console!")
  23. log(cast_v2s(the_input))
  24. if (is_physical_string(the_input)):
  25. comm_set(port, the_input)
  26. else:
  27. comm_set(port, cast_v2s(the_input))
  28. sleep(0.05)