コード例 #1
0
ファイル: KNCAPI.cs プロジェクト: thomasr3/MediaPortal-1
        /// <summary>
        /// Sends the DiSEqC command.
        /// </summary>
        /// <param name="ulRange">The DisEqCPort</param>
        /// <returns>true if succeeded, otherwise false</returns>
        protected bool SendDiSEqCCommand(ulong ulRange)
        {
            Log.Log.Info("KNC:  SendDiSEqC Command {0}", ulRange);
            // get ControlNode of tuner control node
            object ControlNode;
            int    hr = ((IBDA_Topology)m_tunerFilter).GetControlNode(0, 1, 0, out ControlNode);

            if (hr == 0)
            // retrieve the BDA_DeviceControl interface
            {
                IBDA_DeviceControl DecviceControl = (IBDA_DeviceControl)m_tunerFilter;
                if (DecviceControl != null)
                {
                    if (ControlNode != null)
                    {
                        IBDA_FrequencyFilter FrequencyFilter = ControlNode as IBDA_FrequencyFilter;
                        hr = DecviceControl.StartChanges();
                        if (hr == 0)
                        {
                            if (FrequencyFilter != null)
                            {
                                hr = FrequencyFilter.put_Range(ulRange);
                                Log.Log.Info("KNC:  put_Range:{0} success:{1}", ulRange, hr);
                                if (hr == 0)
                                {
                                    // did it accept the changes?
                                    hr = DecviceControl.CheckChanges();
                                    if (hr == 0)
                                    {
                                        hr = DecviceControl.CommitChanges();
                                        if (hr == 0)
                                        {
                                            Log.Log.Info("KNC:  CommitChanges() Succeeded");
                                            return(true);
                                        }
                                        // reset configuration
                                        Log.Log.Info("KNC:  CommitChanges() Failed!");
                                        DecviceControl.StartChanges();
                                        DecviceControl.CommitChanges();
                                        return(false);
                                    }
                                    Log.Log.Info("KNC:  CheckChanges() Failed!");
                                    return(false);
                                }
                                Log.Log.Info("KNC:  put_Range Failed!");
                                return(false);
                            }
                        }
                    }
                }
            }
            Log.Log.Info("KNC:  GetControlNode Failed!");
            return(false);
        }
コード例 #2
0
        private bool disableDiseqcCommands(IBaseFilter tunerFilter)
        {
            IBDA_DeviceControl deviceControl = (IBDA_DeviceControl)tunerFilter;

            if (deviceControl != null)
            {
                reply = deviceControl.StartChanges();
                if (reply == 0)
                {
                    Logger.Instance.Write("Win7API DiSEqC handler: disabling driver diseqc commands");
                    reply = commandInterface.put_EnableDiseqCommands(0x00);
                    if (reply != 0)
                    {
                        Logger.Instance.Write("Win7API DiSEqC handler: Put Enable command failed: error code 0x" + reply.ToString("X"));
                    }
                    else
                    {
                        reply = deviceControl.CheckChanges();
                        if (reply == 0)
                        {
                            reply = deviceControl.CommitChanges();
                            if (reply == 0)
                            {
                                return(true);
                            }

                            Logger.Instance.Write("Win7API DiSEqC Handler: Commit Changes failed with reply 0x" + reply.ToString("X"));

                            deviceControl.StartChanges();
                            deviceControl.CommitChanges();
                        }
                        else
                        {
                            Logger.Instance.Write("Win7API DiSEqC Handler: Check Changes failed with reply 0x" + reply.ToString("X"));
                        }
                    }
                }
                else
                {
                    Logger.Instance.Write("Win7API DiSEqC Handler: Start Changes failed with reply 0x" + reply.ToString("X"));
                }
            }
            else
            {
                Logger.Instance.Write("Win7API DiSEqC Handler: failed to get device control interface");
            }

            return(false);
        }
コード例 #3
0
        private void Config()
        {
            int hr = 0;

            graphBuilder = (IFilterGraph2) new FilterGraph();
            rot          = new DsROTEntry(graphBuilder);

            // Assume that the first device in this category IS a BDA device...
            DsDevice[] devices = DsDevice.GetDevicesOfCat(FilterCategory.BDASourceFiltersCategory);

            hr = graphBuilder.AddSourceFilterForMoniker(devices[0].Mon, null, devices[0].Name, out bdaTuner);
            DsError.ThrowExceptionForHR(hr);

            deviceControl = (IBDA_DeviceControl)bdaTuner;
        }
