Blame view

src/monitoring/plc_checker.py 1.47 KB
9bb6a2a9   Patrick Maeght   colibri-new-fixed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

import logging

logger = logging.getLogger(__name__)

class PlcChecker(object):

    def __init__(self, plc_struct):
        self.struct = plc_struct
        self.path_list = None
        #self.plc_global = copy.copy(self.struct["devices"])
        #self.struct
        self.captors = [
            "OutsideTemp",
            "InsideTemp",
            "OutsideHumidity",
            "InsideHumidity",
            "Pressure",
            "RainRate",
            "WindSpeed",
            "WindDir",
            "WindDirCardinal",
            "DewPoint",
        ]
        self.captors_conf = {}

    def scan_captors(self):
        logger.debug(self.struct["date"])
        for captor_type in self.captors:
            self.captors_conf[captor_type] = {}
            logger.debug(captor_type + ":")
            self.cross_devices_list(captor_type)

    def cross_devices_list(self, captor_type):
        """"""
        for device in self.struct["devices"]:
            if device["device_name"] != "GLOBAL" and device["device_type"] == "meteo" and device["valid"] == "yes":
                self.cros_captor_list(device, captor_type)

    def cros_captor_list(self, device, captor_type):
        device_id = device["device_name"] + "/" + device["serial_number"]
        for captor in device["device_values"]:
            if captor["name"] == captor_type:
                self.captors_conf[captor_type][device_id] = captor["value"]
                logger.debug("-- " + device_id + " : " + str(captor["value"]))