コード例 #1
0
        private void Tests()
        {
            int            hr = 0;
            BDAChangeState state;

            hr = deviceControl.CheckChanges();
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(hr == 0, "IBDA_DeviceControl.CheckChanges");

            hr = deviceControl.CommitChanges();
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(hr == 0, "IBDA_DeviceControl.CommitChanges");

            hr = deviceControl.StartChanges();
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(hr == 0, "IBDA_DeviceControl.StartChanges");

            hr = deviceControl.GetChangeState(out state);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(hr == 0, "IBDA_DeviceControl.GetChangeState");
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }