PAGe_UserManuals


User Guide PAGe
Project
BMW AUTOSAR Core 4 Rel. 3 and adaptive BMW AUTOSAR Core Rel. 1
Author
BMW AG
Release Date
2017-11-09
Version
1.1.0
Status
Release
Hotline
+49 89 382 - 32233 (classic) / +49 89 382 - 22522 (adaptive)
Contact
bac@bmw.de (classic) / abac@bmw.de (adaptive)
https://asc.bmw.com/jira/browse/BSUP (extern)
https://asc.bmwgroup.net/jira/browse/BSUP (intern)
Revision History
Version
Date
Changed by
Description
1.1.0
2017-11-09
JC-42
Initial Documentation Release
Company
Bayerische
Motoren Werke
Aktiengesellschaft
Postal address
BMW AG
80788 München
Office address
Forschungs- und
Innovationszentrum
(FIZ)
Hufelandstr. 1
80937 München
Telephone
Switchboard
+49 89 382-0
Internet
www.bmwgroup.com
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 1 of 22


Table of Contents
1 Overview
3
1.1
Purpose
3
1.2
Usage
3
1.2.1
Generation
3
1.2.2
Validation
3
1.2.3
verb
3
2 Acronyms and Abbreviations
4
3 Functionality
5
3.1
Command Line Usage
5
3.2
Fileformat
5
3.3
Available Function and Objects
6
3.4
Handling of paramconf
7
3.5
Notes ARXML shortcuts
7
3.6
Loops
7
4 Examples
8
4.1
Basic Navigation
8
4.1.1
ARXML Files
8
4.1.1.1
input.arxml
8
4.1.2
pgen Files
9
4.1.2.1
input.pgen
9
4.1.3
Command line
10
4.1.4
Console Output
10
4.1.5
File Output
10
4.2
Logging
11
4.2.1
pgen Files
11
4.2.1.1
input.pgen
11
4.2.2
Command line
11
4.2.3
Console Output
11
4.2.4
File Output
11
4.3
Usage of Code Blocks
11
4.3.1
pgen Files
12
4.3.1.1
input.pgen
12
4.3.2
Command line
12
4.3.3
Console Output
12
4.3.4
File Output
12
4.4
Conditionals
13
4.4.1
ARXML Files
13
4.4.1.1
input.arxml
13
4.4.2
pgen Files
14
4.4.2.1
input.pgen
14
4.4.3
Command line
14
4.4.4
Console Output
15
4.4.5
File Output
15
4.5
More Functions
15
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 2 of 22


4.5.1
ARXML Files
15
4.5.1.1
input.arxml
15
4.5.2
pgen Files
17
4.5.2.1
input.pgen
17
4.5.3
Command line
17
4.5.4
Console Output
17
4.5.5
File Output
17
4.6
ARXML Stuff
17
4.6.1
ARXML Files
18
4.6.1.1
input.arxml
18
4.6.2
pgen Files
19
4.6.2.1
input.pgen
19
4.6.3
Command line
19
4.6.4
Console Output
19
4.6.5
File Output
20
4.7
Filtering Elements
20
4.7.1
ARXML Files
20
4.7.1.1
input.arxml
20
4.7.2
pgen Files
21
4.7.2.1
input.pgen
21
4.7.3
Command line
21
4.7.4
Console Output
21
4.7.5
File Output
22
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 3 of 22


1
Overview
Purpose
This user guide describes the functionality and usage of the Python AUTOSAR Generator (PAGe).
PAGe is a generator for text templates which has some knowledge of the AUTOSAR Meta Model
regarding parameter configuration. It allows easy access of modules, containers and values as well as
providing loops and verify a paramconf against a paramdef. These options are also available for postbuild.
PAGe is based on Python 3. It uses only modules of the standard library.
PAGe is designed for the usage with the BMW AUTOSAR Core modules.
Input files must have the ending .pgen which is removed from the output filename.
Usage
Generation
To generate a pgen file.
python3 -m page example.pgen
If arxmls should be used pass them to the commandline as well.
python3 -m page -o /tmp example.pgen input.arxml
Also multiple pgen files and arxml files work.
python3 -m page -o /tmp example1.pgen example2.pgen input.arxml input_new.arxml
Validation
In case you want to check a paramconf against its corresponding paramdef you can use the following
commandline
python3 -m page paramconf.arxml paramdef.arxml
The validation will be performed for all the variants if an ecuc configuration is provided, too.
python3 -m page paramconf.arxml paramdef.arxml ecuc.arxml
verb
To enable a more verbose output add -v to -vvvv to the command line.
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 4 of 22


