statechart: echo.scxml
The statechart receives one or more echo events and prints out the event parameter onto the console. It terminates upon a quit event. See also README.md in the dsl4sc repository.
$ cat <<EOF | scxmlrun echo.scxml
{"event" : {"name":"echo", "data":"hello"}}
{"event" : {"name":"echo", "data":"world"}}
{"event" : {"name":"quit"}}
EOF
then we immediately get the following console messages:
hello
world
events can be passed over the network:
$ scxmlrun echo.scxml --sub echo &
$ cat <<EOF | mosquitto_pub -t echo -l
{"event" : {"name":"echo", "data":"hello"}}
{"event" : {"name":"echo", "data":"world"}}
{"event" : {"name":"quit"}}
EOF
test automation using shelltest
for convenience, the above examples are defined respectively in echo.conf and echo_mqtt.conf, and can be tested, using the shelltest tool, as follows
$ shelltest echo.conf
:echo.conf: [OK]
...
$ shelltest echo_mqtt.conf
:echo_mqtt.conf: [OK]
...