The slice timer should be stopped when not in the
Running state. The way to enforce this is
to add an
Exit block to
Running and move the
stopSliceTimer() action there.
Since the state's
Exit actions are being
defined, it would appear natural to put the
startSliceTimer() action into a
Entry block. But there two reasons against
There is only one transition into the
Running's entry actions gains nothing.
startSliceTimer()is an entry action, then it cannot access that transition argument. The only way around it is to store the slice time in the
Taskclass and then retrieve it immediately in the entry action (
startSliceTimer(ctxt.getSliceTime())). Now moving the action to the entry block is worse than doing nothing.
(Go here to learn more about state entry and exit actions.)
There is one final task: connecting the task FSM to
Task application class.