Skip to content

Commit

Permalink
Implement SenderReceiverInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
cogu committed Jan 28, 2024
1 parent 0fbf839 commit 54316e0
Show file tree
Hide file tree
Showing 11 changed files with 918 additions and 208 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# Changelog

The first name in a bullet point below is the Python class name while the second name is the identifier used in the XML schema (XSD file).

Elements marked as `collectable` means that they can be added directly to a package.
Non-collectable elements are various sub-elements to collectable elements.

The name in the parenthesis after each element is the name used in the XML schema (XSD file).
## Unreleased

### Added

#### XML Port interface elements

* SenderReceiverInterface | SENDER-RECEIVER-INTERFACE | `collectable`
* InvalidationPolicy | INVALIDATION-POLICY

#### XML - Data type elements

* VariableDataPrototype | VARIABLE-DATA-PROTOTYPE

## [v0.5.1] - 2023-11-09

Expand Down
2 changes: 1 addition & 1 deletion examples/xml/constant/data/constants.arxml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<SHORT-NAME>RecordConstant</SHORT-NAME>
<VALUE-SPEC>
<RECORD-VALUE-SPECIFICATION>
<SHORT-LABEL>Label4</SHORT-LABEL>
<SHORT-LABEL>Label5</SHORT-LABEL>
<FIELDS>
<TEXT-VALUE-SPECIFICATION>
<VALUE>Value1</VALUE>
Expand Down
19 changes: 19 additions & 0 deletions examples/xml/port_interface/data/sender_receiver_interface.arxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<AUTOSAR xsi:schemaLocation="http://autosar.org/schema/r4.0 AUTOSAR_00051.xsd" xmlns="http://autosar.org/schema/r4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AR-PACKAGES>
<AR-PACKAGE>
<SHORT-NAME>PortInterfaces</SHORT-NAME>
<ELEMENTS>
<SENDER-RECEIVER-INTERFACE>
<SHORT-NAME>HeadLightStatus_I</SHORT-NAME>
<DATA-ELEMENTS>
<VARIABLE-DATA-PROTOTYPE>
<SHORT-NAME>HeadLightStatus</SHORT-NAME>
<TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE">/DataTypes/ImplementationDataTypes/InactiveActive_T</TYPE-TREF>
</VARIABLE-DATA-PROTOTYPE>
</DATA-ELEMENTS>
</SENDER-RECEIVER-INTERFACE>
</ELEMENTS>
</AR-PACKAGE>
</AR-PACKAGES>
</AUTOSAR>
36 changes: 36 additions & 0 deletions examples/xml/port_interface/sender_receiver_interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
Sender-receiver port interface examples
"""
import os
import autosar
import autosar.xml.element as ar_element


def create_interface_with_one_element():
"""
Creates an array implementation data type with VALUE element
"""
workspace = autosar.xml.Workspace()
packages = dict(zip(["BaseTypes", "ImplementationDataTypes", "PortInterfaces"],
workspace.make_packages("DataTypes/BaseTypes",
"DataTypes/ImplementationDataTypes",
"PortInterfaces")))
uint8_base_type = ar_element.SwBaseType('uint8', size=8)
packages["BaseTypes"].append(uint8_base_type)
sw_data_def_props = ar_element.SwDataDefPropsConditional(base_type_ref=uint8_base_type.ref())
inactive_active_t = ar_element.ImplementationDataType("InactiveActive_T",
category="VALUE",
sw_data_def_props=sw_data_def_props)
packages["ImplementationDataTypes"].append(inactive_active_t)
portinterface = ar_element.SenderReceiverInterface.make_simple("HeadLightStatus_I",
"HeadLightStatus",
type_ref=inactive_active_t.ref())
packages["PortInterfaces"].append(portinterface)
document_path = os.path.abspath(os.path.join(os.path.dirname(
__file__), 'data', 'sender_receiver_interface.arxml'))
workspace.create_document(document_path, packages="/PortInterfaces")
workspace.write_documents()


if __name__ == "__main__":
create_interface_with_one_element()
Loading

0 comments on commit 54316e0

Please sign in to comment.