コード例 #1
0
ファイル: SatelliteGroup.cs プロジェクト: meee1/satgen
 private void OnSatellite_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "Attenuation" && AttenuationsLinked && !suppressLinkedAttenuationChange)
     {
         SatelliteDefinition satellite = (SatelliteDefinition)sender;
         if (satellite.IsEnabled)
         {
             suppressLinkedAttenuationChange = true;
             LinkedAttenuation = satellite.Attenuation;
             foreach (SatelliteDefinition item in Satellites.Where(delegate(SatelliteDefinition s)
             {
                 if (s != satellite)
                 {
                     return(s.IsEnabled);
                 }
                 return(false);
             }))
             {
                 item.Attenuation = LinkedAttenuation;
             }
             Application.Current.Dispatcher.BeginInvoke((Action) delegate
             {
                 suppressLinkedAttenuationChange = false;
             }, DispatcherPriority.DataBind);
         }
     }
 }
コード例 #2
0
        public void OnDestroy()
        {
            if (FocusOverlay != null)
            {
                FocusOverlay.Dispose();
            }
            if (FilterOverlay != null)
            {
                FilterOverlay.Dispose();
            }
            if (FilterOverlay != null)
            {
                FilterOverlay.Dispose();
            }
            if (Renderer != null)
            {
                Renderer.Detach();
            }
            if (Network != null)
            {
                Network.Dispose();
            }
            if (Satellites != null)
            {
                Satellites.Dispose();
            }
            if (Antennas != null)
            {
                Antennas.Dispose();
            }

            Instance = null;
        }
コード例 #3
0
ファイル: MainModel.cs プロジェクト: nebosite/Learning
 //-------------------------------------------------------------------------------------
 /// <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);
     }
 }
コード例 #4
0
        private void OnDestroy()
        {
            Settings.Save();
            Gui.Dispose();
            Renderer.Detach();
            Network.Dispose();
            Satellites.Dispose();
            Antennas.Dispose();

            Instance = null;
        }
コード例 #5
0
ファイル: SolidPlanet.cs プロジェクト: topProgrammist/oop3lab
 public override string[] getObjectInfo()
 {
     string[] str = new string[7];
     str[0] = Name;
     str[1] = Mass.ToString();
     str[2] = Radius.ToString();
     str[3] = Temperature.ToString();
     str[4] = RotationPeriod.ToString();
     str[5] = Satellites.ToString();
     str[6] = AttractivePower.ToString();
     return(str);
 }
コード例 #6
0
        public void OnDestroy()
        {
            if (FocusOverlay != null)
            {
                FocusOverlay.Dispose();
            }
            if (ManeuverNodeOverlay != null)
            {
                ManeuverNodeOverlay.Dispose();
            }
            if (FilterOverlay != null)
            {
                FilterOverlay.Dispose();
            }
            if (Renderer != null)
            {
                Renderer.Detach();
            }
            if (Network != null)
            {
                Network.Dispose();
            }
            if (Satellites != null)
            {
                Satellites.Dispose();
            }
            if (Antennas != null)
            {
                Antennas.Dispose();
            }

            // Remove GUI stuff
            GameEvents.onShowUI.Remove(UIOn);
            GameEvents.onHideUI.Remove(UIOff);

            // addons
            if (ctrlLockAddon != null)
            {
                ctrlLockAddon = null;
            }
            if (kacAddon != null)
            {
                kacAddon = null;
            }

            Instance = null;
        }
