def air_cleaning(self): for valve in self.valves_in_use_feeding: Context.control_box.open_valve(valve) Context.run_pump(Context.water_out1, duration=10) Context.control_box.close_valve(valve) lprint("Air_cleaning_done")
def general_priming(self): for valve in self.valves_in_use_feeding: Context.control_box.open_valve(valve) Context.run_pump(Context.water_in, duration=0.5) Context.run_pump(Context.water_out1, duration=4) Context.control_box.close_valve(valve) lprint("General_priming_done")
def prepare(self, food_amount_multiplier): # pour food into fishfeeder for _ in range(food_amount_multiplier): Context.rotate_food_servo(180) Context.rotate_food_servo(0) # bring clean water to fishfeeder #for _ in range(1): #Context.check_water_sensor() #Context.run_pump(Context.water_in, duration=0.5) #Context.STATUS = "FoodPrepared" lprint("food prepared")
def initialize(self): Context.initialize() if not self.check_early_stop(): Context.DAY, Context.TIME = datetime.datetime.today().strftime( '%Y-%m-%d %H:%M:%S').split() # Initialize water sensor GPIO.setmode(GPIO.BCM) GPIO.setup(Context.water_sensor, GPIO.OUT) GPIO.output(Context.water_sensor, GPIO.LOW) sleep(0.05) GPIO.setup(Context.water_sensor, GPIO.IN) lprint("initialized")
def priming(self, valves_in_use_feeding): # Open all valves for valve in valves_in_use_feeding: Context.control_box.open_valve(valve) # prime water In for _ in range(1): Context.check_water_sensor() Context.run_pump(Context.water_in, duration=0.5) # prime water Out for _ in range(1): Context.check_water_sensor() Context.run_pump(Context.water_out1, duration=3) Context.control_box.close_valve(valve) # # Close all valves # for valve in valves_in_use: # Context.control_box.close_valve(valve) lprint("pumps primed")
def stream(self): # stream water to fish tanks for i in range(2): Context.check_water_sensor() Context.run_pump(Context.water_out1, duration=1) # bring water and stream fishfeeder for _ in range(1): Context.check_water_sensor() Context.control_box.set_pwm(Context.water_in, 255) Context.control_box.set_pwm(Context.water_out1, 255) sleep(0.5) Context.control_box.set_pwm(Context.water_in, 0) Context.control_box.set_pwm(Context.water_out1, 0) Context.run_pump(Context.water_out1, duration=1) #for _ in range(1): #Context.check_water_sensor() #Context.run_pump(Context.water_in, duration=1) #for _ in range(1): #Context.check_water_sensor() #Context.run_pump(Context.water_out1, duration=2) lprint("food water mix streamed")
def clean(self): for _ in range(1): # bring clean water to fishfeeder Context.check_water_sensor() Context.run_pump(Context.water_in, duration=0.25) # thrash water from fishfeeder Context.check_water_sensor() Context.run_pump(Context.water_out1, duration=2) for _ in range(1): for _ in range(1): # bring clean water to fishfeeder Context.check_water_sensor() Context.run_pump(Context.water_in, duration=0.25) for _ in range(1): # thrash water from fishfeeder Context.check_water_sensor() Context.run_pump(Context.water_out1, duration=1) for _ in range(1): # bring clean water to fishfeeder Context.check_water_sensor() Context.run_pump(Context.water_in, duration=2) for _ in range(1): # thrash water from fishfeeder Context.check_water_sensor() Context.run_pump(Context.water_out1, duration=20) Context.STATUS = "Cleaned" lprint("tanks cleaned")
def demo_pumps(pumps, duration=0.5): ctx = Context() Context.initialize() ctx.run_pump(pumps, duration=duration)