コード例 #1
0
ファイル: AsmViewer.cs プロジェクト: Meindert66/T8SuitePro
        internal void LoadDataFromFile(string filename, SymbolCollection m_symbols)
        {
            richTextBox1.LoadFile(filename, RichTextBoxStreamType.RichText);

            //richTextBox1.LoadFile(filename, RichTextBoxStreamType.PlainText);
            /*string totaltext = string.Empty;

            int linecount = 0;
            using (StreamReader sr = new StreamReader(filename))
            {
                using (StreamWriter sw = new StreamWriter(Application.StartupPath + "\\temp.asm", false))
                {
                    sw.Write(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fswiss\fcharset0 Courier new;}}{\colortbl ;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;}{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\lang1033\f0\fs20 ");
                    string line = string.Empty;
                    while ((line = sr.ReadLine()) != null)
                    {
                        sw.WriteLine(HighlightText(line) + @"\par");
                        linecount++;
                        //if (linecount == 1000) break;
                    }
                    sw.Write(@"\lang1043\par}");
                }
            }
            richTextBox1.LoadFile(Application.StartupPath + "\\temp.asm");*/
            //richTextBox1.Text = totaltext;
        }
コード例 #2
0
        public void ExportPackage(SymbolCollection sc, string filename, string packagefilename)
        {
            if (File.Exists(packagefilename)) File.Delete(packagefilename);

            foreach (SymbolHelper sh in sc)
            {
                if (sh.Flash_start_address - m_AddressOffset > 0 && sh.Flash_start_address - m_AddressOffset < 0x80000)
                {

                    byte[] data = readdatafromfile(filename, (int)sh.Flash_start_address - m_AddressOffset, sh.Length);
                    // if the symbol contains data... use that
                    if (sh.Currentdata != null)
                    {
                        if (sh.Length > 0) data = sh.Currentdata;
                    }
                    ExportMap(packagefilename, sh.Varname, sh.Userdescription, sh.Length, data);
                }
                else if (sh.Flash_start_address  > 0 && sh.Flash_start_address  < 0x80000)
                {

                    byte[] data = readdatafromfile(filename, (int)sh.Flash_start_address , sh.Length);
                    // if the symbol contains data... use that
                    if (sh.Currentdata != null)
                    {
                        if (sh.Length > 0) data = sh.Currentdata;
                    }
                    ExportMap(packagefilename, sh.Varname, sh.Userdescription, sh.Length, data);
                }
            }
        }
コード例 #3
0
        public void ExportPackage(SymbolCollection sc, string filename, string packagefilename)
        {
            if (File.Exists(packagefilename)) File.Delete(packagefilename);

            foreach (SymbolHelper sh in sc)
            {
                if (sh.Flash_start_address > 0 && sh.Flash_start_address < 0x100000)
                {
                    byte[] data = readdatafromfile(filename, (int)sh.Flash_start_address, sh.Length);
                    ExportMap(packagefilename, sh.Varname, sh.Userdescription, sh.Length, data);
                }
            }
        }
コード例 #4
0
 public void SetSymbolList(SymbolCollection sc)
 {
     lookUpEdit1.Properties.DisplayMember = "Varname";
     lookUpEdit1.Properties.ValueMember = "Varname";
     lookUpEdit2.Properties.DisplayMember = "Varname";
     lookUpEdit2.Properties.ValueMember = "Varname";
     lookUpEdit3.Properties.DisplayMember = "Varname";
     lookUpEdit3.Properties.ValueMember = "Varname";
     lookUpEdit1.Properties.DataSource = sc;
     lookUpEdit2.Properties.DataSource = sc;
     lookUpEdit3.Properties.DataSource = sc;
     _symbols = sc;
 }
コード例 #5
0
 public void SetSymbolList(SymbolCollection sc)
 {
     lookUpEdit1.Properties.DisplayMember = "Varname";
     lookUpEdit1.Properties.ValueMember   = "Varname";
     lookUpEdit2.Properties.DisplayMember = "Varname";
     lookUpEdit2.Properties.ValueMember   = "Varname";
     lookUpEdit3.Properties.DisplayMember = "Varname";
     lookUpEdit3.Properties.ValueMember   = "Varname";
     lookUpEdit1.Properties.DataSource    = sc;
     lookUpEdit2.Properties.DataSource    = sc;
     lookUpEdit3.Properties.DataSource    = sc;
     _symbols = sc;
 }
コード例 #6
0
ファイル: AxisBrowser.cs プロジェクト: ChrisPea/TuningSuites
        public void ShowSymbolCollection(SymbolCollection sc)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("SYMBOLNAME");
            dt.Columns.Add("DESCRIPTION");
            dt.Columns.Add("XAXIS");
            dt.Columns.Add("XAXISDESCRIPTION");
            dt.Columns.Add("YAXIS");
            dt.Columns.Add("YAXISDESCRIPTION");
            SymbolAxesTranslator sat = new SymbolAxesTranslator();

            SymbolTranslator symtrans = new SymbolTranslator();
            string helptext = string.Empty;
            XDFCategories cat = XDFCategories.Undocumented;
            XDFSubCategory subcat = XDFSubCategory.Undocumented;
            string xaxis = string.Empty;
            string yaxis = string.Empty;
            string xaxisdescr = "";
            string yaxisdescr = "";
            string zaxisdescr = "";
            foreach (SymbolHelper sh in sc)
            {
                string name = sh.Varname;
                if (sh.Userdescription != "" && sh.Userdescription != String.Format("Symbolnumber {0}", sh.Symbol_number))
                {
                    name = sh.Userdescription;
                }

                sat.GetAxisSymbols(name, out xaxis, out yaxis, out xaxisdescr, out yaxisdescr, out zaxisdescr);
                string symboldescr = symtrans.TranslateSymbolToHelpText(name, out helptext, out cat, out subcat, m_ApplicationLanguage);
                if (xaxis != "")
                {
                    xaxisdescr = symtrans.TranslateSymbolToHelpText(xaxis, out helptext, out cat, out subcat, m_ApplicationLanguage);
                }
                if (yaxis != "")
                {
                    yaxisdescr = symtrans.TranslateSymbolToHelpText(yaxis, out helptext, out cat, out subcat, m_ApplicationLanguage);
                }
                if (xaxis != "" || yaxis != "")
                {
                    dt.Rows.Add(name, symboldescr, xaxis, xaxisdescr, yaxis, yaxisdescr);
                }
            }
            gridControl1.DataSource = dt;
        }
コード例 #7
0
        public SymbolCollection GetSelectedSymbolCollection()
        {
            // build a new collection based on the selected rows
            SymbolCollection scSelected = new SymbolCollection();
            if (gridControl1.DataSource != null)
            {
                //DataTable dt = (DataTable)gridControl1.DataSource;

                int[] selrows = gridView1.GetSelectedRows();
                foreach (int rowhandle in selrows)
                {
                    SymbolHelper sh = (SymbolHelper)gridView1.GetRow(rowhandle);
                    if (sh != null)
                    {
                        scSelected.Add(sh);
                    }
                }
            }
            return scSelected;
        }
コード例 #8
0
        public SymbolCollection GetSelectedSymbolCollection()
        {
            // build a new collection based on the selected rows
            SymbolCollection scSelected = new SymbolCollection();

            if (gridControl1.DataSource != null)
            {
                //DataTable dt = (DataTable)gridControl1.DataSource;


                int[] selrows = gridView1.GetSelectedRows();
                foreach (int rowhandle in selrows)
                {
                    SymbolHelper sh = (SymbolHelper)gridView1.GetRow(rowhandle);
                    if (sh != null)
                    {
                        scSelected.Add(sh);
                    }
                }
            }
            return(scSelected);
        }
コード例 #9
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private void exportAsTuningPackageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // export selected maps as tuning package (name the file t7p)
            // get selected rows
            int[] selectedrows = gridViewSymbols.GetSelectedRows();
            SymbolCollection scToExport = new SymbolCollection();
            if (selectedrows.Length > 0)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = "Trionic 7 packages|*.t7p";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    int grouplevel = gridViewSymbols.GetRowLevel((int)selectedrows.GetValue(0));
                    if (grouplevel >= gridViewSymbols.GroupCount)
                    {
                        int[] selrows = gridViewSymbols.GetSelectedRows();
                        if (selrows.Length > 0)
                        {
                            for (int i = 0; i < selrows.Length; i++)
                            {
                                SymbolHelper sh = (SymbolHelper)gridViewSymbols.GetRow((int)selrows.GetValue(i));
                                // make a copy?
                                scToExport.Add(sh);
                            }

                            PackageExporter pe = new PackageExporter();
                            if (IsSoftwareOpen())
                            {
                                pe.AddressOffset = GetOpenFileOffset();
                            }
                            pe.ExportPackage(scToExport, m_currentfile, sfd.FileName);
                        }

                    }
                }

            }
        }
コード例 #10
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        void edit_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (sender is frmEditTuningPackage)
            {
                frmEditTuningPackage edit = (frmEditTuningPackage)sender;
                if (edit.WriteData)
                {
                    // save the package again with altered settings probably.
                    logger.Debug("We should write the tuning package here!");
                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.Filter = "Trionic 7 packages|*.t7p";
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        System.Data.DataTable dt = edit.GetDataTable();
                        SymbolCollection scToExport = new SymbolCollection();
                        foreach (DataRow dr in dt.Rows)
                        {
                            SymbolHelper sh = new SymbolHelper();
                            sh.Varname = dr["Map"].ToString();
                            sh.Currentdata = ConvertTuningPackageDataToByteArray(dr["Data"].ToString());
                            sh.Flash_start_address = GetSymbolAddress(m_symbols, sh.Varname);
                            sh.Userdescription = GetUserDescription(m_symbols, sh.Varname);
                            sh.Length = GetSymbolLength(m_symbols, sh.Varname);
                            scToExport.Add(sh);

                        }
                        PackageExporter pe = new PackageExporter();
                        if (IsSoftwareOpen())
                        {
                            pe.AddressOffset = GetOpenFileOffset();
                        }
                        pe.ExportPackage(scToExport, m_currentfile, sfd.FileName);
                    }
                }
            }
            tunpackeditWindow = null;
        }
