Improved functionnality of the main form

This commit is contained in:
2023-05-22 10:20:54 +02:00
parent 96de5485fe
commit e650072213
5 changed files with 128 additions and 47 deletions
+16 -10
View File
@@ -236,6 +236,7 @@ namespace Test_Merge
{
case 0:
//Main Zone
//Parallel.For(0, mainZones[mainZoneId].Zones.Count,async i =>
for (int i = 0; i < mainZones[mainZoneId].Zones.Count; i++)
{
DriverData data = await mainZones[mainZoneId].Zones[i].Decode(new List<string>(drivers));
@@ -259,34 +260,39 @@ namespace Test_Merge
Storage.AddDriverStat(stats, DriverLaps[i]);
}
//Checking if its a pitstop
//If the tyre is a different counpound or if the tyre is much fresher than the older one then it must be because the driver had a pitstop
//BE CAREFULL the last if is here because the OCR is quite weak with the number 4
//if (data.CurrentTyre.Coumpound != DriverDataLogs[i][DriverDataLogs[i].Count - 2].CurrentTyre.Coumpound
//|| data.CurrentTyre.NumberOfLaps != DriverDataLogs[i][DriverDataLogs[i].Count - 2].CurrentTyre.NumberOfLaps
//&& data.CurrentTyre.NumberOfLaps < DriverDataLogs[i][DriverDataLogs[i].Count - 2].CurrentTyre.NumberOfLaps
//&& DriverDataLogs[i][DriverDataLogs[i].Count - 2].CurrentTyre.NumberOfLaps != 3)
//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)
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;
}
return result;
//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))
{
return "";
}
else
{
return result;
}
}
public void ChangeImage(Bitmap Image)