Skip to content

Commit

Permalink
Merge branch 'edge' into RLIQ-69-hardware-control-liquid-sense
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj committed Feb 17, 2023
2 parents 90ebf12 + b422488 commit cd41b39
Show file tree
Hide file tree
Showing 706 changed files with 68,358 additions and 29,256 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
root: true,

parserOptions: {
project: './tsconfig-eslint.json',
project: require('path').join(__dirname, 'tsconfig-eslint.json'),
},

extends: ['standard-with-typescript', 'plugin:react/recommended', 'prettier'],
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# These files are binary and line endings should be left untouched
*.hex binary
*.bat binary
*.gltf binary
api/pypi-readme.rst text eol=lf
16 changes: 16 additions & 0 deletions api-client/src/calibration/getCalibrationPipetteOffset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { GET, request } from '../request'

import type { ResponsePromise } from '../request'
import type { HostConfig } from '../types'
import type { AllPipetteOffsetCalibrations } from './types'

export function getCalibrationPipetteOffset(
config: HostConfig
): ResponsePromise<AllPipetteOffsetCalibrations> {
return request<AllPipetteOffsetCalibrations>(
GET,
'/calibration/pipette_offset',
null,
config
)
}
11 changes: 11 additions & 0 deletions api-client/src/calibration/getCalibrationStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { GET, request } from '../request'

import type { ResponsePromise } from '../request'
import type { HostConfig } from '../types'
import type { CalibrationStatus } from './types'

export function getCalibrationStatus(
config: HostConfig
): ResponsePromise<CalibrationStatus> {
return request<CalibrationStatus>(GET, '/calibration/status', null, config)
}
16 changes: 16 additions & 0 deletions api-client/src/calibration/getCalibrationTipLength.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { GET, request } from '../request'

import type { ResponsePromise } from '../request'
import type { HostConfig } from '../types'
import type { AllTipLengthCalibrations } from './types'

export function getCalibrationTipLength(
config: HostConfig
): ResponsePromise<AllTipLengthCalibrations> {
return request<AllTipLengthCalibrations>(
GET,
'/calibration/tip_length',
null,
config
)
}
3 changes: 3 additions & 0 deletions api-client/src/calibration/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export { deleteCalibration } from './deleteCalibration'
export { getCalibrationStatus } from './getCalibrationStatus'
export { getCalibrationPipetteOffset } from './getCalibrationPipetteOffset'
export { getCalibrationTipLength } from './getCalibrationTipLength'

