UML and SysML to C++ - Operation Specification

This section describes the UML and SysML to C++ operation.

This page discusses:

Glossary

Acronym Definition
SPO Software Production Operation
BL Behavior Layer
ML Middleware Layer
BSM Behavior-Specific Middleware
TSM Target-Specific Middleware

Referenced Documents

Document Internal Reference
Software Producer Model Specification [1]
UML and SysML - Component Model Generator Specification [2]
UML and SysML to C++ - Interface Code Generation Specifications [3]
UML and SysML to C++ - Activity Code Generator Specification [4]
UML and SysML to C++ - Constraint Code Generator Specification [5]
UML and SysML to C++ - Opaque Behavior Code Generator Specification [6]
UML and SysML to C++ - Statemachine Code Generator Specification [7]
C++ Code Architecture Specification [8]
Targeted Application Concepts [9]
UML and SysML To Code Concepts [10]
UML and SysML to C++ - Class Code Generator Specification [11]
UML and SysML to C++ - Assembly Code Generator Specification [12]

General Concepts

UML to C++ code operation is a code generation operation producing C++ code from UML entities.

UML entities belong to a design composed of multiple design patterns described as follows. See [10] for more information.

Components Layer Generation

This operation generates the code associated with the components layer. For more information on the components layer, see to [9].

Target layers

Note that a software producer model is generated with the code. The purpose of this mode is to describe the contract of the generated components and the connection between them. It mainly contains a description of:

  • Interface elements – data, types, operations
  • Connections,
  • Executable information.

See [1] for more information on the software producer model.

See [2] for more information on the model generation.

The generated code for a component is composed of:

  • A structure and implementation of UML classes - See [11]
  • A Classifier behavior and operations triggered by ExecutionTypes See XXX for more information on Execution Types
    • Statemachine - See [7],
    • Activity - See [4],
    • Opaque behavior - See [6],
  • A list of communication points – See [3],
    • SysML constraint blocks connected to these communication points. See [5].

The generated code for the communication and scheduling component specifies the communication between the components and schedules the behaviors triggered by Execution Types. – See [12]

It is generated from a composition of components or from a single component to expose its communication points.

UML to C++ code generation operation generates automatically all of these elements.

The generated code of behaviors must have a predictable behavior. To respect this constraint, the input behavior must respect design patterns. You are guided during the design phase by the validation constraints. The generator supports only a limited list of designed patterns. See the dedicated documents for more information.

The code generator produces a valid code. You can implement or customize some specific parts (for example, you can implement a state in a statemachine). These customized parts must respect the validation constraints.

Once the code is generated, you can modify identified parts of the generated code. These sections of code are identified by comments in the generated code as user code sections. User code sections can be used by other applications to perform a round-trip operation and replicate the modified code in the input model. Note also that user code sections can be protected from a generation to another to prevent code lost. For more information about user code sections, see [8].

Limitation

The case of ambiguous semantics will be clarified in the next iteration of the SysML Statemachine generator function.

A typical example is the order used to read and manage input signals, which impacts the way the statemachine behaves.

Input Elements

Not applicable

Validation Constraints

The code generated from a UML or SysML behavior is expected to have predictable behavior. For this, the input behavior must respect design patterns. The generators support only a limited list of designed patterns. These patterns are described in specific documents.

The validations constraints are described in the code generators specifications for each UML and SysML behavior. For more information, see the dedicated specification.

Code Generator Specification

Software Production Operation Identity Card

Characteristics Values
Name UML to C++
Nature Component generation
Description This operation generates C++ code for: - UML classes - SysML Blocks - Instance Specifications
Scan description The scan lists SysML blocks, UML classes, and UML packages.
Supported files files with .mdzip and .mdxml extension.
Input objects - SysML block - UML class - UML package - Instance Specifications
Return codes -1 : Generation is KO 0 : Generation is OK 1: Input data are incorrect 2: Model contains errors. Code generation cannot be executed.
Feature Generation - 50 credits per selected class

Parameters

code_deployment_id Parameter

Attributes Values
Name code_deployment_id
Description Mandatory parameter to specify the code deployment identifier to be used in the generated
Type String
Multiplicity 1

report_name Parameter

Attributes Values
Name report_name
Description Optional parameter specifying the name of the validation report. It is possible to use specific options for the name of the report as following: - %time% to be replaced by the UTC date in ISO-8601 format of the validation. Example: 2022-08-31T09:39:45.856814300Z - %input_file_name% to be replaced by the input file name without its extension. Hidden in CATIA Magic.
Type String
Values [Default] %input_file_name%
Multiplicity 0..1

dry_run Parameter