コード例 #11
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private void ConvertFileToDif(string filename, bool AutoExport)
        {
            System.Windows.Forms.Application.DoEvents();
            DateTime startDate = DateTime.MaxValue;
            DateTime endDate = DateTime.MinValue;
            try
            {
                SymbolCollection sc = new SymbolCollection();
                string[] alllines = File.ReadAllLines(filename);
                //using (StreamReader sr = new StreamReader(filename))
                {
                    //string line = string.Empty;
                    char[] sep = new char[1];
                    char[] sep2 = new char[1];
                    //int linecount = 0;
                    sep.SetValue('|', 0);
                    sep2.SetValue('=', 0);
                    //while ((line = sr.ReadLine()) != null)

                    foreach(string line in alllines)
                    {
                        string[] values = line.Split(sep);
                        if (values.Length > 0)
                        {
                            try
                            {
                                //dd/MM/yyyy HH:mm:ss
                                //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                string dtstring = (string)values.GetValue(0);
                                DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                if (dt > endDate) endDate = dt;
                                if (dt < startDate) startDate = dt;
                                for (int t = 1; t < values.Length; t++)
                                {
                                    string subvalue = (string)values.GetValue(t);
                                    string[] subvals = subvalue.Split(sep2);
                                    if (subvals.Length == 2)
                                    {
                                        string varname = (string)subvals.GetValue(0);
                                        bool sfound = false;
                                        foreach (SymbolHelper sh in sc)
                                        {
                                            if (sh.Varname == varname || sh.Userdescription == varname)
                                            {
                                                sfound = true;
                                            }
                                        }
                                        SymbolHelper nsh = new SymbolHelper();
                                        nsh.Varname = varname;
                                        if (!sfound) sc.Add(nsh);
                                    }
                                }
                            }
                            catch (Exception pE)
                            {
                                logger.Debug(pE.Message);
                            }
                        }
                    }
                }

                if (AutoExport)
                {
                    foreach (SymbolHelper sh in sc)
                    {
                        sh.Color = GetColorFromRegistry(sh.Varname);
                    }
                    DifGenerator difgen = new DifGenerator();
                    difgen.AppSettings = m_appSettings;

                    //difgen.LowAFR = m_appSettings.WidebandLowAFR;
                    //difgen.HighAFR = m_appSettings.WidebandHighAFR;
                    //difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage;
                    //difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage;
                    difgen.WidebandSymbol = m_appSettings.WideBandSymbol;
                    //difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol;
                    difgen.UseWidebandInput = false;

                    difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress);
                    frmProgressLogWorks = new frmProgress();
                    frmProgressLogWorks.SetProgress("Exporting to LogWorks");
                    frmProgressLogWorks.Show();
                    System.Windows.Forms.Application.DoEvents();
                    try
                    {
                        difgen.ConvertFileToDif(filename, sc, startDate, endDate, m_appSettings.InterpolateLogWorksTimescale, m_appSettings.InterpolateLogWorksTimescale);
                    }
                    catch (Exception expE1)
                    {
                        logger.Debug(expE1.Message);
                    }
                    frmProgressLogWorks.Close();
                }
                else
                {

                    // show selection screen
                    frmPlotSelection plotsel = new frmPlotSelection();
                    foreach (SymbolHelper sh in sc)
                    {
                        plotsel.AddItemToList(sh.Varname);
                    }
                    plotsel.Startdate = startDate;
                    plotsel.Enddate = endDate;
                    plotsel.SelectAllSymbols();
                    if (plotsel.ShowDialog() == DialogResult.OK)
                    {
                        sc = plotsel.Sc;
                        endDate = plotsel.Enddate;
                        startDate = plotsel.Startdate;
                        DifGenerator difgen = new DifGenerator();
                        LogFilters filterhelper = new LogFilters();
                        difgen.SetFilters(filterhelper.GetFiltersFromRegistry());
                        difgen.AppSettings = m_appSettings;
                        //difgen.LowAFR = m_appSettings.WidebandLowAFR;
                        //difgen.HighAFR = m_appSettings.WidebandHighAFR;
                        //difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage;
                        //difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage;
                        difgen.WidebandSymbol = m_appSettings.WideBandSymbol;
                        //difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol;
                        difgen.UseWidebandInput = false;

                        difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress);
                        frmProgressLogWorks = new frmProgress();
                        frmProgressLogWorks.SetProgress("Exporting to LogWorks");
                        frmProgressLogWorks.Show();
                        System.Windows.Forms.Application.DoEvents();
                        try
                        {
                            if (difgen.ConvertFileToDif(filename, sc, startDate, endDate, m_appSettings.InterpolateLogWorksTimescale, m_appSettings.InterpolateLogWorksTimescale))
                            {
                                StartLogWorksWithCurrentFile(Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".dif");
                            }
                            else
                            {
                                frmInfoBox info = new frmInfoBox("No data was found to export!");
                            }
                        }
                        catch (Exception expE2)
                        {
                            logger.Debug(expE2.Message);
                        }
                        frmProgressLogWorks.Close();
                    }
                    TimeSpan ts = new TimeSpan(endDate.Ticks - startDate.Ticks);
                    //MessageBox.Show("LogFile should be " + ts.ToString());
                }
            }
            catch (Exception E)
            {
                logger.Debug(E.Message);
            }
        }
コード例 #12
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private void CompareToFile(string filename)
        {
            if (m_symbols.Count > 0)
            {
                dockManager1.BeginUpdate();
                try
                {
                    DockPanel dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500));
                    CompareResults tabdet = new CompareResults();
                    tabdet.ShowAddressesInHex = m_appSettings.ShowAddressesInHex;
                    tabdet.SetFilterMode(m_appSettings.ShowAddressesInHex);
                    tabdet.Dock = DockStyle.Fill;
                    tabdet.Filename = filename;
                    tabdet.onSymbolSelect += new CompareResults.NotifySelectSymbol(tabdet_onSymbolSelect);
                    dockPanel.Controls.Add(tabdet);
                    dockPanel.Text = "Compare results: " + Path.GetFileName(filename);
                    dockPanel.DockTo(dockManager1, DockingStyle.Left, 1);

                    dockPanel.Width = 700;

                    SymbolCollection compare_symbols = new SymbolCollection();
                    FileInfo fi = new FileInfo(filename);
                    Trionic7File compareFile = TryToOpenFileUsingClass(filename, out compare_symbols, (int)fi.Length, false);
                    barProgress.EditValue = 60;
                    barProgress.Caption = "Loading header";
                    System.Windows.Forms.Application.DoEvents();

                    T7FileHeader t7fh = new T7FileHeader();
                    t7fh.init(filename, false);
                    int m_sramOffset = ReverseInt(t7fh.Unknown_9cvalue);
                    if (m_sramOffset == 0) m_sramOffset = compareFile.SramOffsetForOpenFile;
                    if (m_sramOffset == 0) m_sramOffset = 0xEFFC04;
                    barProgress.EditValue = 90;
                    barProgress.Caption = "Starting compare";
                    System.Windows.Forms.Application.DoEvents();

                    System.Windows.Forms.Application.DoEvents();
                    barProgress.Visibility = BarItemVisibility.Always;
                    barProgress.Caption = "Comparing symbols in files...";
                    barProgress.EditValue = 0;
                    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")); //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");
                    dt.Columns.Add("MissingInOriFile", Type.GetType("System.Boolean"));
                    dt.Columns.Add("MissingInCompareFile", Type.GetType("System.Boolean"));
                    string category = "";
                    string ht = string.Empty;
                    double diffperc = 0;
                    int diffabs = 0;
                    double diffavg = 0;
                    int percentageDone = 0;
                    int symNumber = 0;
                    XDFCategories cat = XDFCategories.Undocumented;
                    XDFSubCategory subcat = XDFSubCategory.Undocumented;
                    if (compare_symbols.Count > 0)
                    {
                        CompareResults cr = new CompareResults();
                        cr.ShowAddressesInHex = m_appSettings.ShowAddressesInHex;
                        cr.SetFilterMode(m_appSettings.ShowAddressesInHex);
                        SymbolTranslator st = new SymbolTranslator();
                        Int64 compareStartAddress = 0;
                        Int64 orgStartAddress = 0;
                        foreach (SymbolHelper sh_compare in compare_symbols)
                        {
                            try
                            {
                                symNumber++;
                                percentageDone = (symNumber * 50) / compare_symbols.Count;
                                if (Convert.ToInt32(barProgress.EditValue) != percentageDone)
                                {
                                    barProgress.EditValue = percentageDone;
                                    System.Windows.Forms.Application.DoEvents();
                                }
                            }
                            catch (Exception E)
                            {
                                logger.Debug(E.Message);
                            }

                            string compareName = sh_compare.Varname;
                            if (compareName.StartsWith("Symbolnumber")) compareName = sh_compare.Userdescription;

                            compareStartAddress = sh_compare.Flash_start_address;
                            if (IsSoftwareOpen(compare_symbols))
                            {
                                // get address
                                if (IsSymbolCalibration(compareName) && sh_compare.Length < 0x400 && sh_compare.Flash_start_address > m_currentfile_size)
                                {
                                    compareStartAddress = sh_compare.Flash_start_address - m_sramOffset;
                                }
                            }

                            foreach (SymbolHelper sh_org in m_symbols)
                            {
                                string originalName = sh_org.Varname;
                                if (originalName.StartsWith("Symbolnumber")) originalName = sh_org.Userdescription;

                                if (compareName.Equals(originalName) && compareName != String.Empty)
                                {
                                    if (compareStartAddress > 0 && compareStartAddress < 0x80000)
                                    {
                                        orgStartAddress = (int)GetSymbolAddress(m_symbols, sh_org.Varname);
                                        if (orgStartAddress > 0 && orgStartAddress < 0x80000)
                                        {
                                            if (!CompareSymbolToCurrentFile(compareName, (int)compareStartAddress, sh_compare.Length, filename, out diffperc, out diffabs, out diffavg))
                                            {
                                                category = "";
                                                if (sh_org.Varname.Contains("."))
                                                {
                                                    try
                                                    {
                                                        category = sh_org.Varname.Substring(0, sh_org.Varname.IndexOf("."));
                                                    }
                                                    catch (Exception cE)
                                                    {
                                                        logger.Debug("Failed to assign category to symbol: " + sh_org.Varname + " err: " + cE.Message);
                                                    }
                                                }
                                                else if (sh_org.Userdescription.Contains("."))
                                                {
                                                    try
                                                    {
                                                        category = sh_org.Userdescription.Substring(0, sh_org.Userdescription.IndexOf("."));
                                                    }
                                                    catch (Exception cE)
                                                    {
                                                        logger.Debug("Failed to assign category to symbol: " + sh_org.Userdescription + " err: " + cE.Message);
                                                    }
                                                }

                                                dt.Rows.Add(sh_compare.Varname, sh_compare.Start_address, compareStartAddress, sh_compare.Length, sh_compare.Length, st.TranslateSymbolToHelpText(sh_compare.Varname, out ht, out cat, out subcat, m_appSettings.ApplicationLanguage), false, 0, diffperc, diffabs, diffavg, category, "", sh_org.Symbol_number, sh_compare.Symbol_number, sh_org.Userdescription, false, false);
                                            }
                                        }
                                    }
                                    break;
                                }
                            }
                        }

                        symNumber = 0;
                        string varnameori = string.Empty;
                        string varnamecomp = string.Empty;
                        foreach (SymbolHelper shtest in compare_symbols)
                        {
                            try
                            {
                                symNumber++;
                                percentageDone = 50 + (symNumber * 25) / compare_symbols.Count;
                                if (Convert.ToInt32(barProgress.EditValue) != percentageDone)
                                {
                                    barProgress.EditValue = percentageDone;
                                    System.Windows.Forms.Application.DoEvents();
                                }
                            }
                            catch (Exception E)
                            {
                                logger.Debug(E.Message);
                            }
                            bool _foundSymbol = false;
                            varnamecomp = shtest.Varname;
                            if (varnamecomp.StartsWith("Symbolnumber")) varnamecomp = shtest.Userdescription;
                            if (IsSymbolCalibration(varnamecomp))
                            {
                                foreach (SymbolHelper shoritest in m_symbols)
                                {
                                    varnameori = shoritest.Varname;
                                    if (varnameori.StartsWith("Symbolnumber")) varnameori = shoritest.Userdescription;

                                    if (varnamecomp == varnameori)
                                    {
                                        _foundSymbol = true;
                                        break;
                                    }
                                }
                                if (!_foundSymbol)
                                {
                                    // add this symbol to the MissingInOriCollection
                                    dt.Rows.Add(varnamecomp, shtest.Start_address, shtest.Flash_start_address, shtest.Length, shtest.Length, st.TranslateSymbolToHelpText(varnamecomp, out ht, out cat, out subcat, m_appSettings.ApplicationLanguage), false, 0, 0, 0, 0, "Missing in original", "", 0, shtest.Symbol_number, shtest.Userdescription, true, false);
                                }
                            }
                        }
                        symNumber = 0;
                        foreach (SymbolHelper shtest in m_symbols)
                        {
                            try
                            {
                                symNumber++;
                                percentageDone = 75 + (symNumber * 25) / compare_symbols.Count;
                                if (Convert.ToInt32(barProgress.EditValue) != percentageDone)
                                {
                                    barProgress.EditValue = percentageDone;
                                    System.Windows.Forms.Application.DoEvents();
                                }
                            }
                            catch (Exception E)
                            {
                                logger.Debug(E.Message);
                            }
                            bool _foundSymbol = false;
                            varnamecomp = shtest.Varname;
                            if (varnamecomp.StartsWith("Symbolnumber")) varnamecomp = shtest.Userdescription;
                            if (IsSymbolCalibration(varnamecomp))
                            {
                                foreach (SymbolHelper shoritest in compare_symbols)
                                {
                                    varnameori = shoritest.Varname;
                                    if (varnameori.StartsWith("Symbolnumber")) varnameori = shoritest.Userdescription;

                                    if (varnamecomp == varnameori)
                                    {
                                        _foundSymbol = true;
                                        break;
                                    }
                                }
                                if (!_foundSymbol)
                                {
                                    // add this symbol to the MissingInCompCollection
                                    dt.Rows.Add(varnamecomp, shtest.Start_address, shtest.Flash_start_address, shtest.Length, shtest.Length, st.TranslateSymbolToHelpText(varnamecomp, out ht, out cat, out subcat, m_appSettings.ApplicationLanguage), false, 0, 0, 0, 0, "Missing in compare", "", 0, shtest.Symbol_number, shtest.Userdescription, false, true);
                                }
                            }
                        }
                        tabdet.CompareSymbolCollection = compare_symbols;
                        tabdet.OriginalSymbolCollection = m_symbols;
                        tabdet.OriginalFilename = m_currentfile;
                        tabdet.CompareFilename = filename;
                        tabdet.OpenGridViewGroups(tabdet.gridControl1, 1);
                        tabdet.gridControl1.DataSource = dt.Copy();
                        barProgress.Visibility = BarItemVisibility.Never;
                        barProgress.Caption = "Done";

                    }
                }
                catch (Exception E)
                {
                    logger.Debug(E.Message);
                }
                dockManager1.EndUpdate();
            }
        }
