-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example how to create component from template class
- Loading branch information
Showing
13 changed files
with
430 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
""" | ||
Component type templates | ||
""" | ||
# flake8: noqa | ||
# pylint: disable=C0103, C0301 | ||
|
||
|
||
import autosar.xml.element as ar_element | ||
import autosar.xml.workspace as ar_workspace | ||
from . import factory, portinterface, constants | ||
|
||
NAMESPACE = "Default" | ||
|
||
|
||
def create_ReceiverComponent(_0: str, | ||
workspace: ar_workspace.Workspace, | ||
deps: dict[str, ar_element.ARElement] | None, | ||
**_1) -> ar_element.ApplicationSoftwareComponentType: | ||
""" | ||
Create Receiver component type | ||
""" | ||
|
||
timer_interface = deps[portinterface.FreeRunningTimer_I.ref(workspace)] | ||
vehicle_speed_interface = deps[portinterface.EngineSpeed_I.ref(workspace)] | ||
engine_speed_interface = deps[portinterface.VehicleSpeed_I.ref(workspace)] | ||
engine_speed_init = deps[constants.EngineSpeed_IV.ref(workspace)] | ||
vehicle_speed_init = deps[constants.VehicleSpeed_IV.ref(workspace)] | ||
swc = ar_element.ApplicationSoftwareComponentType("ReceiverComponent") | ||
swc.create_require_port("EngineSpeed", engine_speed_interface, com_spec={"init_value": engine_speed_init.ref(), | ||
"alive_timeout": 0, | ||
"enable_update": False, | ||
"uses_end_to_end_protection": False, | ||
"handle_never_received": False | ||
}) | ||
swc.create_require_port("VehicleSpeed", vehicle_speed_interface, com_spec={"init_value": vehicle_speed_init.ref(), | ||
"alive_timeout": 0, | ||
"enable_update": False, | ||
"uses_end_to_end_protection": False, | ||
"handle_never_received": False | ||
}) | ||
swc.create_require_port("FreeRunningTimer", timer_interface) | ||
swc.create_internal_behavior() | ||
return swc | ||
|
||
|
||
ReceiverComponent = factory.GenericComponentTypeTemplate("ReceiverComponent", | ||
NAMESPACE, | ||
create_ReceiverComponent, | ||
depends=[portinterface.EngineSpeed_I, | ||
portinterface.VehicleSpeed_I, | ||
portinterface.FreeRunningTimer_I, | ||
constants.EngineSpeed_IV, | ||
constants.VehicleSpeed_IV,]) | ||
ReceiverComponent_Implementation = factory.SwcImplementationTemplate("ReceiverComponent_Implementation", | ||
NAMESPACE, | ||
component_type=ReceiverComponent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
""" | ||
Constants templates | ||
""" | ||
# flake8: noqa | ||
# pylint: disable=C0103, C0301 | ||
|
||
from . import factory | ||
|
||
NAMESPACE = "Default" | ||
|
||
EngineSpeed_IV = factory.ConstantTemplate("EngineSpeed_IV", NAMESPACE, 65535) | ||
VehicleSpeed_IV = factory.ConstantTemplate("VehicleSpeed_IV", NAMESPACE, 65535) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.