1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use rust_stdf::{stdf_file::*, stdf_record_type::*, StdfRecordView};
use std::env;
use std::time::Instant;
fn main() {
let stdf_path: String;
if let Some(fpath) = env::args().nth(1) {
stdf_path = fpath;
println!("Input path: {}\n", stdf_path);
} else {
println!("no path\n");
return;
};
let ptr_test_name = env::args()
.nth(2)
.unwrap_or_else(|| "contiuity test".to_string());
let mut reader = match StdfReader::new(&stdf_path) {
Ok(r) => r,
Err(e) => {
println!("{}", e);
return;
}
};
let start_time = Instant::now();
// and put test result of PTR named
// "continuity test" in a vector.
let mut dut_count: u64 = 0;
let mut continuity_rlt = vec![];
// use type filter to work on certain types,
// use `|` to combine multiple typs
let rec_types = REC_PIR | REC_PTR | REC_MPR;
// iterator starts from current file position,
// if file hits EOF, it will NOT redirect to 0.
//
// unlike `stdf_raw_iter_example.rs`, the view iterator reuses one buffer and
// yields a borrowed `RawDataElementView`, so it cannot be a std `Iterator`;
// drive it with an inherent `next` in a `while let` loop instead.
let mut iter = reader.get_rawdata_view_iter();
while let Some(item) = iter.next() {
let raw = item.unwrap();
if !raw.is_type(rec_types) {
continue;
}
// build a view from raw data without parsing the whole record,
// get corresponding field value by getter method.
//
// it can be more efficient than `stdf_example.rs`
// when you only need a few fields of a record.
let rec_view: StdfRecordView = (&raw).into();
match rec_view {
StdfRecordView::PIR(_) => {
dut_count += 1;
}
StdfRecordView::PTR(ptr_view) => {
// println!(
// "[PTR] offset in file: {}, test num: {}, test name: [{}], test result: {}",
// raw.offset,
// ptr_view.test_num(),
// ptr_view.test_txt().as_str(),
// ptr_view.result()
// );
if ptr_view.test_txt().as_str() == ptr_test_name.as_str() {
continuity_rlt.push(ptr_view.result());
}
}
StdfRecordView::MPR(mpr_view) if mpr_view.res_scal().is_none() => {
println!("{:?}", mpr_view.to_owned());
}
_ => {}
}
}
let elapsed = start_time.elapsed().as_millis();
println!(
"Total duts {} \n {} result {:?}\n elapsed time {} ms",
dut_count, ptr_test_name, continuity_rlt, elapsed
);
}