Skip to content

Commit 35ede05

Browse files
authored
Merge pull request #889 from BohdanBuinich/fix/arxml-import-consistency
Fix import organization in arxml module
2 parents d76c169 + 92db9d7 commit 35ede05

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

src/canmatrix/formats/arxml.py

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,21 @@
3232
import typing
3333
from builtins import *
3434

35-
import lxml.etree
36-
37-
from canmatrix.CanMatrix import CanMatrix
38-
from canmatrix.Define import Define
39-
from canmatrix.Frame import Frame
40-
from canmatrix.Signal import Signal
41-
from canmatrix.Ecu import Ecu
42-
from canmatrix.Pdu import Pdu
43-
from canmatrix.ArbitrationId import ArbitrationId
35+
import canmatrix.Endpoint
4436
import canmatrix.cancluster
4537
import canmatrix.types
4638
import canmatrix.utils
47-
from canmatrix.FloatFactory import FloatFactory
39+
import lxml.etree
40+
from canmatrix.ArbitrationId import ArbitrationId
4841
from canmatrix.AutosarSecOCProperties import AutosarSecOCProperties
42+
from canmatrix.CanMatrix import CanMatrix, matrix_class
43+
from canmatrix.Define import Define
44+
from canmatrix.Ecu import Ecu
45+
from canmatrix.Endpoint import Endpoint
46+
from canmatrix.FloatFactory import FloatFactory
47+
from canmatrix.Frame import Frame
48+
from canmatrix.Pdu import Pdu
49+
from canmatrix.Signal import Signal
4950

5051
logger = logging.getLogger(__name__)
5152

