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
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,5 +12,5 @@ fn main() {
|
||||
let asc_path = Path::new(&args[2]);
|
||||
let output_dir = Path::new(&args[3]);
|
||||
|
||||
libsvld::decode(&dbc, asc_path, output_dir);
|
||||
libsvld::decode_to_motec(&dbc, asc_path, output_dir);
|
||||
}
|
||||
|
||||
+1
-1
@@ -317,7 +317,7 @@ fn main() {
|
||||
.map_err(|e| format!("Failed to parse DBC: {:?}", e))?;
|
||||
let mut out = Vec::with_capacity(total);
|
||||
for (i, asc) in asc_paths.iter().enumerate() {
|
||||
let info = libsvld::decode(&dbc, asc, &output_dir);
|
||||
let info = libsvld::decode_to_motec(&dbc, asc, &output_dir);
|
||||
out.push(build_file_result(asc, info));
|
||||
let done = i + 1;
|
||||
let w = window_weak.clone();
|
||||
|
||||
Reference in New Issue
Block a user