Skip to content

Commit

Permalink
Merge pull request #2445 from FarmBot/staging
Browse files Browse the repository at this point in the history
v15.8.7
  • Loading branch information
gabrielburnworth committed Nov 1, 2023
2 parents c49ce99 + 07cf2aa commit b4b8b12
Show file tree
Hide file tree
Showing 16 changed files with 537 additions and 85 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ GEM
faraday (~> 1.0)
globalid (1.2.1)
activesupport (>= 6.1)
google-apis-core (0.11.1)
google-apis-core (0.11.2)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
Expand Down
8 changes: 7 additions & 1 deletion app/models/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ class Device < ApplicationRecord
TIMEZONES = TZInfo::Timezone.all_identifiers
BAD_TZ = "%{value} is not a valid timezone"
BAD_OTA_HOUR = "must be a value from 0 to 23."
ORDER_NUMBER_TAKEN = "has already been taken. " \
"If you purchased multiple FarmBots with the same " \
"order number, you may add -1, -2, -3, etc. to " \
"the end of the order number to register additional " \
"FarmBots after the first one."
THROTTLE_ON = "Device is sending too many logs (%s). " \
"Suspending log storage and display until %s."
THROTTLE_OFF = "Cooldown period has ended. " \
Expand Down Expand Up @@ -43,7 +48,8 @@ class Device < ApplicationRecord
}
validates :ota_hour,
inclusion: { in: [*0..23], message: BAD_OTA_HOUR, allow_nil: true }
validates :fb_order_number, uniqueness: true, allow_nil: true
validates :fb_order_number,
uniqueness: { message: ORDER_NUMBER_TAKEN, allow_nil: true }
before_validation :perform_gradual_upgrade

