示例#1
0
        public SlotModel()
        {
            _unitInfoLogic = new UnitInfoLogic();

             Initialize();
             TimeOfLastUnitStart = DateTime.MinValue;
             TimeOfLastFrameProgress = DateTime.MinValue;
        }
示例#2
0
        internal void UpdateBenchmarkData(UnitInfoLogic currentUnitInfo, IEnumerable<UnitInfoLogic> parsedUnits, int currentUnitIndex)
        {
            foreach (var unitInfoLogic in parsedUnits)
             {
            if (unitInfoLogic == null)
            {
               continue;
            }

            if (currentUnitInfo.UnitInfoData.IsSameUnitAs(unitInfoLogic.UnitInfoData))
            {
               // found the current unit
               // current frame has already been recorded, increment to the next frame
               int previousFramesComplete = currentUnitInfo.FramesComplete + 1;
               // Update benchmarks
               BenchmarkCollection.UpdateData(unitInfoLogic.UnitInfoData, previousFramesComplete, unitInfoLogic.FramesComplete);
               // Update history database
               if (!unitInfoLogic.FinishedTime.Equals(DateTime.MinValue))
               {
                  UpdateUnitInfoDatabase(unitInfoLogic);
               }
            }
            //// used when there is no currentUnitInfo
            //else if (unitInfoLogic.UnitInfoData.QueueIndex == currentUnitIndex)
            //{
            //   BenchmarkCollection.UpdateData(unitInfoLogic.UnitInfoData, 0, unitInfoLogic.FramesComplete);
            //}
             }
        }
示例#3
0
        /// <summary>
        /// Update Time of Last Frame Progress based on Current and Parsed UnitInfo
        /// </summary>
        private void UpdateTimeOfLastProgress(UnitInfoLogic parsedUnitInfo)
        {
            // Matches the Current Project and Raw Download Time
             if (UnitInfoLogic.UnitInfoData.IsSameUnitAs(parsedUnitInfo.UnitInfoData))
             {
            // If the Unit Start Time Stamp is no longer the same as the UnitInfoLogic
            if (parsedUnitInfo.UnitInfoData.UnitStartTimeStamp.Equals(TimeSpan.MinValue) == false &&
                UnitInfoLogic.UnitInfoData.UnitStartTimeStamp.Equals(TimeSpan.MinValue) == false &&
                parsedUnitInfo.UnitInfoData.UnitStartTimeStamp.Equals(UnitInfoLogic.UnitInfoData.UnitStartTimeStamp) == false)
            {
               TimeOfLastUnitStart = DateTime.Now;
            }

            // If the Frames Complete is greater than the UnitInfoLogic Frames Complete
            if (parsedUnitInfo.FramesComplete > UnitInfoLogic.FramesComplete)
            {
               // Update the Time Of Last Frame Progress
               TimeOfLastFrameProgress = DateTime.Now;
            }
             }
             else // Different UnitInfo - Update the Time Of Last
             // Unit Start and Clear Frame Progress Value
             {
            TimeOfLastUnitStart = DateTime.Now;
            TimeOfLastFrameProgress = DateTime.MinValue;
             }
        }
示例#4
0
        /// <summary>
        /// Update Project Benchmarks
        /// </summary>
        /// <param name="currentUnitInfo">Current UnitInfo</param>
        /// <param name="parsedUnits">Parsed UnitInfo Array</param>
        /// <param name="nextUnitIndex">Index of Current UnitInfo</param>
        internal void UpdateBenchmarkData(UnitInfoLogic currentUnitInfo, UnitInfoLogic[] parsedUnits, int nextUnitIndex)
        {
            var foundCurrent = false;
             var processUpdates = false;
             var index = GetStartingIndex(nextUnitIndex, parsedUnits.Length);

             while (index != -1)
             {
            // If Current has not been found, check the nextUnitIndex
            // or try to match the Current Project and Raw Download Time
            if (parsedUnits[index] != null && processUpdates == false && (index == nextUnitIndex || currentUnitInfo.UnitInfoData.IsSameUnitAs(parsedUnits[index].UnitInfoData)))
            {
               foundCurrent = true;
               processUpdates = true;
            }

            if (processUpdates)
            {
               int previousFramesComplete = 0;
               if (foundCurrent)
               {
                  // current frame has already been recorded, increment to the next frame
                  previousFramesComplete = currentUnitInfo.FramesComplete + 1;
                  foundCurrent = false;
               }

               // Even though the current UnitInfoLogic has been found in the parsed UnitInfoLogic array doesn't
               // mean that all entries in the array will be present.  See TestFiles\SMP_12\FAHlog.txt.
               if (parsedUnits[index] != null)
               {
                  // Update benchmarks
                  BenchmarkCollection.UpdateData(parsedUnits[index].UnitInfoData, previousFramesComplete, parsedUnits[index].FramesComplete);
                  // Update history database
                  UpdateUnitInfoDatabase(parsedUnits[index]);
               }
            }

            #region Increment to the next unit or set terminal value
            if (index == nextUnitIndex)
            {
               index = -1;
            }
            else if (index == parsedUnits.Length - 1)
            {
               index = 0;
            }
            else
            {
               index++;
            }
            #endregion
             }
        }
