Skip to content

Commit 1598575

Browse files
committed
Added pump management task for ePBR (#30)
1 parent 160f8d9 commit 1598575

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

custom/tasks/PBR.py

+26-5
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,31 @@ def __init__(self, config):
301301
}
302302

303303

304-
class ePBRGeneralPump(PBRGeneralPump):
304+
class ePBRpump(PBRGeneralPump):
305305
def __init__(self, config):
306-
super(ePBRGeneralPump, self).__init__(config)
306+
super(ePBRpump, self).__init__(config)
307307

308-
# od should be available somehow
309-
# because is being used for OD bounds
310-
# so we need to use it also for decision to keep on pump
308+
def stabilize(self, od):
309+
if self.is_od_value_too_high(od):
310+
self.is_pump_on = True
311+
if self.is_od_value_too_low(od):
312+
self.is_pump_on = False
313+
if self.is_pump_on:
314+
self.change_pump_state(True)
315+
316+
def change_pump_state(self, state: bool):
317+
for try_n in range(5):
318+
command = Command(self.device_id, "8", [self.pump_id, 1], self.task_id)
319+
self.device.post_command(command, 1)
320+
command.await_cmd()
321+
322+
if isinstance(command.response, bool) and command.response:
323+
sleep(2)
324+
325+
command = Command(self.device_id, "8", [self.pump_id, 0], self.task_id)
326+
self.device.post_command(command, 1)
327+
command.await_cmd()
328+
329+
if isinstance(command.response, bool) and command.response:
330+
return
331+
raise ConnectionError

custom/tasks/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
"PSI_GMS_measure_all": GMS.GMSMeasureAll,
1212
# Phenometrics
1313
"ePBR_measure_all": PBR.ePBRMeasureAll,
14-
"ePBR_pump": PBR.ePBRGeneralPump,
14+
"ePBR_pump": PBR.ePBRpump,
1515
}

0 commit comments

Comments
 (0)