Class: Robots::Bed::Base
- Inherits:
-
Object
show all
- Includes:
- Form
- Defined in:
- app/models/robots/bed/base.rb
Overview
A bed is a barcoded area of a robot that can receive a labware.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#barcodes ⇒ Object
62
63
64
|
# File 'app/models/robots/bed/base.rb', line 62
def barcodes
@barcodes ||= []
end
|
#child ⇒ Object
Our robot has beds/rack-spaces
9
10
11
|
# File 'app/models/robots/bed/base.rb', line 9
def child
@child
end
|
#label ⇒ Object
Our robot has beds/rack-spaces
9
10
11
|
# File 'app/models/robots/bed/base.rb', line 9
def label
@label
end
|
#parents ⇒ Object
Our robot has beds/rack-spaces
9
10
11
|
# File 'app/models/robots/bed/base.rb', line 9
def parents
@parents
end
|
#purpose ⇒ Object
Our robot has beds/rack-spaces
9
10
11
|
# File 'app/models/robots/bed/base.rb', line 9
def purpose
@purpose
end
|
#robot ⇒ Object
Our robot has beds/rack-spaces
9
10
11
|
# File 'app/models/robots/bed/base.rb', line 9
def robot
@robot
end
|
#shared_parent ⇒ Object
Our robot has beds/rack-spaces
9
10
11
|
# File 'app/models/robots/bed/base.rb', line 9
def shared_parent
@shared_parent
end
|
#states ⇒ Object
Our robot has beds/rack-spaces
9
10
11
|
# File 'app/models/robots/bed/base.rb', line 9
def states
@states
end
|
#target_state ⇒ Object
Our robot has beds/rack-spaces
9
10
11
|
# File 'app/models/robots/bed/base.rb', line 9
def target_state
@target_state
end
|
Instance Method Details
#barcode ⇒ Object
66
67
68
|
# File 'app/models/robots/bed/base.rb', line 66
def barcode
barcodes.first
end
|
#error_messages ⇒ Object
33
34
35
|
# File 'app/models/robots/bed/base.rb', line 33
def error_messages
errors.full_messages.join(' ')
end
|
#find_all_labware ⇒ Object
overriden in sub-classes of bed to customise what class is used and what is included
71
72
73
|
# File 'app/models/robots/bed/base.rb', line 71
def find_all_labware
Sequencescape::Api::V2::Labware.find_all({ barcode: @barcodes }, includes: %i[purpose parents])
end
|
96
97
98
|
# File 'app/models/robots/bed/base.rb', line 96
def formatted_message
"#{label} - #{errors.full_messages.join('; ')}"
end
|
#labware ⇒ Object
82
83
84
|
# File 'app/models/robots/bed/base.rb', line 82
def labware
@labware&.first
end
|
#load(barcodes) ⇒ Object
75
76
77
78
79
80
|
# File 'app/models/robots/bed/base.rb', line 75
def load(barcodes)
@barcodes = Array(barcodes).map(&:strip).uniq.compact_blank
@labware = @barcodes.present? ? find_all_labware : []
end
|
#parent ⇒ Object
41
42
43
|
# File 'app/models/robots/bed/base.rb', line 41
def parent
(@parents || []).first
end
|
#parent=(parent_bed) ⇒ Object
37
38
39
|
# File 'app/models/robots/bed/base.rb', line 37
def parent=(parent_bed)
@parents = [parent_bed]
end
|
#parent_labware ⇒ Object
86
87
88
89
90
91
92
93
94
|
# File 'app/models/robots/bed/base.rb', line 86
def parent_labware
return [] if labware.nil?
parents = labware.parents
return parents if parents.present?
error("Labware #{labware.human_barcode} doesn't seem to have any parents, and yet at least one was expected.")
[]
end
|
#persisted? ⇒ Boolean
Originally defined in module
Form
#purpose_labels ⇒ Object
58
59
60
|
# File 'app/models/robots/bed/base.rb', line 58
def purpose_labels
Array(purpose).to_sentence(two_words_connector: ' or ', last_word_connector: ' or ')
end
|
#recognised? ⇒ Boolean
29
30
31
|
# File 'app/models/robots/bed/base.rb', line 29
def recognised?
true
end
|
#transition ⇒ Object
rubocop:todo Metrics/AbcSize
49
50
51
52
53
54
55
56
|
# File 'app/models/robots/bed/base.rb', line 49
def transition return if target_state.nil? || labware.nil?
StateChangers
.lookup_for(labware.purpose.uuid)
.new(api, labware.uuid, user_uuid)
.move_to!(target_state, "Robot #{robot.name} started")
end
|
#transitions? ⇒ Boolean
45
46
47
|
# File 'app/models/robots/bed/base.rb', line 45
def transitions?
target_state.present?
end
|