Inheritance: SortableCollectionBase, ICustomTypeDescriptor
        public bool GetAxisSymbols(SymbolCollection curSymbols, string symbolname, out string x_axis, out string y_axis, out string x_axis_description, out string y_axis_description, out string z_axis_description)
        {
            bool retval = false;
            x_axis = "";
            y_axis = "";
            x_axis_description = "x-axis";
            y_axis_description = "y-axis";
            z_axis_description = "z-axis";
            int xid = GetSymbolAxisXID(curSymbols, symbolname);
            y_axis_description = TranslateAxisID(xid);
            int yid = GetSymbolAxisYID(curSymbols, symbolname);
            x_axis_description = TranslateAxisID(yid);

            /*
            switch (symbolname)
            {
                case "MAFCal.WeightConstFuelMap":
                    x_axis = "MAFCal.n_EngineXSP";
                    y_axis = "MAFCal.p_InletGradYSP";
                    x_axis_description = "Engine speed (%)";
                    y_axis_description = "Inlet pressure (kPa)";
                    break;
            }
            if (y_axis != "") retval = true;*/
            return retval;
        }
        public override void FindSVBL(byte[] allBytes, string filename, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
        {
            if (!FindSVBLSequenceOne(allBytes, filename, newSymbols, newCodeBlocks))
            {
                if (!FindSVBLSequenceTwo(allBytes, filename, newSymbols, newCodeBlocks))
                {
                    if (!FindSVBLSequenceThree(allBytes, filename, newSymbols, newCodeBlocks))
                    {
                        // set C300 map with length 1= SVBL
                        foreach (SymbolHelper sh in newSymbols)
                        {
                            if (sh.X_axis_ID == 0xC300)
                            {
                                Console.WriteLine(sh.Length);
                                if (sh.Length == 2)
                                {
                                    sh.Category = "Detected maps";
                                    sh.Subcategory = "Limiters";
                                    sh.Varname = "SVBL Boost limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                                    sh.CodeBlock = DetermineCodeBlockByByAddress(sh.Flash_start_address, newCodeBlocks);

                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 public override void FindSVBL(byte[] allBytes, string filename, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
 {
     if (!FindSVBLSequenceOne(allBytes, filename, newSymbols, newCodeBlocks))
     {
         FindSVBLSequenceTwo(allBytes, filename, newSymbols, newCodeBlocks);
     }
 }
Esempio n. 4
0
        private bool DisableEGRMap(string filename, SymbolCollection symbols, bool autoUpdateChecksum)
        {
            bool retval = true;
            int egrAddress = (int)Tools.Instance.GetSymbolAddressLike(Tools.Instance.m_symbols, "EGR");
            if (egrAddress > 0)
            {
                foreach (SymbolHelper sh in Tools.Instance.m_symbols)
                {
                    if (sh.Flash_start_address == egrAddress)
                    {
                        byte[] egrdata = Tools.Instance.readdatafromfile(filename, egrAddress, sh.Length, EDCFileType.EDC15P);
                        int newValue = 8500;
                        for (int rows = 0; rows < sh.X_axis_length; rows++)
                        {
                            for (int cols = 0; cols < sh.Y_axis_length; cols++)
                            {
                                byte b1 = (byte)((newValue & 0x00FF00) / 256);
                                byte b2 = (byte)(newValue & 0x0000FF);

                                egrdata[rows * sh.Y_axis_length * 2 + cols * 2] = b1;
                                egrdata[rows * sh.Y_axis_length * 2 + (cols * 2) + 1] = b2;
                            }
                        }
                        SaveAndSyncData(egrdata.Length, (int)sh.Flash_start_address, egrdata, filename, true, "Disabled EGR map", autoUpdateChecksum);
                    }
                }
            }
            else retval = false;
            return retval;
        }
Esempio n. 5
0
        private bool CheckMajorMapsPresent(SymbolCollection newSymbols, EDCFileType type, out string _message)
        {
            _message = string.Empty;
            if (type == EDCFileType.EDC15C || type == EDCFileType.EDC15M || type == EDCFileType.EDC16 || type == EDCFileType.EDC17) return false; ;

            if (type == EDCFileType.EDC15P || type == EDCFileType.EDC15P6)
            {
                if (MapsWithNameMissing("Injector duration", newSymbols)) _message += "Injector duration maps missing" + Environment.NewLine;
                if (MapsWithNameMissing("Inverse driver wish", newSymbols)) _message += "Inverse driver wish map missing" + Environment.NewLine;
            }
            if (type == EDCFileType.EDC15P || type == EDCFileType.EDC15P6 || type == EDCFileType.EDC15V)
            {
                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 (MapsWithNameMissing("SOI limiter", newSymbols)) _message += "SOI limiter missing" + Environment.NewLine;
            }
            if (MapsWithNameMissing("Idle RPM", newSymbols)) _message += "Idle RPM map missing" + Environment.NewLine;
            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("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("Boost target map", newSymbols)) _message += "Boost target map 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 (_message == "") return true;
            return false;
        }
        public override void FindSVBL(byte[] allBytes, string filename, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
        {
            bool found = true;
            int offset = 0;
            while (found)
            {
                int SVBLAddress = Tools.Instance.findSequence(allBytes, offset, new byte[10] { 0xDF, 0x7A, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0x7A }, new byte[10] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
                if (SVBLAddress > 0)
                {
                    //Console.WriteLine("Alternative SVBL " + SVBLAddress.ToString("X8"));
                    SymbolHelper shsvbl = new SymbolHelper();
                    shsvbl.Category = "Detected maps";
                    shsvbl.Subcategory = "Limiters";
                    shsvbl.Flash_start_address = SVBLAddress - 2;

                    // if value = 0xC3 0x00 -> two more back
                    int[] testValue = Tools.Instance.readdatafromfileasint(filename, (int)shsvbl.Flash_start_address, 1, EDCFileType.EDC15C);
                    if (testValue[0] == 0xC300) shsvbl.Flash_start_address -= 2;

                    shsvbl.Varname = "SVBL Boost limiter [" + DetermineNumberByFlashBank(shsvbl.Flash_start_address, newCodeBlocks) + "]";
                    shsvbl.Length = 2;
                    shsvbl.CodeBlock = DetermineCodeBlockByByAddress(shsvbl.Flash_start_address, newCodeBlocks);
                    newSymbols.Add(shsvbl);
                    offset = SVBLAddress + 1;
                }
                else found = false;
            }
        }
 private Int32 GetSymbolAxisXID(SymbolCollection curSymbolCollection, string symbolname)
 {
     foreach (SymbolHelper sh in curSymbolCollection)
     {
         if (sh.Varname == symbolname || sh.Userdescription == symbolname)
         {
             return(sh.X_axis_ID);
         }
     }
     return(0);
 }
 private Int32 GetSymbolAxisXID(SymbolCollection curSymbolCollection, string symbolname)
 {
     foreach (SymbolHelper sh in curSymbolCollection)
     {
         if (sh.Varname == symbolname || sh.Userdescription == symbolname)
         {
             return sh.X_axis_ID;
         }
     }
     return 0;
 }
Esempio n. 9
0
 private bool CollectionContainsMapInSize(SymbolCollection newSymbols, int ysize, int xsize)
 {
     foreach (SymbolHelper sh in newSymbols)
     {
         if (sh.Y_axis_length == ysize && sh.X_axis_length == xsize)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 10
0
 public Int64 GetSymbolAddressLike(SymbolCollection curSymbolCollection, string symbolname)
 {
     foreach (SymbolHelper sh in curSymbolCollection)
     {
         if (sh.Varname.StartsWith(symbolname) || sh.Userdescription.StartsWith(symbolname))
         {
             return(sh.Flash_start_address);
         }
     }
     return(0);
 }
Esempio n. 11
0
 private bool MapsWithNameMissing(string varName, SymbolCollection newSymbols)
 {
     foreach (SymbolHelper sh in newSymbols)
     {
         if (sh.Varname.StartsWith(varName))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 12
0
 private void BuildAxisIDList(SymbolCollection newSymbols, List <AxisHelper> newAxisHelpers)
 {
     foreach (SymbolHelper sh in newSymbols)
     {
         if (!sh.Varname.StartsWith("2D") && !sh.Varname.StartsWith("3D"))
         {
             AddToAxisCollection(newAxisHelpers, sh.Y_axis_ID, sh.X_axis_descr, sh.XaxisUnits, sh.X_axis_correction, sh.X_axis_offset);
             AddToAxisCollection(newAxisHelpers, sh.X_axis_ID, sh.Y_axis_descr, sh.YaxisUnits, sh.Y_axis_correction, sh.Y_axis_offset);
         }
     }
 }
Esempio n. 13
0
        public void LoadDataFromFile(string filename, SymbolCollection symbols)
        {
            _fileName          = filename;
            _lastFilename      = _fileName;
            m_symbolcollection = symbols;
            FileInfo fi = new FileInfo(filename);

            m_currentfile_size = (int)fi.Length;
            OpenFile(filename);

            // ???
//            CloseFile();

            /*
             * FileInfo fi = new FileInfo(filename);
             * long numberoflines = fi.Length/16;
             * StringBuilder sb = new StringBuilder();
             * StringBuilder sbascii = new StringBuilder();
             * using (BinaryReader br = new BinaryReader(new FileStream(filename, FileMode.Open)))
             * {
             *  int current_address = 0;
             *  for (int lcount = 0; lcount < numberoflines; lcount++)
             *  {
             *      byte[] readbytes = br.ReadBytes(16);
             *      string line = current_address.ToString("X6") + " ";
             *      for (int bcount = 0; bcount < readbytes.Length; bcount++)
             *      {
             *          byte b = (byte)readbytes.GetValue(bcount);
             *          line += b.ToString("X2") + " ";
             *      }
             *      string line_ascii = string.Empty;
             *      for (int bcount = 0; bcount < readbytes.Length; bcount++)
             *      {
             *          byte b = (byte)readbytes.GetValue(bcount);
             *          if (b >= 0x20 && b <= 0x7f)
             *          {
             *              line_ascii += Convert.ToChar( b);
             *          }
             *          else
             *          {
             *              line_ascii += ".";
             *          }
             *      }
             *      sb.AppendLine(line);
             *      sbascii.AppendLine(line_ascii);
             *      current_address += 16;
             *  }
             * }
             * richTextBox1.Text = sb.ToString();
             * richTextBox2.Text = sbascii.ToString();
             *
             * //MessageBox.Show(richTextBox1.Find("ox1_filt_coef").ToString());*/
        }
Esempio n. 14
0
 public SelectSymbolEventArgs(int address, int length, string mapname, string filename, bool showdiffmap, SymbolCollection symColl, int symbolnumber1, int symbolnumber2, int codeblock1, int codeblock2)
 {
     this._address       = address;
     this._length        = length;
     this._mapname       = mapname;
     this._filename      = filename;
     this._showdiffmap   = showdiffmap;
     this._symbols       = symColl;
     this._symbolnumber1 = symbolnumber1;
     this._symbolnumber2 = symbolnumber2;
     this._codeBlock1    = codeblock1;
     this._codeBlock2    = codeblock2;
 }
Esempio n. 15
0
 private bool AddToSymbolCollection(SymbolCollection newSymbols, SymbolHelper newSymbol, List <CodeBlock> newCodeBlocks)
 {
     //if (newSymbol.Length >= 800) return false;
     foreach (SymbolHelper sh in newSymbols)
     {
         if (sh.Flash_start_address == newSymbol.Flash_start_address)
         {
             //   Console.WriteLine("Already in collection: " + sh.Flash_start_address.ToString("X8"));
             return(false);
         }
     }
     newSymbols.Add(newSymbol);
     newSymbol.CodeBlock = DetermineCodeBlockByByAddress(newSymbol.Flash_start_address, newCodeBlocks);
     return(true);
 }
Esempio n. 16
0
        public bool TuneEDC15PFile(string filename, SymbolCollection symbols, int peakTorque, int peakHP, bool autoUpdateChecksum)
        {
            bool retval = true;
            retval = TuneDriverWish(filename, symbols, peakTorque, peakHP, autoUpdateChecksum);
            if (retval) retval = TuneTorqueLimiter(filename, symbols, peakTorque, peakHP, autoUpdateChecksum);
            if (retval) retval = TuneSmokeLimiter(filename, symbols, peakTorque, peakHP, autoUpdateChecksum);
            if (retval) retval = DisableEGRMap(filename, symbols, autoUpdateChecksum);

            //Increase duration limiter?

            //Increase turbo boost request
            //Adjust N75 map?
            //Increase boost limiter(s) (map + SVBL)

            return false;
        }
Esempio n. 17
0
        private bool TuneDriverWish(string filename, SymbolCollection symbols, int peakTorque, int peakHP, bool autoUpdateChecksum)
        {
            bool retval = true;
            //Increase driverwish to peakIQ if it is not already (only the rightmost 2 columns)
            int dwAddress = (int)Tools.Instance.GetSymbolAddressLike(Tools.Instance.m_symbols, "Driver wish");

            if (dwAddress > 0)
            {
                foreach (SymbolHelper sh in Tools.Instance.m_symbols)
                {
                    if (sh.Flash_start_address == dwAddress)
                    {
                        byte[] dwdata = Tools.Instance.readdatafromfile(filename, dwAddress, sh.Length, EDCFileType.EDC15P);
                        //Console.WriteLine(sh.Varname + " " + sh.Y_axis_length.ToString() + " " + sh.X_axis_length.ToString());
                        int[] rpms = Tools.Instance.readdatafromfileasint(filename, sh.X_axis_address, sh.X_axis_length, EDCFileType.EDC15P);
                        for (int rows = 0; rows < sh.X_axis_length; rows++)
                        {
                            // whats the rpm?
                            int rpm          = rpms[rows];
                            int targetTorque = peakTorque;
                            int targetPower  = Tools.Instance.TorqueToPower(targetTorque, rpm);
                            if (targetPower > peakHP)
                            {
                                targetTorque = Tools.Instance.PowerToTorque(peakHP, rpm);
                            }
                            int targetIQ = Tools.Instance.TorqueToIQ(targetTorque, rpm, 4);
                            // Console.WriteLine("Calculate for rpm: " + rpm.ToString() + " targetT: " + targetTorque.ToString() + " targetP: " + targetPower.ToString() + " targetIQ: " + targetIQ.ToString());
                            targetIQ *= 100;
                            byte b1 = (byte)((targetIQ & 0x00FF00) / 256);
                            byte b2 = (byte)(targetIQ & 0x0000FF);
                            dwdata[rows * sh.Y_axis_length * 2 + (sh.Y_axis_length * 2) - 2] = b1;
                            dwdata[rows * sh.Y_axis_length * 2 + (sh.Y_axis_length * 2) - 1] = b2;
                            dwdata[rows * sh.Y_axis_length * 2 + (sh.Y_axis_length * 2) - 4] = b1;
                            dwdata[rows * sh.Y_axis_length * 2 + (sh.Y_axis_length * 2) - 3] = b2;
                        }
                        SaveAndSyncData(dwdata.Length, (int)sh.Flash_start_address, dwdata, filename, true, "Tuned driver wish", autoUpdateChecksum);
                    }
                }
            }
            else
            {
                retval = false;
            }
            return(retval);
        }
Esempio n. 18
0
        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>();
            // Bosch EDC17 style mapdetection LL LL AXIS AXIS MAPDATA
            byte[] allBytes = File.ReadAllBytes(filename);
            // EDC17 = ReverseEndian
            allBytes = Tools.Instance.reverseEndian(allBytes);
            for (int i = 0; i < allBytes.Length - 32; i += 2)
            {
                int len2Skip = CheckMap(i, allBytes, newSymbols, newCodeBlocks);
                if ((len2Skip % 2) > 0)
                {
                    if (len2Skip > 2)
                    {
                        len2Skip--;
                    }
                    else
                    {
                        len2Skip++;
                    }
                }
                //i += len2Skip;
                //i += len2Skip - 2;
                // For now we don't skip since we can have false alarm and thereby jumping over the start of the "real" map.
            }
            newSymbols.SortColumn   = "Flash_start_address";
            newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending;
            newSymbols.Sort();
            NameKnownMaps(allBytes, newSymbols, newCodeBlocks);
            FindSVBL(allBytes, filename, newSymbols, newCodeBlocks);
            SymbolTranslator strans = new SymbolTranslator();

            foreach (SymbolHelper sh in newSymbols)
            {
                sh.Description = strans.TranslateSymbolToHelpText(sh.Varname);
            }
            return(newSymbols);
        }
Esempio n. 19
0
        private bool TuneDriverWish(string filename, SymbolCollection symbols, int peakTorque, int peakHP, bool autoUpdateChecksum)
        {
            bool retval = true;
            //Increase driverwish to peakIQ if it is not already (only the rightmost 2 columns)
            int dwAddress = (int)Tools.Instance.GetSymbolAddressLike(Tools.Instance.m_symbols, "Driver wish");

            if (dwAddress > 0)
            {
                foreach (SymbolHelper sh in Tools.Instance.m_symbols)
                {
                    if (sh.Flash_start_address == dwAddress)
                    {
                        byte[] dwdata = Tools.Instance.readdatafromfile(filename, dwAddress, sh.Length, EDCFileType.EDC15P);
                        //Console.WriteLine(sh.Varname + " " + sh.Y_axis_length.ToString() + " " + sh.X_axis_length.ToString());
                        int[] rpms = Tools.Instance.readdatafromfileasint(filename, sh.X_axis_address, sh.X_axis_length, EDCFileType.EDC15P);
                        for (int rows = 0; rows < sh.X_axis_length; rows++)
                        {
                            // whats the rpm?
                            int rpm = rpms[rows];
                            int targetTorque = peakTorque;
                            int targetPower = Tools.Instance.TorqueToPower(targetTorque, rpm);
                            if (targetPower > peakHP) targetTorque = Tools.Instance.PowerToTorque(peakHP, rpm);
                            int targetIQ = Tools.Instance.TorqueToIQ(targetTorque, rpm, 4);
                            // Console.WriteLine("Calculate for rpm: " + rpm.ToString() + " targetT: " + targetTorque.ToString() + " targetP: " + targetPower.ToString() + " targetIQ: " + targetIQ.ToString());
                            targetIQ *= 100;
                            byte b1 = (byte)((targetIQ & 0x00FF00) / 256);
                            byte b2 = (byte)(targetIQ & 0x0000FF);
                            dwdata[rows * sh.Y_axis_length * 2 + (sh.Y_axis_length * 2) - 2] = b1;
                            dwdata[rows * sh.Y_axis_length * 2 + (sh.Y_axis_length * 2) - 1] = b2;
                            dwdata[rows * sh.Y_axis_length * 2 + (sh.Y_axis_length * 2) - 4] = b1;
                            dwdata[rows * sh.Y_axis_length * 2 + (sh.Y_axis_length * 2) - 3] = b2;
                        }
                        SaveAndSyncData(dwdata.Length, (int)sh.Flash_start_address, dwdata, filename, true, "Tuned driver wish", autoUpdateChecksum);

                    }
                }

            }
            else retval = false;
            return retval;
        }
Esempio n. 20
0
        public override void FindSVBL(byte[] allBytes, string filename, SymbolCollection newSymbols, List <CodeBlock> newCodeBlocks)
        {
            bool found  = true;
            int  offset = 0;

            while (found)
            {
                int SVBLAddress = Tools.Instance.findSequence(allBytes, offset, new byte[10] {
                    0xDF, 0x7A, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0x7A
                }, new byte[10] {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1
                });
                if (SVBLAddress > 0)
                {
                    //Console.WriteLine("Alternative SVBL " + SVBLAddress.ToString("X8"));
                    SymbolHelper shsvbl = new SymbolHelper();
                    shsvbl.Category            = "Detected maps";
                    shsvbl.Subcategory         = "Limiters";
                    shsvbl.Flash_start_address = SVBLAddress - 2;

                    // if value = 0xC3 0x00 -> two more back
                    int[] testValue = Tools.Instance.readdatafromfileasint(filename, (int)shsvbl.Flash_start_address, 1, EDCFileType.EDC15M);
                    if (testValue[0] == 0xC300)
                    {
                        shsvbl.Flash_start_address -= 2;
                    }

                    shsvbl.Varname   = "SVBL Boost limiter [" + DetermineNumberByFlashBank(shsvbl.Flash_start_address, newCodeBlocks) + "]";
                    shsvbl.Length    = 2;
                    shsvbl.CodeBlock = DetermineCodeBlockByByAddress(shsvbl.Flash_start_address, newCodeBlocks);
                    newSymbols.Add(shsvbl);
                    offset = SVBLAddress + 1;
                }
                else
                {
                    found = false;
                }
            }
        }
Esempio n. 21
0
        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>();
            // Bosch EDC16 style mapdetection LL LL AXIS AXIS MAPDATA
            byte[] allBytes = File.ReadAllBytes(filename);

            for (int i = 0; i < allBytes.Length - 32; i += 2)
            {
                int len2Skip = CheckMap(i, allBytes, newSymbols, newCodeBlocks);
                if ((len2Skip % 2) > 0)
                {
                    if (len2Skip > 2)
                    {
                        len2Skip--;
                    }
                    else
                    {
                        len2Skip++;
                    }
                }
                i += len2Skip;
            }
            newSymbols.SortColumn   = "Flash_start_address";
            newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending;
            newSymbols.Sort();
            NameKnownMaps(allBytes, newSymbols, newCodeBlocks);
            FindSVBL(allBytes, filename, newSymbols, newCodeBlocks);
            SymbolTranslator strans = new SymbolTranslator();

            foreach (SymbolHelper sh in newSymbols)
            {
                sh.Description = strans.TranslateSymbolToHelpText(sh.Varname);
            }
            return(newSymbols);
        }
Esempio n. 22
0
        private bool TuneTorqueLimiter(string filename, SymbolCollection symbols, int peakTorque, int peakHP, bool autoUpdateChecksum)
        {
            bool retval = true;
            //Increase driverwish to peakIQ if it is not already (only the rightmost 2 columns)
            int tlAddress = (int)Tools.Instance.GetSymbolAddressLike(Tools.Instance.m_symbols, "Torque limiter");

            if (tlAddress > 0)
            {
                foreach (SymbolHelper sh in Tools.Instance.m_symbols)
                {
                    if (sh.Flash_start_address == tlAddress)
                    {
                        byte[] tldata = Tools.Instance.readdatafromfile(filename, tlAddress, sh.Length, EDCFileType.EDC15P);
                        // Console.WriteLine(sh.Varname + " " + sh.Y_axis_length.ToString() + " " + sh.X_axis_length.ToString());
                        int[] rpms = Tools.Instance.readdatafromfileasint(filename, sh.Y_axis_address, sh.Y_axis_length, EDCFileType.EDC15P);
                        for (int rows = 0; rows < sh.X_axis_length; rows++)
                        {
                            for (int cols = 0; cols < sh.Y_axis_length; cols++)
                            {
                                // whats the rpm?
                                int rpm          = rpms[cols];
                                int targetTorque = peakTorque;
                                int targetPower  = Tools.Instance.TorqueToPower(targetTorque, rpm);
                                if (targetPower > peakHP)
                                {
                                    targetTorque = Tools.Instance.PowerToTorque(peakHP, rpm);
                                }
                                int targetIQ = Tools.Instance.TorqueToIQ(targetTorque, rpm, 4);
                                int maxIQ    = targetIQ;
                                if (rpm < 550)
                                {
                                    maxIQ = 0;
                                }
                                if (rpm > 5000)
                                {
                                    maxIQ = 0;
                                }
                                if (cols == 0)
                                {
                                    maxIQ = 0;
                                }
                                if (cols == sh.Y_axis_length - 1)
                                {
                                    maxIQ = 0;
                                }
                                if (rpm >= 550 && rpm < 1000)
                                {
                                    maxIQ = 30;
                                }
                                if (rpm >= 1000 && rpm < 1250)
                                {
                                    maxIQ = 45;
                                }
                                if (rpm >= 1250 && rpm < 1500)
                                {
                                    maxIQ = 55;
                                }
                                if (rpm >= 1500 && rpm < 1750)
                                {
                                    maxIQ = 60;
                                }
                                if (rpm >= 1750 && rpm < 1900)
                                {
                                    maxIQ = 65;
                                }
                                if (targetIQ > maxIQ)
                                {
                                    targetIQ = maxIQ;
                                }

                                //Console.WriteLine("Calculate for rpm: " + rpm.ToString() + " targetT: " + targetTorque.ToString() + " targetP: " + targetPower.ToString() + " targetIQ: " + targetIQ.ToString());
                                targetIQ *= 100;
                                byte b1 = (byte)((targetIQ & 0x00FF00) / 256);
                                byte b2 = (byte)(targetIQ & 0x0000FF);

                                tldata[rows * sh.Y_axis_length * 2 + cols * 2]       = b1;
                                tldata[rows * sh.Y_axis_length * 2 + (cols * 2) + 1] = b2;
                            }
                        }
                        SaveAndSyncData(tldata.Length, (int)sh.Flash_start_address, tldata, filename, true, "Tuned torque limiter", autoUpdateChecksum);
                    }
                }
            }
            else
            {
                retval = false;
            }
            return(retval);
        }
Esempio n. 23
0
        private int GetMapNameCountForCodeBlock(string varName, int codeBlock, SymbolCollection newSymbols, bool debug)
        {
            int count = 0;
            if (debug) Console.WriteLine("Check " + varName + " " + codeBlock);

            foreach (SymbolHelper sh in newSymbols)
            {
                if (debug)
                {
                    if (!sh.Varname.StartsWith("2D") && !sh.Varname.StartsWith("3D"))
                    {
                        Console.WriteLine(sh.Varname + " " + sh.CodeBlock);
                    }
                }
                if (sh.Varname.StartsWith(varName) && sh.CodeBlock == codeBlock)
                {

                    if (debug) Console.WriteLine("Found " + sh.Varname + " " + sh.CodeBlock);

                    count++;
                }
            }
            count++;
            return count;
        }
Esempio n. 24
0
        private bool TuneSmokeLimiter(string filename, SymbolCollection symbols, int peakTorque, int peakHP, bool autoUpdateChecksum)
        {
            bool retval = true;
            int peakIQ = peakTorque/6;
            //Smokelimit is when AFR = 1:17, but should decrease to 1:25 on low airmass?
            // full load would allow 1:15.5 or 1:16
            //

            // x = rpm
            int slAddress = (int)Tools.Instance.GetSymbolAddressLike(Tools.Instance.m_symbols, "Smoke limiter");

            if (slAddress > 0)
            {
                foreach (SymbolHelper sh in Tools.Instance.m_symbols)
                {
                    if (sh.Flash_start_address == slAddress)
                    {
                        byte[] sldata = Tools.Instance.readdatafromfile(filename, slAddress, sh.Length, EDCFileType.EDC15P);
                        //Console.WriteLine(sh.Varname + " " + sh.Y_axis_length.ToString() + " " + sh.X_axis_length.ToString());

                        int[] rpms = Tools.Instance.readdatafromfileasint(filename, sh.X_axis_address, sh.X_axis_length, EDCFileType.EDC15P);
                        int maxSupportedAirflow = peakIQ * 17;

                        // range from 300 mg - maxSupportedAirflow
                        int airFlowStep = (maxSupportedAirflow - 300) / sh.Y_axis_length;
                        int[] airFlowAxis = new int[sh.Y_axis_length];
                        for (int i = 0; i < airFlowAxis.Length; i++)
                        {
                            airFlowAxis[i] = (300 + (i * airFlowStep)) * 10;
                        }
                        // save axis
                        byte[] barr = new byte[airFlowAxis.Length * 2];
                        int bCount = 0;
                        for (int i = 0; i < airFlowAxis.Length; i++)
                        {
                            int iVal = (int)airFlowAxis.GetValue(i);
                            byte b1 = (byte)((iVal & 0x00FF00) / 256);
                            byte b2 = (byte)(iVal & 0x0000FF);
                            barr[bCount++] = b1;
                            barr[bCount++] = b2;
                        }
                        Tools.Instance.savedatatobinary(sh.Y_axis_address, barr.Length, barr, filename, true, "Tuned smoke limiter axis", EDCFileType.EDC15P);
                        // check for other symbols with the same length and the same END address
                        foreach (SymbolHelper shaxis in Tools.Instance.m_symbols)
                        {
                            if (shaxis.X_axis_address != sh.X_axis_address)
                            {
                                if ((shaxis.X_axis_address & 0x0FFFF) == (sh.X_axis_address & 0x0FFFF))
                                {
                                    if (shaxis.X_axis_length * 2 == barr.Length)
                                    {
                                        Tools.Instance.savedatatobinary(sh.X_axis_address, barr.Length, barr, filename, true, "Tuned smoke limiter axis", EDCFileType.EDC15P);
                                    }
                                }
                            }
                            else if (shaxis.Y_axis_address != sh.Y_axis_address)
                            {
                                if ((shaxis.Y_axis_address & 0x0FFFF) == (sh.Y_axis_address & 0x0FFFF))
                                {
                                    if (shaxis.Y_axis_length * 2 == barr.Length)
                                    {
                                        Tools.Instance.savedatatobinary(shaxis.Y_axis_address, barr.Length, barr, filename, true, "Tuned smoke limiter axis", EDCFileType.EDC15P);
                                    }
                                }
                            }
                        }

                        if(autoUpdateChecksum) Tools.Instance.UpdateChecksum(filename, false);
                        // end of save axis

                        int[] airmasses = Tools.Instance.readdatafromfileasint(filename, sh.Y_axis_address, sh.Y_axis_length, EDCFileType.EDC15P);

                        for (int rows = 0; rows < sh.X_axis_length; rows++)
                        {
                            for (int cols = 0; cols < sh.Y_axis_length; cols++)
                            {
                                // whats the rpm?

                                int rpm = rpms[rows];
                                // what is the airmass
                                int airmass = airmasses[cols];

                                // we should simply limit to 1:17 for all rpm ranges
                                int newIQ = airmass / 170;

                                int targetTorque = peakTorque;
                                int targetPower = Tools.Instance.TorqueToPower(targetTorque, rpm);
                                if (targetPower > peakHP)
                                {
                                    targetTorque = Tools.Instance.PowerToTorque(peakHP, rpm);
                                    targetPower = Tools.Instance.TorqueToPower(targetTorque, rpm);
                                }
                                int targetIQ = Tools.Instance.TorqueToIQ(targetTorque, rpm, 4);

                                if (newIQ > targetIQ) newIQ = targetIQ;

                                //Console.WriteLine("Calculate for rpm: " + rpm.ToString() + " targetT: " + targetTorque.ToString() + " targetP: " + targetPower.ToString() + " targetIQ: " + targetIQ.ToString());

                                newIQ *= 100;
                                byte b1 = (byte)((newIQ & 0x00FF00) / 256);
                                byte b2 = (byte)(newIQ & 0x0000FF);

                                sldata[rows * sh.Y_axis_length * 2 + cols * 2] = b1;
                                sldata[rows * sh.Y_axis_length * 2 + (cols * 2) + 1] = b2;
                            }
                        }
                        SaveAndSyncData(sldata.Length, (int)sh.Flash_start_address, sldata, filename, true, "Tuned smoke limiter", autoUpdateChecksum);

                    }
                }

            }
            else retval = false;
            return retval;
        }
Esempio n. 25
0
        public override void FindSVBL(byte[] allBytes, string filename, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
        {
            bool found = true;
            int offset = 0;
            while (found)
            {
                int SVBLAddress = Tools.Instance.findSequence(allBytes, offset, new byte[10] { 0xDF, 0x7A, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0x7A }, new byte[10] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
                ///int SVBLAddress = Tools.Instance.findSequence(allBytes, offset, new byte[16] { 0xD2, 0x00, 0xFC, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xFF, 0xFF, 0xFF, 0xC3, 0x00, 0x00 }, new byte[16] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1 });

                if (SVBLAddress > 0)
                {
                    //Console.WriteLine("Alternative SVBL " + SVBLAddress.ToString("X8"));
                    SymbolHelper shsvbl = new SymbolHelper();
                    shsvbl.Category = "Detected maps";
                    shsvbl.Subcategory = "Limiters";
                    shsvbl.Flash_start_address = SVBLAddress - 2;
                    //shsvbl.Flash_start_address = SVBLAddress + 16;

                    // if value = 0xC3 0x00 -> two more back
                    int[] testValue = Tools.Instance.readdatafromfileasint(filename, (int)shsvbl.Flash_start_address, 1, EDCFileType.EDC15P6);
                    if (testValue[0] == 0xC300) shsvbl.Flash_start_address -= 2;

                    shsvbl.Varname = "SVBL Boost limiter [" + DetermineNumberByFlashBank(shsvbl.Flash_start_address, newCodeBlocks) +"]";
                    shsvbl.Length = 2;
                    shsvbl.CodeBlock = DetermineCodeBlockByByAddress(shsvbl.Flash_start_address, newCodeBlocks);
                    newSymbols.Add(shsvbl);

                    int MAPMAFSwitch = Tools.Instance.findSequence(allBytes, SVBLAddress - 0x100, new byte[8] { 0x41, 0x02, 0xFF, 0xFF, 0x00, 0x01, 0x01, 0x00 }, new byte[8] { 1, 1, 0, 0, 1, 1, 1, 1 });
                    if (MAPMAFSwitch > 0)
                    {
                        MAPMAFSwitch += 2;
                        SymbolHelper mapmafsh = new SymbolHelper();
                        //mapmafsh.BitMask = 0x0101;
                        mapmafsh.Category = "Detected maps";
                        mapmafsh.Subcategory = "Switches";
                        mapmafsh.Flash_start_address = MAPMAFSwitch;
                        mapmafsh.Varname = "MAP/MAF switch (0 = MAF, 257/0x101 = MAP)" + DetermineNumberByFlashBank(shsvbl.Flash_start_address, newCodeBlocks);
                        mapmafsh.Length = 2;
                        mapmafsh.CodeBlock = DetermineCodeBlockByByAddress(mapmafsh.Flash_start_address, newCodeBlocks);
                        newSymbols.Add(mapmafsh);
                        Console.WriteLine("Found MAP MAF switch @ " + MAPMAFSwitch.ToString("X8"));
                    }

                    offset = SVBLAddress + 1;
                }
                else found = false;
            }
        }
Esempio n. 26
0
        public override void NameKnownMaps(byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
        {
            SymbolAxesTranslator st = new SymbolAxesTranslator();

            foreach (SymbolHelper sh in newSymbols)
            {
                //sh.X_axis_descr = st.TranslateAxisID(sh.X_axis_ID);
               // sh.Y_axis_descr = st.TranslateAxisID(sh.Y_axis_ID);
                if (sh.Length == 700) // 25*14
                {
                    sh.Category = "Detected maps";
                    sh.Subcategory = "Misc";
                    sh.Varname = "Launch control map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                    sh.Y_axis_correction = 0.156250;
                    sh.Correction = 0.01;
                    sh.X_axis_descr = "Engine speed (rpm)";
                    sh.Y_axis_descr = "Vehicle speed (kph)";
                    sh.Z_axis_descr = "Output percentage";
                    sh.YaxisUnits = "km/h";
                    sh.XaxisUnits = "rpm";
                }

                if (sh.Length == 570)
                {
                    if (((sh.X_axis_ID / 256) & 0xF0) == 0xC0 && ((sh.Y_axis_ID / 256) & 0xF0) == 0xE0)
                    {

                        sh.Category = "Detected maps";
                        sh.Subcategory = "Fuel";
                        int injDurCount = GetMapNameCountForCodeBlock("Injector duration", sh.CodeBlock, newSymbols, false);
                        injDurCount--;
                        sh.Varname = "Injector duration " + injDurCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.Y_axis_correction = 0.01;
                        sh.Correction = 0.023437;
                        sh.X_axis_descr = "Engine speed (rpm)";
                        //sh.Y_axis_descr = "Airflow mg/stroke";
                        sh.Y_axis_descr = "Requested Quantity mg/stroke";

                        sh.Z_axis_descr = "Duration (crankshaft degrees)";
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mg/st";
                    }
                    else if (((sh.X_axis_ID / 256) & 0xF0) == 0xC1 && ((sh.Y_axis_ID / 256) & 0xF0) == 0xE0)
                    {

                        sh.Category = "Detected maps";
                        sh.Subcategory = "Fuel";
                        int injDurCount = GetMapNameCountForCodeBlock("Injector duration", sh.CodeBlock, newSymbols, false);
                        injDurCount--;
                        sh.Varname = "Injector duration " + injDurCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.Y_axis_correction = 0.01;
                        sh.Correction = 0.023437;
                        sh.X_axis_descr = "Engine speed (rpm)";
                        //sh.Y_axis_descr = "Airflow mg/stroke";
                        sh.Y_axis_descr = "Requested Quantity mg/stroke";

                        sh.Z_axis_descr = "Duration (crankshaft degrees)";
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mg/st";
                    }
                }
                else if (sh.Length == 480)
                {
                    if (sh.X_axis_ID / 256 == 0xC5 && sh.Y_axis_ID / 256 == 0xEC)
                    {

                        sh.Category = "Detected maps";
                        sh.Subcategory = "Fuel";
                        int injDurCount = GetMapNameCountForCodeBlock("Injector duration", sh.CodeBlock, newSymbols, false);
                        injDurCount--;

                        //IAT, ECT or Fuel temp?

                        double tempRange = GetTemperatureDurRange(injDurCount - 1);
                        sh.Varname = "Injector duration " + injDurCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.Y_axis_correction = 0.01;
                        sh.Correction = 0.023437;
                        sh.X_axis_descr = "Engine speed (rpm)";
                        //sh.Y_axis_descr = "Airflow mg/stroke";
                        sh.Y_axis_descr = "Requested Quantity mg/stroke";

                        sh.Z_axis_descr = "Duration (crankshaft degrees)";
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mg/st";
                    }
                }
                else if (sh.Length == 448)
                {
                    if (sh.MapSelector.NumRepeats == 10)
                    {
                        // SOI maps detected
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Fuel";
                        int injDurCount = GetMapNameCountForCodeBlock("Start of injection (SOI)", sh.CodeBlock, newSymbols, false);

                        //IAT, ECT or Fuel temp?
                        double tempRange = GetTemperatureSOIRange(sh.MapSelector, injDurCount - 1);
                        //Console.WriteLine("Temperature switch for SOI " + injDurCount.ToString() + " " + tempRange.ToString());
                        //sh.Varname = "Start of injection (SOI) " + injDurCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.Varname = "Start of injection (SOI) " + tempRange.ToString() + " °C [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");

                        sh.Correction = -0.023437;
                        sh.Offset = 78;

                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.X_axis_correction = 0.01; // TODODONE : Check for x or y
                        sh.XaxisUnits = "mg/st";

                        sh.X_axis_descr = "IQ (mg/stroke)";
                        sh.Z_axis_descr = "Start position (degrees BTDC)";
                    }
                }
                else if (sh.Length == 416)
                {
                    string strAddrTest = sh.Flash_start_address.ToString("X8");
                    if (sh.X_axis_ID / 256 == 0xF9 && sh.Y_axis_ID / 256 == 0xDA)
                    {
                        // this is IQ by MAF limiter!
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Smoke limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.X_axis_descr = "Airflow mg/stroke";
                        sh.Correction = 0.01;
                        sh.X_axis_correction = 0.1;
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mg/st";

                    }
                    else if (sh.X_axis_ID / 256 == 0xEC && sh.Y_axis_ID / 256 == 0xDA)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        // if x axis = upto 3000 -> MAP limit, not MAF limit
                        if (GetMaxAxisValue(allBytes, sh, MapViewerEx.AxisIdent.Y_Axis) < 4000)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            sh.Varname = "IQ by MAP limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") +" " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.Correction = 0.01;
                            sh.X_axis_descr = "Boost pressure";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.Z_axis_descr = "Maximum IQ (mg)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mbar";

                        }
                        else
                        {
                            int iqMAFLimCount = GetMapNameCountForCodeBlock("IQ by MAF limiter", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "IQ by MAF limiter " + iqMAFLimCount.ToString() + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            //sh.Varname = "IQ by MAF limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Maximum IQ (mg)";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.1;
                            sh.XaxisUnits = "mg/st";
                            sh.X_axis_descr = "Airflow mg/stroke";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                        }

                    }
                    else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC3)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        int iqMAFLimCount = GetMapNameCountForCodeBlock("IQ by MAF limiter", sh.CodeBlock, newSymbols, false);
                        sh.Varname = "IQ by MAF limiter " + iqMAFLimCount.ToString() + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        //sh.Varname = "IQ by MAF limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        sh.Correction = 0.01;
                        sh.X_axis_correction = 0.1;
                        sh.XaxisUnits = "mg/st";
                        sh.X_axis_descr = "Airflow mg/stroke";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                    }
                    else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID == 0xDDDC)
                    {
                        // SOI
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Fuel";
                        int injDurCount = GetMapNameCountForCodeBlock("Start of injection (SOI)", sh.CodeBlock, newSymbols, false);
                        //IAT, ECT or Fuel temp?
                        double tempRange = GetTemperatureSOIRange(sh.MapSelector, injDurCount - 1);
                        sh.Varname = "Start of injection (SOI) " + tempRange.ToString() + " °C [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.Correction = -0.023437;
                        sh.Offset = 78;
                        sh.X_axis_descr = "IQ (mg/stroke)";

                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.X_axis_correction = 0.01; // TODODONE : Check for x or y
                        sh.XaxisUnits = "mg/st";

                    }
                    else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDD)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Turbo";
                        sh.Varname = "N75 duty cycle [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Duty cycle %";
                        sh.Correction = -0.01;
                        sh.Offset = 100;
                        //sh.Correction = 0.01;
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "IQ (mg/stroke)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mg/st";
                    }
                    else if (strAddrTest.EndsWith("116"))
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Misc";
                        int egrCount = GetMapNameCountForCodeBlock("EGR", sh.CodeBlock, newSymbols, false);
                        sh.Varname = "EGR " + egrCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Correction = 0.1;
                        sh.X_axis_correction = 0.01;
                        sh.Z_axis_descr = "Mass Air Flow (mg/stroke)";
                        sh.X_axis_descr = "IQ (mg/stroke)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mg/st";
                    }
                    else if ((sh.X_axis_ID / 256 == 0xE0) && (sh.Y_axis_ID / 256 == 0xDE))
                    {
                        // x axis should start with 0!
                        if (allBytes[sh.Y_axis_address] == 0 && allBytes[sh.Y_axis_address + 1] == 0)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            int egrCount = GetMapNameCountForCodeBlock("EGR", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "EGR " + egrCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.1;
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Mass Air Flow (mg/stroke)";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                    }
                    else if (sh.X_axis_ID / 256 == 0xEA && sh.Y_axis_ID / 256 == 0xE9)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Fuel";
                        int injDurCount = GetMapNameCountForCodeBlock("Start of injection (SOI)", sh.CodeBlock, newSymbols, false);
                        //IAT, ECT or Fuel temp?
                        double tempRange = GetTemperatureSOIRange(sh.MapSelector, injDurCount - 1);
                        sh.Varname = "Start of injection (SOI) " + tempRange.ToString() + " °C [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.Correction = -0.023437;
                        sh.Offset = 78;

                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.X_axis_correction = 0.01; // TODODONE : Check for x or y
                        sh.XaxisUnits = "mg/st";
                        sh.X_axis_descr = "IQ (mg/stroke)";

                        sh.Z_axis_descr = "Start position (degrees BTDC)";
                    }
                    else if (sh.X_axis_ID / 256 == 0xEA && sh.Y_axis_ID / 256 == 0xE8)
                    {
                        // EGR or N75
                        if (allBytes[sh.X_axis_address] == 0 && allBytes[sh.X_axis_address + 1] == 0)
                        {
                            // EGR
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            int egrCount = GetMapNameCountForCodeBlock("EGR", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "EGR " + egrCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.1;
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Mass Air Flow (mg/stroke)";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";

                        }
                        else
                        {
                            //N75
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Turbo";
                            sh.Varname = "N75 duty cycle [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Duty cycle %";
                            sh.Correction = -0.01;
                            sh.Offset = 100;
                            //sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";

                        }
                    }
                   /* else if ((sh.X_axis_ID / 256 == 0xEA) && (sh.Y_axis_ID / 256 == 0xE8))
                    {
                        // x axis should start with 0!
                        if (allBytes[sh.Y_axis_address] == 0 && allBytes[sh.Y_axis_address + 1] == 0)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            int egrCount = GetMapNameCountForCodeBlock("EGR", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "EGR " + egrCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.1;
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Mass Air Flow (mg/stroke)";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                    }*/
                }
                else if (sh.Length == 390)
                {
                    // 15x12 = inj dur limiter on R3 files
                    if (sh.X_axis_length == 13 && sh.Y_axis_length == 15)
                    {
                        //if (!MapContainsNegativeValues(allBytes, sh))
                        {
                            /*sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            sh.Varname = "Injection duration limiter B [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.Correction = 0.023438;
                            sh.Y_axis_correction = 0.01;
                            sh.Y_axis_descr = "IQ (mg/stroke)";
                            sh.Z_axis_descr = "Max. degrees";
                            sh.X_axis_descr = "Engine speed (rpm)";
                            sh.XaxisUnits = "rpm";
                            sh.YaxisUnits = "mg/st";*/
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            int injDurCount = GetMapNameCountForCodeBlock("Injector duration", sh.CodeBlock, newSymbols, false);
                            injDurCount--;
                            sh.Varname = "Injector duration " + injDurCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.Y_axis_correction = 0.01;
                            sh.Correction = 0.023437;
                            sh.X_axis_descr = "Engine speed (rpm)";
                            //sh.Y_axis_descr = "Airflow mg/stroke";
                            sh.Y_axis_descr = "Requested Quantity mg/stroke";

                            sh.Z_axis_descr = "Duration (crankshaft degrees)";
                            sh.XaxisUnits = "rpm";
                            sh.YaxisUnits = "mg/st";

                        }
                    }
                }
                else if (sh.Length == 384)
                {
                    if (sh.X_axis_length == 12 && sh.Y_axis_length == 16)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Misc";
                        sh.Varname = "Inverse driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Correction = 0.01;
                        sh.X_axis_correction = 0.01;
                        sh.Z_axis_descr = "Throttle  position";
                        sh.X_axis_descr = "IQ (mg/stroke)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        //sh.Z_axis_descr = "Requested IQ (mg)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mg/st";
                    }
                    else if (sh.X_axis_length == 16 && sh.Y_axis_length == 12)
                    {
                        if ((sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDC))
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            sh.Varname = "Smoke limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Maximum IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.X_axis_descr = "Airflow mg/stroke";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.1;
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                        else if ((sh.X_axis_ID / 256 == 0xEC) && (sh.Y_axis_ID / 256 == 0xC0))
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            int egrCount = GetMapNameCountForCodeBlock("EGR", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "EGR " + egrCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.1;
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Mass Air Flow (mg/stroke)";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                    }
                }
                else if (sh.Length == 360)
                {
                    // 15x12 = inj dur limiter on R3 files
                    if (sh.X_axis_length == 12 && sh.Y_axis_length == 15)
                    {
                        //if (!MapContainsNegativeValues(allBytes, sh))
                        {
                            /*sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            sh.Varname = "Injection duration limiter A [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.Correction = 0.023438;
                            sh.Y_axis_correction = 0.01;
                            sh.Y_axis_descr = "IQ (mg/stroke)";
                            sh.Z_axis_descr = "Max. degrees";
                            sh.X_axis_descr = "Engine speed (rpm)";
                            sh.XaxisUnits = "rpm";
                            sh.YaxisUnits = "mg/st";*/
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            int injDurCount = GetMapNameCountForCodeBlock("Injector duration", sh.CodeBlock, newSymbols, false);
                            injDurCount--;
                            sh.Varname = "Injector duration " + injDurCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.Y_axis_correction = 0.01;
                            sh.Correction = 0.023437;
                            sh.X_axis_descr = "Engine speed (rpm)";
                            //sh.Y_axis_descr = "Airflow mg/stroke";
                            sh.Y_axis_descr = "Requested Quantity mg/stroke";

                            sh.Z_axis_descr = "Duration (crankshaft degrees)";
                            sh.XaxisUnits = "rpm";
                            sh.YaxisUnits = "mg/st";

                        }
                    }
                }
                else if (sh.Length == 352)
                {
                    if (sh.X_axis_length == 16 && sh.Y_axis_length == 11)
                    {
                        if (sh.X_axis_ID / 256 == 0xEC && sh.Y_axis_ID / 256 == 0xC0)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            int egrCount = GetMapNameCountForCodeBlock("EGR", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "EGR " + egrCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.1;
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Mass Air Flow (mg/stroke)";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                        else if (sh.X_axis_ID / 256 == 0xEC && sh.Y_axis_ID / 256 == 0xEA)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Turbo";
                            sh.Varname = "N75 duty cycle [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Duty cycle %";
                            sh.Correction = -0.01;
                            sh.Offset = 100;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                    }
                }
                else if (sh.Length == 320)
                {
                    sh.Category = "Probable maps";
                    sh.Subcategory = "Turbo";
                    sh.Varname = "Boost map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "] " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                    if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC3)
                    {
                        sh.Category = "Detected maps";
                        sh.Varname = "Boost target map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "IQ (mg/stroke)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.Z_axis_descr = "Boost target (mbar)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mg/st";
                    }
                    else if (sh.X_axis_ID / 256 == 0xEA && sh.Y_axis_ID / 256 == 0xC0)
                    {
                        sh.Category = "Detected maps";
                        sh.Varname = "Boost target map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "IQ (mg/stroke)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.Z_axis_descr = "Boost target (mbar)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mg/st";
                    }
                    if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDC)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "IQ by MAP limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") +" " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.Correction = 0.01;
                        sh.X_axis_descr = "Boost pressure";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mbar";
                    }

                    if (sh.X_axis_ID / 256 == 0xDA && sh.Y_axis_ID / 256 == 0xDA)
                    {
                        //sh.Category = "Detected maps";
                        //sh.Subcategory = "Limiters";
                        sh.Varname = "Boost map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "] " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.X_axis_descr = "CT (celcius)";
                        sh.X_axis_correction = 0.1;
                        sh.X_axis_offset = -273.1;
                        sh.XaxisUnits = "degrees";
                    }
                    //sh.Correction = 0.01;
                    //sh.Y_axis_correction = 0.01;

                }
                else if (sh.Length == 308)
                {
                    sh.Category = "Detected maps";
                    sh.Subcategory = "Limiters";
                    //sh.Varname = "Boost limiter (temperature) [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                    sh.Varname = "SOI limiter (temperature) [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                    sh.Correction = -0.023437;
                    sh.Offset = 78;
                    sh.Y_axis_descr = "Engine speed (rpm)";
                    sh.X_axis_descr = "IAT (celcius)"; //IAT, ECT or Fuel temp?
                    sh.X_axis_correction = 0.1;
                    sh.X_axis_offset = -273.1;
                    sh.Z_axis_descr = "SOI limit (degrees)";
                    sh.YaxisUnits = "rpm";
                    sh.XaxisUnits = "IAT C";
                }
                else if (sh.Length == 280) // boost target can be 10x14 as well in Seat maps
                {
                    if (sh.X_axis_ID / 256 == 0xEC && sh.Y_axis_ID / 256 == 0xC0)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Turbo";
                        sh.Varname = "Boost target map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "] " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "IQ (mg/stroke)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.Z_axis_descr = "Boost target (mbar)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mg/st";
                    }
                }
                else if (sh.Length == 256)
                {
                    sh.Category = "Detected maps";
                    sh.Subcategory = "Misc";
                    sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                    sh.Correction = 0.01;
                    sh.X_axis_correction = 0.01;
                    sh.X_axis_descr = "Throttle  position";
                    sh.Z_axis_descr = "Requested IQ (mg)";
                    sh.Y_axis_descr = "Engine speed (rpm)";
                    sh.YaxisUnits = "rpm";
                    sh.XaxisUnits = "TPS %";

                }
                else if (sh.Length == 240)
                {
                    if (sh.X_axis_length == 12 && sh.Y_axis_length == 10)
                    {
                        if (sh.X_axis_ID / 256 == 0xEC && sh.Y_axis_ID / 256 == 0xC0)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "Throttle  position";
                            sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "TPS %";
                        }
                    }

                }
                else if (sh.Length == 216)
                {
                    if (sh.X_axis_length == 12 && sh.Y_axis_length == 9)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Misc";
                        sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Correction = 0.01;
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "Throttle  position";
                        sh.Z_axis_descr = "Requested IQ (mg)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "TPS %";
                    }

                }
                else if (sh.Length == 200)
                {
                    if (sh.X_axis_ID / 256 == 0xC2 && sh.Y_axis_ID / 256 == 0xE0)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Boost limit map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        //   sh.Correction = 0.01;
                        //sh.X_axis_correction = 0.01;
                        sh.Y_axis_descr = "Atmospheric pressure (mbar)";
                        sh.Z_axis_descr = "Maximum boost pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";
                    }
                    else if (sh.X_axis_ID / 256 == 0xC0 && sh.Y_axis_ID / 256 == 0xEA)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Boost limit map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        //   sh.Correction = 0.01;
                        //sh.X_axis_correction = 0.01;
                        sh.Y_axis_descr = "Atmospheric pressure (mbar)";
                        sh.Z_axis_descr = "Maximum boost pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";
                    }
                    else if (sh.X_axis_ID / 256 == 0xC1 && sh.Y_axis_ID / 256 == 0xE0)
                    {
                        //if (!MapContainsNegativeValues(allBytes, sh))
                        if(GetMaxAxisValue(allBytes, sh, MapViewerEx.AxisIdent.X_Axis) > 5000)
                        {
                           /* sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            sh.Varname = "Injection duration limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.Correction = 0.023438;
                            sh.Y_axis_correction = 0.01;
                            sh.Y_axis_descr = "IQ (mg/stroke)";
                            sh.Z_axis_descr = "Max. degrees";
                            sh.X_axis_descr = "Engine speed (rpm)";
                            sh.XaxisUnits = "rpm";
                            sh.YaxisUnits = "mg/st";*/
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            int injDurCount = GetMapNameCountForCodeBlock("Injector duration", sh.CodeBlock, newSymbols, false);
                            injDurCount--;
                            sh.Varname = "Injector duration " + injDurCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.Y_axis_correction = 0.01;
                            sh.Correction = 0.023437;
                            sh.X_axis_descr = "Engine speed (rpm)";
                            //sh.Y_axis_descr = "Airflow mg/stroke";
                            sh.Y_axis_descr = "Requested Quantity mg/stroke";

                            sh.Z_axis_descr = "Duration (crankshaft degrees)";
                            sh.XaxisUnits = "rpm";
                            sh.YaxisUnits = "mg/st";

                        }
                    }
                }

                else if (sh.Length == 192)
                {
                    if (sh.X_axis_ID / 256 == 0xEC && sh.Y_axis_ID / 256 == 0xC0)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Misc";
                        sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Correction = 0.01;
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "Throttle  position";
                        sh.Z_axis_descr = "Requested IQ (mg)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "TPS %";

                    }
                }
                else if (sh.Length == 180)
                {
                    if (sh.X_axis_length == 9 && sh.Y_axis_length == 10)
                    {
                        if (sh.X_axis_ID / 256 == 0xEC && sh.Y_axis_ID / 256 == 0xC1)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            int sIQCount = GetMapNameCountForCodeBlock("Start IQ ", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "Start IQ (" + sIQCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.01;
                            sh.X_axis_descr = "CT (celcius)";
                            sh.X_axis_correction = 0.1;
                            sh.X_axis_offset = -273.1;
                            sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "degC";
                        }
                        else if (sh.X_axis_ID / 256 == 0xC0 && sh.Y_axis_ID / 256 == 0xEC)
                        {
                            // atm boost limit R3 file versions
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            sh.Varname = "Boost limit map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            //   sh.Correction = 0.01;
                            //sh.X_axis_correction = 0.01;
                            sh.Y_axis_descr = "Atmospheric pressure (mbar)";
                            sh.Z_axis_descr = "Maximum boost pressure (mbar)";
                            sh.X_axis_descr = "Engine speed (rpm)";
                            sh.XaxisUnits = "rpm";
                            sh.YaxisUnits = "mbar";
                        }
                        else if (sh.X_axis_ID / 256 == 0xC1 && sh.Y_axis_ID / 256 == 0xE0)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            int injDurCount = GetMapNameCountForCodeBlock("Injector duration", sh.CodeBlock, newSymbols, false);
                            injDurCount--;
                            //if (injDurCount < 1) injDurCount = 1;
                            sh.Varname = "Injector duration " + injDurCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Y_axis_correction = 0.01;
                            sh.Correction = 0.023437;
                            sh.X_axis_descr = "Engine speed (rpm)";
                            //sh.Y_axis_descr = "Airflow mg/stroke";
                            sh.Y_axis_descr = "Requested Quantity mg/stroke";

                            sh.Z_axis_descr = "Duration (crankshaft degrees)";
                            sh.XaxisUnits = "rpm";
                            sh.YaxisUnits = "mg/st";
                        }
                    }
                }
                else if (sh.Length == 162)
                {
                    if (sh.X_axis_length == 9 && sh.Y_axis_length == 9)
                    {
                        if (sh.X_axis_ID / 256 == 0xEC && sh.Y_axis_ID / 256 == 0xC1)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            int sIQCount = GetMapNameCountForCodeBlock("Start IQ ", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "Start IQ (" + sIQCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.01;
                            sh.X_axis_descr = "CT (celcius)";
                            sh.X_axis_correction = 0.1;
                            sh.X_axis_offset = -273.1;
                            sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "degC";
                        }
                    }
                }
                else if (sh.Length == 144)
                {
                    if (sh.X_axis_length == 9 && sh.Y_axis_length == 8)
                    {
                        if (sh.X_axis_ID / 256 == 0xEC && sh.Y_axis_ID / 256 == 0xC0)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            sh.Varname = "Fuel correction [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            /*sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "Throttle  position";
                            sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "TPS %";*/
                        }
                    }
                    if (sh.X_axis_length == 8 && sh.Y_axis_length == 9)
                    {
                        if (sh.X_axis_ID / 256 == 0xEC && sh.Y_axis_ID / 256 == 0xC1)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            int sIQCount = GetMapNameCountForCodeBlock("Start IQ ", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "Start IQ (" + sIQCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.X_axis_descr = "CT (celcius)";
                            sh.X_axis_correction = 0.1;
                            sh.X_axis_offset = -273.1;
                            sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.Correction = 0.01;
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "degC";
                        }
                    }
                }

                else if (sh.Length == 128)
                {
                    if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID  == 0xC14a)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "MAF correction by temperature [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Limit";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.X_axis_descr = "IAT (celcius)"; //IAT, ECT or Fuel temp?
                        sh.X_axis_correction = 0.1;
                        sh.X_axis_offset = -273.1;
                        sh.Correction = 0.01;
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "IAT C";

                    }
                }
                else if (sh.Length == 138)  // R3 (1.4 TDi, three cylinder) has this
                {
                    if (sh.X_axis_length == 3 && sh.Y_axis_length == 23)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Torque limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        sh.Y_axis_descr = "Atm. pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.Correction = 0.01;
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";

                    }
                }
                else if (sh.Length == 132)  // R3 (1.4 TDi, three cylinder) has this
                {
                    if (sh.X_axis_length == 3 && sh.Y_axis_length == 22)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Torque limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        sh.Y_axis_descr = "Atm. pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.Correction = 0.01;
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";

                    }
                }
                else if (sh.Length == 126)
                {
                    if (sh.X_axis_length == 3 && sh.Y_axis_length == 21)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Torque limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        sh.Y_axis_descr = "Atm. pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";
                        sh.Correction = 0.01;
                    }
                }
                else if (sh.Length == 120)
                {
                    if (sh.X_axis_length == 3 && sh.Y_axis_length == 20)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Torque limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        sh.Y_axis_descr = "Atm. pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.Correction = 0.01;
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";

                    }
                }
                else if (sh.Length == 64)
                {
                    if (sh.X_axis_length == 32 && sh.Y_axis_length == 1)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Misc";
                        sh.Varname = "MAF linearization [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                    }
                }
                else if (sh.Length == 4)
                {
                    if (sh.X_axis_length == 2 && sh.Y_axis_length == 1)
                    {
                        //if (sh.X_axis_ID >= 0xEBA0 && sh.X_axis_ID <= 0xEBAF)
                        if (sh.X_axis_ID == 0xEBA2 || sh.X_axis_ID == 0xEBA4 || sh.X_axis_ID == 0xE9BC || sh.X_axis_ID == 0xE04A)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            sh.Varname = "MAP linearization [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        }
                        else if (sh.X_axis_ID / 256 == 0xC1) // idle RPM
                        {
                            if (IsValidTemperatureAxis(allBytes, sh, MapViewerEx.AxisIdent.X_Axis))
                            {
                                sh.Category = "Detected maps";
                                sh.Subcategory = "Misc";
                                int lmCount = GetMapNameCountForCodeBlock("Idle RPM", sh.CodeBlock, newSymbols, false);

                                sh.Varname = "Idle RPM (" + lmCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                                sh.Y_axis_descr = "Coolant temperature";
                                sh.Y_axis_correction = 0.1;
                                sh.Y_axis_offset = -273.1;
                                sh.Z_axis_descr = "Target engine speed";
                                sh.YaxisUnits = "°C";
                            }

                        }
                    }
                }
            }
        }
