diff --git a/simulators/plc/colibri-new-fixed-2.json b/simulators/plc/colibri-new-fixed-2.json
index c4f282a..13ba66a 100644
--- a/simulators/plc/colibri-new-fixed-2.json
+++ b/simulators/plc/colibri-new-fixed-2.json
@@ -247,7 +247,7 @@
"device_name": "VantagePro",
"device_type": "meteo",
"serial_number": "ERTRY2344324",
- "valid": "no",
+ "valid": "yes",
"device_values": [
{
"name": "OutsideTemp",
diff --git a/src/dashboard/templates/dashboard/config_weather.html b/src/dashboard/templates/dashboard/config_weather.html
new file mode 100644
index 0000000..1e6a4f3
--- /dev/null
+++ b/src/dashboard/templates/dashboard/config_weather.html
@@ -0,0 +1,47 @@
+
+
+
+
Weather config
+
+
+ Captors list:
+
+
+
Valid meteo devices
+
+
diff --git a/src/dashboard/urls.py b/src/dashboard/urls.py
index bf3de69..5f74ca0 100644
--- a/src/dashboard/urls.py
+++ b/src/dashboard/urls.py
@@ -11,6 +11,7 @@ urlpatterns = [
path('routines', views.routines, name="routines"),
path('weather', views.weather, name="weather"),
path('weather/current', views.weather_current, name="weather_current"),
+ path('weather/config', views.weather_config, name="weather_config"),
path('site', views.site, name="site"),
path('site/current', views.site_current, name="site_current"),
path('proposal', views.proposal, name='proposal'),
diff --git a/src/dashboard/views.py b/src/dashboard/views.py
index a58105e..3c79473 100644
--- a/src/dashboard/views.py
+++ b/src/dashboard/views.py
@@ -143,28 +143,44 @@ def weather(request):
def weather_current(request):
# PM 20180718
- if request.is_ajax():
- try:
- weather_status = WeatherWatch.objects.latest('updated')
- plc_device_status = PlcDeviceStatus.objects.exclude(plc_mode=None).latest('created')
- plc_mode = plc_device_status.plc_mode
- is_safe = plc_device_status.is_safe
- weather = serializers.serialize('json', [weather_status])
- weather = json.loads(weather)
- ack = Config.objects.get(id=1).ack
- plc_timeout = Config.objects.get(pk=1).plc_timeout_seconds
- timeout = (datetime.datetime.now() - plc_device_status.created).total_seconds()
- weather[0]['max_sunelev'] = SUN_ELEV_DAY_THRESHOLD
- weather[0]['sunelev'] = get_sunelev()
- weather[0]["plc_mode"] = plc_mode
- weather[0]["is_safe"] = is_safe
- weather[0]["ACK"] = ack
- weather[0]["plc_timeout"] = timeout
- weather[0]["max_plc_timeout"] = plc_timeout
- weather[0]["pyros_mode"] = Config.objects.get(id=1).pyros_state
- return HttpResponse(json.dumps(weather), content_type="application/json")
- except WeatherWatch.DoesNotExist:
- raise Http404("No WeatherWatch matches the given query.")
+ #if request.is_ajax():
+ try:
+ weather_status = WeatherWatch.objects.latest('updated')
+ plc_device_status = PlcDeviceStatus.objects.exclude(plc_mode=None).latest('created')
+ plc_mode = plc_device_status.plc_mode
+ is_safe = plc_device_status.is_safe
+ weather = serializers.serialize('json', [weather_status])
+ weather = json.loads(weather)
+ ack = Config.objects.get(id=1).ack
+ plc_timeout = Config.objects.get(pk=1).plc_timeout_seconds
+ timeout = (datetime.datetime.now() - plc_device_status.created).total_seconds()
+ weather[0]['max_sunelev'] = SUN_ELEV_DAY_THRESHOLD
+ weather[0]['sunelev'] = get_sunelev()
+ weather[0]["plc_mode"] = plc_mode
+ weather[0]["is_safe"] = is_safe
+ weather[0]["ACK"] = ack
+ weather[0]["plc_timeout"] = timeout
+ weather[0]["max_plc_timeout"] = plc_timeout
+ weather[0]["pyros_mode"] = Config.objects.get(id=1).pyros_state
+ return HttpResponse(json.dumps(weather), content_type="application/json")
+ except WeatherWatch.DoesNotExist:
+ raise Http404("No WeatherWatch matches the given query.")
+
+def weather_config(request):
+ # PM 20180926 prototype whithout database
+ try:
+ #import os
+ from src.monitoring.plc_checker import PlcChecker
+ #cur_dir = os.path.abspath(".")
+ colibri_json = open("../simulators/plc/colibri-new-fixed-2.json")
+ colibri_struct = json.load(colibri_json)
+ plc_status = colibri_struct["statuses"][1]["entities"][0]
+ plc_checker = PlcChecker(plc_status)
+ plc_checker.scan_captors()
+
+ return render(request, 'dashboard/config_weather.html', {'weather_config' : plc_checker.captors_conf})
+ except Config.DoesNotExist:
+ return render(request, 'dashboard/config_weather.html', {'weather_info' : None})
def weather_current_old(request):
try:
diff --git a/src/monitoring/plc_checker.py b/src/monitoring/plc_checker.py
index e5e8a75..431dcdf 100644
--- a/src/monitoring/plc_checker.py
+++ b/src/monitoring/plc_checker.py
@@ -25,11 +25,17 @@ class PlcChecker(object):
self.captors_conf = {}
def scan_captors(self):
- logger.debug(self.struct["date"])
+ try:
+ logger.debug(self.struct["date"])
+ except Exception as e:
+ logger.debug("No date")
for captor_type in self.captors:
self.captors_conf[captor_type] = {}
logger.debug(captor_type + ":")
- self.cross_devices_list(captor_type)
+ try:
+ self.cross_devices_list(captor_type)
+ except Exception as e:
+ logger.debug(captor_type + " error")
def cross_devices_list(self, captor_type):
""""""
--
libgit2 0.21.2