Skip to content

Commit

Permalink
feat(app): acknowledge animation when Flex receives a new protocol (#…
Browse files Browse the repository at this point in the history
…13474)

* Add schemaV7 definition for StatusBarAnimation control

* When ODD detects a new protocol, run status bar Confirm animation

* Update app/src/App/hooks.ts typo

Co-authored-by: Jethary Rader <[email protected]>

---------

Co-authored-by: Jethary Rader <[email protected]>
  • Loading branch information
fsinapi and jerader authored Sep 6, 2023
1 parent cc32b4a commit a04c8d0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/src/App/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
useAllRunsQuery,
useHost,
useRunQuery,
useCreateLiveCommandMutation,
} from '@opentrons/react-api-client'
import {
getProtocol,
Expand All @@ -21,6 +22,7 @@ import {
} from '@opentrons/api-client'
import { checkShellUpdate } from '../redux/shell'
import { useToaster } from '../organisms/ToasterOven'
import type { SetStatusBarCreateCommand } from '@opentrons/shared-data/protocol/types/schemaV7/command/incidental'

import type { Dispatch } from '../redux/types'

Expand Down Expand Up @@ -50,6 +52,11 @@ export function useProtocolReceiptToast(): void {
const protocolIds = protocolIdsQuery.data?.data ?? []
const protocolIdsRef = React.useRef(protocolIds)
const hasRefetched = React.useRef(true)
const { createLiveCommand } = useCreateLiveCommandMutation()
const animationCommand: SetStatusBarCreateCommand = {
commandType: 'setStatusBar',
params: { animation: 'confirm' },
}

if (protocolIdsQuery.isRefetching) {
hasRefetched.current = false
Expand Down Expand Up @@ -98,6 +105,13 @@ export function useProtocolReceiptToast(): void {
console.error(`error invalidating protocols query: ${e.message}`)
)
})
.then(() => {
createLiveCommand({
command: animationCommand,
}).catch((e: Error) =>
console.warn(`cannot run status bar animation: ${e.message}`)
)
})
.catch((e: Error) => {
console.error(e)
})
Expand Down
9 changes: 9 additions & 0 deletions shared-data/js/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,12 @@ export interface GripperDefinition {
jawWidth: { min: number; max: number }
}
}

export type StatusBarAnimation =
| 'idle'
| 'confirm'
| 'updating'
| 'disco'
| 'off'

export type StatusBarAnimations = StatusBarAnimation[]
21 changes: 21 additions & 0 deletions shared-data/protocol/types/schemaV7/command/incidental.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { CommonCommandRunTimeInfo, CommonCommandCreateInfo } from '.'
import type { StatusBarAnimation } from '../../../../js/types'

export type IncidentalCreateCommand = SetStatusBarCreateCommand

export type IncidentalRunTimeCommand = SetStatusBarRunTimeCommand

export interface SetStatusBarCreateCommand extends CommonCommandCreateInfo {
commandType: 'setStatusBar'
params: SetStatusBarParams
}

export interface SetStatusBarRunTimeCommand
extends CommonCommandRunTimeInfo,
SetStatusBarCreateCommand {
result?: any
}

interface SetStatusBarParams {
animation: StatusBarAnimation
}
6 changes: 6 additions & 0 deletions shared-data/protocol/types/schemaV7/command/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import type { GantryRunTimeCommand, GantryCreateCommand } from './gantry'
import type { ModuleRunTimeCommand, ModuleCreateCommand } from './module'
import type { SetupRunTimeCommand, SetupCreateCommand } from './setup'
import type { TimingRunTimeCommand, TimingCreateCommand } from './timing'
import type {
IncidentalCreateCommand,
IncidentalRunTimeCommand,
} from './incidental'
import type {
AnnotationRunTimeCommand,
AnnotationCreateCommand,
Expand Down Expand Up @@ -51,6 +55,7 @@ export type CreateCommand =
| TimingCreateCommand // effecting the timing of command execution
| CalibrationCreateCommand // for automatic pipette calibration
| AnnotationCreateCommand // annotating command execution
| IncidentalCreateCommand // command with only incidental effects (status bar animations)

// commands will be required to have a key, but will not be created with one
export type RunTimeCommand =
Expand All @@ -61,6 +66,7 @@ export type RunTimeCommand =
| TimingRunTimeCommand // effecting the timing of command execution
| CalibrationRunTimeCommand // for automatic pipette calibration
| AnnotationRunTimeCommand // annotating command execution
| IncidentalRunTimeCommand // command with only incidental effects (status bar animations)

interface RunCommandError {
id: string
Expand Down

0 comments on commit a04c8d0

Please sign in to comment.