Class: Robot
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Robot
- Includes:
- Uuid::Uuidable
- Defined in:
- app/models/robot.rb
Defined Under Namespace
Modules: Generator, Verification Classes: PickData
Class Method Summary collapse
- .default_for_verification ⇒ Object
- .find_by_barcode(code) ⇒ Object (also: find_from_barcode)
- .prefix ⇒ Object
- .valid_barcode?(code) ⇒ Boolean
Instance Method Summary collapse
- #all_picks(batch) ⇒ Object
-
#generation_behaviour(generator_id) ⇒ Class
Returns the generation behaviour class for the given generator_id Looks up the RobotProperty with the give generator_id and returns the corresponding Robot::Generator class.
-
#generator(batch:, plate_barcode:, pick_number:, generator_id:) ⇒ Robot::Generator
Returns an instance of the generation behaviour for the given parameters.
- #max_beds ⇒ Object
- #pick_number_to_expected_layout(batch, plate_barcode) ⇒ Object
-
#pick_numbers(batch, plate_barcode) ⇒ Array<String>
Returns an array of all pick numbers associated with the corresponding batch and plate_barcode.
- #verification_behaviour ⇒ Object
Methods included from Uuid::Uuidable
included, #unsaved_uuid!, #uuid
Methods inherited from ApplicationRecord
alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!
Methods included from Squishify
Methods included from Warren::Callback::ExceptExternallyManaged
#broadcast_except_externally_managed, included
Class Method Details
.default_for_verification ⇒ Object
85 86 87 |
# File 'app/models/robot.rb', line 85 def self.default_for_verification with_verification_behaviour.first || first end |
.find_by_barcode(code) ⇒ Object Also known as: find_from_barcode
106 107 108 109 |
# File 'app/models/robot.rb', line 106 def (code) = Barcode.number_to_human(code) Robot.find_by(barcode: ) || Robot.find_by(id: ) end |
.prefix ⇒ Object
102 103 104 |
# File 'app/models/robot.rb', line 102 def prefix 'RB' end |
.valid_barcode?(code) ⇒ Boolean
111 112 113 114 115 116 117 |
# File 'app/models/robot.rb', line 111 def (code) Barcode.(code, prefix) (code) # an exception is raise if not found true rescue StandardError false end |
Instance Method Details
#all_picks(batch) ⇒ Object
41 42 43 |
# File 'app/models/robot.rb', line 41 def all_picks(batch) verification_behaviour.all_picks(batch, max_beds) end |
#generation_behaviour(generator_id) ⇒ Class
Returns the generation behaviour class for the given generator_id Looks up the RobotProperty with the give generator_id and returns the corresponding Robot::Generator class.
60 61 62 63 64 65 66 67 68 69 |
# File 'app/models/robot.rb', line 60 def generation_behaviour(generator_id) property = generation_behaviour_properties.find(generator_id) { 'Hamilton' => Robot::Generator::Hamilton, 'Tecan' => Robot::Generator::Tecan, 'TecanV2' => Robot::Generator::TecanV2, 'TecanV3' => Robot::Generator::TecanV3, 'Beckman' => Robot::Generator::Beckman }.fetch(property.value) end |
#generator(batch:, plate_barcode:, pick_number:, generator_id:) ⇒ Robot::Generator
Returns an instance of the generation behaviour for the given parameters.
79 80 81 82 83 |
# File 'app/models/robot.rb', line 79 def generator(batch:, plate_barcode:, pick_number:, generator_id:) picking_data = Robot::PickData.new(batch, max_beds:).picking_data_hash()[pick_number] layout = verification_behaviour.layout_data_object(picking_data) generation_behaviour(generator_id).new(batch:, plate_barcode:, picking_data:, layout:) end |
#max_beds ⇒ Object
45 46 47 |
# File 'app/models/robot.rb', line 45 def max_beds max_plates_property.try(:value).to_i end |
#pick_number_to_expected_layout(batch, plate_barcode) ⇒ Object
37 38 39 |
# File 'app/models/robot.rb', line 37 def pick_number_to_expected_layout(batch, ) verification_behaviour.pick_number_to_expected_layout(batch, , max_beds) end |
#pick_numbers(batch, plate_barcode) ⇒ Array<String>
Added as I refactor the batches/_assets.html.erb page. Currently just wraps pick_number_to_expected_layout and as a result performs a lot of unnecessary work.
Returns an array of all pick numbers associated with the corresponding batch and plate_barcode
33 34 35 |
# File 'app/models/robot.rb', line 33 def pick_numbers(batch, ) verification_behaviour.pick_numbers(batch, , max_beds) end |
#verification_behaviour ⇒ Object
49 50 51 |
# File 'app/models/robot.rb', line 49 def verification_behaviour @verification_behaviour ||= verification_class.new end |