Crates.io | asammdf |
lib.rs | asammdf |
version | 0.1.0 |
source | src |
created_at | 2024-07-01 13:25:57.787586 |
updated_at | 2024-07-01 13:25:57.787586 |
description | Read and write ASAM MDF file, simply and efficiently. |
homepage | |
repository | https://github.com/H2O2-IO/asammdf |
max_upload_size | |
id | 1288722 |
size | 218,769 |
Read and write ASAM MDF file, simply and efficiently. Currently under development, and not ready for production use.
Read a MDFv3 file, and then write data which recordindex=0 to console.
use asammdf::{MDFFile,SpecVer,v3,MDFObject,IDObject, ValueFormat};
let mut file = MDFFile::new();
file.open("./mdf3.dat").unwrap();
let idblock = file.get_id::<v3::IDBlock>().unwrap();
// MDF file's magic header is "MDF "
assert_eq!(idblock.file_id(), "MDF ");
assert_eq!(idblock.version(), 300);
// get all channel blocks out of MDF file
let iter = file.get_node_ids::<v3::CNBlock>().unwrap().into_iter();
// get all record data with recordindex=0 of these channel blocks
let _: Vec<f64> = iter.map(|node_id| {
let data = file.get_data_cnblock(ValueFormat::Physical, node_id, 0);
let name = file.get_node_by_id::<v3::CNBlock>(node_id).unwrap().name();
println!("({name},{data})");
data
})
.collect();