Commit 9bb6a2a92085e8865aff1def76548fcb3d89e780

Authored by Patrick Maeght
1 parent a38006df
Exists in dev

colibri-new-fixed

simulators/plc/colibri-new-fixed-2.json 0 → 100644
... ... @@ -0,0 +1,417 @@
  1 +{
  2 + "statuses": [
  3 + {
  4 + "frame_model": "1.0",
  5 + "name_creator": "PyROS",
  6 + "version_creator": "20120812.3456",
  7 + "entities": [
  8 + {
  9 + "entity_name": "SOFT_AGENT",
  10 + "from": "PyROS",
  11 + "version_firmware": "20180910",
  12 + "site": "OSM-Mexico",
  13 + "date": "2017-03-03T13:45:00",
  14 + "devices": [
  15 + {
  16 + "device_name": "Monitoring",
  17 + "device_type": "Agent",
  18 + "serial_number": "",
  19 + "valid": "yes",
  20 + "device_values": [
  21 + {
  22 + "name": "Version",
  23 + "type": "string",
  24 + "value": "20190812.3456",
  25 + "unit": "Cal.Ver",
  26 + "comment": "YYYYMMDD.number"
  27 + }
  28 + ]
  29 + },
  30 + {
  31 + "device_name": "Scheduler",
  32 + "type": "Agent",
  33 + "serial_number": "",
  34 + "valid": "yes",
  35 + "device_values": [
  36 + {
  37 + "name": "Version",
  38 + "type": "string",
  39 + "value": "20120812.0123",
  40 + "unit": "Cal.Ver",
  41 + "comment": "YYYYMMDD.number"
  42 + }
  43 + ]
  44 + }
  45 + ]
  46 + },
  47 + {
  48 + "entity_name": "DOME_STATUS",
  49 + "from": "PyROS",
  50 + "version_firmware": "20180910",
  51 + "site": "OSM-Mexico",
  52 + "date": "2017-03-03T13:45:00",
  53 + "devices": [
  54 + {
  55 + "device_name": "Shutter",
  56 + "device_type": "Astelco",
  57 + "serial_number": "45842",
  58 + "valid": "yes",
  59 + "device_values": [
  60 + {
  61 + "name": "Left",
  62 + "type": "string",
  63 + "value": "Closed",
  64 + "unit": "",
  65 + "comment": ""
  66 + },
  67 + {
  68 + "name": "Right",
  69 + "type": "string",
  70 + "value": "Intermediate",
  71 + "unit": "",
  72 + "comment": ""
  73 + }
  74 + ]
  75 + },
  76 + {
  77 + "device_name": "Dome",
  78 + "device_type": "Astelco",
  79 + "serial_number": "45845",
  80 + "valid": "yes",
  81 + "device_values": [
  82 + {
  83 + "name": "Azimuth",
  84 + "type": "float",
  85 + "value": 145.6,
  86 + "unit": "deg",
  87 + "comment": "0=North, 90=East"
  88 + },
  89 + {
  90 + "name": "Acceleration",
  91 + "type": "float",
  92 + "value": 8,
  93 + "unit": "deg/s2",
  94 + "comment": ""
  95 + }
  96 + ]
  97 + }
  98 + ]
  99 + },
  100 + {
  101 + "entity_name": "IMAGE_STATUS",
  102 + "from": "Cagire",
  103 + "version_firmware": "20180910",
  104 + "site": "OSM-Mexico",
  105 + "date": "2017-03-03T13:45:00",
  106 + "devices": [
  107 + {
  108 + "device_name": "IM_20230910_123412",
  109 + "device_type": "image",
  110 + "serial_number": "",
  111 + "valid": "yes",
  112 + "device_values": [
  113 + {
  114 + "name": "DATE-OBS",
  115 + "type": "string",
  116 + "value": "2023-09-10T12:34:56",
  117 + "unit": "ISO8601",
  118 + "comment": "Start exposure"
  119 + },
  120 + {
  121 + "name": "DATE-END",
  122 + "type": "string",
  123 + "value": "2023-09-10T12:38:12",
  124 + "unit": "ISO8601",
  125 + "comment": "End exposure"
  126 + }
  127 + ]
  128 + }
  129 + ]
  130 + }
  131 + ]
  132 + },
  133 + {
  134 + "frame_model": "1.0",
  135 + "name_creator": "PLC",
  136 + "version_creator": "20120812.3456",
  137 + "entities": [
  138 + {
  139 + "entity_name": "PLC_STATUS",
  140 + "from": "Beckhoff",
  141 + "version_firmware": "20170809",
  142 + "site": "OSM-Mexico",
  143 + "date": "2017-03-03T13:45:00",
  144 + "devices": [
  145 + {
  146 + "device_name": "WXT520",
  147 + "device_type": "meteo",
  148 + "serial_number": "14656423",
  149 + "valid": "yes",
  150 + "device_values": [
  151 + {
  152 + "name": "OutsideTemp",
  153 + "type": "float",
  154 + "value": 12.12,
  155 + "unit": "Celcius",
  156 + "comment": ""
  157 + },
  158 + {
  159 + "name": "OutsideHumidity",
  160 + "type": "float",
  161 + "value": 64.1,
  162 + "unit": "percent",
  163 + "comment": ""
  164 + },
  165 + {
  166 + "name": "Pressure",
  167 + "type": "float",
  168 + "value": 769.2,
  169 + "unit": "mbar",
  170 + "comment": "At site elevation"
  171 + },
  172 + {
  173 + "name": "RainRate",
  174 + "type": "float",
  175 + "value": 0,
  176 + "unit": "mm/h",
  177 + "comment": ""
  178 + },
  179 + {
  180 + "name": "WindSpeed",
  181 + "type": "float",
  182 + "value": 3.1,
  183 + "unit": "m/s",
  184 + "comment": ""
  185 + },
  186 + {
  187 + "name": "WindDir",
  188 + "type": "float",
  189 + "value": 202.3,
  190 + "unit": "deg",
  191 + "comment": "(N=0, E=90)"
  192 + },
  193 + {
  194 + "name": "DewPoint",
  195 + "type": "float",
  196 + "value": 8.3,
  197 + "unit": "deg",
  198 + "comment": ""
  199 + }
  200 + ]
  201 + },
  202 + {
  203 + "device_name": "DRD11",
  204 + "device_type": "meteo",
  205 + "serial_number": "RET6789",
  206 + "valid": "yes",
  207 + "device_values": [
  208 + {
  209 + "name": "analog",
  210 + "type": "float",
  211 + "value": 2.345,
  212 + "unit": "V",
  213 + "comment": "3V=Dry <2.5V=Rain"
  214 + },
  215 + {
  216 + "name": "digital",
  217 + "type": "int",
  218 + "value": 1,
  219 + "unit": "bool",
  220 + "comment": "1=Dry 0=Rain"
  221 + }
  222 + ]
  223 + },
  224 + {
  225 + "device_name": "DRD11",
  226 + "device_type": "meteo",
  227 + "serial_number": "RET6007",
  228 + "valid": "yes",
  229 + "device_values": [
  230 + {
  231 + "name": "analog",
  232 + "type": "float",
  233 + "value": 3.412,
  234 + "unit": "V",
  235 + "comment": "3V=Dry <2.5V=Rain"
  236 + },
  237 + {
  238 + "name": "digital",
  239 + "type": "int",
  240 + "value": 1,
  241 + "unit": "bool",
  242 + "comment": "1=Dry 0=Rain"
  243 + }
  244 + ]
  245 + },
  246 + {
  247 + "device_name": "VantagePro",
  248 + "device_type": "meteo",
  249 + "serial_number": "ERTRY2344324",
  250 + "valid": "no",
  251 + "device_values": [
  252 + {
  253 + "name": "OutsideTemp",
  254 + "type": "float",
  255 + "value": 12.45,
  256 + "unit": "Celcius",
  257 + "comment": ""
  258 + },
  259 + {
  260 + "name": "InsideTemp",
  261 + "type": "float",
  262 + "value": 20.28,
  263 + "unit": "Celcius",
  264 + "comment": ""
  265 + },
  266 + {
  267 + "name": "OutsideHumidity",
  268 + "type": "float",
  269 + "value": 65.3,
  270 + "unit": "percent",
  271 + "comment": ""
  272 + },
  273 + {
  274 + "name": "InsideHumidity",
  275 + "type": "float",
  276 + "value": 45.6,
  277 + "unit": "percent",
  278 + "comment": ""
  279 + },
  280 + {
  281 + "name": "Pressure",
  282 + "type": "float",
  283 + "value": 768.7,
  284 + "unit": "mbar",
  285 + "comment": "At site elevation"
  286 + },
  287 + {
  288 + "name": "RainRate",
  289 + "type": "float",
  290 + "value": 0,
  291 + "unit": "mm/h",
  292 + "comment": ""
  293 + },
  294 + {
  295 + "name": "WindSpeed",
  296 + "type": "float",
  297 + "value": 2.8,
  298 + "unit": "m/s",
  299 + "comment": ""
  300 + },
  301 + {
  302 + "name": "WindDir",
  303 + "type": "float",
  304 + "value": 207,
  305 + "unit": "deg",
  306 + "comment": "(N=0, E=90)"
  307 + },
  308 + {
  309 + "name": "WindDirCardinal",
  310 + "type": "string",
  311 + "value": "SW",
  312 + "unit": "string",
  313 + "comment": ""
  314 + },
  315 + {
  316 + "name": "DewPoint",
  317 + "type": "float",
  318 + "value": 8.5,
  319 + "unit": "deg",
  320 + "comment": ""
  321 + }
  322 + ]
  323 + },
  324 + {
  325 + "device_name": "MLX90614-1",
  326 + "device_type": "meteo",
  327 + "serial_number": "Unknown",
  328 + "valid": "yes",
  329 + "device_values": [
  330 + {
  331 + "name": "SensorTemperature",
  332 + "type": "float",
  333 + "value": 23.56,
  334 + "unit": "Celcius",
  335 + "comment": ""
  336 + },
  337 + {
  338 + "name": "SkyTemperature",
  339 + "type": "float",
  340 + "value": -15.67,
  341 + "unit": "Celcius",
  342 + "comment": "Clear<-10 VeryCloudy>4"
  343 + }
  344 + ]
  345 + },
  346 + {
  347 + "device_name": "LAMP_FLAT_CAGIRE",
  348 + "device_type": "calib",
  349 + "serial_number": "REF_3434",
  350 + "valid": "yes",
  351 + "device_values": [
  352 + {
  353 + "name": "status",
  354 + "type": "string",
  355 + "value": "on",
  356 + "unit": "string",
  357 + "comment": "on or off"
  358 + },
  359 + {
  360 + "name": "current",
  361 + "type": "float",
  362 + "value": 0.234,
  363 + "unit": "Ampere",
  364 + "comment": ""
  365 + }
  366 + ]
  367 + },
  368 + {
  369 + "device_name": "Shutter",
  370 + "device_type": "Astelco",
  371 + "serial_number": "45842",
  372 + "valid": "yes",
  373 + "device_values": [
  374 + {
  375 + "name": "Left",
  376 + "type": "string",
  377 + "value": "Closed",
  378 + "unit": "",
  379 + "comment": ""
  380 + },
  381 + {
  382 + "name": "Right",
  383 + "type": "string",
  384 + "value": "Intermediate",
  385 + "unit": "",
  386 + "comment": ""
  387 + }
  388 + ]
  389 + },
  390 + {
  391 + "device_name": "Dome",
  392 + "device_type": "Astelco",
  393 + "serial_number": "45845",
  394 + "valid": "yes",
  395 + "device_values": [
  396 + {
  397 + "name": "Azimuth",
  398 + "type": "float",
  399 + "value": 145.6,
  400 + "unit": "deg",
  401 + "comment": "0=North, 90=East"
  402 + },
  403 + {
  404 + "name": "Acceleration",
  405 + "type": "float",
  406 + "value": 8,
  407 + "unit": "deg/s2",
  408 + "comment": ""
  409 + }
  410 + ]
  411 + }
  412 + ]
  413 + }
  414 + ]
  415 + }
  416 + ]
  417 +}
