Skip to content

Commit

Permalink
add Genesis v1.7 options
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielburnworth committed Nov 2, 2023
1 parent b4b8b12 commit e1caaf2
Show file tree
Hide file tree
Showing 22 changed files with 395 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/models/fbos_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MissingSerial < StandardError; end
FARMDUINO_K14 = "farmduino_k14",
FARMDUINO_K15 = "farmduino_k15",
FARMDUINO_K16 = "farmduino_k16",
FARMDUINO_K17 = "farmduino_k17",
EXPRESS_K10 = "express_k10",
EXPRESS_K11 = "express_k11",
]
Expand Down
2 changes: 2 additions & 0 deletions app/mutations/devices/create_seed_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ class CreateSeedData < Mutations::Command
"genesis_1.4" => Devices::Seeders::GenesisOneFour,
"genesis_1.5" => Devices::Seeders::GenesisOneFive,
"genesis_1.6" => Devices::Seeders::GenesisOneSix,
"genesis_1.7" => Devices::Seeders::GenesisOneSeven,
"genesis_xl_1.4" => Devices::Seeders::GenesisXlOneFour,
"genesis_xl_1.5" => Devices::Seeders::GenesisXlOneFive,
"genesis_xl_1.6" => Devices::Seeders::GenesisXlOneSix,
"genesis_xl_1.7" => Devices::Seeders::GenesisXlOneSeven,

"demo_account" => Devices::Seeders::DemoAccountSeeder,
"none" => Devices::Seeders::None,
Expand Down
73 changes: 73 additions & 0 deletions app/mutations/devices/seeders/genesis_one_seven.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
module Devices
module Seeders
class GenesisOneSeven < AbstractGenesis
def settings_firmware
device
.fbos_config
.update!(firmware_hardware: FbosConfig::FARMDUINO_K17)
end

def settings_change_firmware_config_defaults
end

def peripherals_rotary_tool
add_peripheral(2, ToolNames::ROTARY_TOOL)
end

def peripherals_rotary_tool_reverse
add_peripheral(3, ToolNames::ROTARY_TOOL_REVERSE)
end

def tool_slots_slot_7
add_tool_slot(name: ToolNames::ROTARY_TOOL,
x: 50,
y: 800,
z: -200,
tool: tools_rotary)
end

