Stateflow    

Creating Stateflow Objects

You create a Stateflow object of type State, Box, Function, Note, Transition, Junction, Event, Data, or Target through a call to a constructor method for the object type using the parent (containing) object as an argument. The constructor returns a handle to the newly created object, which you place in a workspace variable. You then use the handle to the object to display or change the object through its properties and methods.

For example, the following command creates and returns a handle s to a new state object in the chart object ch:

By default, the newly created state from the preceding command appears in the upper left-hand corner of the Stateflow chart (at x-y coordinates 0,0).

You can now use the handle s to set its name (Name property) and position (Position property). You can also connect it to other states or junctions by creating a Transition object and setting its Source or Destination property to s. See Create New Objects in the Chart for examples.

All Stateflow objects are created using the general form shown in the preceding command. The section Create New Objects in the Chart gives examples for creating states and transitions. Objects of other types are created just as easily. For example, the following command creates and returns a handle (d1) for a new Data object belonging to the state A (handle sA):


  Creating and Destroying API Objects Establishing an Object's Parent (Container)