public AddressLookupCollectionPropertyDescriptor(AddressLookupCollection coll, int idx)
     :
     base("#" + idx.ToString(), null)
 {
     this.collection = coll;
     this.index      = idx;
 }
 public SelectSRAMSymbolEventArgs(int address, int length, string mapname, string filename1, string filename2, bool showdiffmap, SymbolCollection symColl, AddressLookupCollection adrColl)
 {
     this._address = address;
     this._length = length;
     this._mapname = mapname;
     this._filename1 = filename1;
     this._filename2 = filename2;
     this._showdiffmap = showdiffmap;
     this._symbols = symColl;
     this._addresses = adrColl;
 }
Esempio n. 3
0
        private void ReadAddressLookupTableFromFile(int startofsymboltable, int numberofsymbols,  AddressLookupCollection curAddressLookupCollection, string filename)
        {
            // find the address lookuptable
            // this table starts with 48 79 00 04
            int readstate = 0;
            int readaddress = 0;
            int lookuptablestartaddress = 0x00;

            // test
            readstate = -30;
            // test

            FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
            using (BinaryReader br = new BinaryReader(fs))
            {
                byte[] filebytes = br.ReadBytes((int)fs.Length);
                for (int t = 0; t < filebytes.Length; t++)
                {
                    byte b = filebytes[t];
                /*for (int t = 0; t < fs.Length; t++)
                {
                    byte b = br.ReadByte();*/
                    //4E 75 48 E7 01 30 26 6F 00 16 3E 2F 00 14 24 6F 00 10 60 00 00 0A
                    switch (readstate)
                    {
                        case -30:
                            if (b == 0x4E)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -29:
                            if (b == 0x75)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -28:
                            if (b == 0x48)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -27:
                            if (b == 0xE7)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -26:
                            if (b == 0x01)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -25:
                            if (b == 0x30)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -24:
                            if (b == 0x26)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -23:
                            if (b == 0x6F)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -22:
                            if (b == 0x00)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -21:
                            if (b == 0x16)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -20:
                            if (b == 0x3E)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -19:
                            if (b == 0x2F)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -18:
                            if (b == 0x00)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -17:
                            if (b == 0x14)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -16:
                            if (b == 0x24)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -15:
                            if (b == 0x6F)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -14:
                            if (b == 0x00)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -13:
                            if (b == 0x10)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -12:
                            if (b == 0x60)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -11:
                            if (b == 0x00)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -10:
                            if (b == 0x00)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;
                        case -9:
                            if (b == 0x0A)
                            {
                                readstate = 0;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = -30;
                            }
                            break;

                        case 0:
                            // waiting for first recognition char 48
                            if (b == 0x48)
                            {
                                lookuptablestartaddress = t;
                                readstate++;
                            }
                            break;
                        case 1:
                            // waiting for second char 79
                            if (b == 0x79)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = 0;
                            }
                            break;
                        case 2:
                            // waiting for third char 00
                            if (b == 0x00)
                            {
                                readstate++;
                            }
                            else
                            {
                                lookuptablestartaddress = 0x00;
                                readstate = 0;
                            }
                            break;
                        case 3:
                            // waiting for last char 04
                            if (fs.Length == 0x20000)
                            {
                                if (b == 0x06)
                                {
                                    readstate++;
                                }
                                else
                                {
                                    lookuptablestartaddress = 0x00;
                                    readstate = 0;
                                }
                            }
                            else
                            {
                                if (b == 0x04)
                                {
                                    readstate++;
                                }
                                else
                                {
                                    lookuptablestartaddress = 0x00;
                                    readstate = 0;
                                }
                            }
                            break;
                        default:
                            break;

                    }
                }
            }
            //fs.Flush();
            fs.Close();
            fs.Dispose();

            FileStream fs2 = new FileStream(filename, FileMode.Open, FileAccess.Read);
            fs2.Seek(lookuptablestartaddress + 2, SeekOrigin.Begin);
            readaddress = lookuptablestartaddress + 2;
            using (BinaryReader br = new BinaryReader(fs2))
            {
                for (int sc = 0; sc < numberofsymbols; sc++)
                {
                    if (readaddress >= startofsymboltable) break;
                    int sramaddress = 0;
                    int flashaddress = 0;
                    byte b = br.ReadByte();
                    flashaddress = b * 256 * 256 * 256;
                    b = br.ReadByte();
                    flashaddress += (b * 256 * 256);
                    b = br.ReadByte();
                    flashaddress += (b * 256);
                    b = br.ReadByte();
                    flashaddress += (b);
                    // 8 x dummy
                    b = br.ReadByte();
                    b = br.ReadByte();
                    b = br.ReadByte();
                    b = br.ReadByte();
                    b = br.ReadByte();
                    b = br.ReadByte();
                    b = br.ReadByte();
                    b = br.ReadByte();
                    // lees sram adres
                    b = br.ReadByte();
                    sramaddress = (b * 256);
                    b = br.ReadByte();
                    sramaddress += (b);
                    AddressLookupHelper alh = new AddressLookupHelper();
                    alh.Flash_address = flashaddress;
                    alh.Sram_adddress = sramaddress;
                    curAddressLookupCollection.Add(alh);
                    /*using (StreamWriter sw = new StreamWriter("lookupcollection.txt", true))
                    {
                        sw.WriteLine("Lookup entry: " + alh.Sram_adddress.ToString("X4") + " : " + alh.Flash_address.ToString("X6"));
                    }*/

                    // lees naar volgende 48 79
                    int tel = 0;
                    bool found = false;
                    int tstate = 0;
                    while (tel++ < 16 && !found)
                    {
                        byte tb = br.ReadByte();
                        switch (tstate)
                        {
                            case 0:
                                if (tb == 0x048) tstate++;
                                break;
                            case 1:
                                if (tb == 0x79) found = true;
                                else tstate = 0;
                                break;
                        }
                    }
                    // als niet gevonden.. ?
                    if (!found)
                    {
                        break;
                    }

                }
                //lees 4 bytes address
                /*
                for (int fa = 0; fa < 4; fa++)
                {

                }*/

            }
            //fs2.Flush();
            fs2.Close();
            fs2.Dispose();
            /*using (StreamWriter sw = new StreamWriter("lookupdump.txt", false))
            {
                foreach (AddressLookupHelper ah in m_addresslookup)
                {
                    sw.WriteLine("Helper: " + ah.Sram_adddress.ToString("X4") + " " + ah.Flash_address.ToString("X8"));
                }
            }*/
        }
