Esempio n. 1
0
        /// <summary>
        /// Retrieve live energy data for an account.
        /// </summary>
        /// <remarks>
        /// Does not check read permissions.
        /// </remarks>
        /// <returns>
        /// Live data for each active device of the account.
        /// </returns>
        public IList <LiveDataForDevice> Retrieve(Mini mini, DateTime nowUtc)
        {
            var toUtc   = nowUtc.Truncate(TimeSpan.FromMinutes(1));
            var fromUtc = toUtc.AddMinutes(-5);

            var liveData = new List <LiveDataForDevice>();
            IEnumerable <ValueSerie> seriesList = _seriesRetriever.RetrieveSerieValuesForAccount(mini, fromUtc, toUtc, SeriesResolution.OneMinute);

            foreach (var series in seriesList)
            {
                decimal?power = Series2Power(series.Data);
                liveData.Add(new LiveDataForDevice
                {
                    EnergyType = series.EnergyType,
                    Name       = series.Name,
                    Power      = power
                });
            }

            return(liveData);
        }
Esempio n. 2
0
        /// <summary>
        /// Build the C# result that can be used to generate the Json result for GetSeries.
        /// </summary>
        private IList <Serie> RetrieveForAccount(Mini mini, DateTime inFromUtc, DateTime inToUtc, SeriesResolution inResolution)
        {
            var valueSeries = _seriesRetriever.RetrieveSerieValuesForAccount(mini, inFromUtc, inToUtc, inResolution);

            return(Mapper.Map <IEnumerable <ValueSerie>, IList <Serie> >(valueSeries));
        }