Skip to content

Commit

Permalink
Fix mistakes in README
Browse files Browse the repository at this point in the history
  • Loading branch information
cogu committed Oct 28, 2024
1 parent 1750c6c commit 0e090c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
27 changes: 13 additions & 14 deletions examples/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ Template objects enables developers to describe how ARXML elements should be cre
Think of it like recipes for ARXML elements.
Most importantly it allows us to describe the dependencies between elements. This helps greatly when working in large scale projects with multiple developers.

To assist with their creation, a template factory (see [factory.py](demo_system/factory.py)) needs to written by an experienced developer. New elements are then declared by calling on
the various factory methods. For example, a relatively complex data type can now be declared using a single line of Python code (see [datatype.py](demo_system/datatype.py)).
To assist with their creation, a template factory (see [factory.py](demo_system/factory.py)) needs to be written. New template objects are then declared by calling on the various factory methods. For example, a relatively complex data type can now be declared using a single line of Python code (see [datatype.py](demo_system/datatype.py)).

## Namespaces

Expand All @@ -21,33 +20,33 @@ In short, namespaces handles the creation of packages while templates handles th

### Applying templates

Templates are applied to a workspace using the `Workspace.apply` method.
Templates are applied in a workspace using the `Workspace.apply` method.
In general, applying template objects requires 4 steps.

1. Create an empty workspace object.
1. Create an empty workspace.
2. In the workspace, create one or more namespaces (a default is fine).
3. Call the Workspace.apply method with the template object as argument.
4. Save as ARXML
3. Call the `Workspace.apply` method with the template object as argument.
4. Save the workspace as ARXML

During step 3, Python AUTOSAR not only creates the element itself, it automatically creates all elements
that it depends on (data types, port interfaces, modes etc.).

In the two Python scripts in directory you will see examples how an entire ARXML project is generated from a single line of code:
In the two Python scripts found in this directory you will see examples how an entire ARXML project is generated from a single line of code:

```python
workspace.apply(component.CompositionComponent)
```

This line of code creates all ARXML elements that the CompositionComponent depends on such as:
This will create all ARXML elements that the compositin SWC depends on such as:

- Data types
- Port interfaces
- Constants
- Mode declarations
- SWCs
- inner (or child) SWCs

If you look closely in the examples you will notice that it handles the platform base types differently. Normally, unused elements are skipped but
this step forces the platform types to be created in the project even if they are unused/unreferenced. This is used as to not confuse the toolchain that will read the ARXML files later.
If you look closely in the examples you will notice that it handles the platform types differently. Normally, unused elements are skipped but
this special step forces them to be generated in the project even if they are unused/unreferenced. This is used as to not confuse the toolchain that will read the ARXML files later.

## Generation with config

Expand All @@ -58,12 +57,12 @@ For a full example, see [generate_xml_using_config.py](generate_xml_using_config

## Generation without config

It is possible to accomplish the same result without using a config file. It requires a bit more code setting up the workspace.
See [generate_xml_withouf_config.py](generate_xml_without_config.py) for a full example.
It's possible to accomplish the same result without using a config file. It requires a bit more code setting up the workspace.
See [generate_xml_without_config.py](generate_xml_without_config.py) for a full example of that.

## Advantages and disadvantages using template objects

It's recommended to use templates in medium to large projects that has multiple team members.
It's recommended to use template objects in medium to large projects that has multiple team members.

Advantages:

Expand Down
12 changes: 6 additions & 6 deletions examples/template/demo_system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ This folder contains an example which demonstrates how the template mechanism is
## Software layers

This example uses 3 layers. At the bottom we have the Python AUTOSAR XML API (This git repo).
The Factory layer enables an easy way to create commonly used elements such as data types and port-interfaces.
The [Factory](factory.py) layer enables an easy way to create commonly used elements such as data types and port-interfaces.
It acts like an abstraction layer, hiding most of the low-level details seen in the Python AUTOSAR XML API.

| Template elements |
| Factory |
| Python AUTODSAR |
1. Template element layer
2. Factory layer
3. Python AUTOSAR XML layer

## components

The file components.py contains 3 example SWCs:
The file [components.py](components.py) contains 3 example SWCs:

- ReceiverComponent (ApplicationSoftwareComponentType)
- TimerComponent (ApplicationSoftwareComponentType)
- CompositionComponent (CompositionSwComponentType)

The composition "CompositionComponent" contains the two application SWCs and create some connectors between them.
The composition "CompositionComponent" wraps the two application SWCs and create some connectors between them.
The component TimerComponent provides a timer API (Client-server-interface) that the ReceiverComponent uses.

0 comments on commit 0e090c8

Please sign in to comment.