Esempio n. 4
0
        private void ParseFile(string filename, SymbolCollection curSymbolCollection, AddressLookupCollection curAddressLookupCollection)
        {
            // lezen tot END$ (einde symbol table)

            int m_symboltablestartaddress = 0;
            int state = 0;
            int charcount = 0;
            string dbgstring = string.Empty;
            string asciistring = string.Empty;

            // for test
            state = -10;
            // for test
            SignalDecodeProgress(5);

            //listBox1.Items.Clear();
            try
            {
                FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);

                using (BinaryReader br = new BinaryReader(fs))
                {
                    byte[] filebytes = br.ReadBytes((int)fs.Length);
                    for (int t = 0; t < filebytes.Length; t++)
                    {

                        byte b = filebytes[t];
                    /*for (int t = 0; t < fs.Length; t++)
                    {

                        byte b = br.ReadByte();*/
                        // first find string 00 0A 28 79 00
                        switch (state)
                        {
                            case -10:
                                if (b == 0)
                                {
                                    state++;
                                }
                                break;
                            case -9:
                                if (b == 0x0a)
                                {
                                    state++;
                                }
                                else
                                {
                                    state = -10;
                                }
                                break;
                            case -8:
                                if (b == 0x28)
                                {
                                    state++;
                                }
                                else
                                {
                                    state = -10;
                                }
                                break;
                            case -7:
                                if (b == 0x79)
                                {
                                    state++;
                                }
                                else
                                {
                                    state = -10;
                                }
                                break;
                            case -6:
                                if (b == 0x00)
                                {
                                    state++;
                                }
                                else
                                {
                                    state = -10;
                                }
                                break;
                            case -5:
                                if (b == 0x4E)
                                {
                                    state++;
                                }
                                break;
                            case -4:
                                if (b == 0x75)
                                {
                                    state = 2;
                                }
                                else
                                {
                                    state = -5;
                                }
                                break;

                            case 0:
                                if (b == 0x0d)
                                {
                                    //                                    if (br.PeekChar() == 0x0a)
                                    //                                    {
                                    state++;
                                    //                                    }
                                }
                                break;
                            case 1:
                                if (b == 0x0a)
                                {
                                    state++;
                                    charcount = 0;
                                }
                                else
                                {
                                    state = 0;
                                }
                                break;
                            case 2:
                                if (charcount < 32)
                                {
                                    if (b == 0x0d && /*br.PeekChar()*/ filebytes[t+1] == 0x0a) // start of next symbol
                                    {
                                        state = 1;
                                        int address = t - charcount;
                                        //AddLogItem(address.ToString("X6") + ": " + dbgstring + " - " + asciistring);
                                        TryToAddSymbolToCollection(dbgstring, curSymbolCollection);

                                        if (m_symboltablestartaddress == 0 && t > 0xA000) m_symboltablestartaddress = address;
                                        dbgstring = string.Empty;
                                        asciistring = string.Empty;
                                    }
                                    else
                                    {
                                        charcount++;
                                        dbgstring += b.ToString("X2") + " ";
                                        if (b >= 0x20 && b < 0x80)
                                        {
                                            asciistring += Convert.ToChar(b);
                                        }
                                        else
                                        {
                                            asciistring += ".";
                                        }
                                    }
                                }
                                else
                                {
                                    int address = t - charcount;
                                    // AddLogItem(address.ToString("X6") + ": " + dbgstring + " - " + asciistring);
                                    TryToAddSymbolToCollection(dbgstring, curSymbolCollection);

                                    if (m_symboltablestartaddress == 0 && t > 0xA000) m_symboltablestartaddress = address;
                                    //TryToAddSymbolToCollection(dbgstring);
                                    if (asciistring.StartsWith("END$"))
                                    {
                                        br.Close();
                                        fs.Close();
                                        //button1.Enabled = true;
                                        //AddLogItem("Found end of symbol table, quit");
                                        return;
                                    }
                                    else
                                    {
                                        dbgstring = string.Empty;
                                        asciistring = string.Empty;
                                        state = 0;
                                    }
                                }
                                break;
                        }
                    }
                    br.Close();
                }
                //fs.Flush();
                fs.Close();
                fs.Dispose();
                SignalDecodeProgress(30);

                // now sort the symbols...
            }
            catch (Exception E)
            {
                //MessageBox.Show(E.Message);
                Console.WriteLine(E.Message);
            }
            finally
            {
                //button1.Enabled = true;
                try
                {
                    // fix masked symbolnames...
                    try
                    {
                        FixMaskedSymbols(curSymbolCollection);
                        SignalDecodeProgress(40);

                    }
                    catch (Exception fmsE)
                    {
                        Console.WriteLine("Failed to fix masked symbols: " + fmsE.Message);
                    }
                    try
                    {
                        if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\symbolindex.xml"))
                        {
                            System.Data.DataTable dt = new System.Data.DataTable("DEFAULT");
                            dt.Columns.Add("SYMBOLNAME");
                            foreach (SymbolHelper sh in curSymbolCollection)
                            {
                                dt.Rows.Add(sh.Varname);
                            }
                            dt.WriteXml(System.Windows.Forms.Application.StartupPath + "\\symbolindex.xml");
                        }
                    }
                    catch (Exception wsiE)
                    {
                        Console.WriteLine("Failed to write symbolindex: " + wsiE.Message);
                    }
                    SignalDecodeProgress(50);

                    ReadAddressLookupTableFromFile(m_symboltablestartaddress, curSymbolCollection.Count, curAddressLookupCollection, filename);
                    //Console.WriteLine("Read address lookup table. Symbolcount = " + curSymbolCollection.Count.ToString() + " addresses = " + curAddressLookupCollection.Count.ToString());
                    SignalDecodeProgress(70);

                    foreach (SymbolHelper sh in curSymbolCollection)
                    {
                        foreach (AddressLookupHelper alh in curAddressLookupCollection)
                        {
                            if (sh.Start_address == alh.Sram_adddress)
                            {
                                sh.Flash_start_address = alh.Flash_address;
                                alh.UsedAddress = true;
                                break;
                            }
                        }
                    }
                    SignalDecodeProgress(80);

                    foreach (AddressLookupHelper alh in curAddressLookupCollection)
                    {
                        if (!alh.UsedAddress)
                        {
                            Console.WriteLine("Unused addresshelper: " + alh.Flash_address.ToString("X6") + " " + alh.Sram_adddress.ToString("X4"));
                        }

                    }
                    SignalDecodeProgress(90);

                }
                catch (Exception finE)
                {
                    Console.WriteLine(finE.Message);
                }
            }
        }
 public Trionic5FileInformation()
 {
     m_SymbolCollection = new SymbolCollection();
     m_AddressCollection = new AddressLookupCollection();
 }
Esempio n. 6
0
 public SelectSymbolEventArgs(int address, int length, string mapname, string filename, bool showdiffmap, SymbolCollection symColl, AddressLookupCollection adrColl, Trionic5File _file, Trionic5FileInformation _fileinfo)
 {
     this._address = address;
     this._length = length;
     this._mapname = mapname;
     this._filename = filename;
     this._showdiffmap = showdiffmap;
     this._symbols = symColl;
     this._addresses = adrColl;
     this.m_CompTrionic5File = _file;
     this.m_CompTrionic5FileInformation = _fileinfo;
 }
 public AddressLookupCollectionPropertyDescriptor(AddressLookupCollection coll, int idx)
     : base("#" + idx.ToString(), null)
 {
     this.collection = coll;
     this.index = idx;
 }
Esempio n. 8
0
        private void CompareSymbolTableToFile(string filename, Trionic5Tools.SymbolCollection curSymbolCollection, AddressLookupCollection curAddressLookupCollection, out int numberofsymboldifferent)
        {
            numberofsymboldifferent = 0;
            if (filename != string.Empty)
            {
                //bool m_fileparsed = false;
                SetTaskProgress(0, true);
                SetStatusText("Start symbol parsing");
                // available in repository?
                //ParseFile(progress, filename, curTrionic5Tools.SymbolCollection, curAddressLookupCollection);
                Trionic5File m_CompareToFile = new Trionic5File();
                m_CompareToFile.LibraryPath = Application.StartupPath + "\\Binaries";
                m_CompareToFile.SetAutoUpdateChecksum(m_appSettings.AutoChecksum);

                m_CompareToFile.onDecodeProgress += new IECUFile.DecodeProgress(m_CompareToFile_onDecodeProgress);
                Trionic5FileInformation m_CompareInfo = m_CompareToFile.ParseTrionicFile(filename);
                // available in repository?
                curSymbolCollection = m_CompareInfo.SymbolCollection;
                curAddressLookupCollection = m_CompareInfo.AddressCollection;
                //m_fileparsed = true;
                // AddLogItem("Start symbol export...");
                curSymbolCollection.SortColumn = "Start_address";
                curSymbolCollection.SortingOrder = Trionic5Tools.GenericComparer.SortOrder.Ascending;
                curSymbolCollection.Sort();
                //listView1.SuspendLayout();

                foreach (Trionic5Tools.SymbolHelper sh in curSymbolCollection)
                {
                    float diffperc = 0;
                    int diffabs = 0;
                    float diffavg = 0;
                    if (!CompareSymbolToCurrentFile(sh.Varname, sh.Flash_start_address, sh.Length, filename, out diffperc, out diffabs, out diffavg))
                    {
                        numberofsymboldifferent++;
                    }
                }
                /*if (m_fileparsed)
                {
                    CreateRepositoryItem(filename, curTrionic5Tools.SymbolCollection);
                }*/
                //listView1.ResumeLayout();
                SetTaskProgress(0, false);
                SetStatusText("Idle");
                //barButtonItem14.Enabled = true;
                //progress.Close();

            }
            else
            {
                frmInfoBox info = new frmInfoBox("No file selected, please select one first");
            }
        }
Esempio n. 9
0
        private void CompareToFile(string filename)
        {
            Trionic5Tools.SymbolCollection compSymbols = new Trionic5Tools.SymbolCollection();
            AddressLookupCollection compAddressLookup = new AddressLookupCollection();
            dockManager1.BeginUpdate();
            try
            {
                DevExpress.XtraBars.Docking.DockPanel dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500));
                CompareResults tabdet = new CompareResults();
                tabdet.Dock = DockStyle.Fill;
                tabdet.Filename = filename;

                tabdet.onSymbolSelect += new CompareResults.NotifySelectSymbol(tabdet_onSymbolSelect);
                dockPanel.Controls.Add(tabdet);
                //dockPanel.DockAsTab(dockPanel1);
                dockPanel.Text = "Compare results: " + Path.GetFileName(filename);
                bool isDocked = false;
                foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                {
                    if (pnl.Text.StartsWith("Compare results: ") && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                    {
                        dockPanel.DockAsTab(pnl, 0);

                        isDocked = true;
                        break;
                    }
                }
                if (!isDocked)
                {
                    dockPanel.DockTo(dockManager1, DevExpress.XtraBars.Docking.DockingStyle.Left, 1);
                    dockPanel.Width = 400;
                }
                Trionic5FileInformation m_FileInformation = new Trionic5FileInformation();
                Trionic5File m_CompareToFile = CompareSymbolTable(filename, compSymbols, compAddressLookup, tabdet.gridControl1, out m_FileInformation);
                m_CompareToFile.SetAutoUpdateChecksum(m_appSettings.AutoChecksum);
                tabdet.ComparedTrionic5File = m_CompareToFile;
                tabdet.ComparedTrionic5FileInformation = m_FileInformation;
                tabdet.CompareSymbolCollection = compSymbols;
                tabdet.CompareAddressLookupCollection = compAddressLookup;
                tabdet.OpenGridViewGroups(tabdet.gridControl1, 1);
            }
            catch (Exception E)
            {
                Console.WriteLine(E.Message);
            }
            dockManager1.EndUpdate();
        }
