Skip to content
Snippets Groups Projects
Verified Commit 3f46ee72 authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

Add Wait block as a sub-type of BaseBuildingBlock

parent c4246cf4
No related branches found
No related tags found
No related merge requests found
...@@ -3,10 +3,12 @@ include("base_building_blocks.jl") ...@@ -3,10 +3,12 @@ include("base_building_blocks.jl")
include("building_blocks.jl") include("building_blocks.jl")
include("trapezoids.jl") include("trapezoids.jl")
include("spoilt_slice_selects.jl") include("spoilt_slice_selects.jl")
include("wait_blocks.jl")
import .BaseBuildingBlocks: waveform, waveform_sequence, events, BaseBuildingBlock import .BaseBuildingBlocks: waveform, waveform_sequence, events, BaseBuildingBlock
import .BuildingBlocks: BuildingBlock import .BuildingBlocks: BuildingBlock
import .Trapezoids: Trapezoid, SliceSelect, LineReadout import .Trapezoids: Trapezoid, SliceSelect, LineReadout
import .SpoiltSliceSelects: SpoiltSliceSelect import .SpoiltSliceSelects: SpoiltSliceSelect
import ..WaitBlocks: Wait
end end
\ No newline at end of file
module WaitBlocks
import JuMP: @constraint
import ...BuildSequences: get_global_model
import ...Variables: get_free_variable, VariableType, duration
import ...Components: NoGradient
import ..BaseBuildingBlocks: BaseBuildingBlock
struct Wait <: BuildingBlock
duration :: VariableType
function Wait(var)
res = new(get_free_variable(var))
if !(res.duration isa Number)
@constraint get_global_model() res.duration >= 0
end
end
end
duration(wb::Wait) = wb.duration
Base.keys(::Wait) = (:empty)
Base.getindex(wb::Wait) = NoGradient{1}(wb.duration)
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment