Skip to content

Commit

Permalink
feat(app, shared-data): add usePlacePlateReaderLid to EstopPressedMod…
Browse files Browse the repository at this point in the history
…al to handle plate reader lid.
  • Loading branch information
vegano1 committed Oct 22, 2024
1 parent a35161b commit c7e8264
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 53 deletions.
2 changes: 1 addition & 1 deletion app/src/App/OnDeviceDisplayApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const OnDeviceDisplayApp = (): JSX.Element => {

// TODO (sb:6/12/23) Create a notification manager to set up preference and order of takeover modals
return (
<ApiHostProvider hostname="127.0.0.1">
<ApiHostProvider hostname="10.14.19.57">
<InitialLoadingScreen>
<LocalizationProvider>
<ErrorBoundary FallbackComponent={OnDeviceDisplayAppFallback}>
Expand Down
27 changes: 22 additions & 5 deletions app/src/organisms/EmergencyStop/EstopPressedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
} from '@opentrons/components'

import { useAcknowledgeEstopDisengageMutation } from '@opentrons/react-api-client'
import { usePlacePlateReaderLid } from '/app/resources/modules'


import { getTopPortalEl } from '/app/App/portal'
import { SmallButton } from '/app/atoms/buttons'
Expand All @@ -43,6 +45,7 @@ interface EstopPressedModalProps {
isDismissedModal?: boolean
setIsDismissedModal?: (isDismissedModal: boolean) => void
isWaitingForLogicalDisengage: boolean
isWaitingForPlateReaderLidPlacement: boolean
setShouldSeeLogicalDisengage: () => void
}

Expand All @@ -52,6 +55,7 @@ export function EstopPressedModal({
isDismissedModal,
setIsDismissedModal,
isWaitingForLogicalDisengage,
isWaitingForPlateReaderLidPlacement,
setShouldSeeLogicalDisengage,
}: EstopPressedModalProps): JSX.Element {
const isOnDevice = useSelector(getIsOnDevice)
Expand All @@ -61,6 +65,7 @@ export function EstopPressedModal({
isEngaged={isEngaged}
closeModal={closeModal}
isWaitingForLogicalDisengage={isWaitingForLogicalDisengage}
isWaitingForPlateReaderLidPlacement={isWaitingForPlateReaderLidPlacement}
setShouldSeeLogicalDisengage={setShouldSeeLogicalDisengage}
/>
) : (
Expand All @@ -71,6 +76,7 @@ export function EstopPressedModal({
closeModal={closeModal}
setIsDismissedModal={setIsDismissedModal}
isWaitingForLogicalDisengage={isWaitingForLogicalDisengage}
isWaitingForPlateReaderLidPlacement={isWaitingForPlateReaderLidPlacement}
setShouldSeeLogicalDisengage={setShouldSeeLogicalDisengage}
/>
) : null}
Expand All @@ -84,11 +90,16 @@ function TouchscreenModal({
isEngaged,
closeModal,
isWaitingForLogicalDisengage,
isWaitingForPlateReaderLidPlacement,
setShouldSeeLogicalDisengage,
}: EstopPressedModalProps): JSX.Element {
const { t } = useTranslation(['device_settings', 'branded'])
const [isResuming, setIsResuming] = React.useState<boolean>(false)
const { acknowledgeEstopDisengage } = useAcknowledgeEstopDisengageMutation()

const { placeReaderLid, isPlacing } = usePlacePlateReaderLid({
pipetteInfo: null
})
const modalHeader: OddModalHeaderBaseProps = {
title: t('estop_pressed'),
iconName: 'ot-alert',
Expand All @@ -102,6 +113,7 @@ function TouchscreenModal({
setIsResuming(true)
acknowledgeEstopDisengage(null)
setShouldSeeLogicalDisengage()
placeReaderLid()
closeModal()
}
return (
Expand Down Expand Up @@ -131,15 +143,15 @@ function TouchscreenModal({
data-testid="Estop_pressed_button"
width="100%"
iconName={
isResuming || isWaitingForLogicalDisengage
isResuming || isPlacing || isWaitingForLogicalDisengage || isWaitingForPlateReaderLidPlacement
? 'ot-spinner'
: undefined
}
iconPlacement={
isResuming || isWaitingForLogicalDisengage ? 'startIcon' : undefined
isResuming || isPlacing || isWaitingForLogicalDisengage || isWaitingForPlateReaderLidPlacement ? 'startIcon' : undefined
}
buttonText={t('resume_robot_operations')}
disabled={isEngaged || isResuming || isWaitingForLogicalDisengage}
disabled={isEngaged || isResuming || isPlacing || isWaitingForLogicalDisengage || isWaitingForPlateReaderLidPlacement}
onClick={handleClick}
/>
</Flex>
Expand All @@ -152,11 +164,15 @@ function DesktopModal({
closeModal,
setIsDismissedModal,
isWaitingForLogicalDisengage,
isWaitingForPlateReaderLidPlacement,
setShouldSeeLogicalDisengage,
}: EstopPressedModalProps): JSX.Element {
const { t } = useTranslation('device_settings')
const [isResuming, setIsResuming] = React.useState<boolean>(false)
const { acknowledgeEstopDisengage } = useAcknowledgeEstopDisengageMutation()
const { placeReaderLid, isPlacing } = usePlacePlateReaderLid({
pipetteInfo: null
})

const handleCloseModal = (): void => {
if (setIsDismissedModal != null) {
Expand All @@ -182,6 +198,7 @@ function DesktopModal({
{
onSuccess: () => {
setShouldSeeLogicalDisengage()
placeReaderLid()
closeModal()
},
onError: (error: any) => {
Expand All @@ -204,14 +221,14 @@ function DesktopModal({
<Flex justifyContent={JUSTIFY_FLEX_END}>
<PrimaryButton
onClick={handleClick}
disabled={isEngaged || isResuming || isWaitingForLogicalDisengage}
disabled={isEngaged || isPlacing || isResuming || isWaitingForLogicalDisengage || isWaitingForPlateReaderLidPlacement}
>
<Flex
flexDirection={DIRECTION_ROW}
gridGap={SPACING.spacing8}
alignItems={ALIGN_CENTER}
>
{isResuming || isWaitingForLogicalDisengage ? (
{isResuming || isPlacing || isWaitingForLogicalDisengage || isWaitingForPlateReaderLidPlacement ? (
<Icon size="1rem" spin name="ot-spinner" />
) : null}
{t('resume_robot_operations')}
Expand Down
1 change: 1 addition & 0 deletions app/src/resources/modules/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './useAttachedModules'
export * from './usePlacePlateReaderLid'
46 changes: 0 additions & 46 deletions app/src/resources/modules/hooks/useDropPlateReaderLid.ts

This file was deleted.

49 changes: 49 additions & 0 deletions app/src/resources/modules/hooks/usePlacePlateReaderLid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { useRobotControlCommands } from '/app/resources/maintenance_runs'

import { LabwareLocation, type CreateCommand } from '@opentrons/shared-data'
import type {
UseRobotControlCommandsProps,
UseRobotControlCommandsResult,
} from '/app/resources/maintenance_runs'

interface UsePlacePlateReaderLidResult {
isPlacing: UseRobotControlCommandsResult['isExecuting']
placeReaderLid: UseRobotControlCommandsResult['executeCommands']
}

export type UsePlacePlateReaderLidProps = Pick<
UseRobotControlCommandsProps,
'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 LOAD_PLATE_READER: CreateCommand = {
commandType: 'loadModule' as const,
params: { model: 'absorbanceReaderV1', location: location },
}

const PLACE_READER_LID: CreateCommand = {
commandType: 'unsafe/placeLabware' as const,
params: {
labwareId: labwareId,
location: location,
},
}

const { executeCommands, isExecuting } = useRobotControlCommands({
...props,
commands: [LOAD_PLATE_READER, PLACE_READER_LID],
continuePastCommandFailure: true,
})

return {
isPlacing: isExecuting,
placeReaderLid: executeCommands,
}
}
18 changes: 17 additions & 1 deletion shared-data/command/types/unsafe.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CommonCommandRunTimeInfo, CommonCommandCreateInfo } from '.'
import type { CommonCommandRunTimeInfo, CommonCommandCreateInfo, LabwareLocation } from '.'
import type { MotorAxes } from '../../js/types'

export type UnsafeRunTimeCommand =
Expand All @@ -7,13 +7,15 @@ export type UnsafeRunTimeCommand =
| UnsafeUpdatePositionEstimatorsRunTimeCommand
| UnsafeEngageAxesRunTimeCommand
| UnsafeUngripLabwareRunTimeCommand
| UnsafePlaceLabwareRunTimeCommand

export type UnsafeCreateCommand =
| UnsafeBlowoutInPlaceCreateCommand
| UnsafeDropTipInPlaceCreateCommand
| UnsafeUpdatePositionEstimatorsCreateCommand
| UnsafeEngageAxesCreateCommand
| UnsafeUngripLabwareCreateCommand
| UnsafePlaceLabwareCreateCommand

export interface UnsafeBlowoutInPlaceParams {
pipetteId: string
Expand Down Expand Up @@ -85,3 +87,17 @@ export interface UnsafeUngripLabwareRunTimeCommand
UnsafeUngripLabwareCreateCommand {
result?: any
}
export interface UnsafePlaceLabwareParams {
labwareId: string,
location: LabwareLocation,
}
export interface UnsafePlaceLabwareCreateCommand
extends CommonCommandCreateInfo {
commandType: 'unsafe/placeLabware'
params: UnsafePlaceLabwareParams
}
export interface UnsafePlaceLabwareRunTimeCommand
extends CommonCommandRunTimeInfo,
UnsafePlaceLabwareCreateCommand {
result?: any
}

0 comments on commit c7e8264

Please sign in to comment.