Skip to content
Snippets Groups Projects
Commit ecd6ec0e authored by Philipp Jonas Krieg's avatar Philipp Jonas Krieg
Browse files

modified analyze routine

parent 96ffd4a5
No related branches found
No related tags found
1 merge request!29Finished Communication Logic
......@@ -25,17 +25,18 @@ def analyze_service(p):
# turns light on/off
if is_time_between(p.light_time_on, p.light_time_off, now) and p.light_status == 0:
print("turn on light")
try:
lichton()
except:
print("[analyze.py] No connection to ESP8266 possible")
elif p.light_status == 1:
try:
lichtoff()
except:
print("analyze.py] No connection to ESP8266 possible")
if not p.light_auto_mode:
if is_time_between(p.light_time_on, p.light_time_off, now) and p.light_status == 0:
print("turn on light")
try:
lichton(p)
except:
print("[analyze.py] No connection to ESP8266 possible")
elif p.light_status == 1:
try:
lichtoff(p)
except:
print("analyze.py] No connection to ESP8266 possible")
# checks ph-value and start ph handling routine if needed
if not(p.ph_target[0] <= p.ph_status <= p.ph_target[1]) and not p.ph_routine_started:
......@@ -45,12 +46,9 @@ def analyze_service(p):
# run pumps manually
if p.water_pump_status == 1:
p.water_pump_status = 0
pumpe1()
pumpe1(p)
if p.nutrition_pump_status == 1:
p.nutrition_pump_status = 0
pumpe2()
pumpe2(p)
......
......@@ -43,7 +43,7 @@ def get(p):
def pumpe1():
def pumpe1(p):
# IP-Adresse und Port des ESP8266-Servers
server_ip = output_ip
server_port = 80
......@@ -55,13 +55,14 @@ def pumpe1():
response = requests.get(url)
if response.status_code == 200:
print("Die Pumpe war an")
print("[communication.py] Die Pumpe war an")
p.water_pump_status = 0
return "success"
else:
print("Die Pumpe konnte nicht gestartet werden")
print("[communication.py] Die Pumpe konnte nicht gestartet werden")
return "error"
def pumpe2():
def pumpe2(p):
# IP-Adresse und Port des ESP8266-Servers
server_ip = output_ip
server_port = 80
......@@ -73,13 +74,14 @@ def pumpe2():
response = requests.get(url)
if response.status_code == 200:
print("Die Pumpe war an")
print("[communication.py] Die Pumpe war an")
p.nutrition_pump_status = 0
return "success"
else:
print("Die Pumpe konnte nicht gestartet werden")
print("[communication.py] Die Pumpe konnte nicht gestartet werden")
return "error"
def lichton():
def lichton(p):
# IP-Adresse und Port des ESP8266-Servers
server_ip = output_ip
server_port = 80
......@@ -91,11 +93,12 @@ def lichton():
response = requests.get(url)
if response.status_code == 200:
print("LED wurde eingeschaltet")
p.light_status = 1
print("[communication.py] LED wurde eingeschaltet")
else:
print("LED konnte nicht eingeschaltet werden")
print("[communication.py] LED konnte nicht eingeschaltet werden")
def lichtoff():
def lichtoff(p):
# IP-Adresse und Port des ESP8266-Servers
server_ip = output_ip
server_port = 80
......@@ -107,6 +110,7 @@ def lichtoff():
response = requests.get(url)
if response.status_code == 200:
print("LED wurde ausgeschaltet")
p.light_status = 0
print("[communication.py] LED wurde ausgeschaltet")
else:
print("LED konnte nicht ausgeschaltet werden")
\ No newline at end of file
print("[communication.py] LED konnte nicht ausgeschaltet werden")
\ No newline at end of file
......@@ -5,13 +5,13 @@ from communication import get, pumpe1, pumpe2
def handle_ph(p):
while True:
if p.ph_status < p.ph_target[0]: # ph too low
if pumpe1() == "success":
if pumpe1(p) == "success":
time.sleep(30)
else:
time.sleep(60) # try again after 60 secs
elif p.ph_status > p.ph_target[1]: # ph too high
if pumpe2() == "success":
if pumpe2(p) == "success":
time.sleep(30)
else:
time.sleep(60) # try again after 60 secs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment