Skip to content

Commit

Permalink
fix(app): render "using current calibration" banner when cancelling O…
Browse files Browse the repository at this point in the history
…T-2 deck recalibration (#13642)

Closes RQA-1324
  • Loading branch information
mjhuff authored and sfoster1 committed Sep 28, 2023
1 parent b177328 commit 1665a9a
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 21 deletions.
29 changes: 15 additions & 14 deletions app/src/assets/localization/en/robot_calibration.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"attached_pipettes": "attached pipette calibrations",
"before_you_begin": "Before you begin",
"calibrate": "Calibrate",
"calibrate_deck": "calibrate deck",
"calibrate_pipette": "Calibrate pipette",
"calibrate_tip_length": "Calibrate the length of a tip on this pipette.",
Expand All @@ -10,17 +11,17 @@
"calibrate_z_axis_on_block": "Calibrate z-axis on block",
"calibrate_z_axis_on_slot": "Calibrate z-axis in slot 5",
"calibrate_z_axis_on_trash": "Calibrate z-axis on trash bin",
"calibrate": "Calibrate",
"calibration_block_description": "<block>This block is a specially made tool that fits perfectly on your deck and helps with calibration.</block><block>If you do not have a Calibration Block, please email <supportLink>[email protected]</supportLink> so we can send you one. In your message, be sure to include your name, company or institution name, and shipping address. While you wait for the block to arrive, you can use the flat surface on the trash bin of your robot instead.</block>",
"calibration_complete": "Calibration complete",
"calibration_dashboard": "Calibration Dashboard",
"calibration_health_check": "Calibration Health Check",
"calibration_health_check_intro_body": "<block>Calibration Health Check diagnoses problems with Deck, Tip Length, and Pipette Offset Calibration.</block><block>You will move the pipettes to various positions, which will be compared against your existing calibration data.</block><block>If there is a large difference, you will be prompted to redo some or all of your calibrations.</block>",
"calibration_health_check_results": "Calibration Health Check Results",
"calibration_health_check": "Calibration Health Check",
"calibration_on_opentrons_tips_is_important": "It’s extremely important to perform this calibration using the Opentrons tips and tip racks specified above, as the robot determines accuracy based on the known measurements of these tips.",
"calibration_recommended": "Calibration recommended",
"calibration_status_description": "For accurate and precise movement, calibrate the robot's deck, pipette offsets, and tip lengths.",
"calibration_status": "Calibration Status",
"calibration_status_description": "For accurate and precise movement, calibrate the robot's deck, pipette offsets, and tip lengths.",
"calibrations_aborted": "Using current calibrations.",
"calibrations_complete": "Calibrations complete!",
"change_tip_rack": "Change tip rack",
"check_tip_on_block": "Check tip on block",
Expand All @@ -36,24 +37,24 @@
"confirm_placement": "Confirm placement",
"confirm_tip_rack": "Confirm tip rack",
"custom": "custom",
"deck_calibration": "Deck Calibration",
"deck_calibration_description": "Calibrate the position of the robot's deck. Recommended for all new robots and after moving robots.",
"deck_calibration_error_occurred": "An error occurred while trying to start deck calibration",
"deck_calibration_failure": "Failed to start deck calibration",
"deck_calibration_intro_body": "Deck calibration ensures positional accuracy so that your robot moves as expected. It will accurately establish the OT-2’s deck orientation relative to the gantry.",
"deck_calibration_missing": "You haven't calibrated the deck yet",
"deck_calibration_redo": "recalibrate deck",
"deck_calibration_spinner": "Deck calibration is {{ongoing_action}}",
"deck_calibration": "Deck Calibration",
"deck_invalidates_pipette_offset": "Recalibrating the deck clears pipette offset data",
"definition": "Your OT-2 moves pipettes around in 3D space based on its calibration. <a>Learn more</a> about how calibration works on the OT-2.",
"delete_calibration_data": "Delete calibration data",
"did_pipette_pick_up_tip": "Did pipette pick up tip successfully?",
"direction_controls": "direction controls",
"do_you_have_a_cal_block": "Do you have a Calibration Block?",
"download_calibration": "Download your calibration data",
"download_calibration_data_available": "Save all three types of calibration data as a JSON file.",
"download_calibration_data_unavailable": "No calibration data available.",
"download_calibration_title": "Download Calibration Data",
"download_calibration": "Download your calibration data",
"download_details": "Download details JSON Calibration Check summary",
"finish": "Finish",
"get_started": "Get started",
Expand All @@ -76,21 +77,21 @@
"last_calibrated": "Last calibrated",
"last_completed_on": "Last completed {{timestamp}}",
"last_migrated": "Last known calibration migrated",
"launch_calibration_link_text": "Go to calibration",
"launch_calibration": "Launch calibration",
"launch_calibration_link_text": "Go to calibration",
"manage_pipettes": "manage pipettes",
"missing_calibration_data_long": "Robot is missing calibration data",
"missing_calibration_data": "Missing calibration data",
"missing_calibration_data_long": "Robot is missing calibration data",
"need_help": "Need help?",
"no_pipette": "No pipette attached",
"no_tip_length": "Calibrate your pipette to see saved tip length",
"opentrons_tip_racks_recommended": "Opentrons tip racks are highly recommended. Accuracy cannot be guaranteed with other tip racks.",
"opentrons": "opentrons",
"opentrons_tip_racks_recommended": "Opentrons tip racks are highly recommended. Accuracy cannot be guaranteed with other tip racks.",
"pick_up_tip": "Pick up tip",
"pipette_name_and_serial": "{{name}}, {{serial}}",
"pipette_offset_calibration": "Pipette Offset Calibration",
"pipette_offset_calibration_intro_body": "Calibrating pipette offset measures a pipette’s position relative to the pipette mount and the deck.",
"pipette_offset_calibration_on_mount": "Calibrate this pipette's offset while attached to the robot's {{mount}} mount.",
"pipette_offset_calibration": "Pipette Offset Calibration",
"pipette_offset_description": "Calibrate the position for the the default tip and pipette combination.",
"pipette_offset_recalibrate_both_mounts": "Pipette offsets for both mounts will have to be recalibrated.",
"pipette_offset_requires_tip_length": "You don’t have a tip length saved with this pipette yet. You will need to calibrate tip length before calibrating your pipette offset.",
Expand All @@ -100,29 +101,29 @@
"position_pipette_over_tip": "Position pipette over A1",
"prepare_the_space": "Prepare the space",
"progress_will_be_lost": "{{sessionType}} progress will be lost",
"recalibrate": "Recalibrate",
"recalibrate_pipette": "Recalibrate pipette",
"recalibrate_warning_body": "Performing a deck calibration will clear all of your pipette offset and tip length calibrations. You will need to recalibrate your pipette offset and tip length after completing a deck calibration.",
"recalibrate_warning_heading": "Are you sure you want to recalibrate your deck?",
"recalibrate": "Recalibrate",
"recalibration_recommended": "Recalibration recommended",
"return_tip": "Return tip",
"return_tip_and_continue": "Return tip and continue to next pipette",
"return_tip_and_exit": "Return tip and see calibration health check results",
"return_tip": "Return tip",
"see_how_robot_calibration_works": "See how robot calibration works",
"select_tip_rack": "select tip rack",
"serial_number": "Serial number",
"small": "Small",
"start_over_question": "Start over?",
"start_over": "Start over",
"start_over_question": "Start over?",
"start_with_deck_calibration": "Start with Deck Calibration, which is the basis for the rest of calibration.",
"starting_over_loses_progress": "Starting over will cancel your calibration progress.",
"this_is_the_tip_used_in_pipette_offset_cal": "Please note: You must use the same tips you used in Pipette Offset Calibration, which are listed above.",
"tiny": "Tiny",
"tip_length": "tip length calibration",
"tip_length_and_pipette_offset_calibration": "Tip Length and Pipette Offset Calibration",
"tip_length_calibration_intro_body": "Tip length calibration measures the distance between the bottom of the tip and the pipette’s nozzle.",
"tip_length_calibration": "Tip Length Calibration",
"tip_length_calibration_intro_body": "Tip length calibration measures the distance between the bottom of the tip and the pipette’s nozzle.",
"tip_length_invalidates_pipette_offset": "Recalibrating tip length will clear pipette offset data.",
"tip_length": "tip length calibration",
"tip_pick_up_instructions": "<block>Using the controls below or your keyboard, jog the pipette until the nozzle closest to you is centered above the A1 position and level with the top of the tip.</block><br/><block>When the pipette is properly aligned, pick up the tip.</block>",
"title": "robot calibration",
"to_check": "To check the {{mount}} pipette:",
Expand Down
4 changes: 4 additions & 0 deletions app/src/organisms/CalibrateDeck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export function CalibrateDeck(
dispatchRequests,
showSpinner,
isJogging,
wasExitBeforeCompletion,
offsetInvalidationHandler,
} = props
const { currentStep, instrument, labware, supportedCommands } =
Expand Down Expand Up @@ -96,6 +97,9 @@ export function CalibrateDeck(
}

function cleanUpAndExit(): void {
if (wasExitBeforeCompletion) {
wasExitBeforeCompletion.current = true
}
if (session?.id) {
dispatchRequests(
Sessions.createSessionCommand(robotName, session.id, {
Expand Down
5 changes: 3 additions & 2 deletions app/src/organisms/CalibrateDeck/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { DeckCalibrationSession } from '../../redux/sessions/types'
import { DispatchRequestsType } from '../../redux/robot-api'

import type { MutableRefObject } from 'react'
import type { DeckCalibrationSession } from '../../redux/sessions/types'
export interface CalibrateDeckParentProps {
robotName: string
session: DeckCalibrationSession | null
dispatchRequests: DispatchRequestsType
showSpinner: boolean
isJogging: boolean
wasExitBeforeCompletion?: MutableRefObject<boolean>
offsetInvalidationHandler?: () => void
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const render = (robotName: string = 'otie') => {
pipOffsetCalLauncher={mockPipOffsetCalLauncher}
tipLengthCalLauncher={mockTipLengthCalLauncher}
deckCalLauncher={mockDeckCalLauncher}
wasExitBeforeCompletion={false}
/>
</StaticRouter>,
{
Expand Down Expand Up @@ -93,6 +94,7 @@ describe('CalibrationTaskList', () => {
pipOffsetCalLauncher={mockPipOffsetCalLauncher}
tipLengthCalLauncher={mockTipLengthCalLauncher}
deckCalLauncher={mockDeckCalLauncher}
wasExitBeforeCompletion={false}
/>
</StaticRouter>
)
Expand All @@ -118,6 +120,7 @@ describe('CalibrationTaskList', () => {
pipOffsetCalLauncher={mockPipOffsetCalLauncher}
tipLengthCalLauncher={mockTipLengthCalLauncher}
deckCalLauncher={mockDeckCalLauncher}
wasExitBeforeCompletion={false}
/>
</StaticRouter>
)
Expand All @@ -142,6 +145,7 @@ describe('CalibrationTaskList', () => {
pipOffsetCalLauncher={mockPipOffsetCalLauncher}
tipLengthCalLauncher={mockTipLengthCalLauncher}
deckCalLauncher={mockDeckCalLauncher}
wasExitBeforeCompletion={false}
/>
</StaticRouter>
)
Expand All @@ -166,6 +170,7 @@ describe('CalibrationTaskList', () => {
pipOffsetCalLauncher={mockPipOffsetCalLauncher}
tipLengthCalLauncher={mockTipLengthCalLauncher}
deckCalLauncher={mockDeckCalLauncher}
wasExitBeforeCompletion={false}
/>
</StaticRouter>
)
Expand All @@ -189,6 +194,7 @@ describe('CalibrationTaskList', () => {
pipOffsetCalLauncher={mockPipOffsetCalLauncher}
tipLengthCalLauncher={mockTipLengthCalLauncher}
deckCalLauncher={mockDeckCalLauncher}
wasExitBeforeCompletion={false}
/>
</StaticRouter>
)
Expand All @@ -212,12 +218,35 @@ describe('CalibrationTaskList', () => {
pipOffsetCalLauncher={mockPipOffsetCalLauncher}
tipLengthCalLauncher={mockTipLengthCalLauncher}
deckCalLauncher={mockDeckCalLauncher}
wasExitBeforeCompletion={false}
/>
</StaticRouter>
)
expect(getByText('Calibrations complete!')).toBeTruthy()
})

it('exiting a recalibrate wizard from a task will allow the current calibrations screen to show', () => {
mockUseCalibrationTaskList.mockReturnValueOnce(
expectedIncompleteRightMountTaskList
)

const [{ getByText, rerender }] = render()
const recalibrateLink = getByText('Recalibrate')
recalibrateLink.click()
rerender(
<StaticRouter>
<CalibrationTaskList
robotName={'otie'}
pipOffsetCalLauncher={mockPipOffsetCalLauncher}
tipLengthCalLauncher={mockTipLengthCalLauncher}
deckCalLauncher={mockDeckCalLauncher}
wasExitBeforeCompletion={true}
/>
</StaticRouter>
)
expect(getByText('Using current calibrations.')).toBeTruthy()
})

it('prevents the user from launching calibrations or recalibrations from a task when a protocol run is active', () => {
mockUseCalibrationTaskList.mockReturnValueOnce(
expectedIncompleteDeckCalTaskList
Expand All @@ -236,6 +265,7 @@ describe('CalibrationTaskList', () => {
pipOffsetCalLauncher={mockPipOffsetCalLauncher}
tipLengthCalLauncher={mockTipLengthCalLauncher}
deckCalLauncher={mockDeckCalLauncher}
wasExitBeforeCompletion={false}
/>
</StaticRouter>
)
Expand Down Expand Up @@ -263,6 +293,7 @@ describe('CalibrationTaskList', () => {
pipOffsetCalLauncher={mockPipOffsetCalLauncher}
tipLengthCalLauncher={mockTipLengthCalLauncher}
deckCalLauncher={mockDeckCalLauncher}
wasExitBeforeCompletion={false}
/>
</StaticRouter>
)
Expand Down
12 changes: 10 additions & 2 deletions app/src/organisms/CalibrationTaskList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ interface CalibrationTaskListProps {
pipOffsetCalLauncher: DashboardCalOffsetInvoker
tipLengthCalLauncher: DashboardCalTipLengthInvoker
deckCalLauncher: DashboardCalDeckInvoker
wasExitBeforeCompletion: boolean
}

export function CalibrationTaskList({
robotName,
pipOffsetCalLauncher,
tipLengthCalLauncher,
deckCalLauncher,
wasExitBeforeCompletion,
}: CalibrationTaskListProps): JSX.Element {
const prevActiveIndex = React.useRef<[number, number] | null>(null)
const [hasLaunchedWizard, setHasLaunchedWizard] = React.useState<boolean>(
Expand Down Expand Up @@ -125,9 +127,15 @@ export function CalibrationTaskList({
justifyContent={JUSTIFY_CENTER}
alignItems={ALIGN_CENTER}
>
<Icon name="ot-check" size="3rem" color={COLORS.successEnabled} />
{wasExitBeforeCompletion ? (
<Icon name="ot-alert" size="3rem" color={COLORS.warningEnabled} />
) : (
<Icon name="ot-check" size="3rem" color={COLORS.successEnabled} />
)}
<StyledText as="h1" marginTop={SPACING.spacing24}>
{t('calibrations_complete')}
{wasExitBeforeCompletion
? t('calibrations_aborted')
: t('calibrations_complete')}
</StyledText>
<PrimaryButton
marginTop={SPACING.spacing24}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('CalibrationDashboard', () => {
mockUseCalibrationTaskList.mockReturnValue(expectedTaskList)
mockUseDashboardCalibratePipOffset.mockReturnValue([() => {}, null])
mockUseDashboardCalibrateTipLength.mockReturnValue([() => {}, null])
mockUseDashboardCalibrateDeck.mockReturnValue([() => {}, null])
mockUseDashboardCalibrateDeck.mockReturnValue([() => {}, null, false])
mockUseAttachedPipettes.mockReturnValue({
left: mockLeftProtoPipette,
right: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ export type DashboardCalDeckInvoker = (

export function useDashboardCalibrateDeck(
robotName: string
): [DashboardCalDeckInvoker, JSX.Element | null] {
): [DashboardCalDeckInvoker, JSX.Element | null, boolean] {
const trackedRequestId = React.useRef<string | null>(null)
const createRequestId = React.useRef<string | null>(null)
const jogRequestId = React.useRef<string | null>(null)
const wasExitBeforeCompletion = React.useRef<boolean>(false)
const invalidateHandlerRef = React.useRef<(() => void) | undefined>()
const { t } = useTranslation('robot_calibration')

Expand Down Expand Up @@ -118,6 +119,7 @@ export function useDashboardCalibrateDeck(
showSpinner={showSpinner}
dispatchRequests={dispatchRequests}
isJogging={isJogging}
wasExitBeforeCompletion={wasExitBeforeCompletion}
offsetInvalidationHandler={invalidateHandlerRef.current}
/>
)}
Expand All @@ -126,5 +128,9 @@ export function useDashboardCalibrateDeck(

if (!(startingSession || deckCalSession != null)) Wizard = null

return [handleStartDashboardDeckCalSession, Wizard]
return [
handleStartDashboardDeckCalSession,
Wizard,
wasExitBeforeCompletion.current,
]
}
2 changes: 2 additions & 0 deletions app/src/pages/Devices/CalibrationDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function CalibrationDashboard(): JSX.Element {
const [
dashboardDeckCalLauncher,
DashboardDeckCalWizard,
wasExitBeforeCompletion,
] = useDashboardCalibrateDeck(robotName)
return (
<ApiHostProvider
Expand All @@ -37,6 +38,7 @@ export function CalibrationDashboard(): JSX.Element {
deckCalLauncher={dashboardDeckCalLauncher}
tipLengthCalLauncher={dashboardTipLengthCalLauncher}
pipOffsetCalLauncher={dashboardOffsetCalLauncher}
wasExitBeforeCompletion={wasExitBeforeCompletion}
/>
{DashboardDeckCalWizard}
{DashboardOffsetCalWizard}
Expand Down

0 comments on commit 1665a9a

Please sign in to comment.