class OpenTrons::Labware

Attributes

labware_definitions[RW]
labware_hash[RW]
protocol[RW]

Public Class Methods

new(protocol) click to toggle source
# File lib/opentrons/labware.rb, line 5
def initialize(protocol)
        @protocol = protocol
        @labware_hash = {}
        
        #TODO: Better system for dealing with labware defs, including user-specified.
        @labware_definitions = []
        directory = File.expand_path(File.dirname(__FILE__))
        directory = File.join(directory, "..", "..", "definitions")
        Dir[directory + "/*.json"].each do |filename|
                labware_definitions << JSON.parse(File.read(filename))
        end
end

Public Instance Methods

free_slots() click to toggle source
# File lib/opentrons/labware.rb, line 32
def free_slots
        slots = (1..12).to_a.map{|x| x.to_s}
        taken_slots = labware_hash.map {|key, item| item.slot}
        return slots.select{|x| !(taken_slots.include? x)}
end
inspect() click to toggle source
# File lib/opentrons/labware.rb, line 51
def inspect
        to_s
end
load(model, slot, display_name="") click to toggle source
# File lib/opentrons/labware.rb, line 18
def load(model, slot, display_name="")
        generated_id = ""
        loop do
                generated_id = display_name + "-" + rand(100000...999999).to_s
                break if !(labware_hash.key?(generated_id))
        end

        labware_item = LabwareItem.new(self, model, slot, display_name)

        labware_hash[generated_id] = labware_item

        return labware_item
end
to_hash() click to toggle source

Returns a pure hash of hashes.

# File lib/opentrons/labware.rb, line 39
def to_hash
        as_hash = {}
        labware_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/labware.rb, line 47
def to_s
        "<OpenTrons::Labware:#{object_id}>"
end