public void ImportT5Logfile(string filename) { frmProgress progress = new frmProgress(); progress.Show(); Application.DoEvents(); if (File.Exists(filename)) { _lines.Clear(); _zoomfactor = 1; FileInfo fi = new FileInfo(filename); long bytesread = 0; using (StreamReader sr = new StreamReader(filename)) { string line = string.Empty; while ((line = sr.ReadLine()) != null) { bytesread += line.Length + 2; progress.SetProgressPercentage((int)(bytesread * 100 / fi.Length)); 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 { DateTime dt = Convert.ToDateTime(values.GetValue(0)); for (int tel = 1; tel < values.Length; tel++) { string valuepart = (string)values.GetValue(tel); string[] valueparts = valuepart.Split(sepequals); if (valueparts.Length == 2) { string symbol = (string)valueparts.GetValue(0); string strvalue = (string)valueparts.GetValue(1); double dval = ConvertToDouble(strvalue); this.AddMeasurement(GetGraphName(symbol), symbol, dt, (float)dval, 0, 1, GetGraphColor(symbol)); } } } catch (Exception E) { Console.WriteLine("Failed to process line: " + line + " : " + E.Message); } } } } foreach (GraphLine _line in _lines) { float _min = 0; float _max = -10000; foreach (GraphMeasurement gm in _line.Measurements) { if (gm.Value > _max) { _max = gm.Value; } if (gm.Value < _min) { _min = gm.Value; } } DetermineRange(_line, _min, _max); } } } progress.Close(); }
public void ImportT5Logfile(string filename) { frmProgress progress = new frmProgress(); progress.Show(); Application.DoEvents(); if(File.Exists(filename)) { _lines.Clear(); _zoomfactor = 1; FileInfo fi = new FileInfo(filename); long bytesread = 0; using (StreamReader sr = new StreamReader(filename)) { string line = string.Empty; while ((line = sr.ReadLine()) != null) { bytesread += line.Length + 2; progress.SetProgressPercentage((int)(bytesread * 100 / fi.Length)); 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 { DateTime dt = Convert.ToDateTime(values.GetValue(0)); for (int tel = 1; tel < values.Length; tel++) { string valuepart = (string)values.GetValue(tel); string[] valueparts = valuepart.Split(sepequals); if (valueparts.Length == 2) { string symbol = (string)valueparts.GetValue(0); string strvalue = (string)valueparts.GetValue(1); double dval = ConvertToDouble(strvalue); this.AddMeasurement(GetGraphName(symbol), symbol, dt, (float)dval, 0, 1, GetGraphColor(symbol)); } } } catch (Exception E) { Console.WriteLine("Failed to process line: " + line + " : " + E.Message); } } } } foreach (GraphLine _line in _lines) { float _min = 0; float _max = -10000; foreach (GraphMeasurement gm in _line.Measurements) { if (gm.Value > _max) _max = gm.Value; if (gm.Value < _min) _min = gm.Value; } DetermineRange(_line, _min, _max); } } } progress.Close(); }