Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Category:Eclipse UML Generators/Specification/EmbeddedCGenerator/Contribution"

m (Usage specification)
m (Operation specification)
Line 323: Line 323:
 
==== Operation specification ====
 
==== Operation specification ====
  
TBW
+
The following requirements specify the model to text transformations for uml::Operation.
  
 
== Backward Compatibility and Migration Paths  ==
 
== Backward Compatibility and Migration Paths  ==

Revision as of 08:36, 7 April 2015

Evolution Specification: UML Generator for Embedded C

Current status is DRAFT

Preamble

The traditional text-based approach of embedded software design is not efficient enough to handle such advanced/complex systems. There is a need for modeling C components in order to avoid repetitive and heavy low level processes. As initial contribution to the Eclipse UML generators project, Spacebel proposes development methods and a ANSI C code generator for Embedded Software.

Relevant tickets:

  • Bug TBD - C code generator for Embedded Systems

Introduction

Major provider of IT systems on-board satellites and space vehicles, Spacebel cumulates more than one century of experience in On Board Software. The expertise encompasses the whole flight software development lifecycle, from the early concept studies, including the analysis and the specification over the architecture, the design and the development, to the validation and the final integration of these critical software systems.

When developing embedded systems, software designers are squeezed by two trends — shrinking development cycles and growing design intricacy. The divide-and-conquer strategy for developing these complex systems means coordinating the resources of people with expertise in a wide range of disciplines. Quickly, it appears that the text-based approach of embedded system design is not efficient to manage such complex systems. There is a need for modeling C components in order to avoid repetitive and heavy low level processes.

As indicated in the title, the feature is able to generate C code from UML models. What distinguishes Embedded C from regular C generator or text-based approach are:

  • repeatable and reliable generation of code
  • preservation of the implementation fields
  • highly documented detailed design
  • compliance to MISRA guidelines of C language in critical systems
  • traceability of the specification (requirements) in the sources

Modeling a complete embedded software written in C with UML is not straightforward. Indeed, the UML standard is sometimes too generic with a high level of abstraction. In order to mitigate the abstraction of UML, the generator comes up with an UML profile: the Embedded_C profile.

Detailed Specification

This chapter presents a detailed specification of the Generator UML to Embedded C. The following lines specify the functional & non-functional requirements that shall be implemented by the generator and the UML profile 'Embedded_C'.

Profile specification

UML is so generic and sometimes so abstract that it is really hard to map the C language in UML. In order to overcome this problem, the entities of the C language are described with the help of UML stereotypes. Indeed, the UML standard often needs extensions to specify entities that only exist in C.

Therefore, UML stereotypes constitute a nice way to extend the UML standard. A stereotype is defined either as an extension of a UML base meta-class or as a specialization of an existing stereotype. The extension relationship of UML is not an association but a kind of association directed from the stereotype to the extended meta-class. Consequently, the metadata conveyed by the associated the attributes of the stereotype are associated to the extended meta-class in a transparent manner for the meta-class itself. This allows profiles owning the stereotypes to be applied and removed dynamically without modifying the underlying models.

For the sake of simplicity, a minimum number of stereotypes have been defined.

REQ-PROF-001: The profile Embedded_C shall be identified under the ID 'org.eclipse.umlgen.gen.embedded.c.profile'.

REQ-PROF-002: The profile Embedded_C shall provide the following stereotypes:

  • Array
  • Asm
  • Attribute
  • Constant
  • Inline
  • Pointer
  • Requirement
  • Singleton
  • Object
  • Struct
  • Typedef
  • Union
  • UsesStaticMethods
  • Value
  • Volatile

REQ-PROF-003: The stereotype 'Array' shall be applicable for any uml::Property. It shall have the following attribute:

  • The ‘multiplicity’ of the array shall be specified. The type of the attribute shall be 'String' meaning that it can be an alphanumeric value.
Stereotype Array.JPEG


REQ-PROF-004: The stereotype 'Asm' shall be applicable for any uml::Operation.

Stereotype Asm.JPEG


REQ-PROF-005: The stereotype 'Attribute' shall be applicable for any uml::Property or uml::Datatype. It shall have the following attribute:

  • The 'attribute' of the property or datatype shall be specified (aligned, packed, ...).
