Class: Roby::Coordination::Script::PollUntil
- Inherits:
-
Roby::Coordination::ScriptInstruction
- Object
- Roby::Coordination::ScriptInstruction
- Roby::Coordination::Script::PollUntil
- Defined in:
- lib/roby/coordination/script.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#root_task ⇒ Object
readonly
Returns the value of attribute root_task.
Instance Method Summary collapse
- #cancel ⇒ Object
- #execute(script) ⇒ Object
-
#initialize(root_task, event, block) ⇒ PollUntil
constructor
A new instance of PollUntil.
Constructor Details
#initialize(root_task, event, block) ⇒ PollUntil
51 52 53 54 55 56 57 |
# File 'lib/roby/coordination/script.rb', line 51 def initialize(root_task, event, block) super() @root_task = root_task @event = event @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
49 50 51 |
# File 'lib/roby/coordination/script.rb', line 49 def block @block end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
49 50 51 |
# File 'lib/roby/coordination/script.rb', line 49 def event @event end |
#root_task ⇒ Object (readonly)
Returns the value of attribute root_task.
49 50 51 |
# File 'lib/roby/coordination/script.rb', line 49 def root_task @root_task end |
Instance Method Details
#cancel ⇒ Object
59 60 61 62 |
# File 'lib/roby/coordination/script.rb', line 59 def cancel root_task.remove_poll_handler(@poll_handler_id) if @poll_handler_id super end |
#execute(script) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/roby/coordination/script.rb', line 64 def execute(script) @poll_handler_id = root_task.poll do root_task.instance_eval(&block) end event = self.event.resolve event.once(on_replace: :copy) do |ev| if !disabled? && ev.generator == self.event.resolve cancel script.step end end root_task = script.root_task event_task = event.task if (event_task != root_task) && !root_task.depends_on?(event_task) root_task.depends_on event_task, success: event.symbol else event.when_unreachable(true) do |reason, _generator| unless disabled? raise Script::DeadInstruction.new(script.root_task), "the 'until' condition of #{self} will "\ "never be reached: #{reason}" end end end false end |