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.



109
110
111
112
113
114
# File 'lib/roby/coordination/script.rb', line 109

def initialize(model, event)
    super()

    @model = model
    @event = event
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



106
107
108
# File 'lib/roby/coordination/script.rb', line 106

def event
  @event
end

#modelObject (readonly)

Returns the value of attribute model.



106
107
108
# File 'lib/roby/coordination/script.rb', line 106

def model
  @model
end

#timeout_stopObject

Returns the value of attribute timeout_stop.



107
108
109
# File 'lib/roby/coordination/script.rb', line 107

def timeout_stop
  @timeout_stop
end

Instance Method Details

#execute(script) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/roby/coordination/script.rb', line 116

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