class Syskit::TaskAllocationFailed

Exception raised when we could not find concrete implementations for abstract tasks that are in the plan

Attributes

abstract_tasks[R]

A task to [parents, candidates] mapping for the failed allocations

Public Class Methods

new(engine, still_abstract) click to toggle source

Creates a new TaskAllocationFailed exception for the given tasks.

tasks is a mapping from the abstract tasks to the possible candidate implementation for these tasks, i.e.

t => [model0, model1, ...]
# File lib/syskit/exceptions.rb, line 295
def initialize(engine, still_abstract)
    @abstract_tasks = Hash.new

    still_abstract.each do |task|
        if task.respond_to?(:proxied_data_services)
            component_models = Syskit::Component.each_submodel.to_a
            per_service_candidates = task.proxied_data_services.map do |m|
                component_models.find_all { |component_m| !component_m.abstract? && !component_m.private_specialization? && component_m.fullfills?(m) }.to_set
            end
            candidates = per_service_candidates.inject { |a, b| a & b } || Set.new
        else
            candidates = task.plan.find_local_tasks(task.concrete_model).not_abstract.to_set
        end

        parents = task.
            enum_for(:each_parent_object, Roby::TaskStructure::Dependency).
            map do |parent_task|
                options = parent_task[task,
                    Roby::TaskStructure::Dependency]
                [options[:roles], parent_task]
            end
        abstract_tasks[task] = [parents, candidates]
    end
end

Public Instance Methods

pretty_print(pp) click to toggle source
# File lib/syskit/exceptions.rb, line 320
def pretty_print(pp)
    pp.text "cannot find a concrete implementation for #{abstract_tasks.size} task(s)"

    abstract_tasks.each do |task, (parents, candidates)|
        pp.breakable
        pp.text "#{task.to_s.gsub(/Syskit::/, '')}"
        pp.nest(2) do
            pp.breakable
            if candidates
                if candidates.empty?
                    pp.text "no candidates"
                else
                    pp.text "#{candidates.size} candidates"
                    pp.nest(2) do
                        pp.breakable
                        pp.seplist(candidates) do |c_task|
                            pp.text "#{c_task.short_name}"
                        end
                    end
                end
            end
            pp.breakable
            pp.seplist(parents) do |parent|
                role, parent = parent
                pp.text "child #{role.to_a.first} of #{parent.to_s.gsub(/Syskit::/, '')}"
            end
        end
    end
end