Skip to content

Commit

Permalink
Fixed test running failure, improved reliability, updated versions
Browse files Browse the repository at this point in the history
  • Loading branch information
andymanic committed May 26, 2022
1 parent 905de02 commit c0ac912
Show file tree
Hide file tree
Showing 5 changed files with 262 additions and 185 deletions.
2 changes: 1 addition & 1 deletion Hardware/OSRTT_Full_Code/OSRTT_Full_Code.ino
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) //Run when button pressed
{
Serial.setTimeout(300);
Serial.setTimeout(500);
Keyboard.print(fpsLimit);
Keyboard.print(fpsLimit);
// Check USB voltage level
Expand Down
124 changes: 81 additions & 43 deletions OSRTT Launcher/OSRTT Launcher/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ namespace OSRTT_Launcher
public partial class Main : Form
{
// CHANGE THESE VALUES WHEN ISSUING A NEW RELEASE
private double boardVersion = 2.5;
private double downloadedFirmwareVersion = 2.5;
private string softwareVersion = "2.9";
private double boardVersion = 2.6;
private double downloadedFirmwareVersion = 2.6;
private string softwareVersion = "3.0";

// TODO //
//
Expand Down Expand Up @@ -558,6 +558,7 @@ private void findAndConnectToBoard()
catch (Exception e)
{
Console.WriteLine(e);
SetText(e.Message + e.StackTrace);
}
}
}
Expand Down Expand Up @@ -596,6 +597,7 @@ private void findAndConnectToBoard()
process.Start();
string output = process.StandardOutput.ReadToEnd();
Console.WriteLine(output);
SetText(output);
process.WaitForExit();
//MessageBox.Show(output);
if (output.Contains("Error"))
Expand All @@ -614,6 +616,7 @@ private void findAndConnectToBoard()
{
MessageBox.Show("Unable to write to device, check it's connected via USB.", "Update Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
Console.WriteLine(ex);
SetText(ex.Message + ex.StackTrace);
}
setProgressBar(false);
}
Expand Down Expand Up @@ -1645,18 +1648,18 @@ private void launchGameAndWaitForExit()
// Force UE4 window to selected display if selected is not primary
WinX = display.Bounds.Location.X;
WinY = display.Bounds.Location.Y;
ue4.StartInfo.Arguments = ue4Path + " WinX=" + WinX + " WinY=" + WinY + vsync;
ue4.StartInfo.Arguments = ue4Path + " WinX=" + WinX + " WinY=" + WinY;
}
else
{
ue4.StartInfo.Arguments = ue4Path + vsync;
ue4.StartInfo.Arguments = ue4Path;
}
ue4.Start();
// Process.Start(ue4Path);
}
catch (Exception strE)
{
Console.WriteLine(strE);
Console.WriteLine(strE.Message + strE.StackTrace);
SetText(strE.Message + strE.StackTrace);
}
try
Expand All @@ -1666,32 +1669,37 @@ private void launchGameAndWaitForExit()
{
// Added in case game hasn't finished launching yet
p = Process.GetProcessesByName("ResponseTimeTest-Win64-Shipping");
Thread.Sleep(100);
}
while (!testMode) // hacky and I don't like it but for some reason it's not detecting this

try
{
try
gamma.Clear();
processedGamma.Clear();
results.Clear();
multipleRunData.Clear();
singleResults.Clear();
testLatency.Clear();
int runCount = getRunCount();
for (int r = 0; r < runCount; r++)
{
gamma.Clear();
processedGamma.Clear();
results.Clear();
multipleRunData.Clear();
singleResults.Clear();
testLatency.Clear();
int runCount = getRunCount();
for (int r = 0; r < runCount; r++)
{
results.Add(new List<ProcessData.rawResultData>());
}
testStarted = false;
port.Write("T");
results.Add(new List<ProcessData.rawResultData>());
}
catch (Exception exc)
testStarted = false;
port.Write("T");
while (!testMode)
{
SetText(exc.Message + exc.StackTrace);
Console.WriteLine(exc);
Thread.Sleep(200);
port.Write("T");
}
Thread.Sleep(200);
}
catch (Exception exc)
{
SetText(exc.Message + exc.StackTrace);
Console.WriteLine(exc.Message + exc.StackTrace);
}
Thread.Sleep(200);