... ...
src/dashboard/views.py
... ... @@ -176,7 +176,7 @@ def weather_current_old(request):
176 176 weather_info = WeatherWatch.objects.order_by("-id")[:monitoring] # Use 300 seconds by default with an iteration every 5 seconds # Get the number of data available
177 177 else:
178 178 weather_info = None
179   - return render(request, 'dashboard/current_weather.html', {'weather_info' : weather_info, 'iteration' : monitoring})
  179 + return render(request, 'dashboard/current_weather.html', {'weather_info' : site_current, 'iteration' : monitoring})
180 180 except Config.DoesNotExist:
181 181 return render(request, 'dashboard/current_weather.html', {'weather_info' : None, 'iteration' : 60})
182 182  
... ...
src/monitoring/plc_checker.py 0 → 100644
... ... @@ -0,0 +1,45 @@
  1 +
  2 +import logging
  3 +
  4 +logger = logging.getLogger(__name__)
  5 +
  6 +class PlcChecker(object):
  7 +
  8 + def __init__(self, plc_struct):
  9 + self.struct = plc_struct
  10 + self.path_list = None
  11 + #self.plc_global = copy.copy(self.struct["devices"])
  12 + #self.struct
  13 + self.captors = [
  14 + "OutsideTemp",
  15 + "InsideTemp",
  16 + "OutsideHumidity",
  17 + "InsideHumidity",
  18 + "Pressure",
  19 + "RainRate",
  20 + "WindSpeed",
  21 + "WindDir",
  22 + "WindDirCardinal",
  23 + "DewPoint",
  24 + ]
  25 + self.captors_conf = {}
  26 +
  27 + def scan_captors(self):
  28 + logger.debug(self.struct["date"])
  29 + for captor_type in self.captors:
  30 + self.captors_conf[captor_type] = {}
  31 + logger.debug(captor_type + ":")
  32 + self.cross_devices_list(captor_type)
  33 +
  34 + def cross_devices_list(self, captor_type):
  35 + """"""
  36 + for device in self.struct["devices"]:
  37 + if device["device_name"] != "GLOBAL" and device["device_type"] == "meteo" and device["valid"] == "yes":
  38 + self.cros_captor_list(device, captor_type)
  39 +
  40 + def cros_captor_list(self, device, captor_type):
  41 + device_id = device["device_name"] + "/" + device["serial_number"]
  42 + for captor in device["device_values"]:
  43 + if captor["name"] == captor_type:
  44 + self.captors_conf[captor_type][device_id] = captor["value"]
  45 + logger.debug("-- " + device_id + " : " + str(captor["value"]))