示例#5
0
        /// <summary>
        /// Process the cached log files that exist on this machine
        /// </summary>
        private void Process()
        {
            DateTime start = Instrumentation.ExecStart;

             // Set successful Last Retrieval Time
             LastRetrievalTime = DateTime.Now;
             // Re-Init Slot Level Members Before Processing
             _slotModel.Initialize();

             #region Setup Aggregator

             DataAggregator.ClientName = Settings.Name;
             DataAggregator.QueueFilePath = Path.Combine(Prefs.CacheDirectory, Settings.CachedQueueFileName());
             DataAggregator.FahLogFilePath = Path.Combine(Prefs.CacheDirectory, Settings.CachedFahLogFileName());
             DataAggregator.UnitInfoLogFilePath = Path.Combine(Prefs.CacheDirectory, Settings.CachedUnitInfoFileName());

             #endregion

             #region Run the Aggregator

             IList<UnitInfo> units = DataAggregator.AggregateData();
             // Issue 126 - Use the Folding ID, Team, User ID, and Machine ID from the FAHlog data.
             // Use the Current Queue Entry as a backup data source.
             PopulateRunLevelData(DataAggregator.CurrentClientRun, _slotModel);
             if (DataAggregator.Queue != null)
             {
            PopulateRunLevelData(DataAggregator.Queue.CurrentQueueEntry, _slotModel);
             }

             _slotModel.Queue = DataAggregator.Queue;
             _slotModel.CurrentLogLines = DataAggregator.CurrentLogLines;
             _slotModel.UnitLogLines = DataAggregator.UnitLogLines;

             #endregion

             var parsedUnits = new UnitInfoLogic[units.Count];
             for (int i = 0; i < units.Count; i++)
             {
            if (units[i] != null)
            {
               parsedUnits[i] = BuildUnitInfoLogic(units[i], true);
            }
             }

             // *** THIS HAS TO BE DONE BEFORE UPDATING SlotModel.UnitInfoLogic ***
             UpdateBenchmarkData(_slotModel.UnitInfoLogic, parsedUnits, DataAggregator.CurrentUnitIndex);

             // Update the UnitInfoLogic if we have a Status
             SlotStatus currentWorkUnitStatus = DataAggregator.CurrentClientRun.Status;
             if (!currentWorkUnitStatus.Equals(SlotStatus.Unknown))
             {
            _slotModel.UnitInfoLogic = parsedUnits[DataAggregator.CurrentUnitIndex];
             }

             HandleReturnedStatus(currentWorkUnitStatus, _slotModel);

             _slotModel.UnitInfoLogic.ShowPPDTrace(Logger, _slotModel.Name, _slotModel.Status,
            Prefs.Get<PpdCalculationType>(Preference.PpdCalculation),
            Prefs.Get<BonusCalculationType>(Preference.CalculateBonus));

             string statusMessage = String.Format(CultureInfo.CurrentCulture, "Client Status: {0}", _slotModel.Status);
             Logger.Info(Constants.ClientNameFormat, _slotModel.Name, statusMessage);

             string message = String.Format(CultureInfo.CurrentCulture, "Retrieval finished in {0}", Instrumentation.GetExecTime(start));
             Logger.Info(Constants.ClientNameFormat, Settings.Name, message);
        }
示例#6
0
文件: Client.cs 项目: kszysiu/hfm-net
 protected void UpdateUnitInfoDatabase(UnitInfoLogic unitInfoLogic)
 {
     // Update history database
      if (UnitInfoDatabase != null && UnitInfoDatabase.Connected)
      {
     try
     {
        UnitInfoDatabase.Insert(unitInfoLogic);
     }
     catch (Exception ex)
     {
        Logger.ErrorFormat(ex, "{0}", ex.Message);
     }
      }
 }
示例#7
0
        /// <summary>
        /// Return Multi-Line String (Array)
        /// </summary>
        private IEnumerable<string> ToMultiLineString(ProteinBenchmark benchmark, UnitInfoLogic unitInfoLogic, bool valuesOk, SlotStatus status, string ppdFormatString)
        {
            var output = new List<string>(12);

             Protein protein;
             _proteinDictionary.TryGetValue(benchmark.ProjectID, out protein);
             if (protein != null)
             {
            var calculateBonus = _prefs.Get<BonusCalculationType>(Preference.CalculateBonus);

            output.Add(String.Empty);
            output.Add(String.Format(" Name: {0}", benchmark.OwningSlotName));
            output.Add(String.Format(" Path: {0}", benchmark.OwningClientPath));
            output.Add(String.Format(" Number of Frames Observed: {0}", benchmark.FrameTimes.Count));
            output.Add(String.Empty);
            output.Add(String.Format(" Min. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
               benchmark.MinimumFrameTime, protein.GetPPD(benchmark.MinimumFrameTime, calculateBonus.IsEnabled())));
            output.Add(String.Format(" Avg. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
               benchmark.AverageFrameTime, protein.GetPPD(benchmark.AverageFrameTime, calculateBonus.IsEnabled())));

            if (unitInfoLogic != null && unitInfoLogic.UnitInfoData.ProjectID.Equals(protein.ProjectNumber) && valuesOk)
            {
               output.Add(String.Format(" Cur. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                  unitInfoLogic.GetFrameTime(PpdCalculationType.LastFrame), unitInfoLogic.GetPPD(status, PpdCalculationType.LastFrame, calculateBonus)));
               output.Add(String.Format(" R3F. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                  unitInfoLogic.GetFrameTime(PpdCalculationType.LastThreeFrames), unitInfoLogic.GetPPD(status, PpdCalculationType.LastThreeFrames, calculateBonus)));
               output.Add(String.Format(" All  Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                  unitInfoLogic.GetFrameTime(PpdCalculationType.AllFrames), unitInfoLogic.GetPPD(status, PpdCalculationType.AllFrames, calculateBonus)));
               output.Add(String.Format(" Eff. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                  unitInfoLogic.GetFrameTime(PpdCalculationType.EffectiveRate), unitInfoLogic.GetPPD(status, PpdCalculationType.EffectiveRate, calculateBonus)));
            }

            output.Add(String.Empty);
             }
             else
             {
            _logger.Warn("Could not find Project {0}.", benchmark.ProjectID);
             }

             return output.ToArray();
        }
示例#8
0
 private bool UnitInfoExists(UnitInfoLogic unitInfoLogic)
 {
     var rows = Fetch(BuildUnitKeyQueryParameters(unitInfoLogic));
      return rows.Count != 0;
 }
示例#9
0
 private static QueryParameters BuildUnitKeyQueryParameters(UnitInfoLogic unitInfoLogic)
 {
     var parameters = new QueryParameters();
      parameters.Fields.Add(new QueryField { Name = QueryFieldName.ProjectID, Type = QueryFieldType.Equal, Value = unitInfoLogic.UnitInfoData.ProjectID });
      parameters.Fields.Add(new QueryField { Name = QueryFieldName.ProjectRun, Type = QueryFieldType.Equal, Value = unitInfoLogic.UnitInfoData.ProjectRun });
      parameters.Fields.Add(new QueryField { Name = QueryFieldName.ProjectClone, Type = QueryFieldType.Equal, Value = unitInfoLogic.UnitInfoData.ProjectClone });
      parameters.Fields.Add(new QueryField { Name = QueryFieldName.ProjectGen, Type = QueryFieldType.Equal, Value = unitInfoLogic.UnitInfoData.ProjectGen });
      parameters.Fields.Add(new QueryField { Name = QueryFieldName.DownloadDateTime, Type = QueryFieldType.Equal, Value = unitInfoLogic.UnitInfoData.DownloadTime });
      return parameters;
 }
示例#10
0
        public void Insert(UnitInfoLogic unitInfoLogic)
        {
            // if the work unit is not valid simply return
             if (!ValidateUnitInfo(unitInfoLogic.UnitInfoData)) return;

             // The Insert operation does not setup a WuHistory table if
             // it does not exist.  This was already handled when the
             // the DatabaseFilePath was set.
             Debug.Assert(TableExists(SqlTable.WuHistory));

             // ensure this unit is not written twice
             if (!UnitInfoExists(unitInfoLogic))
             {
            var entry = AutoMapper.Mapper.Map<HistoryEntry>(unitInfoLogic.UnitInfoData);
            // cannot map these two properties from a UnitInfo instance
            // they only live at the UnitInfoLogic level
            entry.FramesCompleted = unitInfoLogic.FramesComplete;
            entry.FrameTimeValue = unitInfoLogic.GetRawTime(PpdCalculationType.AllFrames);
            // SetProtein also sets the SlotType
            entry.SetProtein(unitInfoLogic.CurrentProtein);
            Database.Insert(entry);
             }
        }