Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template improvements #101

Merged
merged 4 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
ref: v0.3.2
path: cfile_0.3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.venv/
build/
sandbox/
usage_tests/
**/autosar.egg-info/
**/__pycache__/
**/data/*.xsd
**/data/validate_all.sh
**/data/validate_all.sh
**/generated/*.xsd
**/generated/validate_all.sh
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Non-collectable elements are various sub-elements to collectable elements.

### Added

#### Workspace

* Various improvements to template classes
* Support project config files

#### XML - Data type elements

* ArgumentDataPrototype | ARGUMENT-DATA-PROTOTYPE
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ It also has some support for parsing AUTOSAR XML files.
3. Currently, only the categories mentioned below are supported. If you want a full API, wait for v0.6.0:
* Data Types
* Constants
* Port Interfaces

## Major design changes

Expand Down Expand Up @@ -53,6 +54,7 @@ For currently supported XML elements, see the [CHANGELOG](CHANGELOG.md) file.

* Python 3.10+
* lxml
* tomli (Python 3.10 only, tomli is built-in for Python 3.11)
* [cfile](https://github.com/cogu/cfile) v0.3.2+

## Installation
Expand Down Expand Up @@ -237,7 +239,7 @@ None
InactiveActive_T: <class 'autosar.xml.element.ImplementationDataType'>
```

Here's a more fleshed out example, tt adds a `TEXTTABLE` CompuMethod and saves everything to an ARXML file. It also demonstrates how you control the XML schema version
Here's a more fleshed out example, it adds a `TEXTTABLE` CompuMethod and saves everything to an ARXML file. It also demonstrates how you control the XML schema version
when saving the file.

```python
Expand Down
6 changes: 3 additions & 3 deletions examples/xml/data_types/sw_addr_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@

if __name__ == "__main__":

#Create document
# Create document
package = ar_element.Package('SwAddrMethod')
elem = ar_element.SwAddrMethod('DEFAULT')
package.append(elem)
document = autosar.xml.document.Document()
document.append(package)

file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'data', 'sw_addr_method_example.arxml'))
#Write document to file system
# Write document to file system
writer = autosar.xml.Writer()
writer.write_file(document, file_path)

#Read document from file system
# Read document from file system
reader = autosar.xml.Reader()
document = reader.read_file(file_path)
addr_method = document.find('/SwAddrMethod/DEFAULT')
Expand Down
27 changes: 27 additions & 0 deletions examples/xml/template/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

[namespace.Default]
BaseType = "/DataTypes/BaseTypes"
ImplementationDataType = "DataTypes/ImplementationDataTypes"
CompuMethod = "DataTypes/CompuMethods"
DataConstraint = "DataTypes/DataConstrs"
ComponentType = "/ComponentTypes"
ModeDeclaration = "/ModeDclrGroups"
PortInterface = "/PortInterfaces"
base_ref = "/"

[namespace.AUTOSAR_Platform]
BaseType = "BaseTypes"
CompuMethod = "CompuMethods"
DataConstraint = "DataConstrs"
ImplementationDataType = "ImplementationDataTypes"

[document.AUTOSAR_Platform]
packages = "/AUTOSAR_Platform"

[document.PortInterfaces]
packages=["/ModeDclrGroups", "/PortInterfaces"]

[document.DataTypes]
packages = "/DataTypes"


1 change: 1 addition & 0 deletions examples/xml/template/demo_system/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Demonstration of how to use template classes"""
11 changes: 11 additions & 0 deletions examples/xml/template/demo_system/datatype.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
data types
"""
# flake8: noqa
# pylint: disable=C0103, C0301

from . import factory, platform

NAMESPACE = "Default"

InactiveActive_T = factory.ImplementationEnumDataTypeTemplate("InactiveActive_T", "Default", platform.BaseTypes.uint8, ["InactiveActive_Inactive", "InactiveActive_Active"])
Loading