def tool_slots_slot_8
add_tool_slot(name: ToolNames::SEED_TROUGH_1,
x: 0,
y: 25,
z: -100,
tool: tools_seed_trough_1,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
end

def tool_slots_slot_9
add_tool_slot(name: ToolNames::SEED_TROUGH_2,
x: 0,
y: 50,
z: -100,
tool: tools_seed_trough_2,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
end

def tools_rotary
@tools_rotary ||=
add_tool(ToolNames::ROTARY_TOOL)
end

def tools_seed_trough_1
@tools_seed_trough_1 ||=
add_tool(ToolNames::SEED_TROUGH_1)
end

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
85 changes: 85 additions & 0 deletions app/mutations/devices/seeders/genesis_xl_one_seven.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
module Devices
module Seeders
class GenesisXlOneSeven < AbstractGenesis
def settings_firmware
device
.fbos_config
.update!(firmware_hardware: FbosConfig::FARMDUINO_K17)
end

def settings_change_firmware_config_defaults
end

def settings_device_name
device.update!(name: Names::GENESIS_XL)
end

def settings_default_map_size_x
device.web_app_config.update!(map_size_x: 5_900)
end

def settings_default_map_size_y
device.web_app_config.update!(map_size_y: 2_900)
end

def peripherals_rotary_tool
add_peripheral(2, ToolNames::ROTARY_TOOL)
end

def peripherals_rotary_tool_reverse
add_peripheral(3, ToolNames::ROTARY_TOOL_REVERSE)
end

def tool_slots_slot_7
add_tool_slot(name: ToolNames::ROTARY_TOOL,
x: 50,
y: 800,
z: -200,
tool: tools_rotary)
end

def tool_slots_slot_8
add_tool_slot(name: ToolNames::SEED_TROUGH_1,
x: 0,
y: 25,
z: -100,
tool: tools_seed_trough_1,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
end

def tool_slots_slot_9
add_tool_slot(name: ToolNames::SEED_TROUGH_2,
x: 0,
y: 50,
z: -100,
tool: tools_seed_trough_2,
pullout_direction: ToolSlot::NONE,
gantry_mounted: true)
end

def tools_rotary
@tools_rotary ||=
add_tool(ToolNames::ROTARY_TOOL)
end

def tools_seed_trough_1
@tools_seed_trough_1 ||=
add_tool(ToolNames::SEED_TROUGH_1)
end

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
1 change: 1 addition & 0 deletions frontend/controls/peripherals/__tests__/index_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ describe("<Peripherals />", () => {
["farmduino_k14", 5],
["farmduino_k15", 5],
["farmduino_k16", 7],
["farmduino_k17", 7],
["express_k10", 3],
["express_k11", 3],
])("adds peripherals: %s", (firmware, expectedAdds) => {
Expand Down
1 change: 1 addition & 0 deletions frontend/controls/peripherals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class Peripherals
...EXTRA_PERIPHERALS,
];
case "farmduino_k16":
case "farmduino_k17":
return [
...BASE_PERIPHERALS,
...ROTARY_TOOL,
Expand Down
2 changes: 1 addition & 1 deletion frontend/devices/connectivity/fbos_metric_demo_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const generateDemoTelemetry = (): TaggedTelemetry[] => {
cpu_usage: 5 + random(-4, 4),
target: "demo",
fbos_version: "100.0.0",
firmware_hardware: "farmduino_k16",
firmware_hardware: "farmduino_k17",
created_at: at,
updated_at: (new Date(at)).toISOString(),
}
Expand Down
1 change: 1 addition & 0 deletions frontend/devices/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export enum Feature {
farmduino_k14 = "farmduino_k14",
farmduino_k15 = "farmduino_k15",
farmduino_k16 = "farmduino_k16",
farmduino_k17 = "farmduino_k17",
firmware_restart = "firmware_restart",
flash_firmware = "flash_firmware",
groups = "groups",
Expand Down
21 changes: 20 additions & 1 deletion frontend/messages/__tests__/cards_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ jest.mock("../../devices/actions", () => ({ updateConfig: jest.fn() }));

jest.mock("../../api/crud", () => ({ destroy: jest.fn() }));

let mockFeatureBoolean = false;
jest.mock("../../devices/should_display", () => ({
shouldDisplayFeature: () => mockFeatureBoolean,
}));

const fakeBulletin: Bulletin = {
content: "Alert content.",
href: "https://farm.bot",
Expand All @@ -28,7 +33,9 @@ jest.mock("../../redux/store", () => ({

import React from "react";
import { mount, shallow } from "enzyme";
import { AlertCard, changeFirmwareHardware, ReSeedAccount } from "../cards";
import {
AlertCard, changeFirmwareHardware, ReSeedAccount, SEED_DATA_OPTIONS,
} from "../cards";
import { AlertCardProps, Bulletin } from "../interfaces";
import { fakeTimeSettings } from "../../__test_support__/fake_time_settings";
import { FBSelect } from "../../ui";
Expand Down Expand Up @@ -249,6 +256,18 @@ describe("changeFirmwareHardware()", () => {
});
});

describe("SEED_DATA_OPTIONS()", () => {
it("returns options", () => {
mockFeatureBoolean = false;
expect(SEED_DATA_OPTIONS().length).toEqual(13);
});

it("returns more options", () => {
mockFeatureBoolean = true;
expect(SEED_DATA_OPTIONS().length).toEqual(15);
});
});

describe("<ReSeedAccount />", () => {
it("changes selection", () => {
window.confirm = () => true;
Expand Down
13 changes: 13 additions & 0 deletions frontend/messages/cards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { push } from "../history";
import moment from "moment";
import { Path } from "../internal_urls";
import { logout } from "../logout";
import { shouldDisplayFeature } from "../devices/should_display";
import { Feature } from "../devices/interfaces";

export const AlertCard = (props: AlertCardProps) => {
const { alert, timeSettings, findApiAlertById, dispatch } = props;
Expand Down Expand Up @@ -187,6 +189,11 @@ const FirmwareChoiceTable = () =>
<td>{"Farmduino"}</td>
<td><code>{FIRMWARE_CHOICES_DDI["farmduino_k16"].label}</code></td>
</tr>
<tr>
<td>{"Genesis v1.7"}</td>
<td>{"Farmduino"}</td>
<td><code>{FIRMWARE_CHOICES_DDI["farmduino_k17"].label}</code></td>
</tr>
<tr>
<td>{"Express v1.0"}</td>
<td>{"Farmduino"}</td>
Expand Down Expand Up @@ -245,9 +252,15 @@ export const SEED_DATA_OPTIONS = (): DropDownItem[] => [
{ label: "Genesis v1.4", value: "genesis_1.4" },
{ label: "Genesis v1.5", value: "genesis_1.5" },
{ label: "Genesis v1.6", value: "genesis_1.6" },
...(shouldDisplayFeature(Feature.farmduino_k17)
? [{ label: "Genesis v1.7", value: "genesis_1.7" }]
: []),
{ label: "Genesis v1.4 XL", value: "genesis_xl_1.4" },
{ label: "Genesis v1.5 XL", value: "genesis_xl_1.5" },
{ label: "Genesis v1.6 XL", value: "genesis_xl_1.6" },
...(shouldDisplayFeature(Feature.farmduino_k17)
? [{ label: "Genesis v1.7 XL", value: "genesis_xl_1.7" }]
: []),
{ label: "Express v1.0", value: "express_1.0" },
{ label: "Express v1.1", value: "express_1.1" },
{ label: "Express v1.0 XL", value: "express_xl_1.0" },
Expand Down
7 changes: 7 additions & 0 deletions frontend/os_download/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ const PLATFORM_DATA = (): PlatformContent[] => [
"Genesis XL v1.6.1 (white cable)",
"Genesis v1.6.2 (white cable or 2 HDMI ports)",
"Genesis XL v1.6.2 (white cable or 2 HDMI ports)",
"Genesis v1.7",
"Genesis XL v1.7",
],
},
{
Expand Down Expand Up @@ -135,6 +137,7 @@ enum Version {
"v1.4" = "v1.4",
"v1.5" = "v1.5",
"v1.6" = "v1.6",
"v1.7" = "v1.7",
}

const VERSIONS = () => ({
Expand All @@ -143,6 +146,7 @@ const VERSIONS = () => ({
Version["v1.1"],
],
[Model.Genesis]: [
// Version["v1.7"],
Version["v1.6"],
Version["v1.5"],
Version["v1.4"],
Expand Down Expand Up @@ -223,6 +227,9 @@ const DOWNLOADS = (): Downloads => ({
[Run.second]: RPI4(),
[Run.third]: RPI4(),
},
[Version["v1.7"]]: {
[Run.first]: RPI4(),
},
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type TestCase = [string, string, FirmwareHardware, string];
const TEST_CASES: TestCase[] = [
["3", "rpi3", "arduino", "pi 3"],
["4", "rpi4", "farmduino_k16", "pi 4"],
["4", "rpi4", "farmduino_k17", "pi 4"],
["01", "rpi", "express_k10", "zero w"],
["02", "rpi3", "express_k11", "zero 2 w"],
];
Expand Down
14 changes: 14 additions & 0 deletions frontend/settings/firmware/__tests__/board_type_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ jest.mock("../../../api/crud", () => ({
save: jest.fn(),
}));

let mockFeatureBoolean = false;
jest.mock("../../../devices/should_display", () => ({
shouldDisplayFeature: () => mockFeatureBoolean,
}));

import React from "react";
import { mount, shallow } from "enzyme";
import { BoardType } from "../board_type";
Expand Down Expand Up @@ -78,6 +83,7 @@ describe("<BoardType/>", () => {
});

it("displays boards", () => {
mockFeatureBoolean = false;
const wrapper = mount(<BoardType {...fakeProps()} />);
const { list } = wrapper.find("FBSelect").props();
expect(list).toEqual([
Expand All @@ -90,5 +96,13 @@ describe("<BoardType/>", () => {
{ label: "Farmduino (Express v1.1)", value: "express_k11" },
{ label: "None", value: "none" },
]);
expect(list?.length).toEqual(8);
});

it("displays more boards", () => {
mockFeatureBoolean = true;
const wrapper = mount(<BoardType {...fakeProps()} />);
const { list } = wrapper.find("FBSelect").props();
expect(list?.length).toEqual(9);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ describe("boardType()", () => {
expect(boardType("5.0.3.I")).toEqual("farmduino_k16");
});

it("returns Farmduino k1.7", () => {
expect(boardType("5.0.3.J")).toEqual("farmduino_k17");
});

it("returns Farmduino Express k1.0", () => {
expect(boardType("5.0.3.E")).toEqual("express_k10");
});
Expand Down
Loading

0 comments on commit e1caaf2

Please sign in to comment.