12345678910111213141516171819202122232425262728293031323334 |
- include "primitives.alh"
- include "services.alh"
- include "modelling.alh"
- include "object_operations.alh"
- include "utils.alh"
- include "io.alh"
- Boolean function main(model : Element):
- String port
- String the_input
- String devs_model
- port = comm_connect("pypdevs_simulator")
-
- log("(PDEVS) task name = " + get_taskname())
- log("(PDEVS) Sending model...")
- comm_set(port, read_attribute(model, set_pop(allInstances(model, "MyString/MyString")), "value"))
- log(port)
-
- while (True):
- if (comm_hasInput(port)):
- log(cast_v2s(has_input()))
- the_input = comm_get(port)
- log("(PDEVS) Got input from simulator!")
- log(the_input)
- output(the_input)
- if (has_input()):
- the_input = input()
- log("(PDEVS) Got input from console/ps simulator!")
- log(cast_v2s(the_input))
- if (is_physical_string(the_input)):
- comm_set(port, the_input)
- else:
- comm_set(port, cast_v2s(the_input))
- sleep(0.05)
|