export * from './types'
85 changes: 85 additions & 0 deletions api-client/src/calibration/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,88 @@ export interface TipLengthDeletionParams {
export type DeleteCalRequestParams =
| PipOffsetDeletionParams
| TipLengthDeletionParams

export type FetchCalibrationStatusParams =
| PipOffsetDeletionParams
| TipLengthDeletionParams

type CalibrationSourceType =
| 'default'
| 'factory'
| 'user'
| 'calibration_check'
| 'legacy'
| 'unknown'
interface IndividualCalibrationHealthStatus {
markedBad: boolean // will be marked bad by a faile cal health check
source: CalibrationSourceType | null // what actor marked it bad
markedAt: string | null // what timestamp it was marked bad
}

export interface DeckCalibrationData {
type: 'attitude' | 'affine'
matrix:
| [
[number, number, number],
[number, number, number],
[number, number, number]
]
| [
[number, number, number, number],
[number, number, number, number],
[number, number, number, number],
[number, number, number, number]
]
lastModified: string | null
pipetteCalibratedWith: string | null // pipette serial number
tiprack: string | null // tip rack hash
source: CalibrationSourceType
status: IndividualCalibrationHealthStatus
}
export interface DeckCalibrationStatus {
status: 'OK' | 'IDENTITY' | 'BAD_CALIBRATION' | 'SINGULARITY'
data: DeckCalibrationData
}
interface InstrumentOffset {
single: [number, number, number]
multi: [number, number, number]
}
export interface InstrumentCalibration {
right: InstrumentOffset
left: InstrumentOffset
}
export interface CalibrationStatus {
deckCalibration: DeckCalibrationStatus
instrumentCalibration: InstrumentCalibration
}

export interface PipetteOffsetCalibration {
pipette: string
mount: Mount
offset: [number, number, number]
tiprack: string
tiprackUri: string
lastModified: string
source: CalibrationSourceType
status: IndividualCalibrationHealthStatus
id: string
}

export interface AllPipetteOffsetCalibrations {
data: PipetteOffsetCalibration[]
}

export interface TipLengthCalibration {
tipLength: number
tiprack: string
pipette: string
lastModified: string
source: CalibrationSourceType
status: IndividualCalibrationHealthStatus
id: string
uri?: string | null
}

export interface AllTipLengthCalibrations {
data: TipLengthCalibration[]
}
1 change: 1 addition & 0 deletions api-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export * from './server'
export * from './modules'
export * from './pipettes'
export * from './calibration'
export * from './robot'
33 changes: 23 additions & 10 deletions api-client/src/protocols/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
parsePipetteEntity,
parseInitialPipetteNamesByMount,
parseAllRequiredModuleModels,
parseAllRequiredModuleModelsById,
parseRequiredModulesEntity,
parseInitialLoadedLabwareEntity,
parseInitialLoadedLabwareBySlot,
parseInitialLoadedLabwareByModuleId,
Expand Down Expand Up @@ -158,7 +158,9 @@ describe('parseInitialPipetteNamesByMount', () => {
})
describe('parsePipetteEntity', () => {
it('returns pipette names by id if loaded', () => {
const expected = [{ id: 'pipette-0', pipetteName: 'p300_single_gen2' }]
const expected = [
{ id: 'pipette-0', pipetteName: 'p300_single_gen2', mount: 'left' },
]
expect(parsePipetteEntity(mockRunTimeCommands)).toEqual(expected)
})
})
Expand All @@ -168,15 +170,23 @@ describe('parseAllRequiredModuleModels', () => {
expect(parseAllRequiredModuleModels(mockRunTimeCommands)).toEqual(expected)
})
})
describe('parseAllRequiredModuleModelsById', () => {
describe('parseRequiredModulesEntity', () => {
it('returns models by id for all loaded modules', () => {
const expected = {
'module-0': { model: 'magneticModuleV2' },
'module-1': { model: 'temperatureModuleV2' },
}
expect(parseAllRequiredModuleModelsById(mockRunTimeCommands)).toEqual(
expected
)
const expected = [
{
id: 'module-0',
model: 'magneticModuleV2',
location: { slotName: '1' },
serialNumber: '',
},
{
id: 'module-1',
model: 'temperatureModuleV2',
location: { slotName: '3' },
serialNumber: '',
},
]
expect(parseRequiredModulesEntity(mockRunTimeCommands)).toEqual(expected)
})
})
describe('parseInitialLoadedLabwareBySlot', () => {
Expand Down Expand Up @@ -233,12 +243,14 @@ describe('parseInitialLoadedLabwareById', () => {
loadName: 'opentrons_96_tiprack_300ul',
definitionUri: 'opentrons/opentrons_96_tiprack_300ul/1',
displayName: 'Opentrons 96 Tip Rack 300 µL',
location: { slotName: '2' },
},
{
id: 'labware-2',
loadName: 'nest_96_wellplate_100ul_pcr_full_skirt',
definitionUri: 'opentrons/nest_96_wellplate_100ul_pcr_full_skirt/1',
displayName: 'NEST 96 Well Plate 100 µL PCR Full Skirt',
location: { moduleId: 'module-0' },
},
{
id: 'labware-3',
Expand All @@ -247,6 +259,7 @@ describe('parseInitialLoadedLabwareById', () => {
'opentrons/opentrons_24_aluminumblock_generic_2ml_screwcap/1',
displayName:
'Opentrons 24 Well Aluminum Block with Generic 2 mL Screwcap',
location: { moduleId: 'module-1' },
},
]
expect(parseInitialLoadedLabwareEntity(mockRunTimeCommands)).toEqual(
Expand Down
100 changes: 45 additions & 55 deletions api-client/src/protocols/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
import reduce from 'lodash/reduce'

import { COLORS } from '@opentrons/components/src/ui-style-constants'
import type { ModuleModel, PipetteName, Liquid } from '@opentrons/shared-data'
import type {
ModuleModel,
PipetteName,
Liquid,
LoadedPipette,
LoadedLabware,
LoadedModule,
} from '@opentrons/shared-data'
import type { RunTimeCommand } from '@opentrons/shared-data/protocol/types/schemaV6'
import type {
LoadLabwareRunTimeCommand,
Expand Down Expand Up @@ -32,47 +39,34 @@ export function parseInitialPipetteNamesByMount(
}
}

export interface PipetteNamesById {
id: string
pipetteName: PipetteName
}

export function parsePipetteEntity(
commands: RunTimeCommand[]
): PipetteNamesById[] {
const rightPipette = commands.find(
): LoadedPipette[] {
const pipetteEntity = []
const rightPipetteCommand = commands.find(
(command): command is LoadPipetteRunTimeCommand =>
command.commandType === 'loadPipette' && command.params.mount === 'right'
)
const leftPipette = commands.find(
const leftPipetteCommand = commands.find(
(command): command is LoadPipetteRunTimeCommand =>
command.commandType === 'loadPipette' && command.params.mount === 'left'
)

const rightPipetteEntity =
rightPipette != null
? {
id: rightPipette.result.pipetteId,
pipetteName: rightPipette.params.pipetteName,
}
: {}
const leftPipetteEntity =
leftPipette != null
? {
id: leftPipette.result.pipetteId,
pipetteName: leftPipette.params.pipetteName,
}
: {}

if (leftPipetteEntity.id == null && rightPipetteEntity.id != null) {
return [rightPipetteEntity]
} else if (rightPipetteEntity.id == null && leftPipetteEntity.id != null) {
return [leftPipetteEntity]
} else if (rightPipetteEntity.id != null && leftPipetteEntity.id != null) {
return [rightPipetteEntity, leftPipetteEntity]
} else {
return []
if (rightPipetteCommand != null) {
pipetteEntity.push({
id: rightPipetteCommand.result.pipetteId,
pipetteName: rightPipetteCommand.params.pipetteName,
mount: rightPipetteCommand.params.mount,
})
}
if (leftPipetteCommand != null) {
pipetteEntity.push({
id: leftPipetteCommand.result.pipetteId,
pipetteName: leftPipetteCommand.params.pipetteName,
mount: leftPipetteCommand.params.mount,
})
}

return pipetteEntity
}

export function parseAllRequiredModuleModels(
Expand All @@ -87,23 +81,25 @@ export function parseAllRequiredModuleModels(
)
}

export interface ModuleModelsById {
[moduleId: string]: { model: ModuleModel }
}

export function parseAllRequiredModuleModelsById(
// This function is only used to compile modules from commands in the case that the
// app-side protocol analysis is being referenced and stale.
// The only time this will happen is in the protocol list page, where the serialNumber
// should NOT be referenced
export function parseRequiredModulesEntity(
commands: RunTimeCommand[]
): ModuleModelsById {
return commands.reduce<ModuleModelsById>(
(acc, command) =>
): LoadedModule[] {
const loadModuleCommands = commands.filter(
(command): command is LoadModuleRunTimeCommand =>
command.commandType === 'loadModule'
? {
...acc,
[command.result?.moduleId]: { model: command.params.model },
}
: acc,
{}
)
return loadModuleCommands.map(command => {
return {
id: command.result.moduleId,
model: command.params.model,
location: command.params.location,
serialNumber: '',
}
})
}

interface LoadedLabwareBySlot {
Expand Down Expand Up @@ -152,16 +148,9 @@ export function parseInitialLoadedLabwareByModuleId(
)
}

export interface LoadedLabwareEntity {
id: string
loadName: string
definitionUri: string
displayName?: string
}

export function parseInitialLoadedLabwareEntity(
commands: RunTimeCommand[]
): LoadedLabwareEntity[] {
): LoadedLabware[] {
const loadLabwareCommands = commands.filter(
(command): command is LoadLabwareRunTimeCommand =>
command.commandType === 'loadLabware'
Expand All @@ -181,6 +170,7 @@ export function parseInitialLoadedLabwareEntity(
id: labwareId,
loadName,
definitionUri,
location: command.params.location,
displayName: command.params.displayName,
}
})
Expand Down
9 changes: 9 additions & 0 deletions api-client/src/robot/getLights.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { GET, request } from '../request'

import type { ResponsePromise } from '../request'
import type { HostConfig } from '../types'
import type { Lights } from './types'

export function getLights(config: HostConfig): ResponsePromise<Lights> {
return request<Lights>(GET, '/robot/lights', null, config)
}
3 changes: 3 additions & 0 deletions api-client/src/robot/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { getLights } from './getLights'
export { setLights } from './setLights'
export type { Lights, SetLightsData } from './types'
Loading

0 comments on commit cd41b39

Please sign in to comment.