0 46 \ No newline at end of file
... ...
src/monitoring/test_plc_checker.py deleted
... ... @@ -1,4 +0,0 @@
1   -
2   -
3   -import json
4   -
src/monitoring/try_plc_checker.py 0 → 100644
... ... @@ -0,0 +1,286 @@
  1 +
  2 +import logging
  3 +import json
  4 +from monitoring.plc_checker import PlcChecker
  5 +
  6 +plc_status = {
  7 + "entity_name": "PLC_STATUS",
  8 + "from": "Beckhoff",
  9 + "version_firmware": "20170809",
  10 + "site": "OSM-Mexico",
  11 + "date": "2017-03-03T13:45:00",
  12 + "devices": [
  13 + {
  14 + "device_name": "WXT520",
  15 + "device_type": "meteo",
  16 + "serial_number": "14656423",
  17 + "valid": "yes",
  18 + "device_values": [
  19 + {
  20 + "name": "OutsideTemp",
  21 + "type": "float",
  22 + "value": 12.12,
  23 + "unit": "Celcius",
  24 + "comment": ""
  25 + },
  26 + {
  27 + "name": "OutsideHumidity",
  28 + "type": "float",
  29 + "value": 64.1,
  30 + "unit": "percent",
  31 + "comment": ""
  32 + },
  33 + {
  34 + "name": "Pressure",
  35 + "type": "float",
  36 + "value": 769.2,
  37 + "unit": "mbar",
  38 + "comment": "At site elevation"
  39 + },
  40 + {
  41 + "name": "RainRate",
  42 + "type": "float",
  43 + "value": 0,
  44 + "unit": "mm/h",
  45 + "comment": ""
  46 + },
  47 + {
  48 + "name": "WindSpeed",
  49 + "type": "float",
  50 + "value": 3.1,
  51 + "unit": "m/s",
  52 + "comment": ""
  53 + },
  54 + {
  55 + "name": "WindDir",
  56 + "type": "float",
  57 + "value": 202.3,
  58 + "unit": "deg",
  59 + "comment": "(N=0, E=90)"
  60 + },
  61 + {
  62 + "name": "DewPoint",
  63 + "type": "float",
  64 + "value": 8.3,
  65 + "unit": "deg",
  66 + "comment": ""
  67 + }
  68 + ]
  69 + },
  70 + {
  71 + "device_name": "DRD11",
  72 + "device_type": "meteo",
  73 + "serial_number": "RET6789",
  74 + "valid": "yes",
  75 + "device_values": [
  76 + {
  77 + "name": "analog",
  78 + "type": "float",
  79 + "value": 2.345,
  80 + "unit": "V",
  81 + "comment": "3V=Dry <2.5V=Rain"
  82 + },
  83 + {
  84 + "name": "digital",
  85 + "type": "int",
  86 + "value": 1,
  87 + "unit": "bool",
  88 + "comment": "1=Dry 0=Rain"
  89 + }
  90 + ]
  91 + },
  92 + {
  93 + "device_name": "DRD11",
  94 + "device_type": "meteo",
  95 + "serial_number": "RET6007",
  96 + "valid": "yes",
  97 + "device_values": [
  98 + {
  99 + "name": "analog",
  100 + "type": "float",
  101 + "value": 3.412,
  102 + "unit": "V",
  103 + "comment": "3V=Dry <2.5V=Rain"
  104 + },
  105 + {
  106 + "name": "digital",
  107 + "type": "int",
  108 + "value": 1,
  109 + "unit": "bool",
  110 + "comment": "1=Dry 0=Rain"
  111 + }
  112 + ]
  113 + },
  114 + {
  115 + "device_name": "VantagePro",
  116 + "device_type": "meteo",
  117 + "serial_number": "ERTRY2344324",
  118 + "valid": "no",
  119 + "device_values": [
  120 + {
  121 + "name": "OutsideTemp",
  122 + "type": "float",
  123 + "value": 12.45,
  124 + "unit": "Celcius",
  125 + "comment": ""
  126 + },
  127 + {
  128 + "name": "InsideTemp",
  129 + "type": "float",
  130 + "value": 20.28,
  131 + "unit": "Celcius",
  132 + "comment": ""
  133 + },
  134 + {
  135 + "name": "OutsideHumidity",
  136 + "type": "float",
  137 + "value": 65.3,
  138 + "unit": "percent",
  139 + "comment": ""
  140 + },
  141 + {
  142 + "name": "InsideHumidity",
  143 + "type": "float",
  144 + "value": 45.6,
  145 + "unit": "percent",
  146 + "comment": ""
  147 + },
  148 + {
  149 + "name": "Pressure",
  150 + "type": "float",
  151 + "value": 768.7,
  152 + "unit": "mbar",
  153 + "comment": "At site elevation"
  154 + },
  155 + {
  156 + "name": "RainRate",
  157 + "type": "float",
  158 + "value": 0,
  159 + "unit": "mm/h",
  160 + "comment": ""
  161 + },
  162 + {
  163 + "name": "WindSpeed",
  164 + "type": "float",
  165 + "value": 2.8,
  166 + "unit": "m/s",
  167 + "comment": ""
  168 + },
  169 + {
  170 + "name": "WindDir",
  171 + "type": "float",
  172 + "value": 207,
  173 + "unit": "deg",
  174 + "comment": "(N=0, E=90)"
  175 + },
  176 + {
  177 + "name": "WindDirCardinal",
  178 + "type": "string",
  179 + "value": "SW",
  180 + "unit": "string",
  181 + "comment": ""
  182 + },
  183 + {
  184 + "name": "DewPoint",
  185 + "type": "float",
  186 + "value": 8.5,
  187 + "unit": "deg",
  188 + "comment": ""
  189 + }
  190 + ]
  191 + },
  192 + {
  193 + "device_name": "MLX90614-1",
  194 + "device_type": "meteo",
  195 + "serial_number": "Unknown",
  196 + "valid": "yes",
  197 + "device_values": [
  198 + {
  199 + "name": "SensorTemperature",
  200 + "type": "float",
  201 + "value": 23.56,
  202 + "unit": "Celcius",
  203 + "comment": ""
  204 + },
  205 + {
  206 + "name": "SkyTemperature",
  207 + "type": "float",
  208 + "value": -15.67,
  209 + "unit": "Celcius",
  210 + "comment": "Clear<-10 VeryCloudy>4"
  211 + }
  212 + ]
  213 + },
  214 + {
  215 + "device_name": "LAMP_FLAT_CAGIRE",
  216 + "device_type": "calib",
  217 + "serial_number": "REF_3434",
  218 + "valid": "yes",
  219 + "device_values": [
  220 + {
  221 + "name": "status",
  222 + "type": "string",
  223 + "value": "on",
  224 + "unit": "string",
  225 + "comment": "on or off"
  226 + },
  227 + {
  228 + "name": "current",
  229 + "type": "float",
  230 + "value": 0.234,
  231 + "unit": "Ampere",
  232 + "comment": ""
  233 + }
  234 + ]
  235 + },
  236 + {
  237 + "device_name": "Shutter",
  238 + "device_type": "Astelco",
  239 + "serial_number": "45842",
  240 + "valid": "yes",
  241 + "device_values": [
  242 + {
  243 + "name": "Left",
  244 + "type": "string",
  245 + "value": "Closed",
  246 + "unit": "",
  247 + "comment": ""
  248 + },
  249 + {
  250 + "name": "Right",
  251 + "type": "string",
  252 + "value": "Intermediate",
  253 + "unit": "",
  254 + "comment": ""
  255 + }
  256 + ]
  257 + },
  258 + {
  259 + "device_name": "Dome",
  260 + "device_type": "Astelco",
  261 + "serial_number": "45845",
  262 + "valid": "yes",
  263 + "device_values": [
  264 + {
  265 + "name": "Azimuth",
  266 + "type": "float",
  267 + "value": 145.6,
  268 + "unit": "deg",
  269 + "comment": "0=North, 90=East"
  270 + },
  271 + {
  272 + "name": "Acceleration",
  273 + "type": "float",
  274 + "value": 8,
  275 + "unit": "deg/s2",
  276 + "comment": ""
  277 + }
  278 + ]
  279 + }
  280 + ]
  281 + }
  282 +
  283 +my_checker = PlcChecker(plc_status)
  284 +my_checker.scan_captors()
  285 +print(json.dumps(my_checker.captors_conf, indent=4))
  286 +
... ...