Skip to content

Commit ab49210

Browse files
committed
agriculture: change controller direction from number to letters
Signed-off-by: Victor Coman <victor.coman@digi.com>
1 parent 3c8bbb9 commit ab49210

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
web: gunicorn --bind :8000 --workers 3 --threads 2 agriculturecommon.wsgi:application
2-
websocket: daphne -b :: -p 5000 agriculturecommon.asgi:application
2+
websocket: daphne -b :: -p 5000 agriculturecommon.asgi:application

agriculture/static/js/dashboard.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const INFO_WINDOW_CONTENT_CONTROLLER = "" +
6464
" </div>" +
6565
" <div class='marker-info-value'>" +
6666
" <span id='infow-wind'>@@WIND@@</span> km/h (" +
67-
" <span id='infow-wind_dir'>@@WIND_DIR@@</span>)" +
67+
" <span id='infow-wind_dir'>@@WIND_DIR@@</span> )" +
6868
" </div>" +
6969
" </div>" +
7070
" <div class='marker-info-element'>" +
@@ -523,32 +523,14 @@ function updateWeatherStation(response) {
523523

524524
// Update the wind direction value.
525525
controllerWindDir = weatherStationStatus[ID_WIND_DIR];
526-
dir = "";
527-
528-
if (controllerWindDir == 0)
529-
dir = "N"
530-
if (controllerWindDir == 8)
531-
dir = "NE"
532-
if (controllerWindDir == 16)
533-
dir = "E"
534-
if (controllerWindDir == 24)
535-
dir = "SE"
536-
if (controllerWindDir == 32)
537-
dir = "S"
538-
if (controllerWindDir == 40)
539-
dir = "SW"
540-
if (controllerWindDir == 48)
541-
dir = "W"
542-
if (controllerWindDir == 56)
543-
dir = "NW"
544-
526+
dir = getControllerWindDirString(controllerWindDir);
545527

546528
let controllerWindDirElement = document.getElementById(ID_WIND_DIR);
547529
if (controllerWindDirElement != null)
548530
controllerWindDirElement.innerText = dir;
549531
let controllerWindDirInfowElement = document.getElementById("infow-wind_dir");
550532
if (controllerWindDirInfowElement != null)
551-
controllerWindDirInfowElement.innerText = weatherStationStatus[ID_WIND_DIR];
533+
controllerWindDirInfowElement.innerText = dir;
552534

553535
// Update the rain value.
554536
controllerRainDiff = weatherStationStatus[ID_RAIN];
@@ -577,6 +559,26 @@ function updateWeatherStation(response) {
577559
controllerTemperatureElement.innerText = weatherStationStatus[ID_TEMPERATURE];
578560
}
579561

562+
function getControllerWindDirString (controllerWindDir){
563+
if (controllerWindDir == 0)
564+
return "N";
565+
else if (controllerWindDir == 8)
566+
return "NE";
567+
else if (controllerWindDir == 16)
568+
return "E";
569+
else if (controllerWindDir == 24)
570+
return "SE";
571+
else if (controllerWindDir == 32)
572+
return "S";
573+
else if (controllerWindDir == 40)
574+
return "SW";
575+
else if (controllerWindDir == 48)
576+
return "W";
577+
else if (controllerWindDir == 56)
578+
return "NW";
579+
}
580+
581+
580582
// Updates the water tank information based on the given response.
581583
function updateWaterTank(response) {
582584
if (response[ID_STATUS] == null || response[ID_STATUS][ID_TANK] == null)
@@ -697,7 +699,7 @@ function getControllerInfoWindowContent() {
697699
content = content.replace("@@WIND@@", "-");
698700
// Update the wind direction value.
699701
if (controllerWindDir != null)
700-
content = content.replace("@@WIND_DIR@@", controllerWindDir);
702+
content = content.replace("@@WIND_DIR@@", getControllerWindDirString(controllerWindDir));
701703
else
702704
content = content.replace("@@WIND_DIR@@", "-");
703705
// Update the rain value.

0 commit comments

Comments
 (0)