/// <summary> /// Ermittelt die DiSEqC Steuersequenz aus der Angabe einer Quellgruppe und ihres Ursprungs. /// </summary> /// <param name="group">Die zu prüfende Quellgruppe.</param> /// <param name="location">Der zugehörige Ursprung.</param> /// <returns>Die gewünschten Informationen.</returns> /// <exception cref="ArgumentNullException">Mindestens ein Parameter ist nicht gesetzt.</exception> public static StandardDiSEqC FromSourceGroup(SatelliteGroup group, SatelliteLocation location) { // Validate if (group == null) { throw new ArgumentNullException("group"); } if (location == null) { throw new ArgumentNullException("location"); } // Core flags int choice = 0; if (group.Frequency >= location.SwitchFrequency) { choice |= 0x01; } if (group.Polarization == Polarizations.Horizontal) { choice |= 0x02; } // Check mode switch (location.LNB) { case DiSEqCLocations.None: return(new StandardDiSEqC(new byte[] { 0xe0, 0x00, 0x00 }, 0xff, 1)); case DiSEqCLocations.BurstOn: return(new StandardDiSEqC(new byte[0], 0, 1)); case DiSEqCLocations.BurstOff: return(new StandardDiSEqC(new byte[0], 1, 1)); case DiSEqCLocations.DiSEqC1: return(new StandardDiSEqC(new byte[] { 0xe0, 0x10, 0x38, (byte)(0xf0 | choice) }, 0xff, 3)); case DiSEqCLocations.DiSEqC2: return(new StandardDiSEqC(new byte[] { 0xe0, 0x10, 0x38, (byte)(0xf4 | choice) }, 0xff, 3)); case DiSEqCLocations.DiSEqC3: return(new StandardDiSEqC(new byte[] { 0xe0, 0x10, 0x38, (byte)(0xf8 | choice) }, 0xff, 3)); case DiSEqCLocations.DiSEqC4: return(new StandardDiSEqC(new byte[] { 0xe0, 0x10, 0x38, (byte)(0xfc | choice) }, 0xff, 3)); default: throw new NotImplementedException(location.LNB.ToString()); } }
/// <summary> /// Erzeugt eine neue Auswahlinstanz. /// </summary> /// <param name="source">Die zu betrachtende Quelle.</param> public SatelliteGroupSelector( SourceSelection source ) { // Remember m_Location = (SatelliteLocation) source.Location; }
/// <summary> /// Die Auswahl des zu konfigurierenden Ursprungs wurde verändert. /// </summary> /// <param name="sender">Wird ignoriert.</param> /// <param name="e">Wird ignoriert.</param> private void selDish_SelectionChangeCommitted(object sender, EventArgs e) { // Hide pnlSpecial.Visible = false; // Copy back current settings - if any selGroups.GetSelection(); // What to select DiSEqCLocations selection = CurrentLocation; // Template to use ScanTemplate <SatelliteLocation> scan = m_SatTemplates.Find(t => t.Location.LNB == selection); if (null == scan) { // Create new scan = new ScanTemplate <SatelliteLocation>(); // Find it foreach (ScanTemplate <SatelliteLocation> scanLocation in m_PlugIn.Profile.ScanLocations) { if (null != scanLocation.Location) { if (scanLocation.Location.LNB == selection) { // Copy over scan.Location = SatelliteLocation.Parse(scanLocation.Location.ToString()); scan.ScanLocations.AddRange(scanLocation.ScanLocations); // Did it - use only the first one break; } } } // Create new from default if (null == scan.Location) { scan.Location = new SatelliteLocation { Frequency1 = SatelliteLocation.Defaults.Frequency1, Frequency2 = SatelliteLocation.Defaults.Frequency2, SwitchFrequency = SatelliteLocation.Defaults.SwitchFrequency, UsePower = SatelliteLocation.Defaults.UsePower, LNB = selection } } ; // Remember m_SatTemplates.Add(scan); } // Load locations selGroups.SetSelection(scan); // Load LNB settings selLOF1.Value = scan.Location.Frequency1; selLOF2.Value = scan.Location.Frequency2; selSwitch.Value = scan.Location.SwitchFrequency; ckPower.Checked = scan.Location.UsePower; }
/// <summary> /// Ermittelt die DiSEqC Steuersequenz aus der Angabe einer Quellgruppe und ihres Ursprungs. /// </summary> /// <param name="group">Die zu prüfende Quellgruppe.</param> /// <param name="location">Der zugehörige Ursprung.</param> /// <returns>Die gewünschten Informationen.</returns> /// <exception cref="ArgumentNullException">Mindestens ein Parameter ist nicht gesetzt.</exception> public static StandardDiSEqC FromSourceGroup( SatelliteGroup group, SatelliteLocation location ) { // Validate if (group == null) throw new ArgumentNullException( "group" ); if (location == null) throw new ArgumentNullException( "location" ); // Core flags int choice = 0; if (group.Frequency >= location.SwitchFrequency) choice |= 0x01; if (group.Polarization == Polarizations.Horizontal) choice |= 0x02; // Check mode switch (location.LNB) { case DiSEqCLocations.None: return new StandardDiSEqC( new byte[] { 0xe0, 0x00, 0x00 }, 0xff, 1 ); case DiSEqCLocations.BurstOn: return new StandardDiSEqC( new byte[0], 0, 1 ); case DiSEqCLocations.BurstOff: return new StandardDiSEqC( new byte[0], 1, 1 ); case DiSEqCLocations.DiSEqC1: return new StandardDiSEqC( new byte[] { 0xe0, 0x10, 0x38, (byte) (0xf0 | choice) }, 0xff, 3 ); case DiSEqCLocations.DiSEqC2: return new StandardDiSEqC( new byte[] { 0xe0, 0x10, 0x38, (byte) (0xf4 | choice) }, 0xff, 3 ); case DiSEqCLocations.DiSEqC3: return new StandardDiSEqC( new byte[] { 0xe0, 0x10, 0x38, (byte) (0xf8 | choice) }, 0xff, 3 ); case DiSEqCLocations.DiSEqC4: return new StandardDiSEqC( new byte[] { 0xe0, 0x10, 0x38, (byte) (0xfc | choice) }, 0xff, 3 ); default: throw new NotImplementedException( location.LNB.ToString() ); } }
/// <summary> /// Wählt eine Quellgruppe aus. /// </summary> /// <param name="group">Díe Daten der Quellgruppe.</param> /// <param name="location">Die Wahl des Ursprungs, über den die Quellgruppe empfangen werden kann.</param> /// <returns>Gesetzt, wenn es sich um eine DVB-S Quellgruppe handelt.</returns> private Channel_S? Tune( SatelliteGroup group, SatelliteLocation location ) { // Not us if (location == null) return null; if (group == null) return null; // Validate if (FrontendType != FrontendType.Satellite) throw new DVBException( "Expected " + FrontendType.ToString() + " Channel" ); // Create channel var data = new Channel_S { Mode = group.UsesS2Modulation ? DVBSMode.DVB_S2 : DVBSMode.DVB_S, Inversion = SpectrumInversion.Auto, SymbolRate = group.SymbolRate, Frequency = group.Frequency, }; // Attach to the DiSEqC setting var selector = StandardDiSEqC.FromSourceGroup( group, location ); // See if the message is different from the last one if (!selector.Equals( m_lastMessage )) { // Remember m_lastMessage = selector.Clone(); // As long as necessary for (int nCount = selector.Repeat; nCount-- > 0; Thread.Sleep( 120 )) { // Send it DVBException.ThrowOnError( _SendDiSEqCMsg( m_Class.ClassPointer, selector.Request, (byte) selector.Request.Length, selector.Burst ), "Could not send DiSEqC message" ); // Set repeat flag if (selector.Request.Length > 0) selector.Request[0] |= 1; } } // Calculated items data.b22kHz = (group.Frequency >= location.SwitchFrequency) ? 1 : 0; data.LOF = (0 == data.b22kHz) ? location.Frequency1 : location.Frequency2; // Power modes switch (group.Polarization) { case Polarizations.Horizontal: data.LNBPower = PowerMode.Horizontal; break; case Polarizations.Vertical: data.LNBPower = PowerMode.Vertical; break; case Polarizations.NotDefined: data.LNBPower = PowerMode.Off; break; default: throw new ArgumentException( group.Polarization.ToString(), "Polarization" ); } // Process return data.SetChannel( this, false ); }
/// <summary> /// Wählt eine Quellgruppe aus. /// </summary> /// <param name="group">Díe Daten der Quellgruppe.</param> /// <param name="location">Die Wahl des Ursprungs, über den die Quellgruppe empfangen werden kann.</param> /// <returns>Gesetzt, wenn es sich um eine DVB-S Quellgruppe handelt.</returns> private bool SendChannel( SatelliteGroup group, SatelliteLocation location ) { // Not us if (location == null) return false; if (group == null) return false; // Validate if (FrontendType != FrontendType.Satellite) throw new DVBException( "Expected " + FrontendType.ToString() + " Channel" ); // Create channel var channel = new Channel_S { Inversion = SpectrumInversion.Auto, SymbolRate = group.SymbolRate, Frequency = group.Frequency, }; // Attach to the DiSEqC setting var selector = StandardDiSEqC.FromSourceGroup( group, location ); // See if the message is different from the last one if (!selector.Equals( m_lastMessage )) { // Remember m_lastMessage = selector.Clone(); // As long as necessary for (int nCount = selector.Repeat; nCount-- > 0; Thread.Sleep( 120 )) { // Send it DVBException.ThrowOnError( CDVBFrontend_SendDiSEqCMsg( m_Class.ClassPointer, selector.Request, (byte) selector.Request.Length, selector.Burst ), "Could not send DiSEqC Message" ); // Set repeat flag if (selector.Request.Length > 0) selector.Request[0] |= 1; } } // Calculated items channel.b22kHz = (group.Frequency >= location.SwitchFrequency) ? 1 : 0; channel.LOF = (0 == channel.b22kHz) ? location.Frequency1 : location.Frequency2; // Power modes switch (group.Polarization) { case Polarizations.Horizontal: channel.LNBPower = PowerMode.Horizontal; break; case Polarizations.Vertical: channel.LNBPower = PowerMode.Vertical; break; case Polarizations.NotDefined: channel.LNBPower = PowerMode.Off; break; default: throw new ArgumentException( group.Polarization.ToString(), "Polarization" ); } // Process CheckChannel( CDVBFrontend_SetChannel( m_Class.ClassPointer, channel, false ) ); // Check up for synchronisation Channel_S 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; }
/// <summary> /// Wählt eine Quellgruppe aus. /// </summary> /// <param name="group">Díe Daten der Quellgruppe.</param> /// <param name="location">Die Wahl des Ursprungs, über den die Quellgruppe empfangen werden kann.</param> /// <returns>Gesetzt, wenn es sich um eine DVB-S Quellgruppe handelt.</returns> private Channel_S?Tune(SatelliteGroup group, SatelliteLocation location) { // Not us if (location == null) { return(null); } if (group == null) { return(null); } // Validate if (FrontendType != FrontendType.Satellite) { throw new DVBException("Expected " + FrontendType.ToString() + " Channel"); } // Create channel var data = new Channel_S { Mode = group.UsesS2Modulation ? DVBSMode.DVB_S2 : DVBSMode.DVB_S, Inversion = SpectrumInversion.Auto, SymbolRate = group.SymbolRate, Frequency = group.Frequency, }; // Attach to the DiSEqC setting var selector = StandardDiSEqC.FromSourceGroup(group, location); // See if the message is different from the last one if (!selector.Equals(m_lastMessage)) { // Remember m_lastMessage = selector.Clone(); // As long as necessary for (int nCount = selector.Repeat; nCount-- > 0; Thread.Sleep(120)) { // Send it DVBException.ThrowOnError(_SendDiSEqCMsg(m_Class.ClassPointer, selector.Request, (byte)selector.Request.Length, selector.Burst), "Could not send DiSEqC message"); // Set repeat flag if (selector.Request.Length > 0) { selector.Request[0] |= 1; } } } // Calculated items data.b22kHz = (group.Frequency >= location.SwitchFrequency) ? 1 : 0; data.LOF = (0 == data.b22kHz) ? location.Frequency1 : location.Frequency2; // Power modes switch (group.Polarization) { case Polarizations.Horizontal: data.LNBPower = PowerMode.Horizontal; break; case Polarizations.Vertical: data.LNBPower = PowerMode.Vertical; break; case Polarizations.NotDefined: data.LNBPower = PowerMode.Off; break; default: throw new ArgumentException(group.Polarization.ToString(), "Polarization"); } // Process return(data.SetChannel(this, false)); }
/// <summary> /// Wählt eine Quellgruppe aus. /// </summary> /// <param name="group">Díe Daten der Quellgruppe.</param> /// <param name="location">Die Wahl des Ursprungs, über den die Quellgruppe empfangen werden kann.</param> /// <returns>Gesetzt, wenn es sich um eine DVB-S Quellgruppe handelt.</returns> private bool SendChannel(SatelliteGroup group, SatelliteLocation location) { // Not us if (location == null) { return(false); } if (group == null) { return(false); } // Validate if (FrontendType != FrontendType.Satellite) { throw new DVBException("Expected " + FrontendType.ToString() + " Channel"); } // Create channel var channel = new Channel_S { Inversion = SpectrumInversion.Auto, SymbolRate = group.SymbolRate, Frequency = group.Frequency, }; // Attach to the DiSEqC setting var selector = StandardDiSEqC.FromSourceGroup(group, location); // See if the message is different from the last one if (!selector.Equals(m_lastMessage)) { // Remember m_lastMessage = selector.Clone(); // As long as necessary for (int nCount = selector.Repeat; nCount-- > 0; Thread.Sleep(120)) { // Send it DVBException.ThrowOnError(CDVBFrontend_SendDiSEqCMsg(m_Class.ClassPointer, selector.Request, (byte)selector.Request.Length, selector.Burst), "Could not send DiSEqC Message"); // Set repeat flag if (selector.Request.Length > 0) { selector.Request[0] |= 1; } } } // Calculated items channel.b22kHz = (group.Frequency >= location.SwitchFrequency) ? 1 : 0; channel.LOF = (0 == channel.b22kHz) ? location.Frequency1 : location.Frequency2; // Power modes switch (group.Polarization) { case Polarizations.Horizontal: channel.LNBPower = PowerMode.Horizontal; break; case Polarizations.Vertical: channel.LNBPower = PowerMode.Vertical; break; case Polarizations.NotDefined: channel.LNBPower = PowerMode.Off; break; default: throw new ArgumentException(group.Polarization.ToString(), "Polarization"); } // Process CheckChannel(CDVBFrontend_SetChannel(m_Class.ClassPointer, channel, false)); // Check up for synchronisation Channel_S 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); }
/// <summary> /// Erzeugt eine neue Auswahlinstanz. /// </summary> /// <param name="source">Die zu betrachtende Quelle.</param> public SatelliteGroupSelector(SourceSelection source) { // Remember m_Location = (SatelliteLocation)source.Location; }