User code is the action part of transitions in statecharts. For example, using the value of 3, all transitions with actions consisting of three lines or fewer of code are automatically inlined in the calling function.
Inlining is replacing a function call in the generated code with the actual code statements that make up the body of the function. This method optimizes code execution at the expense of a slight increase in code size. For example, increasing the number of lines that can be inlined from 3 to 5 has shortened the code execution time up to 10%.
For example, in the statechart of the HomeHeatingSystem object, the systemControl state has an out transition on a timeout with the following action part:
if(IS_IN(&me->theFurnace,Furnace_starting)) RiCGEN(&me->theFurnace,motorReady());

This action sends a motorReady() event from the HomeHeatingSystem to the Furnace, if the Furnace is in the starting state.
If the ComplexityForInlining property is set to 0 (the default value), the transition code is generated in the takeEvent() operation of the systemControl state of the HomeHeatingSystem object as follows:
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;
}
The dispatchEvent() operation of the rootState of the HomeHeatingSystem object calls the takeEvent() operation as follows:
static int rootState_dispatchEvent(
void * const void_me, short id) {
HomeHeatingSystem * const me =
(HomeHeatingSystem *)void_me;
int res = eventNotConsumed;
switch (me->rootState_active) {
case HomeHeatingSystem_systemControl:
{
res =
HomeHeatingSystem_systemControl_takeEvent(
me, id);
break;
};
default:
break;
};
return res;
}
However, if ComplexityForInlining is set to 3, for example, because the action code is less than three lines, it is generated directly in the dispatchEvent() operation of the rootState, replacing the takeEvent() call as follows:
static int rootState_dispatchEvent(void * const void_me,
short id) {
HomeHeatingSystem * const me = (HomeHeatingSystem *)
void_me;
int res = eventNotConsumed;
switch (me->rootState_active) {
case HomeHeatingSystem_systemControl:
{
if(id == Timeout_id)
{
if(RiCTimeout_getTimeoutId(
(RiCTimeout*) me
->ric_reactive.current_event) ==
HomeHeatingSystem_Timeout_systemControl_id)
{
NOTIFY_TRANSITION_STARTED(me,HomeHeatingSystem,
"1");
RiCTask_unschedTm(me->ric_reactive.myTask,
HomeHeatingSystem_Timeout_systemControl_id,
&me->ric_reactive);
NOTIFY_STATE_EXITED(me,HomeHeatingSystem,
"ROOT.systemControl");
{
/*#[ transition 1 */
if(IS_IN(&me->theFurnace, Furnace_starting))
RiCGEN(&me->theFurnace,motorReady());
/*#]*/
}
}
/* rest of dispatchEvent() */
}