Skip to content

Commit

Permalink
add reset cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
falkecarlsen committed Aug 14, 2024
1 parent 93a2287 commit fb6e4ef
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion py_driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def alive(self):
return time() - self.heartbeat < COMMUNICATION_TIMEOUT

def ready(self):
return not self.busy
return not self.busy and self.alive() and not self.e_stop

def update_state(self, tube=None, quick=False):
"""Get the last state of the device. If cached state is outdated, a new sensor reading is requested."""
Expand Down Expand Up @@ -396,6 +396,16 @@ def e_stop(self):
assert not self.state.dynamic, "Device is still dynamic after emergency stop."
self.e_stop = True

def reset(self):
"""Reset the device and clears the emergency stop."""
self.write("7;")
# wait for device to be ready again after resuming
while not self.ready():
sleep(0.1)
self.update_state(quick=True)
assert not self.state.dynamic, "Device is dynamic after resetting emergency stop."
self.e_stop = False

def set_water_level(self, tube, level):
"""
Set the water level in the selected tube to the provided height.
Expand Down

0 comments on commit fb6e4ef

Please sign in to comment.