Esempio n. 1
0
 public void UnitInfo_CurrentFrame_Test2()
 {
    // Arrange
    var unitInfo = new UnitInfo();
    var unitFrame = new UnitFrame { FrameID = 0 };
    var logLine = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame };
    unitInfo.LogLines = new List<LogLine>(new[] { logLine });
    // Act & Assert
    Assert.AreSame(unitFrame, unitInfo.CurrentFrame);
 }
Esempio n. 2
0
 public void UnitInfo_CurrentFrame_Test3()
 {
    // Arrange
    var unitInfo = new UnitInfo();
    var logLine0 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 0 } };
    var logLine1 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 1 } };
    var unitFrame5 = new UnitFrame { FrameID = 5 };
    var logLine5 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame5 };
    unitInfo.LogLines = new List<LogLine>(new[] { logLine0, logLine1, logLine5 });
    // Act & Assert
    Assert.AreSame(unitFrame5, unitInfo.CurrentFrame);
 }
Esempio n. 3
0
      internal virtual object GetLineData(LogLine logLine)
      {
         switch (logLine.LineType)
         {
            case LogLineType.WorkUnitProject:
               Match projectIdMatch;
               if ((projectIdMatch = ProjectIDRegex.Match(logLine.LineRaw)).Success)
               {
                  return projectIdMatch;
               }
               return new LogLineError(String.Format("Failed to parse Project (R/C/G) values from '{0}'", logLine.LineRaw));
            case LogLineType.WorkUnitCoreVersion:
               Match coreVersionMatch;
               if ((coreVersionMatch = CoreVersionRegex.Match(logLine.LineRaw)).Success)
               {
                  float value;
                  if (Single.TryParse(coreVersionMatch.Result("${CoreVer}").Trim(), NumberStyles.Number, CultureInfo.InvariantCulture, out value))
                  {
                     return value;
                  }
                  return new LogLineError(String.Format("Failed to parse Core Version value from '{0}'", logLine.LineRaw));
               }
               // return null here because a derived parser may also parse these lines
               // if we were to return LogLineError the line would be marked as an error
               // line and we don't want that (see LogLineParserLegacy).
               return null;
            case LogLineType.WorkUnitFrame:
               UnitFrame frame = GetUnitFrame(logLine);
               if (frame != null)
               {
                  return frame;
               }
               frame = GetGpuUnitFrame(logLine);
               if (frame != null)
               {
                  return frame;
               }
               return new LogLineError(String.Format("Failed to parse Frame Data from '{0}'", logLine.LineRaw));
            case LogLineType.WorkUnitCoreShutdown:
               Match coreShutdownMatch;
               if ((coreShutdownMatch = CoreShutdownRegex.Match(logLine.LineRaw)).Success)
               {
                  // remove any carriage returns from fahclient log lines - 12/30/11
                  string unitResultValue = coreShutdownMatch.Result("${UnitResult}").Replace("\r", String.Empty);
                  return unitResultValue.ToWorkUnitResult();
               }
               return new LogLineError(String.Format("Failed to parse Work Unit Result value from '{0}'", logLine.LineRaw));
         }

         return null;
      }
Esempio n. 4
0
 internal static UnitFrame ParseWorkUnitFrame(LogLine logLine)
 {
    UnitFrame frame = GetUnitFrame(logLine);
    if (frame != null)
    {
       return frame;
    }
    frame = GetGpuUnitFrame(logLine);
    if (frame != null)
    {
       return frame;
    }
    return null;
 }
Esempio n. 5
0
      protected override void HandleLogOpen(LogLine logLine)
      {
         // only respect the first LogOpen line that is observed - 7/28/14
         if (!_logOpenObserved)
         {
            base.HandleLogOpen(logLine);

            if (CurrentClientRun != null)
            {
               CurrentClientRun.StartTime = (DateTime)logLine.LineData;
            }
         }
         _logOpenObserved = true;
      }
Esempio n. 6
0
 internal static ProjectInfo ParseWorkUnitProject(LogLine logLine)
 {
    Match projectIdMatch;
    if ((projectIdMatch = FahLogRegex.Common.ProjectIDRegex.Match(logLine.LineRaw)).Success)
    {
       return new ProjectInfo
       {
          ProjectID = Int32.Parse(projectIdMatch.Groups["ProjectNumber"].Value),
          ProjectRun = Int32.Parse(projectIdMatch.Groups["Run"].Value),
          ProjectClone = Int32.Parse(projectIdMatch.Groups["Clone"].Value),
          ProjectGen = Int32.Parse(projectIdMatch.Groups["Gen"].Value)
       };
    }
    return null;
 }