コード例 #13
0
 public frmSymbolSelect(SymbolCollection symbols)
 {
     m_symbols = symbols;
     InitializeComponent();
 }
コード例 #14
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        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);

                }
            }
        }
コード例 #15
0
ファイル: LogFile.cs プロジェクト: mattias197711/TuningSuites
        public static SymbolCollection FindSymbols(string filename, ref DateTime startDate, ref DateTime endDate)
        {
            SymbolCollection sc = new SymbolCollection();

            string[] alllines = File.ReadAllLines(filename);
            //using (StreamReader sr = new StreamReader(filename))
            {
                //string line = string.Empty;
                char[] sep  = new char[1];
                char[] sep2 = new char[1];
                //int linecount = 0;
                sep.SetValue('|', 0);
                sep2.SetValue('=', 0);
                //while ((line = sr.ReadLine()) != null)

                foreach (string line in alllines)
                {
                    string[] values = line.Split(sep);
                    if (values.Length > 0)
                    {
                        try
                        {
                            //dd/MM/yyyy HH:mm:ss
                            //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                            string   dtstring = (string)values.GetValue(0);
                            DateTime dt       = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                            if (dt > endDate)
                            {
                                endDate = dt;
                            }
                            if (dt < startDate)
                            {
                                startDate = dt;
                            }
                            for (int t = 1; t < values.Length; t++)
                            {
                                string   subvalue = (string)values.GetValue(t);
                                string[] subvals  = subvalue.Split(sep2);
                                if (subvals.Length == 2)
                                {
                                    string varname = (string)subvals.GetValue(0);
                                    bool   sfound  = false;
                                    foreach (SymbolHelper sh in sc)
                                    {
                                        if (sh.Varname == varname || sh.Userdescription == varname)
                                        {
                                            sfound = true;
                                        }
                                    }
                                    SymbolHelper nsh = new SymbolHelper();
                                    nsh.Varname = varname;
                                    if (!sfound)
                                    {
                                        sc.Add(nsh);
                                    }
                                }
                            }
                        }
                        catch (Exception pE)
                        {
                            logger.Debug(pE.Message);
                        }
                    }
                }
            }
            return(sc);
        }
コード例 #16
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private int GetTableMatrixWitdhByName(string filename, SymbolCollection curSymbols, string symbolname, out int columns, out int rows)
        {
            columns = 1;// GetSymbolLength(curSymbols, symbolname) / 2;
            if (symbolname == "TorqueCal.M_NominalMap") columns = 18;
            else if (symbolname == "TorqueCal.M_IgnInflTorqMap") columns = 18; //<GS-31052011>
            //else if (symbolname == "TorqueCal.M_EngXSP") columns = 18;
            else if (symbolname == "TorqueCal.X_AccPedalMap") columns = 16;
            else if (symbolname == "TorqueCal.fi_IgnLimMap") columns = 18; //??
            else if (symbolname == "IgnKnkCal.AdapTimer") columns = 18;
            else if (symbolname == "IgnNormCal2Type") columns = 18;
            else if (symbolname == "KnkSoundRedCalType") columns = 18;
            //else if (symbolname == "IgnLOffCal.n_EngYSP") columns = 18;
            else if (symbolname == "MissfCal.DetLevLowLim") columns = 18;
            else if (symbolname == "MissfCal.DetectLevel") columns = 18;
            else if (symbolname == "KnkFuelCal.EnrichmentMap") columns = 18;
            else if (symbolname == "KnkFuelCalType") columns = 18;
            // else if (symbolname == "IgnNormCal.ST_Enable") columns = 18;
            else if (symbolname == "KnkFuelCal.fi_MapMaxOff") columns = 16;
            else if (symbolname == "AirComp.LimPresComp") columns = 8;
            else if (symbolname == "IgnTempCal.AirMap") columns = 5;
            else if (symbolname == "IgnTempCal.EngMap") columns = 5;
            else if (symbolname == "TorqueCal.fi_IgnMinTab") columns = 4;
            else if (symbolname == "MissfCal.DetectLoadLevel") columns = 5;
            else if (symbolname == "KnkDetCal.RefFactorMap") columns = 16;
            else if (symbolname == "BFuelCal.Map") columns = 18;
            else if (symbolname == "BFuelCal.StartMap") columns = 18;
            else if (symbolname == "BFuelCal.E85Map") columns = 18;
            //else if (symbolname == "TorqueCal.M_IgnInflTorqMap") columns = 18;
            else if (symbolname == "TCompCal.EnrFacMap") columns = 8;
            else if (symbolname == "TCompCal.EnrFacE85Map") columns = 8;

            else if (symbolname == "TCompCal.EnrFacAutMap") columns = 8;
            else if (symbolname == "AftSt2ExtraCal.EnrFacMap") columns = 15;
            else if (symbolname == "AftSt2ExtraCal.EnrMapE85") columns = 7;
            else if (symbolname == "AftSt1ExtraCal.EnrFacMap") columns = 15;
            else if (symbolname == "StartCal.HighAltFacMap") columns = 15;
            else if (symbolname == "BoostCal.p_DiffILimMap") columns = 4;
            else if (symbolname == "MissfCal.outOfLimDelayMAT") columns = 4;
            else if (symbolname == "KnkAdaptCal.WeightMap2") columns = 4;
            else if (symbolname == "KnkAdaptCal.MaxRef") columns = 3;
            else if (symbolname == "MissfAdap.MissfCntMap") columns = 18;
            else if (symbolname == "TorqueCal.M_PumpLossMap") columns = 2;
            else if (symbolname == "HotStCal2.RestartMap") columns = 6;
            else if (symbolname == "StartCal.ScaleFacRpmE85Map") columns = 8;
            else if (symbolname == "StartCal.ScaleFacRpmMap") columns = 8;
            else if (symbolname == "SwitchCal.A_AmbPresMap") columns = 2;

            /*
            Maps met lengte 242 hebben 11 hoogte en breedte 22
            Maps met lengte 200 hebben 10 hoogte en breedte 20
            Maps met lengte 198 hebben 11 hoogte en breedte 18
            Maps met lengte 100 hebben 5 hoogte en breedte 20                 * */

            /* 16
            TorqueCal.M_NominalMap 18
            TorqueCal.M_IgnInflTroqMap 8*/
            else if (GetSymbolLength(curSymbols, symbolname) == 576) columns = 18;
            else if (GetSymbolLength(curSymbols, symbolname) == 512) columns = 16;

            else if (GetSymbolLength(curSymbols, symbolname) == 336) columns = 12;

            else if (GetSymbolLength(curSymbols, symbolname) == 288) columns = 9;
            else if (GetSymbolLength(curSymbols, symbolname) == 256) columns = 8;
            else if (GetSymbolLength(curSymbols, symbolname) == 242) columns = 11; // of 11?
            else if (GetSymbolLength(curSymbols, symbolname) == 224) columns = 8;
            else if (GetSymbolLength(curSymbols, symbolname) == 200) columns = 10; //
            else if (GetSymbolLength(curSymbols, symbolname) == 198) columns = 9; //
            else if (GetSymbolLength(curSymbols, symbolname) == 192) columns = 8;
            else if (GetSymbolLength(curSymbols, symbolname) == 128) columns = 8;
            else if (GetSymbolLength(curSymbols, symbolname) == 120) columns = 5;
            else if (GetSymbolLength(curSymbols, symbolname) == 100) columns = 10;
            else if (GetSymbolLength(curSymbols, symbolname) == 98) columns = 7;
            else if (GetSymbolLength(curSymbols, symbolname) == 80) columns = 5;
            else if (GetSymbolLength(curSymbols, symbolname) == 60) columns = 5;
            else if (GetSymbolLength(curSymbols, symbolname) == 50) columns = 5;
            else if (GetSymbolLength(curSymbols, symbolname) == 96) columns = 6;
            else if (GetSymbolLength(curSymbols, symbolname) == 64) columns = 4;
            else if (GetSymbolLength(curSymbols, symbolname) == 160) columns = 10;
            else if (GetSymbolLength(curSymbols, symbolname) == 72) columns = 9;

            rows = GetSymbolLength(curSymbols, symbolname) / columns;
            return columns;
        }
