コード例 #1
0
ファイル: Vendor.cs プロジェクト: aleanza/WeatherStation
 public double ReadDoubleValue(ISensorConfiguration sensorConfiguration)
 {
     using (var connection = _external.Connect())
     {
         return(connection.ReadDoubleValue(sensorConfiguration.Uri));
     }
 }
コード例 #2
0
ファイル: Vendor.cs プロジェクト: aleanza/WeatherStation
        public bool Validate(ISensorConfiguration sensorConfiguration)
        {
            if (!_external.CanHandleUri(sensorConfiguration.Uri))
            {
                throw new ArgumentException("Invalid argument" + sensorConfiguration.Uri);
            }

            return(true);
        }
コード例 #3
0
        /// <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));
            });
        }
コード例 #4
0
ファイル: Sensor.cs プロジェクト: aleanza/WeatherStation
 public Sensor(IVendor vendor, ISensorConfiguration sensorConfiguration)
 {
     _vendor = vendor;
     _sensorConfiguration = sensorConfiguration;
 }
コード例 #5
0
 public void OnSensorUpdated(ISensorConfiguration aConfiguration, int aSensorId)
 {
     throw new System.NotImplementedException();
 }
コード例 #6
0
 public void OnSensorCreated(ISensorConfiguration aConfiguration, int aSensorId)
 {
     CretedSensor = aConfiguration.ReadSensorInfoById(aSensorId);
 }
コード例 #7
0
        public void SetSensorConfiguration(ISensorConfiguration aConfiguration)
        {
            if (aConfiguration == null) {
                throw new ArgumentNullException("aConfiguration");
            }

            configuration = aConfiguration;
        }
コード例 #8
0
 public void OnSensorDeleted(ISensorConfiguration aConfiguration, int aSensorId)
 {
     throw new NotImplementedException();
 }
コード例 #9
0
 public void SetSensorConfiguration(ISensorConfiguration aSensorConfiguration)
 {
 }
コード例 #10
0
ファイル: Vendor.cs プロジェクト: aleanza/WeatherStation
 public double ReadDoubleValue(ISensorConfiguration sensorConfiguration)
 {
     return(_external.ReadDoubleValue(sensorConfiguration.Uri));
 }
コード例 #11
0
 public void SetSensorConfiguration(ISensorConfiguration aSensorConfiguration)
 {
     //throw new System.NotImplementedException();
 }