2017-06-29 12:54:02 -06:00
|
|
|
import * as React from "react";
|
2019-12-05 13:52:16 -07:00
|
|
|
import { StepButton } from "./step_buttons";
|
2018-01-20 07:46:44 -07:00
|
|
|
import { scrollToBottom } from "../util";
|
2018-06-14 12:48:30 -06:00
|
|
|
import { Row } from "../ui/index";
|
2018-08-01 07:33:39 -06:00
|
|
|
import { TaggedSequence } from "farmbot";
|
2018-05-01 18:19:30 -06:00
|
|
|
import { CONFIG_DEFAULTS } from "farmbot/dist/config";
|
2018-09-11 17:17:30 -06:00
|
|
|
import { ShouldDisplay, Feature } from "../devices/interfaces";
|
2019-02-26 20:12:02 -07:00
|
|
|
import { MessageType } from "./interfaces";
|
2019-04-02 13:59:37 -06:00
|
|
|
import { t } from "../i18next_wrapper";
|
2019-04-09 22:11:26 -06:00
|
|
|
import { NOTHING_SELECTED } from "./locals_list/handle_select";
|
2017-06-29 12:54:02 -06:00
|
|
|
|
2018-09-11 17:17:30 -06:00
|
|
|
export interface StepButtonProps {
|
2017-06-29 12:54:02 -06:00
|
|
|
dispatch: Function;
|
|
|
|
current: TaggedSequence | undefined;
|
2018-09-11 17:17:30 -06:00
|
|
|
shouldDisplay: ShouldDisplay;
|
2019-04-09 19:45:59 -06:00
|
|
|
stepIndex: number | undefined;
|
2017-06-29 12:54:02 -06:00
|
|
|
}
|
|
|
|
|
2018-09-11 17:17:30 -06:00
|
|
|
export function StepButtonCluster(props: StepButtonProps) {
|
2019-04-09 19:45:59 -06:00
|
|
|
const { dispatch, current, shouldDisplay, stepIndex } = props;
|
|
|
|
const commonStepProps = { dispatch, current, index: stepIndex };
|
2017-06-29 12:54:02 -06:00
|
|
|
const ALL_THE_BUTTONS = [
|
2019-04-09 19:45:59 -06:00
|
|
|
<StepButton {...commonStepProps}
|
2017-06-29 12:54:02 -06:00
|
|
|
step={{
|
|
|
|
kind: "move_absolute",
|
|
|
|
args: {
|
2019-04-09 22:11:26 -06:00
|
|
|
location: NOTHING_SELECTED,
|
2019-04-09 19:45:59 -06:00
|
|
|
offset: { kind: "coordinate", args: { x: 0, y: 0, z: 0 } },
|
2018-05-01 18:19:30 -06:00
|
|
|
speed: CONFIG_DEFAULTS.speed
|
2017-06-29 12:54:02 -06:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
color="blue">
|
2019-04-09 22:00:03 -06:00
|
|
|
{t("MOVE TO")}
|
2017-06-29 12:54:02 -06:00
|
|
|
</StepButton>,
|
2019-04-09 19:45:59 -06:00
|
|
|
<StepButton {...commonStepProps}
|
2017-06-29 12:54:02 -06:00
|
|
|
step={{
|
|
|
|
kind: "move_relative",
|
2018-05-01 18:19:30 -06:00
|
|
|
args: { x: 0, y: 0, z: 0, speed: CONFIG_DEFAULTS.speed }
|
2017-06-29 12:54:02 -06:00
|
|
|
}}
|
|
|
|
color="green">
|
|
|
|
{t("MOVE RELATIVE")}
|
|
|
|
</StepButton>,
|
2019-04-09 19:45:59 -06:00
|
|
|
<StepButton {...commonStepProps}
|
2017-06-29 12:54:02 -06:00
|
|
|
step={{
|
|
|
|
kind: "write_pin",
|
2019-04-09 22:11:26 -06:00
|
|
|
args: { pin_number: NOTHING_SELECTED, pin_value: 0, pin_mode: 0 }
|
2017-06-29 12:54:02 -06:00
|
|
|
}}
|
|
|
|
color="orange">
|
2019-04-09 22:11:26 -06:00
|
|
|
{t("CONTROL PERIPHERAL")}
|
2017-06-29 12:54:02 -06:00
|
|
|
</StepButton>,
|
2019-04-09 19:45:59 -06:00
|
|
|
<StepButton {...commonStepProps}
|
2017-06-29 12:54:02 -06:00
|
|
|
step={{
|
|
|
|
kind: "read_pin",
|
|
|
|
args: {
|
2019-04-09 22:11:26 -06:00
|
|
|
pin_number: NOTHING_SELECTED,
|
2017-06-29 12:54:02 -06:00
|
|
|
pin_mode: 0,
|
|
|
|
label: "---"
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
color="yellow">
|
2019-04-09 22:11:26 -06:00
|
|
|
{t("READ SENSOR")}
|
2017-06-29 12:54:02 -06:00
|
|
|
</StepButton>,
|
2019-12-21 21:43:41 -07:00
|
|
|
<StepButton {...commonStepProps}
|
|
|
|
step={{
|
|
|
|
kind: "set_servo_angle",
|
|
|
|
args: {
|
|
|
|
pin_number: 4,
|
|
|
|
pin_value: 90
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
color="blue">
|
|
|
|
{t("CONTROL SERVO")}
|
|
|
|
</StepButton>,
|
2019-04-09 19:45:59 -06:00
|
|
|
<StepButton {...commonStepProps}
|
2017-06-29 12:54:02 -06:00
|
|
|
step={{
|
|
|
|
kind: "wait",
|
|
|
|
args: { milliseconds: 0 }
|
|
|
|
}}
|
|
|
|
color="brown">
|
|
|
|
{t("WAIT")}
|
|
|
|
</StepButton>,
|
2019-04-09 19:45:59 -06:00
|
|
|
<StepButton {...commonStepProps}
|
2017-06-29 12:54:02 -06:00
|
|
|
step={{
|
|
|
|
kind: "send_message",
|
|
|
|
args: {
|
2018-02-27 10:49:37 -07:00
|
|
|
message: t("FarmBot is at position ") + "{{ x }}, {{ y }}, {{ z }}.",
|
2019-02-26 20:12:02 -07:00
|
|
|
message_type: MessageType.success
|
2017-06-29 12:54:02 -06:00
|
|
|
}
|
|
|
|
}}
|
2019-12-21 21:43:41 -07:00
|
|
|
color="brown">
|
2020-01-07 14:00:25 -07:00
|
|
|
{t("SEND MESSAGE")}
|
2019-12-21 21:43:41 -07:00
|
|
|
</StepButton>,
|
2019-12-26 09:25:03 -07:00
|
|
|
<StepButton {...commonStepProps}
|
|
|
|
step={{ kind: "reboot", args: { package: "farmbot_os" } }}
|
|
|
|
color="brown">
|
|
|
|
{t("REBOOT")}
|
|
|
|
</StepButton>,
|
2020-04-28 08:18:04 -06:00
|
|
|
<StepButton {...commonStepProps}
|
|
|
|
step={{ kind: "power_off", args: {} }}
|
|
|
|
color="brown">
|
|
|
|
{t("SHUTDOWN")}
|
|
|
|
</StepButton>,
|
2020-01-07 14:00:25 -07:00
|
|
|
<StepButton {...commonStepProps}
|
|
|
|
step={{ kind: "emergency_lock", args: {} }}
|
|
|
|
color="red">
|
|
|
|
{t("E-STOP")}
|
|
|
|
</StepButton>,
|
2019-04-09 19:45:59 -06:00
|
|
|
<StepButton{...commonStepProps}
|
2017-06-29 12:54:02 -06:00
|
|
|
step={{
|
|
|
|
kind: "find_home",
|
|
|
|
args: {
|
|
|
|
axis: "all",
|
2017-12-07 14:09:34 -07:00
|
|
|
speed: 100
|
2017-06-29 12:54:02 -06:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
color="blue">
|
|
|
|
{t("Find Home")}
|
|
|
|
</StepButton>,
|
2019-12-02 13:53:19 -07:00
|
|
|
<StepButton{...commonStepProps}
|
|
|
|
step={{
|
|
|
|
kind: "zero",
|
|
|
|
args: { axis: "all" }
|
|
|
|
}}
|
|
|
|
color="blue">
|
|
|
|
{t("Set Zero")}
|
|
|
|
</StepButton>,
|
|
|
|
<StepButton{...commonStepProps}
|
|
|
|
step={{
|
|
|
|
kind: "calibrate",
|
|
|
|
args: { axis: "all" }
|
|
|
|
}}
|
|
|
|
color="blue">
|
|
|
|
{t("Calibrate")}
|
|
|
|
</StepButton>,
|
2019-04-09 19:45:59 -06:00
|
|
|
<StepButton {...commonStepProps}
|
2017-06-29 12:54:02 -06:00
|
|
|
step={{
|
|
|
|
kind: "_if",
|
|
|
|
args: {
|
|
|
|
lhs: "x",
|
|
|
|
op: "is",
|
|
|
|
rhs: 0,
|
|
|
|
_then: { kind: "nothing", args: {} },
|
|
|
|
_else: { kind: "nothing", args: {} }
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
color="purple">
|
|
|
|
{t("IF STATEMENT")}
|
|
|
|
</StepButton>,
|
2019-04-09 19:45:59 -06:00
|
|
|
<StepButton {...commonStepProps}
|
2017-06-29 12:54:02 -06:00
|
|
|
step={{
|
|
|
|
kind: "execute",
|
|
|
|
args: { sequence_id: 0 }
|
|
|
|
}}
|
|
|
|
color="gray">
|
|
|
|
{t("EXECUTE SEQUENCE")}
|
|
|
|
</StepButton>,
|
2019-04-09 19:45:59 -06:00
|
|
|
<StepButton {...commonStepProps}
|
2017-06-29 12:54:02 -06:00
|
|
|
step={{
|
|
|
|
kind: "execute_script",
|
|
|
|
args: { label: "plant-detection" }
|
|
|
|
}}
|
|
|
|
color="pink">
|
|
|
|
{t("Run Farmware")}
|
|
|
|
</StepButton>,
|
2018-08-24 10:43:07 -06:00
|
|
|
<StepButton
|
2019-04-09 19:45:59 -06:00
|
|
|
{...commonStepProps}
|
2018-08-24 10:43:07 -06:00
|
|
|
color="brown"
|
2019-09-23 12:56:35 -06:00
|
|
|
step={{ kind: "take_photo", args: {} }}>
|
2017-06-29 12:54:02 -06:00
|
|
|
{t("TAKE PHOTO")}
|
2018-08-24 10:43:07 -06:00
|
|
|
</StepButton>,
|
2020-04-23 13:11:25 -06:00
|
|
|
<StepButton
|
|
|
|
{...commonStepProps}
|
|
|
|
step={{
|
|
|
|
kind: "assertion",
|
|
|
|
args: {
|
|
|
|
lua: "return 2 + 2 == 4",
|
|
|
|
_then: { kind: "nothing", args: {} },
|
|
|
|
assertion_type: "abort_recover",
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
color="purple">
|
|
|
|
{t("ASSERTION")}
|
|
|
|
</StepButton>,
|
2017-06-29 12:54:02 -06:00
|
|
|
];
|
|
|
|
|
2020-04-21 15:37:08 -06:00
|
|
|
shouldDisplay(Feature.update_resource) && ALL_THE_BUTTONS.push(<StepButton
|
2019-04-09 19:45:59 -06:00
|
|
|
{...commonStepProps}
|
2018-09-11 17:17:30 -06:00
|
|
|
step={{
|
2020-04-21 15:37:08 -06:00
|
|
|
kind: "update_resource",
|
2020-04-30 17:55:14 -06:00
|
|
|
args: { resource: NOTHING_SELECTED },
|
|
|
|
body: [],
|
2018-09-11 17:17:30 -06:00
|
|
|
}}
|
|
|
|
color="brown">
|
|
|
|
{t("Mark As...")}
|
2020-02-28 09:35:32 -07:00
|
|
|
</StepButton>);
|
2020-04-23 13:11:25 -06:00
|
|
|
|
2020-02-28 09:34:28 -07:00
|
|
|
return <Row>
|
|
|
|
<div className="step-button-cluster">
|
|
|
|
{ALL_THE_BUTTONS.map((stepButton, inx) =>
|
|
|
|
<div key={inx} onClick={() => scrollToBottom("sequenceDiv")}>
|
|
|
|
{stepButton}
|
|
|
|
</div>)}
|
|
|
|
</div>
|
|
|
|
</Row>;
|
2017-06-29 12:54:02 -06:00
|
|
|
}
|