Skip to content

Commit

Permalink
Replace LoadLabwareResult isinstance check with StateUpdate.loaded_la…
Browse files Browse the repository at this point in the history
…bware.
  • Loading branch information
SyntaxColoring committed Oct 28, 2024
1 parent 0a86b9d commit c0d612e
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 157 deletions.
40 changes: 15 additions & 25 deletions api/src/opentrons/protocol_engine/state/tips.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
from opentrons.protocol_engine.state import update_types

from ._abstract_store import HasState, HandlesActions
from ..actions import Action, SucceedCommandAction, ResetTipsAction, get_state_updates
from ..commands import (
Command,
LoadLabwareResult,
)
from ..actions import Action, ResetTipsAction, get_state_updates

from opentrons.hardware_control.nozzle_manager import NozzleMap

Expand Down Expand Up @@ -65,33 +61,14 @@ def handle_action(self, action: Action) -> None:
for state_update in get_state_updates(action):
self._handle_state_update(state_update)

if isinstance(action, SucceedCommandAction):
self._handle_succeeded_command(action.command)

elif isinstance(action, ResetTipsAction):
if isinstance(action, ResetTipsAction):
labware_id = action.labware_id

for well_name in self._state.tips_by_labware_id[labware_id].keys():
self._state.tips_by_labware_id[labware_id][
well_name
] = TipRackWellState.CLEAN

def _handle_succeeded_command(self, command: Command) -> None:
if (
isinstance(command.result, LoadLabwareResult)
and command.result.definition.parameters.isTiprack
):
labware_id = command.result.labwareId
definition = command.result.definition
self._state.tips_by_labware_id[labware_id] = {
well_name: TipRackWellState.CLEAN
for column in definition.ordering
for well_name in column
}
self._state.column_by_labware_id[labware_id] = [
column for column in definition.ordering
]

def _handle_state_update(self, state_update: update_types.StateUpdate) -> None:
if state_update.pipette_config != update_types.NO_CHANGE:
self._state.pipette_info_by_pipette_id[
Expand All @@ -118,6 +95,19 @@ def _handle_state_update(self, state_update: update_types.StateUpdate) -> None:
)
pipette_info.nozzle_map = state_update.pipette_nozzle_map.nozzle_map

if state_update.loaded_labware != update_types.NO_CHANGE:
labware_id = state_update.loaded_labware.labware_id
definition = state_update.loaded_labware.definition
if definition.parameters.isTiprack:
self._state.tips_by_labware_id[labware_id] = {
well_name: TipRackWellState.CLEAN
for column in definition.ordering
for well_name in column
}
self._state.column_by_labware_id[labware_id] = [
column for column in definition.ordering
]

def _set_used_tips( # noqa: C901
self, pipette_id: str, well_name: str, labware_id: str
) -> None:
Expand Down
Loading

0 comments on commit c0d612e

Please sign in to comment.