Skip to content

Commit

Permalink
Simplified aggregator type specifiation
Browse files Browse the repository at this point in the history
  • Loading branch information
Modularius committed Aug 30, 2024
1 parent 9b707f3 commit 2782b74
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
18 changes: 9 additions & 9 deletions digitiser-aggregator/src/frame/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ where
}
}

pub(crate) fn push(&mut self, digitiser_id: DigitizerId, metadata: FrameMetadata, data: D) {
pub(crate) fn push(&mut self, digitiser_id: DigitizerId, metadata: &FrameMetadata, data: D) {
match self
.frames
.iter_mut()
Expand All @@ -38,7 +38,7 @@ where
frame.push_veto_flags(metadata.veto_flags)
}
None => {
let mut frame = PartialFrame::<D>::new(self.ttl, metadata);
let mut frame = PartialFrame::<D>::new(self.ttl, metadata.clone());
frame.push(digitiser_id, data);
self.frames.push_back(frame);
}
Expand Down Expand Up @@ -97,21 +97,21 @@ mod test {

assert!(cache.poll().is_none());

cache.push(0, frame_1.clone(), EventData::dummy_data(0, 5, &[0, 1, 2]));
cache.push(0, &frame_1, EventData::dummy_data(0, 5, &[0, 1, 2]));

assert!(cache.poll().is_none());

cache.push(1, frame_1.clone(), EventData::dummy_data(0, 5, &[3, 4, 5]));
cache.push(1, &frame_1, EventData::dummy_data(0, 5, &[3, 4, 5]));

assert!(cache.poll().is_none());

cache.push(4, frame_1.clone(), EventData::dummy_data(0, 5, &[6, 7, 8]));
cache.push(4, &frame_1, EventData::dummy_data(0, 5, &[6, 7, 8]));

assert!(cache.poll().is_none());

cache.push(
8,
frame_1.clone(),
&frame_1,
EventData::dummy_data(0, 5, &[9, 10, 11]),
);

Expand Down Expand Up @@ -160,17 +160,17 @@ mod test {

assert!(cache.poll().is_none());

cache.push(0, frame_1.clone(), EventData::dummy_data(0, 5, &[0, 1, 2]));
cache.push(0, &frame_1, EventData::dummy_data(0, 5, &[0, 1, 2]));

assert!(cache.poll().is_none());

cache.push(1, frame_1.clone(), EventData::dummy_data(0, 5, &[3, 4, 5]));
cache.push(1, &frame_1, EventData::dummy_data(0, 5, &[3, 4, 5]));

assert!(cache.poll().is_none());

cache.push(
8,
frame_1.clone(),
&frame_1,
EventData::dummy_data(0, 5, &[9, 10, 11]),
);

Expand Down
5 changes: 2 additions & 3 deletions digitiser-aggregator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,10 @@ async fn on_message(
);
match root_as_digitizer_event_list_message(payload) {
Ok(msg) => {
let metadata_result: Result<FrameMetadata, _> = msg.metadata().try_into();
match metadata_result {
match msg.metadata().try_into() {
Ok(metadata) => {
debug!("Event packet: metadata: {:?}", msg.metadata());
cache.push(msg.digitizer_id(), metadata.clone(), msg.into());
cache.push(msg.digitizer_id(), &metadata, msg.into());

if let Some(frame_span) = cache.find_span_mut(metadata) {
if frame_span.span().is_waiting() {
Expand Down

0 comments on commit 2782b74

Please sign in to comment.