Class: Roby::Actions::Models::CoordinationAction

Inherits:
Action show all
Includes:
DRoby::V5::Actions::Models::CoordinationActionDumper
Defined in:
lib/roby/actions/models/coordination_action.rb,
lib/roby/droby/enable.rb

Overview

Action defined by a coordination model

Constant Summary collapse

None =
Object.new

Constants inherited from Action

Action::Void, Action::VoidClass

Instance Attribute Summary collapse

Attributes inherited from Action

#arguments, #doc, #name, #returned_type

Instance Method Summary collapse

Methods included from DRoby::V5::Actions::Models::CoordinationActionDumper

#droby_dump!, #proxy

Methods included from DRoby::V5::Actions::Models::InterfaceActionDumper

#droby_dump!, #proxy_from_existing

Methods inherited from Action

#advanced, #as_plan, #each_arg, #find_arg, #has_arg?, #has_required_arg?, #initialize_copy, #new, #normalize_arguments, #optional_arg, #overloads, #pretty_print, #pretty_print_arguments, #required_arg, #returned_task_type, #returns, #to_action, #to_action_model, #validate_can_overload

Methods included from DRoby::V5::Actions::Models::ActionDumper

#droby_dump, #droby_dump!, #proxy, #proxy!

Constructor Details

#initialize(coordination_model, doc = nil) ⇒ CoordinationAction

Returns a new instance of CoordinationAction.



13
14
15
16
# File 'lib/roby/actions/models/coordination_action.rb', line 13

def initialize(coordination_model, doc = nil)
    super(doc)
    @coordination_model = coordination_model
end

Instance Attribute Details

#coordination_modelnil, Coordination::Models::Base

If this action is actually a coordination model, returns it

Returns:



11
12
13
# File 'lib/roby/actions/models/coordination_action.rb', line 11

def coordination_model
  @coordination_model
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
26
# File 'lib/roby/actions/models/coordination_action.rb', line 23

def ==(other)
    other.kind_of?(self.class) &&
        other.coordination_model == coordination_model
end

#action_interface_modelObject

The underlying action interface model



19
20
21
# File 'lib/roby/actions/models/coordination_action.rb', line 19

def action_interface_model
    coordination_model.action_interface
end

#instanciate(plan, arguments = {}) ⇒ Object



38
39
40
41
42
# File 'lib/roby/actions/models/coordination_action.rb', line 38

def instanciate(plan, arguments = {})
    plan.add(root = coordination_model.task_model.new)
    coordination_model.new(root, arguments)
    root
end

#plan_pattern(job_id: None, **action_arguments) ⇒ Object

Returns the plan pattern that will deploy this action on the plan



47
48
49
50
51
52
53
54
55
56
# File 'lib/roby/actions/models/coordination_action.rb', line 47

def plan_pattern(job_id: None, **action_arguments)
    job_id = ({ job_id: job_id } if job_id != None)

    arguments = {
        action_model: self,
        action_arguments: action_arguments
    }.merge(job_id || {})
    planner = Roby::Actions::Task.new(**arguments)
    planner.planning_result_task
end

#rebind(action_interface_model) ⇒ Action

Create a new action model that is bound to a different interface model

Parameters:

  • action_interface_model (Models::Interface)

    the new model

  • force (Boolean)

    the rebind will happen only if the new interface model is a submodel of the current one. If force is true, it will be done regardless.

Returns:

  • (Action)

    the rebound action model



29
30
31
32
33
34
35
36
# File 'lib/roby/actions/models/coordination_action.rb', line 29

def rebind(action_interface_model)
    rebound = dup
    if action_interface_model < self.action_interface_model
        rebound.coordination_model = coordination_model
            .rebind(action_interface_model)
    end
    rebound
end

#to_sObject



58
59
60
# File 'lib/roby/actions/models/coordination_action.rb', line 58

def to_s
    "#{action_interface_model.name}.#{name}[#{coordination_model}]"
end