コード例 #7
0
ファイル: RTCore.cs プロジェクト: wtchappell/RemoteTech
        /// <summary>
        /// Called by the Unity engine during the Decommissioning phase of the Engine.
        /// This is used to clean up everything before quiting.
        /// </summary>
        public void OnDestroy()
        {
            if (FocusOverlay != null)
            {
                FocusOverlay.Dispose();
            }
            if (ManeuverNodeOverlay != null)
            {
                ManeuverNodeOverlay.Dispose();
            }
            if (FilterOverlay != null)
            {
                FilterOverlay.Dispose();
            }
            if (Renderer != null)
            {
                Renderer.Detach();
            }
            if (Network != null)
            {
                Network.Dispose();
            }
            if (Satellites != null)
            {
                Satellites.Dispose();
            }
            if (Antennas != null)
            {
                Antennas.Dispose();
            }

            // Release all RT locks currently engaged
            ReleaseLocks();

            // Remove GUI stuff
            GameEvents.onShowUI.Remove(UiOn);
            GameEvents.onHideUI.Remove(UiOff);

            // add-ons
            if (KacAddon != null)
            {
                KacAddon = null;
            }

            Instance = null;
        }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: SatelliteGroup.cs プロジェクト: meee1/satgen
        private void UpdateVisibleSatellites()
        {
            IEnumerable <SatelliteBase> source = simulation.VisibleSats[constellation.ConstellationType];

            foreach (SatelliteBase item in from s in source
                     where !(from ss in Satellites
                             select ss.Id).Contains(s.Id)
                     select s)
            {
                SatelliteDefinition satelliteDefinition = new SatelliteDefinition(item, simulation.SimulationParameters, this);
                int i;
                for (i = 0; i < Satellites.Count && item.Id > Satellites[i].Id; i++)
                {
                }
                Satellites.Insert(i, satelliteDefinition);
                satelliteDefinition.PropertyChanged += OnSatellite_PropertyChanged;
            }
            SatelliteDefinition[] array = Satellites.ToArray();
            foreach (SatelliteDefinition satDef in array)
            {
                SatelliteBase satelliteBase = source.FirstOrDefault((SatelliteBase s) => s.Id == satDef.Id);
                if (satelliteBase != null)
                {
                    if (simulation.SimulationParameters.SatCountLimitMode != 0)
                    {
                        satDef.IsEnabled = satelliteBase.IsEnabled;
                    }
                }
                else
                {
                    satDef.PropertyChanged -= OnSatellite_PropertyChanged;
                    Satellites.Remove(satDef);
                }
            }
            SatelliteCount = (constellation.IsEnabled ? (from s in Satellites
                                                         where s.IsEnabled
                                                         select s).Count() : 0);
        }
コード例 #10
0
ファイル: NmeaEmulator.cs プロジェクト: yangkf1985/DotSpatial
        /// <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);
        }
コード例 #11
0
ファイル: WmcUtilities.cs プロジェクト: garyan2/epg123
        public static bool UpdateDvbsTransponders(bool ignoreDefault)
        {
            var ret     = false;
            var mxfPath = Helper.TransponderMxfPath;

            try
            {
                // if defaultsatellites.mxf exists, import it and return
                if (!ignoreDefault && File.Exists(Helper.DefaultSatellitesPath))
                {
                    mxfPath = Helper.DefaultSatellitesPath;
                    goto ImportAndLock;
                }

                // read the satellites.xml file from either the file system or the resource file
                var satXml = new Satellites();
                if (File.Exists(Helper.SatellitesXmlPath))
                {
                    using (var stream = new StreamReader(Helper.SatellitesXmlPath, Encoding.UTF8))
                    {
                        var        serializer = new XmlSerializer(typeof(Satellites));
                        TextReader reader     = new StringReader(stream.ReadToEnd());
                        satXml = (Satellites)serializer.Deserialize(reader);
                        reader.Close();
                    }
                }
                else
                {
                    using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("epg123Client.satellites.xml"))
                        using (var reader = new StreamReader(stream, Encoding.UTF8))
                        {
                            var        serializer = new XmlSerializer(typeof(Satellites));
                            TextReader tr         = new StringReader(reader.ReadToEnd());
                            satXml = (Satellites)serializer.Deserialize(tr);
                            tr.Close();
                        }
                }

                // populate the mxf class
                var mxf    = new Mxf();
                var unique = satXml.Satellite.GroupBy(arg => arg.Name).Select(arg => arg.FirstOrDefault());
                foreach (var sat in unique)
                {
                    var freqs  = new HashSet <string>();
                    var mxfSat = new MxfDvbsSatellite {
                        Name = sat.Name, PositionEast = sat.Position, _transponders = new List <MxfDvbsTransponder>()
                    };
                    var matches = satXml.Satellite.Where(arg => arg.Name == sat.Name);
                    foreach (var match in matches)
                    {
                        foreach (var txp in match.Transponder.Where(txp => freqs.Add($"{txp.Frequency}_{txp.Polarization}")))
                        {
                            mxfSat._transponders.Add(new MxfDvbsTransponder
                            {
                                _satellite       = mxfSat,
                                CarrierFrequency = txp.Frequency,
                                Polarization     = txp.Polarization,
                                SymbolRate       = txp.SymbolRate
                            });
                        }
                    }
                    mxf.DvbsDataSet._allSatellites.Add(mxfSat);
                }

                // create the temporary mxf file
                using (var stream = new StreamWriter(Helper.TransponderMxfPath, false, Encoding.UTF8))
                    using (var writer = XmlWriter.Create(stream, new XmlWriterSettings {
                        Indent = true
                    }))
                    {
                        var serializer = new XmlSerializer(typeof(Mxf));
                        var ns         = new XmlSerializerNamespaces();
                        ns.Add("", "");
                        serializer.Serialize(writer, mxf, ns);
                    }

                // import the mxf file with new satellite transponders
ImportAndLock:
                ret = ImportMxfFile(mxfPath);
                var uid = WmcStore.WmcObjectStore.UIds["!DvbsDataSet"];
                uid.Lock();
                uid.Update();
            }
            catch (Exception ex)
            {
                Logger.WriteError($"Exception thrown during UpdateDvbsTransponders(). {ex.Message}\n{ex.StackTrace}");
            }
            return(ret);
        }
