RiCIS_IN() or IS_IN()

The IS_IN() statement determines whether an object is in a particular state.

RICIS_IN() has the same effect as IS_IN(). This statement takes a pointer to an object and the name of the state being checked as arguments. The name of the state has the format <object>_<state>.

For example, to make sure that a Furnace object is not in the faultS state before it changes from one state to another, you can use the following IS_IN() statement as a guard on a transition in the statechart for the Furnace:

[!IS_IN(me,Furnace_faultS)]

The definition of IS_IN() is as follows:

#define IS_IN(me, state) state##_IN((me))

This macro calls the IN() operation generated for the state. See Checking the state of an object.

When referencing states, you must use the generated state name. This method can be tricky when referencing sibling states that have the same name. For example, if an object A has an And state B with concurrent states B1 and B2, and each of these has a substate C, the following enumerated values are generated for these states:

/*states enumeration: */
enum A_Enum{ A_RiCNonState=0, A_B=1, A_B2=2,
   A_B2_C=3, A_B1=4, A_C=5 }

The generated name of substate C of B1 is A_C. Therefore, the proper macro call to see whether A is in C of B1 would be IS_IN(me, A_C), not IS_IN(me, A_B1_C).


Feedback