Subversion Repositories HomeAutomation

Rev

Rev 1229 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1.  
  2. function CanMessage(className, directionFlag, moduleName, moduleId, commandName, data)
  3. {
  4.     this.myClassName = className;
  5.     this.myDirectionFlag = directionFlag;
  6.     this.myModuleName = moduleName;
  7.     this.myModuleId = moduleId;
  8.     this.myCommandName = commandName;
  9.    
  10.     if (!data)
  11.         data = new Array();
  12.  
  13.     this.myData = data;
  14. }
  15.  
  16. CanMessage.prototype.myClassName = null;
  17. CanMessage.prototype.myDirectionFlag = null;
  18. CanMessage.prototype.myModuleName = null;
  19. CanMessage.prototype.myModuleId = null;
  20. CanMessage.prototype.myCommandName = null;
  21. CanMessage.prototype.myData = null;
  22.  
  23. CanMessage.prototype.setClassName = function(className)
  24. {
  25.     this.myClassName = className;
  26. }
  27.  
  28. CanMessage.prototype.getClassName = function()
  29. {
  30.     return this.myClassName;
  31. }
  32.  
  33. CanMessage.prototype.setDirectionFlag = function(directionFlag)
  34. {
  35.     this.myDirectionFlag = directionFlag;
  36. }
  37.  
  38. CanMessage.prototype.getDirectionFlag = function()
  39. {
  40.     return this.myDirectionFlag;
  41. }
  42.  
  43. CanMessage.prototype.setModuleName = function(moduleName)
  44. {
  45.     this.myModuleName = moduleName;
  46. }
  47.  
  48. CanMessage.prototype.getModuleName = function()
  49. {
  50.     return this.myModuleName;
  51. }
  52.  
  53. CanMessage.prototype.setModuleId = function(moduleId)
  54. {
  55.     this.myModuleId = moduleId;
  56. }
  57.  
  58. CanMessage.prototype.getModuleId = function()
  59. {
  60.     return this.myModuleId;
  61. }
  62.  
  63. CanMessage.prototype.setCommandName = function(commandName)
  64. {
  65.     this.myCommandName = commandName;
  66. }
  67.  
  68. CanMessage.prototype.getCommandName = function()
  69. {
  70.     return this.myCommandName;
  71. }
  72.  
  73. CanMessage.prototype.setData = function(name, value)
  74. {
  75.     this.myData[name] = value;
  76. }
  77.  
  78. CanMessage.prototype.getData = function(name)
  79. {
  80.     return this.myData[name];
  81. }
  82.  
  83. CanMessage.prototype.getDataString = function()
  84. {
  85.     var str = "";
  86.    
  87.     for (var key in this.myData)
  88.     {
  89.         /* encode base64 on the data part */
  90.         this.myData[key] = encode64(this.myData[key]+'');
  91.         str += key + ":" + this.myData[key] + ",";
  92.     }
  93.    
  94.     return str.rtrim(",");
  95. }
  96.  
  97.  
  98. CanMessage.prototype.send = function()
  99. {
  100.     sendCanMessage( this.getClassName(),
  101.             this.getDirectionFlag(),
  102.             this.getModuleName(),
  103.             this.getModuleId(),
  104.             this.getCommandName(),
  105.             this.getDataString());
  106. }
  107.  
  108. CanMessage.prototype.toString = function()
  109. {
  110.     return "[CanMessage] " +    this.getClassName() + ", " +
  111.                     this.getDirectionFlag() + ", " +
  112.                     this.getModuleName() + ", " +
  113.                     this.getModuleId() + ", " +
  114.                     this.getCommandName() + ", " +
  115.                     this.getDataString();
  116.                    
  117. }
  118.