Class: Robots::Bed::PlateToTubeRacksBed

Inherits:
Base
  • Object
show all
Defined in:
app/models/robots/bed/plate_to_tube_racks_bed.rb

Overview

This bed hosts the parent plate or a tube-rack. It uses the robot to find its labware and child labware. When it is used as a source bed, it should host the Plate. When it is used as a destination bed, it should host a tube-rack wrapper.

Instance Method Summary collapse

Instance Method Details

#change_tube_state(tube) ⇒ Object

Changes the state of one tube to the target state. This method is called by the transition method.

Parameters:

  • tube (Tube)

    the tube for which the state should be changed



61
62
63
64
# File 'app/models/robots/bed/plate_to_tube_racks_bed.rb', line 61

def change_tube_state(tube)
  state_changer = StateChangers.lookup_for(tube.purpose.uuid)
  state_changer.new(api, tube.uuid, user_uuid).move_to!(target_state, "Robot #{robot.name} started")
end

#child_labwareArray<TubeRackWrapper>

Returns an array of labware from the robot’s labware store for barcodes.

Returns:



30
31
32
33
34
# File 'app/models/robots/bed/plate_to_tube_racks_bed.rb', line 30

def child_labware
  return [] if labware.blank?

  @child_labware ||= robot.child_labware(labware)
end

#labware_created_with_robot(robot_barcode) ⇒ void

This method returns an undefined value.

Updates the metadata of the labware with the robot barcode. This method is called inside the robot controller’s start action for tube-rack wrappers and it sets the created_with_robot metadata field.

Parameters:

  • robot_barcode (String)

    the robot barcode



17
18
19
20
21
22
23
24
# File 'app/models/robots/bed/plate_to_tube_racks_bed.rb', line 17

def labware_created_with_robot(robot_barcode)
  # RobotController uses machine barcode for initialising LabwareMetadata
  labware.tubes.each do |tube|
    LabwareMetadata
      .new(api: api, user: user_uuid, barcode: tube.barcode.machine)
      .update!(created_with_robot: robot_barcode)
  end
end

#load(barcodes) ⇒ void

This method returns an undefined value.

Loads labware into this bed from the robot’s labware store.

Parameters:

  • barcodes (Array<String>)

    array containing the barcode of the labware



41
42
43
44
# File 'app/models/robots/bed/plate_to_tube_racks_bed.rb', line 41

def load(barcodes)
  @barcodes = Array(barcodes).filter_map(&:strip).uniq
  @labware = @barcodes.present? ? robot.find_bed_labware(@barcodes) : []
end

#transitionvoid

This method returns an undefined value.

Changes the state of the labware to the target state. It will change the state of all tubes of the tube-rack on this bed.



51
52
53
54
55
# File 'app/models/robots/bed/plate_to_tube_racks_bed.rb', line 51

def transition
  return if target_state.nil? || labware.nil? # We have nothing to do

  labware.tubes.each { |tube| change_tube_state(tube) }
end