Exemplo n.º 1
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;
        }
Exemplo n.º 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);
        }