Skip to content

Commit 30b366d

Browse files
tainnokMarkus Konradebroecker
authored
arxml: read data related to E2E-protection (#594)
* read informations about E2E-Profiles (of I-Signalgroup) into the canmatrix-object * also read informations about E2E-Profiles (of I-Signalgroup) into the canmatrix-object if a Container-PDU is processed Co-authored-by: Markus Konrad <[email protected]> Co-authored-by: Eduard Bröcker <[email protected]>
1 parent 8ccb76b commit 30b366d

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

Diff for: src/canmatrix/canmatrix.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ class SignalGroup(object):
465465
name = attr.ib() # type: str
466466
id = attr.ib() # type: int
467467
signals = attr.ib(factory=list, repr=False) # type: typing.MutableSequence[Signal]
468+
e2e_trans = attr.ib(default=None)
468469

469470
def add_signal(self, signal): # type: (Signal) -> None
470471
"""Add a Signal to SignalGroup.
@@ -788,15 +789,15 @@ def add_signal(self, signal):
788789
"""
789790
self.signals.append(signal)
790791
return self.signals[len(self.signals) - 1]
791-
def add_signal_group(self, Name, Id, signalNames):
792+
def add_signal_group(self, Name, Id, signalNames, e2e_trans=None):
792793
# type: (str, int, typing.Sequence[str]) -> None
793794
"""Add new SignalGroup to the Frame. Add given signals to the group.
794795
795796
:param str Name: Group name
796797
:param int Id: Group id
797798
:param list of str signalNames: list of Signal names to add. Non existing names are ignored.
798799
"""
799-
newGroup = SignalGroup(Name, Id)
800+
newGroup = SignalGroup(Name, Id, e2e_trans=e2e_trans)
800801
self.signalGroups.append(newGroup)
801802
for signal in signalNames:
802803
signal = signal.strip()
@@ -996,15 +997,15 @@ def __iter__(self): # type: () -> typing.Iterator[Signal]
996997

997998
return iter(self.signals)
998999

999-
def add_signal_group(self, Name, Id, signalNames):
1000+
def add_signal_group(self, Name, Id, signalNames, e2e_trans=None):
10001001
# type: (str, int, typing.Sequence[str]) -> None
10011002
"""Add new SignalGroup to the Frame. Add given signals to the group.
10021003
10031004
:param str Name: Group name
10041005
:param int Id: Group id
10051006
:param list of str signalNames: list of Signal names to add. Non existing names are ignored.
10061007
"""
1007-
newGroup = SignalGroup(Name, Id)
1008+
newGroup = SignalGroup(Name, Id, e2e_trans=e2e_trans)
10081009
self.signalGroups.append(newGroup)
10091010
for signal in signalNames:
10101011
signal = signal.strip()

Diff for: src/canmatrix/formats/arxml.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -973,10 +973,22 @@ def dump(dbs, f, **options):
973973
frames_cache = {} # type: typing.Dict[_Element, canmatrix.Frame]
974974

975975

976-
def get_sys_signals(sys_signal, sys_signal_array, frame, group_id, ea):
976+
def get_signalgrp_and_signals(sys_signal, sys_signal_array, frame, group_id, ea):
977977
# type: (_Element, typing.Sequence[_Element], canmatrix.Frame, int, str) -> None
978978
members = [ea.get_element_name(signal) for signal in sys_signal_array]
979-
frame.add_signal_group(ea.get_element_name(sys_signal), group_id, members)
979+
980+
# get data related to E2E-Protection
981+
transform_ele = ea.follow_ref(sys_signal, "TRANSFORMER-REF")
982+
e2e_transform = None
983+
if transform_ele is not None:
984+
e2e_transform = {
985+
'profile': ea.get_child(transform_ele, "PROFILE-NAME").text,
986+
}
987+
data_id_elems = ea.get_children(ea.get_child(sys_signal, "TRANSFORMATION-I-SIGNAL-PROPSS"), "DATA-ID")
988+
if data_id_elems is not None:
989+
e2e_transform['data_ids'] = [int(x.text) for x in data_id_elems]
990+
991+
frame.add_signal_group(ea.get_element_name(sys_signal), group_id, members, e2e_transform)
980992

981993

982994
def decode_compu_method(compu_method, ea, float_factory):
@@ -1087,12 +1099,9 @@ def get_signals(signal_array, frame, ea, multiplex_id, float_factory, bit_offset
10871099
isignal = ea.follow_ref(signal, "I-SIGNAL-GROUP-REF")
10881100
if isignal is not None:
10891101
logger.debug("get_signals: found I-SIGNAL-GROUP ")
1090-
10911102
isignal_array = ea.follow_all_ref(isignal, "I-SIGNAL-REF")
1103+
get_signalgrp_and_signals(isignal, isignal_array, frame, group_id, ea)
10921104

1093-
system_signal_array = [ea.follow_ref(isignal, "SYSTEM-SIGNAL-REF") for isignal in isignal_array]
1094-
system_signal_group = ea.follow_ref(isignal, "SYSTEM-SIGNAL-GROUP-REF")
1095-
get_sys_signals(system_signal_group, system_signal_array, frame, group_id, ea)
10961105
group_id = group_id + 1
10971106
continue
10981107
if isignal is None:

0 commit comments

Comments
 (0)