Commit 81cd16464440d47181924da096f76fb2d4e916a8

Authored by Patrick Maeght
1 parent ecca856b
Exists in dev

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
... ... @@ -167,19 +167,19 @@ def weather_current(request):
167 167 raise Http404("No WeatherWatch matches the given query.")
168 168  
169 169 def weather_config(request):
170   - """ PM 20180926 prototype whithout database
  170 + """ PM 20180926 prototype without database
171 171 http://127.0.0.1:8000/dashboard/weather/config
172 172 """
173 173 try:
174   - #import os
  174 + # Import PLC status sensor parser
175 175 from src.monitoring.plc_checker import PlcChecker
176   - #cur_dir = os.path.abspath(".")
  176 + # Parse PLC status in colibri-new-fixed-2.json
177 177 colibri_json = open("../simulators/plc/colibri-new-fixed-2.json")
178 178 colibri_struct = json.load(colibri_json)
179 179 plc_status = colibri_struct["statuses"][1]["entities"][0]
180 180 plc_checker = PlcChecker(plc_status)
181   - plc_checker.scan_captors()
182   -
  181 + plc_checker.scan_sensors()
  182 + # Return template with sensors list
183 183 return render(request, 'dashboard/config_weather.html', {'weather_config' : plc_checker.captors_conf, 'base_template' : "base.html"})
184 184 except Config.DoesNotExist:
185 185 return render(request, 'dashboard/config_weather.html', {'weather_info' : None})
... ...
src/monitoring/plc_checker.py
... ... @@ -24,7 +24,7 @@ class PlcChecker(object):
24 24 ]
25 25 self.captors_conf = {}
26 26  
27   - def scan_captors(self):
  27 + def scan_sensors(self):
28 28 try:
29 29 logger.debug(self.struct["date"])
30 30 except Exception as e:
... ...
src/monitoring/try_plc_checker.py
... ... @@ -281,6 +281,6 @@ plc_status = {
281 281 }
282 282  
283 283 my_checker = PlcChecker(plc_status)
284   -my_checker.scan_captors()
  284 +my_checker.scan_sensors()
285 285 print(json.dumps(my_checker.captors_conf, indent=4))
286 286  
... ...