Esempio n. 27
0
 private bool AddToSymbolCollection(SymbolCollection newSymbols, SymbolHelper newSymbol, List<CodeBlock> newCodeBlocks)
 {
     if (newSymbol.Length >= 800) return false;
     foreach (SymbolHelper sh in newSymbols)
     {
         if (sh.Flash_start_address == newSymbol.Flash_start_address)
         {
             //   Console.WriteLine("Already in collection: " + sh.Flash_start_address.ToString("X8"));
             return false;
         }
         // not allowed to overlap
        /* else if (newSymbol.Flash_start_address > sh.Flash_start_address && newSymbol.Flash_start_address < (sh.Flash_start_address + sh.Length))
         {
             Console.WriteLine("Overlapping map: " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_length.ToString() + " x " + sh.Y_axis_length.ToString());
             Console.WriteLine("Overlapping new: " + newSymbol.Flash_start_address.ToString("X8") + " " + newSymbol.X_axis_length.ToString() + " x " + newSymbol.Y_axis_length.ToString());
             return false;
         }*/
     }
     newSymbols.Add(newSymbol);
     newSymbol.CodeBlock = DetermineCodeBlockByByAddress(newSymbol.Flash_start_address, newCodeBlocks);
     return true;
 }
Esempio n. 28
0
        private bool CheckMajorMapsPresent(SymbolCollection newSymbols, EDCFileType type, out string _message)
        {
            _message = string.Empty;
            if (type == EDCFileType.EDC15C || type == EDCFileType.EDC15M || type == EDCFileType.EDC16 || type == EDCFileType.EDC17)
            {
                return(false);
            }
            ;

            if (type == EDCFileType.EDC15P || type == EDCFileType.EDC15P6)
            {
                if (MapsWithNameMissing("Injector duration", newSymbols))
                {
                    _message += "Injector duration maps missing" + Environment.NewLine;
                }
                if (MapsWithNameMissing("Inverse driver wish", newSymbols))
                {
                    _message += "Inverse driver wish map missing" + Environment.NewLine;
                }
            }
            if (type == EDCFileType.EDC15P || type == EDCFileType.EDC15P6 || type == EDCFileType.EDC15V)
            {
                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 (MapsWithNameMissing("SOI limiter", newSymbols))
                {
                    _message += "SOI limiter missing" + Environment.NewLine;
                }
            }
            if (MapsWithNameMissing("Idle RPM", newSymbols))
            {
                _message += "Idle RPM map missing" + Environment.NewLine;
            }
            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("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("Boost target map", newSymbols))
            {
                _message += "Boost target map 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 (_message == "")
            {
                return(true);
            }
            return(false);
        }
Esempio n. 29
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();
        }
Esempio n. 30
0
        public override void NameKnownMaps(byte[] allBytes, SymbolCollection newSymbols, List <CodeBlock> newCodeBlocks)
        {
            SymbolAxesTranslator st = new SymbolAxesTranslator();

            foreach (SymbolHelper sh in newSymbols)
            {
                // sh.X_axis_descr = st.TranslateAxisID(sh.X_axis_ID);
                // sh.Y_axis_descr = st.TranslateAxisID(sh.Y_axis_ID);
                if (sh.X_axis_length == 4 && sh.Y_axis_length == 20)
                {
                    sh.Category    = "Detected maps";
                    sh.Subcategory = "Limiters";
                    //int lmCount = GetMapNameCountForCodeBlock("Torque limiter", sh.CodeBlock, newSymbols, false);
                    sh.Varname      = "Torque limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                    sh.Z_axis_descr = "Maximum IQ (mg)";
                    //sh.Y_axis_descr = "Atm. pressure (mbar)";
                    sh.Y_axis_descr = "Engine speed (rpm)";
                    sh.Correction   = 0.01;
                    sh.YaxisUnits   = "rpm";
                }

                if (sh.X_axis_length == 4 && sh.Y_axis_length == 21)
                {
                    sh.Category    = "Detected maps";
                    sh.Subcategory = "Limiters";
                    //int lmCount = GetMapNameCountForCodeBlock("Torque limiter", sh.CodeBlock, newSymbols, false);
                    sh.Varname      = "Torque limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                    sh.Z_axis_descr = "Maximum IQ (mg)";
                    //sh.Y_axis_descr = "Atm. pressure (mbar)";
                    sh.Y_axis_descr = "Engine speed (rpm)";
                    sh.Correction   = 0.01;
                    sh.YaxisUnits   = "rpm";
                }
                else if (sh.X_axis_length == 3 && sh.Y_axis_length == 21)
                {
                    if (!CollectionContainsMapInSize(newSymbols, 21, 4))
                    {
                        sh.Category    = "Detected maps";
                        sh.Subcategory = "Limiters";
                        //int lmCount = GetMapNameCountForCodeBlock("Torque limiter", sh.CodeBlock, newSymbols, false);
                        sh.Varname      = "Torque limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        //sh.Y_axis_descr = "Atm. pressure (mbar)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.Correction   = 0.01;
                        sh.YaxisUnits   = "rpm";
                    }
                }
                else if (sh.X_axis_length == 16 && sh.Y_axis_length == 8)
                {
                    sh.Category    = "Detected maps";
                    sh.Subcategory = "Misc";
                    int dwCount = GetMapNameCountForCodeBlock("Driver wish ", sh.CodeBlock, newSymbols, false);

                    sh.Varname           = "Driver wish (" + dwCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                    sh.Correction        = 0.01;
                    sh.X_axis_correction = 0.01;
                    sh.X_axis_descr      = "Throttle  position";
                    sh.Z_axis_descr      = "Requested IQ (mg)";
                    sh.Y_axis_descr      = "Engine speed (rpm)";
                    sh.YaxisUnits        = "rpm";
                    sh.XaxisUnits        = "TPS %";
                }
                else if (sh.X_axis_length == 15 && sh.Y_axis_length == 16)
                {
                    sh.Category          = "Detected maps";
                    sh.Subcategory       = "Misc";
                    sh.Varname           = "IQ to Torque conversion [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                    sh.Correction        = 0.01;
                    sh.X_axis_correction = 0.1;
                    sh.X_axis_descr      = "Torque";
                    sh.Z_axis_descr      = "IQ (mg)";
                    sh.Y_axis_descr      = "Engine speed (rpm)";
                    sh.YaxisUnits        = "rpm";
                    sh.XaxisUnits        = "Nm";
                }
                else if (sh.X_axis_length == 11 && sh.Y_axis_length == 10)
                {
                    sh.Category    = "Detected maps";
                    sh.Subcategory = "Limiters";
                    sh.Varname     = "Boost limit map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                    //   sh.Correction = 0.01;
                    //sh.X_axis_correction = 0.01;
                    sh.X_axis_descr = "Atmospheric pressure (mbar)";
                    sh.Z_axis_descr = "Maximum boost pressure (mbar)";
                    sh.Y_axis_descr = "Engine speed (rpm)";
                    sh.YaxisUnits   = "rpm";
                    sh.XaxisUnits   = "mbar";
                }
                else if (sh.X_axis_length == 19 && sh.Y_axis_length == 15)
                {
                    sh.Category    = "Detected maps";
                    sh.Subcategory = "Fuel";
                    int injDurCount = GetMapNameCountForCodeBlock("Injector duration", sh.CodeBlock, newSymbols, false);
                    sh.Varname           = "Injector duration " + injDurCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]"; // " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                    sh.Y_axis_correction = 0.01;                                                                                                                               // TODO: Check for x or y
                    sh.Correction        = 0.023437;
                    sh.X_axis_descr      = "Engine speed (rpm)";
                    //sh.Y_axis_descr = "Airflow mg/stroke";
                    sh.Y_axis_descr = "Requested Quantity mg/stroke";

                    sh.Z_axis_descr = "Duration (crankshaft degrees)";
                    sh.XaxisUnits   = "rpm";
                    sh.YaxisUnits   = "mg/st";
                }
                else if (sh.X_axis_length == 16 && sh.Y_axis_length == 12)
                {
                    //int xmax = GetMaxAxisValue(allBytes, sh, MapViewerEx.AxisIdent.X_Axis);
                    //int ymax = GetMaxAxisValue(allBytes, sh, MapViewerEx.AxisIdent.Y_Axis);
                    //Console.WriteLine(xmax.ToString() + " " + ymax.ToString() + " " + sh.Flash_start_address.ToString("X8"));
                    if (GetMaxAxisValue(allBytes, sh, MapViewerEx.AxisIdent.Y_Axis) < 4000)
                    {
                        sh.Category     = "Detected maps";
                        sh.Subcategory  = "Limiters";
                        sh.Varname      = "Smoke limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.X_axis_descr = "Manifold pressure (mbar)";
                        sh.Correction   = 0.01;
                        //sh.X_axis_correction = 0.1; // TODO: Check for x or y
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mbar";
                    }
                }
                else if (sh.X_axis_length == 16 && sh.Y_axis_length == 14)
                {
                    // SOI
                    sh.Category    = "Detected maps";
                    sh.Subcategory = "Fuel";
                    int injDurCount = GetMapNameCountForCodeBlock("Start of injection (SOI)", sh.CodeBlock, newSymbols, false);

                    //Console.WriteLine("Temperature switch for SOI " + injDurCount.ToString() + " " + tempRange.ToString());
                    //sh.Varname = "Start of injection (SOI) " + injDurCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                    sh.Varname = "Start of injection (SOI) " + injDurCount.ToString() + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");

                    sh.Correction = 0.023437;
                    //sh.Offset = 78;

                    sh.Y_axis_descr      = "Engine speed (rpm)";
                    sh.YaxisUnits        = "rpm";
                    sh.X_axis_correction = 0.01; // TODODONE : Check for x or y
                    sh.XaxisUnits        = "mg/st";

                    sh.X_axis_descr = "IQ (mg/stroke)";
                    sh.Z_axis_descr = "Start position (degrees BTDC)";
                }
            }
        }
