Farmbot-Web-App/frontend/devices/interfaces.ts

259 lines
7.6 KiB
TypeScript
Raw Normal View History

2017-06-29 12:54:02 -06:00
import { AuthState } from "../auth/interfaces";
import {
2018-08-01 18:20:50 -06:00
BotStateTree, ConfigurationName,
McuParamName, SyncStatus, LocationName,
2017-06-29 12:54:02 -06:00
TaggedImage,
TaggedPeripheral,
2018-03-10 00:17:53 -07:00
TaggedDevice,
TaggedSensor,
TaggedFarmwareInstallation,
JobProgress,
2019-06-03 17:41:59 -06:00
FirmwareHardware,
2019-07-12 14:39:40 -06:00
Alert,
2018-08-01 07:09:30 -06:00
} from "farmbot";
2018-01-23 18:03:45 -07:00
import { ResourceIndex } from "../resources/interfaces";
2017-07-28 15:24:21 -06:00
import { WD_ENV } from "../farmware/weed_detector/remote_env/interfaces";
2020-03-13 15:06:40 -06:00
import { ConnectionState, NetworkState } from "../connectivity/interfaces";
2017-12-16 17:16:19 -07:00
import { IntegerSize } from "../util";
2018-06-21 15:04:21 -06:00
import { Farmwares } from "../farmware/interfaces";
2018-10-22 09:35:44 -06:00
import { FirmwareConfig } from "farmbot/dist/resources/configs/firmware";
2019-04-09 23:17:03 -06:00
import { GetWebAppConfigValue } from "../config_storage/actions";
import { TimeSettings } from "../interfaces";
2017-06-29 12:54:02 -06:00
export interface Props {
auth: AuthState | undefined;
bot: BotState;
deviceAccount: TaggedDevice;
images: TaggedImage[];
dispatch: Function;
2017-11-30 20:43:35 -07:00
resources: ResourceIndex;
2018-01-27 02:29:13 -07:00
sourceFbosConfig: SourceFbosConfig;
2018-03-09 02:34:24 -07:00
sourceFwConfig: SourceFwConfig;
2018-03-07 22:08:00 -07:00
shouldDisplay: ShouldDisplay;
2018-03-08 21:03:02 -07:00
firmwareConfig: FirmwareConfig | undefined;
2018-11-01 11:17:18 -06:00
env: UserEnv;
saveFarmwareEnv: SaveFarmwareEnv;
2019-04-09 23:17:03 -06:00
timeSettings: TimeSettings;
2019-07-12 14:39:40 -06:00
alerts: Alert[];
2017-06-29 12:54:02 -06:00
}
2018-11-01 11:17:18 -06:00
/** Function to save a Farmware env variable to the API. */
export type SaveFarmwareEnv =
(key: string, value: string) => (dispatch: Function) => void;
2018-03-09 02:34:24 -07:00
/** Value and consistency of the value between the bot and /api/fbos_config. */
2018-01-27 02:29:13 -07:00
export type SourceFbosConfig = (config: ConfigurationName) =>
{
value: boolean | number | string | undefined,
consistent: boolean
};
2018-03-09 02:34:24 -07:00
/**
* Value and consistency of the value between the bot and /api/firmware_config.
* */
export type SourceFwConfig = (config: McuParamName) =>
{ value: number | undefined, consistent: boolean };
2018-03-08 18:02:50 -07:00
/** Function to determine if a feature should be displayed. */
export type ShouldDisplay = (x: Feature) => boolean;
/** Names of features that use minimum FBOS version checking. */
export enum Feature {
2019-10-09 15:04:23 -06:00
api_farmware_env = "api_farmware_env",
api_farmware_installations = "api_farmware_installations",
2018-03-13 18:34:30 -06:00
api_pin_bindings = "api_pin_bindings",
2019-10-09 15:04:23 -06:00
assertion_block = "assertion_block",
backscheduled_regimens = "backscheduled_regimens",
2019-10-09 15:04:23 -06:00
boot_sequence = "boot_sequence",
change_ownership = "change_ownership",
2020-02-07 16:05:16 -07:00
criteria_groups = "criteria_groups",
2019-10-09 15:04:23 -06:00
endstop_invert = "endstop_invert",
express_k10 = "express_k10",
farmduino_k14 = "farmduino_k14",
2019-12-27 13:30:58 -07:00
farmduino_k15 = "farmduino_k15",
2018-09-24 13:34:38 -06:00
firmware_restart = "firmware_restart",
2019-04-09 20:31:25 -06:00
flash_firmware = "flash_firmware",
2019-10-09 15:04:23 -06:00
groups = "groups",
jest_feature = "jest_feature",
long_scaling_factor = "long_scaling_factor",
mark_as_step = "mark_as_step",
named_pins = "named_pins",
2019-07-15 16:53:28 -06:00
none_firmware = "none_firmware",
2019-11-13 15:49:39 -07:00
ota_update_hour = "ota_update_hour",
2019-10-09 15:04:23 -06:00
rpi_led_control = "rpi_led_control",
sensors = "sensors",
use_update_channel = "use_update_channel",
2020-02-07 16:05:16 -07:00
variables = "variables",
2018-03-08 18:02:50 -07:00
}
2019-10-09 15:04:23 -06:00
2020-02-15 11:30:23 -07:00
/** Object fetched from ExternalUrl.featureMinVersions. */
2018-03-08 18:02:50 -07:00
export type MinOsFeatureLookup = Partial<Record<Feature, string>>;
2017-06-29 12:54:02 -06:00
export interface BotState {
2017-11-22 07:46:47 -07:00
/** The browser optimistically overwrites FBOS sync status to "syncing..."
* to reduce UI latency. When AJAX/sync operations fail, we need
* a mechanism to rollback the update to the previous value. We store the
* value of the status prior to the update here for safety */
2017-11-21 15:24:34 -07:00
statusStash?: SyncStatus | undefined;
2017-06-29 12:54:02 -06:00
/** How many steps to move when the user presses a manual movement arrow */
stepSize: number;
/** The current os version on the github release api */
currentOSVersion?: string;
2018-01-10 17:37:36 -07:00
/** The current beta os version on the github release api */
currentBetaOSVersion?: string;
2018-01-28 14:00:16 -07:00
/** The current beta os commit on the github release api */
currentBetaOSCommit?: string;
2018-03-07 20:42:34 -07:00
/** JSON string of minimum required FBOS versions for various features. */
2018-03-08 18:02:50 -07:00
minOsFeatureData?: MinOsFeatureLookup;
2020-03-13 15:06:40 -06:00
/** Notes notifying users of changes that may require intervention. */
osReleaseNotes?: string;
2017-06-29 12:54:02 -06:00
/** Is the bot in sync with the api */
dirty: boolean;
/** The state of the bot, as reported by the bot over MQTT. */
hardware: HardwareState;
/** Hardware settings auto update on blur. Tells the UI if it should load a
* spinner or not. */
isUpdating?: boolean;
controlPanelState: ControlPanelState;
2017-11-20 12:44:46 -07:00
/** Have all API requests been acknowledged by external services? This flag
* lets us know if it is safe to do data critical tasks with the bot */
consistent: boolean;
connectivity: ConnectionState;
2017-06-29 12:54:02 -06:00
}
/** Status registers for the bot's status */
export type HardwareState = BotStateTree;
export interface GithubRelease {
tag_name: string;
2018-01-28 14:00:16 -07:00
target_commitish: string;
2020-01-28 12:30:04 -07:00
assets: {
name: string;
browser_download_url: string;
}[];
2018-01-28 14:00:16 -07:00
}
export interface OsUpdateInfo {
version: string;
commit: string;
2017-06-29 12:54:02 -06:00
}
export interface MoveRelProps {
x: number;
y: number;
z: number;
speed?: number | undefined;
}
export type Xyz = "x" | "y" | "z";
export type Axis = Xyz | "all";
2017-08-02 17:59:34 -06:00
export type BotPosition = Record<Xyz, (number | undefined)>;
2017-10-20 00:26:41 -06:00
export type BotLocationData = Record<LocationName, BotPosition>;
2017-08-02 17:59:34 -06:00
export type StepsPerMmXY = Record<"x" | "y", (number | undefined)>;
2018-11-01 11:17:18 -06:00
export type UserEnv = Record<string, string | undefined>;
2017-06-29 12:54:02 -06:00
export interface FarmbotOsProps {
bot: BotState;
2019-07-12 14:39:40 -06:00
alerts: Alert[];
2019-06-07 18:26:12 -06:00
deviceAccount: TaggedDevice;
2017-06-29 12:54:02 -06:00
dispatch: Function;
2018-01-27 02:29:13 -07:00
sourceFbosConfig: SourceFbosConfig;
2018-03-07 22:08:00 -07:00
shouldDisplay: ShouldDisplay;
2018-11-01 11:17:18 -06:00
env: UserEnv;
saveFarmwareEnv: SaveFarmwareEnv;
2019-04-09 23:17:03 -06:00
timeSettings: TimeSettings;
2017-06-29 12:54:02 -06:00
}
2020-03-13 15:06:40 -06:00
export interface FarmbotSettingsProps {
bot: BotState;
alerts: Alert[];
device: TaggedDevice;
dispatch: Function;
sourceFbosConfig: SourceFbosConfig;
shouldDisplay: ShouldDisplay;
env: UserEnv;
saveFarmwareEnv: SaveFarmwareEnv;
timeSettings: TimeSettings;
botOnline: boolean;
2018-01-11 23:18:26 -07:00
}
2017-06-29 12:54:02 -06:00
export interface McuInputBoxProps {
2018-03-09 02:34:24 -07:00
sourceFwConfig: SourceFwConfig;
2017-06-29 12:54:02 -06:00
setting: McuParamName;
dispatch: Function;
2017-12-16 17:16:19 -07:00
intSize?: IntegerSize;
2018-07-13 14:56:01 -06:00
float?: boolean;
2019-01-28 17:04:50 -07:00
scale?: number;
2017-12-20 15:22:35 -07:00
filter?: number;
2018-01-29 13:53:24 -07:00
gray?: boolean;
2017-06-29 12:54:02 -06:00
}
export interface EStopButtonProps {
bot: BotState;
2019-04-17 13:31:18 -06:00
forceUnlock: boolean;
2017-06-29 12:54:02 -06:00
}
export interface PeripheralsProps {
bot: BotState;
peripherals: TaggedPeripheral[];
dispatch: Function;
disabled: boolean | undefined;
2020-02-18 12:21:09 -07:00
firmwareHardware: FirmwareHardware | undefined;
2017-06-29 12:54:02 -06:00
}
2018-03-10 00:17:53 -07:00
export interface SensorsProps {
bot: BotState;
sensors: TaggedSensor[];
dispatch: Function;
disabled: boolean | undefined;
2020-02-18 12:21:09 -07:00
firmwareHardware: FirmwareHardware | undefined;
2018-03-10 00:17:53 -07:00
}
2017-06-29 12:54:02 -06:00
export interface FarmwareProps {
dispatch: Function;
2019-12-27 11:37:54 -07:00
wDEnv: Partial<WD_ENV>;
env: UserEnv;
2017-06-29 12:54:02 -06:00
images: TaggedImage[];
currentImage: TaggedImage | undefined;
botToMqttStatus: NetworkState;
2018-06-21 15:04:21 -06:00
farmwares: Farmwares;
2019-04-09 23:17:03 -06:00
timeSettings: TimeSettings;
2018-01-19 10:49:07 -07:00
syncStatus: SyncStatus | undefined;
2019-04-09 23:17:03 -06:00
getConfigValue: GetWebAppConfigValue;
2018-02-14 22:07:36 -07:00
firstPartyFarmwareNames: string[];
2018-06-21 15:04:21 -06:00
currentFarmware: string | undefined;
2018-11-01 11:17:18 -06:00
shouldDisplay: ShouldDisplay;
saveFarmwareEnv: SaveFarmwareEnv;
2018-11-05 18:37:09 -07:00
taggedFarmwareInstallations: TaggedFarmwareInstallation[];
imageJobs: JobProgress[];
2019-04-09 19:45:59 -06:00
infoOpen: boolean;
2017-06-29 12:54:02 -06:00
}
export interface HardwareSettingsProps {
controlPanelState: ControlPanelState;
dispatch: Function;
bot: BotState;
shouldDisplay: ShouldDisplay;
2018-03-09 02:34:24 -07:00
sourceFwConfig: SourceFwConfig;
2018-03-08 21:03:02 -07:00
firmwareConfig: FirmwareConfig | undefined;
2019-06-03 17:41:59 -06:00
firmwareHardware: FirmwareHardware | undefined;
2019-06-21 15:45:44 -06:00
resources: ResourceIndex;
2017-06-29 12:54:02 -06:00
}
export interface ControlPanelState {
homing_and_calibration: boolean;
motors: boolean;
2020-02-15 11:29:09 -07:00
encoders: boolean;
endstops: boolean;
error_handling: boolean;
2020-02-18 12:21:09 -07:00
pin_guard: boolean;
2017-06-29 12:54:02 -06:00
danger_zone: boolean;
2020-02-18 12:21:09 -07:00
pin_bindings: boolean;
power_and_reset: boolean;
2020-02-28 09:50:14 -07:00
farm_designer: boolean;
firmware: boolean;
farmbot_os: boolean;
2017-06-29 12:54:02 -06:00
}