Esempio n. 1
0
 /// <summary>
 /// Initialize a new instance of the TuningSpec class for a DVB satellite frequency.
 /// </summary>
 /// <param name="satellite">The satellite to tune to.</param>
 /// <param name="frequency">The frequency to tune to.</param>
 public TuningSpec(Satellite satellite, SatelliteFrequency frequency)
 {
     this.frequency = frequency;
     this.satellite = satellite;
     symbolRate = frequency.SymbolRate;
     fec = frequency.FEC;
     signalPolarization = frequency.Polarization;
     modulation = frequency.Modulation;
 }
        /// <summary>
        /// Compare another satellite frequency with this one.
        /// </summary>
        /// <param name="compareFrequency">The tuning frequency to be compared to.</param>
        /// <returns>0 if the frequencies are equal, -1 if this instance is less, +1 otherwise.</returns>
        public override int CompareTo(object compareFrequency)
        {
            SatelliteFrequency satelliteFrequency = compareFrequency as SatelliteFrequency;

            if (satelliteFrequency == null)
            {
                throw (new ArgumentException("Object is not a SatelliteFrequency"));
            }

            if (satelliteFrequency.Frequency == Frequency)
            {
                return(polarization.ToString().CompareTo(satelliteFrequency.Polarization.ToString()));
            }

            return(Frequency.CompareTo(satelliteFrequency.Frequency));
        }
        /// <summary>
        /// Generate a copy of this frequency.
        /// </summary>
        /// <returns>A new instance with the same properties as the old instance.</returns>
        public override TuningFrequency Clone()
        {
            SatelliteFrequency newFrequency = new SatelliteFrequency();

            base.Clone(newFrequency);

            newFrequency.FEC          = fec;
            newFrequency.Polarization = polarization;
            newFrequency.SymbolRate   = symbolRate;
            newFrequency.Pilot        = pilot;
            newFrequency.RollOff      = rollOff;
            newFrequency.Modulation   = modulation;

            if (satelliteDish != null)
            {
                newFrequency.SatelliteDish = (SatelliteDish)satelliteDish.Clone();
            }

            return(newFrequency);
        }
Esempio n. 4
0
        /// <summary>
        /// Generate a copy of this frequency.
        /// </summary>
        /// <returns>A new instance with the same properties as the old instance.</returns>
        public override TuningFrequency Clone()
        {
            SatelliteFrequency newFrequency = new SatelliteFrequency();
            base.Clone(newFrequency);

            newFrequency.FEC = fec;
            newFrequency.Polarization = polarization;
            newFrequency.SymbolRate = symbolRate;
            newFrequency.Pilot = pilot;
            newFrequency.RollOff = rollOff;
            newFrequency.Modulation = modulation;

            if (satelliteDish != null)
                newFrequency.SatelliteDish = (SatelliteDish)satelliteDish.Clone();

            return (newFrequency);
        }
Esempio n. 5
0
        internal void load(FileInfo fileInfo)
        {
            SatelliteFrequency satelliteFrequency = null;
            XmlReader reader = null;

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreWhitespace = true;

            try
            {
                reader = XmlReader.Create(fileInfo.FullName, settings);
            }
            catch (IOException)
            {
                Logger.Instance.Write("Failed to open " + fileInfo.Name);
                return;
            }

            try
            {
                while (!reader.EOF)
                {
                    reader.Read();
                    if (reader.IsStartElement())
                    {
                        switch (reader.Name)
                        {
                            case "Transponder":
                                if (satelliteFrequency != null)
                                    AddFrequency(satelliteFrequency);

                                satelliteFrequency = new SatelliteFrequency();
                                satelliteFrequency.Provider = this;

                                break;
                            default:
                                if (satelliteFrequency != null)
                                    satelliteFrequency.load(reader);
                                break;
                        }
                    }
                }

                if (satelliteFrequency != null)
                    AddFrequency(satelliteFrequency);
            }
            catch (XmlException e)
            {
                Logger.Instance.Write("Failed to load file " + fileInfo.Name);
                Logger.Instance.Write("Data exception: " + e.Message);
            }
            catch (IOException e)
            {
                Logger.Instance.Write("Failed to load file " + fileInfo.Name);
                Logger.Instance.Write("I/O exception: " + e.Message);
            }

            if (reader != null)
                reader.Close();
        }
Esempio n. 6
0
        /// <summary>
        /// Add a new frequency.
        /// </summary>
        /// <param name="newFrequency">The frequency to be added.</param>
        public void AddFrequency(SatelliteFrequency newFrequency)
        {
            foreach (SatelliteFrequency oldFrequency in Frequencies)
            {
                if (oldFrequency.Frequency == newFrequency.Frequency)
                {
                    if (oldFrequency.Polarization == newFrequency.Polarization)
                        return;
                    else
                    {
                        if (oldFrequency.Polarization.PolarizationAbbreviation.CompareTo(newFrequency.Polarization.PolarizationAbbreviation) > 0)
                        {
                            Frequencies.Insert(Frequencies.IndexOf(oldFrequency), newFrequency);
                            return;
                        }
                    }
                }

                if (oldFrequency.Frequency > newFrequency.Frequency)
                {
                    Frequencies.Insert(Frequencies.IndexOf(oldFrequency), newFrequency);
                    return;
                }
            }

            Frequencies.Add(newFrequency);
        }