2
Acronyms and Abbreviations
API
Application Programming Interface
Application Application stands for the high-level part of software that uses the APIs
provided by the modules. It can also mean the driving application that does
not belong to the Bootloader.
AUTOSAR Automotive Open System Architecture
OS
Operating System
PAGe
Python AUTOSAR Generator
pgen
Page generation file
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 5 of 22


3
Functionality
PAGe builds a model of the provided ARXML paramconf and paramdefs. Within the pgen files you have
access to this model and can navigate and retrieve values easily. Besides the access to the data you have
the full power of python.
Command Line Usage
Either you install page or you add the main directory to the source path. Installation can be achieved by
python3 setup.py install
after that the page command will be available. So you can call PAGe using:
page input.pgen test.arxml -vvvv
But you may want to do install page only in a virtualenv so it does not harm any other installation.
-o Specify the output directory, default is the current directory.
--stdout do not write files, print output to stdout instead.
-vvv change level of verbosity.
-l Location to write the logfile to. Default is stdout.
-m Specify delimiter to be used in pgen files. This allows you to specify other delimiters than the default
e.g. you have files, where the defaults have a special meaning and you don't like to escape the every
time used.
-d Enable debug mode (trap functions become active)
-V Verifies given paramconf against the paramdefs which ara supplied.
-i Add paths for the search of includes.
-D Pass variables to the pgen files (params dictionary)
-O Change the optimisedb. This database stores the hash and the filename, so file with no change will
not be overwritten.
-f Forces write of files, even if no output change has been detected.
Fileformat
The pgen files shall be utf-8 encoded files. The files shall use unix file endings, windows file endings \r\n
are transformed to \n.
A file consists of text and several blocks that are interpreted by PAGe. These blocks are enclosed by a
special sequence of characters. %{ marks the beginning of a block and }% marks the end. The first
character occuring directly after the opening tag has a special meaning an defines the type of the block.
The following distinct blocks are supported:
The result of the statement within the tags are printed as output. A single statement shall be used but
can contain newline and indentiation. The result of the statement will appear in the output file.
This marker indicates a section of code. The code can consist of any valid piece of python code and is
also able to use the access functions for the data of the ARXMLs. It can be indentiated and consist
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 6 of 22


of multiple lines. For indentiation the first line is taken for reference, the rest of the indentiation has
to follow Pythons rules.
For conditions the colon is used as a marker. It occurs at least two times, one for the condition and one
time (without extra text) for the closure. This is needed for the correct handling. You still have to use
if, elif and else keywords.
For quick conditionals you can use a question mark. It works also directly as output. The condition
followed by a colon which seperates it from the part which is written in case of success. And an
optional second colon to seperate the ouput in the case the condition is not fullfilled.
This one loops over a statement. You can loop over a number of container instances, or any other
python iterateable. To iterate over a python iterateable use the syntax myitem in mycontainer which
makes the current item available as myitem. For loop over arxml elements, please have a look at ??
Use the plus sign for including other pgen or python files. These files are included and interpreted at
the current point within the file which they are included. A file can be included several times. Pure
python files can be included, too. By default the current path of the currently leaded source files (or
included files) is used as search directory. You can add directories using the command line switch -i
This mark is for special handling of post build variation. It loops over the configured pre defined variants
that are configured for the ecu. Within the context of this mark, you have two special variables
available: predefined_variant_name which is the name of the current variant or None if no
variantation is configured. And predefined_variant_postfix which contains an underscore
followed by the variant name or an empty string else. This can be used to build the name of the
configuration according to ECUConfiguration.
Available Function and Objects
The following functions are provided as part of PAGe:
comment Format a given string as a comment in the current context. If no delimiter are given, the
functions calls the automatic delimiter resolution. The string is splitted into single lines and enclosed
in the delimiter
set_comment_delimiter Set the comment markers
count Count elements found by shortname/search expression.
current_file Get the current filename of the file processed (pgen file).
current_shortname Get the AUTOSAR shortname of the current scope.
current_shortname_path Get the AUTOSAR shortname path.
each Get unique shortname paths of the elements that match the given search expression.
exists Checks existence of elements specified by search expression or shortname in current context.
generation_file_fullpath Full path of the source file.
generation_file_modification Date of modification of the source file.
generation_info Info about the generation as dict.
generation_timestamp Timestamp of generation.
generation_tool name of the generation tool.
generation_version_info Version of Generator.
get_elements Get list of elements matching search expression.
get_xpaths Deprecated for get_elements.
into Change context to given target, resets if target is None. The scope is held in a stack
join Join a set of values referenced by the search expression.
leave Leave the current scope.
reset Resets the context to the root node.
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 7 of 22


