Пример #1
0
        public void GetDataPoints()
        {
            var dataPoint1 = CreateDataPoint("s1", "mySensorType1");

            _repository.Save(dataPoint1);

            _repository.Save(CreateDataPoint("s1", "mySensorType2"));
            _repository.Save(CreateDataPoint("s2", "mySensorType1"));
            _repository.Save(CreateDataPoint("s2", "mySensorType2"));

            var loadedDataPoints = _repository.GetDataPoints("s1", "mySensorType1", DateTimeRange.Unbounded);

            loadedDataPoints.Should().HaveCount(1);
            DataPoint.IdentityEquals(dataPoint1, loadedDataPoints[0]).Should().BeTrue();
        }
Пример #2
0
        public GetDataPointsResponse GetDataPoints(string stationId, string sensorType)
        {
            var dataPoints = _repository.GetDataPoints(
                stationId,
                sensorType,
                DateTimeRange.Last24Hours);

            return(new GetDataPointsResponse {
                DataPoints = dataPoints.Select(ToDataPointApi).ToList()
            });
        }
        public JsonResult <StationDataPoints> GetStationDataPoints(string stationId, int lastHours = 24)
        {
            var dateTimeRange = StationController.CreateDateTimeRange(lastHours.ToString());

            var sensorValuesList = SensorDetails.GetSensorTypeValues()
                                   .SelectMany(type => _repository.GetDataPoints(stationId, type, dateTimeRange))
                                   .GroupBy(dp => dp.SensorType)
                                   .Select(ToSensorValues)
                                   .ToList()
            ;

            return(ToJson(new StationDataPoints
            {
                StationId = stationId,
                SensorValues = sensorValuesList
            }));
        }
Пример #4
0
        private static string GetChartHtmlForStationSensor(string stationId,
                                                           IDataPointRepository repository,
                                                           string sensorType,
                                                           DateTimeRange dateTimeRange)
        {
            var dataPoints = repository.GetDataPoints(stationId, sensorType, dateTimeRange)
                             .Where(dp => dp.SensorValueNumber != 0.0d)
                             .Select(dp => new Tuple <DateTime, double>(dp.SensorTimestampUtc, dp.SensorValueNumber))
                             .ToList();

            if (!dataPoints.Any())
            {
                return(null);
            }

            var chart = Chart.Line(dataPoints, FSharpOption <IEnumerable <string> > .None,
                                   FSharpOption <Configuration.Options> .None);

            chart.WithOptions(new Configuration.Options {
                title = sensorType
            });

            return(chart.GetInlineHtml());
        }
Пример #5
0
 public IActionResult GetDataPoints()
 {
     return(Ok(_dataPointRepository.GetDataPoints()));
 }