public MovingAverage(ZPMonitorService zpMonitorService, ILoggerFactory loggerFactory, DurationType durationType, bool excludeZeroPowerValues)
        {
            m_zpMonitorService       = zpMonitorService;
            Logger                   = loggerFactory.CreateLogger <MovingAverage>();
            m_durationType           = durationType;
            m_duration               = MovingAverage.GetDuration(durationType);
            m_excludeZeroPowerValues = excludeZeroPowerValues;

            m_statsQueue = new Queue <Statistics>();

            m_zpMonitorService.RiderStateEvent += RiderStateEventHandler;
        }
示例#2
0
        /// <summary>
        /// Generic moving average collector
        /// </summary>
        /// <param name="durationType"></param>The duration of collection
        /// <param name="excludeZeroPowerValues"></param>Whether to exclude zeros when collecting
        /// <param name="allowHighRes"></param>Whether to allow use of high-res packets.  Currently only collectors under 30 seconds use these.
        public MovingAverage(DurationType durationType, bool excludeZeroPowerValues, bool allowHighRes = true)
        {
            Logger = ZAMsettings.LoggerFactory.CreateLogger <MovingAverage>();

            m_durationType           = durationType;
            m_duration               = MovingAverage.GetDuration(durationType);
            m_excludeZeroPowerValues = excludeZeroPowerValues;

            m_statsQueue = new Queue <Statistics>();

            if (m_duration <= 30 && allowHighRes)
            {
                ZAMsettings.ZPMonitorService.HighResRiderStateEvent += RiderStateEventHandler;
                Logger.LogInformation($"{m_duration} seconds moving average collector using high-res packets.");
            }
            else
            {
                ZAMsettings.ZPMonitorService.RiderStateEvent += RiderStateEventHandler;
            }
        }