Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/danielhrisca/asammdf
Browse files Browse the repository at this point in the history
…into development/shortcut_tests
  • Loading branch information
FillBk committed Apr 8, 2024
2 parents 40a4afb + ef6773f commit fdf1f08
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/asammdf/gui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
COLORS_COUNT = len(COLORS)

SUPPORTED_FILE_EXTENSIONS = {".csv", ".zip", ".erg", ".dat", ".mdf", ".mf4", ".mf4z"}
SUPPORTED_BUS_DATABASE_EXTENSIONS = {".arxml", ".dbc", ".xml"}

GREEN = "#599e5e"
BLUE = "#61b2e2"
Expand Down
7 changes: 5 additions & 2 deletions src/asammdf/gui/widgets/mdi_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,14 @@ def dropEvent(self, e):
files = []
for path in e.mimeData().text().splitlines():
path = Path(path.replace(r"file:///", ""))
if path.suffix.lower() in utils.SUPPORTED_FILE_EXTENSIONS:
if (
path.suffix.lower()
in utils.SUPPORTED_FILE_EXTENSIONS | utils.SUPPORTED_BUS_DATABASE_EXTENSIONS
):
files.append(str(path))

if files:
self.open_files_request.emit(str(path))
self.open_files_request.emit(files)
except:
print(format_exc())

Expand Down
8 changes: 6 additions & 2 deletions test/test_CAN_bus_loogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ def test_obd_extract(self):

signals = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".npy"]

out = mdf.extract_bus_logging({"CAN": [(dbc, 0)]})
out = mdf.extract_bus_logging({"CAN": [(dbc, 0)]}, ignore_value2text_conversion=True)

for signal in signals:
name = signal.stem

target = np.load(signal)
sig = out.get(name)
if sig.samples.dtype.kind == "S":
sig = out.get(name, raw=True)

self.assertTrue(np.array_equal(sig.samples, target), f"{name} {sig} {target}")

Expand All @@ -68,13 +70,15 @@ def test_j1939_extract(self):

signals = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".npy"]

out = mdf.extract_bus_logging({"CAN": [(dbc, 0)]})
out = mdf.extract_bus_logging({"CAN": [(dbc, 0)]}, ignore_value2text_conversion=True)

for signal in signals:
name = signal.stem

target = np.load(signal)
values = out.get(name).samples
if values.dtype.kind == "S":
values = out.get(name, raw=True).samples

self.assertTrue(np.array_equal(values, target))

Expand Down
2 changes: 1 addition & 1 deletion test/test_cantp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TestCANTP(unittest.TestCase):

payload = np.vstack(
[
np.frombuffer(b"\x10\x0B\x52\x49\x47\x20\x20\x39", dtype="uint8"), # Initisl part
np.frombuffer(b"\x10\x0B\x52\x49\x47\x20\x20\x39", dtype="uint8"), # Initial part
np.frombuffer(b"\x30\xff\x00\x4c\x40\x00\xd5\x54", dtype="uint8"), # Flow control
np.frombuffer(b"\x21\x30\x30\x30\x38\x33\x00\x00", dtype="uint8"), # Final (second) part
np.frombuffer(b"\x10\x0B\x52\x49\x47\x20\x20\x39", dtype="uint8"), # Initial part of next frame...
Expand Down

0 comments on commit fdf1f08

Please sign in to comment.