Esempio n. 7
0
        protected override void HandleLogHeader(LogLine logLine)
        {
            base.HandleLogHeader(logLine);

             // If the last line observed was a LogOpen or a LogHeader, return
             // and don't use this as a signal to add a new ClientRun.
             if (_currentLineType.Equals(LogLineType.LogOpen) ||
             _currentLineType.Equals(LogLineType.LogHeader)) return;

             // Otherwise, if we see a LogHeader and the preceeding line was not
             // a LogOpen or a LogHeader, then we use this as a signal to create
             // a new ClientRun.  This is a backup option and I don't expect this
             // situtation to happen at all if the log file is not corrupt.
             Add(new ClientRun(logLine.LineIndex));

             _currentLineType = logLine.LineType;
        }
Esempio n. 8
0
        protected override void HandleWorkUnitCleaningUp(LogLine logLine)
        {
            base.HandleWorkUnitCleaningUp(logLine);

             var queueIndex = (int)logLine.LineData;
             if (_unitIndexData.ContainsKey(queueIndex))
             {
            if (CurrentClientRun == null)
            {
               Add(new ClientRun(logLine.LineIndex));
            }

            Debug.Assert(CurrentClientRun != null);

            CurrentClientRun.UnitIndexes.Add(new UnitIndex(queueIndex, _unitIndexData[queueIndex].WorkingIndex, logLine.LineIndex));

            // remove from dictionary
            _unitIndexData.Remove(queueIndex);
             }
        }
Esempio n. 9
0
 internal static void SetLogLineParser(LogLine line, FahLogType fahLogType)
 {
    if (line.LineType == LogLineType.Unknown)
    {
       return;
    }
    Func<LogLine, object> parser;
    if (!CommonParsers.TryGetValue(line.LineType, out parser))
    {
       switch (fahLogType)
       {
          case FahLogType.Legacy:
             LegacyParsers.TryGetValue(line.LineType, out parser);
             break;
          case FahLogType.FahClient:
             FahClientParsers.TryGetValue(line.LineType, out parser);
             break;
       }
    }
    if (parser != null)
    {
       line.SetParser(parser);
    }
 }
Esempio n. 10
0
 protected override void HandleWorkUnitStart(LogLine logLine)
 {
     _unitIndexData.StartIndex = logLine.LineIndex;
      _currentLineType = logLine.LineType;
 }
Esempio n. 11
0
 protected override void HandleWorkUnitWorking(LogLine logLine)
 {
     // This first check allows us to overlook the "+ Working ..." message
      // that gets written after a client is Paused.  We don't want to key
      // work unit positions based on this log entry.
      if (_currentLineType.Equals(LogLineType.WorkUnitPaused))
      {
     // Return to a Running state
     _currentLineType = LogLineType.WorkUnitRunning;
      }
      else
      {
     _unitIndexData.WorkingIndex = logLine.LineIndex;
     _currentLineType = logLine.LineType;
      }
 }
Esempio n. 12
0
        protected override void HandleWorkUnitQueueIndex(LogLine logLine)
        {
            base.HandleWorkUnitQueueIndex(logLine);

             _unitIndexData.QueueSlotIndex = (int)logLine.LineData;
        }
Esempio n. 13
0
        protected override void HandleWorkUnitRunning(LogLine logLine)
        {
            if (CurrentClientRun == null)
             {
            Add(new ClientRun(logLine.LineIndex));
             }

             Debug.Assert(CurrentClientRun != null);

             // If we've already seen a WorkUnitRunning line, ignore this one.);
             if (_currentLineType.Equals(LogLineType.WorkUnitRunning)) return;

             // Not Checking the Queue Slot - we don't care if we found a valid slot or not
             if (_unitIndexData.ProcessingIndex > -1)
             {
            CurrentClientRun.UnitIndexes.Add(new UnitIndex(_unitIndexData.QueueSlotIndex, _unitIndexData.ProcessingIndex));
             }
             else if (_unitIndexData.WorkingIndex > -1)
             {
            CurrentClientRun.UnitIndexes.Add(new UnitIndex(_unitIndexData.QueueSlotIndex, _unitIndexData.WorkingIndex));
             }
             else if (_unitIndexData.StartIndex > -1)
             {
            CurrentClientRun.UnitIndexes.Add(new UnitIndex(_unitIndexData.QueueSlotIndex, _unitIndexData.StartIndex));
             }
             else
             {
            CurrentClientRun.UnitIndexes.Add(new UnitIndex(_unitIndexData.QueueSlotIndex, logLine.LineIndex));
             }

             _currentLineType = logLine.LineType;

             // Re-initialize Values
             _unitIndexData.Initialize();
        }
Esempio n. 14
0
 internal static object ParseClientCoreCommunicationsError(LogLine logLine)
 {
    return WorkUnitResult.ClientCoreError;
 }
