示例#1
0
        public MasterServiceTests()
        {
            MqttConfiguration = new MqttConfiguration()
            {
                Host     = "192.168.66.200",
                Port     = 64220,
                Username = "******",
                Password = "******"
            };

            var configuration = new TasmotaConfiguration()
            {
                Subnet = IPAddress.Parse("192.168.66.0"),
            };

            Network = new MockNetwork(configuration.Subnet, 30, MqttConfiguration);

            var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
            var tasmotaClient = new MockTasmotaClient(Network);
            var mongoClient   = new MongoClient("mongodb://localhost");

            Database         = mongoClient.GetDatabase("tasmocc-test");
            DeviceRepository = new DeviceRepository(Database);
            var deviceConfigurationRepository = new DeviceConfigurationRepository(Database);

            TasmotaService = new TasmotaService(Options.Create(configuration), loggerFactory.CreateLogger <TasmotaService>(), tasmotaClient);
            MasterService  = new MasterService(Options.Create(MqttConfiguration), loggerFactory.CreateLogger <MasterService>(), TasmotaService, DeviceRepository, deviceConfigurationRepository)
            {
                ScanNetworkOnStart = false
            };
        }
示例#2
0
        } = true;                                                    // Set to false on tests

        public MasterService(IOptions <MqttConfiguration> mqttOptions, ILogger <MasterService> logger, TasmotaService tasmotaService, DeviceRepository deviceRepository, DeviceConfigurationRepository deviceConfigurationRepository)
        {
            _mqttOptions      = mqttOptions.Value;
            _logger           = logger;
            _tasmotaService   = tasmotaService;
            _deviceRepository = deviceRepository;
            _deviceConfigurationRepository = deviceConfigurationRepository;
        }
示例#3
0
 public DatabaseMonitor(IOptions <TasmotaConfiguration> tasmotaOptions, ILogger <DatabaseMonitor> logger, DeviceRepository deviceRepository, DeviceConfigurationRepository deviceConfigurationRepository, TemplateRepository templateRepository, IHubContext <DevicesHub, IDevicesHubClient> hubContext, MasterService masterService)
 {
     _tasmotaOptions   = tasmotaOptions;
     _logger           = logger;
     _deviceRepository = deviceRepository;
     _deviceConfigurationRepository = deviceConfigurationRepository;
     _templateRepository            = templateRepository;
     _hubContext    = hubContext;
     _masterService = masterService;
 }
示例#4
0
        /// <summary>
        /// Inicializar router
        /// </summary>
        /// <param name="devices">Gestor de dispositivos</param>
        /// <param name="users">Gestor de usuarios</param>
        public void Init(DeviceManager devices, UserManager users)
        {
            m_configRepo = new DeviceConfigurationRepository();

            m_deviceManager = devices;
            m_deviceManager.OnDeviceConnected    += DeviceManager_OnDeviceConnected;
            m_deviceManager.OnDeviceDisconnected += DeviceManager_OnDeviceDisconnected;

            m_userManager = users;
            m_userManager.OnUserConnected    += UserManager_OnUserConnected;
            m_userManager.OnUserDisconnected += UserManager_OnUserDisconnected;
        }
示例#5
0
 /// <summary>
 /// Inicializar servicio de datos de dispositivos
 /// </summary>
 public DevicesDataService()
 {
     m_configRepo = new DeviceConfigurationRepository();
     m_transRepo  = new DeviceTranslationRepository();
 }