Stereotype Attribute.JPEG


REQ-PROF-006: The stereotype 'Constant' shall be applicable for any uml::EnumerationLiteral of a given uml::Enumeration. It shall have the following attributes:

  • The ‘declaration’ of the constant shall be specified or leave empty. The type of the attribute is String meaning that it can be an alphanumeric value.
  • The ‘condition’ of the constant shall be specified or leave at ‘None’. In case ifndef or ifdef is selected, the definition of the constant will be conditional with respect to its name existence.
Stereotype Constant.JPEG


REQ-PROF-007: The stereotype 'Inline' shall be applicable for any uml::Operation.

  • The ‘condition’ of the inline operation shall be specified or leave at ‘None’. In case ifndef or ifdef is selected, the definition of the inline operation will be conditional with respect to a ‘value’.
  • The ‘value’ (of the condition) of the inline operation shall be specified or leave empty. The attribute ‘Value’ only takes effect when the attribute ‘condition’ is different than ‘None’ (e.g. condition = 'ifdef, value = 'DEBUGGING).
Stereotype Inline.JPEG


REQ-PROF-008: The stereotype 'Pointer' shall be applicable for any uml::TypedElement. It shall have the following attribute:

  • The pointer kind shall be specified. The pointer can be simple, double or none. The pointer may also be oriented constant data or constant pointer.
Stereotype Pointer.JPEG


REQ-PROF-009: The stereotype 'Requirement' shall be applicable for any uml::Constraint. It shall have the following attributes:

  • The attribute ‘parents’ shall make the traceability between requirement baseline and technical specification. The value of the ‘parents’ can be empty or it can be a list of requirement IDs.
  • It shall possible to specify how the requirement is verified (Review, Inspection, Test, Analysis). By default, the verification by test shall be selected.
Stereotype Requirement.JPEG


REQ-PROF-010: The stereotype 'Singleton' shall be applicable for any uml::Class.

Stereotype Singleton.JPEG


REQ-PROF-011: The stereotype 'Object' shall be applicable for any uml::Class.

Stereotype Object.JPEG


REQ-PROF-012: The stereotype 'Struct' shall be applicable for any uml::TypedElement.

Stereotype Struct.JPEG


REQ-PROF-013: The stereotype 'Typedef' shall be applicable for any uml::DataType or uml::Enumeration. It shall have the following attribute:

  • The attribute ‘MappedType’ shall be specified. The attribute must receive the existing type to which it is mapped.

In case of Enumeration, if the attribute ‘MappedType’ is specified, the default type of the Enumeration is redefined by an specified mapped type. Otherwise, the Enumeration itself is seen as a type.

Stereotype Typedef.JPEG


REQ-PROF-014: The stereotype 'Union' shall be applicable for any uml::DataType.

Stereotype Union.JPEG


REQ-PROF-015: The stereotype 'UsesStaticMethods' shall be applicable for any uml::Property.

Stereotype UsesStaticMethods.JPEG


REQ-PROF-016: The stereotype 'Value' shall be applicable for any uml::EnumerationLiteral. It shall have the following attribute:

  • The attribute ‘Value’ shall be specified. It specifies the value of the Enumeration Literal. It can be an alphanumeric value.
Stereotype Value.JPEG


REQ-PROF-017: The stereotype 'Volatile' shall be applicable for uml::Property.

Stereotype Volatile.JPEG


In addition to the stereotypes, the profile should also own the basic types of the C language.

REQ-PROF-018: The profile Embedded_C shall provide the primitive types of the C language:

  • char
  • signed char
  • unsigned char
  • int
  • signed int
  • unsigned int
  • short
  • signed short
  • unsigned short
  • long
  • signed long
  • unsigned long
  • long long
  • signed long long
  • unsigned long long
  • float
  • double
  • void
File-Primitive Types.JPEG

Generator specification

