Skip to content

Commit

Permalink
resolve circular logic and uptodate ot3 vs flex naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
ncdiehl11 committed Oct 11, 2023
1 parent 0e4e209 commit 83d05f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function ProtocolRunSetup({
const robot = useRobot(robotName)
const calibrationStatusRobot = useRunCalibrationStatus(robotName, runId)
const calibrationStatusModules = useModuleCalibrationStatus(robotName, runId)
const isOT3 = useIsOT3(robotName)
const isFlex = useIsOT3(robotName)
const runHasStarted = useRunHasStarted(runId)
const { analysisErrors } = useProtocolAnalysisErrors(runId)
const [expandedStepKey, setExpandedStepKey] = React.useState<StepKey | null>(
Expand Down Expand Up @@ -135,7 +135,7 @@ export function ProtocolRunSetup({
/>
),
// change description for OT-3
description: isOT3
description: isFlex
? t(`${ROBOT_CALIBRATION_STEP_KEY}_description_pipettes_only`)
: t(`${ROBOT_CALIBRATION_STEP_KEY}_description`),
},
Expand Down Expand Up @@ -236,7 +236,7 @@ export function ProtocolRunSetup({
runHasStarted,
calibrationStatusRobot,
calibrationStatusModules,
isOT3,
isFlex,
}}
/>
}
Expand Down Expand Up @@ -265,22 +265,22 @@ interface StepRightElementProps {
calibrationStatusRobot: ProtocolCalibrationStatus
calibrationStatusModules?: ProtocolCalibrationStatus
runHasStarted: boolean
isOT3: boolean
isFlex: boolean
}
function StepRightElement(props: StepRightElementProps): JSX.Element | null {
const {
stepKey,
runHasStarted,
calibrationStatusRobot,
calibrationStatusModules,
isOT3,
isFlex,
} = props
const { t } = useTranslation('protocol_setup')

if (
!runHasStarted &&
(stepKey === ROBOT_CALIBRATION_STEP_KEY ||
(stepKey === MODULE_SETUP_KEY && isOT3))
(stepKey === MODULE_SETUP_KEY && isFlex))
) {
const calibrationStatus =
stepKey === ROBOT_CALIBRATION_STEP_KEY
Expand Down
22 changes: 11 additions & 11 deletions app/src/organisms/Devices/hooks/useModuleCalibrationStatus.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import {
useIsOT3,
useModuleRenderInfoForProtocolById,
ProtocolCalibrationStatus,
} from '.'
import { useIsOT3 } from './useIsOT3'
import { useModuleRenderInfoForProtocolById } from '.'
import { ProtocolCalibrationStatus } from '.'

export function useModuleCalibrationStatus(
robotName: string,
runId: string
): ProtocolCalibrationStatus {
const isOT3 = useIsOT3(robotName)
const isFlex = useIsOT3(robotName)
const moduleRenderInfoForProtocolById = useModuleRenderInfoForProtocolById(
robotName,
runId
)
// only check module calibration for Flex
if (!isOT3) {
if (!isFlex) {
return { complete: true }
}

const moduleKeys = Object.keys(moduleRenderInfoForProtocolById)
if (moduleKeys.length === 0) {
const moduleInfoKeys = Object.keys(moduleRenderInfoForProtocolById)
if (moduleInfoKeys.length === 0) {
return { complete: true }
}
const moduleData = moduleKeys.map(key => moduleRenderInfoForProtocolById[key])
if (!moduleData.every(m => m.attachedModuleMatch?.moduleOffset != null)) {
const moduleData = moduleInfoKeys.map(
key => moduleRenderInfoForProtocolById[key]
)
if (moduleData.some(m => m.attachedModuleMatch?.moduleOffset == null)) {
return { complete: false, reason: 'calibrate_module_failure_reason' }
} else {
return { complete: true }
Expand Down

0 comments on commit 83d05f2

Please sign in to comment.