Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Fixes and improvements
Browse files Browse the repository at this point in the history
- Revamped benchmarking
- Added more config options
- Better handling of failed miner starts
- Added loading startup screen
  • Loading branch information
nicehashdev committed Oct 21, 2015
1 parent 324a7a3 commit 2a34342
Show file tree
Hide file tree
Showing 17 changed files with 526 additions and 208 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ cpuid/cpuid.vcxproj.user
*.pdb
*.idb
NiceHashMiner.sdf
NiceHashMiner.opensdf
11 changes: 11 additions & 0 deletions NiceHashMiner/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Group
{
#pragma warning disable 649
public string Name; // only used for easier manual identification in config file
public int APIBindPort;
public string ExtraLaunchParameters;
public string UsePassword;
public int[] DisabledDevices;
Expand All @@ -43,6 +44,9 @@ public class Config
public int LessThreads;
public int SwitchMinSecondsFixed;
public int SwitchMinSecondsDynamic;
public int MinerAPIQueryInterval;
public int MinerRestartDelayMS;
public int[] BenchmarkTimeLimits;
public Group[] Groups;
#pragma warning restore 649

Expand All @@ -66,6 +70,12 @@ static Config()
ConfigData.SwitchMinSecondsFixed = 3 * 60;
if (ConfigData.SwitchMinSecondsDynamic <= 0)
ConfigData.SwitchMinSecondsDynamic = 3 * 60;
if (ConfigData.MinerAPIQueryInterval <= 0)
ConfigData.MinerAPIQueryInterval = 5;
if (ConfigData.MinerRestartDelayMS <= 0)
ConfigData.MinerRestartDelayMS = 200;
if (ConfigData.BenchmarkTimeLimits == null || ConfigData.BenchmarkTimeLimits.Length < 3)
ConfigData.BenchmarkTimeLimits = new int[] { 10, 20, 60 };
}

public static void Commit()
Expand All @@ -82,6 +92,7 @@ public static void RebuildGroups()
{
CG[i] = new Group();
CG[i].Name = Form1.Miners[i].MinerDeviceName;
CG[i].APIBindPort = Form1.Miners[i].APIPort;
CG[i].ExtraLaunchParameters = Form1.Miners[i].ExtraLaunchParameters;
CG[i].UsePassword = Form1.Miners[i].UsePassword;
CG[i].Algorithms = new Algo[Form1.Miners[i].SupportedAlgorithms.Length];
Expand Down
3 changes: 3 additions & 0 deletions NiceHashMiner/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 50 additions & 6 deletions NiceHashMiner/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public partial class Form1 : Form
private Timer SMACheck;
private Timer BalanceCheck;
private Timer SMAMinerCheck;
private Timer StartupTimer;
private Form3 LoadingScreen;
private int LoadCounter = 0;

private Random R;

Expand Down Expand Up @@ -90,6 +93,8 @@ public Form1()
{
Miners[i].ExtraLaunchParameters = Config.ConfigData.Groups[i].ExtraLaunchParameters;
Miners[i].UsePassword = Config.ConfigData.Groups[i].UsePassword;
if (Config.ConfigData.Groups[i].APIBindPort > 0)
Miners[i].APIPort = Config.ConfigData.Groups[i].APIBindPort;
for (int z = 0; z < Config.ConfigData.Groups[i].Algorithms.Length && z < Miners[i].SupportedAlgorithms.Length; z++)
{
Miners[i].SupportedAlgorithms[z].BenchmarkSpeed = Config.ConfigData.Groups[i].Algorithms[z].BenchmarkSpeed;
Expand Down Expand Up @@ -124,7 +129,18 @@ public Form1()

MinerStatsCheck = new Timer();
MinerStatsCheck.Tick += MinerStatsCheck_Tick;
MinerStatsCheck.Interval = 5000; // every 5 seconds
MinerStatsCheck.Interval = Config.ConfigData.MinerAPIQueryInterval * 1000;

SMAMinerCheck = new Timer();
SMAMinerCheck.Tick += SMAMinerCheck_Tick;
SMAMinerCheck.Interval = Config.ConfigData.SwitchMinSecondsFixed * 1000 + R.Next(Config.ConfigData.SwitchMinSecondsDynamic * 1000);
}


void StartupTimer_Tick(object sender, EventArgs e)
{
StartupTimer.Stop();
StartupTimer = null;

UpdateCheck = new Timer();
UpdateCheck.Tick += UpdateCheck_Tick;
Expand All @@ -143,14 +159,38 @@ public Form1()
BalanceCheck.Interval = 61 * 1000; // every 61 seconds
BalanceCheck.Start();
BalanceCheck_Tick(null, null);
}

SMAMinerCheck = new Timer();
SMAMinerCheck.Tick += SMAMinerCheck_Tick;
SMAMinerCheck.Interval = Config.ConfigData.SwitchMinSecondsFixed * 1000 + R.Next(Config.ConfigData.SwitchMinSecondsDynamic * 1000);

private void Form1_Shown(object sender, EventArgs e)
{
LoadingScreen = new Form3();
LoadingScreen.Location = new Point(this.Location.X + (this.Width - LoadingScreen.Width) / 2, this.Location.Y + (this.Height - LoadingScreen.Height) / 2);
LoadingScreen.Show();

StartupTimer = new Timer();
StartupTimer.Tick += StartupTimer_Tick;
StartupTimer.Interval = 200;
StartupTimer.Start();
}


void SMAMinerCheck_Tick(object sender, EventArgs e)
private void IncreaseLoadCounter()
{
LoadCounter++;
if (LoadCounter >= 3)
{
if (LoadingScreen != null)
{
LoadingScreen.Close();
this.Enabled = true;
LoadingScreen = null;
}
}
}


private void SMAMinerCheck_Tick(object sender, EventArgs e)
{
SMAMinerCheck.Interval = Config.ConfigData.SwitchMinSecondsFixed * 1000 + R.Next(Config.ConfigData.SwitchMinSecondsDynamic * 1000);

Expand All @@ -172,7 +212,7 @@ void SMAMinerCheck_Tick(object sender, EventArgs e)
{
m.Stop();
// wait 0.5 seconds before going on
System.Threading.Thread.Sleep(500);
System.Threading.Thread.Sleep(Config.ConfigData.MinerRestartDelayMS);
}
}

Expand Down Expand Up @@ -268,6 +308,7 @@ void BalanceCheck_Tick(object sender, EventArgs e)
Helpers.ConsolePrint("NICEHASH: balance get");
double Balance = NiceHashStats.GetBalance(textBox1.Text.Trim());
if (Balance > 0) toolStripStatusLabel6.Text = Balance.ToString("F8");
IncreaseLoadCounter();
}


Expand All @@ -276,13 +317,16 @@ void SMACheck_Tick(object sender, EventArgs e)
Helpers.ConsolePrint("NICEHASH: sma get");
NiceHashSMA[] t = NiceHashStats.GetAlgorithmRates();
if (t != null) NiceHashData = t;
IncreaseLoadCounter();
}


void UpdateCheck_Tick(object sender, EventArgs e)
{
Helpers.ConsolePrint("NICEHASH: version get");
string ver = NiceHashStats.GetVersion();
IncreaseLoadCounter();

if (ver == null) return;

if (ver != Application.ProductVersion)
Expand Down
109 changes: 79 additions & 30 deletions NiceHashMiner/Form2.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2a34342

Please sign in to comment.