Esempio n. 15
0
        protected override void HandleWorkUnitProcessing(LogLine logLine)
        {
            base.HandleWorkUnitProcessing(logLine);

             // If we have not found a ProcessingIndex (== -1) then set it.
             // Othwerwise, if ProcessingIndex (!= -1) and a CoreDownloadIndex
             // has been observerd and is greater than the current ProcessingIndex,
             // then update the ProcessingIndex to bypass the CoreDownload section
             // of the log file.
             if (_unitIndexData.ProcessingIndex == -1 ||
            (_unitIndexData.ProcessingIndex != -1 &&
             _unitIndexData.CoreDownloadIndex > _unitIndexData.ProcessingIndex))
             {
            _unitIndexData.ProcessingIndex = logLine.LineIndex;
             }

             _currentLineType = logLine.LineType;
        }
Esempio n. 16
0
 protected override void HandleWorkUnitCoreReturn(LogLine logLine)
 {
     AddWorkUnitResult(((UnitResult)logLine.LineData).Value);
 }
Esempio n. 17
0
        protected override void HandleWorkUnitCoreDownload(LogLine logLine)
        {
            base.HandleWorkUnitCoreDownload(logLine);

             _unitIndexData.CoreDownloadIndex = logLine.LineIndex;
             _currentLineType = logLine.LineType;
        }
Esempio n. 18
0
 internal static object ParseWorkUnitCoreVersion(LogLine logLine)
 {
    Match coreVersionMatch;
    if ((coreVersionMatch = FahLogRegex.Common.CoreVersionRegex.Match(logLine.LineRaw)).Success)
    {
       float value;
       if (Single.TryParse(coreVersionMatch.Result("${CoreVer}").Trim(), NumberStyles.Number, CultureInfo.InvariantCulture, out value))
       {
          return value;
       }
    }
    /*** ProtoMol Only */
    if ((coreVersionMatch = FahLogRegex.Legacy.ProtoMolCoreVersionRegex.Match(logLine.LineRaw)).Success)
    {
       float value;
       if (Single.TryParse(coreVersionMatch.Result("${CoreVer}").Trim(), NumberStyles.Number, CultureInfo.InvariantCulture, out value))
       {
          return value;
       }
    }
    /*******************/
    return null;
 }
Esempio n. 19
0
 internal static object ParseWorkUnitCallingCore(LogLine logLine)
 {
    Match workUnitCallingCoreMatch;
    if ((workUnitCallingCoreMatch = FahLogRegex.Legacy.WorkUnitCallingCore.Match(logLine.LineRaw)).Success)
    {
       return Int32.Parse(workUnitCallingCoreMatch.Result("${Threads}"));
    }
    // not an error - not all "Calling" lines will have a "-np X" in the line
    return 0;
 }
Esempio n. 20
0
 internal static object ParseWorkUnitCoreReturn(LogLine logLine)
 {
    Match coreReturnMatch;
    if ((coreReturnMatch = FahLogRegex.FahClient.WorkUnitCoreReturnRegex.Match(logLine.LineRaw)).Success)
    {
       return coreReturnMatch.Groups["UnitResult"].Value.ToWorkUnitResult();
    }
    return null;
 }
Esempio n. 21
0
 internal static object ParseWorkUnitCoreVersion(LogLine logLine)
 {
    Match coreVersionMatch;
    if ((coreVersionMatch = FahLogRegex.Common.CoreVersionRegex.Match(logLine.LineRaw)).Success)
    {
       string coreVer = coreVersionMatch.Groups["CoreVer"].Value.Trim();
       float value;
       if (Single.TryParse(coreVer, NumberStyles.Number, CultureInfo.InvariantCulture, out value))
       {
          return value;
       }
       // Try to parse GPU Core Versions in the 0.#.## format
       if (coreVer.StartsWith("0."))
       {
          if (Single.TryParse(coreVer.Substring(2), NumberStyles.Number, CultureInfo.InvariantCulture, out value))
          {
             return value;
          }
       }
    }
    return null;
 }
Esempio n. 22
0
         internal static object ParseLogOpen(LogLine logLine)
         {
            Match logOpenMatch;
            if ((logOpenMatch = FahLogRegex.FahClient.LogOpenRegex.Match(logLine.LineRaw)).Success)
            {
               string startTime = logOpenMatch.Result("${StartTime}");
               // Similar code found in HFM.Client.Converters.DateTimeConverter
               // ISO 8601
               DateTime value;
               if (DateTime.TryParse(startTime, CultureInfo.InvariantCulture,
                  DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out value))
               {
                  return value;
               }

               // custom format for older v7 clients
               if (DateTime.TryParseExact(startTime, "dd/MMM/yyyy-HH:mm:ss", CultureInfo.InvariantCulture,
                  DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out value))
               {
                  return value;
               }
            }
            return null;
         }
