Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if tokens[9]:
comment = _load_comment(tokens[9][0])
# The rest.
unit, factor, offset, enum, minimum, maximum, decimal = _load_signal_attributes(
tokens[8],
enum,
enums,
minimum,
maximum,
decimal)
if byte_order == 'big_endian':
start = (8 * (start // 8) + (7 - (start % 8)))
return Signal(name=name,
start=start,
length=length,
receivers=[],
byte_order=byte_order,
is_signed=is_signed,
scale=factor,
offset=offset,
minimum=minimum,
maximum=maximum,
unit=unit,
choices=enum,
comment=comment,
is_multiplexer=False,
multiplexer_ids=multiplexer_ids,
multiplexer_signal=multiplexer_signal,
is_float=is_float,
for label in label_set.iterfind('ns:Label', NAMESPACES):
label_value = int(label.attrib['value'])
label_name = label.attrib['name']
labels[label_value] = label_name
# TODO: Label groups.
# Receivers.
consumer = signal.find('ns:Consumer', NAMESPACES)
if consumer is not None:
for receiver in consumer.iterfind('ns:NodeRef', NAMESPACES):
receivers.append(_get_node_name_by_id(nodes,
receiver.attrib['id']))
return Signal(name=name,
start=_start_bit(offset, byte_order),
length=length,
receivers=receivers,
byte_order=byte_order,
is_signed=is_signed,
scale=slope,
offset=intercept,
minimum=minimum,
maximum=maximum,
unit=unit,
choices=labels,
comment=notes,
is_float=is_float,
decimal=decimal)
# Unit and comment.
unit = self.load_signal_unit(system_signal)
comment = self.load_signal_comment(system_signal)
# Minimum, maximum, factor, offset and choices.
minimum, maximum, factor, offset, choices = self.load_system_signal(
system_signal,
decimal)
# Type.
is_signed, is_float = self.load_signal_type(i_signal)
# ToDo: receivers
return Signal(name=name,
start=start_position,
length=length,
receivers=receivers,
byte_order=byte_order,
is_signed=is_signed,
scale=factor,
offset=offset,
minimum=minimum,
maximum=maximum,
unit=unit,
choices=choices,
comment=comment,
is_float=is_float,
decimal=decimal)
byte_order = 'big_endian'
# Comment.
if tokens[8]:
comment = _load_comment(tokens[8][0])
# The rest.
unit, factor, offset, enum, minimum, maximum, decimal = _load_signal_attributes(
tokens[7],
enum,
enums,
minimum,
maximum,
decimal)
return Signal(name=name,
start=offset,
length=length,
receivers=[],
byte_order=byte_order,
is_signed=is_signed,
scale=factor,
offset=offset,
minimum=minimum,
maximum=maximum,
unit=unit,
choices=enum,
comment=comment,
is_multiplexer=False,
is_float=is_float,
decimal=decimal)
except (KeyError, TypeError):
return name
def get_signal_initial_value(frame_id_dbc, name):
signal_attributes = get_attributes(frame_id_dbc, name)
try:
return signal_attributes['GenSigStartValue'].value
except (KeyError, TypeError):
return None
signals = []
for signal in tokens:
signals.append(
Signal(name=get_signal_name(frame_id_dbc, signal[1][0]),
start=int(signal[3]),
length=int(signal[5]),
receivers=get_receivers(signal[20]),
byte_order=('big_endian'
if signal[7] == '0'
else 'little_endian'),
is_signed=(signal[8] == '-'),
initial=get_signal_initial_value(frame_id_dbc, signal[1][0]),
scale=num(signal[10]),
offset=num(signal[12]),
minimum=get_minimum(signal[15], signal[17]),
maximum=get_maximum(signal[15], signal[17]),
decimal=SignalDecimal(Decimal(signal[10]),
Decimal(signal[12]),
get_minimum_decimal(signal[15],
signal[17]),
return None
if length is None:
LOGGER.warning('No bit size found for signal %s.', name)
return None
if byte_order is None:
LOGGER.warning('No endianness found for signal %s.', name)
return None
# ToDo: minimum, maximum, factor, offset, unit, choices,
# comment and receivers.
return Signal(name=name,
start=bit_position,
length=length,
receivers=receivers,
byte_order=byte_order,
is_signed=is_signed,
scale=factor,
offset=offset,
minimum=minimum,
maximum=maximum,
unit=unit,
choices=choices,
comment=comment,
is_float=is_float,
decimal=decimal)