private void btnParse_Click(object sender, EventArgs e) { if (txtLogPath.Text.Length == 0) { return; } treeView1.Nodes.Clear(); if (File.Exists(txtLogPath.Text)) { FahLogType fahLogType = GetLogFileType(); //var sw = Stopwatch.StartNew(); _fahLog = FahLog.Read(File.ReadLines(txtLogPath.Text), fahLogType); //sw.Stop(); //Debug.WriteLine("FahLog.Read ET: {0}", sw.Elapsed); _logLines = _fahLog.ToList(); PopulateClientRunsInTree(_fahLog); richTextBox1.SetLogLines(_logLines, String.Empty, true); } else { MessageBox.Show(this, String.Format(CultureInfo.CurrentCulture, "File '{0}' does not exist.", txtLogPath.Text), Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void MessageConnectionMessageReceived(object sender, MessageReceivedEventArgs e) { if (AbortFlag) { return; } Logger.DebugFormat(Constants.ClientNameFormat, Settings.Name, e.JsonMessage.GetHeader()); _messages.Add(e); if (e.DataType == typeof(SlotCollection)) { foreach (var slot in _messages.SlotCollection) { _messageConnection.SendCommand(String.Format(CultureInfo.InvariantCulture, Constants.FahClientSlotOptions, slot.Id)); } } else if (e.DataType == typeof(LogRestart) || e.DataType == typeof(LogUpdate)) { bool createNew = e.DataType == typeof(LogRestart); if (createNew) { _fahLog.Clear(); } var logFragment = (LogFragment)e.TypedMessage; string filteredLogFragment = String.Join("\n", logFragment.Value.Split('\n').Where(x => x.Length != 0)); using (var textReader = new StringReader(filteredLogFragment)) using (var reader = new Log.FahClient.FahClientLogTextReader(textReader)) { _fahLog.Read(reader); } WriteToLocalFahLogCache(logFragment.Value, createNew); if (_messages.LogRetrieved) { _messageConnection.SendCommand("queue-info"); } } }
/// <summary> /// Process the cached log files that exist on this machine /// </summary> private void Process() { var sw = Stopwatch.StartNew(); // Set successful Last Retrieval Time LastRetrievalTime = DateTime.Now; // Re-Init Slot Level Members Before Processing _slotModel.Initialize(); #region Setup Aggregator var dataAggregator = new LegacyDataAggregator { Logger = Logger }; dataAggregator.ClientName = Settings.Name; string queueFilePath = Path.Combine(Prefs.CacheDirectory, Settings.CachedQueueFileName()); string fahLogFilePath = Path.Combine(Prefs.CacheDirectory, Settings.CachedFahLogFileName()); string unitInfoLogFilePath = Path.Combine(Prefs.CacheDirectory, Settings.CachedUnitInfoFileName()); #endregion #region Run the Aggregator var queue = ReadQueueFile(queueFilePath); var fahLog = FahLog.Read(File.ReadLines(fahLogFilePath), FahLogType.Legacy); var unitInfo = ReadUnitInfoFile(unitInfoLogFilePath); var result = dataAggregator.AggregateData(fahLog, queue, unitInfo); // 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(result, _slotModel); if (result.Queue != null) { PopulateRunLevelData(result.Queue.Current, _slotModel); } _slotModel.Queue = result.Queue; _slotModel.CurrentLogLines = result.CurrentLogLines; _slotModel.UnitLogLines = result.UnitInfos.OrderBy(x => x.Key).Select(x => x.Value != null ? x.Value.LogLines : null).ToArray(); #endregion var parsedUnits = new UnitInfoModel[result.UnitInfos.Count]; for (int i = 0; i < result.UnitInfos.Count; i++) { if (result.UnitInfos[i] != null) { parsedUnits[i] = BuildUnitInfoLogic(result.UnitInfos[i], true); } } // *** THIS HAS TO BE DONE BEFORE UPDATING SlotModel.UnitInfoLogic *** UpdateBenchmarkData(_slotModel.UnitInfoModel, parsedUnits, result.CurrentUnitIndex); // Update the UnitInfoLogic if we have a Status if (result.Status != SlotStatus.Unknown) { _slotModel.UnitInfoModel = parsedUnits[result.CurrentUnitIndex]; } HandleReturnedStatus(result.Status, _slotModel); _slotModel.UnitInfoModel.ShowPPDTrace(Logger, _slotModel.Name, _slotModel.Status, Prefs.Get <PpdCalculationType>(Preference.PpdCalculation), Prefs.Get <BonusCalculationType>(Preference.BonusCalculation)); string statusMessage = String.Format(CultureInfo.CurrentCulture, "Client Status: {0}", _slotModel.Status); Logger.InfoFormat(Constants.ClientNameFormat, _slotModel.Name, statusMessage); string message = String.Format(CultureInfo.CurrentCulture, "Retrieval finished: {0}", sw.GetExecTime()); Logger.InfoFormat(Constants.ClientNameFormat, Settings.Name, message); }
public void Client_v7_10_0() { const int slotId = 0; _dataAggregator.ClientName = "Client_v7_10"; var fahLog = FahLog.Read(File.ReadLines("..\\..\\..\\TestFiles\\Client_v7_10\\log.txt"), FahLogType.FahClient); 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.First(), 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(660000, unitInfoData.RawFramesComplete); Assert.AreEqual(2000000, unitInfoData.RawFramesTotal); Assert.AreEqual(10, unitInfoData.FramesObserved); Assert.AreEqual(33, unitInfoData.CurrentFrame.FrameID); Assert.AreEqual(new TimeSpan(4, 46, 8), unitInfoData.CurrentFrame.TimeOfFrame); Assert.AreEqual(new TimeSpan(0, 8, 31), unitInfoData.CurrentFrame.FrameDuration); Assert.AreEqual("A4", unitInfoData.CoreID); #endregion }