A few month ago we released our Model that we use internally for unit-testing Embedded Engineer found with our other sample models:  CodeGenerationComponentsTest.EAP

Today we want to show you our (internal) documentation which UML types are supported by LieberLieber Embedded Engineer code generation.

We could also describe it as our currently implemented subset of executable UML 😉

Supported UML types

The following is a plaine list of all UML types supported by Embedded Engineer.
Not all types included will be used to generate code directly but might be used for structural or metatype purposes.

All references to UML types are refering to OMG UML Superstructure Version 2.4.1 definitions.

UML chapter Type supported subtypes
7 Class
7.3.1 Abstraction trace
7.3.2 AggregationKind Shared, Composite
7.3.3 Association
7.3.8 Classifier
7.3.12 Dependency
7.3.13 DirectedRelationship
7.3.16 Enumeration
7.3.20 Generalization
7.3.24 Interface
7.3.37 Operation
7.3.38 Package
7.3.42 Parameter
7.3.43 ParameterDirectionKind (all) in, inout, out, return
7.3.44 PrimitiveType
7.3.45 Property
7.3.46 Realization
7.3.53 TypedElement
7.3.54 Usage
7.3.56 VisibilityKind
9.3.12 Port
11.3.4 ActionInputPin
11.3.8 CallAction
11.3.9 CallBehaviorAction
11.3.10 CallOperationAction
11.3.19 InputPin
11.3.26 OpaqueAction
11.3.27 OutputPin
11.3.28 Pin
11.3.38 ReadVariableAction
11.3.45 SendSignalAction
11.3.52 ValueSpecificationAction
11.3.56 WriteVariableAction
12.3.4 Activity
12.3.5 ActivityEdge
12.3.6 ActivityFinalNode
12.3.8 ActivityNode
12.3.9 ActivityParameterNode
12.3.12 Behavior
12.3.14 CallBehaviorAction
12.3.15 CallOperationAction
12.3.17 Clause
12.3.18 ConditionalNode
12.3.19 ControlFlow
12.3.20 ControlNode
12.3.22 DecisionNode
12.3.24 ExecutableNode
12.3.26 ExpansionNode
12.3.27 ExpansionRegion
12.3.28 FinalNode
12.3.30 ForkNode
12.3.31 InitialNode
12.3.35 LoopNode
12.3.36 MergeNode
12.3.37 ObjectFlow
12.3.38 ObjectNode
12.3.48 StructuredActivityNode
13.3.2 Behavior
13.3.20 OpaqueBehavior
13.3.24 Signal
13.3.25 SignalEvent
13.3.31 Trigger
15.3.2 FinalState
15.3.8 Pseudostate
15.3.9 PseudostateKind Initial,Shallow History, Deep History, Entry point, Exit point, Junction, Choice
15.3.10 Region
15.3.11 State
15.3.12 StateMachine
15.3.13 TimeEvent
15.3.14 Transition
15.3.15 TransitionKind internal, external
15.3.16 Vertex
Extended type Requirement

Structural requirements for code generation

Embedded Engineer was built to generate behavioral code from state machines and activities for an entire system, therefore a structure containg all elements for code generation needs to be present in the model.

Package

Starting point for code generation is always a package with the main generation settings and the generation folder set as Tagged Values.

A package may contain sub packages for further structuring of the model and classes.

Depending on the settings each sub package may generate a sub directory.

Supported Tagged Values

  • Any Model Settings Tagged Value
    These settings should be handled via the Embedded Engineer settings dialog and may differ between tools.
  • GenSrcDir
    The directory where the code will be generated to.
  • FileHeader
    Customize documentation file header.
  • NoCodeGen
    Disables code generation for this package and all containing elements.
  • MethodHeader *
    Customize documentation header for operations.
  • FieldHeader *
    Customize documentation header for attributes.

* This header will be used for all subsequent methods and fields if not redefined in subsequent packages, elements, methods and/or fields.

Class

Class elements represent the code files themselfs and therfore code, for a declaration and implementation file, will be generated for each class.

