2017-06-29 12:54:02 -06:00
|
|
|
import { Everything } from "../interfaces";
|
2018-05-18 16:34:12 -06:00
|
|
|
import { Props, HardwareFlags, FarmwareConfigs } from "./interfaces";
|
2019-12-27 11:37:54 -07:00
|
|
|
import { selectAllSequences, findSequence } from "../resources/selectors";
|
2017-08-06 19:12:09 -06:00
|
|
|
import { getStepTag } from "../resources/sequence_tagging";
|
2018-01-24 17:33:16 -07:00
|
|
|
import { enabledAxisMap } from "../devices/components/axis_tracking_status";
|
2019-12-27 11:37:54 -07:00
|
|
|
import { validFwConfig } from "../util";
|
2018-08-30 19:25:58 -06:00
|
|
|
import { BooleanSetting } from "../session_keys";
|
|
|
|
import { getWebAppConfigValue } from "../config_storage/actions";
|
2019-04-11 21:17:18 -06:00
|
|
|
import { getFirmwareConfig } from "../resources/getters";
|
2019-03-20 14:18:19 -06:00
|
|
|
import { Farmwares } from "../farmware/interfaces";
|
|
|
|
import { manifestInfo } from "../farmware/generate_manifest_info";
|
2019-04-16 11:01:27 -06:00
|
|
|
import { calculateAxialLengths } from "../controls/move/direction_axes_props";
|
2019-12-13 14:26:57 -07:00
|
|
|
import { mapStateToFolderProps } from "../folders/map_state_to_props";
|
2019-12-27 11:37:54 -07:00
|
|
|
import { getEnv, getShouldDisplayFn } from "../farmware/state_to_props";
|
|
|
|
import {
|
2020-02-28 09:35:32 -07:00
|
|
|
cameraDisabled,
|
2019-12-27 11:37:54 -07:00
|
|
|
} from "../devices/components/fbos_settings/camera_selection";
|
2017-06-29 12:54:02 -06:00
|
|
|
|
|
|
|
export function mapStateToProps(props: Everything): Props {
|
2017-08-28 05:49:13 -06:00
|
|
|
const uuid = props.resources.consumers.sequences.current;
|
2017-11-28 17:01:35 -07:00
|
|
|
const sequence = uuid ? findSequence(props.resources.index, uuid) : undefined;
|
2020-01-03 13:04:45 -07:00
|
|
|
(sequence?.body.body || []).map(x => getStepTag(x));
|
2017-08-06 19:12:09 -06:00
|
|
|
|
2018-03-09 02:34:24 -07:00
|
|
|
const fwConfig = validFwConfig(getFirmwareConfig(props.resources.index));
|
|
|
|
const { mcu_params } = props.bot.hardware;
|
|
|
|
const firmwareSettings = fwConfig || mcu_params;
|
2018-01-24 17:33:16 -07:00
|
|
|
const hardwareFlags = (): HardwareFlags => {
|
|
|
|
return {
|
2018-03-09 02:34:24 -07:00
|
|
|
findHomeEnabled: enabledAxisMap(firmwareSettings),
|
2018-01-24 17:33:16 -07:00
|
|
|
stopAtHome: {
|
2018-03-09 02:34:24 -07:00
|
|
|
x: !!firmwareSettings.movement_stop_at_home_x,
|
|
|
|
y: !!firmwareSettings.movement_stop_at_home_y,
|
|
|
|
z: !!firmwareSettings.movement_stop_at_home_z
|
2018-01-24 17:33:16 -07:00
|
|
|
},
|
|
|
|
stopAtMax: {
|
2018-03-09 02:34:24 -07:00
|
|
|
x: !!firmwareSettings.movement_stop_at_max_x,
|
|
|
|
y: !!firmwareSettings.movement_stop_at_max_y,
|
|
|
|
z: !!firmwareSettings.movement_stop_at_max_z
|
2018-01-24 17:33:16 -07:00
|
|
|
},
|
|
|
|
negativeOnly: {
|
2018-03-09 02:34:24 -07:00
|
|
|
x: !!firmwareSettings.movement_home_up_x,
|
|
|
|
y: !!firmwareSettings.movement_home_up_y,
|
|
|
|
z: !!firmwareSettings.movement_home_up_z
|
2018-01-24 17:33:16 -07:00
|
|
|
},
|
2019-04-16 11:01:27 -06:00
|
|
|
axisLength: calculateAxialLengths({ firmwareSettings }),
|
2018-01-24 17:33:16 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-03-20 14:18:19 -06:00
|
|
|
const botStateFarmwares = props.bot.hardware.process_info.farmwares;
|
|
|
|
const farmwares: Farmwares = {};
|
|
|
|
Object.values(botStateFarmwares).map((fm: unknown) => {
|
|
|
|
const info = manifestInfo(fm);
|
|
|
|
farmwares[info.name] = manifestInfo(fm);
|
|
|
|
});
|
|
|
|
const farmwareNames = Object.values(farmwares).map(fw => fw.name);
|
2018-02-14 22:07:36 -07:00
|
|
|
const { firstPartyFarmwareNames } = props.resources.consumers.farmware;
|
2019-04-11 21:17:18 -06:00
|
|
|
const getConfig = getWebAppConfigValue(() => props);
|
|
|
|
const showFirstPartyFarmware =
|
|
|
|
!!getConfig(BooleanSetting.show_first_party_farmware);
|
2018-05-18 16:34:12 -06:00
|
|
|
const farmwareConfigs: FarmwareConfigs = {};
|
2019-03-20 14:18:19 -06:00
|
|
|
Object.values(farmwares).map(fw => farmwareConfigs[fw.name] = fw.config);
|
2018-02-14 22:07:36 -07:00
|
|
|
|
2019-12-27 11:37:54 -07:00
|
|
|
const shouldDisplay = getShouldDisplayFn(props.resources.index, props.bot);
|
|
|
|
const env = getEnv(props.resources.index, shouldDisplay, props.bot);
|
2019-04-09 19:29:25 -06:00
|
|
|
|
2017-06-29 12:54:02 -06:00
|
|
|
return {
|
|
|
|
dispatch: props.dispatch,
|
|
|
|
sequences: selectAllSequences(props.resources.index),
|
2017-08-06 19:12:09 -06:00
|
|
|
sequence: sequence,
|
2017-07-07 08:52:55 -06:00
|
|
|
resources: props.resources.index,
|
2017-11-28 17:01:35 -07:00
|
|
|
syncStatus: (props
|
|
|
|
.bot
|
|
|
|
.hardware
|
|
|
|
.informational_settings
|
|
|
|
.sync_status || "unknown"),
|
2018-01-24 17:33:16 -07:00
|
|
|
hardwareFlags: hardwareFlags(),
|
2019-12-27 11:37:54 -07:00
|
|
|
farmwareData: {
|
2018-02-14 22:07:36 -07:00
|
|
|
farmwareNames,
|
|
|
|
firstPartyFarmwareNames,
|
2018-05-18 16:34:12 -06:00
|
|
|
showFirstPartyFarmware,
|
|
|
|
farmwareConfigs,
|
2019-12-27 11:37:54 -07:00
|
|
|
cameraDisabled: cameraDisabled(env),
|
2018-03-06 20:02:11 -07:00
|
|
|
},
|
2019-04-09 19:29:25 -06:00
|
|
|
shouldDisplay,
|
2019-04-12 20:50:10 -06:00
|
|
|
getWebAppConfigValue: getConfig,
|
2019-01-12 05:25:02 -07:00
|
|
|
menuOpen: props.resources.consumers.sequences.menuOpen,
|
2019-04-09 19:45:59 -06:00
|
|
|
stepIndex: props.resources.consumers.sequences.stepIndex,
|
2019-12-19 18:30:02 -07:00
|
|
|
folderData: mapStateToFolderProps(props)
|
2017-06-29 12:54:02 -06:00
|
|
|
};
|
|
|
|
}
|