From df16079439363d0640d47aa9fcb8547aa1621e81 Mon Sep 17 00:00:00 2001 From: smb2268 Date: Tue, 15 Oct 2024 13:50:06 -0400 Subject: [PATCH] PLAT-547 command text strings for plate reader commands --- .../en/protocol_command_text.json | 4 ++ .../hooks/useCommandTextString/index.tsx | 12 ++++- .../utils/getAbsorbanceReaderCommandText.ts | 45 +++++++++++++++++++ .../hooks/useCommandTextString/utils/index.ts | 1 + 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 app/src/molecules/Command/hooks/useCommandTextString/utils/getAbsorbanceReaderCommandText.ts diff --git a/app/src/assets/localization/en/protocol_command_text.json b/app/src/assets/localization/en/protocol_command_text.json index c78aef13785..a1d027bb084 100644 --- a/app/src/assets/localization/en/protocol_command_text.json +++ b/app/src/assets/localization/en/protocol_command_text.json @@ -1,4 +1,8 @@ { + "absorbance_reader_open_lid": "Opening Absorbance Reader lid", + "absorbance_reader_close_lid": "Closing Absorbance Reader lid", + "absorbance_reader_initialize": "Initializing Absorbance Reader to perform {{mode}} measurement at {{wavelengths}}", + "absorbance_reader_read": "Reading plate in Absorbance Reader", "adapter_in_mod_in_slot": "{{adapter}} on {{module}} in {{slot}}", "adapter_in_slot": "{{adapter}} in {{slot}}", "aspirate": "Aspirating {{volume}} µL from well {{well_name}} of {{labware}} in {{labware_location}} at {{flow_rate}} µL/sec", diff --git a/app/src/molecules/Command/hooks/useCommandTextString/index.tsx b/app/src/molecules/Command/hooks/useCommandTextString/index.tsx index 1cf39cc0d1f..2cf35994890 100644 --- a/app/src/molecules/Command/hooks/useCommandTextString/index.tsx +++ b/app/src/molecules/Command/hooks/useCommandTextString/index.tsx @@ -127,7 +127,17 @@ export function useCommandTextString( command, }), } - + case 'absorbanceReader/openLid': + case 'absorbanceReader/closeLid': + case 'absorbanceReader/initialize': + case 'absorbanceReader/read': + return { + kind: 'generic', + commandText: utils.getAbsorbanceReaderCommandText({ + ...fullParams, + command, + }), + } case 'thermocycler/runProfile': return utils.getTCRunProfileCommandText({ ...fullParams, command }) diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getAbsorbanceReaderCommandText.ts b/app/src/molecules/Command/hooks/useCommandTextString/utils/getAbsorbanceReaderCommandText.ts new file mode 100644 index 00000000000..bd527c3b57a --- /dev/null +++ b/app/src/molecules/Command/hooks/useCommandTextString/utils/getAbsorbanceReaderCommandText.ts @@ -0,0 +1,45 @@ +import type { + AbsorbanceReaderOpenLidRunTimeCommand, + AbsorbanceReaderCloseLidRunTimeCommand, + AbsorbanceReaderInitializeRunTimeCommand, + AbsorbanceReaderReadRunTimeCommand, + RunTimeCommand, +} from '@opentrons/shared-data' +import type { HandlesCommands } from './types' + +export type AbsorbanceCreateCommand = + | AbsorbanceReaderOpenLidRunTimeCommand + | AbsorbanceReaderCloseLidRunTimeCommand + | AbsorbanceReaderInitializeRunTimeCommand + | AbsorbanceReaderReadRunTimeCommand + +const KEYS_BY_COMMAND_TYPE: { + [commandType in AbsorbanceCreateCommand['commandType']]: string +} = { + 'absorbanceReader/openLid': 'absorbance_reader_open_lid', + 'absorbanceReader/closeLid': 'absorbance_reader_close_lid', + 'absorbanceReader/initialize': 'absorbance_reader_initialize', + 'absorbanceReader/read': 'absorbance_reader_read', +} + +type HandledCommands = Extract< + RunTimeCommand, + { commandType: keyof typeof KEYS_BY_COMMAND_TYPE } +> + +type GetAbsorbanceReaderCommandText = HandlesCommands + +export const getAbsorbanceReaderCommandText = ({ + command, + t, +}: GetAbsorbanceReaderCommandText): string => { + console.log(t(KEYS_BY_COMMAND_TYPE[command.commandType])) + if (command.commandType === 'absorbanceReader/initialize') { + const wavelengths = command.params.sampleWavelengths.join(' nm, ') + ` nm` + return t('absorbance_reader_initialize', { + mode: command.params.measureMode, + wavelengths: wavelengths, + }) + } + return t(KEYS_BY_COMMAND_TYPE[command.commandType]) +} diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/index.ts b/app/src/molecules/Command/hooks/useCommandTextString/utils/index.ts index 590824e558d..76659ca1222 100644 --- a/app/src/molecules/Command/hooks/useCommandTextString/utils/index.ts +++ b/app/src/molecules/Command/hooks/useCommandTextString/utils/index.ts @@ -23,3 +23,4 @@ export { getUnknownCommandText } from './getUnknownCommandText' export { getPipettingCommandText } from './getPipettingCommandText' export { getLiquidProbeCommandText } from './getLiquidProbeCommandText' export { getRailLightsCommandText } from './getRailLightsCommandText' +export { getAbsorbanceReaderCommandText } from './getAbsorbanceReaderCommandText'