//------------------------------------------------------------------------------------- /// <summary> /// RegenerateSatellites /// </summary> //------------------------------------------------------------------------------------- public void RegenerateSatellites() { StartTimeSeconds = GlobalTimeSeconds; _samples = new List <double>(); _lastSample = GlobalTimeSeconds; Satellites.Clear(); foreach (var satellite in _selectedGenerator.Generate(SatelliteCount)) { Satellites.Add(satellite); } }
private int BuildSatellites(double OrbitNum, Orbit myOrbit, Star primary, int HZone, double ComLumAddFromPrim, int numsats) { var ringcount = 0; var retry = false; var ret = 0; for (var i = 0; i < numsats; i++) { var satellite = new Satellite(_configuration) { Name = string.Format("{0}/A{1}", Name, i) }; Satellites.Add(satellite); satellite.Build(Normal.Size.Value, PlanetType); if (satellite.PlanetType == WorldType.RING) { ringcount += 1; } if (ringcount > 3) { // Can only have 3 rings while (satellite.PlanetType == WorldType.RING) { satellite.Build(Normal.Size.Value, PlanetType); } } // Check for repeat orbits do { retry = false; for (var j = 0; j < i - 1; j++) { if (Satellites[j].OrbitNumber == Satellites[i].OrbitNumber) { satellite.SetOrbit(Normal.Size.Value, PlanetType); } } } while (retry); var k = satellite.FleshOut(this, myOrbit, primary, HZone, ComLumAddFromPrim); ret = Math.Max(k, ret); } Satellites.Sort(); return(ret); }
/// <summary> /// Randomizes the emulation by changing speed and direction /// </summary> public override void Randomize() { // Randomize the base emulation for speed/bearing base.Randomize(); _horizontalDOP = new DilutionOfPrecision((float)(Seed.NextDouble() * (_maxHdop - _minHdop) + _minHdop)); _verticalDOP = new DilutionOfPrecision((float)(Seed.NextDouble() * (_maxVdop - _minVdop) + _minVdop)); // Mean is hypotenuse of the (X, Y, Z, n) axes. _meanDOP = new DilutionOfPrecision((float)Math.Sqrt(Math.Pow(_horizontalDOP.Value, 2) + Math.Pow(_verticalDOP.Value, 2))); lock (Satellites) { if (Satellites.Count == 0) { int sats = Seed.Next(4, 12); //Satellites.Add(new Satellite(32, new Azimuth(225), new Elevation(45), new SignalToNoiseRatio(25))); Satellites.Add(new Satellite(32, new Azimuth(Seed.Next(360)), new Elevation(Seed.Next(90)), new SignalToNoiseRatio(Seed.Next(50)))); if (sats > 1) { Satellites.Add(new Satellite(24, new Azimuth(Seed.Next(360)), new Elevation(Seed.Next(90)), new SignalToNoiseRatio(Seed.Next(50)))); } if (sats > 2) { Satellites.Add(new Satellite(25, new Azimuth(Seed.Next(360)), new Elevation(Seed.Next(90)), new SignalToNoiseRatio(Seed.Next(50)))); } if (sats > 3) { Satellites.Add(new Satellite(26, new Azimuth(Seed.Next(360)), new Elevation(Seed.Next(90)), new SignalToNoiseRatio(Seed.Next(50)))); } if (sats > 4) { Satellites.Add(new Satellite(27, new Azimuth(Seed.Next(360)), new Elevation(Seed.Next(90)), new SignalToNoiseRatio(Seed.Next(50)))); } if (sats > 5) { Satellites.Add(new Satellite(16, new Azimuth(Seed.Next(360)), new Elevation(Seed.Next(90)), new SignalToNoiseRatio(Seed.Next(50)))); } if (sats > 6) { Satellites.Add(new Satellite(14, new Azimuth(Seed.Next(360)), new Elevation(Seed.Next(90)), new SignalToNoiseRatio(Seed.Next(50)))); } if (sats > 7) { Satellites.Add(new Satellite(6, new Azimuth(Seed.Next(360)), new Elevation(Seed.Next(90)), new SignalToNoiseRatio(Seed.Next(50)))); } if (sats > 8) { Satellites.Add(new Satellite(7, new Azimuth(Seed.Next(360)), new Elevation(Seed.Next(90)), new SignalToNoiseRatio(Seed.Next(50)))); } if (sats > 9) { Satellites.Add(new Satellite(4, new Azimuth(Seed.Next(360)), new Elevation(Seed.Next(90)), new SignalToNoiseRatio(Seed.Next(50)))); } if (sats > 10) { Satellites.Add(new Satellite(19, new Azimuth(Seed.Next(360)), new Elevation(Seed.Next(90)), new SignalToNoiseRatio(Seed.Next(50)))); } if (sats > 11) { Satellites.Add(new Satellite(8, new Azimuth(Seed.Next(360)), new Elevation(Seed.Next(90)), new SignalToNoiseRatio(Seed.Next(50)))); } } } SetRandom(true); }
public virtual void AddSatellite(Satellite satellite) { Satellites.Add(satellite.Id, satellite); }
// Interprets a "Satellites in View" NMEA sentence private bool ParseGpgsv(string sentence) { bool result = false; try { string[] words = GetWords(sentence); string rawNumberOfMessages = words[1]; string rawSequenceNumber = words[2]; string rawSatellitesInView = words[3]; SatelliteCount = int.Parse(rawSatellitesInView, NmeaCultureInfo); if (rawSequenceNumber == "1") { Satellites.Clear(); _allSatellitesLoaded = false; } if (rawSequenceNumber == rawNumberOfMessages) { _allSatellitesLoaded = true; } int index = 4; if (words.Length < 16) { return(false); } while (index <= 16 && words.Length > index + 4 && words[index] != "") { Satellite tempSatellite = new Satellite(); string id = words[index]; if (id != "") { int.TryParse(id, NumberStyles.Integer, NmeaCultureInfo, out tempSatellite.Id); } string elevation = words[index + 1]; if (elevation != "") { tempSatellite.Elevation = double.Parse(elevation, NmeaCultureInfo); } string azimuth = words[index + 2]; if (azimuth != "") { tempSatellite.Azimuth = Convert.ToDouble(azimuth, CultureInfo.InvariantCulture); } string snr = words[index + 3]; tempSatellite.Snr = snr == "" ? 0 : Convert.ToDouble(snr, CultureInfo.InvariantCulture); index = index + 4; Satellites.Add(tempSatellite); } result = true; } catch { } // Indicate that the sentence was recognized return(result); }