class Syskit::Actions::Models::Action

Representation of the deployment of a syskit instance requirement on the action interface

Attributes

requirements[R]

The instance requirement object for this action

It is the “pure” requirements, where the enclsoing DI context is not yet injected

@return [InstanceRequirements]

Public Class Methods

new(requirements, doc = nil) click to toggle source
Calls superclass method
# File lib/syskit/actions/action_model.rb, line 15
def initialize(requirements, doc = nil)
    super(doc)
    @requirements = requirements
    returns(requirements.proxy_task_model)
end

Public Instance Methods

droby_dump!(peer) click to toggle source

Called by Roby::Actions::Models::Action to modify self so that it is droby-marshallable

It only resets the requirements attribute, as InstanceRequirements are not (yet) marshallable in droby

Calls superclass method
# File lib/syskit/actions/action_model.rb, line 110
def droby_dump!(peer)
    super
    @requirements = peer.dump(requirements)
end
initialize_copy(old) click to toggle source
Calls superclass method
# File lib/syskit/actions/action_model.rb, line 58
def initialize_copy(old)
    super
    @requirements = old.requirements.dup
end
instanciate(plan, **arguments) click to toggle source

Instanciate this action on the given plan

# File lib/syskit/actions/action_model.rb, line 90
def instanciate(plan, **arguments)
    plan.add(task = plan_pattern(**arguments))
    task
end
method_missing(m, *args, &block) click to toggle source
Calls superclass method
# File lib/syskit/actions/action_model.rb, line 131
def method_missing(m, *args, &block)
    if requirements.respond_to?(m)
        req = requirements.dup
        req.send(m, *args, &block)
        Actions::Models::Action.new(req, doc)
    else super
    end
end
new(**arguments) click to toggle source

@return [Action] an action instance based on this model

# File lib/syskit/actions/action_model.rb, line 64
def new(**arguments)
    Actions::Action.new(self, **arguments)
end
plan_pattern(**arguments) click to toggle source
# File lib/syskit/actions/action_model.rb, line 68
def plan_pattern(**arguments)
    job_id = Hash.new
    if arguments.has_key?(:job_id)
        job_id[:job_id] = arguments.delete(:job_id)
    end
    req = to_instance_requirements(**arguments)
    placeholder = req.as_plan(**job_id)
    placeholder.planning_task.action_model = self
    placeholder.planning_task.action_arguments = req.arguments
    placeholder
end
proxy!(peer) click to toggle source
Calls superclass method
# File lib/syskit/actions/action_model.rb, line 115
def proxy!(peer)
    super
    if @requirements_model # Backward compatibility
        @requirements.add_models([peer.local_object(@requirements_model)])
        @requirements.name = @requirements_name
        @requirements.with_arguments(peer.local_object(@requirements_arguments))
        @requirements_model = @requirements_name = @requirements_arguments = nil
    else
        @requirements = peer.local_object(@requirements)
    end
end
rebind(action_interface_model) click to toggle source

Rebind this action to another action interface

# File lib/syskit/actions/action_model.rb, line 37
def rebind(action_interface_model)
    # NOTE: use_profile maps all definitions into the new profile.
    # NOTE: DI injection will happen at this point, and we just
    # NOTE: have to look for already-defined actions
    if overloaded = action_interface_model.actions[name]
        overloaded
    else
        dup
    end
end
rebind_requirements(profile) click to toggle source

Create a new action with the same arguments but the requirements rebound to a new profile

@param [Profile] the profile onto which definitions should be

rebound

@return [Action]

# File lib/syskit/actions/action_model.rb, line 54
def rebind_requirements(profile)
    requirements.rebind(profile).to_action_model
end
respond_to_missing?(m, include_private) click to toggle source
Calls superclass method
# File lib/syskit/actions/action_model.rb, line 127
def respond_to_missing?(m, include_private)
    requirements.respond_to?(m) || super
end
run(action_interface, **arguments) click to toggle source

Injects the tasks necessary to deploy requirements on the plan associated with the given action interface

@param [ActionInterface] the action interface @param [Hash] arguments the arguments (unused) @return [Roby::Task] the action task

# File lib/syskit/actions/action_model.rb, line 101
def run(action_interface, **arguments)
    instanciate(action_interface.plan, **arguments)
end
to_instance_requirements(**arguments) click to toggle source
# File lib/syskit/actions/action_model.rb, line 80
def to_instance_requirements(**arguments)
    if !requirements.has_template? && requirements.can_use_template?
        requirements.compute_template
    end
    req = requirements.dup
    req.with_arguments(**arguments)
    req
end
to_s() click to toggle source
# File lib/syskit/actions/action_model.rb, line 21
def to_s
    name =
        if (requirement_name = requirements.name)
            "#{requirement_name}_def"
        else
            requirements.to_s
        end

    if requirements.respond_to?(:profile)
        "#{name} of #{requirements.profile}"
    else
        name
    end
end