コード例 #1
0
        /// <summary>
        /// Aktiviert die Auswahl einer DVB-S2 Quellgruppe.
        /// </summary>
        /// <param name="tune">Der aktuelle Auswahlvorgang.</param>
        /// <returns>Beschreibt, wie die Bearbeitung weiter fortgeführt werden soll.</returns>
        private static PipelineResult ActivateS2(DataGraph.TuneToken tune)
        {
            // Graph is starting or resetting
            var group = (tune == null) ? null : tune.SourceGroup as SatelliteGroup;

            if (group == null)
            {
                return(PipelineResult.Continue);
            }

            // Attach to tuner
            var tuner = tune.Pipeline.Graph.TunerFilter;

            if (tuner == null)
            {
                return(PipelineResult.Continue);
            }

            // Verify that grpah is created
            if (tune.Pipeline.Graph.TransportStreamAnalyser == null)
            {
                return(PipelineResult.Continue);
            }

            // Not DVB-S2
            if (!group.UsesS2Modulation)
            {
                return(PipelineResult.Continue);
            }

            // Attach to the locator of the tune request
            var locator = tune.TuneRequest.Locator;

            try
            {
                // Apply modulation
                switch (group.Modulation)
                {
                case SatelliteModulations.QPSK: locator.Modulation = (ModulationType)(ModulationType.AnalogFrequency + 5); break;

                case SatelliteModulations.PSK8: locator.Modulation = (ModulationType)(ModulationType.AnalogFrequency + 6); break;

                case SatelliteModulations.QAM16: locator.Modulation = ModulationType.QAM16; break;
                }

                // Store back
                tune.TuneRequest.Locator = locator;
            }
            finally
            {
                // Cleanup properly
                BDAEnvironment.Release(ref locator);
            }

            // Attach to the one input pin of the tuner
            using (var input = tuner.GetSinglePin(PinDirection.Input))
            {
                // Start with roll-off
                using (var propertySet = KsPropertySet.Create <RollOff>(input.Interface))
                    if (propertySet != null)
                    {
                        // Get the property and node to use
                        var roNode = KsPNode.Create(BdaTunerExtensionProperties, BDATunerExtensions.RollOff, BDANodes.Tuner);

                        // Update
                        if (propertySet.DoesSupport(roNode, PropertySetSupportedTypes.Set))
                        {
                            switch (group.RollOff)
                            {
                            case S2RollOffs.Alpha35: propertySet.Set(roNode, RollOff.Offset35); break;

                            case S2RollOffs.Alpha25: propertySet.Set(roNode, RollOff.Offset25); break;

                            case S2RollOffs.Alpha20: propertySet.Set(roNode, RollOff.Offset20); break;

                            default: propertySet.Set(roNode, RollOff.NotSet); break;
                            }
                        }
                    }

                // Continue with pilot
                using (var propertySet = KsPropertySet.Create <Pilot>(input.Interface))
                    if (propertySet != null)
                    {
                        // Get the property and node to use
                        var piNode = KsPNode.Create(BdaTunerExtensionProperties, BDATunerExtensions.Pilot, BDANodes.Tuner);

                        // Update
                        if (propertySet.DoesSupport(piNode, PropertySetSupportedTypes.Set))
                        {
                            propertySet.Set(piNode, Pilot.NotSet);
                        }
                    }
            }

            // Normal
            return(PipelineResult.Continue);
        }
