From ae99052c80ade83b560c8e51949c507275cd1a52 Mon Sep 17 00:00:00 2001 From: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk> Date: Wed, 21 Feb 2024 17:55:52 +0000 Subject: [PATCH] Allow meaningless variables in SingleReadout --- src/components/readouts/single_readouts.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/readouts/single_readouts.jl b/src/components/readouts/single_readouts.jl index ee72037..c814763 100644 --- a/src/components/readouts/single_readouts.jl +++ b/src/components/readouts/single_readouts.jl @@ -12,6 +12,18 @@ Represents an instantaneous `Readout` of the signal. It has no parameters or variables to set. """ struct SingleReadout <: ReadoutComponent + SingleReadout(s::Symbol) = new() +end + +function SingleReadout(; duration=nothing, kwargs...) + bad_keys = [key for (key, value) in pairs(kwargs) if !(isnothing(value) || (value isa Union{AbstractArray, Tuple} && all(isnothing.(value))))] + if length(bad_keys) > 0 + error("SingleReadout does not expect any variables, yet it received $bad_keys.") + end + if !(duration in (nothing, :min, :max, 0, 0.)) + error("SingleReadout did not expect a value for duration, yet received $duration.") + end + return SingleReadout(:prevent_loop) end duration(::SingleReadout) = 0. -- GitLab