Skip to content

Commit

Permalink
Merge branch 'edge' into RQA-2303-handle-unexpected-mod-fw-name
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj authored Mar 26, 2024
2 parents 0fb8738 + 1b28bab commit c11b186
Show file tree
Hide file tree
Showing 94 changed files with 6,487 additions and 19,052 deletions.
9 changes: 8 additions & 1 deletion app/src/atoms/Chip/Chip.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { Flex, COLORS, SPACING } from '@opentrons/components'
import { Flex, COLORS, ICON_DATA_BY_NAME, SPACING } from '@opentrons/components'
import { touchScreenViewport } from '../../DesignTokens/constants'
import { Chip } from '.'
import type { Story, Meta } from '@storybook/react'
Expand Down Expand Up @@ -27,6 +27,13 @@ export default {
},
defaultValue: 'medium',
},
iconName: {
options: Object.keys(ICON_DATA_BY_NAME),
control: {
type: 'select',
},
defaultValue: 'ot-alert',
},
},
component: Chip,
parameters: touchScreenViewport,
Expand Down
21 changes: 14 additions & 7 deletions app/src/molecules/InstrumentCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react'

import {
ALIGN_FLEX_START,
ALIGN_CENTER,
BORDERS,
Box,
COLORS,
Expand Down Expand Up @@ -80,13 +81,19 @@ export function InstrumentCard(props: InstrumentCardProps): JSX.Element {
</Flex>
) : null}
{instrumentDiagramProps?.pipetteSpecs != null ? (
<InstrumentDiagram
pipetteSpecs={instrumentDiagramProps.pipetteSpecs}
mount={instrumentDiagramProps.mount}
transform="scale(0.3)"
size="3.125rem"
transformOrigin="20% -10%"
/>
<Flex
alignItems={ALIGN_CENTER}
width="3.75rem"
height="3.375rem"
paddingRight={SPACING.spacing8}
>
<InstrumentDiagram
pipetteSpecs={instrumentDiagramProps.pipetteSpecs}
mount={instrumentDiagramProps.mount}
transform="scale(0.3)"
transformOrigin={'-5% 52%'}
/>
</Flex>
) : null}
<Flex
alignItems={ALIGN_FLEX_START}
Expand Down
118 changes: 57 additions & 61 deletions app/src/organisms/Devices/InstrumentsAndModules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react'
import { useTranslation } from 'react-i18next'
import { getPipetteModelSpecs, LEFT, RIGHT } from '@opentrons/shared-data'
import {
useAllPipetteOffsetCalibrationsQuery,
useModulesQuery,
usePipettesQuery,
useInstrumentsQuery,
Expand All @@ -28,10 +27,10 @@ import { ModuleCard } from '../ModuleCard'
import { useIsFlex, useIsRobotViewable, useRunStatuses } from './hooks'
import {
getIs96ChannelPipetteAttached,
getOffsetCalibrationForMount,
getShowPipetteCalibrationWarning,
} from './utils'
import { PipetteCard } from './PipetteCard'
import { FlexPipetteCard } from './PipetteCard/FlexPipetteCard'
import { GripperCard } from '../GripperCard'
import { useIsEstopNotDisengaged } from '../../resources/devices/hooks/useIsEstopNotDisengaged'

Expand All @@ -43,7 +42,6 @@ import type {
} from '@opentrons/api-client'

const EQUIPMENT_POLL_MS = 5000
const FETCH_PIPETTE_CAL_POLL = 30000
interface InstrumentsAndModulesProps {
robotName: string
}
Expand All @@ -52,20 +50,22 @@ export function InstrumentsAndModules({
robotName,
}: InstrumentsAndModulesProps): JSX.Element | null {
const { t } = useTranslation(['device_details', 'shared'])
const isFlex = useIsFlex(robotName)
const attachedPipettes = usePipettesQuery(
{},
{
refetchInterval: EQUIPMENT_POLL_MS,
enabled: !isFlex,
}
)?.data ?? { left: undefined, right: undefined }
const isRobotViewable = useIsRobotViewable(robotName)
const currentRunId = useCurrentRunId()
const { isRunTerminal, isRunRunning } = useRunStatuses()
const isFlex = useIsFlex(robotName)
const isEstopNotDisengaged = useIsEstopNotDisengaged(robotName)

const { data: attachedInstruments } = useInstrumentsQuery({
refetchInterval: EQUIPMENT_POLL_MS,
enabled: isFlex,
})

const attachedGripper =
Expand Down Expand Up @@ -120,26 +120,6 @@ export function InstrumentsAndModules({
const leftColumnModules = attachedModules?.slice(0, halfAttachedModulesSize)
const rightColumnModules = attachedModules?.slice(halfAttachedModulesSize)

// The following pipetteOffset related code has been lifted out of the PipetteCard component
// to eliminate duplicated useInterval calls to `calibration/pipette_offset` coming from each card.
// Instead we now capture all offset calibration data here, and pass the appropriate calibration
// data to the associated card via props
const pipetteOffsetCalibrations =
useAllPipetteOffsetCalibrationsQuery({
refetchInterval: FETCH_PIPETTE_CAL_POLL,
enabled: !isFlex,
})?.data?.data ?? []
const leftMountOffsetCalibration = getOffsetCalibrationForMount(
pipetteOffsetCalibrations,
attachedPipettes,
LEFT
)
const rightMountOffsetCalibration = getOffsetCalibrationForMount(
pipetteOffsetCalibrations,
attachedPipettes,
RIGHT
)

return (
<Flex
alignItems={ALIGN_FLEX_START}
Expand Down Expand Up @@ -186,37 +166,46 @@ export function InstrumentsAndModules({
flexDirection={DIRECTION_COLUMN}
gridGap={SPACING.spacing8}
>
<PipetteCard
pipetteId={attachedPipettes.left?.id}
pipetteModelSpecs={
attachedPipettes.left?.model != null
? getPipetteModelSpecs(attachedPipettes.left?.model) ?? null
: null
}
isPipetteCalibrated={
isFlex && attachedLeftPipette?.ok
? attachedLeftPipette?.data?.calibratedOffset
?.last_modified != null
: leftMountOffsetCalibration != null
}
mount={LEFT}
robotName={robotName}
pipetteIs96Channel={is96ChannelAttached}
pipetteIsBad={badLeftPipette != null}
isRunActive={currentRunId != null && isRunRunning}
isEstopNotDisengaged={isEstopNotDisengaged}
/>
{isFlex && (
<GripperCard
attachedGripper={attachedGripper}
isCalibrated={
attachedGripper?.ok === true &&
attachedGripper?.data?.calibratedOffset?.last_modified !=
null
{!isFlex ? (
<PipetteCard
pipetteId={attachedPipettes.left?.id}
pipetteModelSpecs={
attachedPipettes.left?.model != null
? getPipetteModelSpecs(attachedPipettes.left?.model) ??
null
: null
}
mount={LEFT}
robotName={robotName}
isRunActive={currentRunId != null && isRunRunning}
isEstopNotDisengaged={isEstopNotDisengaged}
/>
) : (
<>
<FlexPipetteCard
attachedPipette={attachedLeftPipette}
pipetteModelSpecs={
attachedLeftPipette?.instrumentModel != null
? getPipetteModelSpecs(
attachedLeftPipette.instrumentModel
) ?? null
: null
}
mount={LEFT}
isRunActive={currentRunId != null && isRunRunning}
isEstopNotDisengaged={isEstopNotDisengaged}
/>
<GripperCard
attachedGripper={attachedGripper}
isCalibrated={
attachedGripper?.ok === true &&
attachedGripper?.data?.calibratedOffset?.last_modified !=
null
}
isRunActive={currentRunId != null && isRunRunning}
isEstopNotDisengaged={isEstopNotDisengaged}
/>
</>
)}
{leftColumnModules.map((module, index) => (
<ModuleCard
Expand All @@ -237,7 +226,7 @@ export function InstrumentsAndModules({
flexDirection={DIRECTION_COLUMN}
gridGap={SPACING.spacing8}
>
{!Boolean(is96ChannelAttached) && (
{!isFlex ? (
<PipetteCard
pipetteId={attachedPipettes.right?.id}
pipetteModelSpecs={
Expand All @@ -246,20 +235,27 @@ export function InstrumentsAndModules({
null
: null
}
isPipetteCalibrated={
isFlex && attachedRightPipette?.ok
? attachedRightPipette?.data?.calibratedOffset
?.last_modified != null
: rightMountOffsetCalibration != null
}
mount={RIGHT}
robotName={robotName}
pipetteIs96Channel={false}
pipetteIsBad={badRightPipette != null}
isRunActive={currentRunId != null && isRunRunning}
isEstopNotDisengaged={isEstopNotDisengaged}
/>
)}
) : null}
{isFlex && !is96ChannelAttached ? (
<FlexPipetteCard
attachedPipette={attachedRightPipette}
pipetteModelSpecs={
attachedRightPipette?.instrumentModel != null
? getPipetteModelSpecs(
attachedRightPipette.instrumentModel
) ?? null
: null
}
mount={RIGHT}
isRunActive={currentRunId != null && isRunRunning}
isEstopNotDisengaged={isEstopNotDisengaged}
/>
) : null}
{rightColumnModules.map((module, index) => (
<ModuleCard
key={`moduleCard_${String(module.moduleType)}_${String(
Expand Down
24 changes: 11 additions & 13 deletions app/src/organisms/Devices/PipetteCard/AboutPipetteSlideout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,30 @@ import {
StyledText,
TYPOGRAPHY,
} from '@opentrons/components'
import { useInstrumentsQuery } from '@opentrons/react-api-client'
import { Slideout } from '../../../atoms/Slideout'

import type { AttachedPipette } from '../../../redux/pipettes/types'
import type { PipetteData } from '@opentrons/api-client'
import type { PipetteModelSpecs, PipetteMount } from '@opentrons/shared-data'
import type { PipetteModelSpecs } from '@opentrons/shared-data'

interface AboutPipetteSlideoutProps {
pipetteId: AttachedPipette['id']
pipetteName: PipetteModelSpecs['displayName']
mount: PipetteMount
firmwareVersion?: string
onCloseClick: () => unknown
isExpanded: boolean
}

export const AboutPipetteSlideout = (
props: AboutPipetteSlideoutProps
): JSX.Element | null => {
const { pipetteId, pipetteName, isExpanded, mount, onCloseClick } = props
const {
pipetteId,
pipetteName,
isExpanded,
firmwareVersion,
onCloseClick,
} = props
const { i18n, t } = useTranslation(['device_details', 'shared'])
const { data: attachedInstruments } = useInstrumentsQuery()
const instrumentInfo =
attachedInstruments?.data?.find(
(i): i is PipetteData =>
i.instrumentType === 'pipette' && i.ok && i.mount === mount
) ?? null

return (
<Slideout
Expand All @@ -52,7 +50,7 @@ export const AboutPipetteSlideout = (
}
>
<Flex flexDirection={DIRECTION_COLUMN}>
{instrumentInfo?.firmwareVersion != null && (
{firmwareVersion != null && (
<>
<StyledText
as="h6"
Expand All @@ -66,7 +64,7 @@ export const AboutPipetteSlideout = (
paddingTop={SPACING.spacing4}
paddingBottom={SPACING.spacing16}
>
{instrumentInfo.firmwareVersion}
{firmwareVersion}
</StyledText>
</>
)}
Expand Down
Loading

0 comments on commit c11b186

Please sign in to comment.