Esempio n. 31
0
        private bool TuneSmokeLimiter(string filename, SymbolCollection symbols, int peakTorque, int peakHP, bool autoUpdateChecksum)
        {
            bool retval = true;
            int  peakIQ = peakTorque / 6;
            //Smokelimit is when AFR = 1:17, but should decrease to 1:25 on low airmass?
            // full load would allow 1:15.5 or 1:16
            //

            // x = rpm
            int slAddress = (int)Tools.Instance.GetSymbolAddressLike(Tools.Instance.m_symbols, "Smoke limiter");

            if (slAddress > 0)
            {
                foreach (SymbolHelper sh in Tools.Instance.m_symbols)
                {
                    if (sh.Flash_start_address == slAddress)
                    {
                        byte[] sldata = Tools.Instance.readdatafromfile(filename, slAddress, sh.Length, EDCFileType.EDC15P);
                        //Console.WriteLine(sh.Varname + " " + sh.Y_axis_length.ToString() + " " + sh.X_axis_length.ToString());

                        int[] rpms = Tools.Instance.readdatafromfileasint(filename, sh.X_axis_address, sh.X_axis_length, EDCFileType.EDC15P);
                        int   maxSupportedAirflow = peakIQ * 17;

                        // range from 300 mg - maxSupportedAirflow
                        int   airFlowStep = (maxSupportedAirflow - 300) / sh.Y_axis_length;
                        int[] airFlowAxis = new int[sh.Y_axis_length];
                        for (int i = 0; i < airFlowAxis.Length; i++)
                        {
                            airFlowAxis[i] = (300 + (i * airFlowStep)) * 10;
                        }
                        // save axis
                        byte[] barr   = new byte[airFlowAxis.Length * 2];
                        int    bCount = 0;
                        for (int i = 0; i < airFlowAxis.Length; i++)
                        {
                            int  iVal = (int)airFlowAxis.GetValue(i);
                            byte b1   = (byte)((iVal & 0x00FF00) / 256);
                            byte b2   = (byte)(iVal & 0x0000FF);
                            barr[bCount++] = b1;
                            barr[bCount++] = b2;
                        }
                        Tools.Instance.savedatatobinary(sh.Y_axis_address, barr.Length, barr, filename, true, "Tuned smoke limiter axis", EDCFileType.EDC15P);
                        // check for other symbols with the same length and the same END address
                        foreach (SymbolHelper shaxis in Tools.Instance.m_symbols)
                        {
                            if (shaxis.X_axis_address != sh.X_axis_address)
                            {
                                if ((shaxis.X_axis_address & 0x0FFFF) == (sh.X_axis_address & 0x0FFFF))
                                {
                                    if (shaxis.X_axis_length * 2 == barr.Length)
                                    {
                                        Tools.Instance.savedatatobinary(sh.X_axis_address, barr.Length, barr, filename, true, "Tuned smoke limiter axis", EDCFileType.EDC15P);
                                    }
                                }
                            }
                            else if (shaxis.Y_axis_address != sh.Y_axis_address)
                            {
                                if ((shaxis.Y_axis_address & 0x0FFFF) == (sh.Y_axis_address & 0x0FFFF))
                                {
                                    if (shaxis.Y_axis_length * 2 == barr.Length)
                                    {
                                        Tools.Instance.savedatatobinary(shaxis.Y_axis_address, barr.Length, barr, filename, true, "Tuned smoke limiter axis", EDCFileType.EDC15P);
                                    }
                                }
                            }
                        }

                        if (autoUpdateChecksum)
                        {
                            Tools.Instance.UpdateChecksum(filename, false);
                        }
                        // end of save axis


                        int[] airmasses = Tools.Instance.readdatafromfileasint(filename, sh.Y_axis_address, sh.Y_axis_length, EDCFileType.EDC15P);

                        for (int rows = 0; rows < sh.X_axis_length; rows++)
                        {
                            for (int cols = 0; cols < sh.Y_axis_length; cols++)
                            {
                                // whats the rpm?

                                int rpm = rpms[rows];
                                // what is the airmass
                                int airmass = airmasses[cols];

                                // we should simply limit to 1:17 for all rpm ranges
                                int newIQ = airmass / 170;

                                int targetTorque = peakTorque;
                                int targetPower  = Tools.Instance.TorqueToPower(targetTorque, rpm);
                                if (targetPower > peakHP)
                                {
                                    targetTorque = Tools.Instance.PowerToTorque(peakHP, rpm);
                                    targetPower  = Tools.Instance.TorqueToPower(targetTorque, rpm);
                                }
                                int targetIQ = Tools.Instance.TorqueToIQ(targetTorque, rpm, 4);

                                if (newIQ > targetIQ)
                                {
                                    newIQ = targetIQ;
                                }

                                //Console.WriteLine("Calculate for rpm: " + rpm.ToString() + " targetT: " + targetTorque.ToString() + " targetP: " + targetPower.ToString() + " targetIQ: " + targetIQ.ToString());

                                newIQ *= 100;
                                byte b1 = (byte)((newIQ & 0x00FF00) / 256);
                                byte b2 = (byte)(newIQ & 0x0000FF);

                                sldata[rows * sh.Y_axis_length * 2 + cols * 2]       = b1;
                                sldata[rows * sh.Y_axis_length * 2 + (cols * 2) + 1] = b2;
                            }
                        }
                        SaveAndSyncData(sldata.Length, (int)sh.Flash_start_address, sldata, filename, true, "Tuned smoke limiter", autoUpdateChecksum);
                    }
                }
            }
            else
            {
                retval = false;
            }
            return(retval);
        }
