Example #1
0
        /// <summary>
        /// Time per frame (TPF) of the unit
        /// </summary>
        public TimeSpan GetFrameTime(PpdCalculationType calculationType)
        {
            int rawTime = GetRawTime(calculationType);

            if (rawTime != 0)
            {
                return(TimeSpan.FromSeconds(rawTime));
            }

            var benchmark = _benchmarkService?.GetBenchmark(UnitInfoData);

            return(benchmark?.AverageFrameTime ?? TimeSpan.Zero);
        }
Example #2
0
        public void ShowPPDTrace(ILogger logger, string slotName, SlotStatus status, PpdCalculationType calculationType, BonusCalculationType bonusCalculationType)
        {
            // test the level
            if (!logger.IsDebugEnabled)
            {
                return;
            }

            if (CurrentProtein.IsUnknown)
            {
                logger.DebugFormat(Constants.ClientNameFormat, slotName, "Protein is unknown... 0 PPD.");
                return;
            }

            // Issue 125
            if (bonusCalculationType == BonusCalculationType.DownloadTime)
            {
                // Issue 183
                if (status.Equals(SlotStatus.RunningAsync) ||
                    status.Equals(SlotStatus.RunningNoFrameTimes))
                {
                    logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time.");
                }
                else
                {
                    logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Download Time.");
                }
            }
            else if (bonusCalculationType == BonusCalculationType.FrameTime)
            {
                logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time.");
            }
            else
            {
                logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Standard PPD.");
            }

            TimeSpan frameTime = GetFrameTime(calculationType);
            var      values    = ProductionCalculator.GetProductionValues(frameTime, CurrentProtein, GetEftByDownloadTime(frameTime), GetEftByFrameTime(frameTime));

            logger.DebugFormat(" - {0}", UnitInfoData.ToProjectString());
            logger.Debug(values.ToMultiLineString());
        }
Example #3
0
        /// <summary>
        /// Frame Time per section based on current PPD calculation setting (readonly)
        /// </summary>
        public int GetRawTime(PpdCalculationType calculationType)
        {
            switch (calculationType)
            {
            case PpdCalculationType.LastFrame:
                return(_unitInfo.FramesObserved > 1 ? Convert.ToInt32(_unitInfo.CurrentFrame.Duration.TotalSeconds) : 0);

            case PpdCalculationType.LastThreeFrames:
                return(_unitInfo.FramesObserved > 3 ? GetDurationInSeconds(3) : 0);

            case PpdCalculationType.AllFrames:
                return(_unitInfo.FramesObserved > 0 ? GetDurationInSeconds(_unitInfo.FramesObserved) : 0);

            case PpdCalculationType.EffectiveRate:
                return(GetRawTimePerUnitDownload());
            }

            return(0);
        }
Example #4
0
        /// <summary>
        /// Time per frame (TPF) of the unit
        /// </summary>
        public TimeSpan GetFrameTime(PpdCalculationType calculationType)
        {
            int rawTime = GetRawTime(calculationType);

            if (rawTime != 0)
            {
                return(TimeSpan.FromSeconds(rawTime));
            }

            // Issue 79 - no benchmark container is available to merged display instances
            if (_benchmarkService != null)
            {
                ProteinBenchmark benchmark = _benchmarkService.GetBenchmark(UnitInfoData);
                if (benchmark != null)
                {
                    return(benchmark.AverageFrameTime);
                }
            }
            return(TimeSpan.Zero);
        }
Example #5
0
 /// <summary>
 /// Units per day (UPD) rating for this unit
 /// </summary>
 public double GetUPD(PpdCalculationType calculationType)
 {
     return(ProductionCalculator.GetUPD(GetFrameTime(calculationType), CurrentProtein.Frames));
 }
Example #6
0
 public bool IsUsingBenchmarkFrameTime(PpdCalculationType calculationType)
 {
     return(GetRawTime(calculationType) == 0);
 }