# Give the user back the amount of logs they are allowed to view.
Expand Down
27 changes: 18 additions & 9 deletions app/mutations/devices/seeders/abstract_express.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def tool_slots_slot_1
add_tool_slot(name: ToolNames::SEED_TROUGH_1,
x: 0,
y: 25,
z: 0,
z: -100,
tool: tools_seed_trough_1,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
Expand All @@ -43,7 +43,7 @@ def tool_slots_slot_2
add_tool_slot(name: ToolNames::SEED_TROUGH_2,
x: 0,
y: 50,
z: 0,
z: -100,
tool: tools_seed_trough_2,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
Expand Down Expand Up @@ -75,20 +75,29 @@ def tools_weeder; end
def tools_rotary; end
def sequences_mount_tool; end
def sequences_dismount_tool; end
def sequences_mow_all_weeds; end
def sequences_pick_from_seed_tray; end

def sequences_pick_up_seed
s = SequenceSeeds::PICK_UP_SEED_EXPRESS.deep_dup

s.dig(:body, 1, :body, 0, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 1, :body, 1, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 1, :body, 2, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 2, :args, :pin_number, :args)[:pin_id] = vacuum_id
s.dig(:body, 0, :body, 0, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 0, :body, 1, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 0, :body, 2, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 1, :args, :pin_number, :args)[:pin_id] = vacuum_id
s.dig(:body, 2, :body, 0, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 2, :body, 1, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 2, :body, 2, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 3, :body, 0, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 3, :body, 1, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 3, :body, 2, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 4, :body, 0, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 4, :body, 1, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
s.dig(:body, 4, :body, 2, :args, :axis_operand, :args)[:tool_id] = seed_trough_1_id
Sequences::Create.run!(s, device: device)
end

def sequences_plant_seed
s = SequenceSeeds::PLANT_SEED_EXPRESS.deep_dup

s.dig(:body, 2, :args, :pin_number, :args)[:pin_id] = vacuum_id
Sequences::Create.run!(s, device: device)
end

Expand Down
31 changes: 27 additions & 4 deletions app/mutations/devices/seeders/abstract_genesis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,34 @@ def tools_weeder
def tools_rotary; end

def sequences_mount_tool
install_sequence_version_by_name("Mount Tool")
success = install_sequence_version_by_name(PublicSequenceNames::MOUNT_TOOL)
if !success
s = SequenceSeeds::MOUNT_TOOL.deep_dup
Sequences::Create.run!(s, device: device)
end
end

def sequences_dismount_tool
install_sequence_version_by_name("Dismount Tool")
success = install_sequence_version_by_name(PublicSequenceNames::DISMOUNT_TOOL)
if !success
s = SequenceSeeds::DISMOUNT_TOOL.deep_dup
Sequences::Create.run!(s, device: device)
end
end

def sequences_pick_from_seed_tray
success = install_sequence_version_by_name(PublicSequenceNames::PICK_FROM_SEED_TRAY)
if !success
s = SequenceSeeds::PICK_FROM_SEED_TRAY.deep_dup
Sequences::Create.run!(s, device: device)
end
end

def sequences_pick_up_seed
s = SequenceSeeds::PICK_UP_SEED_GENESIS.deep_dup

seed_bin_id = device.tools.find_by!(name: ToolNames::SEED_BIN).id
mount_tool_id = device.sequences.find_by!(name: "Mount Tool").id
mount_tool_id = device.sequences.find_by!(name: PublicSequenceNames::MOUNT_TOOL).id

s.dig(:body, 0, :args)[:sequence_id] = mount_tool_id
s.dig(:body, 0, :body, 0, :args, :data_value, :args)[:tool_id] = seeder_id
Expand All @@ -139,8 +155,15 @@ def sequences_pick_up_seed
Sequences::Create.run!(s, device: device)
end

def sequences_plant_seed
s = SequenceSeeds::PLANT_SEED_GENESIS.deep_dup

s.dig(:body, 2, :args, :pin_number, :args)[:pin_id] = vacuum_id
Sequences::Create.run!(s, device: device)
end

def sequences_find_home
s = SequenceSeeds::FIND_HOME.deep_dup
s = SequenceSeeds::FIND_HOME_GENESIS.deep_dup
Sequences::Create.run!(s, device: device)
end

Expand Down
50 changes: 37 additions & 13 deletions app/mutations/devices/seeders/abstract_seeder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class AbstractSeeder
:sequences_soil_height_grid,
:sequences_grid,
:sequences_dispense_water,
:sequences_mow_all_weeds,
:sequences_pick_from_seed_tray,

# EVERYTHING ELSE ========================
:misc,
Expand Down Expand Up @@ -122,13 +124,9 @@ def sensors_tool_verification; end
def sequences_mount_tool; end
def sequences_dismount_tool; end
def sequences_pick_up_seed; end

def sequences_plant_seed
s = SequenceSeeds::PLANT_SEED.deep_dup

s.dig(:body, 2, :args, :pin_number, :args)[:pin_id] = vacuum_id
Sequences::Create.run!(s, device: device)
end
def sequences_plant_seed; end
def sequences_mow_all_weeds; end
def sequences_pick_from_seed_tray; end

def sequences_take_photo_of_plant
s = SequenceSeeds::TAKE_PHOTO_OF_PLANT.deep_dup
Expand Down Expand Up @@ -175,27 +173,51 @@ def sequences_water_all_plants
def sequences_find_home; end

def sequences_water_all
install_sequence_version_by_name(PublicSequenceNames::WATER_ALL)
success = install_sequence_version_by_name(PublicSequenceNames::WATER_ALL)
if !success
s = SequenceSeeds::WATER_ALL.deep_dup
Sequences::Create.run!(s, device: device)
end
end

def sequences_photo_grid
install_sequence_version_by_name(PublicSequenceNames::PHOTO_GRID)
success = install_sequence_version_by_name(PublicSequenceNames::PHOTO_GRID)
if !success
s = SequenceSeeds::PHOTO_GRID.deep_dup
Sequences::Create.run!(s, device: device)
end
end

def sequences_weed_detection_grid
install_sequence_version_by_name(PublicSequenceNames::WEED_DETECTION_GRID)
success = install_sequence_version_by_name(PublicSequenceNames::WEED_DETECTION_GRID)
if !success
s = SequenceSeeds::WEED_DETECTION_GRID.deep_dup
Sequences::Create.run!(s, device: device)
end
end

def sequences_soil_height_grid
install_sequence_version_by_name(PublicSequenceNames::SOIL_HEIGHT_GRID)
success = install_sequence_version_by_name(PublicSequenceNames::SOIL_HEIGHT_GRID)
if !success
s = SequenceSeeds::SOIL_HEIGHT_GRID.deep_dup
Sequences::Create.run!(s, device: device)
end
end

def sequences_grid
install_sequence_version_by_name(PublicSequenceNames::GRID)
success = install_sequence_version_by_name(PublicSequenceNames::GRID)
if !success
s = SequenceSeeds::GRID.deep_dup
Sequences::Create.run!(s, device: device)
end
end

def sequences_dispense_water
install_sequence_version_by_name(PublicSequenceNames::DISPENSE_WATER)
success = install_sequence_version_by_name(PublicSequenceNames::DISPENSE_WATER)
if !success
s = SequenceSeeds::DISPENSE_WATER.deep_dup
Sequences::Create.run!(s, device: device)
end
end

def settings_default_map_size_x; end
Expand Down Expand Up @@ -249,10 +271,12 @@ def install_sequence_version_by_name(name)
msg = "Unable to install public sequence: #{name}"
device.tell(msg)
Rollbar.error(msg)
return false
else
Sequences::Install.run!(
sequence_version: sv,
device: device)
return true
end
end

Expand Down
17 changes: 15 additions & 2 deletions app/mutations/devices/seeders/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,23 @@ module SequenceSeeds
ALL = YAML.load(File.read(SEQUENCE_FIXTURE_PATH))
PICK_UP_SEED_EXPRESS = ALL.fetch(:PICK_UP_SEED_EXPRESS)
PICK_UP_SEED_GENESIS = ALL.fetch(:PICK_UP_SEED_GENESIS)
PLANT_SEED = ALL.fetch(:PLANT_SEED)
PLANT_SEED_GENESIS = ALL.fetch(:PLANT_SEED_GENESIS)
PLANT_SEED_EXPRESS = ALL.fetch(:PLANT_SEED_EXPRESS)
TAKE_PHOTO_OF_PLANT = ALL.fetch(:TAKE_PHOTO_OF_PLANT)
WATER_PLANT = ALL.fetch(:WATER_PLANT)
WATER_ALL_PLANTS = ALL.fetch(:WATER_ALL_PLANTS)
FIND_HOME = ALL.fetch(:FIND_HOME)
FIND_HOME_GENESIS = ALL.fetch(:FIND_HOME_GENESIS)
FIND_HOME_EXPRESS = ALL.fetch(:FIND_HOME_EXPRESS)
MOUNT_TOOL = ALL.fetch(:MOUNT_TOOL)
DISMOUNT_TOOL = ALL.fetch(:DISMOUNT_TOOL)
DISPENSE_WATER = ALL.fetch(:DISPENSE_WATER)
SOIL_HEIGHT_GRID = ALL.fetch(:SOIL_HEIGHT_GRID)
GRID = ALL.fetch(:GRID)
WATER_ALL = ALL.fetch(:WATER_ALL)
PHOTO_GRID = ALL.fetch(:PHOTO_GRID)
WEED_DETECTION_GRID = ALL.fetch(:WEED_DETECTION_GRID)
MOW_ALL_WEEDS = ALL.fetch(:MOW_ALL_WEEDS)
PICK_FROM_SEED_TRAY = ALL.fetch(:PICK_FROM_SEED_TRAY)
end

module PublicSequenceNames
Expand All @@ -58,6 +69,8 @@ module PublicSequenceNames
WEED_DETECTION_GRID = "Weed Detection Grid"
MOUNT_TOOL = "Mount Tool"
DISMOUNT_TOOL = "Dismount Tool"
MOW_ALL_WEEDS = "Mow All Weeds"
PICK_FROM_SEED_TRAY = "Pick from Seed Tray"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/mutations/devices/seeders/genesis_one_five.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def tool_slots_slot_7
add_tool_slot(name: ToolNames::SEED_TROUGH_1,
x: 0,
y: 25,
z: 0,
z: -100,
tool: tools_seed_trough_1,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
Expand All @@ -21,7 +21,7 @@ def tool_slots_slot_8
add_tool_slot(name: ToolNames::SEED_TROUGH_2,
x: 0,
y: 50,
z: 0,
z: -100,
tool: tools_seed_trough_2,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
Expand Down
12 changes: 10 additions & 2 deletions app/mutations/devices/seeders/genesis_one_six.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def tool_slots_slot_8
add_tool_slot(name: ToolNames::SEED_TROUGH_1,
x: 0,
y: 25,
z: 0,
z: -100,
tool: tools_seed_trough_1,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
Expand All @@ -40,7 +40,7 @@ def tool_slots_slot_9
add_tool_slot(name: ToolNames::SEED_TROUGH_2,
x: 0,
y: 50,
z: 0,
z: -100,
tool: tools_seed_trough_2,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
Expand All @@ -60,6 +60,14 @@ def tools_seed_trough_2
@tools_seed_trough_2 ||=
add_tool(ToolNames::SEED_TROUGH_2)
end

def sequences_mow_all_weeds
success = install_sequence_version_by_name(PublicSequenceNames::MOW_ALL_WEEDS)
if !success
s = SequenceSeeds::MOW_ALL_WEEDS.deep_dup
Sequences::Create.run!(s, device: device)
end
end
end
end
end
4 changes: 2 additions & 2 deletions app/mutations/devices/seeders/genesis_xl_one_five.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def tool_slots_slot_7
add_tool_slot(name: ToolNames::SEED_TROUGH_1,
x: 0,
y: 25,
z: 0,
z: -100,
tool: tools_seed_trough_1,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
Expand All @@ -33,7 +33,7 @@ def tool_slots_slot_8
add_tool_slot(name: ToolNames::SEED_TROUGH_2,
x: 0,
y: 50,
z: 0,
z: -100,
tool: tools_seed_trough_2,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
Expand Down
12 changes: 10 additions & 2 deletions app/mutations/devices/seeders/genesis_xl_one_six.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def tool_slots_slot_8
add_tool_slot(name: ToolNames::SEED_TROUGH_1,
x: 0,
y: 25,
z: 0,
z: -100,
tool: tools_seed_trough_1,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
Expand All @@ -52,7 +52,7 @@ def tool_slots_slot_9
add_tool_slot(name: ToolNames::SEED_TROUGH_2,
x: 0,
y: 50,
z: 0,
z: -100,
tool: tools_seed_trough_2,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
Expand All @@ -72,6 +72,14 @@ def tools_seed_trough_2
@tools_seed_trough_2 ||=
add_tool(ToolNames::SEED_TROUGH_2)
end

def sequences_mow_all_weeds
success = install_sequence_version_by_name(PublicSequenceNames::MOW_ALL_WEEDS)
if !success
s = SequenceSeeds::MOW_ALL_WEEDS.deep_dup
Sequences::Create.run!(s, device: device)
end
end
end
end
end
2 changes: 2 additions & 0 deletions app/mutations/devices/seeders/none.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def sequences_pick_up_seed; end
def sequences_plant_seed; end
def sequences_take_photo_of_plant; end
def sequences_water_plant; end
def sequences_mow_all_weeds; end
def sequences_pick_from_seed_tray; end
def point_groups_spinach; end
def point_groups_broccoli; end
def point_groups_beet; end
Expand Down

0 comments on commit b4b8b12

Please sign in to comment.