Skip to content

Commit

Permalink
no op open and close lid if lid already in desired end position
Browse files Browse the repository at this point in the history
  • Loading branch information
CaseyBatten committed Aug 12, 2024
1 parent 91a3242 commit 9b01734
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
2 changes: 1 addition & 1 deletion api/docs/v2/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@
("py:class", r".*protocol_api\.config.*"),
("py:class", r".*opentrons_shared_data.*"),
("py:class", r".*protocol_api._parameters.Parameters.*"),
("py:class", r".*AbsorbanceReaderContext"), # shh it's a secret (for now)
("py:class", r".*AbsorbanceReaderContext"),
("py:class", r".*RobotContext"), # shh it's a secret (for now)
("py:class", r'.*AbstractLabware|APIVersion|LabwareLike|LoadedCoreMap|ModuleTypes|NoneType|OffDeckType|ProtocolCore|WellCore'), # laundry list of not fully qualified things
]
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,30 @@ async def execute(
mod_substate = self._state_view.modules.get_absorbance_reader_substate(
module_id=params.moduleId
)
# Make sure the lid is open
mod_substate.raise_if_lid_status_not_expected(lid_on_expected=False)

# Allow propagation of ModuleNotAttachedError.
_ = self._equipment.get_module_hardware_api(mod_substate.module_id)

# lid should currently be docked
# lid should currently be on the module
assert mod_substate.lid_id is not None
loaded_lid = self._state_view.labware.get(mod_substate.lid_id)
assert labware_validation.is_absorbance_reader_lid(loaded_lid.loadName)

# If the lid is already Closed, No-op out
if mod_substate.is_lid_on:
current_offset_id = self._equipment.find_applicable_labware_offset_id(
labware_definition_uri=loaded_lid.definitionUri,
labware_location=loaded_lid.location,
)
return SuccessData(
public=CloseLidResult(
lidId=loaded_lid.id,
newLocation=loaded_lid.location,
offsetId=current_offset_id,
),
private=None,
)

# Allow propagation of ModuleNotAttachedError.
_ = self._equipment.get_module_hardware_api(mod_substate.module_id)

current_location = loaded_lid.location
validated_current_location = (
self._state_view.geometry.ensure_valid_gripper_location(current_location)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,29 @@ async def execute(self, params: OpenLidParams) -> SuccessData[OpenLidResult, Non
mod_substate = self._state_view.modules.get_absorbance_reader_substate(
module_id=params.moduleId
)
# Make sure the lid is closed
mod_substate.raise_if_lid_status_not_expected(lid_on_expected=True)

# Allow propagation of ModuleNotAttachedError.
_ = self._equipment.get_module_hardware_api(mod_substate.module_id)

# lid should currently be on the module
assert mod_substate.lid_id is not None
loaded_lid = self._state_view.labware.get(mod_substate.lid_id)
assert labware_validation.is_absorbance_reader_lid(loaded_lid.loadName)

# If the lid is already Open, No-op out
if not mod_substate.is_lid_on:
current_offset_id = self._equipment.find_applicable_labware_offset_id(
labware_definition_uri=loaded_lid.definitionUri,
labware_location=loaded_lid.location,
)
return SuccessData(
public=OpenLidResult(
lidId=loaded_lid.id,
newLocation=loaded_lid.location,
offsetId=current_offset_id,
),
private=None,
)

# Allow propagation of ModuleNotAttachedError.
_ = self._equipment.get_module_hardware_api(mod_substate.module_id)

current_location = loaded_lid.location
validated_current_location = (
self._state_view.geometry.ensure_valid_gripper_location(current_location)
Expand Down

0 comments on commit 9b01734

Please sign in to comment.