@@ -164,7 +165,7 @@ def get_short_name(self, element):
164165
# type: (_Element, str) -> str
165166
"""Get element short name."""
166167
return self.sn_cache.get(element, "")
167-
168+
168169
def follow_ref(self, start_element, element_name):
169170
ref_element = self.find(element_name, start_element)
170171
if ref_element is None:
@@ -1223,7 +1224,7 @@ def get_signals(signal_array, frame, ea, multiplex_id, float_factory, bit_offset
12231224

12241225
# To Get Update Bit
12251226
ub_start_bit = ea.get_child(signal, "UPDATE-INDICATION-BIT-POSITION")
1226-
1227+
12271228
isignal = ea.follow_ref(signal, "SIGNAL-REF")
12281229
if isignal is None:
12291230
isignal = ea.follow_ref(signal, "I-SIGNAL-REF") # AR4
@@ -1421,7 +1422,7 @@ def get_signals(signal_array, frame, ea, multiplex_id, float_factory, bit_offset
14211422
else:
14221423
is_signed = False
14231424
is_float = False
1424-
1425+
14251426
unit_element = ea.follow_ref(isignal, "UNIT-REF")
14261427
display_name = ea.get_child(unit_element, "DISPLAY-NAME")
14271428
if display_name is not None:
@@ -1537,7 +1538,7 @@ def get_signals(signal_array, frame, ea, multiplex_id, float_factory, bit_offset
15371538
new_signal.add_attribute("ISignalName", isignal_name)
15381539
if system_signal_name is not None and system_signal_name:
15391540
new_signal.add_attribute("SysSignalName", system_signal_name)
1540-
1541+
15411542
existing_signal = frame.signal_by_name(new_signal.name)
15421543
if existing_signal is None:
15431544
frame.add_signal(new_signal)
@@ -2028,7 +2029,7 @@ def set_frame_trigger_attributes_to_frame(frame_triggering, _frame):
20282029
# does not support "a pdu containing another pdu" this is the only acceptable workaround
20292030
_add_autosar_secoc_signals_to_parent(new_frame) # add secoc-realted signals to Frame
20302031
# new_frame.add_pdu(target_pdu)
2031-
2032+
20322033
comment = ea.get_element_desc(frame_elem)
20332034
if pdu is not None:
20342035
new_frame.add_attribute("PduName", ea.get_short_name(pdu))
@@ -2234,7 +2235,7 @@ def decode_ethernet_helper(ea, float_factory, generated_update_bits_init_to_1: b
22342235

22352236
socket_connetions = ea.findall("SOCKET-CONNECTION-IPDU-IDENTIFIER")
22362237
pdu_triggering_header_id_map = {}
2237-
2238+
22382239
for socket_connetion in socket_connetions:
22392240
header_id = ea.get_child(socket_connetion, "HEADER-ID")
22402241
ipdu_triggering = ea.follow_ref(socket_connetion, "PDU-TRIGGERING-REF")
@@ -2247,12 +2248,12 @@ def decode_ethernet_helper(ea, float_factory, generated_update_bits_init_to_1: b
22472248
for ec in ecs:
22482249
baudrate_elem = ea.find("BAUDRATE", ec)
22492250
physical_channels = ea.findall("ETHERNET-PHYSICAL-CHANNEL", ec)
2250-
2251+
22512252
for pc in physical_channels:
2252-
db = CanMatrix(type=canmatrix.matrix_class.SOMEIP)
2253+
db = CanMatrix(type=matrix_class.SOMEIP)
22532254

22542255
db.baudrate = int(baudrate_elem.text, 0) if baudrate_elem is not None else 0
2255-
2256+
22562257
channel_name = ea.get_element_name(pc)
22572258

22582259
vlan = ea.get_child(pc, "VLAN")
@@ -2288,7 +2289,7 @@ def decode_ethernet_helper(ea, float_factory, generated_update_bits_init_to_1: b
22882289
get_text = lambda el: el.text if el is not None else None
22892290
get_int = lambda el: int(el.text, 0) if el is not None else 0
22902291

2291-
endpoint = canmatrix.Endpoint(
2292+
endpoint = Endpoint(
22922293
server_ipv4=get_text(server_ipv4),
22932294
server_ipv6=get_text(server_ipv6),
22942295
server_port=get_int(server_port),
@@ -2322,7 +2323,7 @@ def decode_ethernet_helper(ea, float_factory, generated_update_bits_init_to_1: b
23222323

23232324
# Size
23242325
ipdu_length = int(ea.get_child(ipdu, "LENGTH").text, 0)
2325-
2326+
23262327
# Cycle-Time
23272328
timing_spec = ea.get_child(ipdu, "I-PDU-TIMING-SPECIFICATION")
23282329
if timing_spec is None:
@@ -2333,7 +2334,7 @@ def decode_ethernet_helper(ea, float_factory, generated_update_bits_init_to_1: b
23332334
cycle_time = 0
23342335
if value is not None:
23352336
cycle_time = int(float_factory(value.text) * 1000)
2336-
2337+
23372338
# print(ipdu.tag)
23382339
# if ipdu is not None and 'SECURED-I-PDU' in ipdu.tag:
23392340
# print("get IN?")
@@ -2365,14 +2366,14 @@ def decode_ethernet_helper(ea, float_factory, generated_update_bits_init_to_1: b
23652366
target_frame.add_receiver(ecu.name)
23662367
else:
23672368
pass
2368-
2369+
23692370
pdu_sig_mapping = ea.findall("I-SIGNAL-TO-I-PDU-MAPPING", ipdu)
23702371

23712372
get_signals(pdu_sig_mapping, target_frame, ea, None, float_factory,
23722373
generated_update_bits_init_to_1=generated_update_bits_init_to_1)
23732374
# target_frame.update_receiver() # It will make transmitter and receiver worse
23742375
db.add_frame(target_frame)
2375-
2376+
23762377
return found_matrixes
23772378

23782379

@@ -2480,7 +2481,7 @@ def decode_can_helper(ea, float_factory, ignore_cluster_info, generated_update_b
24802481
generated_update_bits_init_to_1)
24812482
if frame is not None:
24822483
frame.is_j1939 = "J-1939" in cc.tag
2483-
2484+
24842485
comm_directions = ea.selector(frameTrig, ">>FRAME-PORT-REF/COMMUNICATION-DIRECTION")
24852486
for comm_direction in comm_directions:
24862487
ecu_elem = ea.get_ecu_instance(element=comm_direction)

0 commit comments

Comments
 (0)