private InverterTemperatureSummary BuildTemperatureSummary(ConcurrentDictionary <long, string> collection, DateTimeOffset intervalStart, DateTimeOffset intervalEnd, List <string> removedTexts) { var moments = _summaryFunctions.FillSummary <MomentBatteryInverterTemperatures, SenecEntities.BatteryObject1>( collection, intervalStart, intervalEnd, (moment, meter) => _adapter.Convert(moment, meter).GetMoment(), removedTexts); var maximumValues = (int)(intervalEnd - intervalStart).TotalSeconds; var temperatureSensors = moments.Max(a => a.Temperatures.Count); Statistic[] statistics = Enumerable.Range(0, temperatureSensors) .Select(i => CreateStatistics(moments, (moment) => moment.Temperatures.Skip(i).First())).ToArray(); var stats = new InverterTemperatureSummary( intervalStartIncluded: intervalStart, intervalEndExcluded: intervalEnd, secondsWithoutData: maximumValues - moments.Count, statistics ); return(stats); }
public BatteryInverterTemperatureSummaryEntity(InverterTemperatureSummary entity, int version) : base( intervalEndExcluded: entity.IntervalEndExcluded, intervalStartIncluded: entity.IntervalStartIncluded, temperatures: entity.Temperatures.ToArray(), secondsWithoutData: entity.SecondsWithoutData) { Id = "ITS_" + this.GetKey(); Partition = "ITS_" + this.GetKey(); Version = version; }
public async Task <bool> AddAsync(InverterTemperatureSummary notification, CancellationToken cancellationToken) { var result = await _context.CreateItemAsync(notification)(cancellationToken); return(result.StatusCode == HttpStatusCode.Created); }
public Func <CancellationToken, Task <ItemResponse <BatteryInverterTemperatureSummaryEntity> > > CreateItemAsync(InverterTemperatureSummary energySummary) { var persistedValue = new BatteryInverterTemperatureSummaryEntity(energySummary, _version.Number); Func <CancellationToken, Task <ItemResponse <BatteryInverterTemperatureSummaryEntity> > > obj = (CancellationToken c) => _container.CreateItemAsync(persistedValue, cancellationToken: c); return(obj); }