Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1732 | linlun | 1 | |
| 2 | function multiSwitch(type, name, id) |
||
| 3 | { |
||
| 4 | this.CanService(type, name, id); |
||
| 5 | this.myLastValue = new Array(); |
||
| 6 | } |
||
| 7 | |||
| 8 | extend(multiSwitch, CanService); |
||
| 9 | |||
| 10 | multiSwitch.prototype.myReportInterval = null; |
||
| 11 | multiSwitch.prototype.myLastValue = 0; |
||
| 12 | |||
| 13 | multiSwitch.prototype.canMessageHandler = function(canMessage) |
||
| 14 | { |
||
| 15 | if (canMessage.getDirectionFlag() == "From_Owner") |
||
| 16 | { |
||
| 17 | switch (canMessage.getCommandName()) |
||
| 18 | { |
||
| 19 | case "SetPin": |
||
| 20 | log(this.myName + ":" + this.myId + "> New value: " + canMessage.getData("PinId") + "\n"); |
||
| 21 | this.myLastValue = canMessage.getData("PinId"); |
||
| 22 | this.callEvent("newValue", canMessage.getData("PinId")); |
||
| 23 | break; |
||
| 24 | /* |
||
| 25 | case "Report_Interval": |
||
| 26 | log(this.myName + ":" + this.myId + "> New report interval: " + canMessage.getData("Time") + "\n"); |
||
| 27 | this.myReportInterval = canMessage.getData("Time"); |
||
| 28 | break;*/ |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | this.CanService.prototype.canMessageHandler.call(this, canMessage); |
||
| 33 | } |
||
| 34 | |||
| 35 | multiSwitch.prototype.getValue = function() |
||
| 36 | { |
||
| 37 | return this.myLastValue; |
||
| 38 | } |
||
| 39 | |||
| 40 | multiSwitch.prototype.setPin = function(pinId) |
||
| 41 | { |
||
| 42 | var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "SetPin"); |
||
| 43 | canMessage.setData("PinId", pinId); |
||
| 44 | canMessage.setData("Status","High"); |
||
| 45 | sendMessage(canMessage); |
||
| 46 | this.myLastValue = pinId; |
||
| 47 | } |
||
| 48 | |||
| 49 | |||
| 50 |