Skip to content

Commit

Permalink
Impl QdFrameMeta::get_dtype_string
Browse files Browse the repository at this point in the history
Do some validation of the first frame header. For now, it only logs
warnings, might need to become errors in the future.
  • Loading branch information
sk1p committed Jul 23, 2024
1 parent 8096313 commit 7d8690e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
12 changes: 11 additions & 1 deletion libertem_qd_mpx/src/background_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use common::{
frame_stack::{FrameMeta, FrameStackForWriting, FrameStackWriteError, WriteGuard},
generic_connection::AcquisitionConfig,
tcp::{self, ReadExactError},
utils::{num_from_byte_slice, three_way_shift, NumParseError},
utils::{num_from_byte_slice, NumParseError},
};
use ipc_test::{slab::ShmError, SharedSlabAllocator};
use log::{debug, error, info, trace, warn};
Expand Down Expand Up @@ -537,6 +537,16 @@ fn passive_acquisition(
// hardware trigger):
let first_frame_meta: QdFrameMeta = peek_first_frame_header(&mut stream, to_thread_r)?;

match &first_frame_meta.mq1a {
None => warn!("missing mq1a header, this will probably cause issues in raw mode!"),
Some(mq1a) => match mq1a.counter_depth {
1 | 6 | 12 | 24 => {}
_ => {
warn!("unknown counter depth {}", mq1a.counter_depth);
}
},
}

acquisition(
to_thread_r,
from_thread_s,
Expand Down
25 changes: 24 additions & 1 deletion libertem_qd_mpx/src/base_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,30 @@ impl FrameMeta for QdFrameMeta {
}

fn get_dtype_string(&self) -> String {
todo!()
let raw_dtype = if let Some(mq1a) = &self.mq1a {
match mq1a.counter_depth {
1 | 6 => "uint8",
12 => "uint16",
24 => "uint32",
_ => {
// FIXME: unknown counter depth; can't determine raw dtype!
"uint8"
}
}
} else {
// FIXME: not really correct, but we can't know the data type if the
// detector doesn't include the mq1a header!
"uint8"
};

match self.dtype {
DType::U01 | DType::U08 => "uint8",
DType::U16 => "uint16",
DType::U32 => "uint32",
DType::U64 => "uint64",
DType::R64 => raw_dtype,
}
.to_owned()
}

fn get_shape(&self) -> (u64, u64) {
Expand Down

0 comments on commit 7d8690e

Please sign in to comment.