pdevs_client.alc 982 B

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