slightly improved the Emulator
This commit is contained in:
+21
-13
@@ -208,9 +208,9 @@ namespace Test_Merge
|
|||||||
actions.SendKeys(OpenQA.Selenium.Keys.Space).Perform();
|
actions.SendKeys(OpenQA.Selenium.Keys.Space).Perform();
|
||||||
//Clicks on the settings Icon
|
//Clicks on the settings Icon
|
||||||
|
|
||||||
int tries = 0;
|
int settingsClickTries = 0;
|
||||||
bool success = false;
|
bool settingsClickSuccess = false;
|
||||||
while (tries < 100 && !success)
|
while (settingsClickTries < 100 && !settingsClickSuccess)
|
||||||
{
|
{
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
try
|
try
|
||||||
@@ -221,39 +221,47 @@ namespace Test_Merge
|
|||||||
SelectElement select = new SelectElement(selectElement);
|
SelectElement select = new SelectElement(selectElement);
|
||||||
IWebElement selectOption = selectElement.FindElement(By.CssSelector("option[value^='1080_']"));
|
IWebElement selectOption = selectElement.FindElement(By.CssSelector("option[value^='1080_']"));
|
||||||
selectOption.Click();
|
selectOption.Click();
|
||||||
success = true;
|
settingsClickSuccess = true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
//Sometimes it can crash because it could not get the options to show up in time. When it happens just retry
|
//Sometimes it can crash because it could not get the options to show up in time. When it happens just retry
|
||||||
success = false;
|
settingsClickSuccess = false;
|
||||||
tries++;
|
settingsClickTries++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success)
|
if (!settingsClickSuccess)
|
||||||
{
|
{
|
||||||
Screenshot("ERROR105");
|
Screenshot("ERROR105");
|
||||||
Driver.Dispose();
|
Driver.Dispose();
|
||||||
return 105;
|
return 105;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Thread.Sleep(3000);
|
|
||||||
}
|
|
||||||
|
|
||||||
Screenshot("BEFOREFULLSCREEN");
|
Screenshot("BEFOREFULLSCREEN");
|
||||||
|
|
||||||
//Makes the feed fullscreen
|
//Makes the feed fullscreen
|
||||||
//Driver.Manage().Window.Size = new System.Drawing.Size(windowWidth, windowHeight);
|
int fullScreenClickTries = 0;
|
||||||
|
bool fullScreenClickSuccess = false;
|
||||||
Driver.Manage().Window.Maximize();
|
Driver.Manage().Window.Maximize();
|
||||||
WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));
|
//WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));
|
||||||
|
while (fullScreenClickTries < 100 && !fullScreenClickSuccess)
|
||||||
|
{
|
||||||
|
Thread.Sleep(150);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IWebElement fullScreenButton = Driver.FindElement(By.ClassName("bmpui-ui-fullscreentogglebutton"));
|
IWebElement fullScreenButton = Driver.FindElement(By.ClassName("bmpui-ui-fullscreentogglebutton"));
|
||||||
fullScreenButton.Click();
|
fullScreenButton.Click();
|
||||||
|
fullScreenClickSuccess = true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
{
|
||||||
|
fullScreenClickSuccess = false;
|
||||||
|
fullScreenClickTries++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fullScreenClickSuccess)
|
||||||
{
|
{
|
||||||
Screenshot("ERROR106");
|
Screenshot("ERROR106");
|
||||||
Driver.Dispose();
|
Driver.Dispose();
|
||||||
|
|||||||
+11
-2
@@ -235,11 +235,17 @@ namespace Test_Merge
|
|||||||
switch (mainZoneId)
|
switch (mainZoneId)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
//object lockObject = new object();
|
||||||
//Main Zone
|
//Main Zone
|
||||||
//Parallel.For(0, mainZones[mainZoneId].Zones.Count,async i =>
|
//Parallel.For(0, mainZones[mainZoneId].Zones.Count, async i =>
|
||||||
for (int i = 0; i < mainZones[mainZoneId].Zones.Count; i++)
|
for (int i = 0; i < mainZones[mainZoneId].Zones.Count; i++)
|
||||||
|
{
|
||||||
|
await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
DriverData data = await mainZones[mainZoneId].Zones[i].Decode(new List<string>(drivers));
|
DriverData data = await mainZones[mainZoneId].Zones[i].Decode(new List<string>(drivers));
|
||||||
|
|
||||||
|
//lock (lockObject)
|
||||||
|
//{
|
||||||
mainResults.Add(data);
|
mainResults.Add(data);
|
||||||
DriverDataLogs[i].Add(data);
|
DriverDataLogs[i].Add(data);
|
||||||
|
|
||||||
@@ -251,6 +257,7 @@ namespace Test_Merge
|
|||||||
|
|
||||||
//Checking if its a new lap
|
//Checking if its a new lap
|
||||||
//If the third sector is filled but it was'nt the last time, then it means that a new Lap has been started
|
//If the third sector is filled but it was'nt the last time, then it means that a new Lap has been started
|
||||||
|
//Lap detection can be f***ed if the OCR takes so much time that an entire sector can be raced without us knowing.
|
||||||
if (
|
if (
|
||||||
DriverDataLogs[i][DriverDataLogs[i].Count - 1].Sector3 != 0
|
DriverDataLogs[i][DriverDataLogs[i].Count - 1].Sector3 != 0
|
||||||
&& DriverDataLogs[i][DriverDataLogs[i].Count - 2].Sector3 == 0)
|
&& DriverDataLogs[i][DriverDataLogs[i].Count - 2].Sector3 == 0)
|
||||||
@@ -268,6 +275,8 @@ namespace Test_Merge
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DriverDataLogs[i].Add(data);
|
DriverDataLogs[i].Add(data);
|
||||||
|
//}
|
||||||
|
});
|
||||||
}//);
|
}//);
|
||||||
break;
|
break;
|
||||||
//Next there could be a Title Zone and TrackInfoZone
|
//Next there could be a Title Zone and TrackInfoZone
|
||||||
@@ -285,7 +294,7 @@ namespace Test_Merge
|
|||||||
}
|
}
|
||||||
//If 75% or more of the drivers cannot be decoded there must be a problem somewhere.
|
//If 75% or more of the drivers cannot be decoded there must be a problem somewhere.
|
||||||
//Some can be because if they are out of the race usually the OCR returns -1 as the driver position
|
//Some can be because if they are out of the race usually the OCR returns -1 as the driver position
|
||||||
if (nullDrivers >= Convert.ToInt32((float)NUMBER_OF_DRIVERS / 4.0f * 3.0f))
|
if (nullDrivers >= Convert.ToInt32((float)NUMBER_OF_DRIVERS / 4.0f * 3.0f) || mainResults.Count == 0)
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user