Subversion Repositories HomeAutomation

Rev

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

  1.  
  2. function hwPWM(type, name, id)
  3. {
  4.     this.CanService(type, name, id);
  5.     this.myLastValue = new Array();
  6. }
  7.  
  8. extend(hwPWM, CanService);
  9.  
  10. hwPWM.prototype.myReportInterval = null;
  11. hwPWM.prototype.myLastValue = null;
  12.  
  13. hwPWM.prototype.canMessageHandler = function(canMessage)
  14. {
  15.     if (canMessage.getDirectionFlag() == "From_Owner")
  16.     {
  17.         switch (canMessage.getCommandName())
  18.         {
  19.         /*case "hwPWM":
  20.         log(this.myName + ":" + this.myId + "> New value: " + canMessage.getData("Value") + "\n");
  21.         this.myLastValue[canMessage.getData("Id")] = canMessage.getData("Value");
  22.         this.callEvent("newValue", canMessage.getData("Id"));
  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. hwPWM.prototype.getValue = function(sensorId)
  36. {
  37.     return this.myLastValue[sensorId];
  38. }
  39.  
  40.  
  41. /*hwPWM.prototype.setReportInterval = function(time)
  42. {
  43.     var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "Report_Interval");
  44.     canMessage.setData("Time", time);
  45.     sendMessage(canMessage);
  46. }*/
  47.  
  48. /**
  49. pwmValue in % with 0.01 resolution (Example: 55.25%)
  50. */
  51. hwPWM.prototype.setPWMValue = function(pwmvalue, sensorId)
  52. {
  53.     var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "Pwm");
  54.     canMessage.setData("Id", sensorId);
  55.     canMessage.setData("Value", pwmvalue*100);
  56.     sendMessage(canMessage);
  57.    
  58.     this.myLastValue[sensorId] = pwmvalue;
  59. }
  60. /*hwPWM.prototype.configure = function(pwmPeriod, pwmDefaultValue, DefaultState, StartUpState)
  61. {
  62.     var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "CONFIG");
  63.     canMessage.setData("pwmPeriod", pwmPeriod);
  64.     canMessage.setData("pwmDefaultValue", pwmDefaultValue);
  65.     canMessage.setData("DefaultState", DefaultState);
  66.     canMessage.setData("StartUpState", StartUpState);
  67.     sendMessage(canMessage);
  68. }*/
  69.  
  70.