Split decode, decode_to_motec
This commit is contained in:
+37
-15
@@ -164,9 +164,15 @@ pub struct DecodeProcessInfo {
|
||||
pub chunk_size: usize,
|
||||
}
|
||||
|
||||
pub struct DecodeResult {
|
||||
pub data: HashMap<CanId, Vec<CanFrame>>,
|
||||
pub metadata: HashMap<CanId, MessageMetadata>,
|
||||
|
||||
pub info: DecodeProcessInfo,
|
||||
}
|
||||
|
||||
pub fn decode(dbc: &Dbc,
|
||||
asc_path: &Path,
|
||||
output_dir: &Path) -> DecodeProcessInfo {
|
||||
asc_path: &Path) -> DecodeResult {
|
||||
let thread_count = std::thread::available_parallelism().unwrap().get();
|
||||
|
||||
let file = File::open(asc_path).unwrap();
|
||||
@@ -178,10 +184,6 @@ pub fn decode(dbc: &Dbc,
|
||||
mmap.advise(Advice::WillNeed).unwrap();
|
||||
|
||||
let date = parse_asc_date(&mmap[..memchr::memchr(b'\r', &mmap).unwrap()]).unwrap();
|
||||
|
||||
let date_str = date
|
||||
.and_utc()
|
||||
.to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
|
||||
// println!("Date: {}", date);
|
||||
|
||||
let page_size = page_size::get();
|
||||
@@ -253,8 +255,36 @@ pub fn decode(dbc: &Dbc,
|
||||
// println!("{:?}", unknown_ids);
|
||||
// println!("{:?}", error_frames);
|
||||
|
||||
DecodeResult {
|
||||
data,
|
||||
metadata,
|
||||
info: DecodeProcessInfo {
|
||||
unknown_ids,
|
||||
error_frames,
|
||||
date,
|
||||
thread_count,
|
||||
page_size,
|
||||
pages_per_chunk,
|
||||
chunk_size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn decode_to_motec(dbc: &Dbc,
|
||||
asc_path: &Path,
|
||||
output_dir: &Path) -> DecodeProcessInfo {
|
||||
let DecodeResult {
|
||||
mut data,
|
||||
metadata,
|
||||
info,
|
||||
} = decode(dbc, asc_path);
|
||||
|
||||
println!("Post processing");
|
||||
|
||||
let date_str = info.date
|
||||
.and_utc()
|
||||
.to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
|
||||
|
||||
for (_, frames) in &mut data {
|
||||
// frames.voracious_mt_sort(thread_count);
|
||||
frames.voracious_sort();
|
||||
@@ -271,13 +301,5 @@ pub fn decode(dbc: &Dbc,
|
||||
motec::write(&output_dir.join(out_name), &msgs, data);
|
||||
println!("Finished!");
|
||||
|
||||
DecodeProcessInfo {
|
||||
unknown_ids,
|
||||
error_frames,
|
||||
date,
|
||||
thread_count,
|
||||
page_size,
|
||||
pages_per_chunk,
|
||||
chunk_size,
|
||||
}
|
||||
info
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user