From 81cd16464440d47181924da096f76fb2d4e916a8 Mon Sep 17 00:00:00 2001 From: pmaeght Date: Wed, 26 Sep 2018 14:51:17 +0200 Subject: [PATCH] weather_config prototype without database - Parse PLC status in colibri-new-fixed-2.json - Return template with sensors list - http://127.0.0.1:8000/dashboard/weather/config --- src/dashboard/views.py | 10 +++++----- src/monitoring/plc_checker.py | 2 +- src/monitoring/try_plc_checker.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dashboard/views.py b/src/dashboard/views.py index dfc6947..e0ed6b9 100644 --- a/src/dashboard/views.py +++ b/src/dashboard/views.py @@ -167,19 +167,19 @@ def weather_current(request): raise Http404("No WeatherWatch matches the given query.") def weather_config(request): - """ PM 20180926 prototype whithout database + """ PM 20180926 prototype without database http://127.0.0.1:8000/dashboard/weather/config """ try: - #import os + # Import PLC status sensor parser from src.monitoring.plc_checker import PlcChecker - #cur_dir = os.path.abspath(".") + # Parse PLC status in colibri-new-fixed-2.json 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() - + plc_checker.scan_sensors() + # Return template with sensors list return render(request, 'dashboard/config_weather.html', {'weather_config' : plc_checker.captors_conf, 'base_template' : "base.html"}) except Config.DoesNotExist: return render(request, 'dashboard/config_weather.html', {'weather_info' : None}) diff --git a/src/monitoring/plc_checker.py b/src/monitoring/plc_checker.py index 431dcdf..c09f152 100644 --- a/src/monitoring/plc_checker.py +++ b/src/monitoring/plc_checker.py @@ -24,7 +24,7 @@ class PlcChecker(object): ] self.captors_conf = {} - def scan_captors(self): + def scan_sensors(self): try: logger.debug(self.struct["date"]) except Exception as e: diff --git a/src/monitoring/try_plc_checker.py b/src/monitoring/try_plc_checker.py index 398aede..08f19cc 100644 --- a/src/monitoring/try_plc_checker.py +++ b/src/monitoring/try_plc_checker.py @@ -281,6 +281,6 @@ plc_status = { } my_checker = PlcChecker(plc_status) -my_checker.scan_captors() +my_checker.scan_sensors() print(json.dumps(my_checker.captors_conf, indent=4)) -- libgit2 0.21.2