/// <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 CableGroup ToGroup(this EPG.Descriptors.CableDelivery descriptor) { // Create core CableGroup group = new CableGroup { Frequency = descriptor.Frequency, SpectrumInversion = SpectrumInversions.Auto, SymbolRate = descriptor.SymbolRate * 1000, Bandwidth = Bandwidths.NotDefined }; // Modulation switch (descriptor.Modulation) { case EPG.CableModulations.QAM16: group.Modulation = CableModulations.QAM16; break; case EPG.CableModulations.QAM32: group.Modulation = CableModulations.QAM32; break; case EPG.CableModulations.QAM64: group.Modulation = CableModulations.QAM64; break; case EPG.CableModulations.QAM128: group.Modulation = CableModulations.QAM128; break; case EPG.CableModulations.QAM256: group.Modulation = CableModulations.QAM256; break; } // Report return(group); }
/// <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); }
/// <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 CableGroup group) { // Reset group = null; // None if (string.IsNullOrEmpty(text)) { return(false); } // Split string[] parts = text.Split(','); if (6 != parts.Length) { return(false); } // Check type if (!parts[0].Trim().Equals("DVB-C")) { return(false); } // Read frequency uint frequency; if (!uint.TryParse(parts[1].Trim(), out frequency)) { return(false); } // Inversion SpectrumInversions inversion; try { // Load inversion = (SpectrumInversions)Enum.Parse(typeof(SpectrumInversions), parts[2].Trim()); } catch (FormatException) { // Not valid return(false); } // Bandwidth Bandwidths bandwidth; try { // Load bandwidth = (Bandwidths)Enum.Parse(typeof(Bandwidths), parts[3].Trim()); } catch (FormatException) { // Not valid return(false); } // Read symbol rate uint symbolrate; if (!uint.TryParse(parts[4].Trim(), out symbolrate)) { return(false); } // Modulation CableModulations modulation; try { // Load modulation = (CableModulations)Enum.Parse(typeof(CableModulations), parts[5].Trim()); } catch (FormatException) { // Not valid return(false); } // Just create group = new CableGroup { Bandwidth = bandwidth, Frequency = frequency, Modulation = modulation, SpectrumInversion = inversion, SymbolRate = symbolrate }; // Did it return(true); }
/// <summary> /// Wählt eine Quellgruppe an. /// </summary> /// <param name="group">Die Daten zur Quellgruppe.</param> /// <returns>Gesetzt, wenn es sich um eine DVB-C Quellgruppe handelt.</returns> private Channel_C? Tune( CableGroup group ) { // Not us if (group == null) return null; // Validate if (FrontendType != FrontendType.Cable) throw new DVBException( "Expected " + FrontendType.ToString() + " Channel" ); // Helper var data = new Channel_C { Frequency = group.Frequency, SymbolRate = group.SymbolRate, }; // Spectrum inversion switch (group.SpectrumInversion) { case SpectrumInversions.On: data.Inversion = SpectrumInversion.On; break; case SpectrumInversions.Off: data.Inversion = SpectrumInversion.Off; break; case SpectrumInversions.Auto: data.Inversion = SpectrumInversion.Auto; break; default: data.Inversion = SpectrumInversion.Auto; break; } // Modulation switch (group.Modulation) { case CableModulations.QAM16: data.Qam = Qam.Qam16; break; case CableModulations.QAM32: data.Qam = Qam.Qam32; break; case CableModulations.QAM64: data.Qam = Qam.Qam64; break; case CableModulations.QAM128: data.Qam = Qam.Qam128; break; case CableModulations.QAM256: data.Qam = Qam.Qam256; break; default: data.Qam = Qam.Qam64; break; } // 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 ); }
/// <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 CableGroup group ) { // Reset group = null; // None if (string.IsNullOrEmpty( text )) return false; // Split string[] parts = text.Split( ',' ); if (6 != parts.Length) return false; // Check type if (!parts[0].Trim().Equals( "DVB-C" )) return false; // Read frequency uint frequency; if (!uint.TryParse( parts[1].Trim(), out frequency )) return false; // Inversion SpectrumInversions inversion; try { // Load inversion = (SpectrumInversions) Enum.Parse( typeof( SpectrumInversions ), parts[2].Trim() ); } catch (FormatException) { // Not valid return false; } // Bandwidth Bandwidths bandwidth; try { // Load bandwidth = (Bandwidths) Enum.Parse( typeof( Bandwidths ), parts[3].Trim() ); } catch (FormatException) { // Not valid return false; } // Read symbol rate uint symbolrate; if (!uint.TryParse( parts[4].Trim(), out symbolrate )) return false; // Modulation CableModulations modulation; try { // Load modulation = (CableModulations) Enum.Parse( typeof( CableModulations ), parts[5].Trim() ); } catch (FormatException) { // Not valid return false; } // Just create group = new CableGroup { Bandwidth = bandwidth, Frequency = frequency, Modulation = modulation, SpectrumInversion = inversion, SymbolRate = symbolrate }; // Did it return true; }
/// <summary> /// Wählt eine Quellgruppe an. /// </summary> /// <param name="group">Die Daten zur Quellgruppe.</param> /// <returns>Gesetzt, wenn es sich um eine DVB-C Quellgruppe handelt.</returns> private bool SendChannel( CableGroup group ) { // Not us if (group == null) return false; // Validate if (FrontendType != FrontendType.Cable) throw new DVBException( "Expected " + FrontendType.ToString() + " Channel" ); // Helper var channel = new Channel_C { Frequency = group.Frequency, SymbolRate = group.SymbolRate, }; // Spectrum inversion switch (group.SpectrumInversion) { case SpectrumInversions.On: channel.Inversion = SpectrumInversion.On; break; case SpectrumInversions.Off: channel.Inversion = SpectrumInversion.Off; break; case SpectrumInversions.Auto: channel.Inversion = SpectrumInversion.Auto; break; default: channel.Inversion = SpectrumInversion.Auto; break; } // Modulation switch (group.Modulation) { case CableModulations.QAM16: channel.Qam = Qam.Qam16; break; case CableModulations.QAM32: channel.Qam = Qam.Qam32; break; case CableModulations.QAM64: channel.Qam = Qam.Qam64; break; case CableModulations.QAM128: channel.Qam = Qam.Qam128; break; case CableModulations.QAM256: channel.Qam = Qam.Qam256; break; default: channel.Qam = Qam.Qam64; break; } // 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_C val1, val2; // Get channel twice CheckChannel( CDVBFrontend_GetChannel( m_Class.ClassPointer, out val1 ) ); CheckChannel( CDVBFrontend_GetChannel( m_Class.ClassPointer, out val2 ) ); // Did it return true; }