class Roby::Coordination::Models::Script::Wait
Script
element that implements {Script#wait}
Attributes
event[R]
time_barrier[R]
@return [Time,nil] time after which an emission is valid.
'nil' means that only emissions that have happened after the script reached this instruction are considered
timeout[R]
@return [Float] number of seconds after which the wait
instruction should generate an error
Public Class Methods
new(event, after: nil)
click to toggle source
@option options [Float] :timeout (nil) value for {#timeout} @option options [Time] :after (nil) value for
{#time_barrier}
# File lib/roby/coordination/models/script.rb, line 58 def initialize(event, after: nil) @event = event @done = false @time_barrier = after end
Public Instance Methods
execute(script)
click to toggle source
# File lib/roby/coordination/models/script.rb, line 68 def execute(script) event = self.event.resolve plan = script.plan root_task = script.root_task if time_barrier last_event = event.history.last if last_event && last_event.time > time_barrier return true end end if event.unreachable? plan.add_error(DeadInstruction.new(script.root_task)) return false end if event.task != root_task role_name = "wait_#{self.object_id}" current_roles = (root_task.depends_on?(event.task) && root_task.roles_of(event.task)) root_task.depends_on event.task, success: nil, role: role_name end event.if_unreachable(cancel_at_emission: true) do |reason, generator| if !disabled? generator.plan.add_error(DeadInstruction.new(script.root_task)) end end event.on on_replace: :copy do |event| if event.generator == self.event.resolve && !disabled? if !time_barrier || event.time > time_barrier if role_name && (child = script.root_task.find_child_from_role(role_name)) script.root_task.remove_roles(child, role_name, remove_child_when_empty: !current_roles || !current_roles.empty?) end cancel script.step end end end false end
new(script)
click to toggle source
# File lib/roby/coordination/models/script.rb, line 64 def new(script) Wait.new(script.instance_for(event), after: time_barrier) end
to_s()
click to toggle source
# File lib/roby/coordination/models/script.rb, line 116 def to_s; "wait(#{event})" end
waited_task_role()
click to toggle source
# File lib/roby/coordination/models/script.rb, line 112 def waited_task_role "wait_#{object_id}" end