コード例 #1
0
        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));
        }
コード例 #2
0
        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();
            }
        }