Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cyber-Physical Systems
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ben Luno Becker
Cyber-Physical Systems
Commits
ecd6ec0e
Commit
ecd6ec0e
authored
1 year ago
by
Philipp Jonas Krieg
Browse files
Options
Downloads
Patches
Plain Diff
modified analyze routine
parent
96ffd4a5
No related branches found
Branches containing commit
No related tags found
1 merge request
!29
Finished Communication Logic
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
analyze.py
+14
-16
14 additions, 16 deletions
analyze.py
communication.py
+16
-12
16 additions, 12 deletions
communication.py
ph.py
+2
-2
2 additions, 2 deletions
ph.py
with
32 additions
and
30 deletions
analyze.py
+
14
−
16
View file @
ecd6ec0e
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
communication.py
+
16
−
12
View file @
ecd6ec0e
...
...
@@ -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
This diff is collapsed.
Click to expand it.
ph.py
+
2
−
2
View file @
ecd6ec0e
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment