Beispiel #1
0
 private void SetupLogFilters()
 {
     // setup the export filters
     LogFilters filterhelper = new LogFilters();
     frmLogFilters frmfilters = new frmLogFilters();
     LogFilterCollection filters = filterhelper.GetFiltersFromRegistry();
     frmfilters.SetFilters(filters);
     Trionic5Tools.SymbolCollection sc = new Trionic5Tools.SymbolCollection();
     foreach (Trionic5Tools.SymbolHelper sh in m_trionicFileInformation.SymbolCollection)
     {
         if (!sh.Varname.Contains("!")) sc.Add(sh);
     }
     frmfilters.SetSymbols(sc);
     if (frmfilters.ShowDialog() == DialogResult.OK)
     {
         filterhelper.SaveFiltersToRegistry(frmfilters.GetFilters());
     }
 }
Beispiel #2
0
        private void ConvertFileToDif(string filename, bool AutoExport)
        {
            System.Windows.Forms.Application.DoEvents();
            DateTime startDate = DateTime.MaxValue;
            DateTime endDate = DateTime.MinValue;
            try
            {
                Trionic5Tools.SymbolCollection sc = new Trionic5Tools.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 (Trionic5Tools.SymbolHelper sh in sc)
                                        {
                                            if (sh.Varname == varname)
                                            {
                                                sfound = true;
                                            }
                                        }
                                        Trionic5Tools.SymbolHelper nsh = new Trionic5Tools.SymbolHelper();
                                        nsh.Varname = varname;
                                        if (!sfound) sc.Add(nsh);
                                    }
                                }
                            }
                            catch (Exception pE)
                            {
                                Console.WriteLine(pE.Message);
                            }
                        }
                    }
                }

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

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

                    difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress);
                    System.Windows.Forms.Application.DoEvents();
                    try
                    {
                        difgen.ConvertFileToDif(filename, sc, startDate, endDate, true, true);
                    }
                    catch (Exception expE1)
                    {
                        Console.WriteLine(expE1.Message);
                    }
                }
                else
                {

                    // show selection screen
                    frmPlotSelection plotsel = new frmPlotSelection();
                    foreach (Trionic5Tools.SymbolHelper sh in sc)
                    {
                        if (sh.Varname != "Pgm_status")
                        {
                            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.LowAFR = m_appSettings.WidebandLowAFR / 1000;
                        difgen.HighAFR = m_appSettings.WidebandHighAFR / 1000;
                        difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage / 1000;
                        difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage / 1000;
                        difgen.WidebandSymbol = m_appSettings.WidebandLambdaSymbol;
                        difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol;
                        difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress);
                        try
                        {
                            if (difgen.ConvertFileToDif(filename, sc, startDate, endDate, m_appSettings.InterpolateLogWorksTimescale, true))
                            {
                                //difgen.ConvertFileToDif(filename, sc, startDate, endDate, false, false);
                                StartLogWorksWithCurrentFile(Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".dif");
                            }
                            else
                            {
                                frmInfoBox info = new frmInfoBox("No data was found to export!");
                            }
                        }
                        catch (Exception expE2)
                        {
                            Console.WriteLine(expE2.Message);
                        }
                    }
                    TimeSpan ts = new TimeSpan(endDate.Ticks - startDate.Ticks);
                }
            }
            catch (Exception E)
            {
                Console.WriteLine(E.Message);
            }
        }
Beispiel #3
0
        private void OpenAndDisplayLogFile(string filename)
        {
            // create a new dock with a graph view in it
            //dockManager1.BeginUpdate();
            DevExpress.XtraBars.Docking.DockPanel dp = dockManager1.AddPanel(DevExpress.XtraBars.Docking.DockingStyle.Left);

            dp.Size = new Size(dockManager1.Form.ClientSize.Width - dockSymbols.Width, dockSymbols.Height);
            dp.Hide();
            dp.Text = "CANBus logfile: " + Path.GetFileName(filename);
            RealtimeGraphControl lfv = new RealtimeGraphControl();
            LogFilters lfhelper = new LogFilters();
            lfv.SetFilters(lfhelper.GetFiltersFromRegistry());
            dp.Controls.Add(lfv);
            lfv.ImportT5Logfile(filename);
            //dp.Height = 600;
            lfv.Dock = DockStyle.Fill;
            dp.Show();
        }
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            // setup the export filters
            LogFilters filterhelper = new LogFilters();
            frmLogFilters frmfilters = new frmLogFilters();
            LogFilterCollection filters = filterhelper.GetFiltersFromRegistry();
            Console.WriteLine("filters: " + filters.Count);
            frmfilters.SetFilters(filters);
            if (gridControl1.DataSource != null)
            {
                DataTable dt = (DataTable)gridControl1.DataSource;

                int[] selrows = gridView1.GetSelectedRows();
                foreach (int rowhandle in selrows)
                {
                    DataRowView dv = (DataRowView)gridView1.GetRow(rowhandle);
                    if (dv != null)
                    {
                        SymbolHelper sh = new SymbolHelper();
                        sh.Varname = dv.Row["SYMBOLNAME"].ToString();
                        sh.Color = Color.FromArgb(Convert.ToInt32(dv.Row["COLOR"]));
                        _sc.Add(sh);
                    }
                }

            }
            frmfilters.SetSymbols(_sc);
            if (frmfilters.ShowDialog() == DialogResult.OK)
            {
                DialogResult = DialogResult.None;
                filterhelper.SaveFiltersToRegistry(frmfilters.GetFilters());
            }
        }