コード例 #1
0
        public void UnitInfo_GetUnitFrame_Test2()
        {
            // Arrange
            var unitInfo = new UnitInfo();
            var logLine  = new LogLine {
                LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame {
                    FrameID = 0
                }
            };

            unitInfo.LogLines = new List <LogLine>(new[] { logLine });
            // Act & Assert
            Assert.IsNotNull(unitInfo.GetUnitFrame(0));
            Assert.IsNull(unitInfo.GetUnitFrame(1));
        }
コード例 #2
0
        public void UnitInfo_GetUnitFrame_Test1()
        {
            // Arrange
            var unitInfo = new UnitInfo();

            // Act & Assert
            Assert.IsNull(unitInfo.GetUnitFrame(0));
        }
コード例 #3
0
        private bool UpdateFrames(UnitInfo unit, int startingFrame, int endingFrame, ProteinBenchmark benchmark)
        {
            bool result = false;

            for (int i = startingFrame; i <= endingFrame; i++)
            {
                UnitFrame frame = unit.GetUnitFrame(i);
                if (frame != null)
                {
                    if (benchmark.SetFrameTime(frame.FrameDuration))
                    {
                        result = true;
                    }
                }
                else
                {
                    Logger.DebugFormat("({0}) FrameID '{1}' not found for Project {2}", unit.OwningSlotName, i, unit.ProjectID);
                }
            }

            return(result);
        }
コード例 #4
0
ファイル: UnitInfoModel.cs プロジェクト: pnoodles/hfm-net
        /// <summary>
        /// Get the average duration over the specified number of most recent frames
        /// </summary>
        /// <param name="numberOfFrames">Number of most recent frames</param>
        private int GetDurationInSeconds(int numberOfFrames)
        {
            // the numberOfFrames must be 1 or greater
            // if CurrentFrame is null then no frames have been captured yet
            if (numberOfFrames < 1 || _unitInfo.CurrentFrame == null)
            {
                return(0);
            }

            // init return value
            int averageSeconds = 0;

            // Make sure we only add frame durations greater than a Zero TimeSpan
            // The first frame will always have a Zero TimeSpan for frame duration
            // we don't want to take this frame into account when calculating 'AllFrames' - Issue 23
            TimeSpan totalTime   = TimeSpan.Zero;
            int      countFrames = 0;

            int frameId = _unitInfo.CurrentFrame.FrameID;

            for (int i = 0; i < numberOfFrames; i++)
            {
                // Issue 199
                var unitFrame = _unitInfo.GetUnitFrame(frameId);
                if (unitFrame != null && unitFrame.FrameDuration > TimeSpan.Zero)
                {
                    totalTime = totalTime.Add(unitFrame.FrameDuration);
                    countFrames++;
                }
                frameId--;
            }

            if (countFrames > 0)
            {
                averageSeconds = Convert.ToInt32(totalTime.TotalSeconds) / countFrames;
            }

            return(averageSeconds);
        }