ConvertPartnumber() public method

public ConvertPartnumber ( string partnumber, int length ) : ECUInfo
partnumber string
length int
return ECUInfo
        private void ConvertPartNumber()
        {
            partNumberConverter pnc = new partNumberConverter();
            ECUInfo ecuinfo = pnc.ConvertPartnumber(buttonEdit1.Text, 0);

            lblCarModel.Text = "---";
            lblECUType.Text = "---";
            lblFuel.Text = "---";
            lblCarType.Text = "---";
            lblRating.Text = "--/--";
            lblSoftwareID.Text = "---";

            if (ecuinfo.CarMake != string.Empty)
            {

                lblCarModel.Text = ecuinfo.CarMake;
                lblECUType.Text = ecuinfo.EcuType;
                lblFuel.Text = ecuinfo.FuelType;
                lblCarType.Text = ecuinfo.CarType;
                lblSoftwareID.Text = ecuinfo.SoftwareID;
                if (ecuinfo.HP > 0 || ecuinfo.TQ > 0)
                {
                    lblRating.Text = ecuinfo.HP + " hp/" + ecuinfo.TQ + " Nm";
                }
                else
                {
                    lblRating.Text = "";
                }

                if (System.IO.File.Exists(Path.Combine(Application.StartupPath, "Binaries\\" + buttonEdit1.Text + ".BIN")))
                {
                    simpleButton2.Enabled = true;
                    simpleButton3.Enabled = true;
                    simpleButton4.Enabled = true;
                }
                else
                {
                    simpleButton2.Enabled = false;
                    simpleButton3.Enabled = false;
                    simpleButton4.Enabled = false;
                }
            }
            else
            {
                MessageBox.Show("The entered partnumber was not recognized by VAGEDCSuite");
            }
        }
        public override SymbolCollection parseFile(string filename, out List<CodeBlock> newCodeBlocks, out List<AxisHelper> newAxisHelpers)
        {
            newCodeBlocks = new List<CodeBlock>();
            SymbolCollection newSymbols = new SymbolCollection();
            newAxisHelpers = new List<AxisHelper>();
            byte[] allBytes = File.ReadAllBytes(filename);
            string boschnumber = ExtractBoschPartnumber(allBytes);
            string softwareNumber = ExtractSoftwareNumber(allBytes);
            string additionalInfo = ExtractInfo(allBytes);
            string partnumber = ExtractPartnumber(allBytes);
            partNumberConverter pnc = new partNumberConverter();
            ECUInfo info = pnc.ConvertPartnumber(boschnumber, allBytes.Length);
            // check if V6 2.5 TDI/R4 1.9 TDI/R3 1.4 TDi
            int nrCylinders = pnc.GetNumberOfCylinders(info.EngineType, additionalInfo);
            // we can detect maps depending on ECUType/EngineType/nrCylinders/Filesize etc

            VerifyCodeBlocks(allBytes, newSymbols, newCodeBlocks);

            for (int t = 0; t < allBytes.Length - 1; t += 2)
            {
                int len2skip = 0;
                if (CheckMap(t, allBytes, newSymbols, newCodeBlocks, out len2skip))
                {
                    if (len2skip > 2) len2skip -= 2; // make sure we don't miss maps
                    if ((len2skip % 2) > 0) len2skip -= 1;
                    if (len2skip < 0) len2skip = 0;
                   // t += len2skip;
                    // Console.WriteLine("map detected: " + t.ToString("X8"));
                }
            }

            newSymbols.SortColumn = "Flash_start_address";
            newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending;
            newSymbols.Sort();
            NameKnownMaps(allBytes, newSymbols, newCodeBlocks);
            BuildAxisIDList(newSymbols, newAxisHelpers);
            MatchAxis(newSymbols, newAxisHelpers);

            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
            return newSymbols;
        }
 private void AddPartNumber(string part)
 {
     partNumberConverter pnc = new partNumberConverter();
     ECUInfo ecuinfo = new ECUInfo();
     ecuinfo = pnc.ConvertPartnumber(part, 0);
     dt.Rows.Add(ecuinfo.CarMake, ecuinfo.CarType, ecuinfo.EngineType, part, ecuinfo.SoftwareID, ecuinfo.EcuType, ecuinfo.FuelType, ecuinfo.HP, ecuinfo.TQ);
 }