コード例 #12
0
 public void CorrectPointer(HashSet <AdvancedObject> objects)
 {
     Orbits     = objects.FirstOrDefault(o => o.Equals(Orbits));
     Satellites = Satellites.Select(o => objects.First(o.Equals)).ToHashSet();
 }
コード例 #13
0
ファイル: NmeaParser.cs プロジェクト: zyh329/inSSIDer-2
        // 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);
        }
コード例 #14
0
ファイル: NmeaParser.cs プロジェクト: zyh329/inSSIDer-2
        // Interprets a "Fixed Satellites and DOP" NMEA sentence
        public bool ParseGPGSA(string sentence)
        {
            bool result = false;

            try
            {
                string[] Words = GetWords(sentence);

                string rawMode1a = Words[1];
                string rawMode1b = Words[2];

                int[] satIDs_  = new int[MaxChannels];
                int   idx      = 3;
                int   satCount = 0;

                for (int i = 0; i < MaxChannels; i++)
                {
                    try
                    {
                        if (Words[idx] != string.Empty)
                        {
                            satIDs_[i] = Convert.ToInt32(Words[idx]);
                            satCount++;
                        }
                        else
                        {
                            satIDs_[i] = int.MaxValue;
                        }
                    }
                    catch (FormatException)
                    {
                        satIDs_[i] = int.MaxValue;
                    }
                    idx++;
                }

                SatIDs = satIDs_.Where(i => i < int.MaxValue).ToArray(); //new int[satCount];

                if (Satellites != null)
                {
                    Satellites.ForEach(sat => sat.IsUsed = false);
                    Satellites.ForEach(sat => sat.IsUsed = SatIDs.Contains(sat.Id));
                }

                string rawPdop = Words[idx];
                string rawHdop = Words[idx + 1];
                string rawVdop = Words[idx + 2];

                if (rawMode1a == "M")
                {
                    IsForced2D3D = true;
                }
                if (rawMode1a == "A")
                {
                    IsForced2D3D = false;
                }

                if (rawMode1b != "")
                {
                    FixMode = Convert.ToInt32(rawMode1b);
                }
                if (rawPdop != "")
                {
                    Pdop = Convert.ToDouble(rawPdop, CultureInfo.InvariantCulture);
                }
                if (rawHdop != "")
                {
                    Hdop = Convert.ToDouble(rawHdop, CultureInfo.InvariantCulture);
                }
                if (rawVdop != "")
                {
                    Vdop = Convert.ToDouble(rawVdop, CultureInfo.InvariantCulture);
                }

                result = true;
            }
            catch
            {
            }
            return(result);
        }
