Skip to content

Commit

Permalink
feat(api): support offset in json protocol touch-tip command
Browse files Browse the repository at this point in the history
* update step-generation & JSON schema to support new optional field
  • Loading branch information
IanLondon committed Oct 29, 2018
1 parent a1cceee commit 5d06d57
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 12 deletions.
7 changes: 6 additions & 1 deletion api/src/opentrons/protocols/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ def dispatch_commands(protocol_data, loaded_pipettes, loaded_labware): # noqa:
pipette.dispense(volume, location)

elif command_type == 'touch-tip':
pipette.touch_tip(location)
offset_from_top = -1
if ('offsetFromBottomMm' in params):
offset_from_bottom = params['offsetFromBottomMm']
offset_from_top = (
location.properties['depth'] - offset_from_bottom)
pipette.touch_tip(location, v_offset=offset_from_top)


def execute_protocol(protocol):
Expand Down
2 changes: 2 additions & 0 deletions protocol-designer/src/file-data/selectors/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ export const robotStateTimeline: Selector<StepGeneration.Timeline> = createSelec
return (forms[stepId] && forms[stepId].validatedForm) || null
})

console.log({forms, orderedSteps, allFormData})

// TODO: Ian 2018-06-14 `takeWhile` isn't inferring the right type
// $FlowFixMe
const continuousValidForms: Array<StepGeneration.CommandCreatorData> = takeWhile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ describe('touchTip', () => {
expect(result.robotState).toEqual(robotStateWithTip)
})

test('touchTip with tip, specifying offsetFromBottomMm', () => {
const result = touchTip({
pipette: 'p300SingleId',
labware: 'sourcePlateId',
well: 'A1',
offsetFromBottomMm: 10,
})(robotStateWithTip)

expect(result.commands).toEqual([{
command: 'touch-tip',
params: {
pipette: 'p300SingleId',
labware: 'sourcePlateId',
well: 'A1',
offsetFromBottomMm: 10,
},
}])

expect(result.robotState).toEqual(robotStateWithTip)
})

test('touchTip with invalid pipette ID should throw error', () => {
const result = touchTipWithErrors({
pipette: 'badPipette',
Expand Down
9 changes: 6 additions & 3 deletions protocol-designer/src/step-generation/touchTip.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// @flow
// import cloneDeep from 'lodash/cloneDeep'
import {noTipOnPipette, pipetteDoesNotExist} from './errorCreators'
import type {RobotState, CommandCreator, CommandCreatorError, PipetteLabwareFields} from './'
import type {RobotState, CommandCreator, CommandCreatorError, TouchTipArgs} from './'

const touchTip = (args: PipetteLabwareFields): CommandCreator => (prevRobotState: RobotState) => {
const touchTip = (args: TouchTipArgs): CommandCreator => (prevRobotState: RobotState) => {
/** touchTip with given args. Requires tip. */
const actionName = 'touchTip'
const {pipette, labware, well} = args
const {pipette, labware, well, offsetFromBottomMm} = args

const pipetteData = prevRobotState.instruments[pipette]

Expand All @@ -30,6 +30,9 @@ const touchTip = (args: PipetteLabwareFields): CommandCreator => (prevRobotState
pipette,
labware,
well,
offsetFromBottomMm: offsetFromBottomMm == null
? undefined
: offsetFromBottomMm,
},
}]

Expand Down
9 changes: 7 additions & 2 deletions protocol-designer/src/step-generation/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ export type PipetteLabwareFields = {|
/* TODO optional uL/sec (or uL/minute???) speed here */
|}

export type TouchTipArgs = {|
...PipetteLabwareFields,
offsetFromBottomMm?: ?number,
|}

export type AspirateDispenseArgs = {|
...PipetteLabwareFields,
volume: number,
Expand All @@ -217,10 +222,10 @@ export type Command = {|
command: 'aspirate' | 'dispense',
params: AspirateDispenseArgs,
|} | {|
command: 'pick-up-tip' | 'drop-tip' | 'touch-tip',
command: 'pick-up-tip' | 'drop-tip' | 'blowout',
params: PipetteLabwareFields,
|} | {|
command: 'blowout',
command: 'touch-tip',
params: {|
...PipetteLabwareFields,
offsetFromBottomMm?: ?number,
Expand Down
8 changes: 4 additions & 4 deletions protocol-designer/src/steplist/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ export const currentFormCanBeSaved: Selector<boolean | null> = createSelector(
getSelectedStepId,
allSteps,
labwareIngredSelectors.getLabware,
(formData, selectedStepId, allSteps, labware) =>
((typeof selectedStepId === 'number') && allSteps[selectedStepId] && formData)
? Object.values(stepFormToArgs(formData, {labware}).errors).length === 0
: null
(formData, selectedStepId, allSteps, labware) => true
// ((typeof selectedStepId === 'number') && allSteps[selectedStepId] && formData)
// ? Object.values(stepFormToArgs(formData, {labware}).errors).length === 0
// : null
)

export default {
Expand Down
23 changes: 21 additions & 2 deletions shared-data/protocol-json-schema/protocol-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,32 @@
},

{
"description": "Pick up tip / drop tip / touch tip / blowout commands",
"description": "Touch tip commands",
"type": "object",
"required": ["command", "params"],
"additionalProperties": false,
"properties": {
"command": {
"enum": ["pick-up-tip", "drop-tip", "touch-tip", "blowout"]
"enum": ["touch-tip"]
},
"params": {
"allOf": [
{"$ref": "#/definitions/pipette-access-params"},
{"$ref": "#/definitions/offsetFromBottomMm"}
]
}
}
},


{
"description": "Pick up tip / drop tip / blowout commands",
"type": "object",
"required": ["command", "params"],
"additionalProperties": false,
"properties": {
"command": {
"enum": ["pick-up-tip", "drop-tip", "blowout"]
},
"params": {
"allOf": [
Expand Down

0 comments on commit 5d06d57

Please sign in to comment.