Skip to content

Commit edab4bc

Browse files
committed
Implement more event classes
- DataReceiveErrorEvent - DataSendCompletedEvent - DataWriteCompletedEvent - ModeSwitchedAckEvent - OperationInvokedEvent - SwcModeSwitchEvent - TimingEvent
1 parent e6e0056 commit edab4bc

File tree

7 files changed

+1208
-78
lines changed

7 files changed

+1208
-78
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ Non-collectable elements are various sub-elements to collectable elements.
1616

1717
#### XML - SWC internal behavior elements
1818

19+
* DataReceiveErrorEvent | DATA-RECEIVE-ERROR-EVENT
1920
* DataReceivedEvent | DATA-RECEIVED-EVENT
21+
* DataSendCompletedEvent | DATA-SEND-COMPLETED-EVENT
22+
* DataWriteCompletedEvent | DATA-WRITE-COMPLETED-EVENT
2023
* InitEvent | INIT-EVENT
24+
* ModeSwitchedAckEvent | MODE-SWITCHED-ACK-EVENT
25+
* OperationInvokedEvent | OPERATION-INVOKED-EVENT
26+
* SwcModeSwitchEvent | SWC-MODE-SWITCH-EVENT
27+
* TimingEvent | TIMING-EVENT
2128
* InternalBehavior | SWC-INTERNAL-BEHAVIOR (Partly implemented)
2229
* RunnableEntity | RUNNABLE-ENTITY
2330

src/autosar/xml/element.py

+222-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
ExclusiveAreaRef,
4646
ExclusiveAreaNestingOrderRef,
4747
AbstractRequiredPortPrototypeRef,
48+
AbstractProvidedPortPrototypeRef,
4849
RunnableEntityRef,
50+
VariableAccessRef,
51+
ModeSwitchPointRef,
4952
)
5053

5154

@@ -5260,14 +5263,31 @@ def __init__(self,
52605263
context_port: AbstractRequiredPortPrototypeRef | None = None,
52615264
target_data_element: VariableDataPrototypeRef | str | None = None,
52625265
) -> None:
5263-
# .CONTEXT-R-PORT-REF (Use same name as in RModeInAtomicSwcInstanceRef for consistency)
5266+
# .CONTEXT-R-PORT-REF (Keep name consistent in similar classes)
52645267
self.context_port: AbstractRequiredPortPrototypeRef | None = None
52655268
# .TARGET-DATA-ELEMENT-REF
52665269
self.target_data_element: VariableDataPrototypeRef | None = None
52675270
self._assign_optional("context_port", context_port, AbstractRequiredPortPrototypeRef)
52685271
self._assign_optional("target_data_element", target_data_element, VariableDataPrototypeRef)
52695272

52705273

5274+
class POperationInAtomicSwcInstanceRef(ARObject):
5275+
"""
5276+
Complex type AR:P-OPERATION-IN-ATOMIC-SWC-INSTANCE-REF
5277+
Tag variants: 'OPERATION-IREF'
5278+
"""
5279+
5280+
def __init__(self,
5281+
context_port: AbstractProvidedPortPrototypeRef | None = None,
5282+
target_provided_operation: ClientServerOperationRef | str | None = None,
5283+
) -> None:
5284+
# .CONTEXT-P-PORT-REF (Keep name consistent in similar classes)
5285+
self.context_port: AbstractProvidedPortPrototypeRef | None = None
5286+
# .TARGET-PROVIDED-OPERATION-REF
5287+
self.target_provided_operation: ClientServerOperationRef | None = None
5288+
self._assign_optional("context_port", context_port, AbstractProvidedPortPrototypeRef)
5289+
self._assign_optional("target_provided_operation", target_provided_operation, ClientServerOperationRef)
5290+
52715291
# --- SWC internal behavior elements
52725292

52735293