示例#4
0
        public EDCFileType DetermineFileType(string fileName, bool isPrimaryFile)
        {
            byte[] allBytes = File.ReadAllBytes(fileName);
            string boschnumber = ExtractBoschPartnumber(allBytes);
            //Console.WriteLine("Bosch number: " + boschnumber);
            partNumberConverter pnc = new partNumberConverter();
            ECUInfo info = pnc.ConvertPartnumber(boschnumber, allBytes.Length);
            if (info.EcuType.Contains("EDC15P-6"))
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.EDC15P6;
                return EDCFileType.EDC15P6;
            }
            else if (info.EcuType.Contains("EDC15P"))
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.EDC15P;
                return EDCFileType.EDC15P;
            }
            else if (info.EcuType.Contains("EDC15M"))
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.EDC15M;
                return EDCFileType.EDC15M;
            }
            else if (info.EcuType.Contains("MSA15") || info.EcuType.Contains("EDC15V-5"))
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.MSA15;
                return EDCFileType.MSA15;
            }
            else if (info.EcuType.Contains("MSA12"))
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.MSA12;
                return EDCFileType.MSA12;
            }
            else if (info.EcuType.Contains("MSA11"))
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.MSA11;
                return EDCFileType.MSA11;
            }
            else if (info.EcuType.Contains("MSA6"))
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.MSA6;
                return EDCFileType.MSA6;
            }
            else if (info.EcuType.Contains("EDC15V"))
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.EDC15V;
                return EDCFileType.EDC15V;
            }
            if (info.EcuType.Contains("EDC15C"))
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.EDC15C;
                return EDCFileType.EDC15C;
            }
            else if (info.EcuType.Contains("EDC16"))
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.EDC16;
                return EDCFileType.EDC16;
            }
            else if (info.EcuType.Contains("EDC17"))
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.EDC17;
                return EDCFileType.EDC17;
            }

            else if (IsEDC16Partnumber(boschnumber))
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.EDC16;
                return EDCFileType.EDC16;
            }
            else if (boschnumber != string.Empty)
            {
                if (allBytes.Length == 1024 * 1024 * 2)
                {
                    if (isPrimaryFile) m_currentFileType = EDCFileType.EDC17;
                    return EDCFileType.EDC17;
                }
                else if (boschnumber.StartsWith("EDC17"))
                {
                    if (isPrimaryFile) m_currentFileType = EDCFileType.EDC17;
                    return EDCFileType.EDC17;
                }
                else
                {
                    if (isPrimaryFile) m_currentFileType = EDCFileType.EDC15V;
                    return EDCFileType.EDC15V;
                }
            }
            else
            {
                if (isPrimaryFile) m_currentFileType = EDCFileType.EDC16;
                return EDCFileType.EDC16; // default to EDC16???
            }
        }
示例#5
0
        private void btnFirmwareInformation_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Tools.Instance.m_currentfile != string.Empty)
            {
                if(File.Exists(Tools.Instance.m_currentfile))
                {

                    byte[] allBytes = File.ReadAllBytes(Tools.Instance.m_currentfile);
                    IEDCFileParser parser = Tools.Instance.GetParserForFile(Tools.Instance.m_currentfile, false);
                    partNumberConverter pnc = new partNumberConverter();
                    ECUInfo ecuinfo = pnc.ConvertPartnumber(parser.ExtractBoschPartnumber(allBytes), allBytes.Length);
                    frmFirmwareInfo info = new frmFirmwareInfo();
                    info.InfoString = parser.ExtractInfo(allBytes);
                    info.partNumber = parser.ExtractBoschPartnumber(allBytes);
                    if(ecuinfo.SoftwareID == "") ecuinfo.SoftwareID = parser.ExtractPartnumber(allBytes);
                    info.SoftwareID = ecuinfo.SoftwareID + " " + parser.ExtractSoftwareNumber(allBytes);
                    info.carDetails = ecuinfo.CarMake + " " + ecuinfo.CarType;
                    string enginedetails = ecuinfo.EngineType;
                    string hpinfo = string.Empty;
                    string tqinfo = string.Empty;
                    if (ecuinfo.HP > 0) hpinfo = ecuinfo.HP.ToString() + " bhp";
                    if (ecuinfo.TQ > 0) tqinfo = ecuinfo.TQ.ToString() + " Nm";
                    if (hpinfo != string.Empty || tqinfo != string.Empty)
                    {
                        enginedetails += " (";
                        if (hpinfo != string.Empty) enginedetails += hpinfo;
                        if (hpinfo != string.Empty && tqinfo != string.Empty) enginedetails += "/";
                        if (tqinfo != string.Empty) enginedetails += tqinfo;
                        enginedetails += ")";
                    }
                    info.EngineType = /*ecuinfo.EngineType*/ enginedetails;
                    info.ecuDetails = ecuinfo.EcuType;
                    //DumpECUInfo(ecuinfo);
                    ChecksumResultDetails result = Tools.Instance.UpdateChecksum(Tools.Instance.m_currentfile, true);
                    string chkType = string.Empty;
                    if (result.TypeResult == ChecksumType.VAG_EDC15P_V41) chkType = "VAG EDC15P V4.1";
                    else if (result.TypeResult == ChecksumType.VAG_EDC15P_V41V2) chkType = "VAG EDC15P V4.1v2";
                    else if (result.TypeResult == ChecksumType.VAG_EDC15P_V41_2002) chkType = "VAG EDC15P V4.1 2002+";
                    else if (result.TypeResult != ChecksumType.Unknown) chkType = result.TypeResult.ToString();

                    chkType += " " + result.CalculationResult.ToString();

                    info.checksumType = chkType;
                    // number of codeblocks?
                    info.codeBlocks = DetermineNumberOfCodeblocks().ToString();
                    info.ShowDialog();
                }
            }
        }
