Subversion Repositories HomeAutomation

Rev

Rev 1609 | Blame | Last modification | View Log | SVN | RSS feed

  1.  
  2. function Dimmer230(name)
  3. {
  4.     this.Module(name);
  5.     Dimmer230.instance_ = this;
  6. }
  7.  
  8. Extend(Dimmer230, Module);
  9.  
  10. Dimmer230.instance_ = null;
  11.  
  12. Dimmer230.prototype.ReceiveMessage = function(id, command, variables)
  13. {
  14.     switch (command)
  15.     {
  16.         case "Netinfo":
  17.         {
  18.             break;
  19.         }
  20.     }
  21.    
  22.     this.Module.prototype.ReceiveMessage.call(this, id, command, variables);
  23. }
  24.  
  25. function Dimmer230_complete(args)
  26. {
  27.     var result = new Array();
  28.    
  29.     var arg_index = args.length - 1;
  30.    
  31.     if (arg_index == 1) // id
  32.     {
  33.         result = Dimmer230.instance_.GetAvailableIds();
  34.     }
  35.     else if (arg_index == 2) // channel
  36.     {
  37.         result = [ 0 ];
  38.     }
  39.     else if (arg_index > 2)
  40.     {
  41.         if (args[0] == "Dimmer230_StartFade")
  42.         {
  43.             if (arg_index == 3) // speed
  44.             {
  45.                 result = [ 50, 135, 200, 255 ];
  46.             }
  47.             else if (arg_index == 4) // direction
  48.             {
  49.                 result = [ "Increase", "Decrease" ];
  50.             }
  51.         }
  52.         else if (args[0] == "Dimmer230_AbsoluteFade")
  53.         {
  54.             if (arg_index == 3) // speed
  55.             {
  56.                 result = [ 50, 135, 200, 255 ];
  57.             }
  58.             else if (arg_index == 4) // end_value
  59.             {
  60.                 result = [ 0, 50, 100, 150, 200, 255 ];
  61.             }
  62.         }
  63.         else if (args[0] == "Dimmer230_RelativeFade")
  64.         {
  65.             if (arg_index == 3) // speed
  66.             {
  67.                 result = [ 50, 135, 200, 255 ];
  68.             }
  69.             else if (arg_index == 4) // direction
  70.             {
  71.                 result = [ "Increase", "Decrease" ];
  72.             }
  73.             else if (arg_index == 5) // steps
  74.             {
  75.                 result = [ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 ];
  76.             }
  77.         }
  78.         else if (args[0] == "Dimmer230_Demo")
  79.         {
  80.             if (arg_index == 3) // speed
  81.             {
  82.                 result = [ 50, 135, 200, 255 ];
  83.             }
  84.             else if (arg_index == 4) // steps
  85.             {
  86.                 result = [ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 ];
  87.             }
  88.         }
  89.     }
  90.    
  91.     return result;
  92. }
  93.  
  94. function Dimmer230_StartFade(id, channel, speed, direction)
  95. {
  96.     var variables = [
  97.     { "Channel"   : channel },
  98.     { "Speed"     : speed },
  99.     { "Direction" : direction } ];
  100.    
  101.     Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Start_Fade", variables);
  102.     return "OK";
  103. }
  104. RegisterConsoleCommand(Dimmer230_StartFade, Dimmer230_complete);
  105.  
  106.  
  107. function Dimmer230_StopFade(id, channel)
  108. {
  109.     var variables = [
  110.     { "Channel"  : channel } ];
  111.    
  112.     Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Stop_Fade", variables);
  113.     return "OK";
  114. }
  115. RegisterConsoleCommand(Dimmer230_StopFade, Dimmer230_complete);
  116.  
  117.  
  118. function Dimmer230_AbsoluteFade(id, channel, speed, end_value)
  119. {
  120.     var variables = [
  121.     { "Channel"  : channel },
  122.     { "Speed"    : speed },
  123.     { "EndValue" : end_value } ];
  124.    
  125.     Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Abs_Fade", variables);
  126.     return "OK";
  127. }
  128. RegisterConsoleCommand(Dimmer230_AbsoluteFade, Dimmer230_complete);
  129.  
  130.  
  131. function Dimmer230_RelativeFade(id, channel, speed, direction, steps)
  132. {
  133.     var variables = [
  134.     { "Channel"   : channel },
  135.     { "Speed"     : speed },
  136.     { "Direction" : direction },
  137.     { "Steps"     : steps } ];
  138.    
  139.     Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Rel_Fade", variables);
  140.     return "OK";
  141. }
  142. RegisterConsoleCommand(Dimmer230_RelativeFade, Dimmer230_complete);
  143.  
  144.  
  145. function Dimmer230_Demo(id, channel, speed, steps)
  146. {
  147.     var variables = [
  148.     { "Channel"   : channel },
  149.     { "Speed"     : speed },
  150.     { "Steps"     : steps } ];
  151.    
  152.     Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Demo", variables);
  153.     return "OK";
  154. }
  155. RegisterConsoleCommand(Dimmer230_Demo, Dimmer230_complete);
  156.