Exemple #1
0
        private void Actions_btnCompareSRAMSnapshots_ItemClick(object sender, 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
                    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")); //0
                    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");
                    dt.Columns.Add("SymbolNumber1", Type.GetType("System.Int32"));
                    dt.Columns.Add("SymbolNumber2", Type.GetType("System.Int32"));
                    dt.Columns.Add("Userdescription");
                    int cnt = 0;
                    frmProgress progress = new frmProgress();
                    progress.SetProgress("Comparing SRAM snapshots");
                    progress.Show();
                    foreach (SymbolHelper sh in m_symbols)
                    {
                        int percentage = cnt * 100 / m_symbols.Count;
                        cnt++;
                        progress.SetProgressPercentage(percentage);
                        //SetTaskProgress(percentage, true);
                        string symbolname = sh.Varname;
                        if (symbolname.StartsWith("Symbol:")) symbolname = sh.Userdescription;
                        if (IsSymbolCalibration(symbolname))
                        {

                            byte[] data_1 = readdatafromSRAMfile(filename_1, (int)sh.Start_address, (int)sh.Length);
                            byte[] data_2 = readdatafromSRAMfile(filename_2, (int)sh.Start_address, (int)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 (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)
                                        {
                                            logger.Debug(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 (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.Description, false, 0, diffperc, diffabs, diffavg, sh.Category.ToString().Replace("_", " "), sh.Subcategory.ToString().Replace("_", " "), sh.Symbol_number, sh.Symbol_number, sh.Userdescription);
                                }
                            }
                        }

                    }
                    progress.Close();
                    SymbolCollection compSymbols = new SymbolCollection();
                    //AddressLookupCollection compAddressLookup = new AddressLookupCollection();
                    dockManager1.BeginUpdate();
                    try
                    {
                        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 (DockPanel pnl in dockManager1.Panels)
                        {
                            if (pnl.Text.StartsWith("SRAM compare results: ") && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible))
                            {
                                dockPanel.DockAsTab(pnl, 0);
                                isDocked = true;
                                break;
                            }
                        }
                        if (!isDocked)
                        {
                            dockPanel.DockTo(dockManager1, 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)
                    {
                        logger.Debug(E.Message);
                    }
                    dockManager1.EndUpdate();
                    SetStatusText("SRAM compare done");
                    //SetTaskProgress(0, false);

                }
            }
        }
Exemple #2
0
 void tabdet_onSRAMSymbolSelect(object sender, SRAMCompareResults.SelectSRAMSymbolEventArgs e)
 {
     if (!e.ShowDiffMap)
     {
         //StartTableViewer(e.SymbolName);
         StartSRAMTableViewer(e.Filename1, e.SymbolName, e.SymbolLength, (int)GetSymbolAddress(m_symbols, e.SymbolName), (int)GetSymbolAddressSRAM(m_symbols, e.SymbolName));
         StartSRAMTableViewer(e.Filename2, e.SymbolName, e.SymbolLength, (int)GetSymbolAddress(m_symbols, e.SymbolName), (int)GetSymbolAddressSRAM(m_symbols, e.SymbolName));
     }
     else
     {
         //Implement this viewer type in 2.0
         StartSRAMCompareDifferenceViewer(e.SymbolName, e.Filename1, e.Filename2, e.SymbolLength, (int)GetSymbolAddressSRAM(m_symbols, e.SymbolName), "");
     }
 }