public RapidSolution_C04[] analyseFileRapidC04(string path, string adress, ref string message) { RapidSolution_C04[] c04 = null; System.Collections.ArrayList tmp = new System.Collections.ArrayList(); string str = null; StreamReader reader = null; try { reader = new StreamReader(new FileStream(path, FileMode.Open)); while ((str = reader.ReadLine()) != null) { if (str.Length > 6) { str = str.Remove(0, 6); } double result = double.NaN; double mjd = double.NaN; if (str.Length >= 9) { string stmp = str.Substring(0, 9); double.TryParse(stmp, System.Globalization.NumberStyles.Any, Constants.NumberFormatEN, out result); if (result == 0.0) { mjd = double.NaN; } else { mjd = result; } } double x = double.NaN; if (str.Length >= 21) { string stmp = str.Substring(11, 10); double.TryParse(stmp, System.Globalization.NumberStyles.Any, Constants.NumberFormatEN, out result); if (result == 0.0) { x = double.NaN; } else { x = result; } } double y = double.NaN; if (str.Length >= 40) { string stmp = str.Substring(30, 10); double.TryParse(stmp, System.Globalization.NumberStyles.Any, Constants.NumberFormatEN, out result); if (result == 0.0) { y = double.NaN; } else { y = result; } } double UT1_UTC = double.NaN; if (str.Length >= 62) { string stmp = str.Substring(52, 10); double.TryParse(stmp, System.Globalization.NumberStyles.Any, Constants.NumberFormatEN, out result); if (result == 0.0) { UT1_UTC = double.NaN; } else { UT1_UTC = result; } } double LOD = double.NaN; if (str.Length >= 80) { string stmp = str.Substring(72, 8); double.TryParse(stmp, System.Globalization.NumberStyles.Any, Constants.NumberFormatEN, out result); if (result == 0.0) { LOD = double.NaN; } else { LOD = result; } } double prediction = double.NaN; if (str.Contains("P")) { prediction = 1.0; } else { prediction = 0.0; } if (!double.IsNaN(mjd) && !double.IsNaN(x) && !double.IsNaN(y) && !double.IsNaN(UT1_UTC)) { DateTime dt = TimeConversion.TimeConversion.ModJulDay2Time(mjd); tmp.Add(new double[9] { dt.Year, dt.Month, dt.Day, mjd, x, y, UT1_UTC, LOD / 1000.0, prediction }); } } reader.Close(); c04 = new RapidSolution_C04[tmp.Count]; for (int i = 0; i < tmp.Count; i++) { double[] t = (double[])tmp[i]; c04[i] = new RapidSolution_C04(t[3], new DateTime((int)t[0], (int)t[1], (int)t[2], 0, 0, 0), t[4], t[5], t[6], t[7], Convert.ToBoolean(t[8])); } } catch (Exception ex) { if (reader != null) { reader.Close(); } c04 = null; message += "Error on analysis of the rapid solution from:" + Environment.NewLine + " " + adress + Environment.NewLine + "System Error:" + ex.Message + Environment.NewLine; } return(c04); }
/// <summary> /// Analyses the file 'finals.data' from UNSO. /// </summary> /// <param name="path">Path of the file.</param> /// <param name="adress">Address of the host, where the file to be analyses are found.</param> /// <param name="message">Error message, if something was going wrong on reading.</param> /// <returns>Returns the the object for 'RapidSolution_C04' (favorable is used the temporary object)</returns> public RapidSolution_C04[] analyseFileRapidC04_old(string path, string adress, ref string message) { RapidSolution_C04[] c04 = null; System.Collections.ArrayList tmp = new System.Collections.ArrayList(); string str = null; char[] delimeter = new char[] { ' ', '\t', 'I', 'P' }; string[] parts = null; StreamReader reader = null; try { reader = new StreamReader(new FileStream(path, FileMode.Open)); while ((str = reader.ReadLine()) != null) { if (str.Length > 6) { str = str.Remove(0, 6); } parts = str.Split(delimeter, StringSplitOptions.RemoveEmptyEntries); double mjd, x, y, UT1_UTC, LOD, prediction = double.NaN; if (str.Contains("P")) { prediction = 1.0; } else { prediction = 0.0; } if (parts != null && parts.Length > 13 && double.TryParse(parts[0], System.Globalization.NumberStyles.Any, Constants.NumberFormatEN, out mjd) && double.TryParse(parts[1], System.Globalization.NumberStyles.Any, Constants.NumberFormatEN, out x) && double.TryParse(parts[3], System.Globalization.NumberStyles.Any, Constants.NumberFormatEN, out y) && double.TryParse(parts[5], System.Globalization.NumberStyles.Any, Constants.NumberFormatEN, out UT1_UTC) && double.TryParse(parts[7], System.Globalization.NumberStyles.Any, Constants.NumberFormatEN, out LOD)) { DateTime dt = TimeConversion.TimeConversion.ModJulDay2Time(mjd); tmp.Add(new double[9] { dt.Year, dt.Month, dt.Day, mjd, x, y, UT1_UTC, LOD / 1000.0, prediction }); } } reader.Close(); c04 = new RapidSolution_C04[tmp.Count]; for (int i = 0; i < tmp.Count; i++) { double[] t = (double[])tmp[i]; c04[i] = new RapidSolution_C04(t[3], new DateTime((int)t[0], (int)t[1], (int)t[2], 0, 0, 0), t[4], t[5], t[6], t[7], Convert.ToBoolean(t[8])); } } catch (Exception ex) { if (reader != null) { reader.Close(); } c04 = null; message += "Error on analysis of the rapid solution from:" + Environment.NewLine + " " + adress + Environment.NewLine + "System Error:" + ex.Message + Environment.NewLine; } return(c04); }