Beispiel #1
0
        private void btnParse_Click(object sender, EventArgs e)
        {
            if (txtLogPath.Text.Length == 0)
            {
                return;
            }

            treeView1.Nodes.Clear();

            if (File.Exists(txtLogPath.Text))
            {
#if DEBUG
                var sw = Stopwatch.StartNew();
#endif
                _fahLog = FahClientLog.Read(txtLogPath.Text);
#if DEBUG
                sw.Stop();
                Debug.WriteLine("FahLog.Read ET: {0}", sw.Elapsed);
#endif
                _logLines = LogLineEnumerable.Create(_fahLog).ToList();
                PopulateClientRunsInTree(_fahLog);
                richTextBox1.SetLogLines(_logLines, true);
            }
            else
            {
                MessageBox.Show(this, String.Format(CultureInfo.CurrentCulture,
                                                    "File '{0}' does not exist.", txtLogPath.Text), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Reads the log file from the given path and returns a new <see cref="FahClientLog"/> object.
 /// </summary>
 /// <param name="path">The log file path.</param>
 /// <returns>A new <see cref="FahClientLog"/> object.</returns>
 public static FahClientLog Read(string path)
 {
     using (var textReader = new StreamReader(path))
         using (var reader = new FahClientLogTextReader(textReader))
         {
             var log = new FahClientLog();
             log.Read(reader);
             return(log);
         }
 }
Beispiel #3
0
            /// <summary>
            /// Reads the log file asynchronously from the given path and returns a new <see cref="FahClientLog"/> object.
            /// </summary>
            /// <param name="path">The log file path.</param>
            /// <returns>A new <see cref="FahClientLog"/> object.</returns>
            public static async Task <FahClientLog> ReadAsync(string path)
            {
                using (var textReader = new StreamReader(path))
                    using (var reader = new FahClientLogTextReader(textReader))
                    {
                        var log = new FahClientLog();
                        await log.ReadAsync(reader).ConfigureAwait(false);

                        return(log);
                    }
            }
        public void Client_v7_10_0()
        {
            const int slotId = 0;

            _dataAggregator.ClientName = "Client_v7_10";

            var fahLog = FahClientLog.Read("..\\..\\..\\TestFiles\\Client_v7_10\\log.txt");

            string message        = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\units.txt");
            var    unitCollection = new UnitCollection();

            unitCollection.Fill(JsonMessageConnection.GetNextJsonMessage(ref message));

            message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\info.txt");
            var info = new Info();

            info.Fill(JsonMessageConnection.GetNextJsonMessage(ref message));

            message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\options.txt");
            var options = new Options();

            options.Fill(JsonMessageConnection.GetNextJsonMessage(ref message));

            message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\slot-options1.txt");
            var slotOptions = new SlotOptions();

            slotOptions.Fill(JsonMessageConnection.GetNextJsonMessage(ref message));

            var result = _dataAggregator.AggregateData(fahLog.ClientRuns.Last(), unitCollection, info, options, slotOptions, new UnitInfo(), slotId);

            Assert.AreEqual(1, result.UnitInfos.Count);
            Assert.IsFalse(result.UnitInfos.Any(x => x.Value == null));

            #region Check Data Aggregator

            Assert.IsNotNull(result.Queue);
            Assert.AreEqual(1, result.CurrentUnitIndex);
            Assert.AreEqual(new DateTime(2012, 1, 11, 3, 24, 22), result.StartTime);
            Assert.AreEqual(null, result.Arguments);
            Assert.AreEqual(null, result.ClientVersion);
            Assert.AreEqual(null, result.UserID);
            Assert.AreEqual(0, result.MachineID);
            Assert.AreEqual(SlotStatus.Unknown, result.Status);
            Assert.IsNotNull(result.CurrentLogLines);
            Assert.IsFalse(result.UnitInfos.Any(x => x.Value.LogLines == null));
            if (result.UnitInfos.ContainsKey(result.CurrentUnitIndex))
            {
                Assert.AreEqual(result.CurrentLogLines, result.UnitInfos[result.CurrentUnitIndex].LogLines);
            }

            #endregion

            var unitInfoData = result.UnitInfos[result.CurrentUnitIndex];

            #region Check Unit Info Data Values
            Assert.AreEqual(null, unitInfoData.OwningSlotName);
            Assert.AreEqual(null, unitInfoData.OwningClientName);
            Assert.AreEqual(null, unitInfoData.OwningClientPath);
            Assert.AreEqual(-1, unitInfoData.OwningSlotId);
            Assert.AreEqual(DateTime.MinValue, unitInfoData.UnitRetrievalTime);
            Assert.AreEqual("harlam357", unitInfoData.FoldingID);
            Assert.AreEqual(32, unitInfoData.Team);
            Assert.AreEqual(SlotType.CPU, unitInfoData.SlotType);
            Assert.AreEqual(new DateTime(2012, 1, 10, 23, 20, 27), unitInfoData.DownloadTime);
            Assert.AreEqual(new DateTime(2012, 1, 22, 16, 22, 51), unitInfoData.DueTime);
            Assert.AreEqual(new TimeSpan(3, 25, 32), unitInfoData.UnitStartTimeStamp);
            Assert.AreEqual(DateTime.MinValue, unitInfoData.FinishedTime);
            Assert.AreEqual(2.27f, unitInfoData.CoreVersion);
            Assert.AreEqual(7610, unitInfoData.ProjectID);
            Assert.AreEqual(630, unitInfoData.ProjectRun);
            Assert.AreEqual(0, unitInfoData.ProjectClone);
            Assert.AreEqual(59, unitInfoData.ProjectGen);
            Assert.AreEqual(String.Empty, unitInfoData.ProteinName);
            Assert.AreEqual(String.Empty, unitInfoData.ProteinTag);
            Assert.AreEqual(WorkUnitResult.Unknown, unitInfoData.UnitResult);
            Assert.AreEqual(10, unitInfoData.FramesObserved);
            Assert.AreEqual(33, unitInfoData.CurrentFrame.ID);
            Assert.AreEqual(660000, unitInfoData.CurrentFrame.RawFramesComplete);
            Assert.AreEqual(2000000, unitInfoData.CurrentFrame.RawFramesTotal);
            Assert.AreEqual(new TimeSpan(4, 46, 8), unitInfoData.CurrentFrame.TimeStamp);
            Assert.AreEqual(new TimeSpan(0, 8, 31), unitInfoData.CurrentFrame.Duration);
            Assert.AreEqual("A4", unitInfoData.CoreID);
            #endregion
        }
        public void Client_v7_10_0_UnitDataOnly()
        {
            const int slotId = 0;

            _dataAggregator.ClientName = "Client_v7_10";

            var    fahLog          = new FahClientLog();
            string filteredLogText = String.Join(Environment.NewLine, File.ReadLines("..\\..\\..\\TestFiles\\Client_v7_10\\log.txt").Where(x => x.Length != 0).Take(82));

            using (var textReader = new StringReader(filteredLogText))
                using (var reader = new FahClientLogTextReader(textReader))
                {
                    fahLog.Read(reader);
                }

            string message        = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\units.txt");
            var    unitCollection = new UnitCollection();

            unitCollection.Fill(JsonMessageConnection.GetNextJsonMessage(ref message));

            message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\info.txt");
            var info = new Info();

            info.Fill(JsonMessageConnection.GetNextJsonMessage(ref message));

            message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\options.txt");
            var options = new Options();

            options.Fill(JsonMessageConnection.GetNextJsonMessage(ref message));

            message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\slot-options1.txt");
            var slotOptions = new SlotOptions();

            slotOptions.Fill(JsonMessageConnection.GetNextJsonMessage(ref message));

            var result = _dataAggregator.AggregateData(fahLog.ClientRuns.Last(), unitCollection, info, options, slotOptions, new UnitInfo(), slotId);

            Assert.AreEqual(1, result.UnitInfos.Count);
            Assert.IsFalse(result.UnitInfos.Any(x => x.Value == null));

            #region Check Data Aggregator

            Assert.IsNotNull(result.Queue);
            Assert.AreEqual(1, result.CurrentUnitIndex);
            Assert.AreEqual(new DateTime(2012, 1, 11, 3, 24, 22), result.StartTime);
            Assert.AreEqual(null, result.Arguments);
            Assert.AreEqual(null, result.ClientVersion);
            Assert.AreEqual(null, result.UserID);
            Assert.AreEqual(0, result.MachineID);
            Assert.AreEqual(SlotStatus.Unknown, result.Status);
            Assert.IsNotNull(result.CurrentLogLines);
            Assert.IsTrue(result.UnitInfos.All(x => x.Value.LogLines == null));
            if (result.UnitInfos.ContainsKey(result.CurrentUnitIndex))
            {
                Assert.AreEqual(result.CurrentLogLines, LogLineEnumerable.Create(fahLog.ClientRuns.Last()));
            }

            #endregion

            var unitInfoData = result.UnitInfos[result.CurrentUnitIndex];

            #region Check Unit Info Data Values
            Assert.AreEqual(null, unitInfoData.OwningSlotName);
            Assert.AreEqual(null, unitInfoData.OwningClientName);
            Assert.AreEqual(null, unitInfoData.OwningClientPath);
            Assert.AreEqual(-1, unitInfoData.OwningSlotId);
            Assert.AreEqual(DateTime.MinValue, unitInfoData.UnitRetrievalTime);
            Assert.AreEqual("harlam357", unitInfoData.FoldingID);
            Assert.AreEqual(32, unitInfoData.Team);
            Assert.AreEqual(SlotType.CPU, unitInfoData.SlotType);
            Assert.AreEqual(new DateTime(2012, 1, 10, 23, 20, 27), unitInfoData.DownloadTime);
            Assert.AreEqual(new DateTime(2012, 1, 22, 16, 22, 51), unitInfoData.DueTime);
            Assert.AreEqual(TimeSpan.Zero, unitInfoData.UnitStartTimeStamp);
            Assert.AreEqual(DateTime.MinValue, unitInfoData.FinishedTime);
            Assert.AreEqual(0, unitInfoData.CoreVersion);
            Assert.AreEqual(7610, unitInfoData.ProjectID);
            Assert.AreEqual(630, unitInfoData.ProjectRun);
            Assert.AreEqual(0, unitInfoData.ProjectClone);
            Assert.AreEqual(59, unitInfoData.ProjectGen);
            Assert.AreEqual(String.Empty, unitInfoData.ProteinName);
            Assert.AreEqual(String.Empty, unitInfoData.ProteinTag);
            Assert.AreEqual(WorkUnitResult.Unknown, unitInfoData.UnitResult);
            Assert.AreEqual(0, unitInfoData.FramesObserved);
            Assert.IsNull(unitInfoData.CurrentFrame);
            Assert.AreEqual("A4", unitInfoData.CoreID);
            #endregion
        }