Exception: Syskit::ConflictingDeviceAllocation

Inherits:
SpecError show all
Defined in:
lib/syskit/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device, task0, task1) ⇒ ConflictingDeviceAllocation

Returns a new instance of ConflictingDeviceAllocation



448
449
450
451
452
453
454
455
456
457
# File 'lib/syskit/exceptions.rb', line 448

def initialize(device, task0, task1)
    @device, @tasks = device, [task0, task1]
    @can_merge = task0.can_merge?(task1) || task1.can_merge?(task0)
    if can_merge?
        # Mismatching inputs ... gather more info
        @inputs = Array.new
        @inputs[0] = task0.each_concrete_input_connection.to_a
        @inputs[1] = task1.each_concrete_input_connection.to_a
    end
end

Instance Attribute Details

#deviceObject (readonly)

Returns the value of attribute device



442
443
444
# File 'lib/syskit/exceptions.rb', line 442

def device
  @device
end

#inputsObject (readonly)

Returns the value of attribute inputs



444
445
446
# File 'lib/syskit/exceptions.rb', line 444

def inputs
  @inputs
end

#tasksObject (readonly)

Returns the value of attribute tasks



443
444
445
# File 'lib/syskit/exceptions.rb', line 443

def tasks
  @tasks
end

Instance Method Details

#can_merge?Boolean

Returns:

  • (Boolean)


446
# File 'lib/syskit/exceptions.rb', line 446

def can_merge?; !!@can_merge end

#pretty_print(pp) ⇒ Object



459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# File 'lib/syskit/exceptions.rb', line 459

def pretty_print(pp)
    pp.text "device #{device.name} is assigned to two tasks"
    if can_merge?
        pp.text " that have mismatching inputs"
        tasks.each_with_index do |t, i|
            pp.breakable
            t.pretty_print(pp)
            pp.breakable
            pp.text "#{inputs[i].size} input(s):"
            inputs[i].each do |source_task, source_port, sink_port|
                pp.breakable
                pp.text "  #{source_task}.#{source_port} -> #{sink_port}"
            end
        end
    else
        pp.text " that cannot be merged"
        tasks.each do |t|
            pp.breakable
            t.pretty_print(pp)
        end
    end
end