コード例 #17
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
 private Int64 GetSymbolAddressSRAM(SymbolCollection curSymbolCollection, string symbolname)
 {
     foreach (SymbolHelper sh in curSymbolCollection)
     {
         if (sh.Varname == symbolname || sh.Userdescription == symbolname)
         {
             return sh.Start_address;
         }
     }
     return 0;
 }
コード例 #18
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
 private SymbolCollection GetRealtimeNotificationSymbols()
 {
     SymbolCollection _symbols = new SymbolCollection();
     if (m_symbols != null)
     {
         foreach (SymbolHelper sh in m_symbols)
         {
             if (sh.Start_address > 0xF00000)
             {
                 _symbols.Add(sh);
             }
         }
     }
     return _symbols;
 }
コード例 #19
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private void File_ImportTuningPackage_ItemClick(object sender, ItemClickEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Trionic 7 packages|*.t7p";
            ofd.Multiselect = false;
            char[] sep = new char[1];
            sep.SetValue(',', 0);

            SymbolCollection scToImport = new SymbolCollection();
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("Map");
            dt.Columns.Add("Result");

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                //TODO: create a list of maps to import .. maybe?
                using (StreamReader sr = new StreamReader(ofd.FileName))
                {
                    string line = string.Empty;
                    SymbolHelper sh_Import = new SymbolHelper();
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.StartsWith("symbol="))
                        {
                            //
                            sh_Import = new SymbolHelper();
                            sh_Import.Varname = line.Replace("symbol=", "");
                        }
                        else if (line.StartsWith("length="))
                        {
                            sh_Import.Length = Convert.ToInt32(line.Replace("length=", ""));
                        }
                        else if (line.StartsWith("data="))
                        {
                            //
                            try
                            {
                                string dataBytes = line.Replace("data=", "");
                                // split using ','
                                string[] bytesInStrings = dataBytes.Split(sep);
                                byte[] dataToInsert = new byte[sh_Import.Length];
                                for (int t = 0; t < sh_Import.Length; t++)
                                {
                                    byte b = Convert.ToByte(bytesInStrings[t], 16);
                                    dataToInsert.SetValue(b, t);
                                }
                                int addressInFile = (int)GetSymbolAddress(m_symbols, sh_Import.Varname);
                                if (addressInFile > 0)
                                {
                                    if (_softwareIsOpen && sh_Import.Varname == "MapChkCal.ST_Enable")
                                    {
                                        dt.Rows.Add(sh_Import.Varname, "Skipped");
                                    }
                                    else
                                    {
                                        savedatatobinary(addressInFile, sh_Import.Length, dataToInsert, m_currentfile, true);
                                        // add successful
                                        dt.Rows.Add(sh_Import.Varname, "Success");
                                    }
                                }
                                else
                                {
                                    // add failure
                                    dt.Rows.Add(sh_Import.Varname, "Fail");
                                }
                            }
                            catch (Exception E)
                            {
                                // add failure
                                dt.Rows.Add(sh_Import.Varname, "Fail");
                                logger.Debug(E.Message);
                            }
                        }
                    }
                }
                UpdateChecksum(m_currentfile);
                frmImportResults res = new frmImportResults();
                res.SetDataTable(dt);
                res.ShowDialog();
            }
        }
コード例 #20
0
 public void SetSymbolCollection(SymbolCollection sc)
 {
     //checkedListBoxControl1.Items.Add(varname);
     _sc = sc;
     gridControl1.DataSource = sc;
 }
