How can I control multiple pioreactors through a script? This is an example of my current script:
from pioreactor.background_jobs.dosing_control import DosingController
from pioreactor.background_jobs.temperature_control import TemperatureController
from pioreactor.utils.timing import RepeatedTimer
from pioreactor.whoami import get_unit_name, get_latest_experiment_name
Class Schedule():
def __init__(self, **kwargs):
pass
def main_loop(self):
self.current_time = perf_counter()
growth_rate = self.get_latest_growth_rates()
if growth_rate > self.min_growth_rate:
# main loop logic here
# I change the automation parameters like below
dc.automation_job.target_normalized_od = 1 # example
def background_loop(self):
self.current_time = perf_counter()
if self.time_since_main_loop() - 3600 >= 0:
# some logic
HOURSTOSECONDS = 3600
sc = Schedule()
dc = DosingController(
"turbidostat",
duration = 1,
unit=get_unit_name(),
experiment=get_latest_experiment_name()
)
tc = TemperatureController(
"thermostat",
target_temperature=30,
unit=get_unit_name(),
experiment=get_latest_experiment_name()
)
main_loop = RepeatedTimer(24*HOURS_TO_SECONDS, sc.main_loop).start()
background_loop = RepeatedTimer(1*HOURS_TO_SECONDS, sc.background_loop).start()
dc.block_until_disconnected()
So far I have only been controlling the leader itself, so I don’t really know how to scale this up or send commands to a worker. How would I go about telling every worker to start a chemostat at some initial value?
How can I control multiple pioreactors through a single script? Also, how should I structure the code? For example, I was thinking each pioreactor might be its own object and then all the pioreactors could be stored in a single Python list.