checkWindowThread = new Thread(new ThreadStart(this.checkFocusedWindow));
checkWindowThread.Start();
if (boardVersion > 1.5)
Expand Down Expand Up @@ -1746,6 +1754,8 @@ private void launchGameAndWaitForExit()
{
ResultsView rv = new ResultsView();
rv.setRawData(results);
rv.setGammaData(processedGamma);
rv.setTestLatency(testLatency);
rv.setMultiRunData(multipleRunData);
rv.setAverageData(averageData);
rv.setResultsFolder(resultsFolderPath);
Expand All @@ -1768,6 +1778,8 @@ private void launchGameAndWaitForExit()
rv.setOsMethod(osMethod);
rv.setRunSettings(runSettings);
rv.setGraphView();
rv.setGammaData(processedGamma);
rv.setTestLatency(testLatency);
rv.Show();
});
}
Expand All @@ -1776,6 +1788,7 @@ private void launchGameAndWaitForExit()
catch (InvalidOperationException e)
{
Console.WriteLine(e);
SetText(e.Message + e.StackTrace);
}
catch (IOException ioex)
{
Expand Down Expand Up @@ -1814,6 +1827,8 @@ private void checkFocusedWindow()
{
if (!vsyncTrigger)
{
paused = true;
Thread.Sleep(300);
var item = fpsList.Find(x => x.FPSValue == getSelectedFps());
SendKeys.SendWait(item.Key);
Thread.Sleep(100);
Expand All @@ -1825,6 +1840,7 @@ private void checkFocusedWindow()
{
SendKeys.SendWait("{PGDN}");
}
Thread.Sleep(100);
vsyncTrigger = true;
}
if (paused)
Expand Down Expand Up @@ -1892,7 +1908,7 @@ private void runTest()
Thread.Sleep(10);
try
{ port.Write(i.ToString() + k.ToString()); }
catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); }
catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); SetText(ex.Message + ex.StackTrace); }
Stopwatch sw = new Stopwatch();
sw.Reset();
sw.Start();
Expand All @@ -1911,7 +1927,7 @@ private void runTest()
{
try
{ port.Write(i.ToString() + k.ToString()); }
catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); }
catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); SetText(ex.Message + ex.StackTrace); }
}
else
{
Expand All @@ -1928,7 +1944,7 @@ private void runTest()
}
try
{ port.Write(k.ToString() + i.ToString()); }
catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); }
catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); SetText(ex.Message + ex.StackTrace); }
sw.Reset();
sw.Start();
while (sw.ElapsedMilliseconds < 5000)
Expand All @@ -1946,7 +1962,7 @@ private void runTest()
{
try
{ port.Write(k.ToString() + i.ToString()); }
catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); }
catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); SetText(ex.Message + ex.StackTrace); }
}
else
{
Expand Down Expand Up @@ -2961,19 +2977,31 @@ private void processAllRuns(ProcessData.rtMethods rtMethod, ProcessData.osMethod
}
string fullFileName = cf.createFileName(resultsFolderPath, "-FULL-OSRTT.csv");
csvString.AppendLine("Starting RGB,End RGB,Complete Response Time (ms)," + rtType + "," + perType + "," + osType + " " + osSign + ",Visual Response Rating,Input Lag (ms)");
bool failed = false;
foreach (ProcessData.processedResult i in res)
{
// save each run to file
csvString.AppendLine(
i.StartingRGB.ToString() + "," +
i.EndRGB.ToString() + "," +
i.compTime.ToString() + "," +
i.initTime.ToString() + "," +
i.perTime.ToString() + "," +
i.Overshoot.ToString() + "," +
i.visualResponseRating.ToString() + "," +
i.inputLag.ToString()
);
if (i != null)
{
// save each run to file
csvString.AppendLine(
i.StartingRGB.ToString() + "," +
i.EndRGB.ToString() + "," +
i.compTime.ToString() + "," +
i.initTime.ToString() + "," +
i.perTime.ToString() + "," +
i.Overshoot.ToString() + "," +
i.visualResponseRating.ToString() + "," +
i.inputLag.ToString()
);
}
else
{
failed = true;
}
}
if (failed)
{
cf.showMessageBox("Failed to Process", "One or more of the results failed to process and has been left blank.",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
if (runSettings != null)
{
Expand All @@ -2983,8 +3011,10 @@ private void processAllRuns(ProcessData.rtMethods rtMethod, ProcessData.osMethod
File.WriteAllText(fullFilePath, csvString.ToString());
multipleRunData.Add(res);
}

averageData.AddRange(pd.AverageMultipleRuns(processedData, osMethod));
if (multipleRunData.Count != 0)
{
averageData.AddRange(pd.AverageMultipleRuns(processedData, osMethod));
}
// save averaged data to file
string[] folders = resultsFolderPath.Split('\\');
string monitorInfo = folders.Last();
Expand Down Expand Up @@ -3077,7 +3107,15 @@ private void runProcessing()
osMethod = os,
rtMethod = rt
};
processAllRuns(rt, os);
try
{
processAllRuns(rt, os);
}
catch (Exception ex)
{
SetText(ex.Message + ex.StackTrace);
Console.WriteLine(ex.Message + ex.StackTrace);
}
DataUpload ds = new DataUpload();
ds.ShareResults(results, gamma, testLatency, runSettings);
}
Expand Down
Loading

0 comments on commit c0ac912

Please sign in to comment.