LearnAsync() public method

Learns an IR code asynchronously.
public LearnAsync ( CodeFormat codeFormat = null, LearnCodeModifier learnCodeModifier = null, uint forcedFrequency = null, object userState = null ) : Task
codeFormat CodeFormat The format of the IR code to use in learning.
learnCodeModifier LearnCodeModifier The modifier used for the code format.
forcedFrequency uint The frequency to use in learning.
userState object An optional user state object that will be passed to the /// Learning and LearnCompleted events and which can be used when calling LearnAsyncCancel().
return Task
Esempio n. 1
0
 public Task LearnAsync(CodeFormat?codeFormat = null,
                        LearnCodeModifier?learnCodeModifier = null,
                        uint?forcedFrequency = null,
                        object userState     = null)
 {
     _waitHandle.WaitOne();
     return(_learner.LearnAsync(codeFormat, learnCodeModifier, forcedFrequency, userState));
 }
Esempio n. 2
0
    public UsbUirtProcessor(IList<IrCommandEvent> commands)
    {
      _driver = new Driver();
      Log.Debug(string.Format("Usbuirt found version {0}", Driver.GetVersion(_driver)));
      _receiver = new Receiver(_driver);
      _receiver.GenerateLegacyCodes = false;
      _receiver.Received += OnIrReceive;
      _transmitter = new Transmitter(_driver);
      _learner = new Learner(_driver);

      _commands = commands;
      _learnCommand = null;

      //Event from ep source
      OnSourceEvent = (@event, sender) =>
      {
        if (@event.Channel != Channel && !string.IsNullOrEmpty(@event.Channel)) return;

        switch (@event.Name)
        {
          case "ir-transmit":
            var ir = System.Text.Encoding.Default.GetString(@event.Data);
            _transmitter.TransmitAsync(ir);
            break;
          case "ir-learn":
            _learnCommand = @event as IrCommandEvent;
            _learner.LearnAsync(CodeFormat.Uuirt, LearnCodeModifier.Default, null);
            break;
        }
      };

      //Error from ep source
      OnSourceError = (exception, sender) =>
      {
        Log.Error("Error from source endpoint", exception);
      };

      //Close connection with ep source
      OnSourceClose = (sender) =>
      {
        //Close HBus endpoint
        Stop();

        Log.Debug("closed on source close");
      };

    }