Esempio n. 10
0
        private Trionic5File CompareSymbolTable(string filename, Trionic5Tools.SymbolCollection curSymbolCollection, AddressLookupCollection curAddressLookupCollection, DevExpress.XtraGrid.GridControl curGridControl, out Trionic5FileInformation m_CompareInfo)
        {
            //bool m_fileparsed = false;
            //listView1.Items.Clear();
            SetStatusText("Start symbol parsing");
            SetTaskProgress(0, true);
            Trionic5File m_CompareToFile = new Trionic5File();
            m_CompareToFile.LibraryPath = Application.StartupPath + "\\Binaries";
            m_CompareToFile.SetAutoUpdateChecksum(m_appSettings.AutoChecksum);

            m_CompareToFile.SelectFile(filename);
            m_CompareToFile.onDecodeProgress += new IECUFile.DecodeProgress(m_CompareToFile_onDecodeProgress);
            m_CompareInfo = m_CompareToFile.ParseTrionicFile(filename);
            // available in repository?
            curSymbolCollection = m_CompareInfo.SymbolCollection;
            curAddressLookupCollection = m_CompareInfo.AddressCollection;
            //                ParseFile(progress, filename, curTrionic5Tools.SymbolCollection, curAddressLookupCollection);
               // m_fileparsed = true;
            // AddLogItem("Start symbol export...");
            curSymbolCollection.SortColumn = "Start_address";
            curSymbolCollection.SortingOrder = Trionic5Tools.GenericComparer.SortOrder.Ascending;
            curSymbolCollection.Sort();
            // progress.SetProgress("Filling list");
            SetStatusText("Filling list");
            //listView1.SuspendLayout();
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("SYMBOLNAME");
            dt.Columns.Add("SRAMADDRESS", Type.GetType("System.Int32"));
            dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32"));
            dt.Columns.Add("LENGTHBYTES", Type.GetType("System.Int32"));
            dt.Columns.Add("LENGTHVALUES", Type.GetType("System.Int32"));
            dt.Columns.Add("DESCRIPTION");
            dt.Columns.Add("ISCHANGED", Type.GetType("System.Boolean"));
            dt.Columns.Add("CATEGORY", Type.GetType("System.Int32"));
            dt.Columns.Add("DIFFPERCENTAGE", Type.GetType("System.Double"));
            dt.Columns.Add("DIFFABSOLUTE", Type.GetType("System.Int32"));
            dt.Columns.Add("DIFFAVERAGE", Type.GetType("System.Double"));
            dt.Columns.Add("CATEGORYNAME");
            dt.Columns.Add("SUBCATEGORYNAME");

            foreach (Trionic5Tools.SymbolHelper sh in curSymbolCollection)
            {
                float diffperc = 0;
                int diffabs = 0;
                float diffavg = 0;
                if (!CompareSymbolToCurrentFile(sh.Varname, sh.Flash_start_address, sh.Length, filename, out diffperc, out diffabs, out diffavg))
                {
                    dt.Rows.Add(sh.Varname, sh.Start_address, sh.Flash_start_address, sh.Length, sh.Length, m_trionicFileInformation.GetSymbolDescription(sh.Varname), false, (int)m_trionicFileInformation.GetSymbolCategory(sh.Varname), diffperc, diffabs, diffavg, m_trionicFileInformation.GetSymbolCategory(sh.Varname).ToString().Replace("_", " "), m_trionicFileInformation.GetSymbolSubcategory(sh.Varname).ToString().Replace("_", " "));
                }
            }
            curGridControl.DataSource = dt;
            /*if (m_fileparsed)
            {
                CreateRepositoryItem(filename, curTrionic5Tools.SymbolCollection);
            }*/
            //listView1.ResumeLayout();
            SetStatusText("Idle");
            SetTaskProgress(0, false);
            return m_CompareToFile;
            //barButtonItem14.Enabled = true;
        }
Esempio n. 11
0
        private void btnCompareToBinary_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // compare to other binary file(s)!
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Trionic 5 binary files|*.bin";
            ofd.Multiselect = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                if (ofd.FileNames.Length > 1)
                {
                    // bekijk het verschil voor alle geselecteerde bestanden en laat dit zien in een
                    // symbolcompareselector
                    DevExpress.XtraBars.Docking.DockPanel dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500));
                    CompareResultSelector tabdet = new CompareResultSelector();
                    tabdet.onFileSelect += new CompareResultSelector.NotifySelectFile(tabdet_onFileSelect);
                    tabdet.Dock = DockStyle.Fill;
                    dockPanel.Controls.Add(tabdet);
                    System.Data.DataTable dt = new System.Data.DataTable();
                    dt.Columns.Add("FILENAME");
                    dt.Columns.Add("PARTNUMBER");
                    dt.Columns.Add("SOFTWAREID");
                    dt.Columns.Add("NUMBEROFSYMBOLS", Type.GetType("System.Int32"));
                    dt.Columns.Add("FULLFILENAME");
                    int numberofsymbols = 0;

                    foreach (string filename in ofd.FileNames)
                    {
                        Trionic5Tools.SymbolCollection compSymbols = new Trionic5Tools.SymbolCollection();
                        AddressLookupCollection compAddressLookup = new AddressLookupCollection();

                        CompareSymbolTableToFile(filename, compSymbols, compAddressLookup, out numberofsymbols);
                        dt.Rows.Add(Path.GetFileName(filename), "", "", numberofsymbols, filename);
                    }
                    tabdet.SetData(dt);

                    dockPanel.Text = "Compare list: " + Path.GetFileName(m_trionicFileInformation.Filename);
                    bool isDocked = false;
                    foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                    {
                        if (pnl.Text.StartsWith("Compare list: ") && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                        {
                            dockPanel.DockAsTab(pnl, 0);
                            //pnl.Options.ShowCloseButton = false;
                            isDocked = true;
                            break;
                        }
                    }
                    if (!isDocked)
                    {
                        dockPanel.DockTo(dockManager1, DevExpress.XtraBars.Docking.DockingStyle.Left, 1);
                        dockPanel.Width = 700;
                    }

                }
                else if (ofd.FileNames.Length == 1)
                {
                    CompareToFile((string)ofd.FileNames.GetValue(0));
                }
            }
        }