示例#6
0
        private void LoadFiles()
        {
            loading = true;
            simpleButton1.Text = "Cancel";
            simpleButton2.Enabled = false;
            SetProgressVisibility(true);
            SetScanProgress("scanning...", 0);
            Application.DoEvents();
            ctrlAirmassResult airmassResult = new ctrlAirmassResult();
            partNumberConverter pnc = new partNumberConverter();
            List<ScannedFile> detectedFiles = new List<ScannedFile>();
            int fileCounter = 0;
            if (Directory.Exists(buttonEdit1.Text))
            {
                string[] files = Directory.GetFiles(buttonEdit1.Text, "*.*", SearchOption.AllDirectories);
                foreach (string file in files)
                {
                    fileCounter++;
                    int percentage = (fileCounter * 100) / files.Length;
                    SetScanProgress("importing...", percentage);

                    if (cancelLoad)
                    {
                        cancelLoad = false;
                        break;
                    }
                    FileInfo fi = new FileInfo(file);
                    this.Text = "Library builder - " + Path.GetFileNameWithoutExtension(file);
                    Application.DoEvents();
                    if (IsValidLength(fi.Length))
                    {
                        IEDCFileParser parser = Tools.Instance.GetParserForFile(file, false);
                        byte[] allBytes = File.ReadAllBytes(file);
                        string boschPartnumber = parser.ExtractBoschPartnumber(allBytes);
                        List<CodeBlock> newCodeBlocks = new List<CodeBlock>();
                        List<AxisHelper> newAxisHelpers = new List<AxisHelper>();
                        if (boschPartnumber != string.Empty)
                        {
                            //string additionalInfo = parser.ExtractInfo(allBytes);
                            SymbolCollection sc = parser.parseFile(file, out newCodeBlocks, out newAxisHelpers);
                            ECUInfo info = pnc.ConvertPartnumber(boschPartnumber, allBytes.Length);

                            ScannedFile newFile = new ScannedFile();
                            newFile.CarMake = info.CarMake;
                            newFile.CarType = info.CarType;
                            newFile.EcuType = info.EcuType;
                            newFile.EngineType = info.EngineType;
                            newFile.FuellingType = info.FuellingType;
                            newFile.FuelType = info.FuelType;
                            newFile.HP = info.HP;
                            newFile.PartNumber = info.PartNumber;
                            newFile.SoftwareID = info.SoftwareID;
                            newFile.TQ = info.TQ;

                            if (info.EcuType.Contains("EDC15P-6"))
                            {
                                newFile.Filetype = EDCFileType.EDC15P6;
                            }
                            else if (info.EcuType.Contains("EDC15P"))
                            {
                                newFile.Filetype = EDCFileType.EDC15P;
                            }
                            else if (info.EcuType.Contains("EDC15M"))
                            {
                                newFile.Filetype = EDCFileType.EDC15M;
                            }
                            else if (info.EcuType.Contains("EDC15V-5."))
                            {
                                newFile.Filetype = EDCFileType.MSA15;
                            }
                            else if (info.EcuType.Contains("EDC15V"))
                            {
                                newFile.Filetype = EDCFileType.EDC15V;
                            }
                            else if (info.EcuType.Contains("EDC15C"))
                            {
                                newFile.Filetype = EDCFileType.EDC15C;
                            }
                            else if (info.EcuType.Contains("EDC16"))
                            {
                                newFile.Filetype = EDCFileType.EDC16;
                            }
                            else if (info.EcuType.Contains("EDC17"))
                            {
                                newFile.Filetype = EDCFileType.EDC17;
                            }
                            else if (info.EcuType.Contains("MSA15"))
                            {
                                newFile.Filetype = EDCFileType.MSA15;
                            }
                            else if (info.EcuType.Contains("MSA12"))
                            {
                                newFile.Filetype = EDCFileType.MSA12;
                            }
                            else if (info.EcuType.Contains("MSA11"))
                            {
                                newFile.Filetype = EDCFileType.MSA11;
                            }
                            else if (info.EcuType.Contains("MSA6"))
                            {
                                newFile.Filetype = EDCFileType.MSA6;
                            }

                            else if (boschPartnumber != string.Empty)
                            {
                                if (fi.Length == 1024 * 1024 * 2)
                                {
                                    newFile.Filetype = EDCFileType.EDC17;
                                }
                                else if(boschPartnumber.StartsWith("EDC17"))
                                {
                                    newFile.Filetype = EDCFileType.EDC17;
                                }
                                else
                                {
                                    newFile.Filetype = EDCFileType.EDC15V;
                                }
                            }
                            else
                            {
                                newFile.Filetype = EDCFileType.EDC16; // default to EDC16???
                            }
                            newFile.Filename = file;
                            newFile.Filesize = (int)fi.Length;

                            ChecksumResultDetails crd = Tools.Instance.UpdateChecksum(file, true);

                            string chkType = string.Empty;
                            if (crd.TypeResult == ChecksumType.VAG_EDC15P_V41) chkType = "VAG EDC15P V4.1";
                            else if (crd.TypeResult == ChecksumType.VAG_EDC15P_V41V2) chkType = "VAG EDC15P V4.1v2";
                            else if (crd.TypeResult == ChecksumType.VAG_EDC15P_V41_2002) chkType = "VAG EDC15P V4.1 2002+";
                            newFile.ChecksumType = chkType;
                            newFile.ChecksumResult = crd.CalculationResult.ToString();
                            newFile.NumberChecksums = crd.NumberChecksumsTotal;
                            newFile.NumberChecksumsFail = crd.NumberChecksumsFail;
                            newFile.NumberChecksumsOk = crd.NumberChecksumsOk;

                            newFile.NumberMapsDetected = sc.Count;
                            string _message = string.Empty;
                            newFile.MapsOk = CheckMajorMapsPresent(sc,  newFile.Filetype, out _message);
                            newFile.Messages = _message;
                            foreach (SymbolHelper sh in sc)
                            {
                                if (!sh.Varname.StartsWith("3D") && !sh.Varname.StartsWith("2D"))
                                {
                                    newFile.NumberMapsRecognized++;
                                }
                            }

                            try
                            {
                                airmassResult.Currentfile = file;
                                airmassResult.Symbols = sc;
                                airmassResult.Currentfile_size = (int)fi.Length;
                                string additionalInfo = parser.ExtractInfo(allBytes);
                                airmassResult.NumberCylinders = pnc.GetNumberOfCylinders(info.EngineType, additionalInfo);
                                airmassResult.ECUType = info.EcuType;
                                PerformanceResults pr = airmassResult.Calculate(file, sc);
                                newFile.RealHP = pr.Horsepower;
                                newFile.RealTQ = pr.Torque;
                            }
                            catch (Exception)
                            {

                            }

                            detectedFiles.Add(newFile);

                        }
                        else if (file.ToUpper().EndsWith(".BIN") || file.ToUpper().EndsWith(".ORI"))
                        {
                            Console.WriteLine("Missed " + file);
                            // add it as well
                            if (checkEdit1.Checked)
                            {
                                ScannedFile newFile = new ScannedFile();
                                newFile.CarMake = "";
                                newFile.CarType = "";
                                newFile.EcuType = "Unknown";
                                newFile.EngineType = "";
                                newFile.FuellingType = "";
                                newFile.FuelType = "";
                                newFile.HP = 0;
                                newFile.PartNumber = "";
                                newFile.SoftwareID = "";
                                newFile.TQ = 0;
                                newFile.Filetype = EDCFileType.Unknown;
                                newFile.Filename = file;
                                newFile.Filesize = (int)fi.Length;
                                newFile.ChecksumType = "";
                                newFile.ChecksumResult = "";
                                newFile.NumberChecksums = 0;
                                newFile.NumberChecksumsFail = 0;
                                newFile.NumberChecksumsOk = 0;
                                newFile.NumberMapsDetected = 0;
                                newFile.MapsOk = false;
                                newFile.Messages = "";
                                newFile.NumberMapsRecognized = 0;
                                detectedFiles.Add(newFile);
                            }
                        }

                    }
                }
                gridControl1.DataSource = detectedFiles;
            }
            loading = false;
            SetScanProgress("done", 100);
            SetProgressVisibility(false);
            this.Text = "Library builder";
            simpleButton1.Text = "Close";
            simpleButton2.Enabled = true;
            Application.DoEvents();
        }
