Skip to content

Commit

Permalink
Propagate digitizer ID list and completion flag to assembled frames
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Jan 9, 2025
1 parent 3365198 commit 0e0d2bd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
7 changes: 6 additions & 1 deletion digitiser-aggregator/src/data/event.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{Accumulate, DigitiserData};
use crate::frame::AggregatedFrame;
use supermusr_common::{Channel, Intensity, Time};
use supermusr_common::{Channel, DigitizerId, Intensity, Time};
use supermusr_streaming_types::{
aev2_frame_assembled_event_v2_generated::{
finish_frame_assembled_event_list_message_buffer, FrameAssembledEventListMessage,
Expand Down Expand Up @@ -126,6 +126,8 @@ impl From<AggregatedFrame<EventData>> for Vec<u8> {
time: Some(fbb.create_vector::<Time>(&frame.digitiser_data.time)),
voltage: Some(fbb.create_vector::<Intensity>(&frame.digitiser_data.intensity)),
channel: Some(fbb.create_vector::<Channel>(&frame.digitiser_data.channel)),
complete: frame.complete,
digitizers_present: Some(fbb.create_vector::<DigitizerId>(&frame.digitiser_ids)),
};
let message = FrameAssembledEventListMessage::create(&mut fbb, &message);

Expand Down Expand Up @@ -179,6 +181,8 @@ mod test {
time: Some(fbb.create_vector::<Time>(&[1, 2, 8, 9, 7])),
voltage: Some(fbb.create_vector::<Intensity>(&[2, 8, 8, 2, 7])),
channel: Some(fbb.create_vector::<Channel>(&[1, 3, 1, 0, 4])),
complete: true,
digitizers_present: Some(fbb.create_vector::<DigitizerId>(&[0, 1])),
};
let message = FrameAssembledEventListMessage::create(&mut fbb, &message);

Expand All @@ -197,6 +201,7 @@ mod test {
frame_number: 1337,
veto_flags: 4,
},
true,
vec![0, 1],
EventData {
time: vec![1, 2, 8, 9, 7],
Expand Down
16 changes: 9 additions & 7 deletions digitiser-aggregator/src/frame/aggregated.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use super::partial::PartialFrame;
use crate::data::{Accumulate, DigitiserData};
use supermusr_common::spanned::{SpanOnce, Spanned, SpannedMut};
#[cfg(test)]
use supermusr_common::DigitizerId;
use supermusr_common::{
spanned::{SpanOnce, Spanned, SpannedMut},
DigitizerId,
};
use supermusr_streaming_types::FrameMetadata;

pub(crate) struct AggregatedFrame<D> {
span: SpanOnce,
pub(crate) metadata: FrameMetadata,
#[cfg(test)]
pub(crate) complete: bool,
pub(crate) digitiser_ids: Vec<DigitizerId>,
pub(crate) digitiser_data: D,
}
Expand All @@ -17,13 +18,14 @@ pub(crate) struct AggregatedFrame<D> {
impl<D> AggregatedFrame<D> {
pub(crate) fn new(
metadata: FrameMetadata,
#[cfg(test)] digitiser_ids: Vec<DigitizerId>,
complete: bool,
digitiser_ids: Vec<DigitizerId>,
digitiser_data: D,
) -> Self {
Self {
span: Default::default(),
metadata,
#[cfg(test)]
complete,
digitiser_ids,
digitiser_data,
}
Expand All @@ -41,7 +43,7 @@ where
.take()
.expect("partial frame should have a span"),
metadata: partial.metadata.clone(),
#[cfg(test)]
complete: partial.is_complete(),
digitiser_ids: partial.digitiser_ids(),
digitiser_data: <DigitiserData<D> as Accumulate<D>>::accumulate(
&mut partial.digitiser_data,
Expand Down
2 changes: 2 additions & 0 deletions simulator/src/integrated/build_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ pub(crate) fn build_aggregated_event_list_message(
time: Some(fbb.create_vector(&time)),
voltage: Some(fbb.create_vector(&voltage)),
channel: Some(fbb.create_vector(channels)),
complete: true,
digitizers_present: None,
};
let message = FrameAssembledEventListMessage::create(fbb, &message);
finish_frame_assembled_event_list_message_buffer(fbb, message);
Expand Down

0 comments on commit 0e0d2bd

Please sign in to comment.