From 69aeeda2108effffe24077d239d00d4b433c1b80 Mon Sep 17 00:00:00 2001 From: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk> Date: Sat, 27 Jan 2024 20:03:18 +0000 Subject: [PATCH] Access children and start_time for FixedBlock --- src/containers/fixed_blocks.jl | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/containers/fixed_blocks.jl b/src/containers/fixed_blocks.jl index eaaaabe..3e79370 100644 --- a/src/containers/fixed_blocks.jl +++ b/src/containers/fixed_blocks.jl @@ -1,7 +1,7 @@ module FixedBlocks -import ...BuildingBlocks: ContainerBlock +import ...BuildingBlocks: BuildingBlock, ContainerBlock import ...Gradients: FixedGradient import ...Pulses: FixedPulse import ...Variables: duration, variables @@ -44,11 +44,30 @@ struct FixedBlock <: ContainerBlock end end +Base.getindex(fb::FixedBlock, index::Symbol) = fb[Val(index)] +Base.getindex(fb::FixedBlock, ::Val{:pulse}) = fb.pulse +Base.getindex(fb::FixedBlock, ::Val{:gradient}) = fb.gradient + duration(fb::FixedBlock) = fb.duration variables(::Type{<:FixedBlock}) = [] fixed(wb::WaitBlock) = FixedBlock(value(duration(wb))) +start_time(fb::FixedBlock, index::Symbol) = start_time(fb, Val(index)) +start_time(fb::FixedBlock, ::Val{:pulse}) = fb.pulse_delay +start_time(fb::FixedBlock, ::Val{:gradient}) = fb.gradient_delay + +function get_children_blocks(fb::FixedBlock) + res = Tuple{Symbol, BuildingBlock}[] + if !isnothing(fb.pulse) + push!((:pulse, fb.pulse)) + end + if !isnothing(fb. gradient) + push!((:gradient, fb.gradient)) + end + return res +end + end \ No newline at end of file -- GitLab