Subversion Repositories HomeAutomation

Rev

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

  1.  
  2. function irReceive(type, name, id)
  3. {
  4.     this.CanService(type, name, id);
  5. }
  6.  
  7. extend(irReceive, CanService);
  8.  
  9. irReceive.prototype.myLastIRdata = null;
  10. irReceive.prototype.myLastProtocol = null;
  11. irReceive.prototype.myLastStatus = null;
  12.  
  13. irReceive.prototype.canMessageHandler = function(canMessage)
  14. {
  15.     if (canMessage.getDirectionFlag() == "From_Owner")
  16.     {
  17.         switch (canMessage.getCommandName())
  18.         {
  19.         case "IR":
  20.  
  21.             this.myLastIRdata = canMessage.getData("IRdata");
  22.             this.myLastProtocol = canMessage.getData("Protocol");
  23.             this.myLastStatus = canMessage.getData("Status");
  24.        
  25.             log(this.myName + ":" + this.myId + "> New IR, protocol: " + this.getProtocolName(this.myLastProtocol) + ", data: " + this.myLastIRdata + ", button was " + this.getStatusName(this.myLastStatus).toLowerCase() + "\n");
  26.             this.callEvent("newIRdata", null);
  27.         break;
  28.         }
  29.     }
  30.    
  31.     this.CanService.prototype.canMessageHandler.call(this, canMessage);
  32. }
  33.  
  34. irReceive.prototype.getLastIRdata = function()
  35. {
  36.     return this.myLastIRdata;
  37. }
  38.  
  39. irReceive.prototype.getLastProtocol = function()
  40. {
  41.     return this.myLastProtocol;
  42. }
  43.  
  44. irReceive.prototype.getLastStatus = function()
  45. {
  46.     return this.myLastStatus;
  47. }
  48.  
  49. irReceive.prototype.getStatusName = function(status)
  50. {
  51.     var returnData = "Released";
  52.     if (status == 1) {
  53.         returnData = "Pressed";
  54.     }
  55.     return returnData;
  56. }
  57. irReceive.prototype.getProtocolName = function(protocol)
  58. {
  59.     var returnData = "Unknown";
  60.     switch (protocol)
  61.     {
  62.     case 0:
  63.         returnData = "RC5";
  64.     break;
  65.     case 1:
  66.         returnData = "RC6";
  67.     break;
  68.     case 2:
  69.         returnData = "RCMM";
  70.     break;
  71.     case 3:
  72.         returnData = "SIRC";
  73.     break;
  74.     case 4:
  75.         returnData = "Sharp";
  76.     break;
  77.     case 5:
  78.         returnData = "NEC";
  79.     break;
  80.     case 6:
  81.         returnData = "Samsung";
  82.     break;
  83.     case 7:
  84.         returnData = "Marantz";
  85.     break;
  86.     case 255:
  87.         returnData = "Unknown";
  88.     break;
  89.     default:
  90.         returnData = "New protocol, irReceive.js must be updated";
  91.     break;
  92.     }
  93.     return returnData;
  94. }
  95.