Skip to content

Commit be00e8b

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

File tree

3 files changed

+31
-42
lines changed

3 files changed

+31
-42
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.

agriculture/static/js/history.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,9 @@ function drawChart(id, data, title, units, color=null, data2=null, units2=null,
349349
},
350350
vAxes: {
351351
// Adds titles to each axis.
352-
0: {title: units},
353-
},
354-
vAxis: {
355-
ticks: [{v: 0}, {v: 8}, {v: 16}, {v: 24}, {v: 32}, {v: 40}, {v: 48}, {v: 56} , {v: 64}]
352+
0: {title: units, ticks: [{v: 0}, {v: 8}, {v: 16}, {v: 24}, {v: 32}, {v: 40}, {v: 48}, {v: 56} , {v: 64}]}
356353
},
354+
357355
legend: { position: 'bottom' },
358356
tooltip: { ignoreBounds: true, isHtml: true, trigger: 'both' }
359357
};
@@ -366,13 +364,9 @@ function drawChart(id, data, title, units, color=null, data2=null, units2=null,
366364
},
367365
vAxes: {
368366
// Adds titles to each axis.
369-
0: {title: units}
370-
},
371-
vAxis: {
372-
viewWindow: {
373-
min: 0
374-
}
367+
0: {title: units, viewWindow: {min: 0}}
375368
},
369+
376370
legend: { position: 'bottom' },
377371
tooltip: { ignoreBounds: true, isHtml: true, trigger: 'both' }
378372
};
@@ -387,17 +381,10 @@ function drawChart(id, data, title, units, color=null, data2=null, units2=null,
387381
},
388382
vAxes: {
389383
// Adds titles to each axis.
390-
0: {title: units},
391-
1: {title: units2}
384+
0: {title: units, minValue: 0, ticks: [{v: 0}, {v: 8}, {v: 16}, {v: 24}, {v: 32}, {v: 40}, {v: 48}, {v: 56}]},
385+
1: {title: units2, minValue: 0, ticks: [{v: 0, f: 'N'}, {v: 8, f: 'NE'}, {v: 16, f: 'E'}, {v: 24, f: 'SE'}, {v: 32, f: 'S'}, {v: 40, f: 'SW'}, {v: 48, f: 'W'}, {v: 56, f: 'NW'}]}
392386
},
393387

394-
vAxes: [{
395-
minValue: 0,
396-
ticks: [{v: 0}, {v: 8}, {v: 16}, {v: 24}, {v: 32}, {v: 40}, {v: 48}, {v: 56} ]
397-
}, {
398-
minValue: 0,
399-
ticks: [{v: 0, f: 'N'}, {v: 8, f: 'NE'}, {v: 16, f: 'E'}, {v: 24, f: 'SE'}, {v: 32, f: 'S'}, {v: 40, f: 'SW'}, {v: 48, f: 'W'}, {v: 56, f: 'NW'} ]
400-
}],
401388
legend: { position: 'bottom' },
402389
tooltip: { ignoreBounds: true, isHtml: true, trigger: 'both' }
403390
};

0 commit comments

Comments
 (0)