Subversion Repositories HomeAutomation

Rev

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. hwPWM.prototype.setPWMValue = function(pwmvalue, sensorId)
  48. {
  49.     var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "hwPWM");
  50.     canMessage.setData("ChannelId", sensorId);
  51.     canMessage.setData("Value", pwmvalue*100);
  52.     sendMessage(canMessage);
  53.    
  54.     this.myLastValue[sensorId] = pwmvalue;
  55. }
  56. /*hwPWM.prototype.configure = function(pwmPeriod, pwmDefaultValue, DefaultState, StartUpState)
  57. {
  58.     var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "CONFIG");
  59.     canMessage.setData("pwmPeriod", pwmPeriod);
  60.     canMessage.setData("pwmDefaultValue", pwmDefaultValue);
  61.     canMessage.setData("DefaultState", DefaultState);
  62.     canMessage.setData("StartUpState", StartUpState);
  63.     sendMessage(canMessage);
  64. }*/
  65.  
  66.