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
14750670
Commit
14750670
authored
1 year ago
by
laurakutter
Browse files
Options
Downloads
Patches
Plain Diff
removed comments
parent
6178954a
No related branches found
Branches containing commit
No related tags found
1 merge request
!29
Finished Communication Logic
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
static/index.js
+3
-152
3 additions, 152 deletions
static/index.js
with
3 additions
and
152 deletions
static/index.js
+
3
−
152
View file @
14750670
...
...
@@ -16,40 +16,7 @@ function getState() {
uiState
=
Http
.
response
;
}
}
/*
// 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));
}
*/
// refresh values of gui elements
function
refresh
()
{
ph
.
textContent
=
String
(
uiState
.
ph_status
)
+
'
pH
'
;
...
...
@@ -58,23 +25,6 @@ function refresh() {
hum
.
textContent
=
String
(
uiState
.
hum_status
)
+
'
%
'
;
temp
.
textContent
=
String
(
uiState
.
temp_status
)
+
'
°C
'
;
}
/*
//automated steering for nutrition pump and water pump if ph value drops/is too high
function steering() {
if(uiState.ph_status < 5.5) {
setStateWaterPump();
}
if(uiState.ph_status > 7) {
setStateNutritionPump();
}
if(uiState.par_status < 400) {
setStateLightOn();
}
if(uiState.par_status > 700) {
setStateLightOff();
}
}
*/
getState
();
setTimeout
(()
=>
{
refresh
();
},
50
);
...
...
@@ -86,7 +36,7 @@ setInterval(() => {
},
2000
)
//
// PopUp-Fenster
// PopUp-Fenster
// PAR-PopUp
function
showPopUp
()
{
var
popup
=
document
.
getElementById
(
"
myPopup
"
);
...
...
@@ -111,103 +61,4 @@ function showPopUp4() {
function
showPopUp5
()
{
var
popup
=
document
.
getElementById
(
"
myPopup5
"
);
popup
.
classList
.
toggle
(
"
show
"
);
}
// Code beneath was moved to steuerung.js
// let uiState;
// const btn1 = document.getElementById('btn1'); // light
// const btn2 = document.getElementById('btn2'); // pump
// const toggleSwitch = document.getElementById('toggleSwitch');
// const timeSelector = document.getElementById('timeSelector');
// function getState() {
// const Http = new XMLHttpRequest();
// Http.open('GET', '././getState');
// Http.responseType = 'json';
// Http.send();
// Http.onreadystatechange = (e) => {
// uiState = Http.response;
// console.log(uiState)
// }
// }
// function sendState(state) {
// const Http = new XMLHttpRequest();
// Http.open("POST", '././setState');
// Http.setRequestHeader('Content-Type', 'application/json');
// Http.send(JSON.stringify(uiState));
// }
// function refresh() {
// btn1.textContent = uiState.light_status ? 'Licht an' : 'Licht aus';
// // btn2.textContent =
// toggleSwitch.checked = uiState.light_auto_mode ? true : false;
// timeSelector.style.display = uiState.light_auto_mode ? 'block' : 'none';
// }
// btn1.addEventListener('click', function handleClick() {
// const initialText = 'Licht an';
// if (btn1.textContent.toLowerCase().includes(initialText.toLowerCase())) {
// btn1.textContent = 'Licht aus';
// uiState.light_status = 0;
// } else {
// btn1.textContent = initialText;
// uiState.light_status = 1;
// }
// sendState(uiState)
// });
// btn2.addEventListener('click', function handleClick() {
// const initialText = 'Pumpe an';
// if (btn2.textContent.toLowerCase().includes(initialText.toLowerCase())) {
// btn2.textContent = 'Pumpe aus';
// } else {
// btn2.textContent = initialText;
// }
// });
// toggleSwitch.addEventListener('change', function() {
// if (this.checked) {
// timeSelector.style.display = 'block';
// uiState.light_auto_mode = 1;
// } else {
// timeSelector.style.display = 'none';
// uiState.light_auto_mode = 0;
// }
// sendState(uiState)
// });
// //Pop-up Zeitschaltung
// /*
// function myFunction2() {
// var dots = document.getElementById("dots");
// var moreText = document.getElementById("more");
// var btnText = document.getElementById("myBtn");
// if (dots.style.display === "none") {
// dots.style.display = "inline";
// btnText.innerHTML = "Read more";
// moreText.style.display = "none";
// } else {
// dots.style.display = "none";
// btnText.innerHTML = "Read less";
// moreText.style.display = "inline";
// }
// }*/
// // get current status of growbot and refresh gui
// getState(uiState);
// setTimeout(() => { refresh(); }, 50);
}
\ No newline at end of file
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