Subversion Repositories HomeAutomation

Rev

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

  1.  
  2.  
  3. function CanService(name, id)
  4. {
  5.     this.Service(name, id);
  6.  
  7.     this.myIsOnline = false;
  8.     this.myHardwareId = null;
  9.     this.myHeartbeatTime = 0;
  10. }
  11.  
  12. extend(CanService, Service);
  13.  
  14. CanService.prototype.myIsOnline = null;
  15. CanService.prototype.myHardwareId = null;
  16. CanService.prototype.myHeartbeatTime = null;
  17.  
  18. CanService.prototype.canMessageHandler = function(canMessage)
  19. {
  20. }
  21.  
  22. CanService.prototype.onlineHandler = function()
  23. {
  24.     log(this.myName + ":" + this.myId + "> Service went online\n");
  25.     this.myHeartbeatTime = time();
  26.     this.myIsOnline = true;
  27.     this.callEvent("online", null);
  28. }
  29.  
  30. CanService.prototype.heartbeatHandler = function()
  31. {
  32.     this.myHeartbeatTime = time();
  33.     this.myIsOnline = true;
  34.     this.callEvent("heartbeat", null);
  35. }
  36.  
  37. CanService.prototype.checkOffline = function()
  38. {
  39.     if (this.myIsOnline)
  40.     {
  41.         if (this.myHeartbeatTime + 10 < time())
  42.         {
  43.             log(this.myName + ":" + this.myId + "> Service went offline\n");
  44.             this.myIsOnline = false;
  45.             this.callEvent("offline", null);
  46.         }
  47.     }
  48. }
  49.  
  50. CanService.prototype.isOnline = function()
  51. {
  52.     return this.myIsOnline;
  53. }
  54.  
  55. CanService.prototype.setHardwareId = function(hardwareId)
  56. {
  57.     this.myHardwareId = hardwareId;
  58. }
  59.  
  60. CanService.prototype.getHardwareId = function()
  61. {
  62.     return this.myHardwareId;
  63. }
  64.