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

178 lines
4.7 KiB
TypeScript
Raw Normal View History

2017-06-29 12:54:02 -06:00
import { BotStateTree } from "farmbot";
import {
McuParamName,
ConfigurationName,
Dictionary,
SyncStatus,
FarmwareManifest,
LocationName
2017-06-29 12:54:02 -06:00
} from "farmbot";
import { AuthState } from "../auth/interfaces";
import {
TaggedImage,
TaggedPeripheral,
TaggedDevice
} 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";
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;
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;
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;
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
}
2018-01-10 13:08:56 -07:00
export interface BotProp { bot: BotState; }
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;
}
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;
account: TaggedDevice;
botToMqttStatus: NetworkState;
2017-06-29 12:54:02 -06:00
dispatch: Function;
}
2018-01-11 23:18:26 -07:00
export interface FarmbotOsState {
osReleaseNotes: string;
}
export interface CameraSelectionProps {
env: Dictionary<string | undefined>
}
export interface CameraSelectionState {
2017-06-29 12:54:02 -06:00
cameraStatus: "" | "sending" | "done" | "error";
}
export interface StepsPerMMBoxProps {
bot: BotState;
setting: ConfigurationName;
dispatch: Function;
disabled?: boolean;
2017-06-29 12:54:02 -06:00
}
export interface McuInputBoxProps {
bot: BotState;
setting: McuParamName;
dispatch: Function;
2017-12-16 17:16:19 -07:00
intSize?: IntegerSize;
2017-12-20 15:22:35 -07:00
filter?: number;
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
}
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;
// Partial because easier testing. Change to normal `WebAppConfig` if it
// becomes cumbersome later on.
webAppConfig: Partial<WebAppConfig>;
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;
}
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;
2017-06-29 12:54:02 -06:00
}