From 404c700ba4558b50e4fd42ac16f110ca80550ba0 Mon Sep 17 00:00:00 2001
From: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
Date: Thu, 15 Feb 2024 16:09:26 +0000
Subject: [PATCH] Add DelayedEvent

---
 src/components/components.jl     |  2 ++
 src/components/delayed_events.jl | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+)
 create mode 100644 src/components/delayed_events.jl

diff --git a/src/components/components.jl b/src/components/components.jl
index d879bd8..04ab969 100644
--- a/src/components/components.jl
+++ b/src/components/components.jl
@@ -4,11 +4,13 @@ include("gradient_waveforms/gradient_waveforms.jl")
 include("instant_gradients.jl")
 include("pulses/pulses.jl")
 include("readouts/readouts.jl")
+include("delayed_events.jl")
 
 import .AbstractTypes: BaseComponent, GradientWaveform, EventComponent, RFPulseComponent, ReadoutComponent
 import .GradientWaveforms: ConstantGradient, ChangingGradient, NoGradient, split_gradient
 import .InstantGradients: InstantGradient1D, InstantGradient3D
 import .Pulses: GenericPulse, InstantPulse, SincPulse, ConstantPulse
 import .Readouts: ADC, SingleReadout
+import .DelayedEvents: DelayedEvent
 
 end
\ No newline at end of file
diff --git a/src/components/delayed_events.jl b/src/components/delayed_events.jl
new file mode 100644
index 0000000..f05861e
--- /dev/null
+++ b/src/components/delayed_events.jl
@@ -0,0 +1,20 @@
+module DelayedEvents
+import ..AbstractTypes: EventComponent, ReadoutComponent, RFPulseComponent
+import ...Variables: VariableType, get_free_variable, get_pulse, get_readout
+
+struct DelayedEvent{T<:EventComponent} <: EventComponent
+    event :: T
+    delay :: VariableType
+    function DelayedEvent(event::EventComponent, delay=nothing)
+        new(event, get_free_variable(delay))
+    end
+end
+
+
+effective_time(del::DelayedEvent) = effective_time(del.event) + del.delay
+
+get_pulse(del::DelayedEvent{T}) where {T<:RFPulseComponent} = del.event
+get_readout(del::DelayedEvent{T}) where {T<:ReadoutComponent} = del.event
+
+
+end
\ No newline at end of file
-- 
GitLab