Ejemplo n.º 1
0
        /// <summary>
        /// Erzeugt die Beschreibung einer Quellgruppe aus einer SI Beschreibung eines
        /// NIT Eintrags.
        /// </summary>
        /// <param name="descriptor">Die Daten zur Quellgruppe.</param>
        /// <returns>Die Quellgruppe.</returns>
        private static TerrestrialGroup ToGroup(this EPG.Descriptors.TerrestrialDelivery descriptor)
        {
            // Create core
            TerrestrialGroup group =
                new TerrestrialGroup
            {
                Frequency = descriptor.Frequency
            };

            // Bandwidth
            switch (descriptor.Bandwidth)
            {
            case EPG.TerrestrialBandwidths.Five: group.Bandwidth = Bandwidths.Five; break;

            case EPG.TerrestrialBandwidths.Six: group.Bandwidth = Bandwidths.Six; break;

            case EPG.TerrestrialBandwidths.Seven: group.Bandwidth = Bandwidths.Seven; break;

            case EPG.TerrestrialBandwidths.Eight: group.Bandwidth = Bandwidths.Eight; break;

            case EPG.TerrestrialBandwidths.Reserved100: group.Bandwidth = Bandwidths.Reserved100; break;

            case EPG.TerrestrialBandwidths.Reserved101: group.Bandwidth = Bandwidths.Reserved101; break;

            case EPG.TerrestrialBandwidths.Reserved110: group.Bandwidth = Bandwidths.Reserved110; break;

            case EPG.TerrestrialBandwidths.Reserved111: group.Bandwidth = Bandwidths.Reserved111; break;
            }

            // Report
            return(group);
        }
        /// <summary>
        /// Versucht, die Textdarstellung einer Gruppe von Quellen in eine
        /// Gruppeninstanz umzuwandeln.
        /// </summary>
        /// <param name="text">Die Textdarstellung, wie über <see cref="ToString"/>
        /// erzeugt.</param>
        /// <param name="group">Die zugehörige Instanz.</param>
        /// <returns>Gesetzt, wenn eine Umwandlung möglich war.</returns>
        public static bool TryParse(string text, out TerrestrialGroup group)
        {
            // Reset
            group = null;

            // None
            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }

            // Split
            string[] parts = text.Split(',');
            if (3 != parts.Length)
            {
                return(false);
            }

            // Check type
            if (!parts[0].Trim().Equals("DVB-T"))
            {
                return(false);
            }

            // Read frequency
            uint frequency;

            if (!uint.TryParse(parts[1].Trim(), out frequency))
            {
                return(false);
            }

            // Bandwidth
            Bandwidths bandwidth;

            try
            {
                // Load
                bandwidth = (Bandwidths)Enum.Parse(typeof(Bandwidths), parts[2].Trim());
            }
            catch (FormatException)
            {
                // Not valid
                return(false);
            }

            // Just create
            group = new TerrestrialGroup
            {
                Frequency = frequency,
                Bandwidth = bandwidth
            };

            // Did it
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Wandelt eine Textdarstellung einer Gruppe von Quellen in eine
        /// Gruppeninstanz um.
        /// </summary>
        /// <returns>Die rekonstruierte Instanz.</returns>
        /// <exception cref="FormatException">Es wurde keine gültige Textdarstellung angegeben.</exception>
        public static T FromString <T>(string text) where T : SourceGroup
        {
            // None
            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            // Helper
            T group;

            // Dispatch known types
            if (text.StartsWith("DVB-C"))
            {
                group = CableGroup.Parse(text) as T;
            }
            else if (text.StartsWith("DVB-T"))
            {
                group = TerrestrialGroup.Parse(text) as T;
            }
            else if (text.StartsWith("DVB-S"))
            {
                group = SatelliteGroup.Parse(text) as T;
            }
            else
            {
                group = null;
            }

            // Invalid
            if (null == group)
            {
                throw new FormatException(text);
            }

            // Report
            return(group);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Wählt eine Quellgruppe an.
        /// </summary>
        /// <param name="group">Die Daten zur Quellgruppe.</param>
        /// <returns>Gesetzt, wenn es sich um eine DVB-T Quellgruppe handelt.</returns>
        private Channel_T? Tune( TerrestrialGroup group )
        {
            // Not us 
            if (group == null)
                return null;

            // Validate
            if (FrontendType != FrontendType.Terrestrial)
                throw new DVBException( "Expected " + FrontendType.ToString() + " Channel" );

            // Helper
            var data =
                new Channel_T
                {
                    Frequency = group.Frequency,
                    Inversion = SpectrumInversion.Off,
                    Scan = false,
                };

            // Check supported modes
            switch (group.Bandwidth)
            {
                case Bandwidths.Six: data.Bandwidth = BandwidthType.Six; break;
                case Bandwidths.Seven: data.Bandwidth = BandwidthType.Seven; break;
                case Bandwidths.Eight: data.Bandwidth = BandwidthType.Eight; break;
                case Bandwidths.NotDefined: data.Bandwidth = BandwidthType.None; break;
                default: data.Bandwidth = BandwidthType.Auto; break;
            }

            // Process
            return data.SetChannel( this );
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Wählt eine Quellgruppe an.
        /// </summary>
        /// <param name="group">Die Daten zur Quellgruppe.</param>
        /// <returns>Gesetzt, wenn es sich um eine DVB-T Quellgruppe handelt.</returns>
        private bool SendChannel( TerrestrialGroup group )
        {
            // Not us 
            if (group == null)
                return false;

            // Validate
            if (FrontendType != FrontendType.Terrestrial)
                throw new DVBException( "Expected " + FrontendType.ToString() + " Channel" );

            // Helper
            var channel =
                new Channel_T
                {
                    Frequency = group.Frequency,
                    Inversion = SpectrumInversion.Off,
                    Scan = false,
                };

            // Check supported modes
            switch (group.Bandwidth)
            {
                case Bandwidths.Six: channel.Bandwidth = BandwidthType.Six; break;
                case Bandwidths.Seven: channel.Bandwidth = BandwidthType.Seven; break;
                case Bandwidths.Eight: channel.Bandwidth = BandwidthType.Eight; break;
                case Bandwidths.NotDefined: channel.Bandwidth = BandwidthType.None; break;
                default: channel.Bandwidth = BandwidthType.Auto; break;
            }

            // Process
            CheckChannel( CDVBFrontend_SetChannel( m_Class.ClassPointer, channel, false ) );

            // Check up for synchronisation
            Channel_T rVal1, rVal2;

            // Get channel twice
            CheckChannel( CDVBFrontend_GetChannel( m_Class.ClassPointer, out rVal1 ) );
            CheckChannel( CDVBFrontend_GetChannel( m_Class.ClassPointer, out rVal2 ) );

            // Did it
            return true;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Versucht, die Textdarstellung einer Gruppe von Quellen in eine
        /// Gruppeninstanz umzuwandeln.
        /// </summary>
        /// <param name="text">Die Textdarstellung, wie über <see cref="ToString"/>
        /// erzeugt.</param>
        /// <param name="group">Die zugehörige Instanz.</param>
        /// <returns>Gesetzt, wenn eine Umwandlung möglich war.</returns>
        public static bool TryParse( string text, out TerrestrialGroup group )
        {
            // Reset
            group = null;

            // None
            if (string.IsNullOrEmpty( text ))
                return false;

            // Split
            string[] parts = text.Split( ',' );
            if (3 != parts.Length)
                return false;

            // Check type
            if (!parts[0].Trim().Equals( "DVB-T" ))
                return false;

            // Read frequency
            uint frequency;
            if (!uint.TryParse( parts[1].Trim(), out frequency ))
                return false;

            // Bandwidth
            Bandwidths bandwidth;
            try
            {
                // Load
                bandwidth = (Bandwidths) Enum.Parse( typeof( Bandwidths ), parts[2].Trim() );
            }
            catch (FormatException)
            {
                // Not valid
                return false;
            }

            // Just create
            group = new TerrestrialGroup
                {
                    Frequency = frequency,
                    Bandwidth = bandwidth
                };

            // Did it
            return true;
        }