class Syskit::DeviceAllocationFailed

Exception raised when we could not find devices to allocate for tasks that are device drivers

Attributes

candidates[R]

Existing candidates for this device

failed_tasks[R]

The set of tasks that failed allocation

task_parents[R]

A task to parents mapping for tasks involved in this error, at the time of the exception creation

Public Class Methods

new(plan, tasks) click to toggle source
# File lib/syskit/exceptions.rb, line 362
def initialize(plan, tasks)
    @failed_tasks = tasks.dup
    @candidates = Hash.new
    @task_parents = Hash.new

    tasks.each do |abstract_task|
        resolve_device_task(plan, abstract_task)
    end
end

Public Instance Methods

pretty_print(pp) click to toggle source
# File lib/syskit/exceptions.rb, line 399
def pretty_print(pp)
    pp.text "cannot find a device to tie to #{failed_tasks.size} task(s)"

    failed_tasks.each do |task|
        parents = task_parents[task]
        candidates = self.candidates[task]

        pp.breakable
        pp.text "for #{task.to_s.gsub(/Syskit::/, '')}"
        pp.nest(2) do
            if !parents.empty?
                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

            pp.breakable
            pp.seplist(candidates) do |cand|
                srv, tasks = *cand
                if tasks.empty?
                    pp.text "no candidates for #{srv.short_name}"
                else
                    pp.text "candidates for #{srv.short_name}"
                    pp.nest(2) do
                        pp.breakable
                        pp.seplist(tasks) do |cand_t|
                            pp.text "#{cand_t}"
                        end
                    end
                end
            end
        end
    end
end
resolve_device_task(plan, abstract_task) click to toggle source
# File lib/syskit/exceptions.rb, line 372
def resolve_device_task(plan, abstract_task)
    all_tasks = [abstract_task].to_set

    # List the possible candidates for the missing devices
    candidates = Hash.new
    abstract_task.model.each_master_driver_service do |srv|
        if !abstract_task.arguments[:"#{srv.name}_dev"]
            candidates[srv] = plan.find_local_tasks(srv.model).to_set
            candidates[srv].delete(abstract_task)
            all_tasks |= candidates[srv]
        end
    end
    self.candidates[abstract_task] = candidates

    all_tasks.each do |t|
        next if task_parents.has_key?(t)

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