The Generator UML to Embedded C shall be an Acceleo based generator which shall be compliant to the UML2 meta-model (http://www.eclipse.org/uml2/5.0.0/UML). The following lines present the general specification of the feature and a detailed specification of the model to text transformations.

General specification

REQ-GEN-001: The Generator UML to Embedded C shall be identified under the ID 'org.eclipse.umlgen.gen.embedded.c'.

REQ-GEN-002: The feature Generator UML to Embedded C shall include the following plugins:

  • org.eclipse.umlgen.gen.embedded.c
  • org.eclipse.umlgen.gen.embedded.c.profile

REQ-GEN-003: The Generator UML to Embedded C shall be an implementation of the 'org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator'.

REQ-GEN-004: The generator shall generate ANSI C files from an UML model.

The model shall contain at least one uml::Package. Otherwise, nothing is generated.

REQ-GEN-005: The maximum size of a comment line shall be 120 semi-colomns.

REQ-GEN-006: The size of a tabulation shall be 4 spaces.

Package specification

The following requirements specify the model to text transformations for uml::Package.

REQ-PACK-001: A uml::Package shall take the representation of a directory in the file system. The name of the directory shall be the name of the uml::Package.

REQ-PACK-002: Besides the directory, a header and a source file shall be generated for each uml::Package. The name of the files shall be the name of the uml::Package.

REQ-PACK-003: The header file of an uml::Package shall contain the followings:

  • A configurable comment placed at the top of the file
  • The path of the file
  • The includes of parent uml::Package and dependencies (uml::Usage)
  • Comments documenting the uml::Package (with Doxygen tokens)
  • Definitions of macros or constants
  • Definitions of types

REQ-PACK-004: The source file of an uml::Package shall contain the followings:

  • A configurable comment placed at the top of the file
  • The path of the file
  • The includes of its own header and dependencies (uml::Usage)

Class specification

The following requirements specify the model to text transformations for uml::Class.

REQ-CLASS-001: The generator shall generate a source file plus a header file for any uml::Class. The name of both files shall be equal to the name of the uml::Class.

REQ-CLASS-002: The header file of an uml::Class shall contain at least the followings:

  • A configurable comment placed at the top of the file
  • The path of the file
  • The includes of parent uml::Package and dependencies (uml::Usage)
  • Comments documenting the uml::Class (with Doxygen tokens)
  • Definitions of macros or constants
  • Definitions of types
  • Declaration of global variables
  • Declaration of inline functions
  • Declaration of prototypes of public operations

REQ-CLASS-003: The source file of an uml::Class shall contain at least the followings:

  • A configurable comment placed at the top of the file
  • The path of the file
  • The includes of its own header and dependencies (uml::Usage)
  • Declaration of variables
  • Declaration of prototypes of private operations
  • Declaration of variables that use private operations
  • Declaration of functions (protected implementation field included)

REQ-CLASS-004: A uml::Class may have several representations. The generator shall manage the following extensions:

  • Object
  • Singleton

REQ-CLASS-005: In case of uml::Class stereotyped as 'Object', the properties of the given uml::Class shall be generated as variables.

The variables may be public (generated in the source file and external in the header file) or private (generated statically in the source file).

REQ-CLASS-006: In presence of uml::Class stereotyped as 'Singleton' or nothing, a structural definition of the uml::Class shall be generated where the fields of the structure are the properties of the given uml::Class.

The name of the C structure is the name of the uml::Class plus the string '_t'.

REQ-CLASS-007: In presence of a uml::Class stereotyped as 'Singleton', its structural definition shall be instantiated once as a static variable in the source file.

The name of the variable shall be equal to the name of the 'Singleton'.

Property specification

The following requirements specify the model to text transformations for uml::Property.

REQ-PROP-001: A uml::Property which has no type shall be generated as #define.

The default value of the uml::Property is the value of the #define.

REQ-PROP-002: A typped uml::Property marked as read-only shall be generated as constant ('const').

REQ-PROP-003: A uml::Property of an 'Object' class shall be generated as variables.

REQ-PROP-004: Private uml::Property of an 'Object' shall be generated as static variable in the source file.

REQ-PROP-005: Public uml::Property of an 'Object' shall be generated as extern variable in the header file.

REQ-PROP-006: The default value of the property of an 'Object' shall be generated as the initialisation of the variable.

REQ-PROP-007: In case a uml::Comment is applied to the uml::Property, Doxygen comments shall be generated.

REQ-PROP-008: In case the stereotype 'Array' is applied to a uml::Property, the uml::Property shall be generated as an Array with the specified multiplicity.

In case the uml::Multiplicity (upper bound) of the uml::Property is higher than 1 and no stereotype Array is applied on, the uml::Property shall also be generated as an Array with the specified upper value.

Enumeration specification

The following requirements specify the model to text transformations for uml::Enumeration.

REQ-ENUM-001: A uml::Enumeration shall be generated as 'typedef enum'. The name of the enumeration shall be equal to the name of the uml::Enumeration.

REQ-ENUM-002: In case the stereotype 'Typedef' is applied to a uml::Enumeration, the enumeration shall be generated as a simple 'enum'. Below the the 'enum' declaration, a 'typdef' shall specify the corresponding mapped type.

REQ-ENUM-003: Inside a uml::Enumeration, a uml::EnumerationLiteral stereotyped as 'Constant' shall be generated as #define.

The property 'Declaration' of the stereotype 'Constant' is the value of the #define. The stereotype 'Constant' specifies also #define conditions (#ifdef, #ifndef, #endif).

REQ-ENUM-004: In case a comment is applied to the the uml::Enumeration or literals, Doxygen comments shall be generated.

Datatype specification

The following requirements specify the model to text transformations for uml::Datatype.

REQ-DTYPE-001: A uml::Datatype shall be as 'typedef struct'. The id of the structure shall be the name of the uml::Datatype.

REQ-DTYPE-002: All the porperties of the uml::Datatype shall be generated as fields of the structure.

The properties are generated with their types, the multiplicity and the comment (properties may also be stereotyped as 'struct', 'Array', ...).

REQ-DTYPE-003: A uml::datatype stereotyped as 'union' shall be as 'typedef union'.

REQ-DTYPE-004: A uml::datatype stereotyped as typedef shall be generated as 'typedef'.

REQ-DTYPE-005: In case the 'mapped type' property of the stereotype 'typedef' contains the string '%s', the latter shall be replaced by the name of the uml::Datatype.

REQ-DTYPE-006: For each type (structure, typedef or union), corresponding Doxygen comment shall be generated.

Usage specification

The following requirements specify the model to text transformations for uml::Usage.

REQ-USE-001: Private uml::Usage shall be generated as #include in the source file.

REQ-USE-002: Public uml::Usage shall be generated as #include in the header file.

REQ-USE-003: A comment shall be generated to describe the object of the uml::Usage.

Operation specification

The following requirements specify the model to text transformations for uml::Operation.

Backward Compatibility and Migration Paths

Metamodel Changes

This evolution does not change any meta-models.

API Changes

This evolution does not change any API.

User Interface Changes

For consistency, the Embedded C generator should stick with the existing generation properties and menus (ref. User Interface Consistency).

New entries for Embedded C generator shall just be added to the existing infrastructure.

Documentation Changes

User manuals should integrate the user interfaces updates for both Embedded_C profile and the generator.

Tests and Non-regression strategy

In order to exercise the generator and to verify the above requirements, series of simple UML models will be defined as test cases. For each test case, the output file(s) of the generator will compared against expected files that match the specification.

Implementation choices and tradeoffs

Concerning the implementation choices, no particular choices have been done except the use of an UML profile combined with the Acceleo generator. The latter choice may be discussed.

The choice to develop an UML profile has been made after long analysis of what can really be done with only the UML standard. It quickly appeared that UML needs extensions to cope with C syntax and developers vacillated between various ways how it should be done. Other methodologies have been argued e.g. a full Ecore meta-model approach. However, the latter implies to re-develop all the features that already exist in UML (diagrams, editor, ...) in Sirius or whatever. In addition, the full Ecore meta-model approach would be a non-standard modeling framework unlike UML standard.

This profile also strays into maintenance issues. Indeed, if the profile needs modifications, the backward compatibility needs to be preserved. Nowadays, UML modeler like Papyrus now manages the evolution of the model against modification of the profile.

Finally and after experience, it appears that the use of a UML profile for Embedded C systems covers the needs in term of C syntax, entities or even the traceability of the specification.

This category currently contains no pages or media.

Back to the top