Class: RobotsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RobotsController
- Defined in:
- app/controllers/robots_controller.rb
Overview
Handles robot validation The id parameter indicates which robot is being used The controller looks up the current settings in Setting.robots These settings are currently compiled from robots.rb Robot.find_robot generates a new robot based on the matching settings On each controller action a Robot is initialized based on the sett show => renders the form for the selected robot verify => Checks that the robot has been set up correctly, and returns any problems to the user start => Starts the robot, and transitions the plates to the configured states
Instance Method Summary collapse
-
#labware_created_with_robot(labware_barcode, robot_barcode) ⇒ Object
Updates labware metadata with robot barcode.
- #show ⇒ Object
-
#start ⇒ Object
rubocop:todo Metrics/AbcSize.
-
#update_all_labware_metadata(robot_barcode) ⇒ Object
Saves the scanned robot barcode against all the target labware involved in this bed verification (using the ‘labware metadata’ model).
-
#update_bed_labware_metadata(bed, robot_barcode) ⇒ Object
Saves the scanned robot barcode against the labware scanned into this bed (using the ‘labware metadata’ model).
- #verify ⇒ Object
Instance Method Details
#labware_created_with_robot(labware_barcode, robot_barcode) ⇒ Object
Updates labware metadata with robot barcode.
75 76 77 78 79 |
# File 'app/controllers/robots_controller.rb', line 75 def labware_created_with_robot(, ) LabwareMetadata .new(api: api, user: current_user_uuid, barcode: ) .update!(created_with_robot: ) end |
#show ⇒ Object
17 18 19 20 21 22 |
# File 'app/controllers/robots_controller.rb', line 17 def show respond_to do |format| format.html { render 'show', locals: { robot: @robot } } format.csv end end |
#start ⇒ Object
rubocop:todo Metrics/AbcSize
24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/robots_controller.rb', line 24 def start # rubocop:todo Metrics/AbcSize @robot.perform_transfer(stripped_beds) (params[:robot_barcode]) if params[:robot_barcode].present? respond_to { |format| format.html { redirect_to search_path, notice: "Robot #{@robot.name} has been started." } } rescue Robots::Bed::BedError => e # Our beds complained, nothing has happened. respond_to do |format| format.html { redirect_to robot_path(id: @robot.id), notice: "#{e.} No plates have been started." } end end |
#update_all_labware_metadata(robot_barcode) ⇒ Object
Saves the scanned robot barcode against all the target labware involved in this bed verification (using the ‘labware metadata’ model). Beds that are not involved in this bed verification (no ‘transitions’, and no labware scanned into them) are ignored.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/robots_controller.rb', line 43 def () @robot.beds.each_value do |bed| next unless bed.transitions? && bed.labware (bed, ) rescue Sequencescape::Api::ResourceNotFound = bed.labware..machine respond_to do |format| format.html { redirect_to robot_path(id: @robot.id), notice: "Labware #{} not found." } end end end |
#update_bed_labware_metadata(bed, robot_barcode) ⇒ Object
Saves the scanned robot barcode against the labware scanned into this bed (using the ‘labware metadata’ model). If the bed has its own method for updating, use that, otherwise use the method of this controller.
63 64 65 66 67 |
# File 'app/controllers/robots_controller.rb', line 63 def (bed, ) return bed.labware_created_with_robot() if bed.respond_to?(:labware_created_with_robot) = bed.labware..machine labware_created_with_robot(, ) end |
#verify ⇒ Object
81 82 83 84 85 86 |
# File 'app/controllers/robots_controller.rb', line 81 def verify # ActionController::Parameters is no longer a Hash. Ensure the robot params # is Hash and pass only the permitted params to the robot. params = robot_params.to_h render(json: @robot.verify(params)) end |