try_plc_checker.py 8.34 KB

import logging
import json
from monitoring.plc_checker import PlcChecker

plc_status = {
          "entity_name": "PLC_STATUS",
          "from": "Beckhoff",
          "version_firmware": "20170809",
          "site": "OSM-Mexico",
          "date": "2017-03-03T13:45:00",
          "devices": [
            {
              "device_name": "WXT520",
              "device_type": "meteo",
              "serial_number": "14656423",
              "valid": "yes",
              "device_values": [
                {
                  "name": "OutsideTemp",
                  "type": "float",
                  "value": 12.12,
                  "unit": "Celcius",
                  "comment": ""
                },
                {
                  "name": "OutsideHumidity",
                  "type": "float",
                  "value": 64.1,
                  "unit": "percent",
                  "comment": ""
                },
                {
                  "name": "Pressure",
                  "type": "float",
                  "value": 769.2,
                  "unit": "mbar",
                  "comment": "At site elevation"
                },
                {
                  "name": "RainRate",
                  "type": "float",
                  "value": 0,
                  "unit": "mm/h",
                  "comment": ""
                },
                {
                  "name": "WindSpeed",
                  "type": "float",
                  "value": 3.1,
                  "unit": "m/s",
                  "comment": ""
                },
                {
                  "name": "WindDir",
                  "type": "float",
                  "value": 202.3,
                  "unit": "deg",
                  "comment": "(N=0, E=90)"
                },
                {
                  "name": "DewPoint",
                  "type": "float",
                  "value": 8.3,
                  "unit": "deg",
                  "comment": ""
                }
              ]
            },
            {
              "device_name": "DRD11",
              "device_type": "meteo",
              "serial_number": "RET6789",
              "valid": "yes",
              "device_values": [
                {
                  "name": "analog",
                  "type": "float",
                  "value": 2.345,
                  "unit": "V",
                  "comment": "3V=Dry <2.5V=Rain"
                },
                {
                  "name": "digital",
                  "type": "int",
                  "value": 1,
                  "unit": "bool",
                  "comment": "1=Dry 0=Rain"
                }
              ]
            },
            {
              "device_name": "DRD11",
              "device_type": "meteo",
              "serial_number": "RET6007",
              "valid": "yes",
              "device_values": [
                {
                  "name": "analog",
                  "type": "float",
                  "value": 3.412,
                  "unit": "V",
                  "comment": "3V=Dry <2.5V=Rain"
                },
                {
                  "name": "digital",
                  "type": "int",
                  "value": 1,
                  "unit": "bool",
                  "comment": "1=Dry 0=Rain"
                }
              ]
            },
            {
              "device_name": "VantagePro",
              "device_type": "meteo",
              "serial_number": "ERTRY2344324",
              "valid": "no",
              "device_values": [
                {
                  "name": "OutsideTemp",
                  "type": "float",
                  "value": 12.45,
                  "unit": "Celcius",
                  "comment": ""
                },
                {
                  "name": "InsideTemp",
                  "type": "float",
                  "value": 20.28,
                  "unit": "Celcius",
                  "comment": ""
                },
                {
                  "name": "OutsideHumidity",
                  "type": "float",
                  "value": 65.3,
                  "unit": "percent",
                  "comment": ""
                },
                {
                  "name": "InsideHumidity",
                  "type": "float",
                  "value": 45.6,
                  "unit": "percent",
                  "comment": ""
                },
                {
                  "name": "Pressure",
                  "type": "float",
                  "value": 768.7,
                  "unit": "mbar",
                  "comment": "At site elevation"
                },
                {
                  "name": "RainRate",
                  "type": "float",
                  "value": 0,
                  "unit": "mm/h",
                  "comment": ""
                },
                {
                  "name": "WindSpeed",
                  "type": "float",
                  "value": 2.8,
                  "unit": "m/s",
                  "comment": ""
                },
                {
                  "name": "WindDir",
                  "type": "float",
                  "value": 207,
                  "unit": "deg",
                  "comment": "(N=0, E=90)"
                },
                {
                  "name": "WindDirCardinal",
                  "type": "string",
                  "value": "SW",
                  "unit": "string",
                  "comment": ""
                },
                {
                  "name": "DewPoint",
                  "type": "float",
                  "value": 8.5,
                  "unit": "deg",
                  "comment": ""
                }
              ]
            },
            {
              "device_name": "MLX90614-1",
              "device_type": "meteo",
              "serial_number": "Unknown",
              "valid": "yes",
              "device_values": [
                {
                  "name": "SensorTemperature",
                  "type": "float",
                  "value": 23.56,
                  "unit": "Celcius",
                  "comment": ""
                },
                {
                  "name": "SkyTemperature",
                  "type": "float",
                  "value": -15.67,
                  "unit": "Celcius",
                  "comment": "Clear<-10 VeryCloudy>4"
                }
              ]
            },
            {
              "device_name": "LAMP_FLAT_CAGIRE",
              "device_type": "calib",
              "serial_number": "REF_3434",
              "valid": "yes",
              "device_values": [
                {
                  "name": "status",
                  "type": "string",
                  "value": "on",
                  "unit": "string",
                  "comment": "on or off"
                },
                {
                  "name": "current",
                  "type": "float",
                  "value": 0.234,
                  "unit": "Ampere",
                  "comment": ""
                }
              ]
            },
            {
              "device_name": "Shutter",
              "device_type": "Astelco",
              "serial_number": "45842",
              "valid": "yes",
              "device_values": [
                {
                  "name": "Left",
                  "type": "string",
                  "value": "Closed",
                  "unit": "",
                  "comment": ""
                },
                {
                  "name": "Right",
                  "type": "string",
                  "value": "Intermediate",
                  "unit": "",
                  "comment": ""
                }
              ]
            },
            {
              "device_name": "Dome",
              "device_type": "Astelco",
              "serial_number": "45845",
              "valid": "yes",
              "device_values": [
                {
                  "name": "Azimuth",
                  "type": "float",
                  "value": 145.6,
                  "unit": "deg",
                  "comment": "0=North, 90=East"
                },
                {
                  "name": "Acceleration",
                  "type": "float",
                  "value": 8,
                  "unit": "deg/s2",
                  "comment": ""
                }
              ]
            }
          ]
        }

my_checker = PlcChecker(plc_status)
my_checker.scan_sensors()
print(json.dumps(my_checker.captors_conf, indent=4))