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

246 lines
7.3 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,
2018-08-01 07:09:30 -06:00
TaggedDiagnosticDump,
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";
import {
ConnectionStatus, 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 {
2017-10-02 08:58:03 -06:00
userToApi: ConnectionStatus | undefined;
userToMqtt: ConnectionStatus | undefined;
botToMqtt: ConnectionStatus | undefined;
2017-06-29 12:54:02 -06:00
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;
isValidFbosConfig: boolean;
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 {
assertion_block = "assertion_block",
2018-03-08 18:02:50 -07:00
named_pins = "named_pins",
2018-03-10 00:17:53 -07:00
sensors = "sensors",
2018-03-08 18:02:50 -07:00
change_ownership = "change_ownership",
variables = "variables",
2019-03-13 13:05:54 -06:00
loops = "loops",
2018-03-13 18:34:30 -06:00
api_pin_bindings = "api_pin_bindings",
2018-03-13 19:32:19 -06:00
farmduino_k14 = "farmduino_k14",
2018-03-08 18:02:50 -07:00
jest_feature = "jest_feature", // for tests
backscheduled_regimens = "backscheduled_regimens",
endstop_invert = "endstop_invert",
2018-07-19 23:48:32 -06:00
diagnostic_dumps = "diagnostic_dumps",
2018-07-23 14:55:42 -06:00
rpi_led_control = "rpi_led_control",
2018-09-11 17:17:30 -06:00
mark_as_step = "mark_as_step",
2018-09-24 13:34:38 -06:00
firmware_restart = "firmware_restart",
api_farmware_installations = "api_farmware_installations",
2018-11-01 11:17:18 -06:00
api_farmware_env = "api_farmware_env",
2018-11-26 20:39:35 -07:00
use_update_channel = "use_update_channel",
2019-02-07 17:54:47 -07:00
long_scaling_factor = "long_scaling_factor",
2019-04-09 20:31:25 -06:00
flash_firmware = "flash_firmware",
2019-05-03 13:50:27 -06:00
express_k10 = "express_k10",
2019-07-15 16:53:28 -06:00
none_firmware = "none_firmware",
2018-03-08 18:02:50 -07:00
}
/** Object fetched from FEATURE_MIN_VERSIONS_URL. */
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;
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;
}
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[];
diagnostics: TaggedDiagnosticDump[];
2019-06-07 18:26:12 -06:00
deviceAccount: TaggedDevice;
botToMqttStatus: NetworkState;
botToMqttLastSeen: number;
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;
isValidFbosConfig: boolean;
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
}
2018-01-11 23:18:26 -07:00
export interface FarmbotOsState {
2018-09-14 12:54:14 -06:00
osReleaseNotesHeading: string;
2018-01-11 23:18:26 -07:00
osReleaseNotes: string;
}
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;
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;
}
2017-06-29 12:54:02 -06:00
export interface FarmwareProps {
dispatch: Function;
env: Partial<WD_ENV>;
2018-11-01 11:17:18 -06:00
user_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;
botToMqttStatus: NetworkState;
2017-06-29 12:54:02 -06:00
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;
encoders_and_endstops: boolean;
danger_zone: boolean;
power_and_reset: boolean;
2017-12-16 18:21:13 -07:00
pin_guard: boolean;
diagnostic_dumps: boolean;
2017-06-29 12:54:02 -06:00
}