2017-06-29 12:54:02 -06:00
|
|
|
import * as React from "react";
|
|
|
|
import { BooleanMCUInputGroup } from "../boolean_mcu_input_group";
|
2020-02-18 12:21:09 -07:00
|
|
|
import { ToolTips, DeviceSetting } from "../../../constants";
|
2017-06-29 12:54:02 -06:00
|
|
|
import { NumericMCUInputGroup } from "../numeric_mcu_input_group";
|
2017-12-07 21:05:22 -07:00
|
|
|
import { CalibrationRow } from "./calibration_row";
|
2018-01-29 13:53:24 -07:00
|
|
|
import { disabledAxisMap } from "../axis_tracking_status";
|
2017-06-29 12:54:02 -06:00
|
|
|
import { HomingAndCalibrationProps } from "../interfaces";
|
|
|
|
import { Header } from "./header";
|
|
|
|
import { Collapse } from "@blueprintjs/core";
|
2019-04-02 13:59:37 -06:00
|
|
|
import { t } from "../../../i18next_wrapper";
|
2019-04-16 11:01:27 -06:00
|
|
|
import { calculateScale } from "./motors";
|
2020-02-26 11:10:59 -07:00
|
|
|
import { hasEncoders } from "../firmware_hardware_support";
|
2020-02-15 11:29:09 -07:00
|
|
|
import { getDevice } from "../../../device";
|
|
|
|
import { commandErr } from "../../actions";
|
|
|
|
import { CONFIG_DEFAULTS } from "farmbot/dist/config";
|
2020-02-18 12:21:09 -07:00
|
|
|
import { Highlight } from "../maybe_highlight";
|
2020-02-28 09:50:14 -07:00
|
|
|
import { SpacePanelHeader } from "./space_panel_header";
|
2017-06-29 12:54:02 -06:00
|
|
|
|
|
|
|
export function HomingAndCalibration(props: HomingAndCalibrationProps) {
|
|
|
|
|
2020-02-15 11:29:09 -07:00
|
|
|
const {
|
2020-03-13 15:06:40 -06:00
|
|
|
dispatch, bot, sourceFwConfig, firmwareConfig, botOnline,
|
2020-02-15 11:29:09 -07:00
|
|
|
firmwareHardware
|
2018-03-09 02:34:24 -07:00
|
|
|
} = props;
|
|
|
|
const hardware = firmwareConfig ? firmwareConfig : bot.hardware.mcu_params;
|
2017-08-28 05:49:13 -06:00
|
|
|
const { homing_and_calibration } = props.bot.controlPanelState;
|
2017-06-29 12:54:02 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tells us if X/Y/Z have a means of checking their position.
|
|
|
|
* FARMBOT WILL CRASH INTO WALLS IF THIS IS WRONG! BE CAREFUL.
|
|
|
|
*/
|
2018-03-09 02:34:24 -07:00
|
|
|
const disabled = disabledAxisMap(hardware);
|
2017-06-29 12:54:02 -06:00
|
|
|
|
2019-04-16 11:01:27 -06:00
|
|
|
const scale = calculateScale(sourceFwConfig);
|
|
|
|
|
2020-02-18 12:21:09 -07:00
|
|
|
return <Highlight className={"section"}
|
|
|
|
settingName={DeviceSetting.homingAndCalibration}>
|
2017-06-29 12:54:02 -06:00
|
|
|
<Header
|
2020-02-18 12:21:09 -07:00
|
|
|
title={DeviceSetting.homingAndCalibration}
|
|
|
|
panel={"homing_and_calibration"}
|
2017-06-29 12:54:02 -06:00
|
|
|
dispatch={dispatch}
|
2018-06-18 15:12:00 -06:00
|
|
|
expanded={homing_and_calibration} />
|
2017-06-29 12:54:02 -06:00
|
|
|
<Collapse isOpen={!!homing_and_calibration}>
|
2020-03-13 15:06:40 -06:00
|
|
|
<SpacePanelHeader />
|
2020-02-15 11:29:09 -07:00
|
|
|
<CalibrationRow
|
|
|
|
type={"find_home"}
|
2020-02-18 12:21:09 -07:00
|
|
|
title={DeviceSetting.homing}
|
2020-02-15 11:29:09 -07:00
|
|
|
axisTitle={t("FIND HOME")}
|
2020-02-26 11:10:59 -07:00
|
|
|
toolTip={!hasEncoders(firmwareHardware)
|
2020-02-15 11:29:09 -07:00
|
|
|
? ToolTips.HOMING_STALL_DETECTION
|
|
|
|
: ToolTips.HOMING_ENCODERS}
|
|
|
|
action={axis => getDevice()
|
|
|
|
.findHome({ speed: CONFIG_DEFAULTS.speed, axis })
|
|
|
|
.catch(commandErr("'Find Home' request"))}
|
|
|
|
hardware={hardware}
|
2020-03-13 15:06:40 -06:00
|
|
|
botOnline={botOnline} />
|
2020-02-15 11:29:09 -07:00
|
|
|
<CalibrationRow
|
|
|
|
type={"calibrate"}
|
2020-02-18 12:21:09 -07:00
|
|
|
title={DeviceSetting.calibration}
|
2020-02-15 11:29:09 -07:00
|
|
|
axisTitle={t("CALIBRATE")}
|
2020-02-26 11:10:59 -07:00
|
|
|
toolTip={!hasEncoders(firmwareHardware)
|
2020-02-15 11:29:09 -07:00
|
|
|
? ToolTips.CALIBRATION_STALL_DETECTION
|
|
|
|
: ToolTips.CALIBRATION_ENCODERS}
|
|
|
|
action={axis => getDevice().calibrate({ axis })
|
|
|
|
.catch(commandErr("Calibration"))}
|
|
|
|
hardware={hardware}
|
2020-03-13 15:06:40 -06:00
|
|
|
botOnline={botOnline} />
|
2020-02-15 11:29:09 -07:00
|
|
|
<CalibrationRow
|
|
|
|
type={"zero"}
|
2020-02-18 12:21:09 -07:00
|
|
|
title={DeviceSetting.setZeroPosition}
|
2020-02-15 11:29:09 -07:00
|
|
|
axisTitle={t("ZERO")}
|
|
|
|
toolTip={ToolTips.SET_ZERO_POSITION}
|
|
|
|
action={axis => getDevice().setZero(axis)
|
|
|
|
.catch(commandErr("Zeroing"))}
|
|
|
|
hardware={hardware}
|
2020-03-13 15:06:40 -06:00
|
|
|
botOnline={botOnline} />
|
2017-06-29 12:54:02 -06:00
|
|
|
<BooleanMCUInputGroup
|
2020-02-18 12:21:09 -07:00
|
|
|
label={DeviceSetting.findHomeOnBoot}
|
2020-02-26 11:10:59 -07:00
|
|
|
tooltip={!hasEncoders(firmwareHardware)
|
2020-02-15 11:29:09 -07:00
|
|
|
? ToolTips.FIND_HOME_ON_BOOT_STALL_DETECTION
|
|
|
|
: ToolTips.FIND_HOME_ON_BOOT_ENCODERS}
|
2018-01-29 13:53:24 -07:00
|
|
|
disable={disabled}
|
2017-06-29 12:54:02 -06:00
|
|
|
x={"movement_home_at_boot_x"}
|
|
|
|
y={"movement_home_at_boot_y"}
|
|
|
|
z={"movement_home_at_boot_z"}
|
|
|
|
dispatch={dispatch}
|
2018-03-09 02:34:24 -07:00
|
|
|
sourceFwConfig={sourceFwConfig}
|
2017-08-23 16:26:09 -06:00
|
|
|
caution={true} />
|
2017-06-29 12:54:02 -06:00
|
|
|
<BooleanMCUInputGroup
|
2020-02-18 12:21:09 -07:00
|
|
|
label={DeviceSetting.stopAtHome}
|
2018-02-28 13:12:11 -07:00
|
|
|
tooltip={ToolTips.STOP_AT_HOME}
|
2017-06-29 12:54:02 -06:00
|
|
|
x={"movement_stop_at_home_x"}
|
|
|
|
y={"movement_stop_at_home_y"}
|
|
|
|
z={"movement_stop_at_home_z"}
|
|
|
|
dispatch={dispatch}
|
2018-03-09 02:34:24 -07:00
|
|
|
sourceFwConfig={sourceFwConfig} />
|
2017-06-29 12:54:02 -06:00
|
|
|
<BooleanMCUInputGroup
|
2020-02-18 12:21:09 -07:00
|
|
|
label={DeviceSetting.stopAtMax}
|
2018-02-28 13:12:11 -07:00
|
|
|
tooltip={ToolTips.STOP_AT_MAX}
|
2017-06-29 12:54:02 -06:00
|
|
|
x={"movement_stop_at_max_x"}
|
|
|
|
y={"movement_stop_at_max_y"}
|
|
|
|
z={"movement_stop_at_max_z"}
|
|
|
|
dispatch={dispatch}
|
2018-03-09 02:34:24 -07:00
|
|
|
sourceFwConfig={sourceFwConfig} />
|
2017-06-29 12:54:02 -06:00
|
|
|
<BooleanMCUInputGroup
|
2020-02-18 12:21:09 -07:00
|
|
|
label={DeviceSetting.negativeCoordinatesOnly}
|
2018-02-28 13:12:11 -07:00
|
|
|
tooltip={ToolTips.NEGATIVE_COORDINATES_ONLY}
|
2017-06-29 12:54:02 -06:00
|
|
|
x={"movement_home_up_x"}
|
|
|
|
y={"movement_home_up_y"}
|
|
|
|
z={"movement_home_up_z"}
|
|
|
|
dispatch={dispatch}
|
2018-03-09 02:34:24 -07:00
|
|
|
sourceFwConfig={sourceFwConfig} />
|
2017-06-29 12:54:02 -06:00
|
|
|
<NumericMCUInputGroup
|
2020-02-18 12:21:09 -07:00
|
|
|
label={DeviceSetting.axisLength}
|
2018-02-28 13:12:11 -07:00
|
|
|
tooltip={ToolTips.LENGTH}
|
2017-06-29 12:54:02 -06:00
|
|
|
x={"movement_axis_nr_steps_x"}
|
|
|
|
y={"movement_axis_nr_steps_y"}
|
|
|
|
z={"movement_axis_nr_steps_z"}
|
2019-04-16 11:01:27 -06:00
|
|
|
xScale={scale.x}
|
|
|
|
yScale={scale.y}
|
|
|
|
zScale={scale.z}
|
2018-01-29 13:53:24 -07:00
|
|
|
gray={{
|
2018-03-09 02:34:24 -07:00
|
|
|
x: !sourceFwConfig("movement_stop_at_max_x").value,
|
|
|
|
y: !sourceFwConfig("movement_stop_at_max_y").value,
|
|
|
|
z: !sourceFwConfig("movement_stop_at_max_z").value,
|
2018-01-29 13:53:24 -07:00
|
|
|
}}
|
2018-03-09 02:34:24 -07:00
|
|
|
sourceFwConfig={sourceFwConfig}
|
2017-12-16 17:16:19 -07:00
|
|
|
dispatch={dispatch}
|
2020-02-07 16:06:40 -07:00
|
|
|
intSize={"long"} />
|
2017-06-29 12:54:02 -06:00
|
|
|
</Collapse>
|
2020-02-18 12:21:09 -07:00
|
|
|
</Highlight>;
|
2017-06-29 12:54:02 -06:00
|
|
|
}
|