Пример #1
0
        /// <summary>
        /// Meldet eine relative Nummer einer Quellgruppe bezüglich dieser Auswahl.
        /// </summary>
        /// <param name="group">Die zu prüfende Quellgruppe.</param>
        /// <returns>Eine bei 0 beginnenden laufende Nummer, die in eine Farbcodierung umgesetzt wird.</returns>
        public override int GetSubGroupIndex(SourceGroup group)
        {
            // Convert
            SatelliteGroup sat = (SatelliteGroup)group;

            // Check mode
            switch (sat.Polarization)
            {
            case Polarizations.Horizontal: return(0);

            case Polarizations.Vertical: return(1);

            default: return(2);
            }
        }
Пример #2
0
        /// <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());
            }
        }
Пример #3
0
        /// <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() );
            }
        }
Пример #4
0
        /// <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));
        }
Пример #5
0
        /// <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);
        }