saStartCtr method
- covariant Rocket sm,
- SamReq req
Handle action RK.saStartCtr
The covariant keyword is used to inform Dart that sm
will be a subclass of
SamModel
and not SamModel
specifically.
The delay
parameter is passed in by the missile version of the app to set
a longer delay than the normal 10 seconds. This illustrates how parameters are
passed in to the action handlers via the stepParms
facility. Refer to the
sample missile app for more details.
Even though we are in the SamModel.present
execution scope we still need to use
sm.flipState()
to change the state so that any queued requests will be
handled properly.
Changing the model state to RK.ssWaiting or RK.ssCounting will reactivate the timer in the nap function napStartTimer.
Implementation
void saStartCtr(covariant Rocket sm,SamReq req) {
int delay = req.stepParms['delay'];
if (delay != null) {
sm.setHot("ctr",delay);
}
int ctr = sm.getHot("ctr") as int;
if(sm.bLog)log("faStartCtr $sm $ctr");
if (ctr > 10) {
sm.flipState(RK.ssWaiting);
} else {
sm.flipState(RK.ssCounting);
}
}