コード例 #21
0
        public bool ConvertFileToCSV(string filename, SymbolCollection sc, DateTime startDate, DateTime endDate)
        {
            bool   retval      = false;
            string newfilename = Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".csv";

            CastExportProgressEvent(1);
            if (File.Exists(newfilename))
            {
                File.Delete(newfilename);
            }
            using (StreamWriter sw = new StreamWriter(newfilename, false))
            {
                FileInfo         fi         = new FileInfo(filename);
                string[]         alllines   = File.ReadAllLines(filename);
                List <string>    header     = new List <string>(50);
                HashSet <string> headerHash = new HashSet <string>();
                sw.Write("Time");
                {
                    string previousline = string.Empty;
                    char[] sep          = new char[1];
                    char[] sep2         = new char[1];
                    int    linecount    = 0;
                    sep.SetValue('|', 0);
                    sep2.SetValue('=', 0);
                    DateTime dtpreviousline = DateTime.MaxValue;

                    // find all symbolnames to write header
                    foreach (string line in alllines)
                    {
                        string[] values = line.Split(sep);
                        if (values.Length > 0 && CheckValuesAgainstFilters(values))
                        {
                            for (int t = 1; t < values.Length; t++)
                            {
                                string   subvalue = (string)values.GetValue(t);
                                string[] subvals  = subvalue.Split(sep2);
                                if (subvals.Length == 2)
                                {
                                    if (headerHash.Add(subvals[0]))
                                    {
                                        header.Add(subvals[0]);
                                        sw.Write(string.Format(",{0}", subvals[0]));
                                    }
                                }
                            }
                        }
                    }
                    sw.WriteLine();

                    // find all values
                    foreach (string line in alllines)
                    {
                        linecount += line.Length;
                        int percentage = (linecount * 90) / (int)fi.Length;
                        CastExportProgressEvent(10 + percentage);

                        string[] values = line.Split(sep);
                        if (values.Length > 0 && CheckValuesAgainstFilters(values))
                        {
                            try
                            {
                                retval = true;
                                string   dtstring = (string)values.GetValue(0);
                                DateTime dt       = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                if (dtstring.Length > 20)
                                {
                                    dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)), Convert.ToInt32(dtstring.Substring(20, 3)));
                                }
                                if (dt >= startDate && dt <= endDate)
                                {
                                    TimeSpan ts        = new TimeSpan(dt.Ticks - startDate.Ticks);
                                    float    millisecs = (float)(ts.TotalMilliseconds) / 1000F;
                                    sw.Write(millisecs.ToString("F4").Replace(',', '.'));

                                    foreach (string column in header)
                                    {
                                        for (int t = 1; t < values.Length; t++)
                                        {
                                            string   subvalue = (string)values.GetValue(t);
                                            string[] subvals  = subvalue.Split(sep2);
                                            if (subvals.Length == 2)
                                            {
                                                string varname = (string)subvals.GetValue(0);

                                                if (column == varname)
                                                {
                                                    if (varname == "AD_sond")
                                                    {
                                                        double value = ConvertToDouble(subvals[1]);
                                                        value = ConvertToLambda(value);
                                                        sw.Write(string.Format(",{0}", value));
                                                    }
                                                    else if (varname == _widebandSymbol || varname == "DisplProt.AD_Scanner")
                                                    {
                                                        double value = ConvertToDouble(subvals[1]);
                                                        value = ConvertToWidebandLambda(value);
                                                        sw.Write(string.Format(",{0}", value));
                                                    }
                                                    else
                                                    {
                                                        sw.Write(string.Format(",{0}", subvals[1].Replace(",", ".")));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    sw.WriteLine();
                                }
                            }
                            catch (Exception E)
                            {
                                logger.Debug(E.Message);
                            }
                        }
                        previousline = line;
                    }
                }
            }
            return(retval);
        }
コード例 #22
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private void exportFixedTuningPackageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SymbolCollection scToExport = new SymbolCollection();
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "Trionic 7 packages|*.t7p";
            if (sfd.ShowDialog() == DialogResult.OK)
            {

                // add all relevant symbols to the export collection
                //SymbolHelper sh = new SymbolHelper();
                // must contain Varname, FlashAddress, Length, Userdescription
                AddToSymbolCollection(scToExport, "LimEngCal.TurboSpeedTab"); // add axis
                AddToSymbolCollection(scToExport, "LimEngCal.p_AirSP");
                AddToSymbolCollection(scToExport, "AirCtrlCal.m_MaxAirTab"); // add axis
                AddToSymbolCollection(scToExport, "TempLimPosCal.Airmass");
                //AddToSymbolCollection(scToExport, "X_AccPedalAutSP");
                AddToSymbolCollection(scToExport, "BoostCal.RegMap");   // add axis
                AddToSymbolCollection(scToExport, "BoostCal.SetLoadXSP");
                AddToSymbolCollection(scToExport, "BoostCal.n_EngSP");
                AddToSymbolCollection(scToExport, "PedalMapCal.m_RequestMap");// add axis
                AddToSymbolCollection(scToExport, "PedalMapCal.n_EngineMap");
                AddToSymbolCollection(scToExport, "PedalMapCal.X_PedalMap");
                AddToSymbolCollection(scToExport, "BstKnkCal.MaxAirmass");  // add axis
                AddToSymbolCollection(scToExport, "BstKnkCal.OffsetXSP");
                AddToSymbolCollection(scToExport, "BstKnkCal.n_EngYSP");
                AddToSymbolCollection(scToExport, "BstKnkCal.MaxAirmassAu"); // add axis
                AddToSymbolCollection(scToExport, "TorqueCal.M_EngMaxAutTab"); // add axis
                AddToSymbolCollection(scToExport, "TorqueCal.M_EngMaxTab"); // add axis
                AddToSymbolCollection(scToExport, "TorqueCal.M_EngMaxE85Tab"); // add axis
                AddToSymbolCollection(scToExport, "TorqueCal.M_ManGearLim"); // add axis
                AddToSymbolCollection(scToExport, "TorqueCal.M_CabGearLim"); // add axis
                AddToSymbolCollection(scToExport, "TorqueCal.n_Eng5GearSP");
                AddToSymbolCollection(scToExport, "TorqueCal.M_5GearLimTab"); // add axis
                AddToSymbolCollection(scToExport, "TorqueCal.M_NominalMap"); // add axis
                AddToSymbolCollection(scToExport, "TorqueCal.m_AirXSP");
                AddToSymbolCollection(scToExport, "TorqueCal.n_EngYSP");
                AddToSymbolCollection(scToExport, "TorqueCal.m_AirTorqMap"); // add axis
                AddToSymbolCollection(scToExport, "TorqueCal.M_EngXSP");
                AddToSymbolCollection(scToExport, "TorqueCal.m_PedYSP");
                AddToSymbolCollection(scToExport, "FCutCal.m_AirInletLimit");
                AddToSymbolCollection(scToExport, "BoosDiagCal.m_FaultDiff");
                AddToSymbolCollection(scToExport, "BoosDiagCal.ErrMaxMReq");
                AddToSymbolCollection(scToExport, "BFuelCal.Map");
                AddToSymbolCollection(scToExport, "BFuelCal.StartMap");
                AddToSymbolCollection(scToExport, "BFuelCal.E85Map");
                AddToSymbolCollection(scToExport, "BFuelCal.AirXSP");
                AddToSymbolCollection(scToExport, "BFuelCal.RpmYSP");
                AddToSymbolCollection(scToExport, "InjCorrCal.BattCorrSP");
                AddToSymbolCollection(scToExport, "InjCorrCal.BattCorrTab");
                AddToSymbolCollection(scToExport, "InjCorrCal.InjectorConst");
                AddToSymbolCollection(scToExport, "IgnNormCal.Map");
                AddToSymbolCollection(scToExport, "IgnE85Cal.fi_AbsMap");
                AddToSymbolCollection(scToExport, "IgnNormCal.m_AirXSP");
                AddToSymbolCollection(scToExport, "IgnNormCal.n_EngYSP");
                AddToSymbolCollection(scToExport, "IgnKnkCal.IndexMap");
                AddToSymbolCollection(scToExport, "KnkFuelCal.fi_MapMaxOff");
                AddToSymbolCollection(scToExport, "KnkFuelCal.m_AirXSP");
                AddToSymbolCollection(scToExport, "BoostCal.PMap");
                AddToSymbolCollection(scToExport, "BoostCal.IMap");
                AddToSymbolCollection(scToExport, "BoostCal.DMap");
                AddToSymbolCollection(scToExport, "BoostCal.PIDXSP");
                AddToSymbolCollection(scToExport, "BoostCal.PIDYSP");
                AddToSymbolCollection(scToExport, "TorqueCal.M_OverBoostTab");
                AddToSymbolCollection(scToExport, "TorqueCal.n_EngYSP");
                AddToSymbolCollection(scToExport, "KnkFuelCal.EnrichmentMap");
                AddToSymbolCollection(scToExport, "IgnKnkCal.m_AirXSP");
                AddToSymbolCollection(scToExport, "IgnKnkCal.n_EngYSP");
                AddToSymbolCollection(scToExport, "KnkDetCal.RefFactorMap");
                AddToSymbolCollection(scToExport, "KnkDetCal.m_AirXSP");
                AddToSymbolCollection(scToExport, "KnkDetCal.n_EngYSP");
                AddToSymbolCollection(scToExport, "MaxSpdCal.T_EngineSP");
                AddToSymbolCollection(scToExport, "MaxSpdCal.n_EngLimAir");
                AddToSymbolCollection(scToExport, "MaxVehicCal.v_MaxSpeed");
                PackageExporter pe = new PackageExporter();
                if (IsSoftwareOpen())
                {
                    pe.AddressOffset = GetOpenFileOffset();
                }
                pe.ExportPackage(scToExport, m_currentfile, sfd.FileName);
            }
        }
コード例 #23
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private int[] GetXaxisValues(string filename, SymbolCollection curSymbols, string symbolname)
        {
            int[] retval = new int[1];
            retval.SetValue(0, 0);
            int xaxisaddress = 0;
            int xaxislength = 0;
            bool issixteenbit = true;
            double multiplier = 1;

            SymbolAxesTranslator axistranslator = new SymbolAxesTranslator();
            string x_axis = string.Empty;
            string y_axis = string.Empty;
            string x_axis_descr = string.Empty;
            string y_axis_descr = string.Empty;
            string z_axis_descr = string.Empty;
            if (axistranslator.GetAxisSymbols(symbolname, out x_axis, out y_axis, out x_axis_descr, out y_axis_descr, out z_axis_descr))
            {
                if (x_axis != "")
                {
                    xaxislength = GetSymbolLength(curSymbols, x_axis);
                    xaxisaddress = (int)GetSymbolAddress(curSymbols, x_axis);
                }
            }
            multiplier = GetMapCorrectionFactor(x_axis);

            int number = xaxislength;
            if (xaxislength > 0)
            {
                byte[] axisdata = readdatafromfile(filename,xaxisaddress, xaxislength);
                if (issixteenbit) number /= 2;
                retval = new int[number];
                int offset = 0;
                for (int i = 0; i < xaxislength; i++)
                {

                    if (issixteenbit)
                    {
                        byte val1 = (byte)axisdata.GetValue(i);
                        byte val2 = (byte)axisdata.GetValue(++i);
                        int ival1 = Convert.ToInt32(val1);
                        int ival2 = Convert.ToInt32(val2);
                        int value = (ival1 * 256) + ival2;
                        if (symbolname == "BstKnkCal.MaxAirmass" || symbolname == "BstKnkCal.MaxAirmassAu")
                        {
                            if (value > 32000) value = -(65536 - value); // negatief maken
                        }
                        double valtot = (double)value * multiplier;
                        value = (int)valtot;
                        retval.SetValue(value, offset++);
                    }
                    else
                    {
                        byte val1 = (byte)axisdata.GetValue(i);
                        int ival1 = Convert.ToInt32(val1);
                        double valtot = (double)ival1 * multiplier;
                        ival1 = (int)valtot;
                        retval.SetValue(ival1, offset++);
                    }
                }
            }
            return retval;
        }
コード例 #24
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private void File_EditTuningPackage(object sender, ItemClickEventArgs e)
        {
            if (tunpackeditWindow != null)
            {
                frmInfoBox info = new frmInfoBox("You have another tuning package edit window open, please close that first");
                return;
            }
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Trionic 7 packages|*.t7p";
            ofd.Multiselect = false;
            char[] sep = new char[1];
            sep.SetValue(',', 0);

            SymbolCollection scToImport = new SymbolCollection();
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("Map");
            dt.Columns.Add("Length");
            dt.Columns.Add("Data");

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                //TODO: create a list of maps to import .. maybe?
                using (StreamReader sr = new StreamReader(ofd.FileName))
                {
                    string line = string.Empty;
                    SymbolHelper sh_Import = new SymbolHelper();
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.StartsWith("symbol="))
                        {
                            //
                            sh_Import = new SymbolHelper();
                            sh_Import.Varname = line.Replace("symbol=", "");
                        }
                        else if (line.StartsWith("length="))
                        {
                            sh_Import.Length = Convert.ToInt32(line.Replace("length=", ""));
                        }
                        else if (line.StartsWith("data="))
                        {
                            //
                            try
                            {
                                string dataBytes = line.Replace("data=", "");
                                // split using ','
                                string[] bytesInStrings = dataBytes.Split(sep);
                                byte[] dataToInsert = new byte[sh_Import.Length];
                                for (int t = 0; t < sh_Import.Length; t++)
                                {
                                    byte b = Convert.ToByte(bytesInStrings[t], 16);
                                    dataToInsert.SetValue(b, t);
                                }
                                int addressInFile = (int)GetSymbolAddress(m_symbols, sh_Import.Varname);
                                if (addressInFile > 0)
                                {
                                    //savedatatobinary(addressInFile, sh_Import.Length, dataToInsert, m_currentfile, true);
                                    // add successful
                                    dt.Rows.Add(sh_Import.Varname, sh_Import.Length.ToString(), dataBytes);
                                }
                                else
                                {
                                    // add failure
                                    dt.Rows.Add(sh_Import.Varname, sh_Import.Length.ToString(), dataBytes);
                                }
                            }
                            catch (Exception E)
                            {
                                // add failure
                                dt.Rows.Add(sh_Import.Varname, sh_Import.Length.ToString(), "");
                                logger.Debug(E.Message);
                            }
                        }
                    }
                }
                tunpackeditWindow = new frmEditTuningPackage();
                tunpackeditWindow.FormClosed += new FormClosedEventHandler(edit_FormClosed);
                tunpackeditWindow.onMapSelected += new frmEditTuningPackage.MapSelected(edit_onMapSelected);
                tunpackeditWindow.SetFilename(ofd.FileName);
                tunpackeditWindow.SetDataTable(dt);
                tunpackeditWindow.Show();

            }
        }
コード例 #25
0
 public void SetSymbols(SymbolCollection sc)
 {
     repositoryItemLookUpEdit1.DataSource = sc;
 }
コード例 #26
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
 private void GetAxisDescriptions(string filename, SymbolCollection curSymbols, string symbolname, out string x, out string y, out string z)
 {
     x = "x-axis";
     y = "y-axis";
     z = "z-axis";
 }
コード例 #27
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private Trionic7File TryToOpenFileUsingClass(string filename, out SymbolCollection symbol_collection, int filename_size, bool isWorkingFile)
        {
            Trionic7File retval = new Trionic7File();

            retval.onProgress += retval_onProgress;
            SymbolTranslator translator = new SymbolTranslator();
            string help = string.Empty;
            _softwareIsOpen = false;
            _softwareIsOpenDetermined = false;
            m_currentsramfile = string.Empty; // geen sramfile erbij
            barStaticItem1.Caption = "";
            barFilenameText.Caption = "";

            FileInfo fi = new FileInfo(filename);
            try
            {
                fi.IsReadOnly = false;
                btnReadOnly.Caption = "File access OK";
            }
            catch (Exception E)
            {
                logger.Debug("Failed to remove read only flag: " + E.Message);
                btnReadOnly.Caption = "File is READ ONLY";
            }

            try
            {
                if (isWorkingFile)
                {
                    T7FileHeader t7InfoHeader = new T7FileHeader();
                    if (t7InfoHeader.init(filename, m_appSettings.AutoFixFooter))
                    {
                        m_current_softwareversion = t7InfoHeader.getSoftwareVersion();
                        m_currentSramOffsett = ReverseInt(t7InfoHeader.Unknown_9cvalue);
                    }
                    else
                    {
                        m_current_softwareversion = "";
                    }
                }
            }
            catch (Exception E2)
            {
                logger.Debug(E2.Message);
            }
            AddFileToMRUList(filename);
            symbol_collection = retval.ExtractFile(filename, m_appSettings.ApplicationLanguage, m_current_softwareversion);

            SetProgressPercentage(60);
            SetProgress("Examining file");
            System.Windows.Forms.Application.DoEvents();
            if (isWorkingFile)
            {
                if (m_currentSramOffsett == 0)
                {
                    m_currentSramOffsett = retval.SramOffsetForOpenFile;
                    logger.Debug("Overrules m_currentSramOffsett with value from t7file: " + m_currentSramOffsett.ToString("X8"));
                }

                // <GS-27042010> now we need to check if there is a symbol information XML file present.
                try
                {
                    IsSoftwareOpen();
                    // fill in the rest of the parameters
                    barFilenameText.Caption = Path.GetFileNameWithoutExtension(filename);
                }
                catch (Exception E3)
                {
                    logger.Debug(E3.Message);
                }
            }

            if (IsBinaryBiopower())
            {
                foreach (SymbolHelper sh in symbol_collection)
                {
                    if (sh.Varname == "BFuelCal.StartMap")
                    {
                        sh.Varname = "BFuelCal.E85Map";
                        XDFCategories cat = XDFCategories.Undocumented;
                        XDFSubCategory sub = XDFSubCategory.Undocumented;
                        sh.Description = translator.TranslateSymbolToHelpText(sh.Varname, out help, out cat, out sub, m_appSettings.ApplicationLanguage);
                    }
                    if (sh.Userdescription == "BFuelCal.StartMap")
                    {
                        sh.Userdescription = "BFuelCal.E85Map";
                        XDFCategories cat = XDFCategories.Undocumented;
                        XDFSubCategory sub = XDFSubCategory.Undocumented;
                        sh.Description = translator.TranslateSymbolToHelpText(sh.Userdescription, out help, out cat, out sub, m_appSettings.ApplicationLanguage);
                    }
                }
            }
            return retval;
        }
コード例 #28
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
 private Int64 GetSymbolAddress(SymbolCollection curSymbolCollection, string symbolname)
 {
     foreach (SymbolHelper sh in curSymbolCollection)
     {
         if (sh.Varname == symbolname || sh.Userdescription == symbolname)
         {
             string name = sh.Varname;
             if (sh.Varname.StartsWith("Symbol") && sh.Userdescription != "")
             {
                 name = sh.Userdescription;
             }
             if (IsSoftwareOpen() && IsSymbolCalibration(name) /*&& sh.Length > 0x02*/ && sh.Length < 0x400 && sh.Flash_start_address > m_currentfile_size) // <GS-09082010>
             {
                 return sh.Flash_start_address - GetOpenFileOffset();
             }
             /*if (sh.Varname == "X_AccPedalManSP" || sh.Varname == "X_AccPedalAutTAB" || sh.Varname == "X_AccPedalAutSP" || sh.Varname == "X_AccPedalManTAB")
             {
                 return sh.Flash_start_address - 0x0C;
             }*/
             return sh.Flash_start_address;
         }
     }
     return 0;
 }
コード例 #29
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private void addToMyMapsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (gridViewSymbols.FocusedRowHandle >= 0)
            {
                SymbolHelper sh = (SymbolHelper)gridViewSymbols.GetRow(gridViewSymbols.FocusedRowHandle);
                SymbolCollection scmymaps = new SymbolCollection();
                SymbolHelper shnewmymap = new SymbolHelper();
                shnewmymap.Varname = sh.Varname;
                shnewmymap.Description = sh.Varname;
                shnewmymap.Category = "Directly added";
                scmymaps.Add(shnewmymap);
                string filename = System.Windows.Forms.Application.StartupPath + "\\mymaps.xml";
                if (File.Exists(filename))
                {
                    try
                    {
                        System.Xml.XmlDocument mymaps = new System.Xml.XmlDocument();
                        mymaps.Load(System.Windows.Forms.Application.StartupPath + "\\mymaps.xml");
                        foreach (System.Xml.XmlNode category in mymaps.SelectNodes("categories/category"))
                        {
                            foreach (System.Xml.XmlNode map in category.SelectNodes("map"))
                            {
                                SymbolHelper shmap = new SymbolHelper();
                                shmap.Varname = map.Attributes["symbol"].Value;
                                shmap.Category = category.Attributes["title"].Value;
                                shmap.Description = map.Attributes["title"].Value;
                                scmymaps.Add(shmap);
                            }
                        }
                    }
                    catch { }
                }
                // now save a new file
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
                XmlDocument doc = new XmlDocument();// Create the XML Declaration, and append it to XML document
                XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
                doc.AppendChild(dec);// Create the root element
                XmlElement root = doc.CreateElement("categories");
                doc.AppendChild(root);

                scmymaps.SortColumn = "Category";
                scmymaps.SortingOrder = GenericComparer.SortOrder.Ascending;
                scmymaps.Sort();

                string previouscat = "";
                XmlElement title = doc.CreateElement("category");
                foreach (SymbolHelper shmm in scmymaps)
                {
                    if (shmm.Category != previouscat)
                    {
                        previouscat = shmm.Category;
                        title = doc.CreateElement("category");
                        title.SetAttribute("title", previouscat);
                        root.AppendChild(title);
                    }
                    XmlElement map = doc.CreateElement("map");
                    map.SetAttribute("symbol", shmm.Varname);
                    map.SetAttribute("title", shmm.Description);
                    title.AppendChild(map);
                }
                doc.Save(filename);
                if (ribbonControl1.Pages[3].Text == "My Maps")
                {
                    ribbonControl1.Pages.RemoveAt(3);
                }
                LoadMyMaps();
            }
        }
コード例 #30
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
 private int GetSymbolNumber(SymbolCollection curSymbolCollection, string symbolname)
 {
     foreach (SymbolHelper sh in curSymbolCollection)
     {
         if (sh.Varname == symbolname || sh.Userdescription == symbolname)
         {
             return sh.Symbol_number;
         }
     }
     return 0;
 }
コード例 #31
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
 private void AddToSymbolCollection(SymbolCollection scToExport, string symbolName)
 {
     foreach (SymbolHelper sh in m_symbols)
     {
         if (sh.Varname == symbolName || sh.Userdescription == symbolName)
         {
             SymbolHelper shNew = new SymbolHelper();
             shNew.Start_address = sh.Start_address;
             shNew.Symbol_number = sh.Symbol_number;
             shNew.Symbol_number_ECU = sh.Symbol_number_ECU;
             shNew.Internal_address = sh.Internal_address;
             shNew.Varname = symbolName;
             shNew.Flash_start_address = sh.Flash_start_address;
             shNew.Length = sh.Length;
             shNew.Userdescription = symbolName;
             scToExport.Add(shNew);
             break;
         }
     }
 }
コード例 #32
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
 private string GetUserDescription(SymbolCollection curSymbolCollection, string symbolname)
 {
     foreach (SymbolHelper sh in curSymbolCollection)
     {
         if (sh.Varname == symbolname || sh.Userdescription == symbolname)
         {
             return sh.Userdescription;
         }
     }
     return symbolname;
 }