A Class may contain Attributes, Operations, Activities, State Machines

Supported UML Attributes/Associations

  • name
    The name of the element, will be used as class name/function prefix.
  • ownedComment
    The Comments owned by this element. Will be used as code comment for the class.
  • ownedAttribute
    The attributes (i.e., the properties) owned by the class
  • ownedOperation
    The operations owned by the class.
  • ownedElement
    The Elements owned by this element. Supported by the code generator are nested Classes, Activities, State Machines

Supported Stereotypes

  • executable entry point
    Generates an Entry Point to your application.
  • singleton
    Generates a singleton pattern for the class.
  • static
    Generates a static class.
  • struct
    Generates a structure as part of another class.
  • standard lib
    Generates a standard library include when linked with an Usage connector.
  • enumeration
    Generates an enumeration using the class attributes.
  • qobject
    Generates all code needed to use QObject features.

Supported Tagged Values

  • FileHeader
    Customize documentation file header.
  • NoCodeGen
    Disables code generation for this class and all containing elements.
  • MethodHeader *
    Customize documentation header for operations.
  • FieldHeader *
    Customize documentation header for attributes.
  • IncludePath
    Allows customization of the Include path (overrules “Generage Directory for Package” setting)

* This header will be used for all subsequent methods and fields if not redefined in subsequent packages, elements, methods and/or fields.

Attribute

An Attribute will be used to generated variables inside the code. By changing the attributes of an Attribute or extending it with stereotypes, attributes can generate: constants, type definitions, defines, externs, statics,…

Supported UML Attributes/Associations

  • name
    The name of the element, will be used as variable name.
  • type
    Can be a simple string or a typed element and serves as the type of the variable/define/… generated.
  • default
    A string defining the value used to initialize the variable/define/constant.
  • aggregation
    Will be mapped to value containment (e.g.: Shared = by Reference, else = by Value)
  • multiplicity (lower-, upper-bound)
    Will result in creating an array variable with the given type.
  • isStatic
    Will be associated with the “static” modifier for code generation.
  • isReadOnly
    Generates a constant variable.
  • visibility
    VisibilityKind will be mapped to generated language modifiers (e.g.: private, public,…)
  • ownedComment
    The Comments owned by this element. Will be used as code comment for the variable.

Supported Stereotypes

  • functionPointer
    Generates an Attribute for a function pointer
  • define
    Generates a #define declaration for the Attribute applied to.
  • typedef
    Generate a typedef for the attribute applied to (use default value to redefine know types).
  • readonly
    Generates a readonly attribute.
  • extern
    Generates an external attribute.

Supported Tagged Values

  • FieldHeader
    Customize documentation header for attributes.
  • FunctionPointer
    Links operation typedef and functionPointer attribute together.
  • ReferenceImpl
    Customize reference type of a field or parameter. (used to switch between ‘*’ and ‘&’)

Operation

Operations will be used to generat functions inside the code/Class.

Supported UML Attributes/Associations

  • name
    The name of the element, will be used as function name. Ever function name will be prefixed with the parent class name, the only exceptions are function realizations from an interface.
  • type
    Can be a simple string or a typed element and specifies the return result of the operation, if present, if not “void” will be used.
  • ownedParameter
    Specifies the parameters owned by this Operation.
  • isQuery
    Specifies whether an execution of the BehavioralFeature leaves the state of the system unchanged or whether side effects may occur. Will generate a const modifier for the function declaration.
  • isStatic
    Will be associated with the “static” modifier for code generation.
  • visibility
    VisibilityKind will be mapped to generated language modifiers (e.g.: private, public,…)
  • ownedComment
    The Comments owned by this element. Will be used as code comment for the variable.
  • ownedElement
    The Elements owned by this element. Supported by the code generator are OpaqueBehavior and/or Behavior.

Supported Stereotypes

  • constructor
    Ignores the operation name and generates a class constructor.
  • destructor
    Ignores the operation name and generates a class destructor.
  • qsignal
    Generates Qt signal operation as an emitter when a particular event occurs.
  • qslot
    Generates Qt slot as an an operation that is called in response to a particular signal.
    Changes the modifier for the operation.
  • typedef
    Generates a type definition for a function pointer

