public CommandDispatcherService(ICommandHandlersFactory commandHandlersFactory, ICommandBus commandBus, IOutboundEventBus outboundEventBus) { _commandHandlersFactory = commandHandlersFactory; _commandBus = commandBus; _outboundEventBus = outboundEventBus; }
public TelemetryService(IOutboundEventBus outboundEventBus, SwitchDriver window1ReedSwitch, SwitchDriver window2ReedSwitch) { _outboundEventBus = outboundEventBus; _window1ReedSwitch = window1ReedSwitch; _window2ReedSwitch = window2ReedSwitch; }
public DiagnosticService(IOutboundEventBus outboundEventBus) { _outboundEventBus = outboundEventBus; WifiDriver.OnWifiConnected += () => { _isConnectedToNetwork = true; }; WifiDriver.OnWifiDisconnected += () => { _isConnectedToNetwork = false; }; WifiDriver.OnWifiDuringConnection += () => { _isConnectedToNetwork = false; }; }
public InboundMessagesHandler(MqttClientWrapper mqttClient, ICommandBus commandBus, ICommandsFactory commandsFactory, IOutboundEventBus outboundEventBus) { mqttClient.OnMqttMessageReceived += (_, args) => { try { var decodedMessage = DecodeMqttMessage(args); var command = commandsFactory.Create(decodedMessage.Name, decodedMessage.Payload); var errors = command.Validate(); if (errors.Length > 0) { outboundEventBus.Send(new CommandResultEvent(command.CorrelationId, StatusCode.ValidationError, command.GetType().Name, errors.SerializeToString())); return; } commandBus.Send(command); } catch (Exception e) { outboundEventBus.Send(new ErrorEvent( $"Exception during handling inbound message: {e.Message}", ErrorLevel.Warning)); } }; }
public IrrigationService(SolidStateRelaysDriver solidStateRelays, ushort relaySwitchPumpChannel, ushort relaySwitchValveChannel, WaterFlowSensorDriver waterFlowSensorDriver, IOutboundEventBus outboundEventBus) { _relaySwitchValveChannel = relaySwitchValveChannel; _waterFlowSensorDriver = waterFlowSensorDriver; _outboundEventBus = outboundEventBus; _solidStateRelays = solidStateRelays; _relaySwitchPumpChannel = relaySwitchPumpChannel; }
public CommandHandlersFactory(IOutboundEventBus outboundEventBus, IDiagnosticService diagnosticService, WindowsManagingService windowsManagingService) { _mappings = new Hashtable { //Add here all command factories { nameof(PingCommand), new PingCommandHandler(outboundEventBus) }, { nameof(SendDiagnosticDataCommand), new SendDiagnosticDataCommandHandler(outboundEventBus, diagnosticService) }, { nameof(OpenWindowCommand), new OpenWindowCommandHandler(outboundEventBus, windowsManagingService) }, { nameof(CloseWindowCommand), new CloseWindowCommandHandler(outboundEventBus, windowsManagingService) } }; }
public CommandHandlersFactory(IOutboundEventBus outboundEventBus, TelemetryService telemetryService, IDiagnosticService diagnosticService) { _mappings = new Hashtable { //Add here all command factories { nameof(PingCommand), new PingCommandHandler(outboundEventBus) }, { nameof(SendDiagnosticDataCommand), new SendDiagnosticDataCommandHandler(outboundEventBus, diagnosticService) }, { nameof(SetTelemetryIntervalCommand), new SetTelemetryIntervalCommandHandler(telemetryService, outboundEventBus) }, { nameof(StartTelemetryServiceCommand), new StartTelemetryServiceCommandHandler(telemetryService, outboundEventBus) }, { nameof(StopTelemetryServiceCommand), new StopTelemetryServiceCommandHandler(telemetryService, outboundEventBus) }, }; }
public DoorService(IOutboundEventBus outboundEventBus, SwitchDriver doorReedSwitch) { _outboundEventBus = outboundEventBus; _doorReedSwitch = doorReedSwitch; OnDoorOpened = (sender, e) => { _outboundEventBus.Send(new DoorOpenedEvent()); }; OnDoorClosed = (sender, e) => { _outboundEventBus.Send(new DoorClosedEvent()); }; }
public TelemetryService(IOutboundEventBus outboundEventBus, SparkFunAnemometerDriver anemometerDriver, SparkFunWindVaneDriver windVaneDriver, SparkFunRainGaugeDriver rainGaugeDriver, Bme280 bme280Driver, Bh1750 lightSensorDriver) { _outboundEventBus = outboundEventBus; _anemometerDriver = anemometerDriver; _windVaneDriver = windVaneDriver; _rainGaugeDriver = rainGaugeDriver; _bme280Driver = bme280Driver; _lightSensorDriver = lightSensorDriver; }
public StopTelemetryServiceCommandHandler(TelemetryService telemetryService, IOutboundEventBus outboundEventBus) { _telemetryService = telemetryService; _outboundEventBus = outboundEventBus; }
public CommandHandlersFactory(IOutboundEventBus outboundEventBus, IDiagnosticService diagnosticService, IrrigationService irrigationService) =>
public SendDiagnosticDataCommandHandler(IOutboundEventBus outboundEventBus, IDiagnosticService diagnosticService) { _outboundEventBus = outboundEventBus; _diagnosticService = diagnosticService; }
public IrrigateCommandHandler(IrrigationService irrigationService, IOutboundEventBus outboundEventBus) { _irrigationService = irrigationService; _outboundEventBus = outboundEventBus; }
public CommandBus(IOutboundEventBus outboundEventBus) { _outboundEventBus = outboundEventBus; }
public WindowsManagingService(LinearActuatorDriver window1Actuator, LinearActuatorDriver window2Actuator, SwitchDriver window1ReedSwitch, SwitchDriver window2ReedSwitch, SwitchDriver window1ControlSwitch, SwitchDriver window2ControlSwitch, IOutboundEventBus outboundEventBus) { _windowActuators = new[] { window1Actuator, window2Actuator }; _windowReedSwitches = new[] { window1ReedSwitch, window2ReedSwitch }; _windowControlSwitches = new[] { window1ControlSwitch, window2ControlSwitch }; _windowStates = new[] { window1ReedSwitch.GetState(), window2ReedSwitch.GetState() }; _outboundEventBus = outboundEventBus; OnWindow1Opened = (sender, e) => { _windowStates[0] = SwitchState.Opened; _outboundEventBus.Send(new WindowOpenedEvent(0)); }; OnWindow1Closed = (sender, e) => { _windowStates[0] = SwitchState.Closed; _windowActuators[0].StopMoving(); _outboundEventBus.Send(new WindowClosedEvent(0)); }; OnWindow2Opened = (sender, e) => { _windowStates[1] = SwitchState.Opened; _outboundEventBus.Send(new WindowOpenedEvent(1)); }; OnWindow2Closed = (sender, e) => { _windowStates[1] = SwitchState.Closed; _windowActuators[1].StopMoving(); _outboundEventBus.Send(new WindowClosedEvent(1)); }; //Control switches OnWindow1ControlSwitchOpened = (sender, e) => { OpenWindowAsync(0); }; OnWindow1ControlSwitchClosed = (sender, e) => { if (_windowStates[0] == SwitchState.Closed) { return; } CloseWindowAsync(0); }; OnWindow2ControlSwitchOpened = (sender, e) => { OpenWindowAsync(1); }; OnWindow2ControlSwitchClosed = (sender, e) => { if (_windowStates[1] == SwitchState.Closed) { return; } CloseWindowAsync(1); }; }
public PingCommandHandler(IOutboundEventBus outboundEventBus) { _outboundEventBus = outboundEventBus; }
public OpenWindowCommandHandler(IOutboundEventBus outboundEventBus, WindowsManagingService windowsManagingService) { _outboundEventBus = outboundEventBus; _windowsManagingService = windowsManagingService; }