示例#7
0
        private void btnAirmassResult_ItemClick(object sender, ItemClickEventArgs e)
        {
            DevExpress.XtraBars.Docking.DockPanel dockPanel;
            if (CheckAllTablesAvailable())
            {
                dockManager1.BeginUpdate();
                try
                {
                    ctrlAirmassResult airmassResult = new ctrlAirmassResult();
                    airmassResult.Dock = DockStyle.Fill;
                    dockPanel = dockManager1.AddPanel(DevExpress.XtraBars.Docking.DockingStyle.Right);
                    dockPanel.Tag = Tools.Instance.m_currentfile;
                    dockPanel.ClosedPanel += new DevExpress.XtraBars.Docking.DockPanelEventHandler(dockPanel_ClosedPanel);
                    dockPanel.Text = "Airmass result viewer: " + Path.GetFileName(Tools.Instance.m_currentfile);
                    dockPanel.Width = 800;
                    airmassResult.onStartTableViewer += new ctrlAirmassResult.StartTableViewer(airmassResult_onStartTableViewer);
                    airmassResult.onClose += new ctrlAirmassResult.ViewerClose(airmassResult_onClose);
                    airmassResult.Currentfile = Tools.Instance.m_currentfile;
                    airmassResult.Symbols = Tools.Instance.m_symbols;
                    airmassResult.Currentfile_size = Tools.Instance.m_currentfilelength;
                    IEDCFileParser parser = Tools.Instance.GetParserForFile(Tools.Instance.m_currentfile, false);
                    byte[] allBytes = File.ReadAllBytes(Tools.Instance.m_currentfile);
                    string additionalInfo = parser.ExtractInfo(allBytes);
                    //GetNumberOfCylinders
                    string bpn = parser.ExtractBoschPartnumber(allBytes);
                    partNumberConverter pnc = new partNumberConverter();

                    ECUInfo info = pnc.ConvertPartnumber(bpn, allBytes.Length);
                    airmassResult.NumberCylinders = pnc.GetNumberOfCylinders(info.EngineType, additionalInfo);
                    airmassResult.ECUType = info.EcuType;

                    airmassResult.Calculate(Tools.Instance.m_currentfile, Tools.Instance.m_symbols);
                    dockPanel.Controls.Add(airmassResult);
                }
                catch (Exception newdockE)
                {
                    Console.WriteLine(newdockE.Message);
                }
                dockManager1.EndUpdate();
            }
        }
