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
0ba7e125
Commit
0ba7e125
authored
1 year ago
by
Karl-Luca
Committed by
laurakutter
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
textcontent in refresh()
parent
f7cb054c
No related branches found
Branches containing commit
No related tags found
1 merge request
!28
Raspberry webinterface
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
__pycache__/plant.cpython-39.pyc
+0
-0
0 additions, 0 deletions
__pycache__/plant.cpython-39.pyc
static/steuerung.js
+9
-45
9 additions, 45 deletions
static/steuerung.js
with
9 additions
and
45 deletions
__pycache__/plant.cpython-39.pyc
+
0
−
0
View file @
0ba7e125
No preview for this file type
This diff is collapsed.
Click to expand it.
static/steuerung.js
+
9
−
45
View file @
0ba7e125
...
...
@@ -22,89 +22,54 @@ function sendState(state) {
Http
.
setRequestHeader
(
'
Content-Type
'
,
'
application/json
'
);
Http
.
send
(
JSON
.
stringify
(
uiState
));
}
/*
// activate water pump
function setStateWaterPump() {
const Http = new XMLHttpRequest();
Http.open('POST', '././setState');
Http.setRequestHeader('Content-Type', 'application/json');
const state = { message: 'start water-pump'};
Http.send(JSON.stringify(state));
}
//activiate nutrition pump
function setStateNutritionPump() {
const Http = new XMLHttpRequest();
Http.open('POST', '././setState');
Http.setRequestHeader('Content-Type', 'application/json');
const state = { message: 'start nutrition-pump'};
Http.send(JSON.stringify(state));
}
// activate light
function setStateLightOn() {
const Http = new XMLHttpRequest();
Http.open('POST', '././setState');
Http.setRequestHeader('Content-Type', 'application/json');
const state = { message: 'activate light'};
Http.send(JSON.stringify(state));
}
//deactivate light
function setStateLightOff() {
const Http = new XMLHttpRequest();
Http.open('POST', '././setState');
Http.setRequestHeader('Content-Type', 'application/json');
const state = { message: 'deactivate light'};
Http.send(JSON.stringify(state));
}
*/
// updates elements to current state
function
refresh
()
{
getState
();
btn1
.
textContent
=
uiState
.
light_status
?
'
Licht an
'
:
'
Licht aus
'
;
// btn2.textContent =
btn2
.
textContent
=
uiState
.
water_pump_status
?
'
Wasserpumpe an
'
:
'
Wasserpumpe aus
'
;
btn3
.
textContent
=
uiState
.
nutrition_pump_status
?
'
Nährstoffpumpe an
'
:
'
Nährstoffpumpe aus
'
;
toggleSwitch
.
checked
=
uiState
.
light_auto_mode
?
true
:
false
;
timeSelector
.
style
.
display
=
uiState
.
light_auto_mode
?
'
block
'
:
'
none
'
;
}
// event listener for buttons and interative gui elements
//
event listener for light
//
light manual
btn1
.
addEventListener
(
'
click
'
,
function
handleClick
()
{
const
initialText
=
'
Licht an
'
;
if
(
btn1
.
textContent
.
toLowerCase
().
includes
(
initialText
.
toLowerCase
()))
{
btn1
.
textContent
=
'
Licht aus
'
;
//setStateLightOff();
uiState
.
light_status
=
0
;
}
else
{
btn1
.
textContent
=
initialText
;
//setStateLightOn();
uiState
.
light_status
=
1
;
}
sendState
(
uiState
);
});
//
event listener for
water pump
// water pump
btn2
.
addEventListener
(
'
click
'
,
function
handleClick
()
{
const
initialText
=
'
Wasserpumpe an
'
;
if
(
btn2
.
textContent
.
toLowerCase
().
includes
(
initialText
.
toLowerCase
()))
{
btn2
.
textContent
=
'
Wasserpumpe aus
'
;
}
else
{
btn2
.
textContent
=
initialText
;
//setStateWaterPump();
uiState
.
water_pump_status
=
1
;
}
sendState
(
uiState
);
});
//
event listener for
nutrition pump
//nutrition pump
btn3
.
addEventListener
(
'
click
'
,
function
handleClick
()
{
const
initialText
=
'
Nährstoffpumpe an
'
;
if
(
btn3
.
textContent
.
toLowerCase
().
includes
(
initialText
.
toLowerCase
()))
{
btn3
.
textContent
=
'
Nährstoffpumpe aus
'
;
}
else
{
btn3
.
textContent
=
initialText
;
//setStateNutritionPump();
uiState
.
nutrition_pump_status
=
1
;
}
sendState
(
uiState
);
});
// light automatic
toggleSwitch
.
addEventListener
(
'
change
'
,
function
()
{
if
(
this
.
checked
)
{
timeSelector
.
style
.
display
=
'
block
'
;
...
...
@@ -117,7 +82,6 @@ toggleSwitch.addEventListener('change', function() {
});
// get current status of growbot and refresh gui
getState
(
uiState
);
setTimeout
(()
=>
{
refresh
();
},
50
);
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