private List<NmeaBurst> GetUpgradeNmeaBursts() { StringBuilder query = new StringBuilder(); query.AppendFormat(@"SELECT {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20}, {21}, {22}, {23}, {24}, {25}, {26}, {27}, {28}, {29}, {30}, {31}, {32}, {33}, {34}, {35}, {36}, {37}, {38}, {39}, {40}, {41}, {42}, {43}, {44}, {45}, {46}, {47}, {48}, {49}, {50}, {51}, {52}, {53}, {54}, {55}, {56}, {57}, {58}, {59}, {60}, {61}, {62}, {63}, {64}, {65}, {66}, {67}, {68}, {69}, {70}, {71}, {72}, {73}, {74}, {75} from {76}", #region Values TwoTrailsSchema.SharedSchema.CN, //0 TwoTrailsSchema.TtnmeaSchema.PointCN, TwoTrailsSchema.TtnmeaSchema.Used, TwoTrailsSchema.TtnmeaSchema.DateTimeZulu, TwoTrailsSchema.TtnmeaSchema.Longitude, TwoTrailsSchema.TtnmeaSchema.Latitude, //5 TwoTrailsSchema.TtnmeaSchema.LatDir, TwoTrailsSchema.TtnmeaSchema.LonDir, TwoTrailsSchema.TtnmeaSchema.MagVar, TwoTrailsSchema.TtnmeaSchema.MagDir, TwoTrailsSchema.TtnmeaSchema.UtmZone, //10 TwoTrailsSchema.TtnmeaSchema.UtmX, TwoTrailsSchema.TtnmeaSchema.UtmY, TwoTrailsSchema.TtnmeaSchema.Altitude, TwoTrailsSchema.TtnmeaSchema.AltUnit, TwoTrailsSchema.TtnmeaSchema.FixQuality, //15 TwoTrailsSchema.TtnmeaSchema.Mode, TwoTrailsSchema.TtnmeaSchema.PDOP, TwoTrailsSchema.TtnmeaSchema.HDOP, TwoTrailsSchema.TtnmeaSchema.VDOP, TwoTrailsSchema.TtnmeaSchema.PRNS, //20 TwoTrailsSchema.TtnmeaSchema.HDo_Position, TwoTrailsSchema.TtnmeaSchema.HAE, TwoTrailsSchema.TtnmeaSchema.HAE_Unit, TwoTrailsSchema.TtnmeaSchema.Speed, TwoTrailsSchema.TtnmeaSchema.Track_Angle, TwoTrailsSchema.TtnmeaSchema.SatelliteCount, TwoTrailsSchema.TtnmeaSchema.SatelliteUsed, //27 TwoTrailsSchema.TtnmeaSchema.PRN1ID, //28 TwoTrailsSchema.TtnmeaSchema.PRN1Elev, TwoTrailsSchema.TtnmeaSchema.PRN1Az, TwoTrailsSchema.TtnmeaSchema.PRN1SRN, TwoTrailsSchema.TtnmeaSchema.PRN2ID, //32 TwoTrailsSchema.TtnmeaSchema.PRN2Elev, TwoTrailsSchema.TtnmeaSchema.PRN2Az, TwoTrailsSchema.TtnmeaSchema.PRN2SRN, TwoTrailsSchema.TtnmeaSchema.PRN3ID, //36 TwoTrailsSchema.TtnmeaSchema.PRN3Elev, TwoTrailsSchema.TtnmeaSchema.PRN3Az, TwoTrailsSchema.TtnmeaSchema.PRN3SRN, TwoTrailsSchema.TtnmeaSchema.PRN4ID, //40 TwoTrailsSchema.TtnmeaSchema.PRN4Elev, TwoTrailsSchema.TtnmeaSchema.PRN4Az, TwoTrailsSchema.TtnmeaSchema.PRN4SRN, TwoTrailsSchema.TtnmeaSchema.PRN5ID, //44 TwoTrailsSchema.TtnmeaSchema.PRN5Elev, TwoTrailsSchema.TtnmeaSchema.PRN5Az, TwoTrailsSchema.TtnmeaSchema.PRN5SRN, TwoTrailsSchema.TtnmeaSchema.PRN6ID, //48 TwoTrailsSchema.TtnmeaSchema.PRN6Elev, TwoTrailsSchema.TtnmeaSchema.PRN6Az, TwoTrailsSchema.TtnmeaSchema.PRN6SRN, TwoTrailsSchema.TtnmeaSchema.PRN7ID, //52 TwoTrailsSchema.TtnmeaSchema.PRN7Elev, TwoTrailsSchema.TtnmeaSchema.PRN7Az, TwoTrailsSchema.TtnmeaSchema.PRN7SRN, TwoTrailsSchema.TtnmeaSchema.PRN8ID, //56 TwoTrailsSchema.TtnmeaSchema.PRN8Elev, TwoTrailsSchema.TtnmeaSchema.PRN8Az, TwoTrailsSchema.TtnmeaSchema.PRN8SRN, TwoTrailsSchema.TtnmeaSchema.PRN9ID, //60 TwoTrailsSchema.TtnmeaSchema.PRN9Elev, TwoTrailsSchema.TtnmeaSchema.PRN9Az, TwoTrailsSchema.TtnmeaSchema.PRN9SRN, TwoTrailsSchema.TtnmeaSchema.PRN10ID, //64 TwoTrailsSchema.TtnmeaSchema.PRN10Elev, TwoTrailsSchema.TtnmeaSchema.PRN10Az, TwoTrailsSchema.TtnmeaSchema.PRN10SRN, TwoTrailsSchema.TtnmeaSchema.PRN11ID, //68 TwoTrailsSchema.TtnmeaSchema.PRN11Elev, TwoTrailsSchema.TtnmeaSchema.PRN11Az, TwoTrailsSchema.TtnmeaSchema.PRN11SRN, TwoTrailsSchema.TtnmeaSchema.PRN12ID, //72 TwoTrailsSchema.TtnmeaSchema.PRN12Elev, TwoTrailsSchema.TtnmeaSchema.PRN12Az, TwoTrailsSchema.TtnmeaSchema.PRN12SRN, //75 TwoTrailsSchema.TtnmeaSchema.TableName); //76 #endregion List<NmeaBurst> Bursts = new List<NmeaBurst>(); SQLiteCommand cmd = _dbConnection.CreateCommand(); try { cmd.CommandText = query.ToString(); NmeaBurst burst = new NmeaBurst(); SQLiteDataReader reader = cmd.ExecuteReader(); #region Reader while (reader.Read()) { if (!reader.IsDBNull(0)) burst._CN = reader.GetString(0); if (!reader.IsDBNull(1)) burst._PointCN = reader.GetString(1); if (!reader.IsDBNull(2)) burst._Used = reader.GetBoolean(2); if (!reader.IsDBNull(3)) burst._datetime = DateTime.Parse(reader.GetString(3)); if (!reader.IsDBNull(4)) burst._longitude = reader.GetDouble(4); if (!reader.IsDBNull(5)) burst._latitude = reader.GetDouble(5); if (!reader.IsDBNull(6)) burst._latDir = (NorthSouth)Enum.Parse(typeof(NorthSouth), reader.GetString(6), true); if (!reader.IsDBNull(7)) burst._longDir = (EastWest)Enum.Parse(typeof(EastWest), reader.GetString(7), true); if (!reader.IsDBNull(8)) burst._magVar = reader.GetDouble(8); if (!reader.IsDBNull(9)) burst._magVarDir = (EastWest)Enum.Parse(typeof(EastWest), reader.GetString(9), true); if (!reader.IsDBNull(10)) burst._utm_zone = reader.GetInt32(10); if (!reader.IsDBNull(11)) burst._X = reader.GetDouble(11); if (!reader.IsDBNull(12)) burst._Y = reader.GetDouble(12); if (!reader.IsDBNull(13)) { burst._altitude = reader.GetDouble(13); burst._Z = burst._altitude; } if (!reader.IsDBNull(14)) burst._alt_unit = (Unit)Enum.Parse(typeof(Unit), reader.GetString(14), true); if (!reader.IsDBNull(15)) burst._fix_quality = reader.GetInt32(15); if (!reader.IsDBNull(16)) burst._fix = reader.GetInt32(16); if (!reader.IsDBNull(17)) burst._PDOP = reader.GetDouble(17); if (!reader.IsDBNull(18)) burst._HDOP = reader.GetDouble(18); if (!reader.IsDBNull(19)) burst._VDOP = reader.GetDouble(19); if (!reader.IsDBNull(20)) burst._fixed_PRNs = reader.GetString(20); if (!reader.IsDBNull(21)) burst._horiz_dilution_position = reader.GetDouble(21); if (!reader.IsDBNull(22)) burst._geoid_height = reader.GetDouble(22); if (!reader.IsDBNull(23)) burst._geoid_unit = (Unit)Enum.Parse(typeof(Unit), reader.GetString(23), true); if (!reader.IsDBNull(24)) burst._speed = reader.GetDouble(24); if (!reader.IsDBNull(25)) burst._track_angle = reader.GetDouble(25); if (!reader.IsDBNull(26)) burst._num_of_sat = reader.GetInt32(26); if (!reader.IsDBNull(27)) burst._num_of_used_sat = reader.GetInt32(27); for (int i = 28; i < 76; i += 4) { Satellite sat = new Satellite(); if (!reader.IsDBNull(i)) sat.ID = reader.GetString(i); if (!reader.IsDBNull(i + 1)) sat.Elevation = reader.GetDouble(i + 1); if (!reader.IsDBNull(i + 2)) sat.Azimuth = reader.GetDouble(i + 2); if (!reader.IsDBNull(i + 3)) sat.SNR = reader.GetDouble(i + 3); burst.AddSatalite(sat); } Bursts.Add(burst); burst = new NmeaBurst(); } #endregion } catch (Exception ex) { TtUtils.WriteError(ex.Message, "DataAccessUpgrader:GetNmeaBursts", ex.StackTrace); } finally { cmd.Dispose(); } return Bursts; }
/// <summary> /// Parses a GSV sentence /// </summary> /// <param name="tokens">String tokens from the NMEA sentence</param> /// <param name="toFill">NmeaBurst to put the sentence data into</param> private void ParseGSV(String[] tokens, ref NmeaBurst toFill) { try { if (tokens[1] != String.Empty && toFill.totalGSV < 0) { if (tokens[1].IsInteger()) toFill.totalGSV = Convert.ToInt32(tokens[1]); if (tokens[3].IsInteger()) toFill._num_of_sat = Convert.ToInt32(tokens[3]); } for (int i = 4; i < tokens.Length - 4; i += 4) { Satellite s = new Satellite(); if (tokens[i] != String.Empty) s.ID = tokens[i]; if (tokens[i + 1].IsDouble()) s.Elevation = Convert.ToDouble(tokens[i + 1]); if (tokens[i + 2].IsDouble()) s.Azimuth = Convert.ToDouble(tokens[i + 2]); if (tokens[i + 3].IsDouble()) s.SNR = Convert.ToDouble(tokens[i + 3]); toFill.AddSatalite(s); } toFill.countGSV++; //if all GSV sentences parsed mark as GSV completed if (toFill.countGSV >= toFill.totalGSV) toFill.bGSV = true; } catch { toFill.BadData(); } }
public void AddSatalite(Satellite s) { SatellitesSeen.Add(s); }