Example #7
0
 /// <summary>
 /// Esimated time of arrival (ETA) for this unit
 /// </summary>
 public TimeSpan GetEta(PpdCalculationType calculationType)
 {
     return GetEta(GetFrameTime(calculationType));
 }
Example #8
0
 /// <summary>
 /// Estimated time of arrival (ETA) for this unit
 /// </summary>
 public DateTime GetEtaDate(PpdCalculationType calculationType)
 {
     return(_unitInfo.UnitRetrievalTime.Add(GetEta(calculationType)));
 }
Example #9
0
        public void ShowPPDTrace(ILogger logger, string slotName, SlotStatus status, PpdCalculationType calculationType, BonusCalculationType calculateBonus)
        {
            // test the level
             if (!logger.IsDebugEnabled) return;

             if (CurrentProtein.IsUnknown())
             {
            logger.DebugFormat(Constants.ClientNameFormat, slotName, "Protein is unknown... 0 PPD.");
            return;
             }

             // Issue 125
             if (calculateBonus.Equals(BonusCalculationType.DownloadTime))
             {
            // Issue 183
            if (status.Equals(SlotStatus.RunningAsync) ||
                status.Equals(SlotStatus.RunningNoFrameTimes))
            {
               logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time.");
            }
            else
            {
               logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Download Time.");
            }
             }
             else if (calculateBonus.Equals(BonusCalculationType.FrameTime))
             {
            logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time.");
             }
             else
             {
            logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Standard PPD.");
             }

             TimeSpan frameTime = GetFrameTime(calculationType);
             var values = CurrentProtein.GetProductionValues(frameTime, GetEftByDownloadTime(frameTime), GetEftByFrameTime(frameTime), calculateBonus.IsEnabled());
             logger.Debug(values.ToMultiLineString());
        }
Example #10
0
 public bool IsUsingBenchmarkFrameTime(PpdCalculationType calculationType)
 {
     return GetRawTime(calculationType) == 0;
 }
Example #11
0
 /// <summary>
 /// Units per day (UPD) rating for this unit
 /// </summary>
 public double GetUPD(PpdCalculationType calculationType)
 {
     return CurrentProtein.GetUPD(GetFrameTime(calculationType));
 }
Example #12
0
        /// <summary>
        /// Frame Time per section based on current PPD calculation setting (readonly)
        /// </summary>
        public int GetRawTime(PpdCalculationType calculationType)
        {
            switch (calculationType)
             {
            case PpdCalculationType.LastFrame:
               return _unitInfo.FramesObserved > 1 ? Convert.ToInt32(_unitInfo.CurrentFrame.FrameDuration.TotalSeconds) : 0;
            case PpdCalculationType.LastThreeFrames:
               return _unitInfo.FramesObserved > 3 ? GetDurationInSeconds(3) : 0;
            case PpdCalculationType.AllFrames:
               return _unitInfo.FramesObserved > 0 ? GetDurationInSeconds(_unitInfo.FramesObserved) : 0;
            case PpdCalculationType.EffectiveRate:
               return GetRawTimePerUnitDownload();
             }

             return 0;
        }
Example #13
0
 /// <summary>
 /// Points per day (PPD) rating for this unit
 /// </summary>
 public double GetPPD(SlotStatus status, PpdCalculationType calculationType, BonusCalculationType calculateBonus)
 {
     TimeSpan frameTime = GetFrameTime(calculationType);
      return GetPPD(frameTime, GetEftByDownloadTime(frameTime), GetEftByFrameTime(frameTime), status, calculateBonus);
 }
Example #14
0
        /// <summary>
        /// Time per frame (TPF) of the unit
        /// </summary>
        public TimeSpan GetFrameTime(PpdCalculationType calculationType)
        {
            int rawTime = GetRawTime(calculationType);
             if (rawTime != 0)
             {
            return TimeSpan.FromSeconds(rawTime);
             }

             // Issue 79 - no benchmark container is available to merged display instances
             if (_benchmarkCollection != null)
             {
            ProteinBenchmark benchmark = _benchmarkCollection.GetBenchmark(UnitInfoData);
            if (benchmark != null)
            {
               return benchmark.AverageFrameTime;
            }
             }
             return TimeSpan.Zero;
        }
