Stateflow    

User-Written Functions

You can specify calls to user-written functions in the action language. These guidelines apply to user-written function calls:

Example: Function Call Transition Action

These are example formats of function calls using transition action notation.

If S1 is active, event e occurs, c is true, and the transition destination is determined, then a function call is made to function_name with arg1, arg2, and arg3. The transition action in the transition from S2 to S3 shows a function call nested within another function call.

Example: Function Call State Action

These are example formats of function calls using state action notation.

When the default transition into S1 occurs, S1 is marked active and then its entry action, a function call to function_name1 with the specified arguments, is executed and completed. If S2 is active and an event occurs, the during action, a function call to function_name3 with the specified arguments, executes and completes.

Passing Arguments by Reference

A Stateflow action can pass arguments to a user-written function by reference rather than by value. In particular, an action can pass a pointer to a value rather than the value itself. For example, an action could contain the following call.

where f is a custom-code C-function that expects a pointer to x as an argument.

If x is the name of a data item defined in the SF data dictionary, the following rules apply.


 Assignment Operations ml() Functions