Supported Tagged Values

  • inline
    Changes the modifier for the operation.
  • IsAbstract
    Changes the modifier for the operation.
  • IsPure
    Changes the modifier for the operation declaration.
  • IsConst
    Changes the modifier for the operation.
  • ClassifierBehavior
    Defines the behavior for the executable entry point.
  • Object Identifier
    Adds a “@covers [value]” to the method header documentation.

Activity

Activities will be interpreted by iterating along the path ot the control flow. Each Activity will generate a function in the Class.

Supported UML Attributes/Associations

  • name
    The name of the element. It will be used as function name. Ever function name will be prefixed with the parent class name.
  • ownedParameter
    Specifies the parameters owned by this Operation. (Use ParameterDirectionKind.Return to specify a return type)
  • ownedElement
    The Elements owned by this element. Refere to the: Supported Activity Elements List

Supported Stereotypes

  • static (applies to Activity)
    Generates a static function for an activity.
  • switchCase (applies to ConditionalNode)
    Changes the generation of an “if..elseif..” block to an “switch case” block.
  • forLoop (applies to LoopNode)
    Changes the generation of a “while …” loop to a “for …” loop

Supported Tagged Values

  • Increment (applies to LoopNode)
    Allows to set the incremental part of a for-loop.
  • Condition (applies to ConditionalNode)
    Allows to set the condition part of a switch case.

Supported Activity Elements

  • ActionInputPin
  • CallAction
  • CallBehaviorAction
  • CallOperationAction
  • InputPin
  • OpaqueAction
  • OutputPin
  • Pin
  • ReadVariableAction
  • SendSignalAction
  • ValueSpecificationAction
  • WriteVariableAction
  • Activity
  • ActivityEdge
  • ActivityFinalNode
  • ActivityNode
  • ActivityParameterNode
  • Behavior
  • Clause
  • ConditionalNode
  • ControlFlow
  • ControlNode
  • DecisionNode
  • ExecutableNode
  • ExpansionNode
  • ExpansionRegion
  • FinalNode
  • ForkNode
  • InitialNode
  • LoopNode
  • MergeNode
  • ObjectFlow
  • ObjectNode
  • StructuredActivityNode
  • OpaqueBehavior

State Machine

State machines are generated as switch/case constructs. For each state machine the following elements will be generated in the code:

  1. A state machine function ([ClassName]_[StatemachineName]) containing the main switch/case
  2. A state machine initalization function ([ClassName]_[StatemachineName]_init)
  3. A struct containing the instance of the state machine ([ClassName]_[StatemachineName]_STM)
  4. A struct containing the possible states of the state machine ([ClassName]_[StatemachineName]_States)
  5. If Signals are used a signal class and an include statement will be generated.

Supported State Machine Elements

  • name
    The name of the element. Will be used to prefix state machine code elements (see list above).
  • ownedElement
    The Elements owned by this element. Refere to the: Supported State Machine Elements List

Supported State Machine Elements

  • Behavior
  • Signal
  • SignalEvent
  • Trigger
  • FinalState
  • Pseudostate
  • PseudostateKind
  • Region
  • State
  • StateMachine
  • TimeEvent
  • Transition
  • TransitionKind
  • Vertex

Tagged Values

