Rev 1060 | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 994 | arune | 1 | |
| 999 | runge | 2 | function irReceive(type, name, id) |
| 994 | arune | 3 | { |
| 999 | runge | 4 | this.CanService(type, name, id); |
| 994 | arune | 5 | } |
| 6 | |||
| 7 | extend(irReceive, CanService); |
||
| 8 | |||
| 9 | irReceive.prototype.myLastIRdata = null; |
||
| 10 | irReceive.prototype.myLastProtocol = null; |
||
| 11 | irReceive.prototype.myLastStatus = null; |
||
| 1007 | runge | 12 | irReceive.prototype.myLastButton = null; |
| 13 | irReceive.prototype.myLastRemote = null; |
||
| 994 | arune | 14 | |
| 15 | irReceive.prototype.canMessageHandler = function(canMessage) |
||
| 16 | { |
||
| 17 | if (canMessage.getDirectionFlag() == "From_Owner") |
||
| 18 | { |
||
| 19 | switch (canMessage.getCommandName()) |
||
| 20 | { |
||
| 21 | case "IR": |
||
| 1007 | runge | 22 | this.myLastIRdata = canMessage.getData("IRdata"); |
| 23 | this.myLastProtocol = canMessage.getData("Protocol"); |
||
| 24 | this.myLastStatus = canMessage.getData("Status"); |
||
| 1060 | runge | 25 | this.lookupName(this.myLastProtocol, this.myLastIRdata); |
| 994 | arune | 26 | |
| 1007 | runge | 27 | if (this.myLastButton == null) |
| 28 | { |
||
| 1060 | runge | 29 | log(this.myName + ":" + this.myId + "> New IR, protocol: " + this.myLastProtocol + ", data: " + this.myLastIRdata + ", button was " + this.myLastStatus + "\n"); |
| 1007 | runge | 30 | } |
| 31 | else |
||
| 32 | { |
||
| 1046 | runge | 33 | log(this.myName + ":" + this.myId + "> New IR, remote: " + this.myLastRemote + ", button: " + this.myLastButton + ", button was " + this.myLastStatus + "\n"); |
| 1007 | runge | 34 | } |
| 35 | |||
| 36 | this.callEvent("newIRdata", null); |
||
| 994 | arune | 37 | break; |
| 38 | } |
||
| 39 | } |
||
| 40 | |||
| 41 | this.CanService.prototype.canMessageHandler.call(this, canMessage); |
||
| 42 | } |
||
| 43 | |||
| 1007 | runge | 44 | irReceive.prototype.lookupName = function(protocol, data) |
| 45 | { |
||
| 46 | var remotesStore = DataStore.getStore("IRRemotes"); |
||
| 47 | |||
| 48 | if (remotesStore) |
||
| 49 | { |
||
| 50 | for (var n = 0; n < remotesStore['remotes'].length; n++) |
||
| 51 | { |
||
| 52 | if (remotesStore['remotes'][n]['protocol'] == protocol) |
||
| 53 | { |
||
| 54 | if (remotesStore['remotes'][n]['codes'][data]) |
||
| 55 | { |
||
| 56 | this.myLastButton = remotesStore['remotes'][n]['codes'][data]; |
||
| 57 | this.myLastRemote = remotesStore['remotes'][n]['name']; |
||
| 58 | return; |
||
| 59 | } |
||
| 60 | } |
||
| 61 | } |
||
| 62 | } |
||
| 63 | |||
| 64 | this.myLastButton = null; |
||
| 65 | this.myLastRemote = null; |
||
| 66 | } |
||
| 67 | |||
| 994 | arune | 68 | irReceive.prototype.getLastIRdata = function() |
| 69 | { |
||
| 70 | return this.myLastIRdata; |
||
| 71 | } |
||
| 72 | |||
| 73 | irReceive.prototype.getLastProtocol = function() |
||
| 74 | { |
||
| 75 | return this.myLastProtocol; |
||
| 76 | } |
||
| 77 | |||
| 78 | irReceive.prototype.getLastStatus = function() |
||
| 79 | { |
||
| 80 | return this.myLastStatus; |
||
| 81 | } |
||
| 1061 | runge | 82 | |
| 83 | irReceive.prototype.getLastButton = function() |
||
| 84 | { |
||
| 85 | return this.myLastButton; |
||
| 86 | } |
||
| 87 | |||
| 88 | irReceive.prototype.getLastRemote = function() |
||
| 89 | { |
||
| 90 | return this.myLastRemote; |
||
| 91 | } |