class Roby::StateConditionEvent

Implementation of StateSpace#trigger_when

Attributes

condition[R]
state_space[R]
variable_path[R]

Public Class Methods

new(state_space = nil, variable_path = [], condition = nil) click to toggle source
Calls superclass method Roby::StateEvent::new
# File lib/roby/state/events.rb, line 165
def initialize(state_space = nil, variable_path = [], condition = nil)
    @state_space, @variable_path, @condition =
        state_space, variable_path, condition
    super(false)
end

Public Instance Methods

poll() click to toggle source
# File lib/roby/state/events.rb, line 171
def poll
    return if !armed?

    if !variable_path.empty?
        value = variable_path.inject(state_space) do |value, element|
            result =
                if value.respond_to?("#{element}?")
                    if value.send("#{element}?")
                        value.send(element)
                    end
                elsif value.respond_to?(element)
                    value.send(element)
                end

            if !result
                break
            end
            result
        end

        if value && condition.call(value)
            emit
        end
    elsif condition.call
        emit
    end
end