Esempio n. 12
0
        private void btnCompareSRAMSnapshots_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // ask user to point out 2 SRAM files.
            OpenFileDialog ofd1 = new OpenFileDialog();

            ofd1.Title = "First SRAM dump...";
            ofd1.Filter = "SRAM dumps|*.ram";
            ofd1.Multiselect = false;
            if (ofd1.ShowDialog() == DialogResult.OK)
            {
                string filename_1 = ofd1.FileName;
                ofd1.Title = "Second SRAM dump...";
                if (ofd1.ShowDialog() == DialogResult.OK)
                {
                    string filename_2 = ofd1.FileName;
                    // now compare
                   // frmProgress progress = new frmProgress();
                   // progress.SetProgress("Analyzing SRAM dumps... stand by");
                  //  progress.Show();
                  //  System.Windows.Forms.Application.DoEvents();
                    System.Data.DataTable dt = new System.Data.DataTable();
                    dt.Columns.Add("SYMBOLNAME");
                    dt.Columns.Add("SRAMADDRESS", Type.GetType("System.Int32"));
                    dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32"));
                    dt.Columns.Add("LENGTHBYTES", Type.GetType("System.Int32"));
                    dt.Columns.Add("LENGTHVALUES", Type.GetType("System.Int32"));
                    dt.Columns.Add("DESCRIPTION");
                    dt.Columns.Add("ISCHANGED", Type.GetType("System.Boolean"));
                    dt.Columns.Add("CATEGORY", Type.GetType("System.Int32"));
                    dt.Columns.Add("DIFFPERCENTAGE", Type.GetType("System.Double"));
                    dt.Columns.Add("DIFFABSOLUTE", Type.GetType("System.Int32"));
                    dt.Columns.Add("DIFFAVERAGE", Type.GetType("System.Double"));
                    dt.Columns.Add("CATEGORYNAME");
                    dt.Columns.Add("SUBCATEGORYNAME");
                    int cnt = 0;
                    foreach (Trionic5Tools.SymbolHelper sh in m_trionicFileInformation.SymbolCollection)
                    {
                        int percentage = cnt * 100 / m_trionicFileInformation.SymbolCollection.Count;
                        cnt++;
                        SetTaskProgress(percentage, true);
                        byte[] data_1 = m_trionicFile.ReadDataFromFile(filename_1, (uint)sh.Start_address, (uint)sh.Length);
                        byte[] data_2 = m_trionicFile.ReadDataFromFile(filename_2, (uint)sh.Start_address, (uint)sh.Length);
                        if (data_1.Length != data_2.Length)
                        {
                            frmInfoBox info = new frmInfoBox("Sram data structure invalid... " + sh.Varname);
                            return;
                        }
                        else
                        {
                            double diffperc = 0;
                            int diffabs = 0;
                            double diffavg = 0;
                            bool isdifferent = false;
                            if (m_trionicFileInformation.isSixteenBitTable(sh.Varname))
                            {
                                for (int i = 0; i < data_1.Length; i += 2)
                                {
                                    try
                                    {
                                        int value1 = (int)(byte)data_1.GetValue(i) * 256;
                                        value1 += (int)(byte)data_1.GetValue(i + 1);
                                        int value2 = (int)(byte)data_2.GetValue(i) * 256;
                                        value2 += (int)(byte)data_2.GetValue(i + 1);
                                        if (value1 != value2)
                                        {
                                            isdifferent = true;
                                            diffabs++;
                                        }
                                    }
                                    catch (Exception E)
                                    {
                                        Console.WriteLine(E.Message);
                                    }
                                }
                            }
                            else
                            {
                                for (int i = 0; i < data_1.Length; i++)
                                {
                                    if ((byte)data_1.GetValue(i) != (byte)data_2.GetValue(i))
                                    {
                                        isdifferent = true;
                                        diffabs++;
                                    }
                                }
                            }
                            if (isdifferent)
                            {
                                int lengthvalues = sh.Length;
                                if (m_trionicFileInformation.isSixteenBitTable(sh.Varname)) lengthvalues /= 2;
                                diffperc = (diffabs * 100) / lengthvalues;
                                dt.Rows.Add(sh.Varname, sh.Start_address, sh.Flash_start_address, sh.Length, lengthvalues, sh.Helptext, false, (int)sh.Category, diffperc, diffabs, diffavg, sh.Category.ToString().Replace("_", " "), sh.Subcategory.ToString().Replace("_", " "));
                            }
                        }

                    }
                    Trionic5Tools.SymbolCollection compSymbols = new Trionic5Tools.SymbolCollection();
                    AddressLookupCollection compAddressLookup = new AddressLookupCollection();
                    dockManager1.BeginUpdate();
                    try
                    {
                        DevExpress.XtraBars.Docking.DockPanel dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500));
                        SRAMCompareResults tabdet = new SRAMCompareResults();
                        tabdet.Dock = DockStyle.Fill;
                        tabdet.Filename1 = filename_1;
                        tabdet.Filename2 = filename_2;
                        tabdet.onSRAMSymbolSelect += new SRAMCompareResults.NotifySRAMSelectSymbol(tabdet_onSRAMSymbolSelect);
                        dockPanel.Controls.Add(tabdet);
                        //dockPanel.DockAsTab(dockPanel1);
                        dockPanel.Text = "SRAM compare results: " + Path.GetFileName(filename_1) + " " + Path.GetFileName(filename_2);
                        bool isDocked = false;
                        foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                        {
                            if (pnl.Text.StartsWith("SRAM compare results: ") && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                            {
                                dockPanel.DockAsTab(pnl, 0);
                                isDocked = true;
                                break;
                            }
                        }
                        if (!isDocked)
                        {
                            dockPanel.DockTo(dockManager1, DevExpress.XtraBars.Docking.DockingStyle.Left, 1);
                            dockPanel.Width = 700;
                        }
                        //CompareSymbolTable(filename, compSymbols, compAddressLookup, tabdet.gridControl1);
                        tabdet.gridControl1.DataSource = dt;
                        //tabdet.CompareTrionic5Tools.SymbolCollection = compSymbols;
                        //tabdet.CompareAddressLookupCollection = compAddressLookup;
                        tabdet.OpenGridViewGroups(tabdet.gridControl1, 1);
                    }
                    catch (Exception E)
                    {
                        Console.WriteLine(E.Message);
                    }
                    dockManager1.EndUpdate();
                    SetStatusText("SRAM compare done");
                    SetTaskProgress(0, false);

                }
            }
        }
