|
1 | 1 | """
|
2 | 2 | About: Load MDF log files & DBCs from an input folder and showcase various operations.
|
3 |
| -Note: Example assumes v6.0.0+ of asammdf |
| 3 | +Note: Example assumes v6.4.4+ of asammdf |
4 | 4 | """
|
5 | 5 | from asammdf import MDF
|
6 | 6 | import matplotlib.pyplot as plt
|
|
13 | 13 | mdf_extension = ".MF4"
|
14 | 14 | input_folder = "input"
|
15 | 15 | output_folder = "output"
|
| 16 | +dbc_file = "CSS-Electronics-SAE-J1939-DEMO.dbc" |
16 | 17 |
|
17 | 18 |
|
18 | 19 | # load MDF/DBC files from input folder
|
19 | 20 | path = Path(__file__).parent.absolute()
|
20 | 21 | path_in = Path(path, input_folder)
|
21 | 22 | path_out = Path(path, output_folder)
|
| 23 | +path_in_dbc = Path(path_in, dbc_file) |
22 | 24 |
|
23 | 25 | logfiles = list(path_in.glob("*" + mdf_extension))
|
24 |
| -dbc = {"CAN": list(path_in.glob("*" + ".DBC"))} |
| 26 | +dbc = {"CAN": [(path_in_dbc, 0)]} |
25 | 27 |
|
26 | 28 | signals = ["EngineSpeed", "WheelBasedVehicleSpeed"]
|
27 | 29 | print("Log file(s): ", logfiles, "\nDBC(s): ", dbc)
|
|
55 | 57 | # extract a filtered MDF based on a signal list
|
56 | 58 | mdf_scaled_signals = mdf_scaled.filter(signals)
|
57 | 59 |
|
58 |
| -# extract a single signal from the unscaled MDF |
59 |
| -mdf_scaled_signal = mdf.get_bus_signal(bus="CAN", name=signals[0], database=dbc["CAN"][0]) |
60 |
| - |
61 | 60 | # create pandas dataframe from the scaled MDF and e.g. add new signals
|
62 | 61 | pd = mdf_scaled.to_dataframe(time_as_date=True)
|
63 | 62 | pd["ratio"] = pd.loc[:, signals[0]] / pd.loc[:, signals[1]]
|
|
0 commit comments