@@ -5501,7 +5521,7 @@ def __init__(self,
55015521
activation_reasons: ActivationReasonArgumentType = None,
55025522
can_enter_leave: CanEnterLeaveArgumentType = None,
55035523
exclusive_area_nesting_order: ExclusiveAreaNestingOrderArgumentType = None,
5504-
minimum_start_interval: float | None = None,
5524+
minimum_start_interval: int | float | None = None,
55055525
reentrancy_level: ar_enum.ReentrancyLevel | None = None,
55065526
runs_insides: RunsInsidesArgumentType = None,
55075527
sw_addr_method: str | SwAddrMethodRef | None = None,
@@ -5632,6 +5652,39 @@ def append_disabled_mode(self, disabled_mode: RModeInAtomicSwcInstanceRef) -> No
56325652
raise TypeError("disabled_mode must be of type RModeInAtomicSwcInstanceRef")
56335653

56345654

5655+
class DataReceiveErrorEvent(RteEvent):
5656+
"""
5657+
Complex Type AR:DATA-RECEIVE-ERROR-EVENT
5658+
Tag variants: 'DATA-RECEIVE-ERROR-EVENT'
5659+
"""
5660+
5661+
def __init__(self,
5662+
name: str,
5663+
start_on_event: RunnableEntityRef | str | None = None,
5664+
data: RVariableInAtomicSwcInstanceRef | None = None,
5665+
**kwargs) -> None:
5666+
super().__init__(name, start_on_event, **kwargs)
5667+
# .DATA-IREF
5668+
self.data: RVariableInAtomicSwcInstanceRef | None = None
5669+
self._assign_optional_strict("data", data, RVariableInAtomicSwcInstanceRef)
5670+
5671+
@classmethod
5672+
def make(cls,
5673+
name: str,
5674+
start_on_event: RunnableEntityRef | str | None = None,
5675+
context_port: AbstractRequiredPortPrototypeRef | None = None,
5676+
target_data_element: VariableDataPrototypeRef | str | None = None,
5677+
**kwargs) -> "DataReceiveErrorEvent":
5678+
"""
5679+
#convenience-method
5680+
5681+
Simplified creation method that automatically creates
5682+
and uses the necessary RVariableInAtomicSwcInstanceRef object
5683+
"""
5684+
data = RVariableInAtomicSwcInstanceRef(context_port, target_data_element)
5685+
return cls(name, start_on_event, data, **kwargs)
5686+
5687+
56355688
class DataReceivedEvent(RteEvent):
56365689
"""
56375690
Complex Type AR:DATA-RECEIVED-EVENT
@@ -5665,6 +5718,40 @@ def make(cls,
56655718
return cls(name, start_on_event, data, **kwargs)
56665719

56675720

5721+
class DataSendCompletedEvent(RteEvent):
5722+
"""
5723+
Complex Type AR:DATA-SEND-COMPLETED-EVENT
5724+
Tag variants: 'DATA-SEND-COMPLETED-EVENT'
5725+
"""
5726+
5727+
def __init__(self,
5728+
name: str,
5729+
start_on_event: RunnableEntityRef | str | None = None,
5730+
event_source: VariableAccessRef | str | None = None,
5731+
**kwargs) -> None:
5732+
super().__init__(name, start_on_event, **kwargs)
5733+
# .EVENT-SOURCE-REF
5734+
self.event_source: VariableAccessRef | None = None
5735+
self._assign_optional("event_source", event_source, VariableAccessRef)
5736+
5737+
5738+
class DataWriteCompletedEvent(RteEvent):
5739+
"""
5740+
Complex Type AR:DATA-WRITE-COMPLETED-EVENT
5741+
Tag variants: 'DATA-WRITE-COMPLETED-EVENT'
5742+
"""
5743+
5744+
def __init__(self,
5745+
name: str,
5746+
start_on_event: RunnableEntityRef | str | None = None,
5747+
event_source: VariableAccessRef | str | None = None,
5748+
**kwargs) -> None:
5749+
super().__init__(name, start_on_event, **kwargs)
5750+
# .EVENT-SOURCE-REF
5751+
self.event_source: VariableAccessRef | None = None
5752+
self._assign_optional("event_source", event_source, VariableAccessRef)
5753+
5754+
56685755
class InitEvent(RteEvent):
56695756
"""
56705757
Complex Type AR:INIT-EVENT
@@ -5673,6 +5760,139 @@ class InitEvent(RteEvent):
56735760
"""
56745761

56755762

5763+
class ModeSwitchedAckEvent(RteEvent):
5764+
"""
5765+
Complex type AR:MODE-SWITCHED-ACK-EVENT
5766+
Tag variants: 'MODE-SWITCHED-ACK-EVENT'
5767+
"""
5768+
5769+
def __init__(self,
5770+
name: str,
5771+
start_on_event: RunnableEntityRef | str | None = None,
5772+
event_source: ModeSwitchPointRef | str | None = None,
5773+
**kwargs) -> None:
5774+
super().__init__(name, start_on_event, **kwargs)
5775+
# .EVENT-SOURCE-REF
5776+
self.event_source: ModeSwitchPointRef | None = None
5777+
self._assign_optional("event_source", event_source, ModeSwitchPointRef)
5778+
5779+
5780+
class OperationInvokedEvent(RteEvent):
5781+
"""
5782+
Complex type AR:OPERATION-INVOKED-EVENT
5783+
Tag variants: 'OPERATION-INVOKED-EVENT'
5784+
"""
5785+
5786+
def __init__(self,
5787+
name: str,
5788+
start_on_event: RunnableEntityRef | str | None = None,
5789+
operation: POperationInAtomicSwcInstanceRef | None = None,
5790+
**kwargs) -> None:
5791+
super().__init__(name, start_on_event, **kwargs)
5792+
# .OPERATION-IREF
5793+
self.operation: POperationInAtomicSwcInstanceRef | None = None
5794+
self._assign_optional_strict("operation", operation, POperationInAtomicSwcInstanceRef)
5795+
5796+
@classmethod
5797+
def make(cls,
5798+
name: str,
5799+
start_on_event: RunnableEntityRef | str | None = None,
5800+
context_port: AbstractProvidedPortPrototypeRef | None = None,
5801+
target_provided_operation: ClientServerOperationRef | str | None = None,
5802+
**kwargs) -> "OperationInvokedEvent":
5803+
"""
5804+
#convenience-method
5805+
5806+
Simplified creation method that automatically creates
5807+
and uses the necessary POperationInAtomicSwcInstanceRef object
5808+
"""
5809+
operation = POperationInAtomicSwcInstanceRef(context_port, target_provided_operation)
5810+
return cls(name, start_on_event, operation, **kwargs)
5811+
5812+
5813+
SwcModeSwitchEventModeType = Union[RModeInAtomicSwcInstanceRef,
5814+
tuple[RModeInAtomicSwcInstanceRef, RModeInAtomicSwcInstanceRef],
5815+
None]
5816+
5817+
5818+
class SwcModeSwitchEvent(RteEvent):
5819+
"""
5820+
Complex type AR:SWC-MODE-SWITCH-EVENT
5821+
Tag variants: 'SWC-MODE-SWITCH-EVENT'
5822+
"""
5823+
5824+
def __init__(self,
5825+
name: str,
5826+
start_on_event: RunnableEntityRef | str | None = None,
5827+
activation: ar_enum.ModeActivationKind | None = None,
5828+
mode: SwcModeSwitchEventModeType = None,
5829+
**kwargs) -> None:
5830+
super().__init__(name, start_on_event, **kwargs)
5831+
# .ACTIVATION
5832+
self.activation: ar_enum.ModeActivationKind | None = None
5833+
# .MODE-IREFS
5834+
self.mode: SwcModeSwitchEventModeType = None
5835+
5836+
self._assign_optional("activation", activation, ar_enum.ModeActivationKind)
5837+
if mode is not None:
5838+
if isinstance(mode, RModeInAtomicSwcInstanceRef):
5839+
self.mode = mode
5840+
elif isinstance(mode, tuple):
5841+
if (isinstance(mode[0], RModeInAtomicSwcInstanceRef) and # noqa W504
5842+
isinstance(mode[1], RModeInAtomicSwcInstanceRef)):
5843+
self.mode = mode
5844+
else:
5845+
raise TypeError("Both values of mode tuple must be of type RModeInAtomicSwcInstanceRef")
5846+
else:
5847+
msg_part1 = "Invalid type for parameter 'mode'. "
5848+
msg_part2 = "Expected types are RModeInAtomicSwcInstanceRef or tuple of same type."
5849+
msg_part3 = f"Got {str(type(mode))}"
5850+
raise TypeError(msg_part1 + msg_part2 + msg_part3)
5851+
5852+
@classmethod
5853+
def make(cls,
5854+
name: str,
5855+
start_on_event: RunnableEntityRef | str | None = None,
5856+
activation: ar_enum.ModeActivationKind | None = None,
5857+
context_port: AbstractRequiredPortPrototypeRef | None = None,
5858+
context_mode_declaration_group_prototype: ModeDeclarationGroupPrototypeRef | None = None,
5859+
target_mode_declaration: ModeDeclarationRef | None = None,
5860+
**kwargs) -> "SwcModeSwitchEvent":
5861+
"""
5862+
#convenience-method
5863+
5864+
Only suitable for ON-ENTRY and ON-EXIT activation types.
5865+
For ON-TRANSITION activation, use the class constructor instead.
5866+
5867+
"""
5868+
mode = RModeInAtomicSwcInstanceRef(context_port,
5869+
context_mode_declaration_group_prototype,
5870+
target_mode_declaration)
5871+
return cls(name, start_on_event, activation, mode, **kwargs)
5872+
5873+
5874+
class TimingEvent(RteEvent):
5875+
"""
5876+
Complex type AR:TIMING-EVENT
5877+
Tag variants: 'TIMING-EVENT'
5878+
"""
5879+
5880+
def __init__(self,
5881+
name: str,
5882+
start_on_event: RunnableEntityRef | str | None = None,
5883+
offset: int | float | None = None,
5884+
period: int | float | None = None,
5885+
**kwargs) -> None:
5886+
super().__init__(name, start_on_event, **kwargs)
5887+
# .OFFSET
5888+
self.offset: int | float | None = None
5889+
# .PERIOD
5890+
self.period: int | float | None = None
5891+
5892+
self._assign_optional("offset", offset, float)
5893+
self._assign_optional("period", period, float)
5894+
5895+
56765896
class InternalBehavior(Identifiable):
56775897
"""
56785898
Group AR:INTERNAL-BEHAVIOR

0 commit comments

Comments
 (0)