protected override bool GetValueFromEvent(AbstractSensorEvent e) { if (e.SensorId != Id) { return(Value); } if (e is SensorDeactivatedEvent) { return(false); } if (e is SensorActivatedEvent) { return(true); } throw new ArgumentOutOfRangeException(nameof(e)); }
private async Task Handle(AbstractSensorEvent sensorEvent) { Guard.DebugAssertArgumentNotNull(sensorEvent, nameof(sensorEvent)); if (sensorEvent is SensorActivatedEvent) { _log.Information("Sensor {SensorId} activated", sensorEvent.SensorId); await _bindingController.ProcessSensorActivation(sensorEvent.SensorId); } else if (sensorEvent is SensorDeactivatedEvent) { _log.Information("Sensor {SensorId} deactivated", sensorEvent.SensorId); await _bindingController.ProcessSensorDeactivation(sensorEvent.SensorId); } else { throw new NotImplementedException(); } }