Skip to content

Commit

Permalink
Implement remaining event classes
Browse files Browse the repository at this point in the history
- AsynchronousServerCallReturnsEvent
- BackgroundEvent
- ExternalTriggerOccurredEvent
- InternalTriggerOccurredEvent
- SwcModeManagerErrorEvent
- TransformerHardErrorEvent
  • Loading branch information
cogu committed Aug 12, 2024
1 parent edab4bc commit ba0d945
Show file tree
Hide file tree
Showing 8 changed files with 1,098 additions and 116 deletions.
17 changes: 14 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,33 @@ Non-collectable elements are various sub-elements to collectable elements.

#### XML - Software component elements

* PModeGroupInAtomicSwcInstanceRef | P-MODE-GROUP-IN-ATOMIC-SWC-INSTANCE-REF
* POperationInAtomicSwcInstanceRef | P-OPERATION-IN-ATOMIC-SWC-INSTANCE-REF
* PTriggerInAtomicSwcTypeInstanceRef | P-TRIGGER-IN-ATOMIC-SWC-TYPE-INSTANCE-REF
* RModeInAtomicSwcInstanceRef | R-MODE-IN-ATOMIC-SWC-INSTANCE-REF
* RTriggerInAtomicSwcInstanceRef | R-TRIGGER-IN-ATOMIC-SWC-INSTANCE-REF
* RVariableInAtomicSwcInstanceRef | R-VARIABLE-IN-ATOMIC-SWC-INSTANCE-REF

#### XML - SWC internal behavior elements

* DataReceiveErrorEvent | DATA-RECEIVE-ERROR-EVENT
* AsynchronousServerCallReturnsEvent | ASYNCHRONOUS-SERVER-CALL-RETURNS-EVENT
* BackgroundEvent | BACKGROUND-EVENT
* DataReceivedEvent | DATA-RECEIVED-EVENT
* DataReceiveErrorEvent | DATA-RECEIVE-ERROR-EVENT
* DataSendCompletedEvent | DATA-SEND-COMPLETED-EVENT
* DataWriteCompletedEvent | DATA-WRITE-COMPLETED-EVENT
* ExternalTriggerOccurredEvent | EXTERNAL-TRIGGER-OCCURRED-EVENT
* InitEvent | INIT-EVENT
* InternalBehavior | SWC-INTERNAL-BEHAVIOR (Partly implemented)
* runnables
* InternalTriggerOccurredEvent | INTERNAL-TRIGGER-OCCURRED-EVENT
* ModeSwitchedAckEvent | MODE-SWITCHED-ACK-EVENT
* OperationInvokedEvent | OPERATION-INVOKED-EVENT
* RunnableEntity | RUNNABLE-ENTITY
* SwcModeManagerErrorEvent | SWC-MODE-MANAGER-ERROR-EVENT
* SwcModeSwitchEvent | SWC-MODE-SWITCH-EVENT
* TimingEvent | TIMING-EVENT
* InternalBehavior | SWC-INTERNAL-BEHAVIOR (Partly implemented)
* RunnableEntity | RUNNABLE-ENTITY
* TransformerHardErrorEvent | TRANSFORMER-HARD-ERROR-EVENT

### Fixed

Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,14 @@ Below is a rough roadmap of planned releases.
* Port-access
* Port-API options

**v0.5.6** Add some missing elements and functions that wasn't prioritized before.
**v0.5.6** Fixes and refactoring

* Fix some early design mistakes
* Harmonize some member names to better match "qualified name" from XSD (BREAKING CHANGE)
* This mostly means that lot of class member names ending with "_ref" will have its suffix removed
* Attempt to break apart large Python files into smaller ones.

**v0.5.7** Add some missing elements and functions that wasn't prioritized before.

**v0.6.0:** Stable version, publish to PyPI.

Expand Down
216 changes: 204 additions & 12 deletions src/autosar/xml/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
RunnableEntityRef,
VariableAccessRef,
ModeSwitchPointRef,
AsynchronousServerCallResultPointRef,
TriggerRef,
InternalTriggeringPointRef,
)


