Module: Roby::LoggedPlan
- Defined in:
- lib/roby/log/dot.rb,
lib/roby/log/relations.rb
Constant Summary collapse
- PLAN_STROKE_WIDTH =
5
Instance Attribute Summary collapse
-
#depth ⇒ Object
readonly
The plan depth, i.e.
-
#dot_id ⇒ Object
readonly
Returns the value of attribute dot_id.
-
#layout_level ⇒ Object
Returns the value of attribute layout_level.
-
#max_depth ⇒ Object
readonly
The max depth of the plan tree in this branch.
Instance Method Summary collapse
- #all_events(display) ⇒ Object
- #apply_layout(bounding_rects, positions, display, max_depth = nil) ⇒ Object
-
#compute_depth(depth) ⇒ Object
Computes the plan depths and max_depth for this plan and all its children.
- #display(display, item) ⇒ Object
- #display_create(display) ⇒ Object
- #display_parent ⇒ Object
- #each_displayed_relation(display, space, objects) ⇒ Object
- #layout_relations(positions, display, space, objects) ⇒ Object
- #relations_to_dot(display, io, space, objects) ⇒ Object
- #to_dot(display, io, level) ⇒ Object
Instance Attribute Details
#depth ⇒ Object (readonly)
The plan depth, i.e. its distance from the root plan
81 82 83 |
# File 'lib/roby/log/dot.rb', line 81 def depth @depth end |
#dot_id ⇒ Object (readonly)
Returns the value of attribute dot_id.
19 20 21 |
# File 'lib/roby/log/dot.rb', line 19 def dot_id @dot_id end |
#layout_level ⇒ Object
Returns the value of attribute layout_level.
8 9 10 |
# File 'lib/roby/log/dot.rb', line 8 def layout_level @layout_level end |
#max_depth ⇒ Object (readonly)
The max depth of the plan tree in this branch
239 240 241 |
# File 'lib/roby/log/relations.rb', line 239 def max_depth @max_depth end |
Instance Method Details
#all_events(display) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/roby/log/dot.rb', line 9 def all_events(display) known_tasks.inject(free_events.dup) do |events, task| if display.displayed?(task) events.merge(task.events.values.to_value_set) else events end end end |
#apply_layout(bounding_rects, positions, display, max_depth = nil) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/roby/log/dot.rb', line 95 def apply_layout(bounding_rects, positions, display, max_depth = nil) max_depth ||= compute_depth(0) if rect = bounding_rects[dot_id] item = display[self] rect[2] *= 1.2 rect[3] *= 1.2 item.z_value = Log::PLAN_LAYER + depth - max_depth item.set_rect *rect else Roby::Log.warn "no bounding rectangle for #{self} (#{dot_id})" end (known_tasks | finalized_tasks | free_events | finalized_events). each do |obj| obj.apply_layout(positions, display) end transactions.each do |trsc| trsc.apply_layout(bounding_rects, positions, display, max_depth) end layout_relations(positions, display, TaskStructure, known_tasks) end |
#compute_depth(depth) ⇒ Object
Computes the plan depths and max_depth for this plan and all its children. depth is this plan depth
Returns max_depth
87 88 89 90 91 92 93 |
# File 'lib/roby/log/dot.rb', line 87 def compute_depth(depth) @depth = depth child_depth = transactions. map { |trsc| trsc.compute_depth(depth + 1) }. max child_depth || depth end |
#display(display, item) ⇒ Object
251 252 253 |
# File 'lib/roby/log/relations.rb', line 251 def display(display, item) #STDERR.puts "DISPLAYING PLAN\n #{caller.join("\n ")}" end |
#display_create(display) ⇒ Object
241 242 243 244 245 246 247 248 249 |
# File 'lib/roby/log/relations.rb', line 241 def display_create(display) scene = display.scene pen = Qt::Pen.new pen.width = PLAN_STROKE_WIDTH pen.style = Qt::SolidLine pen.cap_style = Qt::SquareCap pen.join_style = Qt::RoundJoin scene.add_rect Qt::RectF.new(0, 0, 0, 0), pen end |
#display_parent ⇒ Object
250 |
# File 'lib/roby/log/relations.rb', line 250 def display_parent; parent_plan end |
#each_displayed_relation(display, space, objects) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/roby/log/dot.rb', line 39 def each_displayed_relation(display, space, objects) space.relations.each do |rel| next unless display.relation_enabled?(rel) objects.each do |from| next unless display.displayed?(from) unless display[from] Roby::Log.warn "no display item for #{from} in #each_displayed_relation" next end from.each_child_object(rel) do |to| next unless display.displayed?(to) unless display[to] Roby::Log.warn "no display item for child in #{from} <#{rel}> #{to} in #each_displayed_relation" next end yield(rel, from, to) end end end end |
#layout_relations(positions, display, space, objects) ⇒ Object
74 75 76 77 78 |
# File 'lib/roby/log/dot.rb', line 74 def layout_relations(positions, display, space, objects) each_displayed_relation(display, space, objects) do |rel, from, to| display.task_relation(from, to, rel, from[to, rel]) end end |
#relations_to_dot(display, io, space, objects) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/roby/log/dot.rb', line 63 def relations_to_dot(display, io, space, objects) each_displayed_relation(display, space, objects) do |rel, from, to| from_id, to_id = from.dot_id, to.dot_id if from_id && to_id io << " #{from_id} -> #{to_id}\n" else Roby::Log.warn "ignoring #{from}(#{from.object_id} #{from_id}) -> #{to}(#{to.object_id} #{to_id}) in #{rel} in #{caller(1).join("\n ")}" end end end |
#to_dot(display, io, level) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/roby/log/dot.rb', line 20 def to_dot(display, io, level) @layout_level = level id = io.layout_id(self) @dot_id = "plan_#{id}" io << "subgraph cluster_#{dot_id} {\n" (known_tasks | finalized_tasks | free_events | finalized_events). each do |obj| obj.to_dot(display, io) if display.displayed?(obj) end io << "};\n" transactions.each do |trsc| trsc.to_dot(display, io, level + 1) end relations_to_dot(display, io, TaskStructure, known_tasks) end |