docs: fix bug in documenting port reads + add section on level events with ports.

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
scripting: more robust state change scheduling in order to avoid races

When evenTransition comes into a state machine, this may cause re-writing
of the entry/running/exit programs currently being executed, becaues the
event sets these hooks immediately, instead of letting the FSM finish
the current (entry or exit) program.

This patch lets changeState schedule a state change, and makes enterstate/
leavestate effectively do the state change and switch the new state programs in.

Since changeState now only schedules, in a number of places, the executePending()
function needs to be called to effectively execute SM statements.

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
scripting: correctly implement asynchronous events in eventTransition

Before this patch, only the last eventTransition of two consecutive ones took effect,
since the event data was shared among all subscribers. This patch makes eventTransition
synchronous again such that each eventTransition evaluates its own data. This requires
some proper locking in the SM.

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
ports: add clear() to inputport operation object.

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
Merge pull request #68 from psoetens/master

Fix state_test failure by fixing StateMachine responding to signals