-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/edge' into api_fix_aspirate_tip
- Loading branch information
Showing
57 changed files
with
1,342 additions
and
872 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from typing import List | ||
|
||
from opentrons.config import feature_flags as ff | ||
|
||
from .types import DoorState, PauseType, PauseResumeError | ||
|
||
|
||
class PauseManager: | ||
""" This class determines whether or not the hardware controller should | ||
pause or resume by evaluating the pause and resume types. The use of two | ||
pause types are used to separate the delay resume (triggered when the delay | ||
timer runs out) and the pause resume (trigged by user via the app). | ||
""" | ||
|
||
def __init__(self, door_state: DoorState) -> None: | ||
self.queue: List[PauseType] = [] | ||
self._blocked_by_door = self._evaluate_door_state(door_state) | ||
|
||
@property | ||
def should_pause(self) -> bool: | ||
return bool(self.queue) | ||
|
||
@property | ||
def blocked_by_door(self) -> bool: | ||
return self._blocked_by_door | ||
|
||
def _evaluate_door_state(self, door_state: DoorState) -> bool: | ||
if ff.enable_door_safety_switch(): | ||
return door_state is DoorState.OPEN | ||
return False | ||
|
||
def set_door(self, door_state: DoorState): | ||
self._blocked_by_door = self._evaluate_door_state(door_state) | ||
|
||
def resume(self, pause_type: PauseType): | ||
# door should be closed before a resume from the app can be received | ||
if self._blocked_by_door and pause_type is PauseType.PAUSE: | ||
raise PauseResumeError | ||
if pause_type in self.queue: | ||
self.queue.remove(pause_type) | ||
|
||
def pause(self, pause_type: PauseType): | ||
if pause_type not in self.queue: | ||
self.queue.append(pause_type) | ||
|
||
def reset(self): | ||
self.queue = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.