Class: Roby::Coordination::Script::TimeoutStart

Inherits:
Roby::Coordination::ScriptInstruction show all
Defined in:
lib/roby/coordination/script.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Roby::Coordination::ScriptInstruction

#cancel

Constructor Details

#initialize(model, event) ⇒ TimeoutStart

Returns a new instance of TimeoutStart.



95
96
97
98
# File 'lib/roby/coordination/script.rb', line 95

def initialize(model, event)
    @model = model
    @event = event
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



92
93
94
# File 'lib/roby/coordination/script.rb', line 92

def event
  @event
end

#modelObject (readonly)

Returns the value of attribute model.



91
92
93
# File 'lib/roby/coordination/script.rb', line 91

def model
  @model
end

#timeout_stopObject

Returns the value of attribute timeout_stop.



93
94
95
# File 'lib/roby/coordination/script.rb', line 93

def timeout_stop
  @timeout_stop
end

Instance Method Details

#execute(script) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/roby/coordination/script.rb', line 100

def execute(script)
    script.root_task.execution_engine.delayed(model.seconds) do
        if !self.disabled?
            # Remove all instructions that are within the
            # timeout's scope
            if event
                event.resolve.emit
                script.jump_to(timeout_stop)
            else
                raise TimedOut.new(script.root_task, script.current_instruction), "#{script.current_instruction} timed out"
            end
        end
    end
    true
end