Esempio n. 13
0
        private void StartCompareMapViewer(string SymbolName, string Filename, int SymbolAddress, int SymbolLength, Trionic5Tools.SymbolCollection curSymbols, AddressLookupCollection curAddresses, Trionic5File curFile, Trionic5FileInformation curFileInfo)
        {
            try
            {
                DevExpress.XtraBars.Docking.DockPanel dockPanel;
                bool pnlfound = false;
                foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                {

                    if (pnl.Text == "Symbol: " + SymbolName + " [" + Path.GetFileName(Filename) + "]")
                    {
                        dockPanel = pnl;
                        pnlfound = true;
                        dockPanel.Show();
                        // nog data verversen?
                    }
                }
                if (!pnlfound)
                {
                    dockManager1.BeginUpdate();
                    try
                    {
                        dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500));
                        dockPanel.Tag = Filename;// m_trionicFile.GetFileInfo().Filename; changed 24/01/2008
                        //IMapViewer tabdet = new MapViewerEx();
                        IMapViewer tabdet;

                        if (m_appSettings.MapViewerType == MapviewerType.Fancy)
                        {
                            tabdet = new MapViewerEx();
                        }
                        else if (m_appSettings.MapViewerType == MapviewerType.Normal)
                        {
                            tabdet = new MapViewer();
                        }
                        else
                        {
                            tabdet = new SimpleMapViewer();
                        }
                        tabdet.AutoUpdateChecksum = m_appSettings.AutoChecksum;
                        tabdet.GraphVisible = m_appSettings.ShowGraphs;
                       // TryTpShowTouchScreenInput();

                        //tabdet.DirectSRAMWriteOnSymbolChange = m_appSettings.DirectSRAMWriteOnSymbolChange;
                       // tabdet.SetViewSize(m_appSettings.DefaultViewSize);

                        //tabdet.IsHexMode = barViewInHex.Checked;
                        tabdet.Viewtype = (Trionic5Tools.ViewType)m_appSettings.DefaultViewType;
                        if (curFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor25)
                        {
                            if (m_appSettings.DefaultViewType == ViewType.Decimal)
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Decimal;
                            }
                            else
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Easy;
                            }
                        }
                        else if (curFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor30)
                        {
                            if (m_appSettings.DefaultViewType == ViewType.Decimal)
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Decimal3Bar;
                            }
                            else
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Easy3Bar;
                            }
                        }
                        else if (curFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor35)
                        {
                            if (m_appSettings.DefaultViewType == ViewType.Decimal)
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Decimal35Bar;
                            }
                            else
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Easy35Bar;
                            }
                        }
                        else if (curFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor40)
                        {
                            if (m_appSettings.DefaultViewType == ViewType.Decimal)
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Decimal4Bar;
                            }
                            else
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Easy4Bar;
                            }
                        }
                        else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor50)
                        {
                            if (m_appSettings.DefaultViewType == ViewType.Decimal)
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Decimal5Bar;
                            }
                            else
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Easy5Bar;
                            }
                        }
                        //tabdet.DisableColors = m_appSettings.DisableMapviewerColors;
                        //tabdet.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows;
                        //tabdet.GraphVisible = m_appSettings.ShowGraphs;
                        //tabdet.IsRedWhite = m_appSettings.ShowRedWhite;
                        tabdet.Filename = Filename;
                        tabdet.Map_name = SymbolName;

                        tabdet.Map_descr = m_trionicFileInformation.GetSymbolDescription(tabdet.Map_name);
                        tabdet.Map_cat = m_trionicFileInformation.GetSymbolCategory(tabdet.Map_name);
                        tabdet.X_axisvalues = curFile.GetMapXaxisValues(tabdet.Map_name);
                        tabdet.Y_axisvalues = curFile.GetMapYaxisValues(tabdet.Map_name);
                        string xdescr = string.Empty;
                        string ydescr = string.Empty;
                        string zdescr = string.Empty;
                        // van compare file halen?
                        curFile.GetMapAxisDescriptions(tabdet.Map_name, out xdescr, out ydescr, out zdescr);
                        tabdet.X_axis_name = xdescr;
                        tabdet.Y_axis_name = ydescr;
                        tabdet.Z_axis_name = zdescr;

                        //tabdet.Map_sramaddress = GetSymbolAddressSRAM(SymbolName);
                        int columns = 8;
                        int rows = 8;

                        int tablewidth = curFile.GetTableMatrixWitdhByName(Filename, tabdet.Map_name, out columns, out rows);
                        int address = Convert.ToInt32(SymbolAddress);
                        if (address != 0)
                        {
                            while (address > curFileInfo.Filelength) address -= curFileInfo.Filelength;
                            tabdet.Map_address = address;
                            int length = SymbolLength;
                            tabdet.Map_length = length;
                            byte[] mapdata = curFile.ReadData((uint)address, (uint)length);
                            tabdet.Map_content = mapdata;
                            tabdet.Correction_factor = curFile.GetCorrectionFactorForMap(tabdet.Map_name);
                            tabdet.Correction_offset = curFile.GetOffsetForMap(tabdet.Map_name);
                            tabdet.IsUpsideDown = true;
                            tabdet.ShowTable(columns, curFile.GetFileInfo().isSixteenBitTable(SymbolName));
                            tabdet.Dock = DockStyle.Fill;
                            //tabdet.onSymbolSave += new MapViewer.NotifySaveSymbol(tabdet_onSymbolSave);
                            tabdet.onClose += new IMapViewer.ViewerClose(OnCloseMapViewer);
                            tabdet.onAxisEditorRequested += new IMapViewer.AxisEditorRequested(mv_onAxisEditorRequested);
                            //tabdet.onAxisLock += new MapViewer.NotifyAxisLock(tabdet_onAxisLock);
                            //tabdet.onSliderMove += new MapViewer.NotifySliderMove(tabdet_onSliderMove);
                            tabdet.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged);
                            tabdet.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx);
                            tabdet.onCellLocked += new IMapViewer.CellLocked(mv_onCellLocked);

                            //tabdet.onSplitterMoved += new MapViewer.SplitterMoved(tabdet_onSplitterMoved);
                            //tabdet.onSurfaceGraphViewChanged += new MapViewer.SurfaceGraphViewChanged(tabdet_onSurfaceGraphViewChanged);
                            //tabdet.onGraphSelectionChanged += new MapViewer.GraphSelectionChanged(tabdet_onGraphSelectionChanged);
                            //tabdet.onViewTypeChanged += new MapViewer.ViewTypeChanged(tabdet_onViewTypeChanged);

                            tabdet.SetViewSize((Trionic5Tools.ViewSize)m_appSettings.DefaultViewSize);
                            //dockPanel.DockAsTab(dockPanel1);
                            //dockPanel.Text = "Symbol: " + SymbolName + " [" + Filename + "]";
                            dockPanel.Text = Path.GetFileName(Filename) + " [" + SymbolName + "]";

                            bool isDocked = false;
                            if (m_appSettings.AutoDockSameSymbol)
                            {
                                foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                                {
                                    if (pnl.Text.Contains("[" + SymbolName +"]") && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                                    {
                                        dockPanel.DockAsTab(pnl, 0);
                                        //pnl.Options.ShowCloseButton = false;
                                        isDocked = true;
                                        break;
                                    }
                                }
                            }
                            if (!isDocked)
                            {
                                if (m_appSettings.AutoDockSameFile)
                                {
                                    foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                                    {
                                        if ((string)pnl.Tag == m_trionicFileInformation.Filename && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                                        {
                                            dockPanel.DockAsTab(pnl, 0);
                                            //pnl.Options.ShowCloseButton = false;
                                            isDocked = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (!isDocked)
                            {
                                dockPanel.DockTo(dockManager1, DevExpress.XtraBars.Docking.DockingStyle.Right, 0);
                                if (m_appSettings.AutoSizeNewWindows)
                                {
                                    if (tabdet.X_axisvalues.Length > 0)
                                    {
                                        dockPanel.Width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                                    }
                                    else
                                    {
                                        //dockPanel.Width = this.Width - dockSymbols.Width - 10;

                                    }
                                }
                                if (dockPanel.Width < 400) dockPanel.Width = 400;
                                //                    dockPanel.Width = 400;
                            }
                            tabdet.InitEditValues();
                            dockPanel.Controls.Add(tabdet);

                        }

                    }
                    catch (Exception E)
                    {
                        Console.WriteLine(E.Message);
                    }
                    dockManager1.EndUpdate();
                }

            }
            catch (Exception startnewcompareE)
            {
                Console.WriteLine(startnewcompareE.Message);
            }
        }
Esempio n. 14
0
 public Trionic5FileInformation()
 {
     m_SymbolCollection  = new SymbolCollection();
     m_AddressCollection = new AddressLookupCollection();
 }