Exemplo n.º 1
0
 def __init__(self):
     self.sensorMutex = RLock()
     self.systemMutex = RLock()
     self.continueMonitoring = False
     self.onDataChanged = None
     self.onSystemInfo = None
     self.currentBusInfo = self.previousBusInfo = None
     self.currentSensorsInfo = self.previousSensorsInfo = None
     self.currentSystemInfo = self.previousSystemInfo = None
     self.cpuLoadValues = {}
     self.disabledSensors = {}
     self.sensorsRefreshCount = 0
     self.retrievingSystemInfo = False
     self.disabledSensorTable = "disabled_sensors"
     self.systemInfoRefreshList = []
     checkAllBus()
     self.gpio = GPIO()
     manager.addDeviceInstance("GPIO", "GPIO", "GPIO", self.gpio, [],
                               "system")
     manager.loadJsonDevices("rest")
     results = DbManager.Select(self.disabledSensorTable)
     if results:
         for row in results:
             self.disabledSensors[row[0]] = 1
     self.StartMonitoring()
Exemplo n.º 2
0
 def __init__(self):
     """Initialize the bus and sensor info and start monitoring sensor states"""
     self.sensorMutex = RLock()
     self.realTimeMutex = RLock()
     self.exiting = Event()
     self.onDataChanged = None
     self.systemData = []
     self.currentSystemState = []
     self.currentRealTimeData = {}                                
     self.queuedRealTimeData = {}
     self.disabledSensors = {}
     self.disabledSensorTable = "disabled_sensors"
     checkAllBus()
     self.gpio = GPIO()
     self.downloadSpeed = DownloadSpeed(Config(APP_SETTINGS))
     self.downloadSpeed.getDownloadSpeed()
     manager.addDeviceInstance("GPIO", "GPIO", "GPIO", self.gpio, [], "system")
     manager.loadJsonDevices("rest")
     results = DbManager.Select(self.disabledSensorTable)
     if results:
         for row in results:
             self.disabledSensors[row[0]] = 1
     self.realTimeMonitorRunning = False
     self.pluginManager = PluginManager(self.OnPluginChange)
     self.pluginManager.load_plugins()
     self.InitCallbacks()
     self.StartMonitoring()
Exemplo n.º 3
0
    def __init__(self, client):
        """Initialize the bus and sensor info and start monitoring sensor states"""
        self.cloudClient = client
        self.sensorMutex = RLock()
        self.realTimeMutex = RLock()
        self.exiting = Event()
        self.onDataChanged = None
        self.systemData = []
        self.currentSystemState = []
        self.currentRealTimeData = {}
        self.queuedRealTimeData = {}
        self.disabledSensors = {}
        self.disabledSensorTable = "disabled_sensors"
        checkAllBus()
        self.gpio = GPIO()
        # self.downloadSpeed = DownloadSpeed(Config(APP_SETTINGS))
        # self.downloadSpeed.getDownloadSpeed()
        manager.addDeviceInstance("GPIO", "GPIO", "GPIO", self.gpio, [],
                                  "system")

        manager.loadJsonDevices("rest")

        if not DYNAMIC_DEVICES:
            warn("loadJsonDevices is None")
            for sensor in sensors.values():
                # info('--------{} {} {}'.format(sensor['name'], sensor['description'], sensor['device']))
                self.AddSensor(sensor['name'], sensor['description'],
                               sensor['device'], sensor['args'])

        #
        # info(DYNAMIC_DEVICES)
        self.config = Config(APP_SETTINGS)
        self.clientId = self.config.get('Agent', 'ClientID', None)
        self.mqtt_dis_prefix = self.config.get('Agent', 'MQTT_DIS_PREFIX',
                                               "homeassistant")
        self.serial = self.cloudClient.hardware.Serial

        for name, device in DYNAMIC_DEVICES.items():

            for type in device['type']:
                if type in ['DAC', 'ADC']:
                    continue
                topic, message = self.AddMQTTSensorDevice(name, type, device)

                if self.cloudClient:
                    info("{} {}".format(topic, message))
                    self.cloudClient.EnqueuePacket(message, topic)
                # info(mqttsensor)

        results = DbManager.Select(self.disabledSensorTable)
        if results:
            for row in results:
                self.disabledSensors[row[0]] = 1
        self.realTimeMonitorRunning = False
        self.pluginManager = PluginManager(self.OnPluginChange)
        self.pluginManager.load_plugins()
        self.InitCallbacks()
        self.StartMonitoring()
Exemplo n.º 4
0
 def LoadData(self):
     with self.mutex:
         results = DbManager.Select(self.tablename)
         if results:
             for row in results:
                 #info('Row: ' + str(row))
                 #for each item already present in db add call AddScheduledItem with insert false
                 self.AddScheduledItem(loads(row[1]), False)
     return True
Exemplo n.º 5
0
 def __init__(self):
     """Initialize the bus and sensor info and start monitoring sensor states"""
     self.sensorMutex = RLock()
     self.exiting = Event()
     self.onDataChanged = None
     self.onSystemInfo = None
     self.systemData = []
     self.currentSystemState = []
     self.disabledSensors = {}
     self.disabledSensorTable = "disabled_sensors"
     checkAllBus()
     self.gpio = GPIO()
     manager.addDeviceInstance("GPIO", "GPIO", "GPIO", self.gpio, [], "system")
     manager.loadJsonDevices("rest")
     results = DbManager.Select(self.disabledSensorTable)
     if results:
         for row in results:
             self.disabledSensors[row[0]] = 1
     self.StartMonitoring()