示例#8
0
        private void SaveAdditionalSymbols()
        {
            System.Data.DataTable dt = new System.Data.DataTable(Path.GetFileNameWithoutExtension(Tools.Instance.m_currentfile));
            dt.Columns.Add("SYMBOLNAME");
            dt.Columns.Add("SYMBOLNUMBER", Type.GetType("System.Int32"));
            dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32"));
            dt.Columns.Add("DESCRIPTION");
            byte[] allBytes = File.ReadAllBytes(Tools.Instance.m_currentfile);
            string boschpartNumber = Tools.Instance.ExtractBoschPartnumber(allBytes);
            partNumberConverter pnc = new partNumberConverter();
            ECUInfo info = pnc.ConvertPartnumber(boschpartNumber,allBytes.Length);
            string checkstring = boschpartNumber + "_" + info.SoftwareID;

            string xmlfilename = Tools.Instance.GetWorkingDirectory() + "\\repository\\" + Path.GetFileNameWithoutExtension(Tools.Instance.m_currentfile) + File.GetCreationTime(Tools.Instance.m_currentfile).ToString("yyyyMMddHHmmss") + checkstring + ".xml";
            if (!Directory.Exists(Tools.Instance.GetWorkingDirectory() + "\\repository"))
            {
                Directory.CreateDirectory(Tools.Instance.GetWorkingDirectory() + "\\repository");
            }
            if (File.Exists(xmlfilename))
            {
                File.Delete(xmlfilename);
            }
            foreach (SymbolHelper sh in Tools.Instance.m_symbols)
            {
                if (sh.Userdescription != "")
                {
                    dt.Rows.Add(sh.Varname, sh.Symbol_number, sh.Flash_start_address, sh.Userdescription);
                }
            }
            dt.WriteXml(xmlfilename);
        }
