Skip to content

Commit

Permalink
agriculture: change controller direction from number to letters
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Coman <[email protected]>
  • Loading branch information
victorcoman committed Dec 13, 2021
1 parent 3c8bbb9 commit ab49210
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion agriculture/Procfile.config → agriculture/Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: gunicorn --bind :8000 --workers 3 --threads 2 agriculturecommon.wsgi:application
websocket: daphne -b :: -p 5000 agriculturecommon.asgi:application
websocket: daphne -b :: -p 5000 agriculturecommon.asgi:application
46 changes: 24 additions & 22 deletions agriculture/static/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const INFO_WINDOW_CONTENT_CONTROLLER = "" +
" </div>" +
" <div class='marker-info-value'>" +
" <span id='infow-wind'>@@WIND@@</span> km/h (" +
" <span id='infow-wind_dir'>@@WIND_DIR@@</span>)" +
" <span id='infow-wind_dir'>@@WIND_DIR@@</span> )" +
" </div>" +
" </div>" +
" <div class='marker-info-element'>" +
Expand Down Expand Up @@ -523,32 +523,14 @@ function updateWeatherStation(response) {

// Update the wind direction value.
controllerWindDir = weatherStationStatus[ID_WIND_DIR];
dir = "";

if (controllerWindDir == 0)
dir = "N"
if (controllerWindDir == 8)
dir = "NE"
if (controllerWindDir == 16)
dir = "E"
if (controllerWindDir == 24)
dir = "SE"
if (controllerWindDir == 32)
dir = "S"
if (controllerWindDir == 40)
dir = "SW"
if (controllerWindDir == 48)
dir = "W"
if (controllerWindDir == 56)
dir = "NW"

dir = getControllerWindDirString(controllerWindDir);

let controllerWindDirElement = document.getElementById(ID_WIND_DIR);
if (controllerWindDirElement != null)
controllerWindDirElement.innerText = dir;
let controllerWindDirInfowElement = document.getElementById("infow-wind_dir");
if (controllerWindDirInfowElement != null)
controllerWindDirInfowElement.innerText = weatherStationStatus[ID_WIND_DIR];
controllerWindDirInfowElement.innerText = dir;

// Update the rain value.
controllerRainDiff = weatherStationStatus[ID_RAIN];
Expand Down Expand Up @@ -577,6 +559,26 @@ function updateWeatherStation(response) {
controllerTemperatureElement.innerText = weatherStationStatus[ID_TEMPERATURE];
}

function getControllerWindDirString (controllerWindDir){
if (controllerWindDir == 0)
return "N";
else if (controllerWindDir == 8)
return "NE";
else if (controllerWindDir == 16)
return "E";
else if (controllerWindDir == 24)
return "SE";
else if (controllerWindDir == 32)
return "S";
else if (controllerWindDir == 40)
return "SW";
else if (controllerWindDir == 48)
return "W";
else if (controllerWindDir == 56)
return "NW";
}


// Updates the water tank information based on the given response.
function updateWaterTank(response) {
if (response[ID_STATUS] == null || response[ID_STATUS][ID_TANK] == null)
Expand Down Expand Up @@ -697,7 +699,7 @@ function getControllerInfoWindowContent() {
content = content.replace("@@WIND@@", "-");
// Update the wind direction value.
if (controllerWindDir != null)
content = content.replace("@@WIND_DIR@@", controllerWindDir);
content = content.replace("@@WIND_DIR@@", getControllerWindDirString(controllerWindDir));
else
content = content.replace("@@WIND_DIR@@", "-");
// Update the rain value.
Expand Down

0 comments on commit ab49210

Please sign in to comment.