-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vcoman/ces demo #6
base: master
Are you sure you want to change the base?
Changes from 1 commit
5e998f0
47f7eac
4cb358e
96697d5
cdb8ce0
6c88f65
464fdfe
971c6a9
4a20395
fcb4c35
3c8bbb9
be00e8b
43d9741
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
option_settings: | ||
aws:elasticbeanstalk:container:python: | ||
WSGIPath: agriculturecommon.wsgi:application | ||
aws:elasticbeanstalk:environment:proxy:staticfiles: | ||
/static: static |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
# Elastic Beanstalk Files | ||
.elasticbeanstalk/* | ||
!.elasticbeanstalk/*.cfg.yml | ||
!.elasticbeanstalk/*.global.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
web: gunicorn --bind :8000 --workers 3 --threads 2 agriculturecommon.wsgi:application | ||
websocket: daphne -b :: -p 5000 agriculturecommon.asgi:application |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,8 +88,10 @@ <h6 class="card-title">Weather station</h6> | |
<td><span class="digi-icon-color fas fa-sun fa-2x"></span></td> | ||
</tr> | ||
<tr> | ||
<td><span id="wind_speed"><i class="fas fa-circle-notch fa-spin"></i></span> km/h</td> | ||
<td><span id="rain_diff"><i class="fas fa-circle-notch fa-spin"></i></span> L/m²</td> | ||
<td><span id="wind_speed"><i class="fas fa-circle-notch fa-spin"></i></span> km/h (<span id="wind_direction"><i class="fas fa-circle-notch fa-spin"></i></span>) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either fill this space with the tag contained in the or put the tag right after the to avoid having this blank line. |
||
</td> | ||
<td><span id="rain_acc"><i class="fas fa-circle-notch fa-spin"></i></span> L/m²</td> | ||
<td><span id="luminosity"><i class="fas fa-circle-notch fa-spin"></i></span> lux</td> | ||
</tr> | ||
</tbody> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file should not be committed, remove it. |
||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
</head> | ||
<body> | ||
|
||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this file required? |
||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
</head> | ||
<body> | ||
|
||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
arrow==0.12.1 | ||
asgiref==3.2.10 | ||
backports.functools-lru-cache==1.6.1 | ||
certifi==2018.4.16 | ||
channels==3.0.2 | ||
chardet==3.0.4 | ||
devicecloud==0.5.7 | ||
Django==3.1 | ||
idna==2.10 | ||
python-dateutil==2.7.5 | ||
pytz==2020.1 | ||
requests==2.20.1 | ||
six==1.14.0 | ||
sqlparse==0.3.1 | ||
urllib3==1.25.10 | ||
|
||
django-pjax~=1.7 | ||
arrow==0.12.1 | ||
asgiref==3.2.10 | ||
backports.functools-lru-cache==1.6.1 | ||
certifi==2018.4.16 | ||
channels==3.0.3 | ||
chardet==3.0.4 | ||
devicecloud==0.5.7 | ||
Django==2.2 | ||
idna | ||
python-dateutil==2.7.5 | ||
pytz==2020.1 | ||
requests==2.20.1 | ||
six==1.14.0 | ||
sqlparse==0.3.1 | ||
urllib3 | ||
django-pjax~=1.7 | ||
supervisor==4.2.2 | ||
gunicorn==20.0.4 | ||
daphne==3.0.1 | ||
channels-redis==3.2.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,18 +292,18 @@ def main(): | |
|
||
# If Python version is greater than 3.7, install the corresponding | ||
# Twisted wheel so the channels module can be installed later on. | ||
if sys.platform == "win32" and py_minor_version > 7: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Undo these changes, these lines should not be commented. |
||
twisted = TWISTED_64 if is_64_bits_python() else TWISTED_32 | ||
twisted_path = os.path.join( | ||
FOLDER_WHEELS, | ||
twisted.format(py_major_version, py_minor_version)) | ||
print("- Installing Twisted wheel (%s)... " % twisted_path, end="") | ||
sys.stdout.flush() | ||
if run_venv_python(venv_context, ['-m', 'pip', 'install', | ||
twisted_path], debug) != 0: | ||
print_error() | ||
sys.exit(-1) | ||
print_success() | ||
# if sys.platform == "win32" and py_minor_version > 7: | ||
# twisted = TWISTED_64 if is_64_bits_python() else TWISTED_32 | ||
# twisted_path = os.path.join( | ||
# FOLDER_WHEELS, | ||
# twisted.format(py_major_version, py_minor_version)) | ||
# print("- Installing Twisted wheel (%s)... " % twisted_path, end="") | ||
# sys.stdout.flush() | ||
# if run_venv_python(venv_context, ['-m', 'pip', 'install', | ||
# twisted_path], debug) != 0: | ||
# print_error() | ||
# sys.exit(-1) | ||
# print_success() | ||
|
||
# Install the application requirements. | ||
print("- Installing application requirements: ") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,8 @@ const INFO_WINDOW_CONTENT_CONTROLLER = "" + | |
" <span class='digi-icon-color fas fa-wind fa-2x'></span>" + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don´t know how to put this comment in source3.zip and source4.zip, so I put it here: Those files should not be committed. |
||
" </div>" + | ||
" <div class='marker-info-value'>" + | ||
" <span id='infow-wind'>@@WIND@@</span> km/h" + | ||
" <span id='infow-wind'>@@WIND@@</span> km/h (" + | ||
" <span id='infow-wind_dir'>@@WIND_DIR@@</span>)" + | ||
" </div>" + | ||
" </div>" + | ||
" <div class='marker-info-element'>" + | ||
|
@@ -87,10 +88,11 @@ const CLASS_STATUS_LOADING = "marker-info-value-status-loading"; | |
const CLASS_BUTTON_STATUS_OFF = "marker-info-button-off"; | ||
|
||
const ID_WIND = "wind_speed"; | ||
const ID_WIND_DIR = "wind_direction"; | ||
const ID_RADIATION = "radiation"; | ||
const ID_LUMINOSITY = "luminosity"; | ||
const ID_RAIN = "rain_diff"; | ||
const ID_RAIN_ACC = "rain"; | ||
const ID_RAIN_ACC = "rain_acc"; | ||
const ID_LEVEL = "level"; | ||
const ID_VALVE = "valve"; | ||
const ID_TEMPERATURE = "temperature"; | ||
|
@@ -103,7 +105,7 @@ const ID_STATIONS = "stations"; | |
const ID_WEATHER = "weather"; | ||
const ID_TANK = "tank"; | ||
|
||
const REFRESH_INTERVAL = 30000; | ||
const REFRESH_INTERVAL = 15000; | ||
|
||
const SUN_GREEN = "<i class='selected-icon-widget fas fa-sun'></i>"; | ||
const CLOUD_GREEN = "<i class='selected-icon-widget fas fa-cloud'></i>"; | ||
|
@@ -133,6 +135,7 @@ var stationMoistures = {}; | |
var stationBatteries = {}; | ||
var stationValves = {}; | ||
var controllerWind = null; | ||
var controllerWindDir = null; | ||
var controllerRain = null; | ||
var controllerRadiation = null; | ||
var controllerLuminosity = null; | ||
|
@@ -508,7 +511,7 @@ function updateWeatherStation(response) { | |
|
||
let weatherStationStatus = response[ID_STATUS][ID_WEATHER]; | ||
|
||
// Update the wind value. | ||
// Update the wind speed value. | ||
controllerWind = weatherStationStatus[ID_WIND]; | ||
let controllerWindElement = document.getElementById(ID_WIND); | ||
if (controllerWindElement != null) | ||
|
@@ -517,14 +520,41 @@ function updateWeatherStation(response) { | |
if (controllerWindInfowElement != null) | ||
controllerWindInfowElement.innerText = weatherStationStatus[ID_WIND]; | ||
|
||
// Update the wind direction value. | ||
controllerWindDir = weatherStationStatus[ID_WIND_DIR]; | ||
dir = ""; | ||
if (controllerWindDir = 0) | ||
dir = "N" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it's not mandatory in JavaScript, but better use |
||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I remember correctly, this was fixed in a later commit, but just in case, use == to compare in an if block. |
||
dir = "NW" | ||
|
||
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]; | ||
|
||
// Update the rain value. | ||
controllerRain = weatherStationStatus[ID_RAIN]; | ||
let controllerRainElement = document.getElementById(ID_RAIN); | ||
controllerRain = weatherStationStatus[ID_RAIN_ACC]; | ||
let controllerRainElement = document.getElementById(ID_RAIN_ACC); | ||
if (controllerRainElement != null) | ||
controllerRainElement.innerText = weatherStationStatus[ID_RAIN]; | ||
controllerRainElement.innerText = weatherStationStatus[ID_RAIN_ACC]; | ||
let controllerRainInfowElement = document.getElementById("infow-rain"); | ||
if (controllerRainInfowElement != null) | ||
controllerRainInfowElement.innerText = weatherStationStatus[ID_RAIN]; | ||
controllerRainInfowElement.innerText = weatherStationStatus[ID_RAIN_ACC]; | ||
|
||
// Update the luminosity value. | ||
controllerLuminosity = weatherStationStatus[ID_LUMINOSITY]; | ||
|
@@ -656,11 +686,16 @@ function getStationInfoWindowContent(stationID) { | |
function getControllerInfoWindowContent() { | ||
// Clone the content template. | ||
let content = INFO_WINDOW_CONTENT_CONTROLLER; | ||
// Update the wind value. | ||
// Update the wind speed value. | ||
if (controllerWind != null) | ||
content = content.replace("@@WIND@@", controllerWind); | ||
else | ||
content = content.replace("@@WIND@@", "-"); | ||
// Update the wind direction value. | ||
if (controllerWindDir != null) | ||
content = content.replace("@@WIND_DIR@@", controllerWindDir); | ||
else | ||
content = content.replace("@@WIND_DIR@@", "-"); | ||
// Update the rain value. | ||
if (controllerRain != null) | ||
content = content.replace("@@RAIN@@", controllerRain); | ||
|
@@ -919,7 +954,7 @@ function updateCurrentWeather() { | |
currentWeatherIcon = SUN_GREEN; | ||
currentWeatherStatus = "sunny"; | ||
|
||
rain = document.getElementById("rain_diff").innerText; | ||
rain = document.getElementById("rain_acc").innerText; | ||
rain = parseInt(rain) | ||
luminosity = document.getElementById("luminosity").innerText; | ||
luminosity = parseInt(luminosity) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,7 @@ var rainData; | |
var radiationData; | ||
var luminosityData; | ||
var temperatureData = {}; | ||
var temperatureDataG = {}; | ||
var moistureData = {}; | ||
var valveData = {}; | ||
|
||
|
@@ -128,6 +129,7 @@ function initCharts() { | |
rainData = null; | ||
radiationData = null; | ||
temperatureData = {}; | ||
temperatureDataG = {}; | ||
moistureData = {}; | ||
valveData = {}; | ||
|
||
|
@@ -175,7 +177,7 @@ function drawAllCharts(refresh=false, showProgress=true) { | |
// Repeat the task every minute. | ||
setTimeout(function() { | ||
drawAllCharts(true, false); | ||
}, 60000); | ||
}, 15000); | ||
} | ||
|
||
// Draws the wind chart. | ||
|
@@ -247,12 +249,12 @@ function drawTemperatureChartG(refresh=false, showProgress=false) { | |
if (showProgress) | ||
$("#temperature-chart-loading").show(); | ||
$.post("/ajax/get_temperature", getJsonData(temperatureInterval), function(response) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add fail callback. |
||
temperatureData = response.data; | ||
temperatureDataG = response.data; | ||
drawTemperatureChartG(); | ||
$("#temperature-chart-loading").hide(); | ||
}); | ||
} else { | ||
drawChart("temperature-chart", temperatureData, "Temperature", "ºC", "#FF0000"); | ||
drawChart("temperature-chart", temperatureDataG, "Temperature", "ºC", "#FF0000"); | ||
} | ||
} | ||
|
||
|
@@ -350,7 +352,7 @@ function drawChart(id, data, title, units, color=null, data2=null, units2=null, | |
0: {title: units}, | ||
}, | ||
vAxis: { | ||
ticks: [{v: 0}, {v: 4}, {v: 8}, {v: 12}, {v: 16}, {v: 20}, {v: 24}, {v: 28} ] | ||
ticks: [{v: 0}, {v: 8}, {v: 16}, {v: 24}, {v: 32}, {v: 40}, {v: 48}, {v: 56} , {v: 64}] | ||
}, | ||
legend: { position: 'bottom' } | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be committed.