Taking events

The takeEvent() operation takes an event off the event queue and evaluates whether that event is valid to trigger a transition of the object out of its current state.

About this task

The takeEvent() operation name has the following format:

<object>_<state>_takeEvent(<object>* const <me>, 
<event ID>)

The event ID is the identification number generated for an event at the top of the package specification file.

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

int HomeHeatingSystem_systemControl_takeEvent(
   HomeHeatingSystem* const me, short id);

This operation has the following implementation:

int HomeHeatingSystem_systemControl_takeEvent(
   HomeHeatingSystem* const me, short id) {
   int res = eventNotConsumed;
   if(id == Timeout_id)
    {
      if(RiCTimeout_getTimeoutId((RiCTimeout*) 
         me->ric_reactive.current_event) ==
         HomeHeatingSystem_Timeout_systemControl_id)
       {
         NOTIFY_TRANSITION_STARTED(me,
            HomeHeatingSystem, "1");            
         HomeHeatingSystem_systemControl_exit(me);
         {
            /*#[ transition 1 */
            if(IS_IN(&me->theFurnace,Furnace_starting))
               RiCGEN(&me->theFurnace,motorReady());
            /*#]*/
         }
         systemControl_entDef(me);
         NOTIFY_TRANSITION_TERMINATED(me,
         HomeHeatingSystem, "1");
         res = eventConsumed;
      }
   }
   return res;
}
Note: A takeEvent() operation is not generated for the root state.

Feedback