Ejemplo n.º 1
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(txtDir.Text))
            {
                MessageBox.Show("Please choose a log directory");
                return;
            }

            settings = LoadSettings();

            closedCount     = 0;
            logs            = new List <ME7LoggerLog>();
            dataPointsByLog = new Dictionary <ME7LoggerLog, DataPointCollection>();

            DirectoryInfo dir = new DirectoryInfo(txtDir.Text);

            int errors = 0;

            foreach (FileInfo file in dir.GetFiles("*.csv"))
            {
                try
                {
                    ME7LoggerSession session = new ME7LoggerSession("", file.FullName, noWait: true);
                    session.LogLineRead   += LogLineRead;
                    session.StatusChanged += SessionStatusChanged;

                    ME7LoggerLog log = session.Log;
                    logs.Add(log);
                    dataPointsByLog[log] = new DataPointCollection(settings);

                    session.Open();
                }
                catch (Exception ex)
                {
                    errors++;
                    closedCount++;
                }
            }

            //waiting for all logs to finish reading (hope visualme7logger.output is threadsafe :) )

            while (errors + closedCount < logs.Count)
            {
                System.Threading.Thread.Sleep(10);
            }

            BuildValues();

            if (errors > 0)
            {
                MessageBox.Show("Errors while processing log files");
            }
        }
Ejemplo n.º 2
0
        public Form1(string configFile, VisualME7Logger.Session.LoggerOptions options, DisplayOptions displayOptions)
        {
            InitializeComponent();

            this.pnlSessionData.Visible = this.spSessionData.Visible = sessionOutputToolStripMenuItem.Checked;

            this.DisplayOptions = displayOptions;
            foreach (var v in Enum.GetValues(typeof(SeriesChartType)))
            {
                cmbChartType.Items.Add(v);
            }
            cmbChartType.SelectedItem = SeriesChartType.FastLine;

            refreshTimer.Tick    += refreshTimer_Tick;
            refreshTimer.Interval = DisplayOptions.RefreshInterval;
            txtRefreshRate.Text   = DisplayOptions.RefreshInterval.ToString();

            if (options.ConnectionType == LoggerOptions.ConnectionTypes.LogFile)
            {
                session = new ME7LoggerSession(Program.ME7LoggerDirectory, options.LogFile,
                                               Program.DebugOutput ?
                                               ME7LoggerSession.SessionTypes.SessionOutput :
                                               ME7LoggerSession.SessionTypes.LogFile);
                this.Text += " - " + session.FileName;
            }
            else
            {
                session = new ME7LoggerSession(Program.ME7LoggerDirectory, options.LogFile, options, configFile);
            }
            session.ExpressionVariables = DisplayOptions.Expressions;

            session.StatusChanged += new ME7LoggerSession.LoggerSessionStatusChanged(this.SessionStatusChanged);
            session.LogLineRead   += new ME7LoggerSession.LogLineReadDel(this.LogLineRead);
            session.DataRead      += new ME7LoggerSession.SessionDataRead(this.SessionDataRead);

            this.OpenSession();

            pauseToolStripMenuItem.Enabled           =
                forwardToolStripMenuItem.Enabled     =
                    reverseToolStripMenuItem.Enabled =
                        scrollbar.Visible            =
                            increasePlaybackSpeedToolStripMenuItem.Enabled      =
                                decreasePlaybackSpeedToolStripMenuItem.Enabled  =
                                    resetPlaybackSpeedToolStripMenuItem.Enabled = session.CanSetPlaybackSpeed;

            this.writeDataToLogFileToolStripMenuItem.Enabled = options.ConnectionType != LoggerOptions.ConnectionTypes.LogFile;
            this.writeDataToLogFileToolStripMenuItem.Checked = session.WriteLogToFileEnabled;
        }
Ejemplo n.º 3
0
 //For testing using text files
 public ME7LoggerLog(ME7LoggerSession session, string logFilePath, bool noWait = false)
     : this(session)
 {
     this.LogFilePath = logFilePath;
     this.noWait      = noWait;
 }
Ejemplo n.º 4
0
 internal ME7LoggerLog(ME7LoggerSession session)
 {
     this.Session = session;
 }
Ejemplo n.º 5
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            wait            = true;
            closedCount     = 0;
            logs            = new List <ME7LoggerLog>();
            dataPointsByLog = new Dictionary <ME7LoggerLog, List <DataPoint> >();
            logsByDutyCycle = new Dictionary <decimal, HashSet <ME7LoggerLog> >();

            DirectoryInfo dir = new DirectoryInfo(txtDir.Text);

            int errors = 0;

            foreach (FileInfo file in dir.GetFiles("*.csv"))
            {
                try
                {
                    ME7LoggerSession session = new ME7LoggerSession("", file.FullName, noWait: true);
                    session.LogLineRead   += LogLineRead;
                    session.StatusChanged += SessionStatusChanged;
                    session.Open();

                    ME7LoggerLog log = session.Log;
                    logs.Add(log);
                    dataPointsByLog[log] = new List <DataPoint>();
                }
                catch
                {
                    errors++;
                }
            }


            //waiting for all logs to finish reading (hope visualme7logger.output is threadsafe :) )

            while (wait)
            {
                System.Threading.Thread.Sleep(10);
            }

            foreach (var log in dataPointsByLog.Keys)
            {
                List <DataPoint> dataPoints = dataPointsByLog[log];
                if (dataPoints.Count == 0)
                {
                    continue;
                }
                int roundedDC = (int)Math.Round(dataPoints[dataPoints.Count / 2].dutyCycle);

                for (int d = 0; d < dutyCycles.Length; ++d)
                {
                    if (dutyCycles[d] == roundedDC)
                    {
                        for (int r = 0; r < rpms.Length; ++r)
                        {
                            int rpm = rpms[r];
                            List <DataPoint> highPoints = new List <DataPoint>();
                            List <DataPoint> lowPoints  = new List <DataPoint>();
                            for (int i = 0; i < dataPoints.Count; ++i)
                            {
                                if (dataPoints[i].rpm <= rpm && (dataPoints.Count >= i + 1 || dataPoints[i + 1].rpm >= rpm))
                                {
                                    lowPoints.Add(dataPoints[i]);
                                }
                                else if (dataPoints[i].rpm >= rpm && (i - 1 < 0 || dataPoints[i - 1].rpm <= rpm))
                                {
                                    highPoints.Add(dataPoints[i]);
                                }
                            }

                            decimal highPressure = highPoints.Count > 0 ? highPoints.Average(p => p.absolutePressure) : 0;
                            decimal lowPressure  = lowPoints.Count > 0 ? lowPoints.Average(p => p.absolutePressure) : 0;

                            decimal value = highPressure == 0 ? lowPressure : lowPressure == 0 ? highPressure : (highPressure + lowPressure) / 2;

                            grdTable.Rows[r + 1].Cells[d + 1].Value = value.ToString("0.000");
                        }
                    }
                }
            }

            MessageBox.Show(string.Format("Done with {0} errors", errors));
        }
Ejemplo n.º 6
0
 //For testing using text files
 public ME7LoggerLog(ME7LoggerSession session, string logFilePath)
     : this(session)
 {
     this.logFilePath = logFilePath;
 }