code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def phys2raw(self, value=None):
# type: (canmatrix.types.OptionalPhysicalValue) -> canmatrix.types.RawValue
"""Return the raw value (= as is on CAN).
:param value: (scaled) value compatible with `decimal` or value choice to encode
:return: raw unscaled value as it appears on the bus
... | Return the raw value (= as is on CAN).
:param value: (scaled) value compatible with `decimal` or value choice to encode
:return: raw unscaled value as it appears on the bus
:rtype: int or decimal.Decimal
| phys2raw | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def raw2phys(self, value, decode_to_str=False):
# type: (canmatrix.types.RawValue, bool) -> typing.Union[canmatrix.types.PhysicalValue, str]
"""Decode the given raw value (= as is on CAN).
:param value: raw value compatible with `decimal`.
:param bool decode_to_str: If True, try to get ... | Decode the given raw value (= as is on CAN).
:param value: raw value compatible with `decimal`.
:param bool decode_to_str: If True, try to get value representation as *string* ('Init' etc.)
:return: physical value (scaled)
| raw2phys | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def by_name(self, name): # type: (str) -> typing.Union[Signal, None]
"""
Find a Signal in the group by Signal name.
:param str name: Signal name to find
:return: signal contained in the group identified by name
:rtype: Signal
"""
for test in self.signals:
... |
Find a Signal in the group by Signal name.
:param str name: Signal name to find
:return: signal contained in the group identified by name
:rtype: Signal
| by_name | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def grouper(iterable, n, fillvalue=None):
"""Collect data into fixed-length chunks or blocks."""
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
args = [iter(iterable)] * n
return zip_longest(*args, fillvalue=fillvalue) | Collect data into fixed-length chunks or blocks. | grouper | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def unpack_bitstring(length, is_float, is_signed, bits):
# type: (int, bool, bool, typing.Any) -> typing.Union[float, int]
"""
returns a value calculated from bits
:param length: length of signal in bits
:param is_float: value is float
:param bits: value as bits (array/iterable)
:param is_si... |
returns a value calculated from bits
:param length: length of signal in bits
:param is_float: value is float
:param bits: value as bits (array/iterable)
:param is_signed: value is signed
:return:
| unpack_bitstring | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def pack_bitstring(length, is_float, value, signed):
"""
returns a value in bits
:param length: length of signal in bits
:param is_float: value is float
:param value: value to encode
:param signed: value is signed
:return:
"""
if is_float:
types = {
32: '>f',
... |
returns a value in bits
:param length: length of signal in bits
:param is_float: value is float
:param value: value to encode
:param signed: value is signed
:return:
| pack_bitstring | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_signal(self, signal):
# type: (Signal) -> Signal
"""
Add Signal to Pdu.
:param Signal signal: Signal to be added.
:return: the signal added.
"""
self.signals.append(signal)
return self.signals[len(self.signals) - 1] |
Add Signal to Pdu.
:param Signal signal: Signal to be added.
:return: the signal added.
| add_signal | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_signal_group(self,
Name: str,
Id: int,
signalNames: typing.Sequence[str],
e2e_properties: typing.Optional[AutosarE2EProperties] = None) -> None:
"""Add new SignalGroup to the Frame. Add given signals ... | Add new SignalGroup to the Frame. Add given signals to the group.
:param str Name: Group name
:param int Id: Group id
:param list of str signalNames: list of Signal names to add. Non existing names are ignored.
| add_signal_group | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def signal_by_name(self, name):
# type: (str) -> typing.Union[Signal, None]
"""
Get signal by name.
:param str name: signal name to be found.
:return: signal with given name or None if not found
"""
for signal in self.signals:
if signal.name == name:
... |
Get signal by name.
:param str name: signal name to be found.
:return: signal with given name or None if not found
| signal_by_name | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def is_multiplexed(self): # type: () -> bool
"""Frame is multiplexed if at least one of its signals is a multiplexer."""
for sig in self.signals:
if sig.is_multiplexer:
return True
return False | Frame is multiplexed if at least one of its signals is a multiplexer. | is_multiplexed | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def get_multiplexer(self): # type: () -> typing.Union[Signal, None]
"""get multiplexer signal if any in frame."""
for sig in self.signals:
if sig.is_multiplexer:
return sig
return None | get multiplexer signal if any in frame. | get_multiplexer | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def get_signals_for_multiplexer_value(self, mux_value):
# type: (int) -> typing.Sequence[Signal]
"""Find Frame Signals by given muxer value.
:param int mux_value: muxer value
:return: list of signals relevant for given muxer value.
:rtype: list of signals
"""
muxe... | Find Frame Signals by given muxer value.
:param int mux_value: muxer value
:return: list of signals relevant for given muxer value.
:rtype: list of signals
| get_signals_for_multiplexer_value | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def effective_cycle_time(self):
"""Calculate effective cycle time for frame, depending on singal cycle times"""
min_cycle_time_list = [y for y in [x.cycle_time for x in self.signals] + [self.cycle_time] if y != 0]
if len(min_cycle_time_list) == 0:
return 0
elif len(min_cycle_... | Calculate effective cycle time for frame, depending on singal cycle times | effective_cycle_time | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def attribute(self, attribute_name, db=None, default=None):
# type: (str, typing.Optional[CanMatrix], typing.Any) -> typing.Any
"""Get any Frame attribute by its name.
:param str attribute_name: attribute name, can be mandatory (ex: id) or optional (customer) attribute.
:param CanMatrix... | Get any Frame attribute by its name.
:param str attribute_name: attribute name, can be mandatory (ex: id) or optional (customer) attribute.
:param CanMatrix db: Optional database parameter to get global default attribute value.
:param default: Default value if attribute doesn't exist.
:... | attribute | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def signal_group_by_name(self, name):
# type: (str) -> typing.Union[SignalGroup, None]
"""Get signal group.
:param str name: group name
:return: SignalGroup by name or None if not found.
:rtype: SignalGroup
"""
for signalGroup in self.signalGroups:
if... | Get signal group.
:param str name: group name
:return: SignalGroup by name or None if not found.
:rtype: SignalGroup
| signal_group_by_name | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_pdu(self, pdu):
# type: (Pdu) -> Pdu
"""
Add Pdu to Frame.
:param Pdu pdu: Pdu to be added.
:return: the pdu added.
"""
self.pdus.append(pdu)
return self.pdus[len(self.pdus) - 1] |
Add Pdu to Frame.
:param Pdu pdu: Pdu to be added.
:return: the pdu added.
| add_pdu | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def pdu_by_name(self, name):
# type: (str) -> typing.Union[Pdu, None]
"""Get PDU.
:param str name: PDU name
:return: PDU by name or None if not found.
:rtype: Pdu
"""
for pdu in self.pdus:
if pdu.name == name:
return pdu
return... | Get PDU.
:param str name: PDU name
:return: PDU by name or None if not found.
:rtype: Pdu
| pdu_by_name | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def pdu_by_id(self, pdu_id):
# type: (int) -> typing.Union[Pdu, None]
"""Get PDU.
:param int pdu_id: PDU id
:return: PDU by id or None if not found.
:rtype: Pdu
"""
for pdu in self.pdus:
if pdu.id == pdu_id:
return pdu
return N... | Get PDU.
:param int pdu_id: PDU id
:return: PDU by id or None if not found.
:rtype: Pdu
| pdu_by_id | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_signal(self, signal):
# type: (Signal) -> Signal
"""
Add Signal to Frame.
:param Signal signal: Signal to be added.
:return: the signal added.
"""
self.signals.append(signal)
return self.signals[len(self.signals) - 1] |
Add Signal to Frame.
:param Signal signal: Signal to be added.
:return: the signal added.
| add_signal | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_receiver(self, receiver):
# type: (str) -> None
"""Add receiver ECU Name to Frame.
:param str receiver: receiver name
"""
if receiver not in self.receivers:
self.receivers.append(receiver) | Add receiver ECU Name to Frame.
:param str receiver: receiver name
| add_receiver | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def glob_signals(self, glob_str):
# type: (str) -> typing.Sequence[Signal]
"""Find Frame Signals by given glob pattern.
:param str glob_str: glob pattern for signal name. See `fnmatch.fnmatchcase`
:return: list of Signals by glob pattern.
:rtype: list of Signal
"""
... | Find Frame Signals by given glob pattern.
:param str glob_str: glob pattern for signal name. See `fnmatch.fnmatchcase`
:return: list of Signals by glob pattern.
:rtype: list of Signal
| glob_signals | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_attribute(self, attribute, value):
# type: (str, typing.Any) -> None
"""
Add the attribute with value to customer Frame attribute-list. If Attribute already exits, modify its value.
:param str attribute: Attribute name
:param any value: attribute value
"""
... |
Add the attribute with value to customer Frame attribute-list. If Attribute already exits, modify its value.
:param str attribute: Attribute name
:param any value: attribute value
| add_attribute | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def del_attribute(self, attribute):
# type: (str) -> typing.Any
"""
Remove attribute from customer Frame attribute-list.
:param str attribute: Attribute name
"""
if attribute in self.attributes:
del self.attributes[attribute] |
Remove attribute from customer Frame attribute-list.
:param str attribute: Attribute name
| del_attribute | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_comment(self, comment):
# type: (str) -> None
"""
Set Frame comment.
:param str comment: Frame comment
"""
self.comment = comment |
Set Frame comment.
:param str comment: Frame comment
| add_comment | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def calc_dlc(self):
# type: () -> None
"""
Compute minimal Frame DLC (length) based on its Signals
:return: Message DLC
"""
max_bit = 0
for sig in self.signals:
if sig.get_startbit() + int(sig.size) > max_bit:
max_bit = sig.get_startbi... |
Compute minimal Frame DLC (length) based on its Signals
:return: Message DLC
| calc_dlc | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def fit_dlc(self):
"""
Compute next allowed DLC (length) for current Frame
"""
max_byte = self.size
last_size = 8
for max_size in [12, 16, 20, 24, 32, 48, 64]:
if max_byte > last_size and max_byte < max_size:
self.size = max_size
... |
Compute next allowed DLC (length) for current Frame
| fit_dlc | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def get_frame_layout(self):
# type: () -> typing.Sequence[typing.Sequence[str]]
"""
get layout of frame.
Represents the bit usage in the frame by means of a list with n items (n bits of frame length).
Every item represents one bit and contains a list of signals (object refs) wit... |
get layout of frame.
Represents the bit usage in the frame by means of a list with n items (n bits of frame length).
Every item represents one bit and contains a list of signals (object refs) with each signal, occupying that bit.
Bits with empty list are unused.
Example: [[], ... | get_frame_layout | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def create_dummy_signals(self): # type: () -> None
"""Create big-endian dummy signals for unused bits.
Names of dummy signals are *_Dummy_<frame.name>_<index>*
"""
bitfield = self.get_frame_layout()
startBit = -1
sigCount = 0
for index, bit_signals in enumerate(... | Create big-endian dummy signals for unused bits.
Names of dummy signals are *_Dummy_<frame.name>_<index>*
| create_dummy_signals | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def update_receiver(self): # type: () -> None
"""
Collect Frame receivers out of receiver given in each signal. Add them to `self.receiver` list.
"""
self.receivers = []
for sig in self.signals:
for receiver in sig.receivers:
self.add_receiver(receive... |
Collect Frame receivers out of receiver given in each signal. Add them to `self.receiver` list.
| update_receiver | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def signals_to_bytes(self, data):
# type: (typing.Mapping[str, canmatrix.types.RawValue]) -> bytes
"""Return a byte string containing the values from data packed
according to the frame format.
:param data: data dictionary of signal : rawValue
:return: A byte string of the packed... | Return a byte string containing the values from data packed
according to the frame format.
:param data: data dictionary of signal : rawValue
:return: A byte string of the packed values.
| signals_to_bytes | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def encode(self, data=None):
# type: (typing.Optional[typing.Mapping[str, typing.Any]]) -> bytes
"""Return a byte string containing the values from data packed
according to the frame format.
:param dict data: data dictionary
:return: A byte string of the packed values.
"... | Return a byte string containing the values from data packed
according to the frame format.
:param dict data: data dictionary
:return: A byte string of the packed values.
| encode | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def bytes_to_bitstrings(data):
# type: (bytes) -> typing.Tuple[str, str]
"""Return two arrays big and little containing bits of given data (bytearray)
:param data: bytearray of bits (little endian).
i.e. bytearray([0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8])
:return: bi... | Return two arrays big and little containing bits of given data (bytearray)
:param data: bytearray of bits (little endian).
i.e. bytearray([0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8])
:return: bit arrays in big and little byteorder
| bytes_to_bitstrings | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def bitstring_to_signal_list(signals, big, little, size):
# type: (typing.Sequence[Signal], str, str, int) -> typing.Sequence[canmatrix.types.RawValue]
"""Return OrderedDictionary with Signal Name: object decodedSignal (flat / without support for multiplexed frames)
:param signals: Iterable of ... | Return OrderedDictionary with Signal Name: object decodedSignal (flat / without support for multiplexed frames)
:param signals: Iterable of signals (class signal) to decode from frame.
:param big: bytearray of bits (big endian).
:param little: bytearray of bits (little endian).
:param s... | bitstring_to_signal_list | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def unpack(self, data: bytes,
allow_truncated: bool = False,
allow_exceeded: bool = False,
) -> typing.Mapping[str, DecodedSignal]:
"""Return OrderedDictionary with Signal Name: object decodedSignal (flat / without support for multiplexed frames)
decodes ever... | Return OrderedDictionary with Signal Name: object decodedSignal (flat / without support for multiplexed frames)
decodes every signal in signal-list.
:param data: bytearray
i.e. bytearray([0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8])
:param report_error: set to False to silence e... | unpack | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def _get_sub_multiplexer(self, parent_multiplexer_name, parent_multiplexer_value):
"""
get any sub-multiplexer in frame used
for complex-multiplexed frame decoding
:param parent_multiplexer_name: string with name of parent multiplexer
:param parent_multiplexer_value: raw_value (... |
get any sub-multiplexer in frame used
for complex-multiplexed frame decoding
:param parent_multiplexer_name: string with name of parent multiplexer
:param parent_multiplexer_value: raw_value (int) of parent multiplexer
:return: muxer signal or None
| _get_sub_multiplexer | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def _filter_signals_for_multiplexer(self, multiplexer_name, multiplexer_value):
"""
filter a list of signals with given multiplexer (name and value)
used for complex-multiplexed frame decoding
:param multiplexer_name: string with name of parent multiplexer
:param multiplexer_va... |
filter a list of signals with given multiplexer (name and value)
used for complex-multiplexed frame decoding
:param multiplexer_name: string with name of parent multiplexer
:param multiplexer_value: raw_value (int) of parent multiplexer
:return: filtered array of canmatrix.Sig... | _filter_signals_for_multiplexer | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def decode(self, data):
# type: (bytes) -> typing.Mapping[str, typing.Any]
"""Return OrderedDictionary with Signal Name: object decodedSignal (support for multiplexed frames)
decodes only signals matching to muxgroup
:param data: bytearray .
i.e. bytearray([0xA1, 0xA2, 0xA3,... | Return OrderedDictionary with Signal Name: object decodedSignal (support for multiplexed frames)
decodes only signals matching to muxgroup
:param data: bytearray .
i.e. bytearray([0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8])
:return: OrderedDictionary
| decode | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def multiplex_signals(self):
"""Assign multiplexer to signals. When a multiplexor is in the frame."""
multiplexor = self.get_multiplexer
if multiplexor is None:
return
for signal in self.signals:
if signal.is_multiplexer or (signal.muxer_for_signal is not None):
... | Assign multiplexer to signals. When a multiplexor is in the frame. | multiplex_signals | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def __init__(self, definition): # type (str) -> None
"""Initialize Define object.
:param str definition: definition string. Ex: "INT -5 10"
"""
definition = definition.strip()
self.definition = definition
self.type = None # type: typing.Optional[str]
self.defau... | Initialize Define object.
:param str definition: definition string. Ex: "INT -5 10"
| __init__ | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def safe_convert_str_to_int(inStr): # type: (str) -> int
"""Convert string to int safely. Check that it isn't float.
:param str inStr: integer represented as string.
:rtype: int
"""
out = int(defaultFloatFactory(inStr))
if out != defaultFloatFact... | Convert string to int safely. Check that it isn't float.
:param str inStr: integer represented as string.
:rtype: int
| safe_convert_str_to_int | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def set_default(self, default): # type: (typing.Any) -> None
"""Set Definition default value.
:param default: default value; number, str or quoted str ("value")
"""
if default is not None and len(default) > 1 and default[0] == '"' and default[-1] == '"':
default = default[1... | Set Definition default value.
:param default: default value; number, str or quoted str ("value")
| set_default | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def update(self): # type: () -> None
"""Update definition string for type ENUM.
For type ENUM rebuild the definition string from current values. Otherwise do nothing.
"""
if self.type != 'ENUM':
return
self.definition = 'ENUM "' + '","' .join(self.values) +'"' | Update definition string for type ENUM.
For type ENUM rebuild the definition string from current values. Otherwise do nothing.
| update | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def contains_j1939(self): # type: () -> bool
"""Check whether the Matrix contains any J1939 Frame."""
for frame in self.frames:
if frame.is_j1939:
return True
return False | Check whether the Matrix contains any J1939 Frame. | contains_j1939 | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def attribute(self, attributeName, default=None): # type(str, typing.Any) -> typing.Any
"""Return custom Matrix attribute by name.
:param str attributeName: attribute name
:param default: default value if given attribute doesn't exist
:return: attribute value or default or None if no s... | Return custom Matrix attribute by name.
:param str attributeName: attribute name
:param default: default value if given attribute doesn't exist
:return: attribute value or default or None if no such attribute found.
| attribute | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_attribute(self, attribute, value): # type: (str, typing.Any) -> None
"""
Add attribute to Matrix attribute-list.
:param str attribute: attribute name
:param value: attribute value
"""
try:
self.attributes[attribute] = str(value)
except Unicod... |
Add attribute to Matrix attribute-list.
:param str attribute: attribute name
:param value: attribute value
| add_attribute | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_signal_defines(self, type, definition):
"""
Add signal-attribute definition to canmatrix.
:param str type: signal type
:param str definition: signal-attribute string definition, see class Define
"""
if type not in self.signal_defines:
self.signal_defi... |
Add signal-attribute definition to canmatrix.
:param str type: signal type
:param str definition: signal-attribute string definition, see class Define
| add_signal_defines | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_frame_defines(self, name, definition): # type: (str, str) -> None
"""
Add frame-attribute definition to canmatrix.
:param str name: frame type
:param str definition: frame definition as string
"""
if name not in self.frame_defines:
self.frame_defines... |
Add frame-attribute definition to canmatrix.
:param str name: frame type
:param str definition: frame definition as string
| add_frame_defines | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_ecu_defines(self, name, definition): # type: (str, str) -> None
"""
Add Boardunit-attribute definition to canmatrix.
:param str name: Boardunit type
:param str definition: BU definition as string
"""
if name not in self.ecu_defines:
self.ecu_defines[... |
Add Boardunit-attribute definition to canmatrix.
:param str name: Boardunit type
:param str definition: BU definition as string
| add_ecu_defines | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_env_defines(self, name, definition): # type: (str, str) -> None
"""
Add enviroment variable-attribute definition to canmatrix.
:param str name: enviroment variable type
:param str definition: enviroment variable definition as string
"""
if name not in self.env_d... |
Add enviroment variable-attribute definition to canmatrix.
:param str name: enviroment variable type
:param str definition: enviroment variable definition as string
| add_env_defines | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_global_defines(self, name, definition): # type: (str, str) -> None
"""
Add global-attribute definition to canmatrix.
:param str name: attribute type
:param str definition: attribute definition as string
"""
if name not in self.global_defines:
self.gl... |
Add global-attribute definition to canmatrix.
:param str name: attribute type
:param str definition: attribute definition as string
| add_global_defines | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def delete_obsolete_defines(self): # type: () -> None
"""Delete all unused Defines.
Delete them from frame_defines, ecu_defines and signal_defines.
"""
defines_to_delete = set() # type: typing.Set[str]
for frameDef in self.frame_defines:
for frame in self.frames:
... | Delete all unused Defines.
Delete them from frame_defines, ecu_defines and signal_defines.
| delete_obsolete_defines | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def frame_by_id(self, arbitration_id): # type: (ArbitrationId) -> typing.Union[Frame, None]
"""Get Frame by its arbitration id.
:param ArbitrationId arbitration_id: Frame id as canmatrix.ArbitrationId
:rtype: Frame or None
"""
hash_name = f"{arbitration_id.id}_{arbitration_id.e... | Get Frame by its arbitration id.
:param ArbitrationId arbitration_id: Frame id as canmatrix.ArbitrationId
:rtype: Frame or None
| frame_by_id | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def frame_by_header_id(self, header_id): # type: (HeaderId) -> typing.Union[Frame, None]
"""Get Frame by its Header id.
:param HeaderId header_id: Header id as canmatrix.header_id
:rtype: Frame or None
"""
for test in self.frames:
if test.header_id == header_id:
... | Get Frame by its Header id.
:param HeaderId header_id: Header id as canmatrix.header_id
:rtype: Frame or None
| frame_by_header_id | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def get_frame_by_id(self, id: int
) -> typing.Union[Frame, None]:
"""Get Frame by id.
:param str name: Frame id to search for
:rtype: Frame or None
"""
return self.frames_dict_id[id] | Get Frame by id.
:param str name: Frame id to search for
:rtype: Frame or None
| get_frame_by_id | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def frame_by_pgn(self, pgn): # type: (int) -> typing.Union[Frame, None]
"""Get Frame by pgn (j1939).
:param int pgn: pgn to search for
:rtype: Frame or None
"""
for test in self.frames:
if test.arbitration_id.pgn == canmatrix.ArbitrationId.from_pgn(pgn).pgn:
... | Get Frame by pgn (j1939).
:param int pgn: pgn to search for
:rtype: Frame or None
| frame_by_pgn | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def frame_by_name(self, name): # type: (str) -> typing.Union[Frame, None]
"""Get Frame by name.
:param str name: Frame name to search for
:rtype: Frame or None
"""
for test in self.frames:
if test.name == name:
return test
return None | Get Frame by name.
:param str name: Frame name to search for
:rtype: Frame or None
| frame_by_name | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def glob_frames(self, globStr): # type: (str) -> typing.List[Frame]
"""Find Frames by given glob pattern.
:param str globStr: glob pattern to filter Frames. See `fnmatch.fnmatchcase`.
:rtype: list of Frame
"""
return_array = []
for test in self.frames:
if fn... | Find Frames by given glob pattern.
:param str globStr: glob pattern to filter Frames. See `fnmatch.fnmatchcase`.
:rtype: list of Frame
| glob_frames | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def ecu_by_name(self, name): # type: (str) -> typing.Union[Ecu, None]
"""
Returns Boardunit by Name.
:param str name: BoardUnit name
:rtype: Ecu or None
"""
for test in self.ecus:
if test.name == name:
return test
return None |
Returns Boardunit by Name.
:param str name: BoardUnit name
:rtype: Ecu or None
| ecu_by_name | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def glob_ecus(self, globStr): # type: (str) -> typing.List[Ecu]
"""
Find ECUs by given glob pattern.
:param globStr: glob pattern to filter BoardUnits. See `fnmatch.fnmatchcase`.
:rtype: list of Ecu
"""
return_array = []
for test in self.ecus:
if fnm... |
Find ECUs by given glob pattern.
:param globStr: glob pattern to filter BoardUnits. See `fnmatch.fnmatchcase`.
:rtype: list of Ecu
| glob_ecus | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_frame(self, frame): # type: (Frame) -> Frame
"""Add the Frame to the Matrix.
:param Frame frame: Frame to add
:return: the inserted Frame
"""
self.frames.append(frame)
self._frames_dict_id_extend = {}
self.frames_dict_name[frame.name] = frame
if ... | Add the Frame to the Matrix.
:param Frame frame: Frame to add
:return: the inserted Frame
| add_frame | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def remove_frame(self, frame): # type: (Frame) -> None
"""Remove the Frame from Matrix.
:param Frame frame: frame to remove from CAN Matrix
"""
self.frames.remove(frame)
self._frames_dict_id_extend = {} | Remove the Frame from Matrix.
:param Frame frame: frame to remove from CAN Matrix
| remove_frame | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def delete_zero_signals(self): # type: () -> None
"""Delete all signals with zero bit width from all Frames."""
for frame in self.frames:
for signal in frame.signals:
if 0 == signal.size:
frame.signals.remove(signal) | Delete all signals with zero bit width from all Frames. | delete_zero_signals | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def del_signal_attributes(self, unwanted_attributes): # type: (typing.Sequence[str]) -> None
"""Delete Signal attributes from all Signals of all Frames.
:param list of str unwanted_attributes: List of attributes to remove
"""
for frame in self.frames:
for signal in frame.si... | Delete Signal attributes from all Signals of all Frames.
:param list of str unwanted_attributes: List of attributes to remove
| del_signal_attributes | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def del_frame_attributes(self, unwanted_attributes): # type: (typing.Sequence[str]) -> None
"""Delete Frame attributes from all Frames.
:param list of str unwanted_attributes: List of attributes to remove
"""
for frame in self.frames:
for attrib in unwanted_attributes:
... | Delete Frame attributes from all Frames.
:param list of str unwanted_attributes: List of attributes to remove
| del_frame_attributes | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def recalc_dlc(self, strategy): # type: (str) -> None
"""Recompute DLC of all Frames.
:param str strategy: selected strategy, "max" or "force".
"""
for frame in self.frames:
if "max" == strategy:
frame.calc_dlc()
if "force" == strategy:
... | Recompute DLC of all Frames.
:param str strategy: selected strategy, "max" or "force".
| recalc_dlc | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def rename_ecu(self, ecu_or_name, new_name): # type: (typing.Union[Ecu, str], str) -> None
"""Rename ECU in the Matrix. Update references in all Frames.
:param str or Ecu ecu_or_name: old name or ECU instance
:param str new_name: new name
"""
ecu = ecu_or_name if isinstance(ecu... | Rename ECU in the Matrix. Update references in all Frames.
:param str or Ecu ecu_or_name: old name or ECU instance
:param str new_name: new name
| rename_ecu | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_ecu(self, ecu): # type(Ecu) -> None # todo return Ecu?
"""Add new ECU to the Matrix. Do nothing if ecu with the same name already exists.
:param Ecu ecu: ECU name to add
"""
for bu in self.ecus:
if bu.name.strip() == ecu.name:
return
self.ec... | Add new ECU to the Matrix. Do nothing if ecu with the same name already exists.
:param Ecu ecu: ECU name to add
| add_ecu | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def del_ecu(self, ecu_or_glob): # type: (typing.Union[Ecu, str]) -> None
"""Remove ECU from Matrix and all Frames.
:param str or Ecu ecu_or_glob: ECU instance or glob pattern to remove from list
"""
ecu_list = [ecu_or_glob] if isinstance(ecu_or_glob, Ecu) else self.glob_ecus(ecu_or_glo... | Remove ECU from Matrix and all Frames.
:param str or Ecu ecu_or_glob: ECU instance or glob pattern to remove from list
| del_ecu | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def update_ecu_list(self): # type: () -> None
"""Check all Frames and add unknown ECUs to the Matrix ECU list."""
for frame in self.frames:
for transmit_ecu in frame.transmitters:
self.add_ecu(Ecu(transmit_ecu))
frame.update_receiver()
for signal in f... | Check all Frames and add unknown ECUs to the Matrix ECU list. | update_ecu_list | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def rename_frame(self, frame_or_name, new_name): # type: (typing.Union[Frame,str], str) -> None
"""Rename Frame.
:param Frame or str frame_or_name: Old Frame instance or name or part of the name with '*' at the beginning or the end.
:param str new_name: new Frame name, suffix or prefix
... | Rename Frame.
:param Frame or str frame_or_name: Old Frame instance or name or part of the name with '*' at the beginning or the end.
:param str new_name: new Frame name, suffix or prefix
| rename_frame | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def del_frame(self, frame_or_name): # type: (typing.Union[Frame, str]) -> None
"""Delete Frame from Matrix.
:param Frame or str frame_or_name: Frame or name to delete"""
frame = frame_or_name if isinstance(frame_or_name, Frame) else self.frame_by_name(frame_or_name)
if frame:
... | Delete Frame from Matrix.
:param Frame or str frame_or_name: Frame or name to delete | del_frame | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def rename_signal(self, signal_or_name, new_name): # type: (typing.Union[Signal, str], str) -> None
"""Rename Signal.
:param Signal or str signal_or_name: Old Signal instance or name or part of the name with '*' at the beginning or the end.
:param str new_name: new Signal name, suffix or prefi... | Rename Signal.
:param Signal or str signal_or_name: Old Signal instance or name or part of the name with '*' at the beginning or the end.
:param str new_name: new Signal name, suffix or prefix
| rename_signal | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def del_signal(self, signal): # type: (typing.Union[Signal, str]) -> None
"""Delete Signal from Matrix and all Frames.
:param Signal or str signal: Signal instance or glob pattern to be deleted"""
if isinstance(signal, Signal):
for frame in self.frames:
if signal in... | Delete Signal from Matrix and all Frames.
:param Signal or str signal: Signal instance or glob pattern to be deleted | del_signal | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_signal_receiver(self, globFrame, globSignal, ecu): # type: (str, str, str) -> None
"""Add Receiver to all Frames and Signals by glob pattern.
:param str globFrame: glob pattern for Frame name.
:param str globSignal: glob pattern for Signal name. Only signals under globFrame are filtere... | Add Receiver to all Frames and Signals by glob pattern.
:param str globFrame: glob pattern for Frame name.
:param str globSignal: glob pattern for Signal name. Only signals under globFrame are filtered.
:param str ecu: Receiver ECU name
| add_signal_receiver | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def del_signal_receiver(self, globFrame, globSignal, ecu): # type: (str, str, str) -> None
"""Delete Receiver from all Frames by glob pattern.
:param str globFrame: glob pattern for Frame name.
:param str globSignal: glob pattern for Signal name. Only signals under globFrame are filtered.
... | Delete Receiver from all Frames by glob pattern.
:param str globFrame: glob pattern for Frame name.
:param str globSignal: glob pattern for Signal name. Only signals under globFrame are filtered.
:param str ecu: Receiver ECU name
| del_signal_receiver | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def add_frame_receiver(self, globFrame, ecu): # type: (str, str) -> None
"""Add Receiver to all Frames by glob pattern.
:param str globFrame: glob pattern for Frame name.
:param str ecu: Receiver ECU name
"""
frames = self.glob_frames(globFrame)
for frame in frames:
... | Add Receiver to all Frames by glob pattern.
:param str globFrame: glob pattern for Frame name.
:param str ecu: Receiver ECU name
| add_frame_receiver | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def merge(self, mergeArray): # type: (typing.Sequence[CanMatrix]) -> None
"""Merge multiple Matrices to this Matrix.
Try to copy all Frames and all environment variables from source Matrices. Don't make duplicates.
Log collisions.
:param list of Matrix mergeArray: list of source CAN M... | Merge multiple Matrices to this Matrix.
Try to copy all Frames and all environment variables from source Matrices. Don't make duplicates.
Log collisions.
:param list of Matrix mergeArray: list of source CAN Matrices to be merged to to self.
| merge | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def set_fd_type(self) -> None:
"""Try to guess and set the CAN type for every frame.
If a Frame is longer than 8 bytes, it must be Flexible Data Rate frame (CAN-FD).
If not, the Frame type stays unchanged.
"""
for frame in self.frames:
if frame.size > 8:
... | Try to guess and set the CAN type for every frame.
If a Frame is longer than 8 bytes, it must be Flexible Data Rate frame (CAN-FD).
If not, the Frame type stays unchanged.
| set_fd_type | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def encode(self,
frame_id: ArbitrationId,
data: typing.Mapping[str, typing.Any]
) -> bytes:
"""Return a byte string containing the values from data packed
according to the frame format.
:param frame_id: frame id
:param data: data dictionary
... | Return a byte string containing the values from data packed
according to the frame format.
:param frame_id: frame id
:param data: data dictionary
:return: A byte string of the packed values.
| encode | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def decode_pycan(self, pycan_msg):
"""Return OrderedDictionary with Signal Name: object decodedSignal
:param pycan_msg: python-can message
:return: OrderedDictionary
"""
canmatrix_arbitration_id = canmatrix.ArbitrationId(pycan_msg.arbitration_id, extended=pycan_msg.is_extended_i... | Return OrderedDictionary with Signal Name: object decodedSignal
:param pycan_msg: python-can message
:return: OrderedDictionary
| decode_pycan | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def decode(self, frame_id, data): # type: (ArbitrationId, bytes) -> typing.Mapping[str, typing.Any]
"""Return OrderedDictionary with Signal Name: object decodedSignal
:param frame_id: frame id
:param data: Iterable or bytes.
i.e. (0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8)
... | Return OrderedDictionary with Signal Name: object decodedSignal
:param frame_id: frame id
:param data: Iterable or bytes.
i.e. (0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8)
:return: OrderedDictionary
| decode | python | ebroecker/canmatrix | src/canmatrix/canmatrix.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/canmatrix.py | BSD-2-Clause |
def copy_ecu(ecu_or_glob, source_db, target_db):
# type: (typing.Union[canmatrix.Ecu, str], canmatrix.CanMatrix, canmatrix.CanMatrix) -> None
"""
Copy ECU(s) identified by Name or as Object from source CAN matrix to target CAN matrix.
This function additionally copy all relevant Defines.
:param ecu... |
Copy ECU(s) identified by Name or as Object from source CAN matrix to target CAN matrix.
This function additionally copy all relevant Defines.
:param ecu_or_glob: Ecu instance or glob pattern for Ecu name
:param source_db: Source CAN matrix
:param target_db: Destination CAN matrix
| copy_ecu | python | ebroecker/canmatrix | src/canmatrix/copy.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/copy.py | BSD-2-Clause |
def copy_ecu_with_frames(ecu_or_glob, source_db, target_db, rx=True, tx=True, direct_ecu_only=True):
# type: (typing.Union[canmatrix.Ecu, str], canmatrix.CanMatrix, canmatrix.CanMatrix, bool, bool, bool) -> None
"""
Copy ECU(s) identified by Name or as Object from source CAN matrix to target CAN matrix.
... |
Copy ECU(s) identified by Name or as Object from source CAN matrix to target CAN matrix.
This function additionally copy all relevant Frames and Defines.
:param ecu_or_glob: Ecu instance or glob pattern for Ecu name
:param source_db: Source CAN matrix
:param target_db: Destination CAN matrix
:... | copy_ecu_with_frames | python | ebroecker/canmatrix | src/canmatrix/copy.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/copy.py | BSD-2-Clause |
def copy_signal(signal_glob, source_db, target_db):
# type: (str, canmatrix.CanMatrix, canmatrix.CanMatrix) -> None
"""
Copy Signals identified by name from source CAN matrix to target CAN matrix.
In target CanMatrix the signal is put without frame, just on top level.
:param signal_glob: Signal glo... |
Copy Signals identified by name from source CAN matrix to target CAN matrix.
In target CanMatrix the signal is put without frame, just on top level.
:param signal_glob: Signal glob pattern
:param source_db: Source CAN matrix
:param target_db: Destination CAN matrix
| copy_signal | python | ebroecker/canmatrix | src/canmatrix/copy.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/copy.py | BSD-2-Clause |
def copy_frame(frame_id, source_db, target_db):
# type: (canmatrix.ArbitrationId, canmatrix.CanMatrix, canmatrix.CanMatrix) -> bool
"""
Copy a Frame identified by ArbitrationId from source CAN matrix to target CAN matrix.
This function additionally copy all relevant ECUs and Defines.
:param frame_i... |
Copy a Frame identified by ArbitrationId from source CAN matrix to target CAN matrix.
This function additionally copy all relevant ECUs and Defines.
:param frame_id: Frame arbitration od
:param source_db: Source CAN matrix
:param target_db: Destination CAN matrix
| copy_frame | python | ebroecker/canmatrix | src/canmatrix/copy.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/copy.py | BSD-2-Clause |
def list_pgn(db):
# type: (canmatrix.CanMatrix) -> typing.Tuple[typing.List[int], typing.List[canmatrix.ArbitrationId]]
"""
Get all PGN values for given frame.
:param db: CanMatrix database
:return: tuple of [pgn] and [arbitration_id]
"""
id_list = [x.arbitration_id for x in db.frames]
... |
Get all PGN values for given frame.
:param db: CanMatrix database
:return: tuple of [pgn] and [arbitration_id]
| list_pgn | python | ebroecker/canmatrix | src/canmatrix/join.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/join.py | BSD-2-Clause |
def ids_sharing_same_pgn(id_x, pgn_x, id_y, pgn_y):
# type: (typing.Sequence[canmatrix.ArbitrationId], typing.Sequence[int], typing.Sequence[canmatrix.ArbitrationId], typing.Sequence[int]) -> typing.Iterable[typing.Tuple[canmatrix.ArbitrationId, canmatrix.ArbitrationId]]
"""Yield arbitration ids which has the s... | Yield arbitration ids which has the same pgn. | ids_sharing_same_pgn | python | ebroecker/canmatrix | src/canmatrix/join.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/join.py | BSD-2-Clause |
def setup_logger(): # type: () -> logging.Logger
"""Setup the root logger. Return the logger instance for possible further setting and use.
To be used from CLI scripts only.
"""
formatter = logging.Formatter(
fmt='%(levelname)s - %(module)s - %(message)s')
handler = logging.StreamHandler(... | Setup the root logger. Return the logger instance for possible further setting and use.
To be used from CLI scripts only.
| setup_logger | python | ebroecker/canmatrix | src/canmatrix/log.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/log.py | BSD-2-Clause |
def set_log_level(logger, level): # type: (logging.Logger, int) -> None
"""Dynamic reconfiguration of the log level"""
if level > 2:
level = 2
elif level < -1:
level = -1
levels = {
-1: logging.ERROR,
0: logging.WARN,
1: logging.INFO,
2: logging.DEBUG
... | Dynamic reconfiguration of the log level | set_log_level | python | ebroecker/canmatrix | src/canmatrix/log.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/log.py | BSD-2-Clause |
def quote_aware_comma_split(string): # type: (str) -> typing.List[str]
"""
Split a string containing comma separated list of fields.
Removing surrounding whitespace, to allow fields to be separated by ", ".
Preserves double quotes within fields, but not double quotes surrounding fields.
Suppresses ... |
Split a string containing comma separated list of fields.
Removing surrounding whitespace, to allow fields to be separated by ", ".
Preserves double quotes within fields, but not double quotes surrounding fields.
Suppresses comma separators which are within double quoted sections.
:param string: ('... | quote_aware_comma_split | python | ebroecker/canmatrix | src/canmatrix/utils.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/utils.py | BSD-2-Clause |
def guess_value(text_value): # type: (str) -> str
"""
Get string value for common strings.
Method is far from complete but helping with odd arxml files.
:param text_value: value in text like "true"
:return: string for value like "1"
"""
if sys.version_info >= (3, 0):
text_value = t... |
Get string value for common strings.
Method is far from complete but helping with odd arxml files.
:param text_value: value in text like "true"
:return: string for value like "1"
| guess_value | python | ebroecker/canmatrix | src/canmatrix/utils.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/utils.py | BSD-2-Clause |
def get_gcd(value1, value2): # type (int,int) -> (int)
"""
Get greatest common divisor of value1 and value2
:param value1: int value 1
:param value2: int value 2
:return: cvt of value 1 and value 2
"""
if sys.version_info >= (3, 5):
return math.gcd(value1, value2)
else:
... |
Get greatest common divisor of value1 and value2
:param value1: int value 1
:param value2: int value 2
:return: cvt of value 1 and value 2
| get_gcd | python | ebroecker/canmatrix | src/canmatrix/utils.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/utils.py | BSD-2-Clause |
def decode_number(value, float_factory): # type(string) -> (int)
"""
Decode string to integer and guess correct base
:param value: string input value
:return: integer
"""
if value is None:
return 0
value = value.strip()
if ('.' in value) or (value.lower() in ["inf", "+inf", "-i... |
Decode string to integer and guess correct base
:param value: string input value
:return: integer
| decode_number | python | ebroecker/canmatrix | src/canmatrix/utils.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/utils.py | BSD-2-Clause |
def cli_compare(matrix1, matrix2, verbosity, silent, check_comments, check_attributes, ignore_valuetables, frames):
"""
canmatrix.cli.compare [options] matrix1 matrix2
matrixX can be any of *.dbc|*.dbf|*.kcd|*.arxml|*.xls(x)|*.sym
"""
import canmatrix.log
root_logger = canmatrix.log.se... |
canmatrix.cli.compare [options] matrix1 matrix2
matrixX can be any of *.dbc|*.dbf|*.kcd|*.arxml|*.xls(x)|*.sym
| cli_compare | python | ebroecker/canmatrix | src/canmatrix/cli/compare.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/cli/compare.py | BSD-2-Clause |
def cli_convert(infile, outfile, silent, verbosity, **options):
"""
canmatrix.cli.convert [options] import-file export-file
import-file: *.dbc|*.dbf|*.kcd|*.arxml|*.json|*.xls(x)|*.sym
export-file: *.dbc|*.dbf|*.kcd|*.arxml|*.json|*.xls(x)|*.sym|*.py
"""
root_logger = canmatrix.log.setup_logg... |
canmatrix.cli.convert [options] import-file export-file
import-file: *.dbc|*.dbf|*.kcd|*.arxml|*.json|*.xls(x)|*.sym
export-file: *.dbc|*.dbf|*.kcd|*.arxml|*.json|*.xls(x)|*.sym|*.py
| cli_convert | python | ebroecker/canmatrix | src/canmatrix/cli/convert.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/cli/convert.py | BSD-2-Clause |
def get_child(self, parent, tag_name):
# type: (_Element, _Element, str) -> typing.Optional[_Element]
"""Get first sub-child or referenced sub-child with given name."""
# logger.debug("get_child: " + tag_name)
if parent is None:
return None
ret = self.find(tag_name, p... | Get first sub-child or referenced sub-child with given name. | get_child | python | ebroecker/canmatrix | src/canmatrix/formats/arxml.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/formats/arxml.py | BSD-2-Clause |
def get_base_type_of_signal(signal):
# type: (canmatrix.Signal) -> typing.Tuple[str, int]
"""Get signal arxml-type and size based on the Signal properties."""
if signal.is_float:
if signal.size > 32:
create_type = "double"
size = 64
else:
create_type = "si... | Get signal arxml-type and size based on the Signal properties. | get_base_type_of_signal | python | ebroecker/canmatrix | src/canmatrix/formats/arxml.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/formats/arxml.py | BSD-2-Clause |
def get_signals(signal_array, frame, ea, multiplex_id, float_factory, bit_offset=0):
# type: (typing.Sequence[_Element], typing.Union[canmatrix.Frame, canmatrix.Pdu], Earxml, int, typing.Callable, int) -> None
"""Add signals from xml to the Frame."""
group_id = 1
if signal_array is None: # Empty signa... | Add signals from xml to the Frame. | get_signals | python | ebroecker/canmatrix | src/canmatrix/formats/arxml.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/formats/arxml.py | BSD-2-Clause |
def update_frame_with_pdu_triggerings(frame, ea, frame_triggering, float_factory):
# type: (canmatrix.Frame, Earxml, _Element, typing.Callable) -> None
"""Update frame with signals from PDU Triggerings."""
pdu_trigs = ea.follow_all_ref(frame_triggering, "PDU-TRIGGERINGS-REF")
if pdu_trigs is not None:
... | Update frame with signals from PDU Triggerings. | update_frame_with_pdu_triggerings | python | ebroecker/canmatrix | src/canmatrix/formats/arxml.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/formats/arxml.py | BSD-2-Clause |
def dump(db, f, **options): # type: (canmatrix.CanMatrix, typing.IO, **typing.Any) -> None
"""
export canmatrix-object as .sym file (compatible to PEAK-Systems)
"""
sym_encoding = options.get('symExportEncoding', 'iso-8859-1')
ignore_encoding_errors = options.get("ignoreEncodingErrors", "strict")
... |
export canmatrix-object as .sym file (compatible to PEAK-Systems)
| dump | python | ebroecker/canmatrix | src/canmatrix/formats/sym.py | https://github.com/ebroecker/canmatrix/blob/master/src/canmatrix/formats/sym.py | BSD-2-Clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.