set_debug Enable pdb debugging.
shortname Get the shortname at the given shortname path expression,
trap Traps if debugging is enabled.
value Fetching the value or value-ref of a search expression. Values are automatically casted to the
correct type.
write Write arguments to the output.
container Selects containers that refere to a given definition ref.
module Selects modules that refere to a given definition ref.
ref Get the elements in the model, which refere to the given shortnamepath as definition ref.
snpath Get the element at the given shortname path.
Additionally to the functions and objects there is a dictionary called params which contains parameters
passed to page by the command line (-D test=hello).
Handling of paramconf
In general when using the data of a paramconf you should never enter a specific path you expect to be in
the configuration. You should only use paths you define in the parameter definition or that are contained
in the configuration as value (value refs).
Notes ARXML shortcuts
The shortnamepaths snpath are looked up in the following order:
return element
.. return parent
contains * Search children
startwith / lookup full path from root node
else lookup relative path
This means, whenever you want to get a grandchild of the current scope you need to prepend a star to
the node you are looking for or use the search.
Loops
In case you loop over VALUE or VALUE-REF elements, you can access its value using value() without a
target specified.
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 8 of 22


4
Examples
Basic Navigation
This example will demonstrate basic navigation through an ARXML document.
The example contains a module named MyModule which is of type TestModule and located in the
package /TestPackage/TestModule
It will demonstrate the following commands:
into
reset
ref
module
current_shortname_path
with
ARXML Files
input.arxml
<?xml version=’1.0’?>
<AUTOSAR xmlns="http://autosar.org/schema/r4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://autosar.org/schema/r4.0 autosar.xsd">
<AR-PACKAGES>
<AR-PACKAGE>
<SHORT-NAME>TestPackage</SHORT-NAME>
<AR-PACKAGES>
<AR-PACKAGE>
<SHORT-NAME>TestModule</SHORT-NAME>
<ELEMENTS>
<ECUC-MODULE-CONFIGURATION-VALUES>
<SHORT-NAME>MyModule</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-MODULE-DEF">/BMW_DEF/TestModule</DEFINITION-REF>
<CONTAINERS>
<ECUC-CONTAINER-VALUE>
<SHORT-NAME>NumericalValues</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/BMW_DEF/TestModule/
NumericalValues</DEFINITION-REF>
<PARAMETER-VALUES>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-INTEGER-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueInt</DEFINITION-REF>
<VALUE>5</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-INTEGER-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueInt</DEFINITION-REF>
<VALUE>8</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
<ECUC-NUMERICAL-PARAM-VALUE>
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 9 of 22