Tagged Value Description Applies to
GenSrcDir The directory where the code will be generated to. Packages
FileHeader Customize documentation file header. Package & Class
NoCodeGen Disables code generation for these packges/elements. Package & Class
MethodHeader Customize documentation header for operations. Package, Class & Operation
FieldHeader Customize documentation header for attributes. Package, Class & Attribute
Increment Allows to set the incremental part of a for-loop. Strutured Activity – LoopNode
Condition Allows to set the condition part of a switch case. Strutured Activity – Conditional Node
ReferenceImpl Customize reference type of a field or parameter. Attribute & Parameter
FunctionPointer Links operation typedef and functionPointer attribute together Attribute
ClassifierBehavior Defines the behavior for the executable entry point. Operation
Object Identifier Adds a “@covers [value]” to the method header documentation. Operation
inline Changes the modifier for the operation. Operation
IsAbstract Changes the modifier for the operation. Operation
IsPure Changes the modifier for the operation declaration. Operation
IsConst Changes the modifier for the operation. Operation
IncludeOrder Allows to order the Include lines defined by Usage connectors. Connector (using)
IncludePath Allows customization of the Include path (overrules “Generage Directory for Package” setting) Class
UsingNamespace Add custom “using namespace” to Usage connectors. Connector (using)
CustomExtension Allows the configuration of .hxx, .hpp, … includes of external libraries Connector (using)

Model Settings Tagged Values

These settings should be handled via the Embedded Engineer settings dialog and may differ between tools.

Tagged Value Description possible values default
CCodeGenerationEnabled Enable C-Code generation in the user interface Yes, No Yes
CppCodeGenerationEnabled Enable C++-Code generation in the user interface Yes, No Yes
UserCodeSyncEnabled Sync the user code blocks before generating code Yes, No Yes
StyleOptions Describes configurable formatting style options supported by ClangFormat. JSON style Clang-Format 4.0 style options
AlwaysGenerateSignals Always re-generate signals when generating code Yes, No No
GenerateIncludesInCFile Generates includes in .c instead of .h file Yes, No No
SignalsAndCodeMenuEntryEnabled Show the “Generate Signals and Code” menu entry in the extensions menu Yes, No Yes
AutoCloseProgressWindow Automatically close code generation progress window Yes, No No
StateMachineCodeGeneration Enable code generation for state machines True, False True
ActivityCodeGeneration Enable code generation for activities True, False True
UserCodeStore Field used to store, sync user code Behavior, InitialCode InitialCode
MisraComplianceEnabled Enable MISRA compliance features – may reduce readability of the generated code True, False True
GenerateDirectories Enables the generation of a sub directory for every sub package Yes, No No
IncludePathDelimiter Delimiter for include path resolving Any single character /
IncludeCommentsBefore Writes the include comment in the line before the include True, False False
FieldCommentPosition Choose the position for comments of a field. BeforeField, AfterField, AfterFieldIfSingleLine AfterFieldIfSingleLine
GenerateUmlDebuggingInfo Enables generation of UML Debugger information for use with the UML Debugger Yes, No Yes
GenerateRequirementComments Enables generation of requirement comments in the code for linked requirements Yes, No Yes

Stereotypes

Stereotype Description Applies to
executable entry point Generates an Entry Point to your application. Class
singleton Generates a singleton pattern for the class. Class
static Generates a static class. Class
static Generates a static function for an activity. Activity
struct Generates a structure as part of another class. Class
standard lib Generates a standard library include when linked with Usage connector. Class
enumeration Generates an enumeration using the class attributes. Class
qobject Generates all code needed to use QObject features. Class
signals Generates an enumeration to contain all state machine signals. Enumeration
qenum Generates an QEnum to use as attribute within an QObject class. Enumeration
requirement When realized or traced by a class, will generate a documentation link. Requirement
switchCase Changes the generation of an “if..elseif..” block to an “switch case” block ConditionalNode
forLoop Changes the generation of a “while …” loop to a “for …” loop LoopNode
constructor Ignores the operation name and generates a class constructor. Operation
destructor Ignores the operation name and generates a class destructor. Operation
qsignal Generates Qt signal operation as an emitter when a particular event occurs. Operation
qslot Generates Qt slot as an an operation that is called in response to a particular signal. Operation
typedef Generates a type definition for a function pointer Operation
functionPointer Generates an attribute for a function pointer Attribute
define Generates a #define declaration for the attribute applied to. Attribute
typedef Generate a typedef for the attribute applied to (use default value to redefine know types). Attribute
readonly Generates a readonly attribute. Attribute
extern Generates an external attribute. Attribute
global Generates global include declaration (with brackets). Connector
trace Generates a documentation link to the traced requirement. Connector