private SymbolCollection DetectMaps(string filename, out List<CodeBlock> newCodeBlocks, out List<AxisHelper> newAxisHelpers, bool showMessage, bool isPrimaryFile)
{
IEDCFileParser parser = Tools.Instance.GetParserForFile(filename, isPrimaryFile);
newCodeBlocks = new List<CodeBlock>();
newAxisHelpers = new List<AxisHelper>();
SymbolCollection newSymbols = new SymbolCollection();
if (parser != null)
{
byte[] allBytes = File.ReadAllBytes(filename);
string boschnumber = parser.ExtractBoschPartnumber(allBytes);
string softwareNumber = parser.ExtractSoftwareNumber(allBytes);
partNumberConverter pnc = new partNumberConverter();
ECUInfo info = pnc.ConvertPartnumber(boschnumber,allBytes.Length);
//MessageBox.Show("Car: " + info.CarMake + "\nECU:" + info.EcuType);
//1) Vw Hardware Number: 38906019GF, Vw System Type: 1,9l R4 EDC15P, Vw Software Number: SG 1434;
//2) Vw Hardware Number: 38906019LJ, Vw System Type: 1,9l R4 EDC15P, Vw Software Number: SG 5934.
if (!info.EcuType.StartsWith("EDC15P") && !info.EcuType.StartsWith("EDC15VM") && info.EcuType != string.Empty && showMessage)
{
frmInfoBox infobx = new frmInfoBox("No EDC15P/VM file [" + info.EcuType + "] " + Path.GetFileName(filename));
}
if (info.EcuType == string.Empty)
{
Console.WriteLine("partnumber " + info.PartNumber + " unknown " + filename);
}
if (isPrimaryFile)
{
string partNo = parser.ExtractPartnumber(allBytes);
partNo = Tools.Instance.StripNonAscii(partNo);
softwareNumber = Tools.Instance.StripNonAscii(softwareNumber);
barPartnumber.Caption = partNo + " " + softwareNumber;
barAdditionalInfo.Caption = info.PartNumber + " " + info.CarMake + " " + info.EcuType + " " + parser.ExtractInfo(allBytes);
}
newSymbols = parser.parseFile(filename, out newCodeBlocks, out newAxisHelpers);
newSymbols.SortColumn = "Flash_start_address";
newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending;
newSymbols.Sort();
//parser.NameKnownMaps(allBytes, newSymbols, newCodeBlocks);
//parser.FindSVBL(allBytes, filename, newSymbols, newCodeBlocks);
/*SymbolTranslator strans = new SymbolTranslator();
foreach (SymbolHelper sh in newSymbols)
{
sh.Description = strans.TranslateSymbolToHelpText(sh.Varname);
}*/
// check for must have maps... if there are maps missing, report it
if (showMessage && (parser is EDC15PFileParser || parser is EDC15P6FileParser))
{
string _message = string.Empty;
if (MapsWithNameMissing("EGR", newSymbols)) _message += "EGR maps missing" + Environment.NewLine;
if (MapsWithNameMissing("SVBL", newSymbols)) _message += "SVBL missing" + Environment.NewLine;
if (MapsWithNameMissing("Torque limiter", newSymbols)) _message += "Torque limiter missing" + Environment.NewLine;
if (MapsWithNameMissing("Smoke limiter", newSymbols)) _message += "Smoke limiter missing" + Environment.NewLine;
//if (MapsWithNameMissing("IQ by MAF limiter", newSymbols)) _message += "IQ by MAF limiter missing" + Environment.NewLine;
if (MapsWithNameMissing("Injector duration", newSymbols)) _message += "Injector duration maps missing" + Environment.NewLine;
if (MapsWithNameMissing("Start of injection", newSymbols)) _message += "Start of injection maps missing" + Environment.NewLine;
if (MapsWithNameMissing("N75 duty cycle", newSymbols)) _message += "N75 duty cycle map missing" + Environment.NewLine;
if (MapsWithNameMissing("Inverse driver wish", newSymbols)) _message += "Inverse driver wish map missing" + Environment.NewLine;
if (MapsWithNameMissing("Boost target map", newSymbols)) _message += "Boost target map missing" + Environment.NewLine;
if (MapsWithNameMissing("SOI limiter", newSymbols)) _message += "SOI limiter missing" + Environment.NewLine;
if (MapsWithNameMissing("Driver wish", newSymbols)) _message += "Driver wish map missing" + Environment.NewLine;
if (MapsWithNameMissing("Boost limit map", newSymbols)) _message += "Boost limit map missing" + Environment.NewLine;
if (MapsWithNameMissing("MAF correction", newSymbols)) _message += "MAF correction map missing" + Environment.NewLine;
if (MapsWithNameMissing("MAF linearization", newSymbols)) _message += "MAF linearization map missing" + Environment.NewLine;
if (MapsWithNameMissing("MAP linearization", newSymbols)) _message += "MAP linearization map missing" + Environment.NewLine;
if (_message != string.Empty)
{
frmInfoBox infobx = new frmInfoBox(_message);
}
}
if (isPrimaryFile)
{
barSymCount.Caption = newSymbols.Count.ToString() + " symbols";
if (MapsWithNameMissing("Launch control map", newSymbols))
{
btnActivateLaunchControl.Enabled = true;
}
else
{
btnActivateLaunchControl.Enabled = false;
}
btnActivateSmokeLimiters.Enabled = false;
try
{
if (Tools.Instance.codeBlockList.Count > 0)
{
if ((GetMapCount("Smoke limiter", newSymbols) / Tools.Instance.codeBlockList.Count) == 1)
{
btnActivateSmokeLimiters.Enabled = true;
}
else
{
btnActivateSmokeLimiters.Enabled = false;
}
}
}
catch (Exception)
{
}
}
}
return newSymbols;
}