Пример #1
0
def SetupMonitors():

    # Setup managers
    commandManager = Managers.CommandManager(config)
    sensorManager = Managers.SensorManager(config)
    # Link them
    commandManager.SetSensorManager(sensorManager)
    sensorManager.SetCommandManager(commandManager)

    # If I have not a list of monitors, I setup only a monitor
    if ('monitors' not in config):
        monitor = Monitor(config, config, commandManager, sensorManager)
    else:  # More Monitors
        # Now setup monitors
        monitor_id = 0
        for monitor_config in config['monitors']:
            monitor_id += 1
            monitor = Monitor(monitor_config, config, commandManager,
                              sensorManager, monitor_id)

    # Start sensors loop
    sensorManager.Start()
Пример #2
0
import Sensors
import Commands
import Managers
from MqttClient import MqttClient
import Logger

sensorManager = None
config = None
config_filename = 'configuration.yaml'

scriptFolder = str(os.path.dirname(os.path.realpath(__file__)))


def LoadYAML():
    global config
    with open(os.path.join(scriptFolder, config_filename)) as f:
        config = yaml.load(f, Loader=yaml.FullLoader)


if __name__ == "__main__":
    LoadYAML()
    logger = Logger.Logger()
    logger.Log(Logger.LOG_INFO, 'Main', 'Starting')
    mqttClient = MqttClient(config, logger)
    commandManager = Managers.CommandManager(config, mqttClient, logger)
    sensorManager = Managers.SensorManager(config, mqttClient, logger)
    commandManager.SetSensorManager(sensorManager)
    sensorManager.SetCommandManager(commandManager)
    # All configurations must go above
    sensorManager.Start()  # Start the loop