|
16 | 16 |
|
17 | 17 | # specify input paths for MF4 files (e.g. on Windows Path("D:\\LOG") for SD, Path("Z:\\") for mapped S3 bucket,
|
18 | 18 | # path_script / "LOG" for relative folder, C:\\Users\\myuser\\folder\\subfolder\\LOG for absolute path, ...)
|
19 |
| -path_input = path_script / "LOG" |
| 19 | +path_input_orig = path_script / "LOG" |
20 | 20 |
|
21 | 21 | # specify devices to process from path_input
|
22 |
| -devices = ["2F6913DB"] |
| 22 | +devices = ["2F6913DB", "5BC57FEC"] |
23 | 23 |
|
24 | 24 | # specify output path (e.g. another mapped S3 bucket, local disk, ...)
|
25 | 25 | path_output = path_script / "mf4-output/concatenated"
|
26 | 26 | path_output_temp = path_script / "mf4-output/temp"
|
27 | 27 |
|
28 | 28 | # optionally finalize files (if *.MFC) and DBC decode them
|
29 |
| -finalize = True |
30 | 29 | enable_dbc_decoding = False
|
31 | 30 | enable_mf4_compression = True
|
32 | 31 | path_dbc_files = path_script / "dbc_files"
|
|
38 | 37 | file_length_hours = 24
|
39 | 38 |
|
40 | 39 | # ----------------------------------------
|
41 |
| -fs = canedge_browser.LocalFileSystem(base_path=path_input) |
42 | 40 |
|
43 |
| -print("path_input: ",path_input) |
44 | 41 | dbc_files = {"CAN": [(dbc, 0) for dbc in list(path_dbc_files.glob("*" + ".DBC"))]}
|
45 | 42 |
|
46 | 43 | for device in devices:
|
| 44 | + path_input = path_input_orig |
| 45 | + fs = canedge_browser.LocalFileSystem(base_path=path_input) |
| 46 | + |
47 | 47 | cnt_sub_period = 0
|
48 | 48 | sub_period_start = period_start
|
49 | 49 | sub_period_stop = period_start
|
|
59 | 59 | print("Skipping device")
|
60 | 60 | continue
|
61 | 61 |
|
62 |
| - # finalize MF4 files and output to temporary folder |
63 |
| - first_log_file = log_files_total[0] |
| 62 | + # finalize all files, then update the filesystem fs and path_input to the temp_finalized sub folder |
| 63 | + log_files_total = finalize_log_files(log_files_total, path_output_temp, path_mdf2finalized) |
| 64 | + fs = canedge_browser.LocalFileSystem(base_path=path_input / path_output_temp.parent / "temp_finalized") |
| 65 | + path_input = path_input / path_output_temp.parent / "temp_finalized" |
64 | 66 |
|
65 |
| - if finalize: |
66 |
| - first_log_file = finalize_log_files([first_log_file], path_output_temp, path_mdf2finalized)[0] |
67 |
| - |
| 67 | + # extract first_log_file |
| 68 | + first_log_file = log_files_total[0] |
| 69 | + |
68 | 70 | mdf = MDF(first_log_file)
|
69 | 71 |
|
70 | 72 | mdf_start, mdf_stop = extract_mdf_start_stop_time(mdf)
|
|
97 | 99 | sub_period_start = sub_period_stop
|
98 | 100 | continue
|
99 | 101 |
|
100 |
| - # finalize MF4 files and output to temporary folder |
101 |
| - if finalize: |
102 |
| - log_files = finalize_log_files(log_files, path_output_temp, path_mdf2finalized) |
103 |
| - |
104 | 102 | # concatenate all sub period files and identify the delta sec to start/stop
|
105 | 103 | mdf = MDF.concatenate(log_files)
|
106 | 104 | mdf_start, mdf_stop = extract_mdf_start_stop_time(mdf)
|
|
133 | 131 | gc.collect()
|
134 | 132 |
|
135 | 133 | # if temp folder is used, clear it
|
136 |
| - if finalize and os.path.exists(path_output_temp): |
| 134 | + if os.path.exists(path_output_temp): |
137 | 135 | print("- Deleting temporary folder")
|
138 | 136 | shutil.rmtree(path_output_temp)
|
139 | 137 |
|
|
0 commit comments