示例#9
0
        private void ParseDirectory(string folder)
        {
            if (Directory.Exists(folder))
            {
                string[] files = Directory.GetFiles(folder, "*.*", SearchOption.AllDirectories);
                foreach (string file in files)
                {
                    FileInfo fi = new FileInfo(file);
                    IEDCFileParser parser = Tools.Instance.GetParserForFile(file, false);

                        OpenFile(file, false);
                        byte[] allBytes = File.ReadAllBytes(file);
                        string boschnumber = parser.ExtractBoschPartnumber(allBytes);
                        string partnumber = parser.ExtractPartnumber(allBytes);
                        string softwareNumber = parser.ExtractSoftwareNumber(allBytes);
                        partNumberConverter pnc = new partNumberConverter();
                        ECUInfo info = pnc.ConvertPartnumber(boschnumber, allBytes.Length);
                        UInt32 chks = AddChecksum(allBytes);
                        // determine peak trq&hp
                        if (info.EcuType.StartsWith("EDC15P"))
                        {
                            // export to the final folder
                            string destFile = Path.Combine(@"D:\Prive\ECU\audi\BinCollection\output", /*info.CarMake + "_" + info.EcuType + "_" +*/ boschnumber + "_" + softwareNumber + "_" + partnumber + "_" + chks.ToString("X8") + ".bin");
                            if (File.Exists(destFile)) Console.WriteLine("Double file: " + destFile);
                            else
                            {
                                File.Copy(file, destFile, false);
                            }
                        }

                }
            }
            Console.WriteLine("Done");
        }
示例#10
0
        private bool ImportXMLFile(string filename, SymbolCollection coll2load, bool ImportFromRepository)
        {
            bool retval = false;
            SymbolTranslator st = new SymbolTranslator();
            System.Data.DataTable dt = new System.Data.DataTable(Path.GetFileNameWithoutExtension(filename));
            dt.Columns.Add("SYMBOLNAME");
            dt.Columns.Add("SYMBOLNUMBER", Type.GetType("System.Int32"));
            dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32"));
            dt.Columns.Add("DESCRIPTION");
            if (ImportFromRepository)
            {
                byte[] allBytes = File.ReadAllBytes(filename);
                string boschpartNumber = Tools.Instance.ExtractBoschPartnumber(allBytes);
                partNumberConverter pnc = new partNumberConverter();
                ECUInfo info = pnc.ConvertPartnumber(boschpartNumber, allBytes.Length);
                string checkstring = boschpartNumber + "_" + info.SoftwareID;

                string xmlfilename = Tools.Instance.GetWorkingDirectory() + "\\repository\\" + Path.GetFileNameWithoutExtension(filename) + File.GetCreationTime(filename).ToString("yyyyMMddHHmmss") + checkstring + ".xml";
                if (!Directory.Exists(Tools.Instance.GetWorkingDirectory() + "\\repository"))
                {
                    Directory.CreateDirectory(Tools.Instance.GetWorkingDirectory() + "\\repository");
                }
                if (File.Exists(xmlfilename))
                {
                    dt.ReadXml(xmlfilename);
                    retval = true;
                }
            }
            else
            {
                string binname = GetFileDescriptionFromFile(filename);
                if (binname != string.Empty)
                {
                    dt = new System.Data.DataTable(binname);
                    dt.Columns.Add("SYMBOLNAME");
                    dt.Columns.Add("SYMBOLNUMBER", Type.GetType("System.Int32"));
                    dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32"));
                    dt.Columns.Add("DESCRIPTION");
                    if (File.Exists(filename))
                    {
                        dt.ReadXml(filename);
                        retval = true;
                    }
                }
            }
            foreach (SymbolHelper sh in coll2load)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    try
                    {
                        //if (dr["SYMBOLNAME"].ToString() == sh.Varname)
                        {
                            if (sh.Flash_start_address == Convert.ToInt32(dr["FLASHADDRESS"]))
                            {
                                sh.Userdescription = dr["DESCRIPTION"].ToString();
                                break;
                            }
                        }
                    }
                    catch (Exception E)
                    {
                        Console.WriteLine(E.Message);
                    }
                }
            }
            return retval;
        }
示例#11
0
        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;
        }