public void EnableSensor(Identifier identifier) { if (_sensorValueProviders.ContainsKey(identifier)) { return; } var sensor = _openHardwareMonitorFacade.Sensors.FirstOrDefault(s => s.Identifier == identifier); if (sensor == null) { return; } Logger.Info("Enabling sensor: {0}", sensor.Identifier); var sensorValueProvider = _sensorValueProviderFactory.Create(sensor); if (_sensorConfigs.TryGetValue(identifier, out var config)) { if (config.Offset.HasValue) { sensorValueProvider = new OffsetSensorValueDecorator(sensorValueProvider, config.Offset.Value); } } _sensorValueProviders.Add(identifier, sensorValueProvider); _hardware.Add(sensor.Hardware); }
public ISensorValueProvider CreateProvider(ISensor sensor) { ISensorValueProvider sensorValueProvider = new SensorValueProvider(sensor); var alpha = Math.Exp(-_config.SensorTimerInterval / (double)_config.DeviceSpeedTimerInterval); sensorValueProvider = new MovingAverageSensorValueDecorator(sensorValueProvider, alpha); if (_sensorConfigs.TryGetValue(sensor.Identifier, out var config) && config.Offset.HasValue) { sensorValueProvider = new OffsetSensorValueDecorator(sensorValueProvider, config.Offset.Value); } return(sensorValueProvider); }