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

229 lines
6.6 KiB
TypeScript
Raw Normal View History

2018-01-27 02:29:13 -07:00
import { BotStateTree, ConfigurationName } from "farmbot";
2017-06-29 12:54:02 -06:00
import {
McuParamName,
Dictionary,
SyncStatus,
FarmwareManifest,
LocationName
2017-06-29 12:54:02 -06:00
} from "farmbot";
import { AuthState } from "../auth/interfaces";
import {
TaggedImage,
TaggedPeripheral,
2018-03-10 00:17:53 -07:00
TaggedDevice,
TaggedSensor,
TaggedDiagnosticDump
2017-06-29 12:54:02 -06:00
} from "../resources/tagged_resources";
2018-01-23 18:03:45 -07:00
import { ResourceIndex } from "../resources/interfaces";
2017-06-29 12:54:02 -06:00
import { TaggedUser } from "../resources/tagged_resources";
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";
import { WebAppConfig } from "../config_storage/web_app_configs";
2018-03-08 21:03:02 -07:00
import { FirmwareConfig } from "../config_storage/firmware_configs";
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;
2017-06-29 12:54:02 -06:00
}
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 {
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",
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",
diagnostic_dumps = "diagnostic_dumps"
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
/** How the device is stored in the API side.
* This is what comes back from the API as JSON.
*/
export interface DeviceAccountSettings {
id: number;
name: string;
timezone?: string | undefined;
2017-12-28 09:49:58 -07:00
tz_offset_hrs: number;
throttled_until?: string;
throttled_at?: string;
fbos_version?: string | undefined;
last_saw_api?: string | undefined;
last_saw_mq?: string | undefined;
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)>;
2017-06-29 12:54:02 -06:00
export interface CalibrationButtonProps {
disabled: boolean;
axis: Axis;
}
export interface FarmbotOsProps {
bot: BotState;
diagnostics: TaggedDiagnosticDump[];
2017-06-29 12:54:02 -06:00
account: TaggedDevice;
botToMqttStatus: NetworkState;
2018-01-24 17:32:50 -07:00
botToMqttLastSeen: string;
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;
2017-06-29 12:54:02 -06:00
}
2018-01-11 23:18:26 -07:00
export interface FarmbotOsState {
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;
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;
user: TaggedUser | undefined;
}
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>;
2017-10-10 22:29:12 -06:00
user_env: Record<string, string | undefined>;
2017-06-29 12:54:02 -06:00
images: TaggedImage[];
currentImage: TaggedImage | undefined;
botToMqttStatus: NetworkState;
2017-06-29 12:54:02 -06:00
farmwares: Dictionary<FarmwareManifest | undefined>;
2017-12-28 13:48:03 -07:00
timeOffset: number;
2018-01-19 10:49:07 -07:00
syncStatus: SyncStatus | undefined;
webAppConfig: Partial<WebAppConfig>;
2018-02-14 22:07:36 -07:00
firstPartyFarmwareNames: string[];
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-01-27 02:29:13 -07:00
sourceFbosConfig: SourceFbosConfig;
2018-03-09 02:34:24 -07:00
sourceFwConfig: SourceFwConfig;
2018-03-08 21:03:02 -07:00
firmwareConfig: FirmwareConfig | undefined;
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
}