Expand Down Expand Up @@ -5229,6 +5232,65 @@ def _create_pass_through_connector(self,
return connector


class POperationInAtomicSwcInstanceRef(ARObject):
"""
Complex type AR:P-OPERATION-IN-ATOMIC-SWC-INSTANCE-REF
Tag variants: 'OPERATION-IREF'
"""

def __init__(self,
context_port: AbstractProvidedPortPrototypeRef | None = None,
target_provided_operation: ClientServerOperationRef | str | None = None,
) -> None:
# .CONTEXT-P-PORT-REF (Keep name consistent in similar classes)
self.context_port: AbstractProvidedPortPrototypeRef | None = None
# .TARGET-PROVIDED-OPERATION-REF
self.target_provided_operation: ClientServerOperationRef | None = None
self._assign_optional("context_port", context_port, AbstractProvidedPortPrototypeRef)
self._assign_optional("target_provided_operation", target_provided_operation, ClientServerOperationRef)


class PModeGroupInAtomicSwcInstanceRef(ARObject):
"""
Complex type AR:P-MODE-GROUP-IN-ATOMIC-SWC-INSTANCE-REF
Tag variants: 'P-MODE-GROUP-IN-ATOMIC-SWC-INSTANCE-REF' | 'MODE-GROUP-IREF' |
'SWC-MODE-GROUP-IREF'
"""

def __init__(self,
context_port: AbstractProvidedPortPrototypeRef | None = None,
context_mode_declaration_group_prototype: ModeDeclarationGroupPrototypeRef | str | None = None,
) -> None:
# .CONTEXT-P-PORT-REF
self.context_port: AbstractProvidedPortPrototypeRef | None = None
# .CONTEXT-MODE-DECLARATION-GROUP-PROTOTYPE-REF
self.context_mode_declaration_group_prototype: ModeDeclarationGroupPrototypeRef | None = None

self._assign_optional("context_port", context_port, AbstractProvidedPortPrototypeRef)
self._assign_optional("context_mode_declaration_group_prototype",
context_mode_declaration_group_prototype,
ModeDeclarationGroupPrototypeRef)


class PTriggerInAtomicSwcTypeInstanceRef(ARObject):
"""
Complex type AR:P-TRIGGER-IN-ATOMIC-SWC-TYPE-INSTANCE-REF
Tag variants: 'P-TRIGGER-IN-ATOMIC-SWC-TYPE-INSTANCE-REF' | 'SWC-TRIGGER-IREF' |
'TRIGGER-IREF'
"""

def __init__(self,
context_port: AbstractProvidedPortPrototypeRef | None = None,
target_trigger: TriggerRef | str | None = None,
) -> None:
# .CONTEXT-P-PORT-REF (Keep name consistent in similar classes)
self.context_port: AbstractProvidedPortPrototypeRef | None = None
# .TARGET-TRIGGER-REF
self.target_trigger: TriggerRef | None = None
self._assign_optional("context_port", context_port, AbstractProvidedPortPrototypeRef)
self._assign_optional("target_trigger", target_trigger, TriggerRef)


class RModeInAtomicSwcInstanceRef(ARObject):
"""
Complex type AR:R-MODE-IN-ATOMIC-SWC-INSTANCE-REF
Expand Down Expand Up @@ -5267,26 +5329,28 @@ def __init__(self,
self.context_port: AbstractRequiredPortPrototypeRef | None = None
# .TARGET-DATA-ELEMENT-REF
self.target_data_element: VariableDataPrototypeRef | None = None

self._assign_optional("context_port", context_port, AbstractRequiredPortPrototypeRef)
self._assign_optional("target_data_element", target_data_element, VariableDataPrototypeRef)


class POperationInAtomicSwcInstanceRef(ARObject):
class RTriggerInAtomicSwcInstanceRef(ARObject):
"""
Complex type AR:P-OPERATION-IN-ATOMIC-SWC-INSTANCE-REF
Tag variants: 'OPERATION-IREF'
Complex type AR:R-TRIGGER-IN-ATOMIC-SWC-INSTANCE-REF
Tag variants: 'TRIGGER-IREF' | 'REQUIRED-TRIGGER-IREF'
"""

def __init__(self,
context_port: AbstractProvidedPortPrototypeRef | None = None,
target_provided_operation: ClientServerOperationRef | str | None = None,
context_port: AbstractRequiredPortPrototypeRef | None = None,
target_trigger: TriggerRef | str | None = None,
) -> None:
# .CONTEXT-P-PORT-REF (Keep name consistent in similar classes)
self.context_port: AbstractProvidedPortPrototypeRef | None = None
# .TARGET-PROVIDED-OPERATION-REF
self.target_provided_operation: ClientServerOperationRef | None = None
self._assign_optional("context_port", context_port, AbstractProvidedPortPrototypeRef)
self._assign_optional("target_provided_operation", target_provided_operation, ClientServerOperationRef)
# .CONTEXT-R-PORT-REF (Keep name consistent in similar classes)
self.context_port: AbstractRequiredPortPrototypeRef | None = None
# .TARGET-TRIGGER-REF
self.target_trigger: TriggerRef | None = None

self._assign_optional("context_port", context_port, AbstractRequiredPortPrototypeRef)
self._assign_optional("target_trigger", target_trigger, TriggerRef)

# --- SWC internal behavior elements

Expand Down Expand Up @@ -5652,6 +5716,31 @@ def append_disabled_mode(self, disabled_mode: RModeInAtomicSwcInstanceRef) -> No
raise TypeError("disabled_mode must be of type RModeInAtomicSwcInstanceRef")


class AsynchronousServerCallReturnsEvent(RteEvent):
"""
Complex type AR:ASYNCHRONOUS-SERVER-CALL-RETURNS-EVENT
Tag variants: 'ASYNCHRONOUS-SERVER-CALL-RETURNS-EVENT'
"""

def __init__(self,
name: str,
start_on_event: RunnableEntityRef | str | None = None,
event_source: AsynchronousServerCallResultPointRef | str | None = None,
**kwargs) -> None:
super().__init__(name, start_on_event, **kwargs)
# .EVENT-SOURCE-REF
self.event_source: AsynchronousServerCallResultPointRef | None = None
self._assign_optional("event_source", event_source, AsynchronousServerCallResultPointRef)


class BackgroundEvent(RteEvent):
"""
Complex Type AR:BACKGROUND-EVENT
Tag variants: 'BACKGROUND-EVENT'
Inherits constructor from base-class
"""


class DataReceiveErrorEvent(RteEvent):
"""
Complex Type AR:DATA-RECEIVE-ERROR-EVENT
Expand Down Expand Up @@ -5752,14 +5841,61 @@ def __init__(self,
self._assign_optional("event_source", event_source, VariableAccessRef)


class ExternalTriggerOccurredEvent(RteEvent):
"""
Complex Type AR:EXTERNAL-TRIGGER-OCCURRED-EVENT
Tag variants: 'EXTERNAL-TRIGGER-OCCURRED-EVENT'
"""

def __init__(self,
name: str,
start_on_event: RunnableEntityRef | str | None = None,
trigger: RTriggerInAtomicSwcInstanceRef | str | None = None,
**kwargs) -> None:
super().__init__(name, start_on_event, **kwargs)
# .TRIGGER-IREF
self.trigger: RTriggerInAtomicSwcInstanceRef | None = None
self._assign_optional_strict("trigger", trigger, RTriggerInAtomicSwcInstanceRef)

@classmethod
def make(cls,
name: str,
start_on_event: RunnableEntityRef | str | None = None,
context_port: AbstractRequiredPortPrototypeRef | None = None,
target_trigger: TriggerRef | str | None = None,
**kwargs) -> "ExternalTriggerOccurredEvent":
"""
#convenience-method
"""
trigger = RTriggerInAtomicSwcInstanceRef(context_port, target_trigger)
return cls(name, start_on_event, trigger, **kwargs)


class InitEvent(RteEvent):
"""
Complex Type AR:INIT-EVENT
Tag variants: 'INIT-EVENT'
Reuses constructor from base-class
Inherits constructor from base-class
"""


class InternalTriggerOccurredEvent(RteEvent):
"""
Complex type AR:INTERNAL-TRIGGER-OCCURRED-EVENT
Tag variants: 'INTERNAL-TRIGGER-OCCURRED-EVENT'
"""

def __init__(self,
name: str,
start_on_event: RunnableEntityRef | str | None = None,
event_source: InternalTriggeringPointRef | str | None = None,
**kwargs) -> None:
super().__init__(name, start_on_event, **kwargs)
# .EVENT-SOURCE-REF
self.event_source: InternalTriggeringPointRef | None = None
self._assign_optional("event_source", event_source, InternalTriggeringPointRef)


class ModeSwitchedAckEvent(RteEvent):
"""
Complex type AR:MODE-SWITCHED-ACK-EVENT
Expand Down Expand Up @@ -5815,6 +5951,36 @@ def make(cls,
None]


class SwcModeManagerErrorEvent(RteEvent):
"""
Complex type AR:SWC-MODE-MANAGER-ERROR-EVENT
Tag variants: 'SWC-MODE-MANAGER-ERROR-EVENT'
"""

def __init__(self,
name: str,
start_on_event: RunnableEntityRef | str | None = None,
mode_group: PModeGroupInAtomicSwcInstanceRef | str | None = None,
**kwargs) -> None:
super().__init__(name, start_on_event, **kwargs)
# .MODE-GROUP-IREF
self.mode_group: PModeGroupInAtomicSwcInstanceRef | None = None
self._assign_optional_strict("mode_group", mode_group, PModeGroupInAtomicSwcInstanceRef)

@classmethod
def make(cls,
name: str,
start_on_event: RunnableEntityRef | str | None = None,
context_port: AbstractProvidedPortPrototypeRef | None = None,
context_mode_declaration_group_prototype: ModeDeclarationGroupPrototypeRef | str | None = None,
**kwargs) -> "SwcModeManagerErrorEvent":
"""
#convenience-method
"""
mode_group = PModeGroupInAtomicSwcInstanceRef(context_port, context_mode_declaration_group_prototype)
return cls(name, start_on_event, mode_group, **kwargs)


class SwcModeSwitchEvent(RteEvent):
"""
Complex type AR:SWC-MODE-SWITCH-EVENT
Expand Down Expand Up @@ -5893,6 +6059,32 @@ def __init__(self,
self._assign_optional("period", period, float)


class TransformerHardErrorEvent(RteEvent):
"""
Complex type AR:TRANSFORMER-HARD-ERROR-EVENT
Tag variants: 'TRANSFORMER-HARD-ERROR-EVENT'
"""

def __init__(self,
name: str,
start_on_event: RunnableEntityRef | str | None = None,
operation: POperationInAtomicSwcInstanceRef | None = None,
required_trigger: RTriggerInAtomicSwcInstanceRef | None = None,
trigger: PTriggerInAtomicSwcTypeInstanceRef | None = None,
**kwargs) -> None:
super().__init__(name, start_on_event, **kwargs)
# .OPERATION-IREF
self.operation: POperationInAtomicSwcInstanceRef | None = None
# .REQUIRED-TRIGGER-IREF
self.required_trigger: RTriggerInAtomicSwcInstanceRef | None = None
# .TRIGGER-IREF
self.trigger: PTriggerInAtomicSwcTypeInstanceRef | None = None

self._assign_optional_strict("operation", operation, POperationInAtomicSwcInstanceRef)
self._assign_optional_strict("required_trigger", required_trigger, RTriggerInAtomicSwcInstanceRef)
self._assign_optional_strict("trigger", trigger, PTriggerInAtomicSwcTypeInstanceRef)


class InternalBehavior(Identifiable):
"""
Group AR:INTERNAL-BEHAVIOR
Expand Down
Loading

0 comments on commit ba0d945

Please sign in to comment.