diff --git a/api-client/src/runs/types.ts b/api-client/src/runs/types.ts index 0415367f1e6..c42752b0eb9 100644 --- a/api-client/src/runs/types.ts +++ b/api-client/src/runs/types.ts @@ -8,6 +8,7 @@ import type { RunTimeCommand, RunTimeParameter, NozzleLayoutConfig, + LabwareLocation, } from '@opentrons/shared-data' import type { ResourceLink, ErrorDetails } from '../types' export * from './commands/types' @@ -116,7 +117,9 @@ export interface Runs { } export interface RunCurrentStateData { + estopEngaged: boolean activeNozzleLayouts: Record // keyed by pipetteId + placeLabwareState?: PlaceLabwareState } export const RUN_ACTION_TYPE_PLAY: 'play' = 'play' @@ -201,3 +204,9 @@ export interface NozzleLayoutValues { activeNozzles: string[] config: NozzleLayoutConfig } + +export interface PlaceLabwareState { + labwareId: string + location: LabwareLocation + shouldPlaceDown: boolean +} diff --git a/app/src/organisms/EmergencyStop/EstopPressedModal.tsx b/app/src/organisms/EmergencyStop/EstopPressedModal.tsx index e1a255abdcb..0266c1f6c07 100644 --- a/app/src/organisms/EmergencyStop/EstopPressedModal.tsx +++ b/app/src/organisms/EmergencyStop/EstopPressedModal.tsx @@ -143,7 +143,7 @@ function TouchscreenModal({ data-testid="Estop_pressed_button" width="100%" iconName={ - isResuming || isPlacing || isWaitingForLogicalDisengage || isWaitingForPlateReaderLidPlacement + isResuming || isPlacing || isWaitingForLogicalDisengage || isWaitingForPlateReaderLidPlacement ? 'ot-spinner' : undefined } diff --git a/app/src/organisms/EmergencyStop/EstopTakeover.tsx b/app/src/organisms/EmergencyStop/EstopTakeover.tsx index 5967edae75a..9460eddff54 100644 --- a/app/src/organisms/EmergencyStop/EstopTakeover.tsx +++ b/app/src/organisms/EmergencyStop/EstopTakeover.tsx @@ -27,6 +27,10 @@ export function EstopTakeover({ robotName }: EstopTakeoverProps): JSX.Element { isWaitingForLogicalDisengage, setIsWaitingForLogicalDisengage, ] = useState(false) + const [ + isWaitingForPlateReaderLidPlacement, + setisWaitingForPlateReaderLidPlacement, + ] = useState(false) const { data: estopStatus } = useEstopQuery({ refetchInterval: estopEngaged ? ESTOP_CURRENTLY_ENGAGED_REFETCH_INTERVAL_MS @@ -65,6 +69,7 @@ export function EstopTakeover({ robotName }: EstopTakeoverProps): JSX.Element { isDismissedModal={isEmergencyStopModalDismissed} setIsDismissedModal={setIsEmergencyStopModalDismissed} isWaitingForLogicalDisengage={isWaitingForLogicalDisengage} + isWaitingForPlateReaderLidPlacement={isWaitingForPlateReaderLidPlacement} setShouldSeeLogicalDisengage={() => { setIsWaitingForLogicalDisengage(true) }} diff --git a/app/src/resources/modules/hooks/usePlacePlateReaderLid.ts b/app/src/resources/modules/hooks/usePlacePlateReaderLid.ts index 5fcacd48cc2..01b73099246 100644 --- a/app/src/resources/modules/hooks/usePlacePlateReaderLid.ts +++ b/app/src/resources/modules/hooks/usePlacePlateReaderLid.ts @@ -5,6 +5,8 @@ import type { UseRobotControlCommandsProps, UseRobotControlCommandsResult, } from '/app/resources/maintenance_runs' +import { useRunCurrentState } from '@opentrons/react-api-client' +import { useCurrentRunId } from '../../runs' interface UsePlacePlateReaderLidResult { isPlacing: UseRobotControlCommandsResult['isExecuting'] @@ -16,12 +18,15 @@ export type UsePlacePlateReaderLidProps = Pick< 'pipetteInfo' | 'onSettled' > -// TODO: Need to conditionally run this function based on `runs/currentState` value export function usePlacePlateReaderLid( props: UsePlacePlateReaderLidProps ): UsePlacePlateReaderLidResult { - const labwareId: string = 'absorbanceReaderV1LidC3' - const location: LabwareLocation = {slotName: 'C3'} + const runId = useCurrentRunId() + const { data: runCurrentState } = useRunCurrentState(runId) + const estopEngaged = runCurrentState?.data.estopEngaged + const placeLabware = runCurrentState?.data.placeLabwareState?.shouldPlaceDown + const labwareId = runCurrentState?.data.placeLabwareState?.labwareId + const location = runCurrentState?.data.placeLabwareState?.location const LOAD_PLATE_READER: CreateCommand = { commandType: 'loadModule' as const, @@ -42,8 +47,18 @@ export function usePlacePlateReaderLid( continuePastCommandFailure: true, }) + const decideFunction = (): void => { + console.log("DECIDE!") + if (estopEngaged != null && placeLabware) { + console.log("PLACE") + executeCommands() + } else { + console.log("DONT PLACE") + } + } + return { isPlacing: isExecuting, - placeReaderLid: executeCommands, + placeReaderLid: decideFunction, } }