private void bg_minemgr_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
if (e.ProgressPercentage == 1)
{
try
{
if (!debugbox.IsDisposed)
{
if (debugbox.Lines.Count() > 500)
{
int index = debugbox.Text.IndexOf(Environment.NewLine);
debugbox.Text = debugbox.Text.Remove(0, debugbox.Lines[0].Length + 2);
}
if (output != null && debugbox.Lines.Count() > 0)
{
if (output != debugbox.Lines[debugbox.Lines.Count() - 2])
debugbox.AppendText(output + "\r\n");
}
else if (output != null)
debugbox.AppendText(output + "\r\n");
//get hr
if (output.EndsWith("hash/s"))
{
string[] hrtmp = output.Split(',');
string[] hrtmp2 = null;
if (hrtmp.Count() == 2)
hrtmp2 = hrtmp[1].Split(' ');
else if (hrtmp.Count() == 3)
hrtmp2 = hrtmp[2].Split(' ');
if (hrsum == 0)
{
if (skiphr)
skiphr = false;
else
{
hrsum = Convert.ToDouble(hrtmp2[1], CultureInfo.InvariantCulture);
hr = hrsum;
}
}
else
{
hrsum += Convert.ToDouble(hrtmp2[1], CultureInfo.InvariantCulture);
hr = hrsum / hrcnt;
if (output.Contains(maingpu))
hrcnt++;
}
}
else if (output.Contains("launch configuration"))
{
string[] split = output.Split(' ');
tsConfig.Text = String.Format("Config: {0}", split[7]);
}
else if (output.Contains("yay"))
{
yays++;
}
if (maingpu == null && output.Contains("GPU #"))
{
string[] arr1 = output.Split(']');
string[] arr2 = arr1[1].Split(':');
maingpu = arr2[0];
}
//report to monitor
if ((output.Contains("failed") || output.Contains("interrupted")) && !output.Contains("HTTP"))
failcnt++;
else if (!output.Contains("retry") && !output.Contains("connection") && !output.Contains("HTTP"))
failcnt = 0;
}
}
catch { }
}
else if (e.ProgressPercentage == 2)
{
tsStatus.Text = "Status: Mining away!";
buStart.Enabled = true;
tsStart.Enabled = true;
laActive.Text = "Active Miner: " + activeminer;
lalfails.Text = "Failovers: " + failstat;
if (failstat == 0)
Logger("[Miner Started] " + activeminer);
}
else if (e.ProgressPercentage == 3)
{
if (dgView.Rows.Count == 1 || dgView.Rows.Count <= badminers++)
{
inflateBalloon("Miner not found!", "Out of viable miners. Halted.", ToolTipIcon.Error);
stopReason = "Reason: Miner not found.";
MinerController(true);
}
else
{
inflateBalloon("Miner not found!", "Miner file could not be found. Trying next miner.", ToolTipIcon.Error);
debugbox.AppendText("[!]Miner not found. Sending next miner in...\r\n");
hasFailed = true;
}
}
else
{
inflateBalloon("Unable to start miner!", "cudaminer could not be started.", ToolTipIcon.Error);
stopReason = "Reason: Unable to start miner.";
MinerController(true);
}
}