コード例 #1
0
            public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
            {
                if (destType == typeof(string) && value is LogSection)
                {
                    // Cast the value to an Employee type
                    LogSection pp = (LogSection)value;

                    return(pp.StartDateTime.ToString() + ", " + pp.EndDateTime.ToString());
                }
                return(base.ConvertTo(context, culture, value, destType));
            }
コード例 #2
0
 private void CloseAndReturnLogSection()
 {
     if (listBoxControl1.SelectedItem != null)
     {
         if (listBoxControl1.SelectedItem is LogSection)
         {
             LogSection ls = (LogSection)listBoxControl1.SelectedItem;
             _selectedStart = ls.StartDateTime;
             _selectedEnd   = ls.EndDateTime;
             _valid         = true;
             DialogResult   = DialogResult.OK;
             Close();
         }
     }
 }
コード例 #3
0
 public bool Contains(LogSection value)
 {
     // If value is not of type Int16, this will return false.
     return(List.Contains(value));
 }
コード例 #4
0
 public void Remove(LogSection value)
 {
     List.Remove(value);
 }
コード例 #5
0
 public void Insert(int index, LogSection value)
 {
     List.Insert(index, value);
 }
コード例 #6
0
 public int IndexOf(LogSection value)
 {
     return(List.IndexOf(value));
 }
コード例 #7
0
 public int Add(LogSection value)
 {
     return(List.Add(value));
 }
コード例 #8
0
 public bool Contains(LogSection value)
 {
     // If value is not of type Int16, this will return false.
     return (List.Contains(value));
 }
コード例 #9
0
 public int Add(LogSection value)
 {
     return (List.Add(value));
 }
コード例 #10
0
 public void Remove(LogSection value)
 {
     List.Remove(value);
 }
コード例 #11
0
 public void Insert(int index, LogSection value)
 {
     List.Insert(index, value);
 }
コード例 #12
0
 public int IndexOf(LogSection value)
 {
     return (List.IndexOf(value));
 }
コード例 #13
0
        private LogSectionCollection AnalyseFile(string filename)
        {
            LogSectionCollection lsc = new LogSectionCollection();
            DateTime _previousDateTime = DateTime.MinValue;
            DateTime _sectionStart = DateTime.MinValue;
            DateTime _sectionEnd = DateTime.MinValue;
            string[] alllines = File.ReadAllLines(filename);
            //using (StreamReader sr = new StreamReader(filename))
            {
                //string line = string.Empty;
                //while ((line = sr.ReadLine()) != null)
                foreach (string line in alllines)
                {
                    char[] sep = new char[1];
                    sep.SetValue('|', 0);
                    char[] sepequals = new char[1];
                    sepequals.SetValue('=', 0);
                    if (line.Length > 0)
                    {
                        //10/03/2009 07:33:06.187|P_Manifold10=-0.64|Lufttemp=8.00|Rpm=1660.00|Bil_hast=15.20|Ign_angle=28.50|AD_EGR=127.00|AFR=17.86|InjectorDC=2.49|Power=0.00|Torque=0.00|
                        // fetch all values from the line including the timestamp
                        string[] values = line.Split(sep);
                        if (values.Length > 1)
                        {
                            try
                            {
                                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)));
                                }

                                //DateTime dt = Convert.ToDateTime(values.GetValue(0));
                                if (_previousDateTime == DateTime.MinValue)
                                {
                                    _previousDateTime = dt; // sync
                                }

                                TimeSpan ts = new TimeSpan(dt.Ticks - _previousDateTime.Ticks);
                                if (_sectionStart == DateTime.MinValue)
                                {
                                   // at least one section
                                    _sectionStart = dt;
                                    _sectionEnd = dt; // initial

                                }
                                if (ts.TotalSeconds < 10)
                                {
                                    _sectionEnd = dt;
                                }
                                else
                                {
                                    LogSection ls = new LogSection();
                                    ls.StartDateTime = _sectionStart;
                                    ls.EndDateTime = _sectionEnd;
                                    ls.Duration = new TimeSpan(ls.EndDateTime.Ticks - ls.StartDateTime.Ticks);
                                    lsc.Add(ls);
                                    // reset probes
                                    //_previousDateTime = _sectionEnd;
                                    _previousDateTime = DateTime.MinValue;
                                    _sectionStart = DateTime.MinValue;
                                    _sectionEnd = DateTime.MinValue;
                                }
                                _previousDateTime = dt;

                            }
                            catch (Exception E)
                            {
                                Console.WriteLine(E.Message);
                            }

                        }
                    }
                }
            }
            if (_sectionStart != DateTime.MinValue && _sectionEnd != DateTime.MinValue)
            {
                LogSection ls = new LogSection();
                ls.StartDateTime = _sectionStart;
                ls.EndDateTime = _sectionEnd;
                ls.Duration = new TimeSpan(ls.EndDateTime.Ticks - ls.StartDateTime.Ticks);
                lsc.Add(ls);
            }
            return lsc;
        }