protected override void ActivateInternal()
        {
            var setting        = Resolver.GetInstance <DeconzToMqttSetting>();
            var logManager     = Resolver.GetInstance <ILogManager>();
            var metricRecorder = Resolver.GetInstance <IMetricRecorder>();

            var sensorRepository = new SensorRepository(setting.DeconzApiKey, new Uri($"ws://{setting.DeconzAddress}:{setting.DeconzApiPort}"));
            var lightRepository  = new LightRepository(setting.DeconzApiKey, new Uri($"ws://{setting.DeconzAddress}:{setting.DeconzApiPort}"));

            var healthCheckService = new HealthCheckService(logManager.GetLogger <HealthCheckService>());
            var websockerReceiver  = new WebsocketReceiver(logManager.GetLogger <WebsocketReceiver>(), new Uri($"ws://{setting.DeconzAddress}:{setting.DeconzWebsocketPort}"));
            var mqttClient         = new MqttClient(logManager.GetLogger <MqttClient>(), metricRecorder, logManager, setting.MqttAddress, setting.MqttUsername, setting.MqttPassword);
            var eventHandler       = new EventHandlingService(logManager.GetLogger <EventHandlingService>(), websockerReceiver, mqttClient, sensorRepository);
            var telemetryService   = new TelemetryService(logManager.GetLogger <TelemetryService>(), metricRecorder, new DeconzRepository[] {
                sensorRepository,
                lightRepository
            }, mqttClient);

            healthCheckService.AddHealthCheck(websockerReceiver);
            healthCheckService.AddHealthCheck(mqttClient);

            mqttClient.Start();
            eventHandler.Start();
            websockerReceiver.Start();
            telemetryService.Start();
            healthCheckService.Start();
        }
示例#2
0
 public ServiceFactory InitTelemetryService()
 {
     _telemetryService = new TelemetryService(_mqttOutboundEventBus, _driversFactory.Window1ReedSwitch, _driversFactory.Window2ReedSwitch);
     _telemetryService.Start();
     Logger.Log(() => $"Free memory after init telemetry service {GC.Run(false)}");
     return(this);
 }
        public void Handle(ICommand command)
        {
            if (_telemetryService.IsRunning())
            {
                _outboundEventBus.Send(new CommandResultEvent(command.CorrelationId, StatusCode.Refused,
                                                              nameof(StartTelemetryServiceCommand), "Telemetry service is already running"));
                return;
            }

            _telemetryService.Start();
            _outboundEventBus.Send(new CommandResultEvent(command.CorrelationId, StatusCode.Success,
                                                          nameof(StartTelemetryServiceCommand)));
        }
        public ServiceFactory InitTelemetry()
        {
            _telemetryService = new TelemetryService(
                _driversFactory.DoorReedSwitch,
                _mqttOutboundEventBus,
                _driversFactory.LightSensor,
                _driversFactory.Bme280,
                _driversFactory.SoilMoistureSensor
                );

            _telemetryService.Start();

            return(this);
        }
示例#5
0
        public ServiceFactory InitTelemetryService()
        {
            _telemetryService = new TelemetryService(_mqttOutboundEventBus,
                                                     _driversFactory.AnemometerDriver,
                                                     _driversFactory.WindVaneDriver,
                                                     _driversFactory.RainGaugeDriver,
                                                     _driversFactory.Bme280,
                                                     _driversFactory.LightSensor);

            _telemetryService.Start();

            Logger.Log(() => $"Free memory after init telemetry service {GC.Run(false)}");

            return(this);
        }