public Record Read(string text) { var recordType = RecordTypeExtension.Parse(text); if (recordType != RecordType.A) { throw new ArgumentException("Wrong record type"); } var code = text.Substring(1, 3); var substring = text.Substring(4).Split(new[] { ':' }); var id = substring[0]; return(new FlightRecorderRecord(code, id, substring.Length > 0 ? substring[1] : string.Empty)); }
Record IRecordReader.Read(string text) { var recordType = RecordTypeExtension.Parse(text); if (recordType != RecordType.B) { throw new ArgumentException("Wrong record type"); } var hours = TimeSpan.FromHours(double.Parse(text.Substring(1, 2))); var minutes = TimeSpan.FromMinutes(double.Parse(text.Substring(3, 2))); var seconds = TimeSpan.FromSeconds(double.Parse(text.Substring(5, 2))); var timeStamp = hours + minutes + seconds; var latitude = ParseLatitude(text.Substring(7, 8)); var longitude = ParseLongitude(text.Substring(15, 9)); var validity = text[24] == 'A' ? FixValidity.ThreeDimensions : FixValidity.TwoDimensions; var pressureAltitude = int.Parse(text.Substring(25, 5)); var gnssAltitude = int.Parse(text.Substring(30, 5)); var additionalData = text.Length > 35 ? text.Substring(35) : string.Empty; return(new FixRecord(timeStamp, latitude, longitude, pressureAltitude, gnssAltitude, additionalData, validity)); }
public Records.Record Read(string text) { var recordType = RecordTypeExtension.Parse(text); if (recordType != RecordType.H) { throw new ArgumentException("Wrong record type"); } var source = text[1] == 'F' ? DataSource.FlightRecorder : DataSource.Other; var values = text.Split(new[] { ':' }); var value = values.Length > 1 ? values[1] : string.Empty; // Parse the Three letters code if (Enum.TryParse <ThreeLetterCode>(text.Substring(2, 3), out ThreeLetterCode tlc)) { return(new HeaderRecord(source, tlc, text, value)); } else { // Unknown three letter code found return(new HeaderRecord(source, ThreeLetterCode.X, text, value)); } }
public Record Read(string text) { var recordType = RecordTypeExtension.Parse(text); return(Read(recordType, text)); }