public void Calculate() { Protein value = _proteinService.Get(SelectedProject); if (value == null) { return; } Protein protein = value.DeepClone(); if (PreferredDeadlineChecked) { protein.PreferredDays = PreferredDeadline; } if (FinalDeadlineChecked) { protein.MaximumDays = FinalDeadline; } if (KFactorChecked) { protein.KFactor = KFactor; } TimeSpan frameTime = TimeSpan.FromMinutes(TpfMinutes).Add(TimeSpan.FromSeconds(TpfSeconds)); TimeSpan totalTimeByFrame = TimeSpan.FromSeconds(frameTime.TotalSeconds * protein.Frames); TimeSpan totalTimeByUser = totalTimeByFrame; if (TotalWuTimeEnabled) { totalTimeByUser = TimeSpan.FromMinutes(TotalWuTimeMinutes).Add(TimeSpan.FromSeconds(TotalWuTimeSeconds)); // user time is less than total time by frame, not permitted if (totalTimeByUser < totalTimeByFrame) { totalTimeByUser = totalTimeByFrame; } } var decimalPlaces = _prefs.Get <int>(Preference.DecimalPlaces); var values = ProductionCalculator.GetProductionValues(frameTime, protein, totalTimeByUser, totalTimeByFrame); CoreName = protein.Core; SlotType = protein.Core.ToSlotType().ToString(); NumberOfAtoms = protein.NumberOfAtoms; CompletionTime = Math.Round((TotalWuTimeEnabled ? totalTimeByUser.TotalDays : totalTimeByFrame.TotalDays), decimalPlaces); PreferredDeadline = protein.PreferredDays; FinalDeadline = protein.MaximumDays; KFactor = protein.KFactor; BonusMultiplier = Math.Round((TotalWuTimeEnabled ? values.DownloadTimeBonusMulti : values.FrameTimeBonusMulti), decimalPlaces); BaseCredit = values.BaseCredit; TotalCredit = Math.Round((TotalWuTimeEnabled ? values.DownloadTimeBonusCredit : values.FrameTimeBonusCredit), decimalPlaces); BasePpd = values.BasePPD; TotalPpd = Math.Round((TotalWuTimeEnabled ? values.DownloadTimeBonusPPD : values.FrameTimeBonusPPD), decimalPlaces); }
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()); }
public void GetProductionValues_Test1() { var protein = new Protein { Credit = 700, PreferredDays = 3, MaximumDays = 5, KFactor = 26.4 }; var values = ProductionCalculator.GetProductionValues(TimeSpan.FromMinutes(5), protein, TimeSpan.FromMinutes(5 * 100).Add(TimeSpan.FromMinutes(10)), TimeSpan.FromMinutes(5 * 100)); Assert.AreEqual(TimeSpan.FromMinutes(5), values.TimePerFrame); Assert.AreEqual(700, values.BaseCredit); Assert.AreEqual(2016.0, values.BasePPD); Assert.AreEqual(TimeSpan.FromDays(3), values.PreferredTime); Assert.AreEqual(TimeSpan.FromDays(5), values.MaximumTime); Assert.AreEqual(26.4, values.KFactor); Assert.AreEqual(TimeSpan.FromMinutes(5 * 100).Add(TimeSpan.FromMinutes(10)), values.UnitTimeByDownloadTime); Assert.AreEqual(19.31, values.DownloadTimeBonusMulti, 0.01); Assert.AreEqual(13513.913, values.DownloadTimeBonusCredit); Assert.AreEqual(38920.07, values.DownloadTimeBonusPPD, 0.01); Assert.AreEqual(TimeSpan.FromMinutes(5 * 100), values.UnitTimeByFrameTime); Assert.AreEqual(19.5, values.FrameTimeBonusMulti, 0.01); Assert.AreEqual(13648.383, values.FrameTimeBonusCredit); Assert.AreEqual(39307.35, values.FrameTimeBonusPPD, 0.01); }