class OpenTrons::Instruments

Attributes

instrument_hash[RW]
protocol[RW]

Public Class Methods

new(protocol) click to toggle source
# File lib/opentrons/instruments.rb, line 16
def initialize(protocol)
        @protocol = protocol
        @instrument_hash = {}
end

Public Instance Methods

add_pipette(model, mount: "left", tip_racks: [], tip_model: nil) click to toggle source
# File lib/opentrons/instruments.rb, line 33
def add_pipette(model, mount: "left", tip_racks: [], tip_model: nil)
        instrument_hash.each do |key, item|
                if item.mount == mount
                        raise ArgumentError.new "Cannot place #{model} on mount #{mount} (already occupied)."
                end
        end

        generated_id = ""
        loop do
                generated_id = model + "-" + rand(100000...999999).to_s
                break if !(instrument_hash.key? generated_id)
        end

        if model.include? "multi"
                pipette = MultiPipette.new(protocol, self, model, mount: mount, tip_racks: tip_racks, tip_model: tip_model)
        else
                pipette = Pipette.new(protocol, self, model, mount: mount, tip_racks: tip_racks, tip_model: tip_model)
        end

        instrument_hash[generated_id] = pipette

        return pipette
end
inspect() click to toggle source
# File lib/opentrons/instruments.rb, line 69
def inspect
        to_s
end
to_hash() click to toggle source
# File lib/opentrons/instruments.rb, line 57
def to_hash
        as_hash = {}
        instrument_hash.each do |key, item|
                as_hash[key] = item.to_hash
        end
        return as_hash
end
to_s() click to toggle source
# File lib/opentrons/instruments.rb, line 65
def to_s
        "<OpenTrons::Instruments:0x#{self.__id__.to_s(16)}>"
end