Entering a state

The enter() operation allows an object to enter a state after the object has successfully received a trigger and any possible guard condition has been passed. The enter() operation also executes any user‑defined action on entry for the state.

About this task

The enter() operation name has the following format:

<object>_<state>_enter(<object*> const <me>)

For example, the following enter() operation is generated for the systemControl state of the HomeHeatingSystem:

void HomeHeatingSystem_systemControl_enter(
   HomeHeatingSystem* const me);

The enter() operation sets the <state>_subState and <state>_active members of the state being exited (based on the statechart) to the one being entered. For example, the enter() operation for the systemControl state of the HomeHeatingSystem sets these two members of the rootState (the previous state) to the systemControl state (the one being entered), as follows:

void HomeHeatingSystem_systemControl_enter(
   HomeHeatingSystem* const me) {
   NOTIFY_STATE_ENTERED(me, HomeHeatingSystem,
      "ROOT.systemControl");
   me->rootState_subState = HomeHeatingSystem_systemControl;
   me->rootState_active = HomeHeatingSystem_systemControl;
   RiCTask_schedTm(me->ric_reactive.myTask, 3000,
      HomeHeatingSystem_Timeout_systemControl_id, 
         &me->ric_reactive, "ROOT.systemControl");
}
Note: An enter() operation is not generated for the root state.

Feedback