Book a Demo

Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Prev Next

Legacy StateMachine Templates

Code generation operates using a set of generation templates. From Release 11.0 of Enterprise Architect, a different set of templates are available as the default for software code generation from a StateMachine diagram into Java, C, ANSI C++ or C# code. You can still use the original templates, as described here, for models developed in earlier releases of Enterprise Architect, if you do not want to upgrade them for the new template facilities.

Switch Between Legacy and Release 11 templates

Access

Display the 'Manage Project Options' dialog, then show the 'Language Specifications' page for your chosen language, using one of the methods outlined in this table. If necessary, expand the 'StateMachine Engineering (for current model)' grouping and set the 'Use the new StateMachine Template' option to True (to use the later templates) or False (to use the Legacy templates).

Ribbon

Configure > Model > Options > Source Code Engineering > [language name]

Legacy Template Transformations

A StateMachine in a Class internally generates a number of constructs in software languages to provide effective execution of the States' behaviors (do, entry and exit) and also to code the appropriate transition's effect when necessary.

Model Objects

Code Objects

See also

Enumerations

  • StateType - consists of an enumeration for each of the States contained within the StateMachine
  • TransitionType – consists of an enumeration for each transition that has a valid effect associated with it; for example, ProcessOrder_Delivered_to_ProcessOrder_Closed
  • CommandType – consists of an enumeration for each of the behavior types that a State can contain (Do, Entry, Exit)

Attributes

  • currState:StateType - a variable to hold the current State's information
  • nextState:StateType - a variable to hold the next State's information, set by each State's transitions accordingly
  • currTransition:TransitionType - a variable to hold the current transition information; this is set if the transition has a valid effect associated with it
  • transcend:Boolean - a flag used to advise if a transition is involved in transcending between different StateMachines (or Submachine states)
  • xx_history:StateType - a history variable for each StateMachine/Submachine State, to hold information about the last State from which the transition took place

Operations

  • StatesProc - a States procedure, containing a map between a State's enumeration and its operation; it de-references the current State's information to invoke the respective State's function
  • TransitionsProc - a Transitions procedure, containing a map between the Transition's enumeration and its effect; it invokes the Transition's effect
  • <<State>> - an operation for each of the States contained within the StateMachine; this renders a State's behaviors based on the input CommandType, and also executes its transitions
  • initializeStateMachine - a function that initializes all the framework-related attributes
  • runStateMachine - a function that iterates through each State, and executes their behaviors and transitions accordingly
Operation Behavior

Notes

  • To be able to generate code from behavioral models, all behavioral constructs should be contained within a Class

Learn more