コード例 #2
0
        /// <summary>
        /// Übernimmt die Ansteuerung einer Antenne.
        /// </summary>
        /// <param name="tune">Der aktuelle Änderungswunsch.</param>
        /// <returns>Beschreibt, wie weiter fortzufahren ist.</returns>
        private PipelineResult ApplyDiSEqC(DataGraph.TuneToken tune)
        {
            // Not active
            var diseqc = (tune == null) ? null : tune.DiSEqCMessage;

            if (diseqc == null)
            {
                // Reset request - or first call at all
                m_LastDiSEqC = null;

                // Next
                return(PipelineResult.Continue);
            }

            // Attach to tuner
            var tuner = tune.Pipeline.Graph.TunerFilter;

            if (tuner == null)
            {
                return(PipelineResult.Continue);
            }

            // Verify that grpah is created
            if (tune.Pipeline.Graph.TransportStreamAnalyser == null)
            {
                return(PipelineResult.Continue);
            }

            // Request the message to send
            if (diseqc.Equals(m_LastDiSEqC))
            {
                return(PipelineResult.Continue);
            }

            // Attach to the one input pin of the tuner
            using (var input = tuner.GetSinglePin(PinDirection.Input))
                using (var propertySet = KsPropertySet.Create <NovaDiSEqCMessage>(input.Interface))
                    if (propertySet != null)
                    {
                        // Create the identifier of the property to use
                        var nodeReference = KsPNode.Create(BdaTunerExtensionProperties, BDATunerExtensions.DiSEqC, BDANodes.Tuner);

                        // Check for support of the property
                        if (!propertySet.DoesSupport(nodeReference, PropertySetSupportedTypes.Set))
                        {
                            return(PipelineResult.Continue);
                        }

                        // Create structures
                        var message = new NovaDiSEqCMessage();

                        // Create a copy
                        var command = (byte[])diseqc.Request.Clone();

                        // As long as necessary
                        for (int nCount = diseqc.Repeat; nCount-- > 0; Thread.Sleep(120))
                        {
                            try
                            {
                                // Prepare the message
                                message.Request  = new byte[151];
                                message.Response = new byte[9];

                                // Fill the message
                                command.CopyTo(message.Request, 0);

                                // Set the lengths
                                message.RequestLength  = (uint)command.Length;
                                message.ResponseLength = 0;

                                // Configure
                                message.ToneBurstModulation  = (ToneBurstModulationModes)diseqc.Burst;
                                message.ResponseMode         = DiSEqCReceiveModes.NoReply;
                                message.DiSEqCVersion        = DiSEqCVersions.Version1;
                                message.AmplitudeAttenuation = 3;
                                message.LastMessage          = true;

                                // Send the message
                                propertySet.Set(nodeReference, message);

                                // Set repeat flag
                                if (command.Length > 0)
                                {
                                    command[0] |= 1;
                                }
                            }
                            catch
                            {
                                // Reset
                                m_LastDiSEqC = null;

                                // Forward
                                throw;
                            }
                        }

                        // Remember
                        m_LastDiSEqC = diseqc.Clone();
                    }

            // Done
            return(PipelineResult.Continue);
        }
コード例 #3
0
        /// <summary>
        /// Führt die DiSEqC Steuerung aus.
        /// </summary>
        /// <param name="token">Die aktuellen Informationen zum Wechsel der Quellgruppe.</param>
        /// <returns>Meldet, wie die weitere Abarbeitung zu erfolgen hat.</returns>
        private PipelineResult ApplyDiSEqC(DataGraph.TuneToken token)
        {
            // Not active
            var diseqc = (token == null) ? null : token.DiSEqCMessage;

            if (diseqc == null)
            {
                // Reset request - or first call at all
                m_LastDiSEqC = null;

                // Next
                return(PipelineResult.Continue);
            }

            // Attach to tuner
            var tuner = token.Pipeline.Graph.TunerFilter;

            if (tuner == null)
            {
                return(PipelineResult.Continue);
            }

            // Verify that grpah is created
            if (token.Pipeline.Graph.TransportStreamAnalyser == null)
            {
                return(PipelineResult.Continue);
            }

            // Request the message to send
            if (diseqc.Equals(m_LastDiSEqC))
            {
                return(PipelineResult.Continue);
            }

            // Attach to the one input pin of the tuner
            using (var input = tuner.GetSinglePin(PinDirection.Input))
                using (var propertySet = KsPropertySet.Create <DiSEqCMessage>(input.Interface))
                    if (propertySet != null)
                    {
                        // Create the identifier of the property to use
                        var nodeReference = KsPNode.Create(TunerExtensionPropertiesS2, TunerExtensionProperties.DiSEqC, 0);

                        // Check for support of the property
                        if (!propertySet.DoesSupport(nodeReference, PropertySetSupportedTypes.Set))
                        {
                            return(PipelineResult.Continue);
                        }

                        // Create structures
                        var message = new DiSEqCMessage();

                        // Create a copy
                        var command = (byte[])diseqc.Request.Clone();

                        // As long as necessary
                        try
                        {
                            // Prepare the message
                            message.Request = new byte[151];

                            // Fill the message
                            command.CopyTo(message.Request, 0);

                            // Configure
                            message.RequestLength = (byte)command.Length;
                            message.LastMessage   = true;
                            message.Power         = 0;

                            // Send the message
                            propertySet.Set(nodeReference, message);
                        }
                        catch
                        {
                            // Reset
                            m_LastDiSEqC = null;

                            // Forward
                            throw;
                        }

                        // Remember
                        m_LastDiSEqC = diseqc.Clone();
                    }

            // Next
            return(PipelineResult.Continue);
        }