Example #1
0
        List <DataPointCollection> GetRanges()
        {
            List <DataPointCollection> ranges = new List <DataPointCollection>();
            DataPoint           last          = null;
            DataPointCollection range         = null;

            for (int i = 0; i < dataPoints.Count; ++i)
            {
                DataPoint current = dataPoints[i];
                if (current.dutyCycle != this.DutyCycleActual)
                {
                    continue;
                }

                if (range == null ||
                    current.timestamp - last.timestamp > .25m) //probably should do this a better way
                {
                    range = new DataPointCollection(settings);
                    ranges.Add(range);
                }
                range.Add(current);
                last = current;
            }
            return(ranges);
        }
Example #2
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");
            }
        }