Esempio n. 23
0
 internal static object ParseWorkUnitQueueIndex(LogLine logLine)
 {
    Match queueIndexMatch;
    if ((queueIndexMatch = FahLogRegex.Legacy.QueueIndexRegex.Match(logLine.LineRaw)).Success)
    {
       return Int32.Parse(queueIndexMatch.Result("${QueueIndex}"));
    }
    return null;
 }
Esempio n. 24
0
 // ReSharper disable once InconsistentNaming
 internal static object ParseClientMachineID(LogLine logLine)
 {
    Match machineIdMatch;
    if ((machineIdMatch = FahLogRegex.Legacy.MachineIDRegex.Match(logLine.LineRaw)).Success)
    {
       return Int32.Parse(machineIdMatch.Result("${MachineID}"));
    }
    return null;
 }
Esempio n. 25
0
        protected override void HandleLogOpen(LogLine logLine)
        {
            base.HandleLogOpen(logLine);

             _currentLineType = logLine.LineType;
        }
Esempio n. 26
0
        protected override void HandleWorkUnitPaused(LogLine logLine)
        {
            base.HandleWorkUnitPaused(logLine);

             _currentLineType = logLine.LineType;
        }
Esempio n. 27
0
         private static UnitFrame GetUnitFrame(LogLine logLine)
         {
            Debug.Assert(logLine != null);

            Match framesCompleted = FahLogRegex.Common.FramesCompletedRegex.Match(logLine.LineRaw);
            if (framesCompleted.Success)
            {
               var frame = new UnitFrame();

               int result;
               if (Int32.TryParse(framesCompleted.Result("${Completed}"), out result))
               {
                  frame.RawFramesComplete = result;
               }
               else
               {
                  return null;
               }

               if (Int32.TryParse(framesCompleted.Result("${Total}"), out result))
               {
                  frame.RawFramesTotal = result;
               }
               else
               {
                  return null;
               }

               string percentString = framesCompleted.Result("${Percent}");

               Match mPercent1 = FahLogRegex.Common.Percent1Regex.Match(percentString);
               Match mPercent2 = FahLogRegex.Common.Percent2Regex.Match(percentString);

               int framePercent;
               if (mPercent1.Success)
               {
                  framePercent = Int32.Parse(mPercent1.Result("${Percent}"));
               }
               else if (mPercent2.Success)
               {
                  framePercent = Int32.Parse(mPercent2.Result("${Percent}"));
               }
               // Try to parse a percentage from in between the parentheses (for older single core clients like v5.02) - Issue 36
               else if (!Int32.TryParse(percentString, out framePercent))
               {
                  return null;
               }

               // Validate the steps are in tolerance with the detected frame percent - Issue 98
               double calculatedPercent = ((double)frame.RawFramesComplete / frame.RawFramesTotal) * 100;
               // ex. [00:19:40] Completed 82499 out of 250000 steps  (33%) - Would Validate
               //     [00:19:40] Completed 82750 out of 250000 steps  (33%) - Would Validate
               // 10% frame step tolerance. In the example the completed must be within 250 steps.
               if (Math.Abs(calculatedPercent - framePercent) <= 0.1)
               {
                  frame.TimeOfFrame = ParseTimeStamp(logLine);
                  frame.FrameID = framePercent;

                  return frame;
               }
               /*** ProtoMol Only */
               // Issue 191 - New ProtoMol Projects don't report frame progress on the precent boundry.
               if (Math.Abs(calculatedPercent - (framePercent + 1)) <= 0.1)
               {
                  frame.TimeOfFrame = ParseTimeStamp(logLine);
                  frame.FrameID = framePercent + 1;

                  return frame;
               }
               /*******************/

               return null;
            }

            return null;
         }
Esempio n. 28
0
 internal static object ParseClientNumberOfUnitsCompleted(LogLine logLine)
 {
    Match completedWorkUnitsMatch;
    if ((completedWorkUnitsMatch = FahLogRegex.Legacy.CompletedWorkUnitsRegex.Match(logLine.LineRaw)).Success)
    {
       return Int32.Parse(completedWorkUnitsMatch.Result("${Completed}"));
    }
    return null;
 }
Esempio n. 29
0
 protected override void HandleWorkUnitWorking(LogLine logLine)
 {
     var queueIndex = (int)logLine.LineData;
      _unitIndexData[queueIndex] = new UnitIndexData { QueueIndex = queueIndex, WorkingIndex = logLine.LineIndex };
 }
Esempio n. 30
0
        protected override void HandleWorkUnitCoreShutdown(LogLine logLine)
        {
            if (_currentLineType.Equals(LogLineType.WorkUnitRunning))
             {
            AddWorkUnitResult((WorkUnitResult)logLine.LineData);
             }

             _currentLineType = logLine.LineType;
        }