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