From b46305ff43514cbcfac992bb312b698d0c0f252c Mon Sep 17 00:00:00 2001 From: Jamey Huffnagle Date: Fri, 19 Jul 2024 16:24:32 -0400 Subject: [PATCH] feat(app, shared-data): Add liquidProbe and tryLiquidProbe command text (#15722) Closes EXEC-567 --- .../en/protocol_command_text.json | 1 + .../__fixtures__/mockRobotSideAnalysis.json | 40 +++++++++++++ .../Command/__tests__/CommandText.test.tsx | 40 +++++++++++++ .../hooks/useCommandTextString/index.tsx | 9 +++ .../utils/getLiquidProbeCommandText.ts | 60 +++++++++++++++++++ .../hooks/useCommandTextString/utils/index.ts | 1 + shared-data/command/types/pipetting.ts | 12 ++++ 7 files changed, 163 insertions(+) create mode 100644 app/src/molecules/Command/hooks/useCommandTextString/utils/getLiquidProbeCommandText.ts diff --git a/app/src/assets/localization/en/protocol_command_text.json b/app/src/assets/localization/en/protocol_command_text.json index 23b2285bbcc..484ec67124a 100644 --- a/app/src/assets/localization/en/protocol_command_text.json +++ b/app/src/assets/localization/en/protocol_command_text.json @@ -16,6 +16,7 @@ "deactivating_tc_block": "Deactivating Thermocycler block", "deactivating_tc_lid": "Deactivating Thermocycler lid", "degrees_c": "{{temp}}°C", + "detect_liquid_presence": "Detecting liquid presence in well {{well_name}} of {{labware}} in {{labware_location}}", "disengaging_magnetic_module": "Disengaging Magnetic Module", "dispense": "Dispensing {{volume}} µL into well {{well_name}} of {{labware}} in {{labware_location}} at {{flow_rate}} µL/sec", "dispense_in_place": "Dispensing {{volume}} µL in place at {{flow_rate}} µL/sec", diff --git a/app/src/molecules/Command/__fixtures__/mockRobotSideAnalysis.json b/app/src/molecules/Command/__fixtures__/mockRobotSideAnalysis.json index 0f084ae89b6..b4a041b36f9 100644 --- a/app/src/molecules/Command/__fixtures__/mockRobotSideAnalysis.json +++ b/app/src/molecules/Command/__fixtures__/mockRobotSideAnalysis.json @@ -6391,6 +6391,46 @@ "addressableAreaName": "D3", "offset": { "x": 0, "y": 0, "z": 0 } } + }, + { + "id": "84f7af1d-c097-4d4b-9819-ad56479bbbb8", + "createdAt": "2023-01-31T21:53:04.965216+00:00", + "commandType": "liquidProbe", + "key": "1248111104", + "status": "succeeded", + "params": { + "labwareId": "b2a40c9d-31b0-4f27-ad4a-c92ced91204d", + "wellName": "A1", + "wellLocation": { + "origin": "top", + "offset": { + "x": 0, + "y": 0, + "z": 0 + } + }, + "pipetteId": "f6d1c83c-9d1b-4d0d-9de3-e6d649739cfb" + } + }, + { + "id": "84f7af1d-c097-4d4b-9819-ad56479bbbb8", + "createdAt": "2023-01-31T21:53:04.965216+00:00", + "commandType": "tryLiquidProbe", + "key": "1248111104", + "status": "succeeded", + "params": { + "labwareId": "b2a40c9d-31b0-4f27-ad4a-c92ced91204d", + "wellName": "A1", + "wellLocation": { + "origin": "top", + "offset": { + "x": 0, + "y": 0, + "z": 0 + } + }, + "pipetteId": "f6d1c83c-9d1b-4d0d-9de3-e6d649739cfb" + } } ], "errors": [], diff --git a/app/src/molecules/Command/__tests__/CommandText.test.tsx b/app/src/molecules/Command/__tests__/CommandText.test.tsx index 132105ecc44..9226f258830 100644 --- a/app/src/molecules/Command/__tests__/CommandText.test.tsx +++ b/app/src/molecules/Command/__tests__/CommandText.test.tsx @@ -1401,4 +1401,44 @@ describe('CommandText', () => { 'Moving NEST 96 Well Plate 100 µL PCR Full Skirt (1) using gripper from Magnetic Module GEN2 in Slot 1 to Magnetic Module GEN2 in Slot 1' ) }) + + it('renders correct text for liquidProbe', () => { + const command = mockCommandTextData.commands.find( + c => c.commandType === 'liquidProbe' + ) + expect(command).not.toBeUndefined() + if (command != null) { + renderWithProviders( + , + { i18nInstance: i18n } + ) + screen.getByText( + 'Detecting liquid presence in well A1 of Opentrons 96 Tip Rack 300 µL in Slot 9' + ) + } + }) + + it('renders correct text for tryLiquidProbe', () => { + const command = mockCommandTextData.commands.find( + c => c.commandType === 'tryLiquidProbe' + ) + expect(command).not.toBeUndefined() + if (command != null) { + renderWithProviders( + , + { i18nInstance: i18n } + ) + screen.getByText( + 'Detecting liquid presence in well A1 of Opentrons 96 Tip Rack 300 µL in Slot 9' + ) + } + }) }) diff --git a/app/src/molecules/Command/hooks/useCommandTextString/index.tsx b/app/src/molecules/Command/hooks/useCommandTextString/index.tsx index 157e7035f27..34df2f33c7f 100644 --- a/app/src/molecules/Command/hooks/useCommandTextString/index.tsx +++ b/app/src/molecules/Command/hooks/useCommandTextString/index.tsx @@ -78,6 +78,15 @@ export function useCommandTextString( commandText: utils.getLoadCommandText(fullParams), } + case 'liquidProbe': + case 'tryLiquidProbe': + return { + commandText: utils.getLiquidProbeCommandText({ + ...fullParams, + command, + }), + } + case 'temperatureModule/setTargetTemperature': case 'temperatureModule/waitForTemperature': case 'thermocycler/setTargetBlockTemperature': diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getLiquidProbeCommandText.ts b/app/src/molecules/Command/hooks/useCommandTextString/utils/getLiquidProbeCommandText.ts new file mode 100644 index 00000000000..a61a4bdf2a3 --- /dev/null +++ b/app/src/molecules/Command/hooks/useCommandTextString/utils/getLiquidProbeCommandText.ts @@ -0,0 +1,60 @@ +import { + getFinalLabwareLocation, + getLabwareDisplayLocation, + getLabwareName, +} from '../../../utils' + +import type { + LiquidProbeRunTimeCommand, + RunTimeCommand, + TryLiquidProbeRunTimeCommand, +} from '@opentrons/shared-data' +import type { HandlesCommands } from './types' +import type { TFunction } from 'i18next' + +type LiquidProbeRunTimeCommands = + | LiquidProbeRunTimeCommand + | TryLiquidProbeRunTimeCommand + +export function getLiquidProbeCommandText({ + command, + commandTextData, + t, + robotType, +}: HandlesCommands): string { + const { wellName, labwareId } = command.params + + const allPreviousCommands = commandTextData?.commands.slice( + 0, + commandTextData.commands.findIndex(c => c.id === command?.id) + ) + + const labwareLocation = + allPreviousCommands != null + ? getFinalLabwareLocation( + labwareId as string, + allPreviousCommands as RunTimeCommand[] + ) + : null + + const displayLocation = + labwareLocation != null && commandTextData != null + ? getLabwareDisplayLocation( + commandTextData, + labwareLocation, + t as TFunction, + robotType + ) + : '' + + const labware = + commandTextData != null + ? getLabwareName(commandTextData, labwareId as string) + : null + + return t('detect_liquid_presence', { + labware, + labware_location: displayLocation, + well_name: wellName, + }) +} diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/index.ts b/app/src/molecules/Command/hooks/useCommandTextString/utils/index.ts index b937e28066d..f7946ff1e47 100644 --- a/app/src/molecules/Command/hooks/useCommandTextString/utils/index.ts +++ b/app/src/molecules/Command/hooks/useCommandTextString/utils/index.ts @@ -20,3 +20,4 @@ export { getCommentCommandText } from './getCommentCommandText' export { getCustomCommandText } from './getCustomCommandText' export { getUnknownCommandText } from './getUnknownCommandText' export { getPipettingCommandText } from './getPipettingCommandText' +export { getLiquidProbeCommandText } from './getLiquidProbeCommandText' diff --git a/shared-data/command/types/pipetting.ts b/shared-data/command/types/pipetting.ts index 73daf7df1f0..7c4c46ef487 100644 --- a/shared-data/command/types/pipetting.ts +++ b/shared-data/command/types/pipetting.ts @@ -18,6 +18,7 @@ export type PipettingRunTimeCommand = | TouchTipRunTimeCommand | VerifyTipPresenceRunTimeCommand | LiquidProbeRunTimeCommand + | TryLiquidProbeRunTimeCommand export type PipettingCreateCommand = | AspirateCreateCommand @@ -36,6 +37,7 @@ export type PipettingCreateCommand = | TouchTipCreateCommand | VerifyTipPresenceCreateCommand | LiquidProbeCreateCommand + | TryLiquidProbeCreateCommand export interface ConfigureForVolumeCreateCommand extends CommonCommandCreateInfo { @@ -206,6 +208,16 @@ export interface LiquidProbeRunTimeCommand result?: Record } +export interface TryLiquidProbeCreateCommand extends CommonCommandCreateInfo { + commandType: 'tryLiquidProbe' + params: WellLocationParam & PipetteAccessParams +} +export interface TryLiquidProbeRunTimeCommand + extends CommonCommandRunTimeInfo, + TryLiquidProbeCreateCommand { + result?: Record +} + export type AspDispAirgapParams = FlowRateParams & PipetteAccessParams & VolumeParams &