コード例 #33
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private void btnGenerateTuningPackage_ItemClick(object sender, ItemClickEventArgs e)
        {
            // generate the default maps as a tuning package from the ECUs SRAM
            if (m_currentfile != "")
            {
                if (CheckCANConnectivity())
                {
                    frmProgress progress = new frmProgress();
                    progress.SetProgress("Downloading tuning package...");
                    progress.Show();
                    SymbolCollection scToExport = new SymbolCollection();
                    PackageExporter pe = new PackageExporter();
                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.Filter = "Trionic 7 packages|*.t7p";
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        AddToSymbolCollection(scToExport, "LimEngCal.TurboSpeedTab"); // add axis
                        AddToSymbolCollection(scToExport, "LimEngCal.p_AirSP");
                        AddToSymbolCollection(scToExport, "AirCtrlCal.m_MaxAirTab"); // add axis
                        AddToSymbolCollection(scToExport, "TempLimPosCal.Airmass");
                        //AddToSymbolCollection(scToExport, "X_AccPedalAutSP");
                        AddToSymbolCollection(scToExport, "BoostCal.RegMap");   // add axis
                        AddToSymbolCollection(scToExport, "BoostCal.SetLoadXSP");
                        AddToSymbolCollection(scToExport, "BoostCal.n_EngSP");
                        AddToSymbolCollection(scToExport, "PedalMapCal.m_RequestMap");// add axis
                        AddToSymbolCollection(scToExport, "PedalMapCal.n_EngineMap");
                        AddToSymbolCollection(scToExport, "PedalMapCal.X_PedalMap");
                        AddToSymbolCollection(scToExport, "BstKnkCal.MaxAirmass");  // add axis
                        AddToSymbolCollection(scToExport, "BstKnkCal.OffsetXSP");
                        AddToSymbolCollection(scToExport, "BstKnkCal.n_EngYSP");
                        AddToSymbolCollection(scToExport, "BstKnkCal.MaxAirmassAu"); // add axis
                        AddToSymbolCollection(scToExport, "TorqueCal.M_EngMaxAutTab"); // add axis
                        AddToSymbolCollection(scToExport, "TorqueCal.M_EngMaxTab"); // add axis
                        AddToSymbolCollection(scToExport, "TorqueCal.M_EngMaxE85Tab"); // add axis
                        AddToSymbolCollection(scToExport, "TorqueCal.M_ManGearLim"); // add axis
                        AddToSymbolCollection(scToExport, "TorqueCal.M_CabGearLim"); // add axis
                        AddToSymbolCollection(scToExport, "TorqueCal.n_Eng5GearSP");
                        AddToSymbolCollection(scToExport, "TorqueCal.M_5GearLimTab"); // add axis
                        AddToSymbolCollection(scToExport, "TorqueCal.M_NominalMap"); // add axis
                        AddToSymbolCollection(scToExport, "TorqueCal.m_AirXSP");
                        AddToSymbolCollection(scToExport, "TorqueCal.n_EngYSP");
                        AddToSymbolCollection(scToExport, "TorqueCal.m_AirTorqMap"); // add axis
                        AddToSymbolCollection(scToExport, "TorqueCal.M_EngXSP");
                        AddToSymbolCollection(scToExport, "TorqueCal.m_PedYSP");
                        AddToSymbolCollection(scToExport, "FCutCal.m_AirInletLimit");
                        AddToSymbolCollection(scToExport, "BoosDiagCal.m_FaultDiff");
                        AddToSymbolCollection(scToExport, "BoosDiagCal.ErrMaxMReq");
                        AddToSymbolCollection(scToExport, "BFuelCal.Map");
                        AddToSymbolCollection(scToExport, "BFuelCal.StartMap");
                        AddToSymbolCollection(scToExport, "BFuelCal.E85Map");
                        AddToSymbolCollection(scToExport, "BFuelCal.AirXSP");
                        AddToSymbolCollection(scToExport, "BFuelCal.RpmYSP");
                        AddToSymbolCollection(scToExport, "InjCorrCal.InjectorConst");
                        AddToSymbolCollection(scToExport, "IgnNormCal.Map");
                        AddToSymbolCollection(scToExport, "IgnE85Cal.fi_AbsMap");
                        AddToSymbolCollection(scToExport, "IgnNormCal.m_AirXSP");
                        AddToSymbolCollection(scToExport, "IgnNormCal.n_EngYSP");
                        AddToSymbolCollection(scToExport, "IgnKnkCal.IndexMap");
                        AddToSymbolCollection(scToExport, "KnkFuelCal.fi_MapMaxOff");
                        AddToSymbolCollection(scToExport, "KnkFuelCal.m_AirXSP");
                        AddToSymbolCollection(scToExport, "BoostCal.PMap");
                        AddToSymbolCollection(scToExport, "BoostCal.IMap");
                        AddToSymbolCollection(scToExport, "BoostCal.DMap");
                        AddToSymbolCollection(scToExport, "BoostCal.PIDXSP");
                        AddToSymbolCollection(scToExport, "BoostCal.PIDYSP");
                        AddToSymbolCollection(scToExport, "TorqueCal.M_OverBoostTab");
                        AddToSymbolCollection(scToExport, "TorqueCal.n_EngYSP");
                        AddToSymbolCollection(scToExport, "KnkFuelCal.EnrichmentMap");
                        AddToSymbolCollection(scToExport, "IgnKnkCal.m_AirXSP");
                        AddToSymbolCollection(scToExport, "IgnKnkCal.n_EngYSP");
                        AddToSymbolCollection(scToExport, "KnkDetCal.RefFactorMap");
                        AddToSymbolCollection(scToExport, "KnkDetCal.m_AirXSP");
                        AddToSymbolCollection(scToExport, "KnkDetCal.n_EngYSP");
                        AddToSymbolCollection(scToExport, "MaxSpdCal.T_EngineSP");
                        AddToSymbolCollection(scToExport, "MaxSpdCal.n_EngLimAir");
                        AddToSymbolCollection(scToExport, "MaxVehicCal.v_MaxSpeed");
                        //pe.ExportPackage(scToExport, m_currentfile, sfd.FileName);
                        if (File.Exists(sfd.FileName)) File.Delete(sfd.FileName);
                        foreach (SymbolHelper sh in scToExport)
                        {
                            //<GS-28012011>

                            progress.SetProgress("Downloading: " + sh.Varname);
                            System.Windows.Forms.Application.DoEvents();
                            byte[] data = ReadMapFromSRAM(sh, false);
                            pe.ExportMap(sfd.FileName, sh.Varname, sh.Userdescription, sh.Length, data);
                            Thread.Sleep(1);
                        }
                    }
                    if (progress != null) progress.Close();
                }
                else
                {
                    frmInfoBox info = new frmInfoBox("An active CAN bus connection is needed to download a tuning package");
                }
            }
        }
コード例 #34
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private int[] GetYaxisValues(string filename, SymbolCollection curSymbols, string symbolname)
        {
            int[] retval = new int[GetSymbolLength(curSymbols, symbolname)];
            //retval.SetValue(0, 0);
            int yaxisaddress = 0;
            int yaxislength = 0;
            bool issixteenbit = true;
            double multiplier = 1;

            SymbolAxesTranslator axistranslator = new SymbolAxesTranslator();
            string x_axis = string.Empty;
            string y_axis = string.Empty;
            string x_axis_descr = string.Empty;
            string y_axis_descr = string.Empty;
            string z_axis_descr = string.Empty;
            if (axistranslator.GetAxisSymbols(symbolname, out x_axis, out y_axis, out x_axis_descr, out y_axis_descr, out z_axis_descr))
            {
                if (y_axis != "")
                {
                    yaxislength = GetSymbolLength(curSymbols, y_axis);
                    yaxisaddress = (int)GetSymbolAddress(curSymbols, y_axis);
                }
            }
            multiplier = GetMapCorrectionFactor(y_axis);
            if (symbolname == "TorqueCal.M_ManGearLim" || symbolname == "TorqueCal.M_CabGearLim")
            {
                retval = new int[6];
                retval.SetValue(-1, 0);
                retval.SetValue(1, 1);
                retval.SetValue(2, 2);
                retval.SetValue(3, 3);
                retval.SetValue(4, 4);
                retval.SetValue(5, 5);
                return retval;
            }
            if (symbolname == "GearCal.Ratio" || symbolname == "GearCal")
            {
                retval = new int[5];
                retval.SetValue(1, 0);
                retval.SetValue(2, 1);
                retval.SetValue(3, 2);
                retval.SetValue(4, 3);
                retval.SetValue(5, 4);

                return retval;

            }
            if (symbolname == "BstMetCal.BoostMeter")
            {
                retval = new int[6];
                retval.SetValue(0, 0);
                retval.SetValue(1, 1);
                retval.SetValue(2, 2);
                retval.SetValue(3, 3);
                retval.SetValue(4, 4);
                retval.SetValue(5, 5);
                return retval;

            }
            int number = yaxislength;
            if (yaxislength > 0)
            {
                byte[] axisdata = readdatafromfile(filename, yaxisaddress, yaxislength);
                if (issixteenbit) number /= 2;
                retval = new int[number];
                int offset = 0;
                for (int i = 0; i < yaxislength; i++)
                {

                    if (issixteenbit)
                    {
                        byte val1 = (byte)axisdata.GetValue(i);
                        byte val2 = (byte)axisdata.GetValue(++i);
                        int ival1 = Convert.ToInt32(val1);
                        int ival2 = Convert.ToInt32(val2);
                        int value = (ival1 * 256) + ival2;
                        double valtot = (double)value * multiplier;
                        value = (int)valtot;
                        if (value > 0x8000)
                        {
                            value = 0x10000 - value;
                            value = -value;
                        }
                        retval.SetValue(value, offset++);
                    }
                    else
                    {
                        byte val1 = (byte)axisdata.GetValue(i);
                        int ival1 = Convert.ToInt32(val1);
                        double valtot = (double)ival1 * multiplier;
                        ival1 = (int)valtot;
                        retval.SetValue(ival1, offset++);
                    }
                }
            }
            return retval;
        }
コード例 #35
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
 private void btnUploadTuningPackage_ItemClick(object sender, ItemClickEventArgs e)
 {
     // upload a t7p file to the ECU
     if (m_currentfile != "")
     {
         if (CheckCANConnectivity())
         {
             OpenFileDialog ofd = new OpenFileDialog();
             ofd.Filter = "Trionic 7 packages|*.t7p";
             ofd.Multiselect = false;
             char[] sep = new char[1];
             sep.SetValue(',', 0);
             SymbolCollection scToImport = new SymbolCollection();
             if (ofd.ShowDialog() == DialogResult.OK)
             {
                 //TODO: create a list of maps to import .. maybe?
                 frmProgress progress = new frmProgress();
                 progress.SetProgress("Uploading tuning package...");
                 progress.Show();
                 using (StreamReader sr = new StreamReader(ofd.FileName))
                 {
                     string line = string.Empty;
                     SymbolHelper sh_Import = new SymbolHelper();
                     while ((line = sr.ReadLine()) != null)
                     {
                         if (line.StartsWith("symbol="))
                         {
                             //
                             sh_Import = new SymbolHelper();
                             sh_Import.Varname = line.Replace("symbol=", "");
                         }
                         else if (line.StartsWith("length="))
                         {
                             sh_Import.Length = Convert.ToInt32(line.Replace("length=", ""));
                         }
                         else if (line.StartsWith("data="))
                         {
                             //
                             try
                             {
                                 string dataBytes = line.Replace("data=", "");
                                 // split using ','
                                 string[] bytesInStrings = dataBytes.Split(sep);
                                 byte[] dataToInsert = new byte[sh_Import.Length];
                                 for (int t = 0; t < sh_Import.Length; t++)
                                 {
                                     byte b = Convert.ToByte(bytesInStrings[t], 16);
                                     dataToInsert.SetValue(b, t);
                                 }
                                 int addressInFile = (int)GetSymbolAddress(m_symbols, sh_Import.Varname);
                                 if (addressInFile > 0)
                                 {
                                     if (sh_Import.Varname != "MapChkCal.ST_Enable")
                                     {
                                         progress.SetProgress("Uploading: " + sh_Import.Varname);
                                         WriteMapToSRAM(sh_Import.Varname, dataToInsert, false);
                                         System.Windows.Forms.Application.DoEvents();
                                         Thread.Sleep(1);
                                     }
                                 }
                             }
                             catch (Exception E)
                             {
                                 // add failure
                                 logger.Debug(E.Message);
                             }
                         }
                     }
                 }
                 if (progress != null) progress.Close();
             }
         }
         else
         {
             frmInfoBox info = new frmInfoBox("An active CAN bus connection is needed to upload a tuning package");
         }
     }
 }
