pdevs_client.alc 782 B

1234567891011121314151617181920212223242526
  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(the_input)
  23. comm_set(port, cast_v2s(the_input))