Subversion Repositories HomeAutomation

Rev

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

  1.  
  2. function Dimmer230(type, name, id)
  3. {
  4.     this.CanService(type, name, id);
  5. }
  6.  
  7.  
  8. Dimmer230.prototype.currentValue = 0;
  9. Dimmer230.prototype.connection = "Disconnected";
  10. Dimmer230.prototype.frequency = "Error / Unknown";
  11.  
  12.  
  13. extend(Dimmer230, CanService);
  14.  
  15. Dimmer230.prototype.canMessageHandler = function(canMessage)
  16. {
  17. var self = this;
  18.     if (canMessage.getDirectionFlag() == "From_Owner")
  19.     {
  20.         switch (canMessage.getCommandName())
  21.         {
  22.         case "Netinfo":
  23.         this.connection = canMessage.getData("Connection");
  24.         this.frequency = canMessage.getData("Frequency");
  25.         this.currentValue = canMessage.getData("DimmerValue");
  26.         var connectString = "disconnected.";
  27.         var frequencyString = "";
  28.         if (this.connection == "Connected")
  29.         {
  30.             connectString = "connected";
  31.             frequencyString = " with frequency "+this.frequency;
  32.         }
  33.  
  34. var dataArray = new Array();
  35. dataArray["service"] = self;
  36. dataArray["channel"] = canMessage.getData("Channel");
  37. dataArray["connection"] = canMessage.getData("Connection");
  38. dataArray["currentValue"] = canMessage.getData("DimmerValue");
  39. dataArray["moduleName"] = canMessage.getModuleName();
  40. dataArray["moduleId"] = canMessage.getModuleId();
  41. this.callEvent("newValue", dataArray);
  42.         //log(this.myName + ":" + this.myId + "> Netstatus, " + connectString + frequencyString + "\n");
  43.         break;
  44.         }
  45.     }
  46.    
  47.     this.CanService.prototype.canMessageHandler.call(this, canMessage);
  48. }
  49.  
  50. Dimmer230.prototype.startFade = function(channel, speed, direction)
  51. {
  52.     var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "Start_Fade");
  53.     canMessage.setData("Channel", channel);
  54.     canMessage.setData("Speed", speed);
  55.     canMessage.setData("Direction", direction);
  56.     sendMessage(canMessage);
  57. }
  58.  
  59. Dimmer230.prototype.stopFade = function(channel)
  60. {
  61.     var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "Stop_Fade");
  62.     canMessage.setData("Channel", channel);
  63.     sendMessage(canMessage);
  64. }
  65.  
  66. Dimmer230.prototype.absFade = function(channel, speed, endValue)
  67. {
  68.     var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "Abs_Fade");
  69.     canMessage.setData("Channel", channel);
  70.     canMessage.setData("Speed", speed);
  71.     canMessage.setData("EndValue", endValue);
  72.     sendMessage(canMessage);
  73. }
  74.  
  75. Dimmer230.prototype.relFade = function(channel, speed, direction, steps)
  76. {
  77.     var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "Rel_Fade");
  78.     canMessage.setData("Channel", channel);
  79.     canMessage.setData("Speed", speed);
  80.     canMessage.setData("Direction", direction);
  81.     canMessage.setData("Steps", steps);
  82.     sendMessage(canMessage);
  83. }
  84.  
  85. Dimmer230.prototype.demo = function(channel, speed, steps)
  86. {
  87.     var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "Demo");
  88.     canMessage.setData("Channel", channel);
  89.     canMessage.setData("Speed", speed);
  90.     canMessage.setData("Steps", steps);
  91.     sendMessage(canMessage);
  92. }
  93.  
  94.