<DEFINITION-REF DEST="ECUC-FLOAT-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueFloat</DEFINITION-REF>
<VALUE>3.1415</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
</PARAMETER-VALUES>
</ECUC-CONTAINER-VALUE>
</CONTAINERS>
</ECUC-MODULE-CONFIGURATION-VALUES>
<ECUC-MODULE-CONFIGURATION-VALUES>
<SHORT-NAME>NotMyModule</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-MODULE-DEF">/BMW_DEF/AnotherTestModule</DEFINITION-
REF>
<CONTAINERS>
<ECUC-CONTAINER-VALUE>
<SHORT-NAME>StringValues</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/BMW_DEF/
AnotherTestModule/StringValues</DEFINITION-REF>
<PARAMETER-VALUES>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-STRING-PARAM-DEF">/BMW_DEF/
AnotherTestModule/StringValues/ValueString</DEFINITION-REF>
<VALUE>Hello World the value is: </VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
</PARAMETER-VALUES>
</ECUC-CONTAINER-VALUE>
</CONTAINERS>
</ECUC-MODULE-CONFIGURATION-VALUES>
</ELEMENTS>
</AR-PACKAGE>
</AR-PACKAGES>
</AR-PACKAGE>
</AR-PACKAGES>
</AUTOSAR>
pgen Files
input.pgen
%{# i n t o ( r e f ( ' TestModule ' ) ) }%
%{= current_shortname_path ( ) }%
This w i l l change i n t o the ∗FIRST∗ element found
%{# i n t o ( r e f ( ' V a l u e I n t ' ) ) }%
The shortname w i l l be taken from the p a r e n t element ,
as t h i s element i s not an i d e n t i f y a b l e .
%{= current_shortname_path ( ) }%
%{= v a l u e ( ) }%
%{# l e a v e ( ) }%
I f you expect more than one use a loop
For the loop the c o n t e x t i s a u t o m a t i c a l l y changed
%{@ r e f ( ' V a l u e I n t ' ) }%
%{= v a l u e ( ) }%
%{@}%
%{# i n t o ( r e f ( ' V a l u e F l o a t ' ) ) }%
%{= current_shortname_path ( ) }%
%{= v a l u e ( ) }%
%{# r e s e t ( ) }%
%{= current_shortname_path ( ) }%
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 10 of 22


%{# i n t o ( r e f ( ' TestModule ' ) ) }%
%{= current_shortname_path ( ) }%
%{# i n t o ( ) }%
%{= current_shortname_path ( ) }%
For a s h o r t i n t e r a c t i o n w i t h a c e r t a i n element w i t h i n a code block ,
you can a l s o use the w i t h statement o f python
%{#
w i t h module ( ' TestModule ' ) :
i n p u t = v a l u e ( r e f ( ' V a l u e F l o a t ' ) )
i n p u t = i n p u t ∗ 2
w i t h module ( ' AnotherTestModule ' ) :
s t r i n g = v a l u e ( r e f ( ' V a l u e S t r i n g ' ) )
}%
%{= ' { } { } ' . format ( s t r i n g , i n p u t ) }%
Command line
page −vvvv i n p u t . a r x m l i n p u t . pgen
Console Output
BMW PAGe
: INFO
Reading XML : i n p u t . a r x m l
BMW PAGe
: INFO
Reading XML took : 0.000859 s
BMW PAGe
: INFO
Reading a l l XMLs took : 0.00104 s
BMW PAGe
: INFO
processing Pgen : i n p u t . pgen
BMW PAGe
: INFO
Open f i l e / 0 0 1 / i n p u t . pgen
BMW PAGe
: INFO
Processing Pgen took : 0.00317 s
BMW PAGe
: INFO
F i l e does not e x i s t
BMW PAGe
: INFO
Wr ite / 0 0 1 / i n p u t
File Output
/ TestPackage / TestModule / MyModule
This w i l l change i n t o the ∗FIRST∗ element found
The shortname w i l l be taken from the p a r e n t element ,
as t h i s element i s not an i d e n t i f y a b l e .
/ TestPackage / TestModule / MyModule / NumericalValues
5
I f you expect more than one use a loop
For the loop the c o n t e x t i s a u t o m a t i c a l l y changed
5
8
/ TestPackage / TestModule / MyModule / NumericalValues
3.1415
ROOT
/ TestPackage / TestModule / MyModule
ROOT
For a s h o r t i n t e r a c t i o n w i t h a c e r t a i n element w i t h i n a code block ,
you can a l s o use the w i t h statement o f python
H e l l o World the v a l u e i s :
6.283
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 11 of 22


Logging
This example will demonstrate the logging functionality.
There are several log levels that depend on the -vs provided on the command line.
It will demonstrate the following commands:
logger.debug
logger.info
logger.warning
logger.error
logger.fatal
pgen Files
input.pgen
Logging o f some i n f o r m a t i o n
%{# l o g g e r . debug ( ' This i s a message f o r debugging so you have to s p e c i f y a few v on the command l i n e ' ) }%
%{# l o g g e r . i n f o ( ' This t e x t w i l l appear i n the INFO log ' ) }%
%{# l o g g e r . warning ( ' You ' ' ve been warned ')}%
%{# l o g g e r . e r r o r ( ' This w i l l not work , ok I \ ' l l l e t you continue ')}%
%{# l o g g e r . f a t a l ( ' Oh noooo ! ' ) } %
Command line
page −vvvv i n p u t . pgen
Console Output
BMW PAGe
: INFO
processing Pgen : i n p u t . pgen
BMW PAGe
: INFO
Open f i l e / 0 0 2 / i n p u t . pgen
BMW PAGe
: DEBUG
This i s a message f o r debugging so you have to s p e c i f y a few v on the command l i n e
BMW PAGe
: INFO
This t e x t w i l l appear i n the INFO l o g
BMW PAGe
: WARNING
Youve been warned
BMW PAGe
: ERROR
This w i l l not work , ok I ' l l l e t you continue
BMW PAGe
: CRITICAL Oh noooo !
BMW PAGe
: INFO
Processing Pgen took : 0.00185 s
BMW PAGe
: INFO
F i l e does not e x i s t
BMW PAGe
: INFO
Wr ite / 0 0 2 / i n p u t
File Output
Logging o f some i n f o r m a t i o n
Usage of Code Blocks
This example will show a few details about the code block
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 12 of 22


The code block is one of PAGes super power. It allows to use any python code from within it. You can still
use PAGes functions but also any other python statement you could think of.
It will demonstrate the following commands:
write
CodeBlock
pgen Files
input.pgen
Usage o f Code Blocks
Besides the output blocks you can use code blocks :
%{#
# The f i r s t l i n e d e f i n e s the b a s i c i n d e n t i a t i o n .
# a l l l i n e s are i n t e r p r e t e d as pure python .
def MyFunction ( a , b ) :
r e t u r n ( a+b ) ∗ b
}%
A l l v a r i a b l e s , f u n c t i o n s , ect . w i l l remain u n t i l the end o f the pgen f i l e .
You can now see the r e s u l t o f the p r e v i o u s f u n c t i o n : %{= MyFunction ( 3 , 5 ) }%
I f you want to w r i t e to the output from w i t h i n a code block , you should use the ∗ w r i t e ∗ command
%{#
f o r x i n range ( 1 , 1 5 ) :
i f ' 3 ' i n s t r ( x ) or x % 3 == 0 :
w r i t e ( ' buzz \ n ' )
e l s e :
w r i t e ( ' { } \ n ' . format ( x ) )
}%
NB : w r i t e does not a u t o m a t i c a l l y add a newline .
Command line
page −vvvv i n p u t . pgen
Console Output
BMW PAGe
: INFO
processing Pgen : i n p u t . pgen
BMW PAGe
: INFO
Open f i l e / 0 0 3 / i n p u t . pgen
BMW PAGe
: INFO
Processing Pgen took : 0.00171 s
BMW PAGe
: INFO
F i l e does not e x i s t
BMW PAGe
: INFO
Wr ite / 0 0 3 / i n p u t
File Output
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 13 of 22


Usage o f Code Blocks
Besides the output blocks you can use code blocks :
A l l v a r i a b l e s , f u n c t i o n s , ect . w i l l remain u n t i l the end o f the pgen f i l e .
You can now see the r e s u l t o f the p r e v i o u s f u n c t i o n : 40
I f you want to w r i t e to the output from w i t h i n a code block , you should use the ∗ w r i t e ∗ command
1
2
buzz
4
5
buzz
7
8
buzz
10
11
buzz
buzz
14
NB : w r i t e does not a u t o m a t i c a l l y add a newline .
Conditionals
This example will show the usage of conditional parts within a pgen file
The example contains a module named MyModule which is of type TestModule and located in the
package /TestPackage/TestModule
It will demonstrate the following commands:
if
elif
else
ShortIfBlock
ConditionalBlock
value
ARXML Files
input.arxml
<?xml version=’1.0’?>
<AUTOSAR xmlns="http://autosar.org/schema/r4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 14 of 22


xsi:schemaLocation="http://autosar.org/schema/r4.0 autosar.xsd">
<AR-PACKAGES>
<AR-PACKAGE>
<SHORT-NAME>TestPackage</SHORT-NAME>
<ELEMENTS>
<ECUC-MODULE-CONFIGURATION-VALUES>
<SHORT-NAME>MyModule</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-MODULE-DEF">/BMW_DEF/TestModule</DEFINITION-REF>
<CONTAINERS>
<ECUC-CONTAINER-VALUE>
<SHORT-NAME>NumericalValues</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/BMW_DEF/TestModule/
NumericalValues</DEFINITION-REF>
<PARAMETER-VALUES>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-INTEGER-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueInt</DEFINITION-REF>
<VALUE>5</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
</PARAMETER-VALUES>
</ECUC-CONTAINER-VALUE>
</CONTAINERS>
</ECUC-MODULE-CONFIGURATION-VALUES>
</ELEMENTS>
</AR-PACKAGE>
</AR-PACKAGES>
</AUTOSAR>
pgen Files
input.pgen
C o n d i t i o n a l s can be done as seen here :
%{: i f v a l u e ( r e f ( ' V a l u e I n t ' ) ) < 6 }%
Test
%{: e l i f e x i s t s ( r e f ( ' V a l u e F l o a t ' ) ) }%
This w i l l not occur i n the output
%{: e l s e }%
This won ' t appear
%{:}%
Want some s h o r t e r i f ?
These w r i t e the t e x t provided dependent on the r e s u l t o f the statement e v a l u a t i o n
# Both o p t i o n s provided
True :
%{? True : For sure ! : Nooooo!}%
False : %{? False : For sure ! : Nooooo!}%
# No i s not an o p t i o n
True :
%{? True : For sure !}%
False : %{? False : For sure !}%
# Only output something i f the r e s u l t i s f a l s e
True :
%{? True : : NO! ! ! ! } %
False : %{? False : : NO! ! ! ! } %
Command line
page −vvvv i n p u t . a r x m l i n p u t . pgen
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 15 of 22


Console Output
BMW PAGe
: INFO
Reading XML : i n p u t . a r x m l
BMW PAGe
: INFO
Reading XML took : 0.000677 s
BMW PAGe
: INFO
Reading a l l XMLs took : 0.000871 s
BMW PAGe
: INFO
processing Pgen : i n p u t . pgen
BMW PAGe
: INFO
Open f i l e / 0 0 4 / i n p u t . pgen
BMW PAGe
: INFO
Processing Pgen took : 0.00211 s
BMW PAGe
: INFO
F i l e does not e x i s t
BMW PAGe
: INFO
Wr ite / 0 0 4 / i n p u t
File Output
C o n d i t i o n a l s can be done as seen here :
Test
Want some s h o r t e r i f ?
These w r i t e the t e x t provided dependent on the r e s u l t o f the statement e v a l u a t i o n
# Both o p t i o n s provided
True :
For sure !
False : Nooooo !
# No i s not an o p t i o n
True :
For sure !
False :
# Only output something i f the r e s u l t i s f a l s e
True :
False : NO ! ! ! !
More Functions
This example will contain usages of different functions.
The example contains a module named MyModule which is of type TestModule and located in the
package /TestPackage/TestModule
It will demonstrate the following commands:
count
current_shortname
exists
with
ARXML Files
input.arxml
<?xml version=’1.0’?>
<AUTOSAR xmlns="http://autosar.org/schema/r4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://autosar.org/schema/r4.0 autosar.xsd">
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 16 of 22


<AR-PACKAGES>
<AR-PACKAGE>
<SHORT-NAME>TestPackage</SHORT-NAME>
<AR-PACKAGES>
<AR-PACKAGE>
<SHORT-NAME>TestModule</SHORT-NAME>
<ELEMENTS>
<ECUC-MODULE-CONFIGURATION-VALUES>
<SHORT-NAME>MyModule</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-MODULE-DEF">/BMW_DEF/TestModule</DEFINITION-REF>
<CONTAINERS>
<ECUC-CONTAINER-VALUE>
<SHORT-NAME>NumericalValues</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/BMW_DEF/TestModule/
NumericalValues</DEFINITION-REF>
<PARAMETER-VALUES>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-INTEGER-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueInt</DEFINITION-REF>
<VALUE>5</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-INTEGER-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueInt</DEFINITION-REF>
<VALUE>8</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-FLOAT-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueFloat</DEFINITION-REF>
<VALUE>3.1415</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
</PARAMETER-VALUES>
</ECUC-CONTAINER-VALUE>
</CONTAINERS>
</ECUC-MODULE-CONFIGURATION-VALUES>
<ECUC-MODULE-CONFIGURATION-VALUES>
<SHORT-NAME>NotMyModule</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-MODULE-DEF">/BMW_DEF/AnotherTestModule</DEFINITION-
REF>
<CONTAINERS>
<ECUC-CONTAINER-VALUE>
<SHORT-NAME>StringValues</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/BMW_DEF/
AnotherTestModule/StringValues</DEFINITION-REF>
<PARAMETER-VALUES>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-STRING-PARAM-DEF">/BMW_DEF/
AnotherTestModule/StringValues/ValueString</DEFINITION-REF>
<VALUE>Hello World the value is: </VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
</PARAMETER-VALUES>
</ECUC-CONTAINER-VALUE>
</CONTAINERS>
</ECUC-MODULE-CONFIGURATION-VALUES>
</ELEMENTS>
</AR-PACKAGE>
</AR-PACKAGES>
</AR-PACKAGE>
</AR-PACKAGES>
</AUTOSAR>
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 17 of 22


pgen Files
input.pgen
%{# i n t o ( r e f ( ' TestModule ' ) ) }%
%{= current_shortname_path ( ) }%
We can a l s o check the number o f elements :
There are %{= count ( r e f ( ' V a l u e I n t ' ) ) }% V a l u e I n t elements .
There e x i s t s a t l e a s t one V a l u e F l o a t : %{= e x i s t s ( r e f ( ' V a l u e F l o a t ' ) ) }%.
You can use the p r e v i o u s o p t i o n s a l s o as an asignment statement :
%{# pre viou s_sn = current_shortname ( ) }%
%{# l e a v e ()}%
and use i t l a t e r
%{= pr evio us_s n }%
Command line
page −vvvv i n p u t . a r x m l i n p u t . pgen
Console Output
BMW PAGe
: INFO
Reading XML : i n p u t . a r x m l
BMW PAGe
: INFO
Reading XML took : 0.0012 s
BMW PAGe
: INFO
Reading a l l XMLs took : 0.00162 s
BMW PAGe
: INFO
processing Pgen : i n p u t . pgen
BMW PAGe
: INFO
Open f i l e / 0 0 5 / i n p u t . pgen
BMW PAGe
: INFO
Processing Pgen took : 0.00212 s
BMW PAGe
: INFO
F i l e does not e x i s t
BMW PAGe
: INFO
Wr ite / 0 0 5 / i n p u t
File Output
/ TestPackage / TestModule / MyModule
We can a l s o check the number o f elements :
There are 2 V a l u e I n t elements .
There e x i s t s a t l e a s t one V a l u e F l o a t : 1 .
You can use the p r e v i o u s o p t i o n s a l s o as an asignment statement :
and use i t l a t e r
MyModule
ARXML Stuff
This example will demonstrate some more ARXML selection stuff which can be usefull.
It will demonstrate the following commands:
into
module
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 18 of 22


each
container
ref
snpath
ARXML Files
input.arxml
<?xml version=’1.0’?>
<AUTOSAR xmlns="http://autosar.org/schema/r4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://autosar.org/schema/r4.0 autosar.xsd">
<AR-PACKAGES>
<AR-PACKAGE>
<SHORT-NAME>TestPackage</SHORT-NAME>
<AR-PACKAGES>
<AR-PACKAGE>
<SHORT-NAME>TestModule</SHORT-NAME>
<ELEMENTS>
<ECUC-MODULE-CONFIGURATION-VALUES>
<SHORT-NAME>MyModule</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-MODULE-DEF">/BMW_DEF/TestModule</DEFINITION-REF>
<CONTAINERS>
<ECUC-CONTAINER-VALUE>
<SHORT-NAME>NumericalValues</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/BMW_DEF/TestModule/
NumericalValues</DEFINITION-REF>
<PARAMETER-VALUES>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-INTEGER-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueInt</DEFINITION-REF>
<VALUE>5</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-INTEGER-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueInt</DEFINITION-REF>
<VALUE>8</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-FLOAT-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueFloat</DEFINITION-REF>
<VALUE>3.1415</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
</PARAMETER-VALUES>
</ECUC-CONTAINER-VALUE>
</CONTAINERS>
</ECUC-MODULE-CONFIGURATION-VALUES>
<ECUC-MODULE-CONFIGURATION-VALUES>
<SHORT-NAME>NotMyModule</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-MODULE-DEF">/BMW_DEF/AnotherTestModule</DEFINITION-
REF>
<CONTAINERS>
<ECUC-CONTAINER-VALUE>
<SHORT-NAME>StringValues</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/BMW_DEF/
AnotherTestModule/StringValues</DEFINITION-REF>
<PARAMETER-VALUES>
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 19 of 22


<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-STRING-PARAM-DEF">/BMW_DEF/
AnotherTestModule/StringValues/ValueString</DEFINITION-REF>
<VALUE>Hello World the value is: </VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
</PARAMETER-VALUES>
<REFERENCE-VALUES>
<ECUC-REFERENCE-VALUE>
<DEFINITION-REF DEST="ECUC-REFERENCE-DEF">/BMW_DEF/AnotherTestModule/
StringValues/ReferenceToNumericals</DEFINITION-REF>
<VALUE-REF DEST="ECUC-CONTAINER-VALUE">/TestPackage/TestModule/
MyModule/NumericalValues</VALUE-REF>
</ECUC-REFERENCE-VALUE>
</REFERENCE-VALUES>
</ECUC-CONTAINER-VALUE>
</CONTAINERS>
</ECUC-MODULE-CONFIGURATION-VALUES>
</ELEMENTS>
</AR-PACKAGE>
</AR-PACKAGES>
</AR-PACKAGE>
</AR-PACKAGES>
</AUTOSAR>
pgen Files
input.pgen
Find a Module and change the c u r r e n t scope to i t
%{# i n t o ( module ( ' TestModule ' ) ) }%
The next element to get to i s a ( sub ) c o n t a i n e r
%{# i n t o ( c o n t a i n e r ( ' NumericalValues ' ) ) }%
But we need a d i f f e r e n t c o n t a i n e r
%{#
r e s e t ( )
i n t o ( c o n t a i n e r ( ' AnotherTestModule / S t r i n g V a l u e s ' ) )
}%
You can search f o r elements references , too :
%{= v a l u e ( r e f ( ' ReferenceToNumericals ' ) ) }%
You can use these to go i n t o but you have to use v a l u e
to get the s t r i n g o f the r e f e r e n c e
%{# i n t o ( v a l u e ( r e f ( ' ReferenceToNumericals ' ) ) ) }%
%{= current_shortname_path ( ) }%
%{# r e s e t ( ) }%
Command line
page −vvvv i n p u t . a r x m l i n p u t . pgen
Console Output
BMW PAGe
: INFO
Reading XML : i n p u t . a r x m l
BMW PAGe
: INFO
Reading XML took : 0.00095 s
BMW PAGe
: INFO
Reading a l l XMLs took : 0.00114 s
BMW PAGe
: INFO
processing Pgen : i n p u t . pgen
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 20 of 22


BMW PAGe
: INFO
Open f i l e / 0 0 6 / i n p u t . pgen
BMW PAGe
: INFO
Processing Pgen took : 0.00228 s
BMW PAGe
: INFO
F i l e does not e x i s t
BMW PAGe
: INFO
Wr ite / 0 0 6 / i n p u t
File Output
Find a Module and change the c u r r e n t scope to i t
The next element to get to i s a ( sub ) c o n t a i n e r
But we need a d i f f e r e n t c o n t a i n e r
You can search f o r elements references , too :
/ TestPackage / TestModule / MyModule / NumericalValues
You can use these to go i n t o but you have to use v a l u e
to get the s t r i n g o f the r e f e r e n c e
/ TestPackage / TestModule / MyModule / NumericalValues
Filtering Elements
This example will demonstrate some techniques that can be used to filter some elements out of a larger
list.
It will demonstrate the following commands:
into
reset
ref
module
current_shortname_path
with
ARXML Files
input.arxml
<?xml version=’1.0’?>
<AUTOSAR xmlns="http://autosar.org/schema/r4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://autosar.org/schema/r4.0 autosar.xsd">
<AR-PACKAGES>
<AR-PACKAGE>
<SHORT-NAME>TestPackage</SHORT-NAME>
<AR-PACKAGES>
<AR-PACKAGE>
<SHORT-NAME>TestModule</SHORT-NAME>
<ELEMENTS>
<ECUC-MODULE-CONFIGURATION-VALUES>
<SHORT-NAME>MyModule</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-MODULE-DEF">/BMW_DEF/TestModule</DEFINITION-REF>
<CONTAINERS>
<ECUC-CONTAINER-VALUE>
<SHORT-NAME>NumericalValues</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/BMW_DEF/TestModule/
NumericalValues</DEFINITION-REF>
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 21 of 22


<PARAMETER-VALUES>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-INTEGER-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueInt</DEFINITION-REF>
<VALUE>5</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-INTEGER-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueInt</DEFINITION-REF>
<VALUE>8</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-FLOAT-PARAM-DEF">/BMW_DEF/TestModule/
NumericalValues/ValueFloat</DEFINITION-REF>
<VALUE>3.1415</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
</PARAMETER-VALUES>
</ECUC-CONTAINER-VALUE>
</CONTAINERS>
</ECUC-MODULE-CONFIGURATION-VALUES>
<ECUC-MODULE-CONFIGURATION-VALUES>
<SHORT-NAME>NotMyModule</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-MODULE-DEF">/BMW_DEF/AnotherTestModule</DEFINITION-
REF>
<CONTAINERS>
<ECUC-CONTAINER-VALUE>
<SHORT-NAME>StringValues</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/BMW_DEF/
AnotherTestModule/StringValues</DEFINITION-REF>
<PARAMETER-VALUES>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF DEST="ECUC-STRING-PARAM-DEF">/BMW_DEF/
AnotherTestModule/StringValues/ValueString</DEFINITION-REF>
<VALUE>Hello World the value is: </VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
</PARAMETER-VALUES>
</ECUC-CONTAINER-VALUE>
</CONTAINERS>
</ECUC-MODULE-CONFIGURATION-VALUES>
</ELEMENTS>
</AR-PACKAGE>
</AR-PACKAGES>
</AR-PACKAGE>
</AR-PACKAGES>
</AUTOSAR>
pgen Files
input.pgen
Command line
page −vvvv i n p u t . a r x m l i n p u t . pgen
Console Output
BMW PAGe
: INFO
Reading XML : i n p u t . a r x m l
BMW PAGe
: INFO
Reading XML took : 0.000903 s
BMW PAGe
: INFO
Reading a l l XMLs took : 0.00111 s
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 22 of 22


BMW PAGe
: INFO
processing Pgen : i n p u t . pgen
BMW PAGe
: INFO
Open f i l e / 0 0 7 / i n p u t . pgen
BMW PAGe
: INFO
Processing Pgen took : 0.00141 s
BMW PAGe
: INFO
Empty content −> no f i l e w r i t t e n
BMW PAGe
: INFO
Skipping w r i t e o f / 0 0 7 / i n p u t , no changes detected
File Output
UserGuide_PAGe, Version 1.1.0, Software Platforms
Page 23 of 22

Document Outline


Last modified October 12, 2025: Initial commit (af72ad2)