Subversion Repositories HomeAutomation

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1.  
  2. function irTransmit(type, name, id)
  3. {
  4.     this.CanService(type, name, id);
  5. }
  6.  
  7. extend(irTransmit, CanService);
  8.  
  9. irTransmit.prototype.canMessageHandler = function(canMessage)
  10. {
  11.     /*if (canMessage.getDirectionFlag() == "From_Owner")
  12.     {
  13.         switch (canMessage.getCommandName())
  14.         {
  15.         case "IR":
  16.         break;
  17.         }
  18.     }*/
  19.    
  20.     this.CanService.prototype.canMessageHandler.call(this, canMessage);
  21. }
  22.  
  23. irTransmit.prototype.sendClick = function(remoteName, buttonName)
  24. {
  25.     this.sendButton(remoteName, buttonName, true);
  26.     sleep(50000);
  27.     this.sendButton(remoteName, buttonName, false);
  28. }
  29.  
  30. irTransmit.prototype.sendButton = function(remoteName, buttonName, down)
  31. {
  32.     var remotesStore = DataStore.getStore("IRRemotes");
  33.    
  34.     if (remotesStore)
  35.     {
  36.         for (var n = 0; n < remotesStore['remotes'].length; n++)
  37.         {
  38.             if (remotesStore['remotes'][n]['name'] == remoteName)
  39.             {
  40.                 for (var code in remotesStore['remotes'][n]['codes'])
  41.                 {
  42.                     if (remotesStore['remotes'][n]['codes'][code] == buttonName)
  43.                     {
  44.                         this.sendData(remotesStore['remotes'][n]['protocol'], code, down ? "Pressed" : "Released");
  45.                         return;
  46.                     }
  47.                 }
  48.             }
  49.         }
  50.     }
  51. }
  52.  
  53. irTransmit.prototype.sendData = function(protocol, data, status)
  54. {
  55.     var canMessage = new CanMessage("sns", "To_Owner", this.myName, this.myId, "IR");
  56.     canMessage.setData("Status", status);
  57.     canMessage.setData("Protocol", protocol);
  58.     canMessage.setData("IRdata", data);
  59.     sendMessage(canMessage);
  60. }
  61.