Exemplo 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");
            }
        }
Exemplo n.º 2
0
 private void OpenSession()
 {
     if (!session.IsOpen)
     {
         try
         {
             session.Open();
         }
         catch (Exception e)
         {
             MessageBox.Show(e.ToString());
             session.Close();
         }
     }
     else
     {
         MessageBox.Show("A session is already open");
     }
 }
Exemplo n.º 3
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));
        }