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

Separate printing for sequences and non-sequences

parent a4fd5e03
No related branches found
No related tags found
No related merge requests found
......@@ -209,7 +209,6 @@ function Base.show(io::IO, printer::BuildingBlockPrinter)
ft = fieldtype(typeof(block), name)
if (
ft in (VariableType, Model) ||
ft <: BuildingBlock ||
(ft <: AbstractVector && eltype(ft) == VariableType) ||
string(name)[1] == '_'
)
......@@ -235,19 +234,6 @@ function Base.show(io::IO, printer::BuildingBlockPrinter)
print(io, "$(nameof(fn))=$(printed_value), ")
end
print(io, ")")
if block isa ContainerBlock
use_start_time = isnothing(printer.start_time) ? 0. : printer.start_time
print(io, ":")
for (child_index, child_block) in get_children_blocks(block)
child_printer = BuildingBlockPrinter(
child_block,
_robust_value(start_time(block, child_index) + use_start_time),
printer.spaces + 2
)
print(io, "\n", repeat(' ', printer.spaces + 2), "- ", child_index, ": ", child_printer)
end
end
end
......
......@@ -2,10 +2,11 @@
Define the [`Sequence`](@ref) building block.
"""
module Sequences
import Printf: @sprintf
import JuMP: Model, @constraint
import ...BuildSequences: @global_model_constructor
import ...Variables: variables, start_time, duration, VariableType, get_free_variable, TR, end_time
import ...BuildingBlocks: BuildingBlock, ContainerBlock, to_block, get_children_indices, scanner_constraints!, fixed, BuildingBlockPrinter
import ...BuildingBlocks: BuildingBlock, ContainerBlock, to_block, get_children_indices, scanner_constraints!, fixed, BuildingBlockPrinter, _robust_value, get_children_blocks
"""
Sequence(building_blocks...; TR=nothing, scanner=nothing)
......@@ -64,9 +65,34 @@ variables(::Type{<:Sequence}) = [TR]
# print timings when printing sequences
Base.show(io::IO, seq::Sequence) = print(io, BuildingBlockPrinter(seq, 0., 0))
function Base.show(io::IO, printer::BuildingBlockPrinter{<:Sequence})
seq = printer.bb
print(io, "Sequence(")
d = _robust_value(duration(seq))
if !isnothing(d)
if !isnothing(printer.start_time)
print(io, "t=", @sprintf("%.3g", printer.start_time), "-", @sprintf("%.3g", printer.start_time + d), ", ")
else
print(io, "duration=", @sprintf("%.3g", d), ",")
end
end
TR = _robust_value(seq.TR)
if !isnothing(TR)
print(io, "TR=", Int(round(TR)))
end
print(io, "):")
end
for (child_index, child_block) in get_children_blocks(seq)
child_printer = BuildingBlockPrinter(
child_block,
isnothing(printer.start_time) ? nothing : _robust_value(start_time(seq, child_index) + printer.start_time),
printer.spaces + 2
)
print(io, "\n", repeat(' ', printer.spaces + 2), "- ", child_index, ": ", child_printer)
end
end
end
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