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
Returns a new instance of PollUntil.
42 43 44 |
# File 'lib/roby/coordination/script.rb', line 42 def initialize(root_task, event, block) @root_task, @event, @block = root_task, event, block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
41 42 43 |
# File 'lib/roby/coordination/script.rb', line 41 def block @block end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
41 42 43 |
# File 'lib/roby/coordination/script.rb', line 41 def event @event end |
#root_task ⇒ Object (readonly)
Returns the value of attribute root_task.
41 42 43 |
# File 'lib/roby/coordination/script.rb', line 41 def root_task @root_task end |
Instance Method Details
#cancel ⇒ Object
46 47 48 49 50 51 |
# File 'lib/roby/coordination/script.rb', line 46 def cancel if @poll_handler_id root_task.remove_poll_handler(@poll_handler_id) end super end |
#execute(script) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/roby/coordination/script.rb', line 53 def execute(script) @poll_handler_id = root_task.poll do root_task.instance_eval(&block) end event = self.event.resolve event.on do |ev| if ev.generator == self.event.resolve && !disabled? cancel script.step end end if event.task != script.root_task script.root_task.depends_on event.task, success: event.symbol else event.when_unreachable(true) do |reason, generator| if !disabled? raise Script::DeadInstruction.new(script.root_task), "the 'until' condition of #{self} will never be reached: #{reason}" end end end false end |