Attributes Values
Name dry_run
Description This parameter is optional. It describes if the generation is executed in dry mode to obtain the log and validation report without producing an ESP assembly model. Hidden in CATIA Magic. Note: This option does not consume any credits.
Type Boolean
Values [Default] Yes / [No]
Multiplicity 0..1

Validate Parameter

Attributes Values
Name Validate
Description Optional parameter to specify if the validation is executed or not. If the validation is not executed, then no check is performed.
Type Boolean
Values [Default] [Yes] / No
Multiplicity 0..1

report_html Parameter

Attributes Values
Name report_html
Description Optional parameter to specify if the validation report is generated in HTML. Only possible if the validation parameter is true. Hidden in CATIA Magic.
Type Boolean
Values [Default] Yes / [No]
Multiplicity 0..1

Implementation Generation Parameter

Attributes Values
Name Implementation Generation
Description Optional parameter to specify the type of generation. The Structure and Behavior Generation option includes behaviors described in the design. The Structure Only Generation option generates code with empty functions. The Headers Only Generation option produces only header files.
Type Enum
Values [Default] [full_implementation], empty_implementation, headers_only
Multiplicity 0..1

Instrumented Code Parameter

Attributes Values
Name Instrumented Code
Description Optional parameter to specify if extra instrumented code is generated. Instrumented code consists of additional variables to monitor the behavior of activities and statemachines.
Type Boolean
Values [Default] [false], true
Multiplicity 0..1

output Parameter

Attributes Values
Name output
Description Optional parameter that specifies the output directory in which resources are stored. If null, the generator generates a UML_to_Cpp folder. Hidden in CATIA Magic.
Type String
Values [Default] N/A
Multiplicity 0..1

Central Pool Size parameter

Attributes Values
Name Central Pool Size
Description Optional parameter to specify the central pool size to be applied. Default value is 512.
Type Positive Integer
Values [Default] [512]
Multiplicity 0..1

Default Pool Size Parameter

Attributes Values
Name Default Pool Size
Description Optional parameter specifying the default pool size to apply to all event pools without any specific size is configured. Default value is 128.
Type Positive Integer
Values [Default] [128]
Multiplicity 0..

Tick Frequency Parameter

Attributes Values
Name Tick Frequency
Description Optional parameter to specify the tick frequency used in the generated code. Default value is 1000 corresponding to 1000 Hz.
Type Positive Integer
Values [Default] [1000]
Multiplicity 0..1

Compiler Parameter

Attributes Values
Name Compiler
Description Optional parameter specifying the C++ compiler to be used to compile the generated code.
Type Enumeration
Values [Default] [none], gcc
Multiplicity 0..1

Misra Violation Comment Parameter

Attributes Values
Name Misra Violation Comment
Description If set to true, adds a comment in the generated code with the violated MISRA rule ID. By default, it is set to false.
Type Boolean
Values [Default] false
Multiplicity 0..1

Misra Ignore Parameter

Attributes Values
Name Misra Ignore
Description This option ignores the MISRA violation inherited from the code generator. It avoids raising these known MISRA violations in the tool report. Violations related to user code are still sent. CppCheck premium is currently supported.
Type String
Values [Default] [none], ignore_cppcheck
Multiplicity 0..1

Cpp Version Parameter

Attributes Values
Name Cpp Version
Description Optional parameter specifying which C++ version the generated code is compliant with.
Type Enumeration
Values [Default] [c++11], c++14, c++17, c++20
Multiplicity 0..1

Derive Instance Graph Parameter

Attributes Values
Name Derive Instance Graph
Description Optional parameter to specify if an instance graph shall be derived from the design and included in the generation output.
Type boolean
Values [Default] [true] / false
Multiplicity 0..1

Files Specification

The code generator generates C++ code compliant with standard c++11, c++14, c++17, c++20

Any character of the block name or the class name which is different of a digit, an ASCII letter, a - or a _, is replaced by an _ in the generated folder / file.

The file name of each behavior is composed with the parent names and its name separated by underscore.

MyBlock_ClassifierBehavior_SubBehavior.cpp/.h

Example 1 of a sub behavior file name called by the classifier behavior

MyBlock_ClassifierBehavior_SubBehavior_SubSubBehavior.cpp/.h

Example 2 of a sub-sub-behavior file name called by a sub behavior called itself by the classifier behavior

The operation must support the file header customization as defined in [10].

Depending on the behavior type, code generation is described in dedicated specification documents. For each behavior type, the name of the generated files is composed of a variable part and a fixed one. The variable part is identified in the specification documents as following: <Behavior> and must be replaced with the parent names as described above.