Example #15
0
 /// <summary>
 /// Esimated time of arrival (ETA) for this unit
 /// </summary>
 public DateTime GetEtaDate(PpdCalculationType calculationType)
 {
     return _unitInfo.UnitRetrievalTime.Add(GetEta(calculationType));
 }
Example #16
0
        /// <summary>
        /// Points per day (PPD) rating for this unit
        /// </summary>
        public double GetPPD(SlotStatus status, PpdCalculationType calculationType, BonusCalculationType calculateBonus)
        {
            TimeSpan frameTime = GetFrameTime(calculationType);

            return(GetPPD(frameTime, GetUnitTimeByDownloadTime(frameTime), GetUnitTimeByFrameTime(frameTime), status, calculateBonus));
        }
Example #17
0
 /// <summary>
 /// Estimated time of arrival (ETA) for this unit
 /// </summary>
 public TimeSpan GetEta(PpdCalculationType calculationType)
 {
     return(GetEta(GetFrameTime(calculationType)));
 }
Example #18
0
        /// <summary>
        /// Work unit credit
        /// </summary>
        public double GetCredit(SlotStatus status, PpdCalculationType calculationType, BonusCalculationType calculateBonus)
        {
            TimeSpan frameTime = GetFrameTime(calculationType);

            return(GetCredit(GetEftByDownloadTime(frameTime), GetEftByFrameTime(frameTime), status, calculateBonus));
        }
Example #19
0
        public void ShowProductionTrace(ILogger logger, string slotName, SlotStatus status, PpdCalculationType calculationType, BonusCalculationType bonusCalculationType)
        {
            // test the level
            if (!logger.IsDebugEnabled)
            {
                return;
            }

            if (CurrentProtein.IsUnknown())
            {
                logger.DebugFormat(Constants.ClientNameFormat, slotName, "Protein is unknown... 0 PPD.");
                return;
            }

            switch (bonusCalculationType)
            {
            case BonusCalculationType.DownloadTime:
                logger.DebugFormat(Constants.ClientNameFormat, slotName,
                                   status == SlotStatus.RunningNoFrameTimes
                            ? "Calculate Bonus PPD by Frame Time."
                            : "Calculate Bonus PPD by Download Time.");
                break;

            case BonusCalculationType.FrameTime:
                logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Bonus PPD by Frame Time.");
                break;

            default:
                logger.DebugFormat(Constants.ClientNameFormat, slotName, "Calculate Standard PPD.");
                break;
            }

            TimeSpan frameTime              = GetFrameTime(calculationType);
            var      noBonusValues          = CurrentProtein.GetProductionValues(frameTime, TimeSpan.Zero);
            TimeSpan unitTimeByDownloadTime = GetUnitTimeByDownloadTime(frameTime);
            var      bonusByDownloadValues  = CurrentProtein.GetProductionValues(frameTime, unitTimeByDownloadTime);
            TimeSpan unitTimeByFrameTime    = GetUnitTimeByFrameTime(frameTime);
            var      bonusByFrameValues     = CurrentProtein.GetProductionValues(frameTime, unitTimeByFrameTime);

            logger.Debug(CreateProductionDebugOutput(UnitInfoData.ToShortProjectString(), frameTime, CurrentProtein, noBonusValues,
                                                     unitTimeByDownloadTime, bonusByDownloadValues,
                                                     unitTimeByFrameTime, bonusByFrameValues));
        }
Example #20
0
 /// <summary>
 /// Units per day (UPD) rating for this unit
 /// </summary>
 public double GetUPD(PpdCalculationType calculationType)
 {
    return ProductionCalculator.GetUPD(GetFrameTime(calculationType), CurrentProtein.Frames);
 }