示例#1
0
文件: CecBus.cs 项目: Dlizzz/Catspaw
        /// <summary>
        /// Switch power state of the given device to the requested power state
        /// </summary>
        /// <param name="device"></param>
        /// <param name="requestedPowerState"></param>
        /// <returns cref="PowerState">New PowerSate. Power state is unknown if the switch fails</returns>
        /// <exception cref="CecException">Can't connect to CecBus</exception>
        public PowerState SwitchDevicePowerState(CecLogicalAddress device, PowerState requestedPowerState)
        {
            PowerState state = PowerState.PowerUnknown;

            switch (requestedPowerState)
            {
            case PowerState.PowerOff:
                if (IsDeviceReady(device) && connection.StandbyDevices(device))
                {
                    state = PowerState.PowerOff;
                }
                break;

            case PowerState.PowerOn:
                // Close and reopen the connection as we lose it when we go to sleep
                connection.Close();
                if (!connection.Open(controller.ComPort, timeout))
                {
                    throw new CecException(Resources.ErrorNoCecControllerConnection);
                }
                // Register active source of the connection
                connection.SetActiveSource(CecDeviceType.PlaybackDevice);

                if (IsDeviceReady(device) && connection.PowerOnDevices(device))
                {
                    state = PowerState.PowerOn;
                }
                break;

            default:
                break;
            }

            return(state);
        }
示例#2
0
        public virtual void DeInit()
        {
            if (_lib != null)
            {
                _lib.DisableCallbacks();
                _lib.Close();
                _lib.Dispose();
            }

            _connected = false;

            _lib         = null;
            _libConfig   = null;
            _cecConfig   = null;
            _repeatTimer = null;
        }
 public void Close()
 {
     Lib.Close();
 }
示例#4
0
 /// <summary>
 /// Close the connection to the CEC devices
 /// </summary>
 public void Close()
 {
     CecLib.Close();
 }
示例#5
0
 public void Close()
 {
     iLib.Close();
     iConnected = false;
 }
示例#6
0
 public void Close()
 {
     lib.Close();
 }