Rev 971 | Rev 999 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 971 | Rev 987 | ||
|---|---|---|---|
| Line 10... | Line 10... | ||
| 10 | after the constructor */ |
10 | after the constructor */ |
| 11 | extend(SensorPrint, Service); |
11 | extend(SensorPrint, Service); |
| 12 | 12 | ||
| 13 | /* Declaration of instance variables, for static variables remove prototype */ |
13 | /* Declaration of instance variables, for static variables remove prototype */ |
| 14 | SensorPrint.prototype.myLCDService = null; |
14 | SensorPrint.prototype.myLCDService = null; |
| - | 15 | SensorPrint.prototype.myDTMFService = null; |
|
| 15 | SensorPrint.prototype.myTempService = null; |
16 | SensorPrint.prototype.myTempService = null; |
| 16 | SensorPrint.prototype.myVoltService = null; |
17 | SensorPrint.prototype.myVoltService = null; |
| 17 | SensorPrint.prototype.myInterval = null; |
18 | SensorPrint.prototype.myInterval = null; |
| - | 19 | SensorPrint.prototype.myOnlinePhonebook = null; |
|
| 18 | 20 | ||
| 19 | /* This function must always be declared, this is where all the startup code |
21 | /* This function must always be declared, this is where all the startup code |
| 20 | should be placed. Gets called with arguments like what ids to use etc. */ |
22 | should be placed. Gets called with arguments like what ids to use etc. */ |
| 21 | SensorPrint.prototype.initialize = function(initialArguments) |
23 | SensorPrint.prototype.initialize = function(initialArguments) |
| 22 | { |
24 | { |
| Line 50... | Line 52... | ||
| 50 | this.myVoltService.registerEventCallback("newValue", function(args) { self.voltageUpdate(args); }); |
52 | this.myVoltService.registerEventCallback("newValue", function(args) { self.voltageUpdate(args); }); |
| 51 | /* Add a callback for when the service goes online */ |
53 | /* Add a callback for when the service goes online */ |
| 52 | this.myVoltService.registerEventCallback("online", function(args) { self.voltOnline(); }); |
54 | this.myVoltService.registerEventCallback("online", function(args) { self.voltOnline(); }); |
| 53 | /* If the service is already online we should call the handler here */ |
55 | /* If the service is already online we should call the handler here */ |
| 54 | this.voltOnline(); |
56 | this.voltOnline(); |
| - | 57 | ||
| - | 58 | ||
| - | 59 | this.myDTMFService = ServiceManager.getService("Can", "SimpleDTMF", this.myInitialArguments["SimpleDTMF"]["Id"]); |
|
| - | 60 | this.myDTMFService.registerEventCallback("newPhonenumber", function(args) { self.dtmfUpdate(args); }); |
|
| - | 61 | //this.myDTMFService.registerEventCallback("online", function(args) { self.dtmfOnline(); }); |
|
| - | 62 | this.dtmfOnline(); |
|
| - | 63 | ||
| - | 64 | this.myOnlinePhonebook = new OnlinePhonebook(function(phonenumber, persons) { self.phonebookLookupCallback(phonenumber, persons); }); |
|
| - | 65 | } |
|
| - | 66 | ||
| - | 67 | SensorPrint.prototype.dtmfOnline = function() |
|
| - | 68 | { |
|
| - | 69 | } |
|
| - | 70 | ||
| - | 71 | SensorPrint.prototype.dtmfUpdate = function(args) |
|
| - | 72 | { |
|
| - | 73 | this.myOnlinePhonebook.lookup(this.myDTMFService.getLastPhonenumber()); |
|
| - | 74 | } |
|
| - | 75 | ||
| - | 76 | SensorPrint.prototype.phonebookLookupCallback = function(phonenumber, persons) |
|
| - | 77 | { |
|
| - | 78 | if (this.myLCDService.isOnline()) |
|
| - | 79 | { |
|
| - | 80 | var personString = ""; |
|
| - | 81 | ||
| - | 82 | for (var n = 0; n < persons.length; n++) |
|
| - | 83 | { |
|
| - | 84 | this.myLCDService.printText(0, n+1, persons[n].pad(18, ' ', 1)); |
|
| - | 85 | /* Print out what we are doing to the console */ |
|
| - | 86 | log(this.myName + ":" + this.myId + "> Trying to print " + persons[n] + " value to LCD\n"); |
|
| - | 87 | } |
|
| - | 88 | ||
| - | 89 | for (var c = n+1; c < 4; c++) |
|
| - | 90 | { |
|
| - | 91 | var str = " "; |
|
| - | 92 | this.myLCDService.printText(0, c, str); |
|
| - | 93 | } |
|
| - | 94 | } |
|
| 55 | } |
95 | } |
| 56 | 96 | ||
| 57 | SensorPrint.prototype.lcdOnline = function() |
97 | SensorPrint.prototype.lcdOnline = function() |
| 58 | { |
98 | { |
| 59 | /* If service is not online do nothing */ |
99 | /* If service is not online do nothing */ |