Esempio n. 32
0
        private void VerifyCodeBlocks(byte[] allBytes, SymbolCollection newSymbols, List <CodeBlock> newCodeBlocks)
        {
            //000001=automatic,000002=manual,000003=4wd ????
            Tools.Instance.m_codeBlock5ID = 0;
            Tools.Instance.m_codeBlock6ID = 0;
            Tools.Instance.m_codeBlock7ID = 0;
            bool found  = true;
            int  offset = 0;
            int  defaultCodeBlockLength = 0x10000;
            int  currentCodeBlockLength = 0;
            int  prevCodeBlockStart     = 0;

            while (found)
            {
                int CodeBlockAddress = Tools.Instance.findSequence(allBytes, offset, new byte[11] {
                    0xC1, 0x02, 0x00, 0x68, 0x00, 0x25, 0x03, 0x00, 0x00, 0x10, 0x27
                }, new byte[11] {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
                });
                if (CodeBlockAddress > 0)
                {
                    CodeBlock newcodeblock = new CodeBlock();
                    newcodeblock.StartAddress = CodeBlockAddress - 1;
                    if (prevCodeBlockStart == 0)
                    {
                        prevCodeBlockStart = newcodeblock.StartAddress;
                    }
                    else if (currentCodeBlockLength == 0)
                    {
                        currentCodeBlockLength = newcodeblock.StartAddress - prevCodeBlockStart;
                        if (currentCodeBlockLength > 0x10000)
                        {
                            currentCodeBlockLength = 0x10000;
                        }
                    }
                    // find the next occurence of the checksum
                    newCodeBlocks.Add(newcodeblock);
                    offset = CodeBlockAddress + 1;
                }
                else
                {
                    found = false;
                }
            }
            foreach (CodeBlock cb in newCodeBlocks)
            {
                if (currentCodeBlockLength != 0)
                {
                    cb.EndAddress = cb.StartAddress + currentCodeBlockLength - 1;
                }
                else
                {
                    cb.EndAddress = cb.StartAddress + defaultCodeBlockLength - 1;
                }
            }
            foreach (CodeBlock cb in newCodeBlocks)
            {
                int autoSequenceIndex = Tools.Instance.findSequence(allBytes, cb.StartAddress, new byte[7] {
                    0x45, 0x44, 0x43, 0x20, 0x20, 0x41, 0x47
                }, new byte[7] {
                    1, 1, 1, 1, 1, 1, 1
                });
                int manualSequenceIndex = Tools.Instance.findSequence(allBytes, cb.StartAddress, new byte[7] {
                    0x45, 0x44, 0x43, 0x20, 0x20, 0x53, 0x47
                }, new byte[7] {
                    1, 1, 1, 1, 1, 1, 1
                });
                if (autoSequenceIndex < cb.EndAddress && autoSequenceIndex >= cb.StartAddress)
                {
                    cb.BlockGearboxType = GearboxType.Automatic;
                }
                if (manualSequenceIndex < cb.EndAddress && manualSequenceIndex >= cb.StartAddress)
                {
                    cb.BlockGearboxType = GearboxType.Manual;
                }
            }
            if (Tools.Instance.m_currentfilelength >= 0x80000)
            {
                Tools.Instance.m_codeBlock5ID = CheckCodeBlock(0x50000, allBytes, newSymbols, newCodeBlocks); //manual specific
                Tools.Instance.m_codeBlock6ID = CheckCodeBlock(0x60000, allBytes, newSymbols, newCodeBlocks); //automatic specific
                Tools.Instance.m_codeBlock7ID = CheckCodeBlock(0x70000, allBytes, newSymbols, newCodeBlocks); //quattro specific
            }
        }
Esempio n. 33
0
 public frmSymbolSelect(SymbolCollection symbols)
 {
     m_symbols = symbols;
     InitializeComponent();
 }
Esempio n. 34
0
        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);
            partNumberConverter pnc = new partNumberConverter();

            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;
                }
            }

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

            RemoveNonSymbols(newSymbols, newCodeBlocks);

            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;
        }
Esempio n. 35
0
 abstract public void NameKnownMaps(byte[] allBytes, SymbolCollection newSymbols, List <CodeBlock> newCodeBlocks);
