public double ReadDoubleValue(ISensorConfiguration sensorConfiguration) { using (var connection = _external.Connect()) { return(connection.ReadDoubleValue(sensorConfiguration.Uri)); } }
public bool Validate(ISensorConfiguration sensorConfiguration) { if (!_external.CanHandleUri(sensorConfiguration.Uri)) { throw new ArgumentException("Invalid argument" + sensorConfiguration.Uri); } return(true); }
/// <summary> /// Creates DataRequestValidator. /// </summary> public DataRequestValidator(ISensorConfiguration sensorConfiguration, IHttpContextAccessor httpContextAccessor, ILogger <DataRequestValidator> logger) { _sensorConfiguration = sensorConfiguration ?? throw new ArgumentNullException(nameof(sensorConfiguration)); _httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); CascadeMode = CascadeMode.Stop; RuleSet("SaveSensorData", () => { RuleFor(x => x.Timestamp) .NotEmpty() .Must(x => (DateTime.UtcNow - x.ToUniversalTime()) <= TimeSpan.FromDays(2) && x.ToUniversalTime() <= DateTime.UtcNow) .WithMessage(x => Error("The Timestamp no musts be great than 2 days.", StructuredData, x)); RuleFor(x => x.Value) .NotNull() .Must(x => x <= _sensor.MaxValue) .WithMessage(x => Error("The Value musts be less than MaxValue or equals MaxValue.", StructuredDataAndConfig, x, _sensor)) .Must(x => x >= _sensor.MinValue) .WithMessage(x => Error("The Value musts be great than MinValue or equals MinValue.", StructuredDataAndConfig, x, _sensor)); }); }
public Sensor(IVendor vendor, ISensorConfiguration sensorConfiguration) { _vendor = vendor; _sensorConfiguration = sensorConfiguration; }
public void OnSensorUpdated(ISensorConfiguration aConfiguration, int aSensorId) { throw new System.NotImplementedException(); }
public void OnSensorCreated(ISensorConfiguration aConfiguration, int aSensorId) { CretedSensor = aConfiguration.ReadSensorInfoById(aSensorId); }
public void SetSensorConfiguration(ISensorConfiguration aConfiguration) { if (aConfiguration == null) { throw new ArgumentNullException("aConfiguration"); } configuration = aConfiguration; }
public void OnSensorDeleted(ISensorConfiguration aConfiguration, int aSensorId) { throw new NotImplementedException(); }
public void SetSensorConfiguration(ISensorConfiguration aSensorConfiguration) { }
public double ReadDoubleValue(ISensorConfiguration sensorConfiguration) { return(_external.ReadDoubleValue(sensorConfiguration.Uri)); }
public void SetSensorConfiguration(ISensorConfiguration aSensorConfiguration) { //throw new System.NotImplementedException(); }