コード例 #15
0
ファイル: NmeaEmulator.cs プロジェクト: yangkf1985/DotSpatial
        /// <summary>
        /// Generates actual data to send to the client.
        /// </summary>
        /// <remarks>Data is sent according to the behavior of a typical GPS device: $GPGGA,
        /// $GPGSA, $GPRMC, $GPGSV sentences are sent every second, and a $GPGSV sentence
        /// is sent every five seconds.
        /// Developers who want to emulate a specific model of GPS device should override this
        /// method and generate the sentences specific to that device.</remarks>
        protected override void OnEmulation()
        {
            // Update real-time position, speed, bearing, etc.
            base.OnEmulation();

            if (Route.Count == 0)
            {
                CurrentPosition = EmulatePositionError(CurrentPosition);
            }

            /* NMEA devices will transmit "bursts" of NMEA sentences, followed by a one-second pause.
             * Other sentences (usually $GPGSV) are transmitted once every few seconds.  This emulator,
             * by default, will transmit the most common NMEA sentences.
             */

            // $GPGGA
            if (!_gpggaInterval.Equals(TimeSpan.Zero)
                // Has enough time elapsed to send the sentence?
                && UtcDateTime.Subtract(_gpggaLastSent) > _gpggaInterval)
            {
                // Get the tracked satellite count
                int trackedCount = Satellites.Count(item => item.SignalToNoiseRatio.Value > 0);

                // Yes
                _gpggaLastSent = UtcDateTime;

                // Queue the sentence to the read buffer
                WriteSentenceToClient(new GpggaSentence(UtcDateTime.TimeOfDay, CurrentPosition, _fixQuality, trackedCount,
                                                        _horizontalDOP, Altitude.Add(EmulateError(_verticalDOP)), Distance.Empty, TimeSpan.Zero, -1)); //Add an error to the altitude written to the client but don't change the actual value (otherwise it will "walk")
            }

            // $GPRMC
            if (!_gprmcInterval.Equals(TimeSpan.Zero)
                // Has enough time elapsed to send the sentence?
                && UtcDateTime.Subtract(_gprmcLastSent) > _gprmcInterval)
            {
                // Yes
                _gprmcLastSent = UtcDateTime;

                // Queue the sentence to the read buffer
                WriteSentenceToClient(new GprmcSentence(UtcDateTime, _fixStatus == FixStatus.Fix, CurrentPosition, Speed,
                                                        Bearing, _magneticVariation));
            }

            // $GPGLL
            if (!_gpgllInterval.Equals(TimeSpan.Zero)
                // Has enough time elapsed to send the sentence?
                && UtcDateTime.Subtract(_gpgllLastSent) > _gpgllInterval)
            {
                // Yes
                _gpgllLastSent = UtcDateTime;

                // Write a $GPGLL to the client
                WriteSentenceToClient(new GpgllSentence(CurrentPosition, UtcDateTime.TimeOfDay, _fixStatus));
            }

            // $GPGSA
            if (!_gpgsaInterval.Equals(TimeSpan.Zero)
                // Has enough time elapsed to send the sentence?
                && UtcDateTime.Subtract(_gpgsaLastSent) > _gpgsaInterval)
            {
                // Yes
                _gpgsaLastSent = UtcDateTime;

                // Queue the sentence to the read buffer
                WriteSentenceToClient(new GpgsaSentence(_fixMode, _fixMethod, Satellites,
                                                        _meanDOP, _horizontalDOP, _verticalDOP));
            }

            // $GPGSV
            if (!_gpgsvInterval.Equals(TimeSpan.Zero)
                // Has enough time elapsed to send the sentence?
                && UtcDateTime.Subtract(_gpgsvLastSent) > _gpgsvInterval)
            {
                // Build a list of sentences from our satellites
                IList <GpgsvSentence> sentences = GpgsvSentence.FromSatellites(Satellites);

                // Yes
                _gpgsvLastSent = UtcDateTime;

                // Write each sentence to the read buffer
                foreach (GpgsvSentence gpgsv in sentences)
                {
                    WriteSentenceToClient(gpgsv);
                }
            }

            // And signal that we have data (or not)
            if (ReadBuffer.Count == 0)
            {
                ReadDataAvailableWaitHandle.Reset();
            }
            else
            {
                ReadDataAvailableWaitHandle.Set();
            }
        }
コード例 #16
0
        //public string CreateMessage(SatelliteMessage[] satelliteMessages)
        //{

        //    int cont = satelliteMessages.Max(s => s.Message.Count);
        //    string[] message = new string[cont];

        //    foreach (var satelliteMessage in satelliteMessages)
        //    {
        //        int index = 0;
        //        foreach (var word in satelliteMessage.Message)
        //        {
        //            if (!string.IsNullOrEmpty(message[index]))
        //            {
        //                if (!string.IsNullOrEmpty(word) && message[index] != word)
        //                {
        //                    //2 palabras distintas en la misma posicion, sale del loop y retorna string vacio
        //                    return string.Empty;
        //                }
        //                index += 1;
        //                continue;
        //            }

        //            message[index] = word;
        //            index += 1;
        //        }
        //    }

        //    if (message.Any(word => string.IsNullOrEmpty(word)))
        //    {
        //        return string.Empty;
        //    }

        //    return string.Join(" ", message);
        //}


        public void Save(Satellites satellite)
        {
            throw new NotImplementedException();
        }
コード例 #17
0
ファイル: DataRoot.cs プロジェクト: h0ly0ne/ChanSort
 public virtual void AddSatellite(Satellite satellite)
 {
     Satellites.Add(satellite.Id, satellite);
 }