class Roby::Actions::Action

The representation of an action, as a model and arguments

Attributes

arguments[R]

The action arguments @return [Hash]

model[RW]

The action model @return [Models::Action]

Public Class Methods

new(model, **arguments) click to toggle source
# File lib/roby/actions/action.rb, line 12
def initialize(model, **arguments)
    @model, @arguments = model, arguments
end

Public Instance Methods

==(other) click to toggle source
# File lib/roby/actions/action.rb, line 20
def ==(other)
    other.kind_of?(Action) &&
        model == other.model &&
        arguments == other.arguments
end
as_plan(**arguments) click to toggle source

Returns a plan pattern that would deploy this action in the plan @return [Roby::Task] the task, with a planning task of type

{Actions::Task}
# File lib/roby/actions/action.rb, line 54
def as_plan(**arguments)
    model.plan_pattern(**self.arguments.merge(arguments))
end
has_missing_required_arg?() click to toggle source
# File lib/roby/actions/action.rb, line 35
def has_missing_required_arg?
    model.arguments.any? do |arg|
        arg_sym = arg.name.to_sym
        if arguments.has_key?(arg_sym)
            TaskArguments.delayed_argument?(arguments.fetch(arg_sym))
        else
            arg.required?
        end
    end
end
instanciate(plan, **arguments) click to toggle source

Deploys this action on the given plan

# File lib/roby/actions/action.rb, line 63
def instanciate(plan, **arguments)
    model.instanciate(plan, self.arguments.merge(arguments))
end
name() click to toggle source
# File lib/roby/actions/action.rb, line 16
def name
    model.name
end
rebind(action_interface_model) click to toggle source
# File lib/roby/actions/action.rb, line 58
def rebind(action_interface_model)
    model.rebind(action_interface_model).new(**arguments)
end
returned_type() click to toggle source

The task model returned by this action

# File lib/roby/actions/action.rb, line 47
def returned_type
    model.returned_type
end
to_action() click to toggle source
# File lib/roby/actions/action.rb, line 75
def to_action
    self
end
to_coordination_task(task_model = Roby::Task) click to toggle source
# File lib/roby/actions/action.rb, line 71
def to_coordination_task(task_model = Roby::Task)
    Coordination::Models::TaskFromAction.new(self)
end
to_s() click to toggle source
# File lib/roby/actions/action.rb, line 67
def to_s
    "#{model}(#{arguments.map { |k,v| "#{k} => #{v}" }.sort.join(", ")})"
end
with_arguments(**arguments) click to toggle source

Update this object with new arguments and returns it

@param [Hash] arguments new arguments @return [self]

# File lib/roby/actions/action.rb, line 30
def with_arguments(**arguments)
    @arguments.merge!(arguments)
    self
end