コード例 #36
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
 private bool IsSoftwareOpen(SymbolCollection symbols)
 {
     bool retval = false;
     foreach (SymbolHelper sh in symbols)
     {
         if (sh.Flash_start_address > m_currentfile_size && sh.Length > 0x100 && sh.Length < 0x400)
         {
             if (sh.Varname == "BFuelCal.Map" || sh.Varname == "IgnNormCal.Map" || sh.Varname == "AirCtrlCal.map" ||
                 sh.Userdescription == "BFuelCal.Map" || sh.Userdescription == "IgnNormCal.Map" || sh.Userdescription == "AirCtrlCal.map")
             {
                 retval = true; // found maps > 0x100 in size in sram
             }
         }
     }
     return retval;
 }
コード例 #37
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private void btnViewMatrixFromLog_ItemClick(object sender, ItemClickEventArgs e)
        {
            // let the user select x axis, y axis and z axis symbols from the logfile
            //
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Trionic 7 logfiles|*.t7l";
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                avgTable = null;
                string[] alllines = File.ReadAllLines(ofd.FileName);
                System.Windows.Forms.Application.DoEvents();
                DateTime startDate = DateTime.MaxValue;
                DateTime endDate = DateTime.MinValue;
                SymbolCollection sc = new SymbolCollection();
                try
                {
                    // using (StreamReader sr = new StreamReader(ofd.FileName))
                    {
                        //string line = string.Empty;

                        char[] sep = new char[1];
                        char[] sep2 = new char[1];
                        //int linecount = 0;
                        sep.SetValue('|', 0);
                        sep2.SetValue('=', 0);
                        //while ((line = sr.ReadLine()) != null)
                        foreach (string line in alllines)
                        {
                            string[] values = line.Split(sep);
                            if (values.Length > 0)
                            {
                                try
                                {
                                    //dd/MM/yyyy HH:mm:ss
                                    //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                    string dtstring = (string)values.GetValue(0);
                                    DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                    if (dt > endDate) endDate = dt;
                                    if (dt < startDate) startDate = dt;
                                    for (int t = 1; t < values.Length; t++)
                                    {
                                        string subvalue = (string)values.GetValue(t);
                                        string[] subvals = subvalue.Split(sep2);
                                        if (subvals.Length == 2)
                                        {
                                            string varname = (string)subvals.GetValue(0);
                                            bool sfound = false;
                                            foreach (SymbolHelper sh in sc)
                                            {
                                                if (sh.Varname == varname)
                                                {
                                                    sfound = true;
                                                }
                                            }
                                            SymbolHelper nsh = new SymbolHelper();
                                            nsh.Varname = varname;
                                            if (!sfound) sc.Add(nsh);
                                        }
                                    }
                                }
                                catch (Exception pE)
                                {
                                    logger.Debug(pE.Message);
                                }
                            }
                        }
                    }
                }
                catch (Exception E)
                {
                    logger.Debug(E.Message);
                }
                frmMatrixSelection sel = new frmMatrixSelection();
                sel.SetSymbolList(sc);
                sel.SetXSelection(m_appSettings.LastXAxisFromMatrix);
                sel.SetYSelection(m_appSettings.LastYAxisFromMatrix);
                sel.SetZSelection(m_appSettings.LastZAxisFromMatrix);
                if (sel.ShowDialog() == DialogResult.OK)
                {
                    // get selected for x, y and z
                    int type = sel.GetViewType(); // <GS-31032011> 0 = mean values, 1 = minimum values, 2 = maximum values
                    string x = sel.GetXAxisSymbol();
                    string y = sel.GetYAxisSymbol();
                    string z = sel.GetZAxisSymbol();
                    m_appSettings.LastXAxisFromMatrix = x;
                    m_appSettings.LastYAxisFromMatrix = y;
                    m_appSettings.LastZAxisFromMatrix = z;
                    double xmin = Double.MaxValue;
                    double xmax = Double.MinValue;
                    double ymin = Double.MaxValue;
                    double ymax = Double.MinValue;
                    double zmin = Double.MaxValue;
                    double zmax = Double.MinValue;
                    //using (StreamReader sr = new StreamReader(ofd.FileName))
                    {
                        // string line = string.Empty;
                        char[] sep = new char[1];
                        char[] sep2 = new char[1];
                        //int linecount = 0;
                        sep.SetValue('|', 0);
                        sep2.SetValue('=', 0);
                        //while ((line = sr.ReadLine()) != null)

                        foreach (string line in alllines)
                        {
                            string[] values = line.Split(sep);
                            if (values.Length > 0)
                            {
                                try
                                {
                                    //dd/MM/yyyy HH:mm:ss
                                    //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                    string dtstring = (string)values.GetValue(0);
                                    DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                    if (dt > endDate) endDate = dt;
                                    if (dt < startDate) startDate = dt;
                                    for (int t = 1; t < values.Length; t++)
                                    {
                                        string subvalue = (string)values.GetValue(t);
                                        string[] subvals = subvalue.Split(sep2);
                                        if (subvals.Length == 2)
                                        {
                                            string varname = (string)subvals.GetValue(0);
                                            double value = ConvertToDouble((string)subvals.GetValue(1));

                                            if (value > 65535) value = 0;
                                            if (value < -65535) value = 0;
                                            if (varname == x)
                                            {
                                                // get max and min

                                                if (value > xmax) xmax = value;
                                                if (value < xmin) xmin = value;
                                            }
                                            else if (varname == y)
                                            {
                                                // get max and min
                                                if (value > ymax) ymax = value;
                                                if (value < ymin) ymin = value;
                                            }
                                            else if (varname == z)
                                            {
                                                // get max and min
                                                if (value > zmax) zmax = value;
                                                if (value < zmin) zmin = value;
                                            }

                                        }
                                    }
                                }
                                catch (Exception pE)
                                {
                                    logger.Debug(pE.Message);
                                }
                            }
                        }
                    }
                    // now we have it all
                    if (xmin == xmax || ymin == ymax)
                    {
                        frmInfoBox info = new frmInfoBox("No data to display ... x or y axis contains no differentiated values");
                        return;
                    }
                    frmMatrixResult result = new frmMatrixResult();
                    result.SetViewType(type); // <GS-31032011> 0 = mean values, 1 = minimum values, 2 = maximum values

                    // parse the file again and add the points
                    System.Data.DataTable dtresult = new System.Data.DataTable();
                    // xmin = -0.8
                    // xmin = 2.01
                    double[] x_values = new double[16];
                    double[] y_values = new double[16];

                    // fill x and y axis
                    for (int i = 0; i < 16; i++)
                    {

                        double xvalue = xmin;
                        if (i > 0) xvalue = xmin + i * ((xmax - xmin) / (15));
                        //logger.Debug("Adding: " + xvalue.ToString());
                        try
                        {
                            dtresult.Columns.Add(xvalue.ToString(), Type.GetType("System.Double"));
                        }
                        catch (Exception E)
                        {
                            logger.Debug("Failed to add column: " + E.Message);
                        }
                        x_values.SetValue(xvalue, i); //    test: andersom?
                    }
                    for (int i = 0; i < 16; i++)
                    {
                        //double yvalue = ymin + ((ymax - ymin) / i);
                        double yvalue = ymin;
                        if (i > 0) yvalue = ymin + i * ((ymax - ymin) / (15));
                        y_values.SetValue(yvalue, i); //    test: andersom?
                    }
                    for (int i = 0; i < 16; i++)
                    {
                        try
                        {
                            dtresult.Rows.Add(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                        }
                        catch (Exception E)
                        {
                            logger.Debug("Failed to add empty row: " + E.Message);
                        }
                    }
                    // table filled
                    double _lastX = 0;
                    double _lastY = 0;
                    double _lastZ = 0;
                    //using (StreamReader sr = new StreamReader(ofd.FileName))
                    {
                        //string line = string.Empty;
                        char[] sep = new char[1];
                        char[] sep2 = new char[1];
                        //int linecount = 0;
                        sep.SetValue('|', 0);
                        sep2.SetValue('=', 0);
                        //while ((line = sr.ReadLine()) != null)
                        foreach (string line in alllines)
                        {
                            string[] values = line.Split(sep);
                            if (values.Length > 0)
                            {
                                try
                                {
                                    //dd/MM/yyyy HH:mm:ss
                                    //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                    string dtstring = (string)values.GetValue(0);
                                    DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                    if (dt > endDate) endDate = dt;
                                    if (dt < startDate) startDate = dt;
                                    for (int t = 1; t < values.Length; t++)
                                    {
                                        string subvalue = (string)values.GetValue(t);
                                        string[] subvals = subvalue.Split(sep2);
                                        if (subvals.Length == 2)
                                        {
                                            string varname = (string)subvals.GetValue(0);
                                            double value = ConvertToDouble((string)subvals.GetValue(1));
                                            if (varname == x)
                                            {
                                                _lastX = value;
                                            }
                                            else if (varname == y)
                                            {
                                                _lastY = value;
                                            }
                                            else if (varname == z)
                                            {
                                                _lastZ = value;
                                            }

                                        }
                                    }
                                }
                                catch (Exception pE)
                                {
                                    logger.Debug(pE.Message);
                                }
                                // add point to the datatable
                                AddPointToDataTable(dtresult, _lastX, _lastY, _lastZ, xmin, xmax, ymin, ymax, zmin, zmax, type);
                            }
                        }
                    }
                    result.MaxValue = zmax;
                    result.MinValue = zmin;
                    result.SetXAxis(x_values);
                    result.SetYAxis(y_values);
                    result.SetXAxisName(x);
                    result.SetYAxisName(y);
                    result.SetZAxisName(z);
                    result.UseNewMapViewer = m_appSettings.UseNewMapViewer;
                    result.SetTable(dtresult);
                    string typedescr = " (Mean values)";
                    if (type == 1) typedescr = " (Minimum values)";
                    else if (type == 2) typedescr = " (Maximum values)";
                    result.Text = "Matrix [" + x + " : " + y + " : " + z + "]" + typedescr;
                    result.Show();
                }
            }
        }