pdevs_client.alc 924 B

123456789101112131415161718192021222324252627282930
  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. port = comm_connect("pypdevs_simulator")
  9. log("Sending model...")
  10. comm_set(port, read_attribute(model, set_pop(allInstances(model, "MyString/MyString")), "value"))
  11. log(port)
  12. while (True):
  13. if (comm_hasInput(port)):
  14. log(cast_v2s(has_input()))
  15. the_input = comm_get(port)
  16. log("Got input from simulator!")
  17. log(the_input)
  18. output(the_input)
  19. if (has_input()):
  20. the_input = input()
  21. log("Got input from console!")
  22. log(cast_v2s(the_input))
  23. if (is_physical_string(the_input)):
  24. comm_set(port, the_input)
  25. else:
  26. comm_set(port, cast_v2s(the_input))
  27. sleep(0.05)