コード例 #4
0
        /// <summary>
        /// gets the diseqc reply
        /// </summary>
        /// <param name="pulRange">The DisEqCPort Port.</param>
        /// <returns>true if succeeded, otherwise false</returns>
        protected bool ReadDiSEqCCommand(out ulong pulRange)
        {
            // get ControlNode of tuner control node
            object ControlNode;
            int    hr = _TunerDevice.GetControlNode(0, 1, 0, out ControlNode);

            if (hr == 0)
            // retrieve the BDA_DeviceControl interface
            {
                IBDA_DeviceControl DecviceControl = (IBDA_DeviceControl)_TunerDevice;
                if (DecviceControl != null)
                {
                    if (ControlNode != null)
                    {
                        IBDA_FrequencyFilter FrequencyFilter = ControlNode as IBDA_FrequencyFilter;
                        hr = DecviceControl.StartChanges();
                        if (hr == 0)
                        {
                            if (FrequencyFilter != null)
                            {
                                hr = FrequencyFilter.get_Range(out pulRange);
                                Log.Log.Info(FormatMessage("  get_Range:{0} success:{1}"), pulRange, hr);
                                if (hr == 0)
                                {
                                    return(true);
                                }
                                Log.Log.Info(FormatMessage("  get_Range Failed!"));
                                return(false);
                            }
                        }
                    }
                }
            }
            Log.Log.Info(FormatMessage("  GetControlNode Failed!"));
            pulRange = 0;
            return(false);
        }
コード例 #5
0
        private bool sendRangeCommand(int range)
        {
            object controlNode;

            reply = ((IBDA_Topology)tunerFilter).GetControlNode(0, 1, 0, out controlNode);
            if (reply == 0)
            {
                IBDA_DeviceControl deviceControl = (IBDA_DeviceControl)tunerFilter;
                if (deviceControl != null)
                {
                    if (controlNode != null)
                    {
                        IBDA_FrequencyFilter frequencyFilter = controlNode as IBDA_FrequencyFilter;
                        reply = deviceControl.StartChanges();
                        if (reply == 0)
                        {
                            if (frequencyFilter != null)
                            {
                                Logger.Instance.Write("Generic DiSEqC Handler: Setting range: 0x" + range.ToString("X"));
                                reply = frequencyFilter.put_Range(range);
                                if (reply == 0)
                                {
                                    reply = deviceControl.CheckChanges();
                                    if (reply == 0)
                                    {
                                        reply = deviceControl.CommitChanges();
                                        if (reply == 0)
                                        {
                                            return(true);
                                        }

                                        Logger.Instance.Write("Generic DiSEqC Handler: Commit Changes failed with reply 0x" + reply.ToString("X"));

                                        deviceControl.StartChanges();
                                        deviceControl.CommitChanges();

                                        return(false);
                                    }
                                    else
                                    {
                                        Logger.Instance.Write("Generic DiSEqC Handler: Check Changes failed with reply 0x" + reply.ToString("X"));
                                        return(false);
                                    }
                                }
                                else
                                {
                                    Logger.Instance.Write("Generic DiSEqC Handler: Set Range failed with reply 0x" + reply.ToString("X"));
                                    return(false);
                                }
                            }
                            else
                            {
                                Logger.Instance.Write("Generic DiSEqC Handler: failed to get frequency filter interface");
                            }
                        }
                        else
                        {
                            Logger.Instance.Write("Generic DiSEqC Handler: Start Changes failed with reply 0x" + reply.ToString("X"));
                        }
                    }
                    else
                    {
                        Logger.Instance.Write("Generic DiSEqC Handler: failed to get control node");
                    }
                }
                else
                {
                    Logger.Instance.Write("Generic DiSEqC Handler: failed to get device control interface");
                }
            }
            else
            {
                Logger.Instance.Write("Generic DiSEqC Handler: failed to get control node");
            }

            return(false);
        }