Subversion Repositories HomeAutomation

Rev

Rev 1603 | Rev 1610 | Go to most recent revision | Blame | Compare with Previous | 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. Dimmer230_complete = function(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.push(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.push(50);
  46.                 result.push(135);
  47.                 result.push(200);
  48.                 result.push(255);
  49.             }
  50.             else if (arg_index == 4) // direction
  51.             {
  52.                 result.push("Increase");
  53.                 result.push("Decrease");
  54.             }
  55.         }
  56.         else if (args[0] == "Dimmer230_AbsoluteFade")
  57.         {
  58.             if (arg_index == 3) // speed
  59.             {
  60.                 result.push(50);
  61.                 result.push(135);
  62.                 result.push(200);
  63.                 result.push(255);
  64.             }
  65.             else if (arg_index == 4) // end_value
  66.             {
  67.                 result.push(0);
  68.                 result.push(50);
  69.                 result.push(100);
  70.                 result.push(150);
  71.                 result.push(200);
  72.                 result.push(255);
  73.             }
  74.         }
  75.         else if (args[0] == "Dimmer230_RelativeFade")
  76.         {
  77.             if (arg_index == 3) // speed
  78.             {
  79.                 result.push(50);
  80.                 result.push(135);
  81.                 result.push(200);
  82.                 result.push(255);
  83.             }
  84.             else if (arg_index == 4) // direction
  85.             {
  86.                 result.push("Increase");
  87.                 result.push("Decrease");
  88.             }
  89.             else if (arg_index == 5) // steps
  90.             {
  91.                 result.push(0);
  92.                 result.push(10);
  93.                 result.push(20);
  94.                 result.push(30);
  95.                 result.push(40);
  96.                 result.push(50);
  97.                 result.push(60);
  98.                 result.push(70);
  99.                 result.push(80);
  100.                 result.push(90);
  101.             }
  102.         }
  103.         else if (args[0] == "Dimmer230_Demo")
  104.         {
  105.             if (arg_index == 3) // speed
  106.             {
  107.                 result.push(50);
  108.                 result.push(135);
  109.                 result.push(200);
  110.                 result.push(255);
  111.             }
  112.             else if (arg_index == 4) // steps
  113.             {
  114.                 result.push(0);
  115.                 result.push(10);
  116.                 result.push(20);
  117.                 result.push(30);
  118.                 result.push(40);
  119.                 result.push(50);
  120.                 result.push(60);
  121.                 result.push(70);
  122.                 result.push(80);
  123.                 result.push(90);
  124.             }
  125.         }
  126.     }
  127.    
  128.     return result;
  129. }
  130.  
  131. Dimmer230_StartFade = function(id, channel, speed, direction)
  132. {
  133.     var variables = [
  134.     { "Channel"   : channel },
  135.     { "Speed"     : speed },
  136.     { "Direction" : direction } ];
  137.    
  138.     Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Start_Fade", variables);
  139.     return "OK";
  140. }
  141. RegisterConsoleCommand("Dimmer230_StartFade", Dimmer230_complete);
  142.  
  143.  
  144. Dimmer230_StopFade = function(id, channel)
  145. {
  146.     var variables = [
  147.     { "Channel"  : channel } ];
  148.    
  149.     Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Stop_Fade", variables);
  150.     return "OK";
  151. }
  152. RegisterConsoleCommand("Dimmer230_StopFade", Dimmer230_complete);
  153.  
  154.  
  155. Dimmer230_AbsoluteFade = function(id, channel, speed, end_value)
  156. {
  157.     var variables = [
  158.     { "Channel"  : channel },
  159.     { "Speed"    : speed },
  160.     { "EndValue" : end_value } ];
  161.    
  162.     Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Abs_Fade", variables);
  163.     return "OK";
  164. }
  165. RegisterConsoleCommand("Dimmer230_AbsoluteFade", Dimmer230_complete);
  166.  
  167.  
  168. Dimmer230_RelativeFade = function(id, channel, speed, direction, steps)
  169. {
  170.     var variables = [
  171.     { "Channel"   : channel },
  172.     { "Speed"     : speed },
  173.     { "Direction" : direction },
  174.     { "Steps"     : steps } ];
  175.    
  176.     Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Rel_Fade", variables);
  177.     return "OK";
  178. }
  179. RegisterConsoleCommand("Dimmer230_RelativeFade", Dimmer230_complete);
  180.  
  181.  
  182. Dimmer230_Demo = function(id, channel, speed, steps)
  183. {
  184.     var variables = [
  185.     { "Channel"   : channel },
  186.     { "Speed"     : speed },
  187.     { "Steps"     : steps } ];
  188.    
  189.     Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Demo", variables);
  190.     return "OK";
  191. }
  192. RegisterConsoleCommand("Dimmer230_Demo", Dimmer230_complete);
  193.