Generating AUTOSAR basic software with Xpand and Artop

AUTOSAR basic software can be configured by a lot of different parameters. Both for AUTOSAR standard modules and vendor specific basic software modules, the parameters that can be configured are defined in parameter definitions and the actual values are configured as parameter values.
In Artop, both reside in .arxml files in the workspace.

Note: The following code generation mechanism is also used in the COMASSO BCT configuration tool, altough the UI and some technical aspects are different.

The developer of a basic software module needs to develop a tool that transform a module configuration into something that can be used for the final software, often C-Code or other artefacts. For AUTOSAR code generation, we need two features in code generation:

  • A comfortable mechanism for code generation. Printing out code with print-Statements is cumbersome. State of the art code generators are template-based.
  • A powerful type system. We would like to see the modules and attributes that are defined in the parameter definitions as first-class citizens in our transformation language – this is a prerequisite for readable and maintainable code.

The first feature is provided by Xtend/Xpand out-of-the-box. Xpand is a template-based code-generator. It also comes with hooks for a flexible type-system, which Artop uses to provide the second feature: The .arxml parameter definitions in the workspace are dynamically scanned and the defined modules, attributes etc. are usable in template development without any compilation steps.

So to print out a list of CanIfInitConfigurations for a given CanIf, we can just have

2013-10-09_12h05_38This will brint the shortName of the CanIf and a list of all CanIfInitConfiguration’s shortNames. This will work for custom param defs as well.

2013-10-09_12h05_46Of course, a real generator will be more complex. Artop also brings a GUI integration. A dialog-box for choosing a generator template can be directly invoked from the user interface: