Permalink
Browse files

Small fixes to CurrentBenchmark picking

  • Loading branch information...
1 parent f84bd65 commit de2a0c8a0592230bcff3d411ed735955867bdf4b @KBomba committed Jan 24, 2015
Showing with 26 additions and 33 deletions.
  1. +11 −22 ccMonitor/GpuLogger.cs
  2. +1 −1 ccMonitor/Gui/HashChart.cs
  3. +14 −4 ccMonitor/Gui/Monitor.Designer.cs
  4. +0 −6 ccMonitor/Gui/Monitor.resx
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Windows.Forms.DataVisualization.Charting;
using ccMonitor.Api;
namespace ccMonitor
@@ -313,11 +312,13 @@ public void Update(Dictionary<string, string>[][] allApiResults, int[] pingTimes
ChangeAvailability(true, availability.RequestedByClose, CurrentBenchmark);
}
- CurrentBenchmark = currentBenchmark;
- CurrentBenchmark.MinerSetup.ApiVersion = liveSetup.ApiVersion;
+ if (currentBenchmark != CurrentBenchmark)
+ {
+ ChangeAvailability(false, false, CurrentBenchmark);
+ CurrentBenchmark = currentBenchmark;
+ }
UpdateSensors(rightHwInfo, pingTimes);
- // Updates the hardware sensors + "network sensors"
UpdateHashLog(history);
@@ -334,28 +335,18 @@ public void Update(Dictionary<string, string>[][] allApiResults, int[] pingTimes
public Benchmark GetCurrentBenchmark(string liveAlgo)
{
Benchmark currentBenchmark = null;
- Benchmark plausibleBenchmark = null;
// CurrentBenchmark is the one with the right live algo and is active
// If there's a new algo, etc, currentBenchmark will stay null
foreach (Benchmark benchmark in BenchLogs)
{
- if (benchmark.Algorithm == liveAlgo)
+ if (benchmark.Algorithm == liveAlgo &&
+ (currentBenchmark == null || benchmark.TimeStarted > currentBenchmark.TimeStarted))
{
- Benchmark.Availability availability = benchmark.AvailableTimeStamps.LastOrDefault();
- if (availability != null && availability.Available)
- {
- currentBenchmark = benchmark;
- break;
- }
-
- if (plausibleBenchmark == null || benchmark.TimeUpdated > plausibleBenchmark.TimeUpdated)
- {
- plausibleBenchmark = benchmark;
- }
+ currentBenchmark = benchmark;
}
}
- return currentBenchmark ?? plausibleBenchmark;
+ return currentBenchmark;
}
private static Benchmark.Setup GetLiveSetup(Dictionary<string, string> hwInfo, Dictionary<string, string> setupInfo,
@@ -848,6 +839,7 @@ private void CreateNewBenchMark(string liveAlgo, Benchmark.Setup liveSetup)
TimeStamp = unixTimeStamp,
Algorithm = liveAlgo,
MinerSetup = liveSetup,
+ TimeStarted = UnixTimeStamp(),
HashLogs = new HashSet<Benchmark.HashEntry>(),
SensorLog = new List<Benchmark.SensorValue>(),
Statistics = new List<Benchmark.GpuStat>(),
@@ -876,7 +868,7 @@ public void ChangeAvailability(bool available, bool monitorClosing = false, Benc
if (benchmark == null)
{
if (BenchLogs == null || BenchLogs.Count == 0) return;
- benchmark = BenchLogs.Last();
+ benchmark = CurrentBenchmark ?? BenchLogs.Last();
}
long unixTimeStamp = UnixTimeStamp();
@@ -892,7 +884,6 @@ public void ChangeAvailability(bool available, bool monitorClosing = false, Benc
benchmark.AvailableTimeStamps.Add(new Benchmark.Availability()
{
TimeStamp = unixTimeStamp,
- //Stratum = prevAvailableTimeStamp.Stratum,
Available = true,
RequestedByClose = prevAvailableTimeStamp.RequestedByClose
});
@@ -902,7 +893,6 @@ public void ChangeAvailability(bool available, bool monitorClosing = false, Benc
benchmark.AvailableTimeStamps.Add(new Benchmark.Availability()
{
TimeStamp = unixTimeStamp,
- //Stratum = CurrentBenchmark == null ? string.Empty : CurrentBenchmark.MinerSetup.MiningUrl,
Available = false,
RequestedByClose = monitorClosing
});
@@ -914,7 +904,6 @@ public void ChangeAvailability(bool available, bool monitorClosing = false, Benc
benchmark.AvailableTimeStamps.Add(new Benchmark.Availability()
{
TimeStamp = unixTimeStamp,
- //Stratum = benchmark.MinerSetup == null ? string.Empty : benchmark.MinerSetup.MiningUrl,
Available = true,
RequestedByClose = monitorClosing
});
@@ -47,7 +47,7 @@ public void UpdateCharts(HashSet<GpuLogger.Benchmark.HashEntry> hashLogs, List<G
HashCount = hashEntry.HashCount
}).Where(chartFriendlyHashEntry => _hours > 9000 || chartFriendlyHashEntry.TimeStamp > (now - start));
- IList<ChartFriendlyHashEntry> values = friendlyHashEntries as IList<ChartFriendlyHashEntry> ?? friendlyHashEntries.ToList();
+ List<ChartFriendlyHashEntry> values = friendlyHashEntries as List<ChartFriendlyHashEntry> ?? friendlyHashEntries.ToList();
if (values.Count > 0)
{
chartFriendlyHashEntries.AddRange(values);
@@ -43,6 +43,7 @@ private void InitializeComponent()
this.clmHashRate = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.clmStandardDeviation = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.clmHashCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.clmFounds = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.clmAccepts = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.clmRejects = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.clmTemperature = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
@@ -57,7 +58,7 @@ private void InitializeComponent()
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.readMeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.clmFounds = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.refreshRateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tbcMonitor.SuspendLayout();
this.tabGeneral.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.scGeneral)).BeginInit();
@@ -199,6 +200,11 @@ private void InitializeComponent()
this.clmHashCount.Text = "Hash Count";
this.clmHashCount.Width = 100;
//
+ // clmFounds
+ //
+ this.clmFounds.Text = "Found";
+ this.clmFounds.Width = 50;
+ //
// clmAccepts
//
this.clmAccepts.Text = "Accepts";
@@ -271,6 +277,8 @@ private void InitializeComponent()
//
// settingsToolStripMenuItem
//
+ this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.refreshRateToolStripMenuItem});
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
this.settingsToolStripMenuItem.Text = "Settings";
@@ -298,10 +306,11 @@ private void InitializeComponent()
this.aboutToolStripMenuItem.Text = "About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
//
- // clmFounds
+ // refreshRateToolStripMenuItem
//
- this.clmFounds.Text = "Found";
- this.clmFounds.Width = 50;
+ this.refreshRateToolStripMenuItem.Name = "refreshRateToolStripMenuItem";
+ this.refreshRateToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.refreshRateToolStripMenuItem.Text = "Refresh rate";
//
// Monitor
//
@@ -359,5 +368,6 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem showRawLogsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem takeScreenshotToolStripMenuItem;
private System.Windows.Forms.ColumnHeader clmFounds;
+ private System.Windows.Forms.ToolStripMenuItem refreshRateToolStripMenuItem;
}
}
@@ -123,12 +123,6 @@
<metadata name="Port.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
- <metadata name="IpAddress.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="Port.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
<metadata name="menuGeneral.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>

0 comments on commit de2a0c8

Please sign in to comment.