Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions doc/specific_iocs/datastreaming/ADRs/007_periods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 7 - Periods

## Status

Accepted.

## Context

Periods are used to split up runs. This may be because a scientist wants to scan over several points and keep events separated before data analysis, or it may be for other arbitrary reasons.

In the previous system, periods are 1-indexed to a user. This means that a dashboard can display things like `1/1 periods` if using a single period, or for example `9/12` periods to show a run that is in progress and currently collecting data to period 9. This means that PVs that interface the client and/or `genie_python` need to display as 1-indexed. NeXus files, specifically the `/raw_data_1/framelog/period_log/value` dataset, follow this logic. Conversely, the hardware was 0-indexed, so the ICP had to subtract/add 1 from the served PVs.

## Decision

We will use 0-indexing everywhere internal and 1-indexing for user facing period controls and readbacks:
- The streaming hardware will use zero-indexed periods.
- UDP messages from detectors will use zero-indexed periods.
- Flatbuffers messages, both before and after event_aggregator, will be zero-indexed
- `kafka_dae_control` will use zero-indexed periods everywhere except user-facing PVs (PVs that have no component starting/ending with a `_`), where it will need to do a conversion
- `kafka_dae_diagnostics` will use zero-indexed periods everywhere except user-facing PVs(see above), where it will need to do a conversion
- The filewriter will need to do a conversion internally to remain consistent with old format, such that flatbuffers messages saying "period 0" end up in a frame log called "period 1".

There was a consideration to reserve period 0 as an "unknown" period, similar to how traditionally the 0th detector was reserved for malformed data, however this doesn't make sense in the streaming world and an event without a period should just be discarded by the hardware or UDP to Kafka layer.

@FreddieAkeroyd FreddieAkeroyd Jul 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

period 0 was traditionally used on the user facing GUI to mean "current period" i.e. you woudl setthe display to use period 0 and it would display whatever was being collected in the current period on the graph

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the current period being whatever the period card was set to

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was it - i thought 1 was, so you could have 1/1 periods rather than 0/1 periods

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Freddie means PVs like SPEC:0:1:X (where the format is SPEC:period:detector) where that zero is interpreted as current period. I think this is mainly a concern for kafka_dae_diagnostics.

@FreddieAkeroyd FreddieAkeroyd Jul 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes things like Tom says, also on PVs used by e.g. live view OPI screen - you can choose period you want to display in live view, if you choose period 0 there it displays picture for current period so saves user needing to toggle between flipper on and flipper off etc.

## Consequences

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this section can we list more explicitly that:

  • Hardware will use zero-indexed
  • UDP messages from detectors will use zero-indexed
  • Flatbuffers messages, both before and after event_aggregator, will use zero-indexed
  • kafka_dae_control will use zero-indexed everywhere except user-facing PVs, where it will need to do a conversion
  • kafka_dae_diagnostics will use zero-indexed everywhere except user-facing PVs, where it will need to do a conversion
  • Filewriter will need to do a conversion internally to remain consistent with old format, such that flatbuffers messages saying "period 0" end up in a frame log called "period 1".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are we considering as a "user-facing PVs" - any PV without explicit access control on it, or any pv that doesn't start/end with an _, or any not documented as user facing?

@Tom-Willemsen Tom-Willemsen Jul 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any pv that doesn't start/end with an _

This feels like a reasonable definition to me. I think we've used conventions like IN:INST:_SOMETHING:SOME_PARAMETER in the past if everything in _SOMETHING is private, so maybe

PV that has no component starting/ending with a _

might be more precise, but not that bothered.

- We can use 0-indexed periods as a standard for everything that isn't user facing (and NeXus files which _are_ user facing) which means dealing with arrays is much simpler
- We need to be careful to make sure that the user is shown 1-indexed periods when viewing and setting periods