private static WorkUnitFrameData GetGpuFrameData(LogLine logLine)
            {
                Debug.Assert(logLine != null);

                Match framesCompletedGpu = FahLogRegex.Common.FramesCompletedGpuRegex.Match(logLine.Raw);

                if (framesCompletedGpu.Success)
                {
                    var frame = new WorkUnitFrameData();

                    frame.RawFramesComplete = Int32.Parse(framesCompletedGpu.Result("${Percent}"));
                    frame.RawFramesTotal    = 100; //Instance.CurrentProtein.Frames
                    // I get this from the project data but what's the point. 100% is 100%.

                    if (logLine.TimeStamp != null)
                    {
                        frame.TimeStamp = logLine.TimeStamp.Value;
                    }
                    frame.ID = frame.RawFramesComplete;

                    return(frame);
                }

                return(null);
            }
            internal static WorkUnitFrameData ParseWorkUnitFrame(LogLine logLine)
            {
                WorkUnitFrameData frameData = GetFrameData(logLine);

                if (frameData != null)
                {
                    return(frameData);
                }

                frameData = GetGpuFrameData(logLine);
                return(frameData);
            }
        private bool UpdateFrames(UnitInfo unit, int startingFrame, int endingFrame, ProteinBenchmark benchmark)
        {
            bool result = false;

            for (int i = startingFrame; i <= endingFrame; i++)
            {
                WorkUnitFrameData frameData = unit.GetFrameData(i);
                if (frameData != null)
                {
                    if (benchmark.SetFrameDuration(frameData.Duration))
                    {
                        result = true;
                    }
                }
                else
                {
                    Logger.DebugFormat("({0}) FrameID '{1}' not found for Project {2}", unit.OwningSlotName, i, unit.ProjectID);
                }
            }

            return(result);
        }
            private static WorkUnitFrameData GetFrameData(LogLine logLine)
            {
                Debug.Assert(logLine != null);

                Match framesCompleted = FahLogRegex.Common.FramesCompletedRegex.Match(logLine.Raw);

                if (framesCompleted.Success)
                {
                    var frame = new WorkUnitFrameData();

                    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)
                    {
                        if (logLine.TimeStamp != null)
                        {
                            frame.TimeStamp = logLine.TimeStamp.Value;
                        }
                        frame.ID = framePercent;

                        return(frame);
                    }

                    /*** ProtoMol Only */
                    // Issue 191 - New ProtoMol Projects don't report frame progress on the percent boundary.
                    if (Math.Abs(calculatedPercent - (framePercent + 1)) <= 0.1)
                    {
                        if (logLine.TimeStamp != null)
                        {
                            frame.TimeStamp = logLine.TimeStamp.Value;
                        }
                        frame.ID = framePercent + 1;

                        return(frame);
                    }
                    /*******************/

                    return(null);
                }

                return(null);
            }