Esempio n. 36
0
        // we need to check AHEAD for selector maps
        // if these are present we may be facing a complex map structure
        // which we need to handle in a special way (selectors always have data like 00 01 00 02 00 03 00 04 etc)
        private bool CheckMap(int t, byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks, out int len2Skip)
        {
            bool mapFound = false;
            bool retval = false;
            bool _dontGenMaps = false;
            len2Skip = 0;
            List<MapSelector> mapSelectors = new List<MapSelector>();
            if (t < allBytes.Length - 0x100)
            {

                if (CheckAxisCount(t, allBytes, out mapSelectors) > 3)
                {
                    // check for selectors as well, and count them in the process
                    Console.WriteLine("Offset " + t.ToString("X8") + " has more than 3 consecutive axis");
                    /*foreach (MapSelector ms in mapSelectors)
                    {
                        Console.WriteLine("selector: " + ms.StartAddress.ToString("X8") + " " + ms.MapLength.ToString() + " " + ms.NumRepeats.ToString());
                    }*/
                    _dontGenMaps = true;

                }

                int xaxisid = (Convert.ToInt32(allBytes[t + 1]) * 256) + Convert.ToInt32(allBytes[t]);

                if (isAxisID(xaxisid))
                {
                    int xaxislen = (Convert.ToInt32(allBytes[t + 3]) * 256) + Convert.ToInt32(allBytes[t + 2]);
                    // Console.WriteLine("Valid XID: " + xaxisid.ToString("X4") + " @" + t.ToString("X8") + " len: " + xaxislen.ToString("X2"));
                    if (isValidLength(xaxislen, xaxisid))
                    {
                        //Console.WriteLine("Valid XID: " + xaxisid.ToString("X4") + " @" + t.ToString("X8") + " len: " + xaxislen.ToString("X2"));
                        // misschien is er nog een as
                        int yaxisid = (Convert.ToInt32(allBytes[t + 5 + (xaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 4 + (xaxislen * 2)]);
                        int yaxislen = (Convert.ToInt32(allBytes[t + 7 + (xaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 6 + (xaxislen * 2)]);
                        if (isAxisID(yaxisid) && isValidLength(yaxislen, yaxisid))
                        {
                            // 3d map

                            int zaxisid = (Convert.ToInt32(allBytes[t + 9 + (xaxislen * 2) + (yaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 8 + (xaxislen * 2) + (yaxislen * 2)]);
                            //Console.WriteLine("Valid YID: " + yaxisid.ToString("X4") + " @" + t.ToString("X8") + " len: " + yaxislen.ToString("X2"));

                            //Console.WriteLine(t.ToString("X8") + " XID: " + xaxisid.ToString("X4") + " XLEN: " + xaxislen.ToString("X2") + " YID: " + yaxisid.ToString("X4") + " YLEN: " + yaxislen.ToString("X2"));
                            SymbolHelper newSymbol = new SymbolHelper();
                            newSymbol.X_axis_length = xaxislen;
                            newSymbol.Y_axis_length = yaxislen;
                            newSymbol.X_axis_ID = xaxisid;
                            newSymbol.Y_axis_ID = yaxisid;
                            newSymbol.X_axis_address = t + 4;
                            newSymbol.Y_axis_address = t + 8 + (xaxislen * 2);

                            newSymbol.Length = xaxislen * yaxislen * 2;
                            newSymbol.Flash_start_address = t + 8 + (xaxislen * 2) + (yaxislen * 2);
                            if (isAxisID(zaxisid))
                            {
                                int zaxislen = (Convert.ToInt32(allBytes[t + 11 + (xaxislen * 2) + (yaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 10 + (xaxislen * 2) + (yaxislen * 2)]);

                                int zaxisaddress = t + 12 + (xaxislen * 2) + (yaxislen * 2);

                                if (isValidLength(zaxislen, zaxisid))
                                {
                                    //   newSymbol.Flash_start_address += 0x10; // dan altijd 16 erbij
                                    int len2skip = (4 + zaxislen * 2);
                                    if (len2skip < 16) len2skip = 16; // at least 16 bytes
                                    newSymbol.Flash_start_address += len2skip;

                                    len2Skip += (xaxislen * 2) + (yaxislen * 2) + zaxislen * 2;

                                    if (!_dontGenMaps)
                                    {
                                        // this has something to do with repeating several times with the same axis set

                                        Console.WriteLine("Added " + len2skip.ToString() + " because of z axis " + newSymbol.Flash_start_address.ToString("X8"));

                                        // maybe there are multiple maps between the end of the map and the start of the next axis
                                        int nextMapAddress = findNextMap(allBytes, (int)(newSymbol.Flash_start_address + newSymbol.Length), newSymbol.Length * 10);
                                        if (nextMapAddress > 0)
                                        {
                                            // is it divisable by the maplength

                                            if (((nextMapAddress - newSymbol.Flash_start_address) % newSymbol.Length) == 0)
                                            {

                                                int numberOfrepeats = (int)(nextMapAddress - newSymbol.Flash_start_address) / newSymbol.Length;
                                                numberOfrepeats = zaxislen;
                                                if (numberOfrepeats > 1)
                                                {
                                                    MapSelector ms = new MapSelector();
                                                    ms.NumRepeats = numberOfrepeats;
                                                    ms.MapLength = newSymbol.Length;
                                                    ms.StartAddress = zaxisaddress;
                                                    ms.XAxisAddress = newSymbol.X_axis_address;
                                                    ms.YAxisAddress = newSymbol.Y_axis_address;
                                                    ms.XAxisLen = newSymbol.X_axis_length;
                                                    ms.YAxisLen = newSymbol.Y_axis_length;
                                                    ms.MapData = new int[zaxislen];
                                                    int boffset = 0;
                                                    for (int ia = 0; ia < zaxislen; ia++)
                                                    {
                                                        int axisValue = Convert.ToInt32(allBytes[zaxisaddress + boffset]) + Convert.ToInt32(allBytes[zaxisaddress + boffset + 1]) * 256;
                                                        ms.MapData.SetValue(axisValue, ia);
                                                        boffset += 2;
                                                    }

                                                    ms.MapIndexes = new int[zaxislen];
                                                    for (int ia = 0; ia < zaxislen; ia++)
                                                    {
                                                        int axisValue = Convert.ToInt32(allBytes[zaxisaddress + boffset]) + Convert.ToInt32(allBytes[zaxisaddress + boffset + 1]) * 256;
                                                        ms.MapIndexes.SetValue(axisValue, ia);
                                                        boffset += 2;
                                                    }

                                                    // numberOfrepeats--;
                                                    //int idx = 0;

                                                    for (int maprepeat = 0; maprepeat < numberOfrepeats; maprepeat++)
                                                    {
                                                        // idx ++;
                                                        SymbolHelper newGenSym = new SymbolHelper();
                                                        newGenSym.X_axis_length = newSymbol.X_axis_length;
                                                        newGenSym.Y_axis_length = newSymbol.Y_axis_length;
                                                        newGenSym.X_axis_ID = newSymbol.X_axis_ID;
                                                        newGenSym.Y_axis_ID = newSymbol.Y_axis_ID;
                                                        newGenSym.X_axis_address = newSymbol.X_axis_address;
                                                        newGenSym.Y_axis_address = newSymbol.Y_axis_address;
                                                        newGenSym.Flash_start_address = newSymbol.Flash_start_address + maprepeat * newSymbol.Length;
                                                        newGenSym.Length = newSymbol.Length;
                                                        newGenSym.Varname = "3D GEN " + newGenSym.Flash_start_address.ToString("X8") + " " + xaxisid.ToString("X4") + " " + yaxisid.ToString("X4");
                                                        newGenSym.MapSelector = ms;
                                                        // attach a mapselector to these maps
                                                        // only add it if the map is not empty
                                                        // otherwise we will cause confusion among users
                                                        if (maprepeat > 0)
                                                        {
                                                            try
                                                            {
                                                                if (ms.MapIndexes[maprepeat] > 0)
                                                                {
                                                                    retval = AddToSymbolCollection(newSymbols, newGenSym, newCodeBlocks);
                                                                    if (retval)
                                                                    {
                                                                        mapFound = true;
                                                                        //GUIDO len2Skip += (xaxislen * 2) + (yaxislen * 2) + newGenSym.Length;
                                                                        t += (xaxislen * 2) + (yaxislen * 2) + newGenSym.Length;
                                                                    }
                                                                }
                                                            }
                                                            catch (Exception)
                                                            {
                                                            }
                                                        }
                                                        else
                                                        {
                                                            retval = AddToSymbolCollection(newSymbols, newGenSym, newCodeBlocks);
                                                            if (retval)
                                                            {
                                                                mapFound = true;
                                                                //GUIDO len2Skip += (xaxislen * 2) + (yaxislen * 2) + newGenSym.Length;
                                                                t += (xaxislen * 2) + (yaxislen * 2) + newGenSym.Length;
                                                            }
                                                        }
                                                    }
                                                }
                                                //Console.WriteLine("Indeed!");
                                                // the first one will be added anyway.. add the second to the last

                                            }

                                        }
                                    }
                                    else
                                    {

                                        int maxisid = (Convert.ToInt32(allBytes[t + 13 + (xaxislen * 2) + (yaxislen * 2) + (zaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 12 + (xaxislen * 2) + (yaxislen * 2) + zaxislen * 2]);
                                        int maxislen = (Convert.ToInt32(allBytes[t + 15 + (xaxislen * 2) + (yaxislen * 2) + (zaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 14 + (xaxislen * 2) + (yaxislen * 2) + zaxislen * 2]);
                                        //maxislen *= 2;

                                        int maxisaddress = t + 16 + (xaxislen * 2) + (yaxislen * 2);

                                        if (isAxisID(maxisid))
                                        {
                                            newSymbol.Flash_start_address += (maxislen * 2) + 4;
                                        }
                                        // special situation, handle selectors
                                        Console.WriteLine("Map start address = " + newSymbol.Flash_start_address.ToString("X8"));
                                        long lastFlashAddress = newSymbol.Flash_start_address;
                                        foreach (MapSelector ms in mapSelectors)
                                        {

                                            // check the memory size between the start of the map and the
                                            // start of the map selector
                                            long memsize = ms.StartAddress - lastFlashAddress;
                                            memsize /= 2; // in words

                                            int mapsize = Convert.ToInt32(memsize) / ms.NumRepeats;

                                            if ((xaxislen * yaxislen) == mapsize)
                                            {
                                                //Console.WriteLine("selector: " + ms.StartAddress.ToString("X8") + " " + ms.MapLength.ToString() + " " + ms.NumRepeats.ToString());
                                                //Console.WriteLine("memsize = " + memsize.ToString() + " mapsize " + mapsize.ToString());
                                                //Console.WriteLine("starting at address: " + lastFlashAddress.ToString("X8"));
                                                // first axis set
                                                for (int i = 0; i < ms.NumRepeats; i++)
                                                {
                                                    SymbolHelper shGen2 = new SymbolHelper();
                                                    shGen2.MapSelector = ms;
                                                    shGen2.X_axis_length = newSymbol.X_axis_length;
                                                    shGen2.Y_axis_length = newSymbol.Y_axis_length;
                                                    shGen2.X_axis_ID = newSymbol.X_axis_ID;
                                                    shGen2.Y_axis_ID = newSymbol.Y_axis_ID;
                                                    shGen2.X_axis_address = newSymbol.X_axis_address;
                                                    shGen2.Y_axis_address = newSymbol.Y_axis_address;
                                                    shGen2.Length = mapsize * 2;
                                                    //shGen2.Category = "Generated";
                                                    long address = lastFlashAddress;
                                                    shGen2.Flash_start_address = address;
                                                    //shGen2.Correction = 0.023437; // TEST
                                                    //shGen2.Varname = "Generated* " + shGen2.Flash_start_address.ToString("X8") + " " + ms.StartAddress.ToString("X8") + " " + ms.NumRepeats.ToString() + " " + i.ToString();
                                                    shGen2.Varname = "3D " + shGen2.Flash_start_address.ToString("X8") + " " + shGen2.X_axis_ID.ToString("X4") + " " + shGen2.Y_axis_ID.ToString("X4");
                                                    retval = AddToSymbolCollection(newSymbols, shGen2, newCodeBlocks);
                                                    if (retval)
                                                    {
                                                        mapFound = true;
                                                        //GUIDO len2Skip += (xaxislen * 2) + (yaxislen * 2) + shGen2.Length;
                                                        t += (xaxislen * 2) + (yaxislen * 2) + shGen2.Length;
                                                    }
                                                    lastFlashAddress = address + mapsize * 2;
                                                    // Console.WriteLine("Set last address to " + lastFlashAddress.ToString("X8"));
                                                }
                                                lastFlashAddress += ms.NumRepeats * 4 + 4;
                                            }
                                            else if ((zaxislen * maxislen) == mapsize)
                                            {
                                                // second axis set
                                                for (int i = 0; i < ms.NumRepeats; i++)
                                                {
                                                    SymbolHelper shGen2 = new SymbolHelper();
                                                    shGen2.MapSelector = ms;
                                                    shGen2.X_axis_length = maxislen;
                                                    shGen2.Y_axis_length = zaxislen;
                                                    shGen2.X_axis_ID = maxisid;
                                                    shGen2.Y_axis_ID = zaxisid;
                                                    shGen2.X_axis_address = maxisaddress;
                                                    shGen2.Y_axis_address = zaxisaddress;
                                                    shGen2.Length = mapsize * 2;
                                                    //shGen2.Category = "Generated";
                                                    long address = lastFlashAddress;
                                                    shGen2.Flash_start_address = address;
                                                    //shGen2.Varname = "Generated** " + shGen2.Flash_start_address.ToString("X8");
                                                    shGen2.Varname = "3D " + shGen2.Flash_start_address.ToString("X8") + " " + shGen2.X_axis_ID.ToString("X4") + " " + shGen2.Y_axis_ID.ToString("X4");

                                                    retval = AddToSymbolCollection(newSymbols, shGen2, newCodeBlocks);
                                                    if (retval)
                                                    {
                                                        mapFound = true;
                                                        //GUIDO len2Skip += (xaxislen * 2) + (yaxislen * 2) + shGen2.Length;
                                                        t += (xaxislen * 2) + (yaxislen * 2) + shGen2.Length;
                                                    }
                                                    lastFlashAddress = address + mapsize * 2;
                                                    //Console.WriteLine("Set last address 2 to " + lastFlashAddress.ToString("X8"));
                                                }
                                                lastFlashAddress += ms.NumRepeats * 4 + 4;
                                            }
                                            //if(ms.NumRepeats

                                        }
                                    }
                                }
                            }
                            newSymbol.Varname = "3D " + newSymbol.Flash_start_address.ToString("X8") + " " + xaxisid.ToString("X4") + " " + yaxisid.ToString("X4");
                            //GUIDO len2Skip = (xaxislen * 2) + (yaxislen * 2) + newSymbol.Length;
                            retval = AddToSymbolCollection(newSymbols, newSymbol, newCodeBlocks);
                            if (retval)
                            {
                                mapFound = true;
                                //GUIDO len2Skip += (xaxislen * 2) + (yaxislen * 2) + newSymbol.Length;
                                t += (xaxislen * 2) + (yaxislen * 2) + newSymbol.Length;
                            }
                        }
                        else
                        {

                            if (yaxisid > 0xC000 && yaxisid < 0xF000 && yaxislen <= 32) Console.WriteLine("Unknown map id: " + yaxisid.ToString("X4") + " len " + yaxislen.ToString("X4") + " at address " + t.ToString("X8"));
                            SymbolHelper newSymbol = new SymbolHelper();
                            newSymbol.X_axis_length = xaxislen;
                            newSymbol.X_axis_ID = xaxisid;
                            newSymbol.X_axis_address = t + 4;
                            newSymbol.Length = xaxislen * 2;
                            newSymbol.Flash_start_address = t + 4 + (xaxislen * 2);
                            newSymbol.Varname = "2D " + newSymbol.Flash_start_address.ToString("X8") + " " + xaxisid.ToString("X4");
                            newSymbol.CodeBlock = DetermineCodeBlockByByAddress(newSymbol.Flash_start_address, newCodeBlocks);
                            retval = AddToSymbolCollection(newSymbols, newSymbol, newCodeBlocks);
                            if (retval)
                            {
                                mapFound = true;
                                //GUIDO len2Skip += (xaxislen * 2);
                                t += (xaxislen * 2);
                            }
                            // 2d map
                        }
                    }

                }
            }
            return mapFound;
        }
Esempio n. 37
0
        private void VerifyCodeBlocks(byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
        {
            //000001=automatic,000002=manual,000003=4wd ????
            Tools.Instance.m_codeBlock5ID = 0;
            Tools.Instance.m_codeBlock6ID = 0;
            Tools.Instance.m_codeBlock7ID = 0;
            bool found = true;
            int offset = 0;
            int defaultCodeBlockLength = 0x10000;
            int currentCodeBlockLength = 0;
            int prevCodeBlockStart = 0;
            while (found)
            {
                int CodeBlockAddress = Tools.Instance.findSequence(allBytes, offset, new byte[11] { 0xC1, 0x02, 0x00, 0x68, 0x00, 0x25, 0x03, 0x00, 0x00, 0x10, 0x27 }, new byte[11] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
                if (CodeBlockAddress > 0)
                {
                    CodeBlock newcodeblock = new CodeBlock();
                    newcodeblock.StartAddress = CodeBlockAddress - 1;
                    if (prevCodeBlockStart == 0) prevCodeBlockStart = newcodeblock.StartAddress;
                    else if (currentCodeBlockLength == 0)
                    {
                        currentCodeBlockLength = newcodeblock.StartAddress - prevCodeBlockStart;
                        if (currentCodeBlockLength > 0x10000) currentCodeBlockLength = 0x10000;
                    }
                    // find the next occurence of the checksum
                    newCodeBlocks.Add(newcodeblock);
                    offset = CodeBlockAddress + 1;
                }
                else found = false;
            }
            foreach (CodeBlock cb in newCodeBlocks)
            {
                if (currentCodeBlockLength != 0) cb.EndAddress = cb.StartAddress + currentCodeBlockLength - 1;
                else cb.EndAddress = cb.StartAddress + defaultCodeBlockLength - 1;
            }
            foreach (CodeBlock cb in newCodeBlocks)
            {
                int autoSequenceIndex = Tools.Instance.findSequence(allBytes, cb.StartAddress, new byte[7] { 0x45, 0x44, 0x43, 0x20, 0x20, 0x41, 0x47 }, new byte[7] { 1, 1, 1, 1, 1, 1, 1 });
                int manualSequenceIndex = Tools.Instance.findSequence(allBytes, cb.StartAddress, new byte[7] { 0x45, 0x44, 0x43, 0x20, 0x20, 0x53, 0x47 }, new byte[7] { 1, 1, 1, 1, 1, 1, 1 });
                if (autoSequenceIndex < cb.EndAddress && autoSequenceIndex >= cb.StartAddress) cb.BlockGearboxType = GearboxType.Automatic;
                if (manualSequenceIndex < cb.EndAddress && manualSequenceIndex >= cb.StartAddress) cb.BlockGearboxType = GearboxType.Manual;
            }

            if (Tools.Instance.m_currentfilelength >= 0x80000)
            {
                Tools.Instance.m_codeBlock5ID = CheckCodeBlock(0x50000, allBytes, newSymbols, newCodeBlocks); //manual specific
                Tools.Instance.m_codeBlock6ID = CheckCodeBlock(0x60000, allBytes, newSymbols, newCodeBlocks); //automatic specific
                Tools.Instance.m_codeBlock7ID = CheckCodeBlock(0x70000, allBytes, newSymbols, newCodeBlocks); //quattro specific
            }
        }
Esempio n. 38
0
 private void RemoveNonSymbols(SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
 {
     if (newCodeBlocks.Count > 0)
     {
         foreach (SymbolHelper sh in newSymbols)
         {
             if (sh.CodeBlock == 0 && (sh.Varname.StartsWith("2D") || sh.Varname.StartsWith("3D")))
             {
                 sh.Subcategory = "Zero codeblock stuff";
             }
         }
     }
 }
Esempio n. 39
0
        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;
        }
Esempio n. 40
0
        public override void NameKnownMaps(byte[] allBytes, SymbolCollection newSymbols, List <CodeBlock> newCodeBlocks)
        {
            SymbolAxesTranslator st = new SymbolAxesTranslator();

            foreach (SymbolHelper sh in newSymbols)
            {
                if (Tools.Instance.m_carMake == CarMakes.BMW)
                {
                    //Console.WriteLine("Flash startadress: " + sh.Flash_start_address);
                    // Look in X-axis for RPM
                    int maxX = 0;
                    int minX = 0;
                    int maxY = 0;
                    int minY = 0;
                    if (sh.Is1D)
                    {
                        maxX = (sh.Currentdata[2 + sh.X_axis_length * 2 - 2]) * 256 +
                               (sh.Currentdata[2 + sh.X_axis_length * 2 - 1]);
                        minX = maxX;/*		(sh.Currentdata[2]) * 256 +	(sh.Currentdata[3]); */
                    }
                    else
                    {
                        maxX = (sh.Currentdata[4 + sh.X_axis_length * 2 - 2]) * 256 +
                               (sh.Currentdata[4 + sh.X_axis_length * 2 - 1]);
                        minX = (sh.Currentdata[4]) * 256 + (sh.Currentdata[5]);
                    }

                    //Console.WriteLine("" + sh.Flash_start_address + sh.Y_axis_offset);
                    // Check max value in Y for 9200 -> RPM
                    if (sh.Is1D)
                    {
                        maxY = (sh.Currentdata[2 + sh.X_axis_length * 2 + sh.Y_axis_length * 2 - 2]) * 256 +
                               (sh.Currentdata[2 + sh.X_axis_length * 2 + sh.Y_axis_length * 2 - 1]);
                        minY = (sh.Currentdata[2 + sh.X_axis_length * 2]) * 256 +
                               (sh.Currentdata[2 + sh.X_axis_length * 2 + 1]);
                    }
                    else
                    {
                        maxY = (sh.Currentdata[4 + sh.X_axis_length * 2 + sh.Y_axis_length * 2 - 2]) * 256 +
                               (sh.Currentdata[4 + sh.X_axis_length * 2 + sh.Y_axis_length * 2 - 1]);
                        minY = (sh.Currentdata[4 + sh.X_axis_length * 2]) * 256 +
                               (sh.Currentdata[4 + sh.X_axis_length * 2 + 1]);
                    }
                    //Console.WriteLine("MinX=" + minX + ", maxX=" + maxX);
                    //Console.WriteLine("MinY=" + minY + ", maxY=" + maxY);

                    /*
                     * if((maxX == 10000 && minX == 1400) || // 750->5000rpm
                     * (maxX == 10000 && minX == 1000) || // 500->5000rpm
                     * (maxX == 9200)) {				  // ->4600rpm
                     *  //sh.Category = "Partly detected maps";
                     *  //sh.Subcategory = "RPM";
                     *  sh.Y_axis_correction = 0.5;
                     *  sh.YaxisUnits = "rpm";
                     *  sh.Y_axis_descr = "rpm";
                     * }
                     */
                    // Temp-related X-axis
                    if ((minX >= 1731 && maxX <= 3931) &&
                        ((minX - 31) % 50 == 0 ||
                         (maxX - 31) % 50 == 0
                        ))
                    {
                        sh.X_axis_correction = 0.1;
                        sh.X_axis_offset     = -273.1;
                        //sh.Correction = 0.1;
                        sh.Category     = "Partly detected maps - temp";
                        sh.X_axis_descr = "Temperature";
                        sh.XaxisUnits   = "C";
                    }
                    if ((sh.X_axis_length == 16 || sh.X_axis_length == 17) && sh.Y_axis_length == 40)
                    {
                        //Injection time
                        sh.Category          = "Detected maps";
                        sh.Subcategory       = "Injection timing";
                        sh.Varname           = "Injection time [" + sh.Flash_start_address.ToString("X8") + "]";
                        sh.X_axis_correction = 0.01;
                        sh.XaxisUnits        = "mm3/inj";
                        sh.X_axis_descr      = "mm3/inj";
                        sh.Z_axis_descr      = "time";
                        sh.Correction        = 0.4;
                        sh.Y_axis_correction = 0.1;
                        sh.YaxisUnits        = "bar";
                        sh.Y_axis_descr      = "bar";
                    }
                    if (sh.X_axis_length == 16 && sh.Y_axis_length == 16 && (maxY == 7000 || maxY == 7500) && minY == 0)
                    {
                        // Todo! Check steps in X and/or Y to further isolate maps!
                        // Injection timing
                        sh.Category          = "Detected maps";
                        sh.Subcategory       = "Injection timing";
                        sh.Varname           = "Injection timing map [" + sh.Flash_start_address.ToString("X8") + "]";
                        sh.X_axis_correction = 0.01;
                        sh.XaxisUnits        = "mm3/cyc";
                        sh.X_axis_descr      = "mm3/cyc";
                        sh.Z_axis_descr      = "Injection timing";
                        sh.Correction        = 0.021969;
                    }
                    if ((sh.X_axis_length == 14 && sh.Y_axis_length == 8))
                    { //|| // 14x8
                        //(sh.X_axis_length == 8 && sh.Y_axis_length == 1 ) ) { // 8x1(0) torquelimiter
                        sh.Category          = "Detected maps";
                        sh.Subcategory       = "Torque";
                        sh.Varname           = "Pedal request map [" + sh.Flash_start_address.ToString("X8") + "]";
                        sh.X_axis_correction = 0.01220703125;
                        sh.X_axis_descr      = "Percent";
                        sh.Y_axis_correction = 0.5;
                        sh.Y_axis_descr      = "RPM";
                        sh.Z_axis_descr      = "Torque (Nm)";
                        sh.XaxisUnits        = "%";
                        sh.Correction        = 0.1;
                    }
                    if (sh.X_axis_length == 8 && sh.Y_axis_length == 10 &&
                        (maxY % 2 == 1 || minY % 2 == 1))
                    { // 8x10 and odd data
                        sh.Category          = "Detected maps";
                        sh.Subcategory       = "Torque";
                        sh.Varname           = "Torque limit given temp [" + sh.Flash_start_address.ToString("X8") + "]";
                        sh.Y_axis_correction = 0.5;
                        sh.Y_axis_descr      = "RPM";
                        sh.X_axis_correction = 0.1;
                        sh.X_axis_offset     = -273.1;
                        sh.Correction        = 0.1;
                        sh.X_axis_descr      = "Temperature";
                        sh.Z_axis_descr      = "Torque (Nm)";
                        sh.XaxisUnits        = "C";
                    }
                    if (sh.X_axis_length == 21 && sh.Y_axis_length == 3)
                    { // 21x3, only one exist in BMW-files
                        sh.Category          = "Detected maps";
                        sh.Subcategory       = "Torque";
                        sh.Varname           = "Torque limit for speed [" + sh.Flash_start_address.ToString("X8") + "]";
                        sh.Y_axis_correction = 0.5;
                        sh.Y_axis_descr      = "RPM";
                        sh.X_axis_correction = 1;
                        sh.Correction        = 0.1;
                        sh.X_axis_descr      = "#";
                        sh.Z_axis_descr      = "Torque (Nm)";
                        sh.XaxisUnits        = "#";
                    }

                    /* // These addresses are only valid for one specific boschnumber.... Needs to be more general
                     * if(sh.Flash_start_address == 0x75200 ||
                     *  sh.Flash_start_address == 0x75444 ||
                     *  sh.Flash_start_address == 0x75688) {
                     *  sh.Varname = "Fuel quantity injected [" + sh.Flash_start_address.ToString("X8") + "]";
                     *  sh.Category = "Detected maps";
                     *  sh.Subcategory = "Injected Fuel";
                     *  sh.Y_axis_correction = 0.5;
                     *  sh.YaxisUnits = "RPM";
                     *  sh.Y_axis_descr = "rpm";
                     *  sh.X_axis_correction = 0.1;
                     *  sh.XaxisUnits = "Nm";
                     *  sh.X_axis_descr = "Nm";
                     *  sh.Z_axis_descr = "Fuel injected quantity f(RPM,Trq)";
                     *  sh.Correction = 0.01;
                     * }
                     *
                     * if(sh.Flash_start_address == 0x52036) {
                     *  sh.Varname = "Gas quantity recirculation [" + sh.Flash_start_address.ToString("X8") + "]";
                     *  sh.Category = "Detected maps";
                     *  sh.Subcategory = "Air control";
                     *
                     *  sh.Y_axis_correction = 0.5;
                     *  sh.YaxisUnits = "RPM";
                     *  sh.Y_axis_descr = "rpm";
                     *
                     *  sh.X_axis_correction = 0.01;
                     *  sh.XaxisUnits = "mm3/hub";
                     *  sh.X_axis_descr = "mm3";
                     *  sh.Z_axis_descr = "Gas quantity";
                     *
                     *  sh.Correction = 0.1;
                     * }
                     * if(sh.Flash_start_address == 0x6EFE4) {
                     *  sh.Varname = "Limiter of turbo f(APS)[" + sh.Flash_start_address.ToString("X8") + "]";
                     *  sh.Category = "Detected maps";
                     *  sh.Subcategory = "Turbo";
                     *
                     *  sh.Y_axis_correction = 0.5;
                     *  sh.YaxisUnits = "RPM";
                     *  sh.Y_axis_descr = "rpm";
                     *
                     *  sh.X_axis_correction = 1;
                     *  sh.XaxisUnits = "hPa";
                     *  sh.X_axis_descr = "hPa";
                     *  sh.Z_axis_descr = "Pressure";
                     *
                     *  sh.Correction = 1;
                     * }
                     */
                }
            }
        }
Esempio n. 41
0
 private void BuildAxisIDList(SymbolCollection newSymbols, List<AxisHelper> newAxisHelpers)
 {
     foreach (SymbolHelper sh in newSymbols)
     {
         if (!sh.Varname.StartsWith("2D") && !sh.Varname.StartsWith("3D"))
         {
             AddToAxisCollection(newAxisHelpers, sh.Y_axis_ID, sh.X_axis_descr, sh.XaxisUnits, sh.X_axis_correction, sh.X_axis_offset);
             AddToAxisCollection(newAxisHelpers, sh.X_axis_ID, sh.Y_axis_descr, sh.YaxisUnits, sh.Y_axis_correction, sh.Y_axis_offset);
         }
     }
 }
Esempio n. 42
0
        private bool TuneTorqueLimiter(string filename, SymbolCollection symbols, int peakTorque, int peakHP, bool autoUpdateChecksum)
        {
            bool retval = true;
            //Increase driverwish to peakIQ if it is not already (only the rightmost 2 columns)
            int tlAddress = (int)Tools.Instance.GetSymbolAddressLike(Tools.Instance.m_symbols, "Torque limiter");

            if (tlAddress > 0)
            {
                foreach (SymbolHelper sh in Tools.Instance.m_symbols)
                {
                    if (sh.Flash_start_address == tlAddress)
                    {
                        byte[] tldata = Tools.Instance.readdatafromfile(filename, tlAddress, sh.Length, EDCFileType.EDC15P);
                       // Console.WriteLine(sh.Varname + " " + sh.Y_axis_length.ToString() + " " + sh.X_axis_length.ToString());
                        int[] rpms = Tools.Instance.readdatafromfileasint(filename, sh.Y_axis_address, sh.Y_axis_length, EDCFileType.EDC15P);
                        for (int rows = 0; rows < sh.X_axis_length; rows++)
                        {
                            for (int cols = 0; cols < sh.Y_axis_length; cols++)
                            {
                                // whats the rpm?
                                int rpm = rpms[cols];
                                int targetTorque = peakTorque;
                                int targetPower = Tools.Instance.TorqueToPower(targetTorque, rpm);
                                if (targetPower > peakHP) targetTorque = Tools.Instance.PowerToTorque(peakHP, rpm);
                                int targetIQ = Tools.Instance.TorqueToIQ(targetTorque, rpm, 4);
                                int maxIQ = targetIQ;
                                if (rpm < 550) maxIQ = 0;
                                if (rpm > 5000) maxIQ = 0;
                                if (cols == 0) maxIQ = 0;
                                if (cols == sh.Y_axis_length - 1) maxIQ = 0;
                                if (rpm >= 550 && rpm < 1000) maxIQ = 30;
                                if (rpm >= 1000 && rpm < 1250) maxIQ = 45;
                                if (rpm >= 1250 && rpm < 1500) maxIQ = 55;
                                if (rpm >= 1500 && rpm < 1750) maxIQ = 60;
                                if (rpm >= 1750 && rpm < 1900) maxIQ = 65;
                                if (targetIQ > maxIQ) targetIQ = maxIQ;

                                //Console.WriteLine("Calculate for rpm: " + rpm.ToString() + " targetT: " + targetTorque.ToString() + " targetP: " + targetPower.ToString() + " targetIQ: " + targetIQ.ToString());
                                targetIQ *= 100;
                                byte b1 = (byte)((targetIQ & 0x00FF00) / 256);
                                byte b2 = (byte)(targetIQ & 0x0000FF);

                                tldata[rows * sh.Y_axis_length * 2 + cols * 2] = b1;
                                tldata[rows * sh.Y_axis_length * 2 + (cols * 2) + 1] = b2;
                            }
                        }
                        SaveAndSyncData(tldata.Length, (int)sh.Flash_start_address, tldata, filename, true, "Tuned torque limiter", autoUpdateChecksum);

                    }
                }

            }
            else retval = false;
            return retval;
        }
Esempio n. 43
0
        // we need to check AHEAD for selector maps
        // if these are present we may be facing a complex map structure
        // which we need to handle in a special way (selectors always have data like 00 01 00 02 00 03 00 04 etc)
        private bool CheckMap(int t, byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks, out int len2Skip)
        {
            len2Skip = 0;
            bool retval = false;
            bool mapFound = false;
            bool _dontGenMaps = false;
            List<MapSelector> mapSelectors = new List<MapSelector>();
            if (t < allBytes.Length - 0x100)
            {

                if (CheckAxisCount(t, allBytes, out mapSelectors) > 3)
                {
                    // check for selectors as well, and count them in the process
                    Console.WriteLine("Offset " + t.ToString("X8") + " has more than 3 consecutive axis");
                    /*foreach (MapSelector ms in mapSelectors)
                    {
                        Console.WriteLine("selector: " + ms.StartAddress.ToString("X8") + " " + ms.MapLength.ToString() + " " + ms.NumRepeats.ToString());
                    }*/
                    _dontGenMaps = true;

                }

                int xaxisid = (Convert.ToInt32(allBytes[t + 1]) * 256) + Convert.ToInt32(allBytes[t]);

                if (isAxisID(xaxisid))
                {
                    int xaxislen = (Convert.ToInt32(allBytes[t + 3]) * 256) + Convert.ToInt32(allBytes[t + 2]);
                    // Console.WriteLine("Valid XID: " + xaxisid.ToString("X4") + " @" + t.ToString("X8") + " len: " + xaxislen.ToString("X2"));
                    if (isValidLength(xaxislen, xaxisid))
                    {
                        //Console.WriteLine("Valid XID: " + xaxisid.ToString("X4") + " @" + t.ToString("X8") + " len: " + xaxislen.ToString("X2"));
                        // misschien is er nog een as
                        int yaxisid = (Convert.ToInt32(allBytes[t + 5 + (xaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 4 + (xaxislen * 2)]);
                        int yaxislen = (Convert.ToInt32(allBytes[t + 7 + (xaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 6 + (xaxislen * 2)]);
                        if (isAxisID(yaxisid) && isValidLength(yaxislen, yaxisid))
                        {
                            // 3d map

                            int zaxisid = (Convert.ToInt32(allBytes[t + 9 + (xaxislen * 2) + (yaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 8 + (xaxislen * 2) + (yaxislen * 2)]);
                            //Console.WriteLine("Valid YID: " + yaxisid.ToString("X4") + " @" + t.ToString("X8") + " len: " + yaxislen.ToString("X2"));

                            //Console.WriteLine(t.ToString("X8") + " XID: " + xaxisid.ToString("X4") + " XLEN: " + xaxislen.ToString("X2") + " YID: " + yaxisid.ToString("X4") + " YLEN: " + yaxislen.ToString("X2"));
                            SymbolHelper newSymbol = new SymbolHelper();
                            newSymbol.X_axis_length = xaxislen;
                            newSymbol.Y_axis_length = yaxislen;
                            newSymbol.X_axis_ID = xaxisid;
                            newSymbol.Y_axis_ID = yaxisid;
                            newSymbol.X_axis_address = t + 4;
                            newSymbol.Y_axis_address = t + 8 + (xaxislen * 2);

                            newSymbol.Length = xaxislen * yaxislen * 2;
                            newSymbol.Flash_start_address = t + 8 + (xaxislen * 2) + (yaxislen * 2);
                            if (isAxisID(zaxisid))
                            {
                                int zaxislen = (Convert.ToInt32(allBytes[t + 11 + (xaxislen * 2) + (yaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 10 + (xaxislen * 2) + (yaxislen * 2)]);

                                int zaxisaddress = t + 12 + (xaxislen * 2) + (yaxislen * 2);

                                if (isValidLength(zaxislen, zaxisid))
                                {
                                    //   newSymbol.Flash_start_address += 0x10; // dan altijd 16 erbij
                                    int len2skip = (4 + zaxislen * 2);
                                    if (len2skip < 16) len2skip = 16; // at least 16 bytes
                                    newSymbol.Flash_start_address += len2skip;
                                    if (!_dontGenMaps)
                                    {
                                        // this has something to do with repeating several times with the same axis set

                                        Console.WriteLine("Added " + len2skip.ToString() + " because of z axis " + newSymbol.Flash_start_address.ToString("X8"));
                                    }
                                    else
                                    {

                                        int maxisid = (Convert.ToInt32(allBytes[t + 13 + (xaxislen * 2) + (yaxislen * 2) + (zaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 12 + (xaxislen * 2) + (yaxislen * 2) + zaxislen * 2]);
                                        int maxislen = (Convert.ToInt32(allBytes[t + 15 + (xaxislen * 2) + (yaxislen * 2) + (zaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 14 + (xaxislen * 2) + (yaxislen * 2) + zaxislen * 2]);
                                        //maxislen *= 2;

                                        int maxisaddress = t + 16 + (xaxislen * 2) + (yaxislen * 2);

                                        if (isAxisID(maxisid))
                                        {
                                            newSymbol.Flash_start_address += (maxislen * 2) + 4;
                                        }
                                        // special situation, handle selectors
                                        Console.WriteLine("Map start address = " + newSymbol.Flash_start_address.ToString("X8"));
                                        long lastFlashAddress = newSymbol.Flash_start_address;
                                        foreach (MapSelector ms in mapSelectors)
                                        {

                                            if (ms.NumRepeats > 0)
                                            {
                                                // check the memory size between the start of the map and the
                                                // start of the map selector
                                                long memsize = ms.StartAddress - lastFlashAddress;
                                                memsize /= 2; // in words

                                                int mapsize = Convert.ToInt32(memsize) / ms.NumRepeats;
                                                //Console.WriteLine("selector: " + ms.StartAddress.ToString("X8") + " " + ms.MapLength.ToString() + " " + ms.NumRepeats.ToString());
                                                //Console.WriteLine("memsize = " + memsize.ToString() + " mapsize " + mapsize.ToString());
                                                //Console.WriteLine("starting at address: " + lastFlashAddress.ToString("X8"));
                                                if ((xaxislen * yaxislen) == mapsize)
                                                {
                                                    // first axis set
                                                    for (int i = 0; i < ms.NumRepeats; i++)
                                                    {
                                                        SymbolHelper shGen2 = new SymbolHelper();
                                                        shGen2.MapSelector = ms;
                                                        shGen2.X_axis_length = newSymbol.X_axis_length;
                                                        shGen2.Y_axis_length = newSymbol.Y_axis_length;
                                                        shGen2.X_axis_ID = newSymbol.X_axis_ID;
                                                        shGen2.Y_axis_ID = newSymbol.Y_axis_ID;
                                                        shGen2.X_axis_address = newSymbol.X_axis_address;
                                                        shGen2.Y_axis_address = newSymbol.Y_axis_address;
                                                        shGen2.Length = mapsize * 2;
                                                        //shGen2.Category = "Generated";
                                                        long address = lastFlashAddress;
                                                        shGen2.Flash_start_address = address;
                                                        //shGen2.Correction = 0.023437; // TEST
                                                        //shGen2.Varname = "Generated* " + shGen2.Flash_start_address.ToString("X8") + " " + ms.StartAddress.ToString("X8") + " " + ms.NumRepeats.ToString() + " " + i.ToString();
                                                        shGen2.Varname = "3D " + shGen2.Flash_start_address.ToString("X8") + " " + shGen2.X_axis_ID.ToString("X4") + " " + shGen2.Y_axis_ID.ToString("X4");
                                                        retval = AddToSymbolCollection(newSymbols, shGen2, newCodeBlocks);
                                                        if (retval)
                                                        {
                                                            mapFound = true;
                                                            len2Skip += (xaxislen * 2) + (yaxislen * 2) + shGen2.Length;
                                                            t += (xaxislen * 2) + (yaxislen * 2) + shGen2.Length;
                                                        }
                                                        lastFlashAddress = address + mapsize * 2;
                                                        // Console.WriteLine("Set last address to " + lastFlashAddress.ToString("X8"));
                                                    }
                                                    lastFlashAddress += ms.NumRepeats * 4 + 4;
                                                }
                                                else if ((zaxislen * maxislen) == mapsize)
                                                {
                                                    // second axis set
                                                    for (int i = 0; i < ms.NumRepeats; i++)
                                                    {
                                                        SymbolHelper shGen2 = new SymbolHelper();
                                                        shGen2.MapSelector = ms;
                                                        shGen2.X_axis_length = maxislen;
                                                        shGen2.Y_axis_length = zaxislen;
                                                        shGen2.X_axis_ID = maxisid;
                                                        shGen2.Y_axis_ID = zaxisid;
                                                        shGen2.X_axis_address = maxisaddress;
                                                        shGen2.Y_axis_address = zaxisaddress;
                                                        shGen2.Length = mapsize * 2;
                                                        //shGen2.Category = "Generated";
                                                        long address = lastFlashAddress;
                                                        shGen2.Flash_start_address = address;
                                                        //shGen2.Varname = "Generated** " + shGen2.Flash_start_address.ToString("X8");
                                                        shGen2.Varname = "3D " + shGen2.Flash_start_address.ToString("X8") + " " + shGen2.X_axis_ID.ToString("X4") + " " + shGen2.Y_axis_ID.ToString("X4");
                                                        retval = AddToSymbolCollection(newSymbols, shGen2, newCodeBlocks);
                                                        if (retval)
                                                        {
                                                            mapFound = true;
                                                            len2Skip += (xaxislen * 2) + (yaxislen * 2) + shGen2.Length;
                                                            t += (xaxislen * 2) + (yaxislen * 2) + shGen2.Length;
                                                        }
                                                        lastFlashAddress = address + mapsize * 2;
                                                        //Console.WriteLine("Set last address 2 to " + lastFlashAddress.ToString("X8"));
                                                    }
                                                    lastFlashAddress += ms.NumRepeats * 4 + 4;
                                                }
                                            }
                                            //if(ms.NumRepeats

                                        }
                                    }
                                }
                            }
                            newSymbol.Varname = "3D " + newSymbol.Flash_start_address.ToString("X8") + " " + xaxisid.ToString("X4") + " " + yaxisid.ToString("X4");
                            retval = AddToSymbolCollection(newSymbols, newSymbol, newCodeBlocks);
                            if (retval)
                            {
                                mapFound = true;
                                len2Skip += (xaxislen * 2) + (yaxislen * 2) + newSymbol.Length;
                                t += (xaxislen * 2) + (yaxislen * 2) + newSymbol.Length;
                            }

                        }
                        else
                        {

                            if (yaxisid > 0xC000 && yaxisid < 0xF000 && yaxislen <= 32) Console.WriteLine("Unknown map id: " + yaxisid.ToString("X4") + " len " + yaxislen.ToString("X4") + " at address " + t.ToString("X8"));
                            SymbolHelper newSymbol = new SymbolHelper();
                            newSymbol.X_axis_length = xaxislen;
                            newSymbol.X_axis_ID = xaxisid;
                            newSymbol.X_axis_address = t + 4;
                            newSymbol.Length = xaxislen * 2;
                            newSymbol.Flash_start_address = t + 4 + (xaxislen * 2);
                            newSymbol.Varname = "2D " + newSymbol.Flash_start_address.ToString("X8") + " " + xaxisid.ToString("X4");
                            //newSymbols.Add(newSymbol);
                            newSymbol.CodeBlock = DetermineCodeBlockByByAddress(newSymbol.Flash_start_address, newCodeBlocks);
                            retval = AddToSymbolCollection(newSymbols, newSymbol, newCodeBlocks);
                            if (retval)
                            {
                                mapFound = true;
                                len2Skip += (xaxislen * 2);
                                t += (xaxislen * 2);
                            }
                            // 2d map
                        }
                    }

                }
            }
            return mapFound;
        }
Esempio n. 44
0
 public frmSymbolSelect(SymbolCollection symbols)
 {
     m_symbols = symbols;
     InitializeComponent();
 }
Esempio n. 45
0
        // EDC17 Little<->Bigendian compared to EDC16
        private int CheckMap(int t, byte[] allBytes, SymbolCollection newSymbols, List <CodeBlock> newCodeBlocks)
        {
            int retval = 0;
            // read LL LL
            int len1 = Convert.ToInt32(allBytes[t]) * 256 + Convert.ToInt32(allBytes[t + 1]);
            int len2 = Convert.ToInt32(allBytes[t + 2]) * 256 + Convert.ToInt32(allBytes[t + 3]);

            if (len1 == 1 && len2 == 1)
            {
                return(retval);
            }
            // BMW uses up to 40(0x28) for one axis.
            if ((len1 <= 64 && len2 <= 64) && (len1 > 0 && len2 >= 0))
            {
                //Console.WriteLine("---New map-- t=" + t.ToString("X"));
                bool ok     = true;
                int  startX = t + 2;                // For 0D-arrays
                if (len2 > 0)
                {
                    startX += 2;                     // For 2D and 3D-arrays
                }
                for (int dX = startX; dX <= startX + len1 * 2 - 4; dX += 2)
                {
                    int b1 = Convert.ToInt32(allBytes[dX]) * 256 + Convert.ToInt32(allBytes[dX + 1]);
                    int b2 = Convert.ToInt32(allBytes[dX + 2]) * 256 + Convert.ToInt32(allBytes[dX + 3]);
                    if (b1 >= b2)
                    {
                        ok = false;
                        break;
                    }
                }
                //Console.WriteLine("-----");
                if (len2 > 0)
                {
                    for (int dY = startX + len1 * 2; dY <= startX + len1 * 2 + len2 * 2 - 4; dY += 2)
                    {
                        int b1 = Convert.ToInt32(allBytes[dY]) * 256 + Convert.ToInt32(allBytes[dY + 1]);
                        int b2 = Convert.ToInt32(allBytes[dY + 2]) * 256 + Convert.ToInt32(allBytes[dY + 3]);
                        if (b1 >= b2)
                        {
                            ok = false;
                            break;
                        }
                    }
                }

                if (ok)
                {
                    //Console.WriteLine("--------------");
                    //for(int i=t; i<t+len1*len2*2;i++)
                    //	Console.Write(allBytes[t].ToString("X2"));
                    //Console.WriteLine("----end----");

                    SymbolHelper sh = new SymbolHelper();
                    sh.X_axis_length = len1;
                    if (len2 == 0)
                    {
                        sh.X_axis_address      = t + 2;
                        sh.Y_axis_address      = t + 2;
                        sh.Y_axis_length       = 1;
                        sh.Flash_start_address = t + 2 + len1 * 2;
                        sh.Varname             = "1D " + sh.Flash_start_address.ToString("X8");
                        sh.Is1D = true;
                    }
                    else
                    {
                        sh.X_axis_address      = t + 4;
                        sh.Y_axis_length       = len2;
                        sh.Y_axis_address      = sh.X_axis_address + sh.X_axis_length * 2;
                        sh.Flash_start_address = sh.Y_axis_address + sh.Y_axis_length * 2;
                        if (sh.X_axis_length > 1 && sh.Y_axis_length > 1)
                        {
                            sh.Varname = "3D " + sh.Flash_start_address.ToString("X8");
                            sh.Is3D    = true;
                        }
                        else
                        {
                            sh.Varname = "2D " + sh.Flash_start_address.ToString("X8");
                            sh.Is2D    = true;
                        }
                    }
                    sh.Length = sh.X_axis_length * sh.Y_axis_length * 2;
                    //sh.Varname = sh.Flash_start_address.ToString("X8");
                    int length = (len1 + len2) * 2 + sh.Length + 4;
                    sh.Currentdata = new byte[length];
                    Array.Copy(allBytes, t, sh.Currentdata, 0, length);

                    AddToSymbolCollection(newSymbols, sh, newCodeBlocks);
                    retval = (len1 + len2) * 2 + sh.Length;
                }
            }
            return(retval);
        }
Esempio n. 46
0
        private void MatchAxis(SymbolCollection newSymbols, List<AxisHelper> newAxisHelpers)
        {
            foreach (SymbolHelper sh in newSymbols)
            {
                if (!sh.YaxisAssigned)
                {
                    foreach (AxisHelper ah in newAxisHelpers)
                    {
                        if (sh.X_axis_ID == ah.AxisID)
                        {
                            sh.Y_axis_descr = ah.Description;
                            sh.YaxisUnits = ah.Units;
                            sh.Y_axis_offset = ah.Offset;
                            sh.Y_axis_correction = ah.Correction;
                            break;
                        }
                    }
                }
                if (!sh.XaxisAssigned)
                {
                    foreach (AxisHelper ah in newAxisHelpers)
                    {
                        if (sh.Y_axis_ID == ah.AxisID)
                        {
                            sh.X_axis_descr = ah.Description;
                            sh.XaxisUnits = ah.Units;
                            sh.X_axis_offset = ah.Offset;
                            sh.X_axis_correction = ah.Correction;
                            break;
                        }
                    }
                }

            }
        }
Esempio n. 47
0
        // we need to check AHEAD for selector maps
        // if these are present we may be facing a complex map structure
        // which we need to handle in a special way (selectors always have data like 00 01 00 02 00 03 00 04 etc)
        private bool CheckMap(int t, byte[] allBytes, SymbolCollection newSymbols, List <CodeBlock> newCodeBlocks, out int len2Skip)
        {
            len2Skip = 0;
            bool retval       = false;
            bool mapFound     = false;
            bool _dontGenMaps = false;
            List <MapSelector> mapSelectors = new List <MapSelector>();

            if (t < allBytes.Length - 0x100)
            {
                if (CheckAxisCount(t, allBytes, out mapSelectors) > 3)
                {
                    // check for selectors as well, and count them in the process
                    Console.WriteLine("Offset " + t.ToString("X8") + " has more than 3 consecutive axis");

                    /*foreach (MapSelector ms in mapSelectors)
                     * {
                     *  Console.WriteLine("selector: " + ms.StartAddress.ToString("X8") + " " + ms.MapLength.ToString() + " " + ms.NumRepeats.ToString());
                     * }*/
                    _dontGenMaps = true;
                }

                int xaxisid = (Convert.ToInt32(allBytes[t + 1]) * 256) + Convert.ToInt32(allBytes[t]);

                if (isAxisID(xaxisid))
                {
                    int xaxislen = (Convert.ToInt32(allBytes[t + 3]) * 256) + Convert.ToInt32(allBytes[t + 2]);
                    // Console.WriteLine("Valid XID: " + xaxisid.ToString("X4") + " @" + t.ToString("X8") + " len: " + xaxislen.ToString("X2"));
                    if (isValidLength(xaxislen, xaxisid))
                    {
                        //Console.WriteLine("Valid XID: " + xaxisid.ToString("X4") + " @" + t.ToString("X8") + " len: " + xaxislen.ToString("X2"));
                        // misschien is er nog een as
                        int yaxisid  = (Convert.ToInt32(allBytes[t + 5 + (xaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 4 + (xaxislen * 2)]);
                        int yaxislen = (Convert.ToInt32(allBytes[t + 7 + (xaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 6 + (xaxislen * 2)]);
                        if (isAxisID(yaxisid) && isValidLength(yaxislen, yaxisid))
                        {
                            // 3d map

                            int zaxisid = (Convert.ToInt32(allBytes[t + 9 + (xaxislen * 2) + (yaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 8 + (xaxislen * 2) + (yaxislen * 2)]);
                            //Console.WriteLine("Valid YID: " + yaxisid.ToString("X4") + " @" + t.ToString("X8") + " len: " + yaxislen.ToString("X2"));


                            //Console.WriteLine(t.ToString("X8") + " XID: " + xaxisid.ToString("X4") + " XLEN: " + xaxislen.ToString("X2") + " YID: " + yaxisid.ToString("X4") + " YLEN: " + yaxislen.ToString("X2"));
                            SymbolHelper newSymbol = new SymbolHelper();
                            newSymbol.X_axis_length  = xaxislen;
                            newSymbol.Y_axis_length  = yaxislen;
                            newSymbol.X_axis_ID      = xaxisid;
                            newSymbol.Y_axis_ID      = yaxisid;
                            newSymbol.X_axis_address = t + 4;
                            newSymbol.Y_axis_address = t + 8 + (xaxislen * 2);

                            newSymbol.Length = xaxislen * yaxislen * 2;
                            newSymbol.Flash_start_address = t + 8 + (xaxislen * 2) + (yaxislen * 2);
                            if (isAxisID(zaxisid))
                            {
                                int zaxislen = (Convert.ToInt32(allBytes[t + 11 + (xaxislen * 2) + (yaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 10 + (xaxislen * 2) + (yaxislen * 2)]);

                                int zaxisaddress = t + 12 + (xaxislen * 2) + (yaxislen * 2);

                                if (isValidLength(zaxislen, zaxisid))
                                {
                                    //   newSymbol.Flash_start_address += 0x10; // dan altijd 16 erbij
                                    int len2skip = (4 + zaxislen * 2);
                                    if (len2skip < 16)
                                    {
                                        len2skip = 16;                // at least 16 bytes
                                    }
                                    newSymbol.Flash_start_address += len2skip;
                                    if (!_dontGenMaps)
                                    {
                                        // this has something to do with repeating several times with the same axis set
                                        Console.WriteLine("Added " + len2skip.ToString() + " because of z axis " + newSymbol.Flash_start_address.ToString("X8"));
                                    }
                                    else
                                    {
                                        int maxisid  = (Convert.ToInt32(allBytes[t + 13 + (xaxislen * 2) + (yaxislen * 2) + (zaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 12 + (xaxislen * 2) + (yaxislen * 2) + zaxislen * 2]);
                                        int maxislen = (Convert.ToInt32(allBytes[t + 15 + (xaxislen * 2) + (yaxislen * 2) + (zaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 14 + (xaxislen * 2) + (yaxislen * 2) + zaxislen * 2]);
                                        //maxislen *= 2;

                                        int maxisaddress = t + 16 + (xaxislen * 2) + (yaxislen * 2);

                                        if (isAxisID(maxisid))
                                        {
                                            newSymbol.Flash_start_address += (maxislen * 2) + 4;
                                        }
                                        // special situation, handle selectors
                                        Console.WriteLine("Map start address = " + newSymbol.Flash_start_address.ToString("X8"));
                                        long lastFlashAddress = newSymbol.Flash_start_address;
                                        foreach (MapSelector ms in mapSelectors)
                                        {
                                            // check the memory size between the start of the map and the
                                            // start of the map selector
                                            long memsize = ms.StartAddress - lastFlashAddress;
                                            memsize /= 2; // in words
                                            if (ms.NumRepeats > 0)
                                            {
                                                int mapsize = Convert.ToInt32(memsize) / ms.NumRepeats;
                                                //Console.WriteLine("selector: " + ms.StartAddress.ToString("X8") + " " + ms.MapLength.ToString() + " " + ms.NumRepeats.ToString());
                                                //Console.WriteLine("memsize = " + memsize.ToString() + " mapsize " + mapsize.ToString());
                                                //Console.WriteLine("starting at address: " + lastFlashAddress.ToString("X8"));
                                                if ((xaxislen * yaxislen) == mapsize)
                                                {
                                                    // first axis set
                                                    for (int i = 0; i < ms.NumRepeats; i++)
                                                    {
                                                        SymbolHelper shGen2 = new SymbolHelper();
                                                        shGen2.MapSelector    = ms;
                                                        shGen2.X_axis_length  = newSymbol.X_axis_length;
                                                        shGen2.Y_axis_length  = newSymbol.Y_axis_length;
                                                        shGen2.X_axis_ID      = newSymbol.X_axis_ID;
                                                        shGen2.Y_axis_ID      = newSymbol.Y_axis_ID;
                                                        shGen2.X_axis_address = newSymbol.X_axis_address;
                                                        shGen2.Y_axis_address = newSymbol.Y_axis_address;
                                                        shGen2.Length         = mapsize * 2;
                                                        //shGen2.Category = "Generated";
                                                        long address = lastFlashAddress;
                                                        shGen2.Flash_start_address = address;
                                                        //shGen2.Correction = 0.023437; // TEST
                                                        //shGen2.Varname = "Generated* " + shGen2.Flash_start_address.ToString("X8") + " " + ms.StartAddress.ToString("X8") + " " + ms.NumRepeats.ToString() + " " + i.ToString();
                                                        shGen2.Varname = "3D " + shGen2.Flash_start_address.ToString("X8") + " " + shGen2.X_axis_ID.ToString("X4") + " " + shGen2.Y_axis_ID.ToString("X4");
                                                        retval         = AddToSymbolCollection(newSymbols, shGen2, newCodeBlocks);
                                                        if (retval)
                                                        {
                                                            mapFound  = true;
                                                            len2Skip += (xaxislen * 2) + (yaxislen * 2) + shGen2.Length;
                                                            t        += (xaxislen * 2) + (yaxislen * 2) + shGen2.Length;
                                                        }
                                                        lastFlashAddress = address + mapsize * 2;
                                                        // Console.WriteLine("Set last address to " + lastFlashAddress.ToString("X8"));
                                                    }
                                                    lastFlashAddress += ms.NumRepeats * 4 + 4;
                                                }
                                                else if ((zaxislen * maxislen) == mapsize)
                                                {
                                                    // second axis set
                                                    for (int i = 0; i < ms.NumRepeats; i++)
                                                    {
                                                        SymbolHelper shGen2 = new SymbolHelper();
                                                        shGen2.MapSelector    = ms;
                                                        shGen2.X_axis_length  = maxislen;
                                                        shGen2.Y_axis_length  = zaxislen;
                                                        shGen2.X_axis_ID      = maxisid;
                                                        shGen2.Y_axis_ID      = zaxisid;
                                                        shGen2.X_axis_address = maxisaddress;
                                                        shGen2.Y_axis_address = zaxisaddress;
                                                        shGen2.Length         = mapsize * 2;
                                                        //shGen2.Category = "Generated";
                                                        long address = lastFlashAddress;
                                                        shGen2.Flash_start_address = address;
                                                        //shGen2.Varname = "Generated** " + shGen2.Flash_start_address.ToString("X8");
                                                        shGen2.Varname = "3D " + shGen2.Flash_start_address.ToString("X8") + " " + shGen2.X_axis_ID.ToString("X4") + " " + shGen2.Y_axis_ID.ToString("X4");

                                                        retval = AddToSymbolCollection(newSymbols, shGen2, newCodeBlocks);
                                                        if (retval)
                                                        {
                                                            mapFound  = true;
                                                            len2Skip += (xaxislen * 2) + (yaxislen * 2) + shGen2.Length;
                                                            t        += (xaxislen * 2) + (yaxislen * 2) + shGen2.Length;
                                                        }
                                                        lastFlashAddress = address + mapsize * 2;
                                                        //Console.WriteLine("Set last address 2 to " + lastFlashAddress.ToString("X8"));
                                                    }
                                                    lastFlashAddress += ms.NumRepeats * 4 + 4;
                                                }
                                            }
                                            //if(ms.NumRepeats
                                        }
                                    }
                                }
                            }
                            newSymbol.Varname = "3D " + newSymbol.Flash_start_address.ToString("X8") + " " + xaxisid.ToString("X4") + " " + yaxisid.ToString("X4");
                            retval            = AddToSymbolCollection(newSymbols, newSymbol, newCodeBlocks);
                            if (retval)
                            {
                                mapFound  = true;
                                len2Skip += (xaxislen * 2) + (yaxislen * 2) + newSymbol.Length;
                                t        += (xaxislen * 2) + (yaxislen * 2) + newSymbol.Length;
                            }
                        }
                        else
                        {
                            if (yaxisid > 0xC000 && yaxisid < 0xF000 && yaxislen <= 32)
                            {
                                Console.WriteLine("Unknown map id: " + yaxisid.ToString("X4") + " len " + yaxislen.ToString("X4") + " at address " + t.ToString("X8"));
                            }
                            SymbolHelper newSymbol = new SymbolHelper();
                            newSymbol.X_axis_length       = xaxislen;
                            newSymbol.X_axis_ID           = xaxisid;
                            newSymbol.X_axis_address      = t + 4;
                            newSymbol.Length              = xaxislen * 2;
                            newSymbol.Flash_start_address = t + 4 + (xaxislen * 2);
                            newSymbol.Varname             = "2D " + newSymbol.Flash_start_address.ToString("X8") + " " + xaxisid.ToString("X4");
                            //newSymbols.Add(newSymbol);
                            newSymbol.CodeBlock = DetermineCodeBlockByByAddress(newSymbol.Flash_start_address, newCodeBlocks);
                            retval = AddToSymbolCollection(newSymbols, newSymbol, newCodeBlocks);
                            if (retval)
                            {
                                mapFound  = true;
                                len2Skip += (xaxislen * 2);
                                t        += (xaxislen * 2);
                            }
                            // 2d map
                        }
                    }
                }
            }
            return(retval);
        }
Esempio n. 48
0
        public override void NameKnownMaps(byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
        {
            SymbolAxesTranslator st = new SymbolAxesTranslator();

            foreach (SymbolHelper sh in newSymbols)
            {
                //sh.X_axis_descr = st.TranslateAxisID(sh.X_axis_ID);
                //sh.Y_axis_descr = st.TranslateAxisID(sh.Y_axis_ID);
                if (sh.Length == 544)
                {
                    if (sh.X_axis_length == 16 && sh.Y_axis_length == 17)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            sh.Varname = "N146 Pump voltage map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            //sh.Correction = 0.001221001; // ?1.221001
                            //Todo: N146 correction factor EDC15C
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Pump voltage (V)";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                    }
                }
                else if (sh.Length == 468)
                {
                    if (sh.X_axis_length == 13 && sh.Y_axis_length == 18)
                    {
                        if (sh.X_axis_ID / 256 == 0xDC && sh.Y_axis_ID / 256 == 0xC0)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            sh.Varname = "Inverse driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Throttle  position";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            //sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                    }
                }
                else if (sh.Length == 416)
                {
                    if (sh.X_axis_length == 0x10 && sh.Y_axis_length == 0x0d)
                    {
                        if (sh.X_axis_ID / 256 == 0xF9 && sh.Y_axis_ID / 256 == 0xDB)
                        {
                            // this is IQ by MAF limiter!
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            sh.Varname = "Smoke limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Maximum IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.X_axis_descr = "Airflow mg/stroke";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.1;
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";

                        }
                        else if (sh.X_axis_ID / 256 == 0xF9 && sh.Y_axis_ID / 256 == 0xDA)
                        {
                            // this is IQ by MAF limiter!
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            sh.Varname = "Smoke limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Maximum IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.X_axis_descr = "Airflow mg/stroke";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.1;
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";

                        }
                        else if (sh.X_axis_ID / 256 == 0xDC && sh.Y_axis_ID / 256 == 0xDA)
                        {
                            // this is IQ by MAF limiter!
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            sh.Varname = "Smoke limiter II [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Maximum IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.X_axis_descr = "Airflow mg/stroke";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.1;
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";

                        }
                        else if (sh.X_axis_ID / 256 == 0xDD && sh.Y_axis_ID / 256 == 0xDA)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Turbo";
                            sh.Varname = "N75 duty cycle [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Duty cycle %";
                            sh.Correction = -0.01;
                            sh.Offset = 100;
                            //sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                        else if (sh.X_axis_ID == 0xE08A && sh.Y_axis_ID == 0xDDD8)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Turbo";
                            sh.Varname = "N75 duty cycle [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Duty cycle %";
                            sh.Correction = -0.01;
                            sh.Offset = 100;
                            //sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                        else    if (sh.X_axis_ID / 256 == 0xDC && sh.Y_axis_ID / 256 == 0xEA)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Turbo";
                            sh.Varname = "N75 duty cycle [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Duty cycle %";
                            sh.Correction = -0.01;
                            sh.Offset = 100;
                            //sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                        else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDE)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            int injDurCount = GetMapNameCountForCodeBlock("Start of injection (N108 SOI)", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "Start of injection (N108 SOI) " + injDurCount.ToString() + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");

                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.X_axis_correction = 0.01; // TODODONE : Check for x or y
                            sh.XaxisUnits = "mg/st";
                            sh.X_axis_descr = "IQ (mg/stroke)";

                            sh.Correction = 0.023437;
                            //sh.Offset = 78;
                            sh.Z_axis_descr = "Start position (degrees BTDC)";
                        }
                    }
                }
                if (sh.Length == 384)
                {

                    if (sh.X_axis_ID / 256 == 0xDD && sh.Y_axis_ID / 256 == 0xC0)
                    {
                        // inv driver wish
                        if (sh.X_axis_length == 12 && sh.Y_axis_length == 16)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            sh.Varname = "Inverse driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Throttle  position";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            //sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                    }
                    if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC1)
                    {
                        // inv driver wish
                        if (sh.X_axis_length == 12 && sh.Y_axis_length == 16)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            sh.Varname = "Inverse driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Throttle  position";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            //sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                    }
                    if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDC)
                    {
                        // smoke limiter
                        if (sh.X_axis_length == 16 && sh.Y_axis_length == 12)
                        {
                            int smCount = GetMapNameCountForCodeBlock("Smoke limiter", sh.CodeBlock, newSymbols, false);
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            sh.Varname = "Smoke limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Maximum IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.X_axis_descr = "Airflow mg/stroke";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.1;
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                    }

                }
                if (sh.Length == 320) // 16*10
                {
                    if (sh.X_axis_ID / 256 == 0xDD && sh.Y_axis_ID / 256 == 0xC0)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Turbo";
                        int tbCount = GetMapNameCountForCodeBlock("Boost target map", sh.CodeBlock, newSymbols, false);
                        sh.Varname = "Boost target map (" + tbCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        //Console.WriteLine("***** " + sh.Varname + " " + sh.Flash_start_address.ToString("X8"));
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "IQ (mg/stroke)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.Z_axis_descr = "Boost target (mbar)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mg/st";
                    }
                    else if (sh.X_axis_ID / 256 == 0xDC && sh.Y_axis_ID == 0xC0BA)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Misc";
                        sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Correction = 0.01;
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "Throttle  position";
                        sh.Z_axis_descr = "Requested IQ (mg)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "TPS %";
                    }
                    else if (sh.X_axis_ID / 256 == 0xDC && sh.Y_axis_ID == 0xC036)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Turbo";
                        int tbCount = GetMapNameCountForCodeBlock("Boost target map", sh.CodeBlock, newSymbols, false);
                        sh.Varname = "Boost target map (" + tbCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "IQ (mg/stroke)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.Z_axis_descr = "Boost target (mbar)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mg/st";
                    }
                    else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC3)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Turbo";
                        int tbCount = GetMapNameCountForCodeBlock("Boost target map", sh.CodeBlock, newSymbols, false);
                        sh.Varname = "Boost target map (" + tbCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "IQ (mg/stroke)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.Z_axis_descr = "Boost target (mbar)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mg/st";
                    }

                }
                if (sh.Length == 312)
                {
                    if (sh.X_axis_length == 13 && sh.Y_axis_length == 12)
                    {
                        if (sh.X_axis_ID / 256 == 0xDC && sh.Y_axis_ID / 256 == 0xD7)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            int injDurCount = GetMapNameCountForCodeBlock("Start of injection (N108 SOI)", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "Start of injection (N108 SOI) " + injDurCount.ToString() + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.Correction = 0.023437;
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.X_axis_correction = 0.01; // TODODONE : Check for x or y
                            sh.XaxisUnits = "mg/st";
                            sh.X_axis_descr = "IQ (mg/stroke)";

                            sh.Z_axis_descr = "Start position (degrees BTDC)";
                        }
                    }
                }
                else if (sh.Length == 256) // 8*16
                {
                    /*if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC1)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Misc";
                        sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Correction = 0.01;
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "Throttle  position";
                        sh.Z_axis_descr = "Requested IQ (mg)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "TPS %";

                    }*/
                    if (sh.X_axis_ID / 256 == 0xDD && sh.Y_axis_ID / 256 == 0xC0)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Misc";
                        sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Correction = 0.01;
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "Throttle  position";
                        sh.Z_axis_descr = "Requested IQ (mg)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "TPS %";

                    }
                }
                else if (sh.Length == 200)
                {
                    if (sh.X_axis_ID / 256 == 0xC0 && sh.Y_axis_ID / 256 == 0xDD)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Boost limit map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        //   sh.Correction = 0.01;
                        //sh.X_axis_correction = 0.01;
                        sh.Y_axis_descr = "Atmospheric pressure (mbar)";
                        sh.Z_axis_descr = "Maximum boost pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";
                    }
                    else if (sh.X_axis_ID / 256 == 0xC0 && sh.Y_axis_ID / 256 == 0xDC)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Boost limit map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        //   sh.Correction = 0.01;
                        //sh.X_axis_correction = 0.01;
                        sh.Y_axis_descr = "Atmospheric pressure (mbar)";
                        sh.Z_axis_descr = "Maximum boost pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";
                    }
                    else if (sh.X_axis_ID  == 0xC2BE && sh.Y_axis_ID  == 0xE08A)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Boost limit map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        //   sh.Correction = 0.01;
                        //sh.X_axis_correction = 0.01;
                        sh.Y_axis_descr = "Atmospheric pressure (mbar)";
                        sh.Z_axis_descr = "Maximum boost pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";
                    }
                }
                else if (sh.Length == 192) // 8*12
                {
                    if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC1)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Misc";
                        sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Correction = 0.01;
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "Throttle  position";
                        sh.Z_axis_descr = "Requested IQ (mg)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "TPS %";

                    }
                }
                else if (sh.Length == 182) // 7*13
                {
                    if (sh.X_axis_ID / 256 == 0xDC && sh.Y_axis_ID / 256 == 0xC0)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Misc";
                        sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Correction = 0.01;
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "Throttle  position";
                        sh.Z_axis_descr = "Requested IQ (mg)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "TPS %";

                    }
                }
                else if (sh.Length == 150)
                {
                    if (sh.X_axis_length == 3 && sh.Y_axis_length == 25)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Torque limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        sh.Y_axis_descr = "Atm. pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.Correction = 0.01;
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";

                    }
                }
                else if (sh.Length == 114)
                {
                    if (sh.X_axis_length == 3 && sh.Y_axis_length == 19)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Torque limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        sh.Y_axis_descr = "Atm. pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.Correction = 0.01;
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";

                    }
                }
            }
        }
Esempio n. 49
0
 private void VerifyCodeBlocks(byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
 {
     //000001=automatic,000002=manual,000003=4wd ????
     Tools.Instance.m_codeBlock5ID = 0;
     Tools.Instance.m_codeBlock6ID = 0;
     Tools.Instance.m_codeBlock7ID = 0;
     bool found = true;
     int offset = 0;
     int defaultCodeBlockLength = 0x10000;
     int currentCodeBlockLength = 0;
     int prevCodeBlockStart = 0;
     while (found)
     {
         int CodeBlockAddress = Tools.Instance.findSequence(allBytes, offset, new byte[16] { 0x14, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, new byte[16] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
         if (CodeBlockAddress > 0)
         {
             CodeBlock newcodeblock = new CodeBlock();
             newcodeblock.StartAddress = CodeBlockAddress +128;
             if (prevCodeBlockStart == 0) prevCodeBlockStart = newcodeblock.StartAddress;
             else if (currentCodeBlockLength == 0)
             {
                 currentCodeBlockLength = newcodeblock.StartAddress - prevCodeBlockStart;
                 if (currentCodeBlockLength > 0x10000) currentCodeBlockLength = 0x10000;
             }
             // find the next occurence of the checksum
             newCodeBlocks.Add(newcodeblock);
             offset = CodeBlockAddress + 128;
         }
         else found = false;
     }
     foreach (CodeBlock cb in newCodeBlocks)
     {
         if (currentCodeBlockLength != 0) cb.EndAddress = cb.StartAddress + currentCodeBlockLength - 1;
         else cb.EndAddress = cb.StartAddress + defaultCodeBlockLength - 1;
     }
     foreach (CodeBlock cb in newCodeBlocks)
     {
         CheckCodeBlock(cb.StartAddress, allBytes, newSymbols, newCodeBlocks);
     }
 }
Esempio n. 50
0
 private bool AddToSymbolCollection(SymbolCollection newSymbols, SymbolHelper newSymbol, List<CodeBlock> newCodeBlocks)
 {
     if (newSymbol.Length >= 800) return false;
     foreach (SymbolHelper sh in newSymbols)
     {
         if (sh.Flash_start_address == newSymbol.Flash_start_address)
         {
             //   Console.WriteLine("Already in collection: " + sh.Flash_start_address.ToString("X8"));
             return false;
         }
     }
     newSymbols.Add(newSymbol);
     newSymbol.CodeBlock = DetermineCodeBlockByByAddress(newSymbol.Flash_start_address, newCodeBlocks);
     return true;
 }
Esempio n. 51
0
        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);
            partNumberConverter pnc = new partNumberConverter();

            VerifyCodeBlocks(allBytes, newSymbols, newCodeBlocks);

            for (int t = 0; t < allBytes.Length - 1; t++)
            {
                CheckMap(t, allBytes, newSymbols, newCodeBlocks);
            }

            newSymbols.SortColumn = "Flash_start_address";
            newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending;
            newSymbols.Sort();
            NameKnownMaps(allBytes, newSymbols, newCodeBlocks);
            FindSVBL(allBytes, filename, newSymbols, newCodeBlocks);
            FindMAPMAFSwitch(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;
        }
Esempio n. 52
0
        private int CheckCodeBlock(int offset, byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
        {
            int codeBlockID = 0;
            try
            {
                int endOfTable = Convert.ToInt32(allBytes[offset + 0x01000]) + Convert.ToInt32(allBytes[offset + 0x01001]) * 256 + offset;
                int codeBlockAddress = Convert.ToInt32(allBytes[offset + 0x01002]) + Convert.ToInt32(allBytes[offset + 0x01003]) * 256 + offset;
                if (endOfTable == offset + 0xC3C3) return 0;
                codeBlockID = Convert.ToInt32(allBytes[codeBlockAddress]) + Convert.ToInt32(allBytes[codeBlockAddress + 1]) * 256;

                foreach (CodeBlock cb in newCodeBlocks)
                {
                    if (cb.StartAddress <= codeBlockAddress && cb.EndAddress >= codeBlockAddress)
                    {
                        cb.CodeID = codeBlockID;
                        cb.AddressID = codeBlockAddress;
                    }
                }
            }
            catch (Exception)
            {
            }
            return codeBlockID;
        }
Esempio n. 53
0
        public override void NameKnownMaps(byte[] allBytes, SymbolCollection newSymbols, List <CodeBlock> newCodeBlocks)
        {
            SymbolAxesTranslator st = new SymbolAxesTranslator();

            foreach (SymbolHelper sh in newSymbols)
            {
                // sh.X_axis_descr = st.TranslateAxisID(sh.X_axis_ID);
                // sh.Y_axis_descr = st.TranslateAxisID(sh.Y_axis_ID);

                if (sh.Length == 450)
                {
                    if (sh.X_axis_length == 15 && sh.Y_axis_length == 15)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xFC)
                        {
                            sh.Category    = "Detected maps";
                            sh.Subcategory = "Fuel";
                            int injDurCount = GetMapNameCountForCodeBlock("Start of injection (SOI)", sh.CodeBlock, newSymbols, false);

                            double tempRange = 0;                                                                                                                                // GetTemperatureSOIRange(sh.MapSelector, injDurCount - 1);
                            sh.Varname = "Start of injection (SOI) " + tempRange.ToString() + " °C [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]"; // " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");

                            sh.Y_axis_descr      = "Engine speed (rpm)";
                            sh.YaxisUnits        = "rpm";
                            sh.X_axis_correction = 0.01; // TODODONE : Check for x or y
                            sh.XaxisUnits        = "mg/st";
                            sh.X_axis_descr      = "IQ (mg/stroke)";

                            sh.Correction   = 0.023437;
                            sh.Z_axis_descr = "Start position (degrees BTDC)";
                        }
                    }
                }
                //12x13 E0 DD = EGR
                if (sh.Length == 312)
                {
                    if (sh.X_axis_length == 13 && sh.Y_axis_length == 12)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDD)
                        {
                            sh.Category    = "Detected maps";
                            sh.Subcategory = "Misc";
                            int egrCount = GetMapNameCountForCodeBlock("EGR", sh.CodeBlock, newSymbols, false);
                            sh.Varname           = "EGR " + egrCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction        = 0.1;
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr      = "Mass Air Flow (mg/stroke)";
                            sh.X_axis_descr      = "IQ (mg/stroke)";
                            sh.Y_axis_descr      = "Engine speed (rpm)";
                            sh.YaxisUnits        = "rpm";
                            sh.XaxisUnits        = "mg/st";
                        }
                    }
                }
                else if (sh.Length == 208)
                {
                    if (sh.X_axis_length == 13 && sh.Y_axis_length == 8)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC1)
                        {
                            sh.Category          = "Detected maps";
                            sh.Subcategory       = "Misc";
                            sh.Varname           = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction        = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr      = "Throttle  position";
                            sh.Z_axis_descr      = "Requested IQ (mg)";
                            sh.Y_axis_descr      = "Engine speed (rpm)";
                            sh.YaxisUnits        = "rpm";
                            sh.XaxisUnits        = "TPS %";
                        }
                    }
                }
                else if (sh.Length == 182) // 7*13
                {
                    if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC1)
                    {
                        sh.Category          = "Detected maps";
                        sh.Subcategory       = "Misc";
                        sh.Varname           = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Correction        = 0.01;
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr      = "Throttle  position";
                        sh.Z_axis_descr      = "Requested IQ (mg)";
                        sh.Y_axis_descr      = "Engine speed (rpm)";
                        sh.YaxisUnits        = "rpm";
                        sh.XaxisUnits        = "TPS %";
                    }
                }
                else if (sh.Length == 176)
                {
                    if (sh.X_axis_length == 11 && sh.Y_axis_length == 8)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
                        {
                            int smCount = GetMapNameCountForCodeBlock("Smoke limiter", sh.CodeBlock, newSymbols, false);
                            sh.Category          = "Detected maps";
                            sh.Subcategory       = "Limiters";
                            sh.Varname           = "Smoke limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr      = "Maximum IQ (mg)";
                            sh.Y_axis_descr      = "Engine speed (rpm)";
                            sh.X_axis_descr      = "Airflow mg/stroke";
                            sh.Correction        = 0.01;
                            sh.X_axis_correction = 0.1;
                            sh.YaxisUnits        = "rpm";
                            sh.XaxisUnits        = "mg/st";
                        }
                    }
                }
                else if (sh.Length == 40)
                {
                    if (sh.X_axis_length == 20 && sh.Y_axis_length == 1)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0)
                        {
                            sh.Category    = "Detected maps";
                            sh.Subcategory = "Limiters";
                            int lmCount = GetMapNameCountForCodeBlock("Torque limiter", sh.CodeBlock, newSymbols, false);
                            sh.Varname      = "Torque limiter (" + lmCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Maximum IQ (mg)";
                            //sh.Y_axis_descr = "Atm. pressure (mbar)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.Correction   = 0.01;
                            sh.YaxisUnits   = "rpm";
                        }
                    }
                }
            }
        }
Esempio n. 54
0
 abstract public void FindSVBL(byte[] allBytes, string filename, SymbolCollection newSymbols, List <CodeBlock> newCodeBlocks);
Esempio n. 55
0
        public override void NameKnownMaps(byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
        {
            //N146 Pump Voltage map:
            SymbolAxesTranslator st = new SymbolAxesTranslator();

            foreach (SymbolHelper sh in newSymbols)
            {
              //  sh.X_axis_descr = st.TranslateAxisID(sh.X_axis_ID);
              //  sh.Y_axis_descr = st.TranslateAxisID(sh.Y_axis_ID);

                if (sh.Length == 544)
                {
                    if (sh.X_axis_length == 16 && sh.Y_axis_length == 17)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            sh.Varname = "N146 Pump voltage map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            //sh.Correction = 0.001221001; // ?1.221001
                            //Todo: N146 correction factor for MSA6
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Pump voltage (V)";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                    }
                }
                if (sh.Length == 448)
                {
                    if (sh.X_axis_length == 16 && sh.Y_axis_length == 14)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            sh.Varname = "N146 Pump voltage map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            //sh.Correction = 0.001221001; // ?1.221001
                            //Todo: N146 correction factor for MSA6
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Pump voltage (V)";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                    }
                }
                //12x13 E0 DD = EGR
                if (sh.Length == 416)
                {
                    if (sh.X_axis_length == 16 && sh.Y_axis_length == 13)
                    {
                        if (sh.X_axis_ID == 0xE08A && sh.Y_axis_ID  == 0xDDD8)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Turbo";
                            sh.Varname = "N75 duty cycle [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Duty cycle %";
                            sh.Correction = -0.01;
                            sh.Offset = 100;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                        else if (sh.X_axis_ID == 0xE08A && sh.Y_axis_ID == 0xDD30)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            int egrCount = GetMapNameCountForCodeBlock("EGR", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "EGR " + egrCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.1;
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Mass Air Flow (mg/stroke)";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                        else if (sh.X_axis_ID == 0xE08A && sh.Y_axis_ID == 0xDEDC)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            int injDurCount = GetMapNameCountForCodeBlock("Start of injection (N108 SOI)", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "Start of injection (N108 SOI) " + injDurCount.ToString() + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.Correction = 0.023437;
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.X_axis_correction = 0.01; // TODODONE : Check for x or y
                            sh.XaxisUnits = "mg/st";
                        }
                        else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDE)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            int egrCount = GetMapNameCountForCodeBlock("EGR", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "EGR " + egrCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.1;
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Mass Air Flow (mg/stroke)";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                        else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDD)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            int injDurCount = GetMapNameCountForCodeBlock("Start of injection (N108 SOI)", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "Start of injection (N108 SOI) " + injDurCount.ToString() + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.Correction = 0.023437;
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.X_axis_correction = 0.01; // TODODONE : Check for x or y
                            sh.XaxisUnits = "mg/st";
                            sh.Z_axis_descr = "Start position (degrees BTDC)";
                        }
                        else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDC)
                        {
                            // IQ by MAP
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            sh.Varname = "IQ by MAP limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") +" " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.Correction = 0.01;
                            sh.X_axis_descr = "Boost pressure";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.Z_axis_descr = "Maximum IQ (mg)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mbar";
                        }
                    }
                }
                else if (sh.Length == 384)
                {
                    if (sh.X_axis_length == 12 && sh.Y_axis_length == 16)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            sh.Varname = "Inverse driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.Z_axis_descr = "Throttle  position";
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            //sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }

                    }
                    else if (sh.X_axis_length == 16 && sh.Y_axis_length == 12)
                    {
                        int smCount = GetMapNameCountForCodeBlock("Smoke limiter", sh.CodeBlock, newSymbols, false);
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Smoke limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.X_axis_descr = "Airflow mg/stroke";
                        sh.Correction = 0.01;
                        sh.X_axis_correction = 0.1;
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "mg/st";
                    }
                }
                else if (sh.Length == 320)
                {
                    if (sh.X_axis_length == 16 && sh.Y_axis_length == 10)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDC)
                        {
                            int smCount = GetMapNameCountForCodeBlock("Smoke limiter", sh.CodeBlock, newSymbols, false);
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            sh.Varname = "Smoke limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Maximum IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.X_axis_descr = "Airflow mg/stroke";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.1;
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                        else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC3)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Turbo";
                            int boostTargetCount = GetMapNameCountForCodeBlock("Boost target map", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "Boost target map (" + boostTargetCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.Z_axis_descr = "Boost target (mbar)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                        else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Turbo";
                            int boostTargetCount = GetMapNameCountForCodeBlock("Boost target map", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "Boost target map (" + boostTargetCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.Z_axis_descr = "Boost target (mbar)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }

                        else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDD)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            sh.Varname = "IQ to airmass [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Required airmass";
                            sh.Correction = 0.1;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                        else if (sh.X_axis_ID == 0xE08A && sh.Y_axis_ID == 0xDEDC)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Fuel";
                            sh.Varname = "IQ to airmass [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Required airmass";
                            sh.Correction = 0.1;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                        else if (sh.X_axis_ID == 0xE08A && sh.Y_axis_ID == 0xC2D0)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Turbo";
                            int boostTargetCount = GetMapNameCountForCodeBlock("Boost target map", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "Boost target map (" + boostTargetCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "IQ (mg/stroke)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.Z_axis_descr = "Boost target (mbar)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "mg/st";
                        }
                    }
                }
                else if (sh.Length == 256)
                {
                    if (sh.X_axis_length == 16 && sh.Y_axis_length == 8)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "Throttle  position";
                            sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "TPS %";
                        }
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC1)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "Throttle  position";
                            sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "TPS %";
                        }
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC0)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "Throttle  position";
                            sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "TPS %";
                        }
                    }
                }
                else if (sh.Length == 200)
                {
                    if (sh.X_axis_ID / 256 == 0xC2 && sh.Y_axis_ID / 256 == 0xE0)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Boost limit map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
                        //   sh.Correction = 0.01;
                        //sh.X_axis_correction = 0.01;
                        sh.Y_axis_descr = "Atmospheric pressure (mbar)";
                        sh.Z_axis_descr = "Maximum boost pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";
                    }
                }
                else if (sh.Length == 192)
                {
                    if (sh.X_axis_length == 12 && sh.Y_axis_length == 8)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "Throttle  position";
                            sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "TPS %";
                        }
                        if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC1)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.01;
                            sh.X_axis_correction = 0.01;
                            sh.X_axis_descr = "Throttle  position";
                            sh.Z_axis_descr = "Requested IQ (mg)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "TPS %";
                        }
                    }
                }
                else if (sh.Length == 182) // 7*13
                {
                    if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC1)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Misc";
                        sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Correction = 0.01;
                        sh.X_axis_correction = 0.01;
                        sh.X_axis_descr = "Throttle  position";
                        sh.Z_axis_descr = "Requested IQ (mg)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "TPS %";
                    }
                    if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
                    {
                        if (IsValidTemperatureAxis(allBytes, sh, MapViewerEx.AxisIdent.Y_Axis))
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            //sh.Varname = "Boost limiter (temperature) [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Varname = "SOI limiter (temperature) [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Correction = 0.023437;
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.X_axis_descr = "Temperature"; //IAT, ECT or Fuel temp?
                            sh.X_axis_correction = 0.1;
                            sh.X_axis_offset = -273.1;
                            sh.Z_axis_descr = "SOI limit (degrees)";
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "°C";
                        }
                    }

                }
                else if (sh.Length == 144)
                {
                    if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC0)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Fuel";
                        int sIQCount = GetMapNameCountForCodeBlock("Start IQ ", sh.CodeBlock, newSymbols, false);
                        sh.Varname = "Start IQ (" + sIQCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Correction = 0.01;
                        sh.X_axis_descr = "CT (celcius)";
                        sh.X_axis_correction = 0.1;
                        sh.X_axis_offset = -273.1;
                        sh.Z_axis_descr = "Requested IQ (mg)";
                        sh.Y_axis_descr = "Engine speed (rpm)";
                        sh.YaxisUnits = "rpm";
                        sh.XaxisUnits = "degC";
                    }
                }
                else if (sh.Length == 128)
                {
                    if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID == 0xC002)
                    {
                        // check for valid axis data on temp data
                        if (IsValidTemperatureAxis(allBytes, sh, MapViewerEx.AxisIdent.Y_Axis))
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            int maflimTempCount = GetMapNameCountForCodeBlock("MAF correction by temperature", sh.CodeBlock, newSymbols, false);
                            maflimTempCount--;
                            sh.Varname = "MAF correction by temperature " + maflimTempCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Limit";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.X_axis_descr = "Intake air temperature"; //IAT, ECT or Fuel temp?
                            sh.X_axis_correction = 0.1;
                            sh.X_axis_offset = -273.1;
                            sh.Correction = 0.01;
                            sh.YaxisUnits = "rpm";
                            sh.XaxisUnits = "°C";
                        }

                    }
                }
                else if (sh.Length == 64)
                {
                    if (sh.X_axis_length == 32 && sh.Y_axis_length == 1)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Misc";
                        sh.Varname = "MAF linearization [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                    }
                }
                else if (sh.Length == 114)
                {
                    if (sh.X_axis_length == 3 && sh.Y_axis_length == 19)
                    {
                        sh.Category = "Detected maps";
                        sh.Subcategory = "Limiters";
                        sh.Varname = "Torque limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        sh.Z_axis_descr = "Maximum IQ (mg)";
                        sh.Y_axis_descr = "Atm. pressure (mbar)";
                        sh.X_axis_descr = "Engine speed (rpm)";
                        sh.Correction = 0.01;
                        sh.XaxisUnits = "rpm";
                        sh.YaxisUnits = "mbar";

                    }
                }
                else if (sh.Length == 38)
                {
                    if (sh.X_axis_length == 19 && sh.Y_axis_length == 1)
                    {
                        if (sh.X_axis_ID / 256 == 0xE0)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Limiters";
                            int lmCount = GetMapNameCountForCodeBlock("Torque limiter", sh.CodeBlock, newSymbols, false);
                            sh.Varname = "Torque limiter (" + lmCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Z_axis_descr = "Maximum IQ (mg)";
                            //sh.Y_axis_descr = "Atm. pressure (mbar)";
                            sh.Y_axis_descr = "Engine speed (rpm)";
                            sh.Correction = 0.01;
                            sh.YaxisUnits = "rpm";
                        }
                    }
                }
                else if (sh.Length == 4)
                {
                    if (sh.X_axis_length == 2 && sh.Y_axis_length == 1)
                    {
                        //if (sh.X_axis_ID >= 0xEBA0 && sh.X_axis_ID <= 0xEBAF)
                        if (sh.X_axis_ID == 0xDF4A)
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            sh.Varname = "MAP linearization [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                        }
                    }
                    if (sh.X_axis_length == 2 && sh.Y_axis_length == 1)
                    {
                        if (sh.X_axis_ID == 0xC002) // idle RPM
                        {
                            sh.Category = "Detected maps";
                            sh.Subcategory = "Misc";
                            int lmCount = GetMapNameCountForCodeBlock("Idle RPM", sh.CodeBlock, newSymbols, false);

                            sh.Varname = "Idle RPM (" + lmCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
                            sh.Y_axis_descr = "Coolant temperature";
                            sh.Y_axis_correction = 0.1;
                            sh.Y_axis_offset = -273.1;
                            sh.Z_axis_descr = "Target engine speed";
                            sh.YaxisUnits = "°C";

                        }
                    }
                }

            }
        }