Removed useless Async methods
This commit is contained in:
+29
-58
@@ -224,7 +224,7 @@ namespace Test_Merge
|
||||
/// </summary>
|
||||
/// <param name="idImage">The id of the image we are working with</param>
|
||||
/// <returns>a string representation of all the returns</returns>
|
||||
public async Task<List<DriverData>> Decode(List<Zone> mainZones, List<string> drivers)
|
||||
public List<DriverData> Decode(List<Zone> mainZones, List<string> drivers)
|
||||
{
|
||||
string result = "";
|
||||
List<DriverData> mainResults = new List<DriverData>();
|
||||
@@ -240,70 +240,41 @@ namespace Test_Merge
|
||||
//Parallel.For(0, mainZones[mainZoneId].Zones.Count, async i =>
|
||||
for (int i = 0; i < mainZones[mainZoneId].Zones.Count; i++)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
DriverData data = mainZones[mainZoneId].Zones[i].Decode(new List<string>(drivers));
|
||||
mainResults.Add(data);
|
||||
DriverDataLogs[i].Add(data);
|
||||
|
||||
if (data.Position != -1 && DriverDataLogs[i].Count > 1)
|
||||
{
|
||||
DriverData data = await mainZones[mainZoneId].Zones[i].Decode(new List<string>(drivers));
|
||||
//Tries to fix the tyres
|
||||
if (data.CurrentTyre.NumberOfLaps > DriverDataLogs[i][DriverDataLogs[i].Count - 2].CurrentTyre.NumberOfLaps + 3)
|
||||
data.CurrentTyre.NumberOfLaps = DriverDataLogs[i][DriverDataLogs[i].Count - 2].CurrentTyre.NumberOfLaps + 1;
|
||||
|
||||
//lock (lockObject)
|
||||
//{
|
||||
mainResults.Add(data);
|
||||
DriverDataLogs[i].Add(data);
|
||||
|
||||
if (data.Position != -1 && DriverDataLogs[i].Count > 1)
|
||||
{
|
||||
//Tries to fix the tyres
|
||||
if (data.CurrentTyre.NumberOfLaps > DriverDataLogs[i][DriverDataLogs[i].Count - 2].CurrentTyre.NumberOfLaps + 3)
|
||||
data.CurrentTyre.NumberOfLaps = DriverDataLogs[i][DriverDataLogs[i].Count - 2].CurrentTyre.NumberOfLaps + 1;
|
||||
|
||||
//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
|
||||
//Lap detection can be f***ed if the OCR takes so much time that an entire sector can be raced without us knowing.
|
||||
if (
|
||||
DriverDataLogs[i][DriverDataLogs[i].Count - 1].Sector3 != 0
|
||||
&& DriverDataLogs[i][DriverDataLogs[i].Count - 2].Sector3 == 0)
|
||||
{
|
||||
DriverData stats = DriverDataLogs[i][DriverDataLogs[i].Count - 2];
|
||||
DriverLaps[i]++;
|
||||
Storage.AddDriverStat(stats, DriverLaps[i]);
|
||||
}
|
||||
//Checking if its a pitstop
|
||||
//Forget this the best way to know if a tyre has been changed is if the number of laps is zero
|
||||
if (data.CurrentTyre.Coumpound != Tyre.Type.Undefined && data.CurrentTyre.NumberOfLaps == 0 && DriverDataLogs[i][DriverDataLogs[i].Count - 2].CurrentTyre.NumberOfLaps != 0)
|
||||
{
|
||||
Storage.AddPitstop(data.Name, DriverLaps[i] - 1, data.CurrentTyre.Coumpound.ToString());
|
||||
//Driver laps -1 because it would take AT LEAST one lap for this program to detect a pitstop
|
||||
}
|
||||
}
|
||||
DriverDataLogs[i].Add(data);
|
||||
//}
|
||||
});
|
||||
//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
|
||||
//Lap detection can be f***ed if the OCR takes so much time that an entire sector can be raced without us knowing.
|
||||
if (
|
||||
DriverDataLogs[i][DriverDataLogs[i].Count - 1].Sector3 != 0
|
||||
&& DriverDataLogs[i][DriverDataLogs[i].Count - 2].Sector3 == 0)
|
||||
{
|
||||
DriverData stats = DriverDataLogs[i][DriverDataLogs[i].Count - 2];
|
||||
DriverLaps[i]++;
|
||||
Storage.AddDriverStat(stats, DriverLaps[i]);
|
||||
}
|
||||
//Checking if its a pitstop
|
||||
//Forget this the best way to know if a tyre has been changed is if the number of laps is zero
|
||||
if (data.CurrentTyre.Coumpound != Tyre.Type.Undefined && data.CurrentTyre.NumberOfLaps == 0 && DriverDataLogs[i][DriverDataLogs[i].Count - 2].CurrentTyre.NumberOfLaps != 0)
|
||||
{
|
||||
Storage.AddPitstop(data.Name, DriverLaps[i] - 1, data.CurrentTyre.Coumpound.ToString());
|
||||
//Driver laps -1 because it would take AT LEAST one lap for this program to detect a pitstop
|
||||
}
|
||||
}
|
||||
DriverDataLogs[i].Add(data);
|
||||
}//);
|
||||
break;
|
||||
//Next there could be a Title Zone and TrackInfoZone
|
||||
}
|
||||
}
|
||||
|
||||
//Display
|
||||
/*
|
||||
int nullDrivers = 0;
|
||||
foreach (DriverData driver in mainResults)
|
||||
{
|
||||
if (driver.Position == -1 && driver.LapTime == 0)
|
||||
nullDrivers++;
|
||||
result += driver.ToString();
|
||||
result += Environment.NewLine;
|
||||
}
|
||||
//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
|
||||
if (nullDrivers >= Convert.ToInt32((float)NUMBER_OF_DRIVERS / 4.0f * 3.0f) || mainResults.Count == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
return mainResults;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user