Пример #1
0
        /// <summary>
        /// Learn an IR command.
        /// </summary>
        /// <param name="fileName">File to place learned IR command in (absolute path).</param>
        /// <returns><c>true</c> if successful, otherwise <c>false</c>.</returns>
        internal static bool LearnIR(string fileName, LearnStatusDelegate learnStatus = null)
        {
            try
            {
                if (String.IsNullOrEmpty(fileName))
                {
                    Log.Error("TV3BlasterPlugin: Null or Empty file name for LearnIR()");
                    return(false);
                }

                if (!_registered)
                {
                    Log.Error("TV3BlasterPlugin: Not registered to an active IR Server");
                    return(false);
                }

                if (_learnIRFilename != null)
                {
                    Log.Error("TV3BlasterPlugin: Already trying to learn an IR command");
                    return(false);
                }

                _learnIRFilename = fileName;

                IrssMessage message = new IrssMessage(MessageType.LearnIR, MessageFlags.Request);
                _client.Send(message);
            }
            catch (Exception ex)
            {
                _learnIRFilename = null;
                Log.Error(ex.ToString());
                return(false);
            }

            return(true);
        }
Пример #2
0
    /// <summary>
    /// Learn an IR command.
    /// </summary>
    /// <param name="fileName">File to place learned IR command in (absolute path).</param>
    /// <returns><c>true</c> if successful, otherwise <c>false</c>.</returns>
    internal static bool LearnIR(string fileName, LearnStatusDelegate learnStatus=null)
    {
      try
      {
        if (String.IsNullOrEmpty(fileName))
        {
          Log.Error("MPControlPlugin: Null or Empty file name for LearnIR()");
          return false;
        }

        if (!_registered)
        {
          Log.Warn("MPControlPlugin: Not registered to an active IR Server");
          return false;
        }

        if (_learnIRFilename != null)
        {
          Log.Warn("MPControlPlugin: Already trying to learn an IR command");
          return false;
        }

        _learnIRFilename = fileName;

        IrssMessage message = new IrssMessage(MessageType.LearnIR, MessageFlags.Request);
        _client.Send(message);
      }
      catch (Exception ex)
      {
        _learnIRFilename = null;
        Log.Error(ex);
        return false;
      }

      return true;
    }