Subversion Repositories HomeAutomation

Rev

Rev 1603 | Rev 1610 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1603 runge 1
 
2
function Dimmer230(name)
3
{
4
    this.Module(name);
1609 runge 5
    Dimmer230.instance_ = this;
1603 runge 6
}
7
 
8
Extend(Dimmer230, Module);
9
 
1609 runge 10
Dimmer230.instance_ = null;
11
 
1603 runge 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
 
1609 runge 25
Dimmer230_complete = function(args)
1603 runge 26
{
1609 runge 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
{
1603 runge 133
    var variables = [
134
    { "Channel"   : channel },
135
    { "Speed"     : speed },
136
    { "Direction" : direction } ];
137
 
1609 runge 138
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Start_Fade", variables);
139
    return "OK";
1603 runge 140
}
1609 runge 141
RegisterConsoleCommand("Dimmer230_StartFade", Dimmer230_complete);
1603 runge 142
 
1609 runge 143
 
144
Dimmer230_StopFade = function(id, channel)
1603 runge 145
{
146
    var variables = [
147
    { "Channel"  : channel } ];
148
 
1609 runge 149
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Stop_Fade", variables);
150
    return "OK";
1603 runge 151
}
1609 runge 152
RegisterConsoleCommand("Dimmer230_StopFade", Dimmer230_complete);
1603 runge 153
 
1609 runge 154
 
155
Dimmer230_AbsoluteFade = function(id, channel, speed, end_value)
1603 runge 156
{
157
    var variables = [
158
    { "Channel"  : channel },
159
    { "Speed"    : speed },
160
    { "EndValue" : end_value } ];
161
 
1609 runge 162
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Abs_Fade", variables);
163
    return "OK";
1603 runge 164
}
1609 runge 165
RegisterConsoleCommand("Dimmer230_AbsoluteFade", Dimmer230_complete);
1603 runge 166
 
1609 runge 167
 
168
Dimmer230_RelativeFade = function(id, channel, speed, direction, steps)
1603 runge 169
{
170
    var variables = [
171
    { "Channel"   : channel },
172
    { "Speed"     : speed },
173
    { "Direction" : direction },
174
    { "Steps"     : steps } ];
175
 
1609 runge 176
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Rel_Fade", variables);
177
    return "OK";
1603 runge 178
}
1609 runge 179
RegisterConsoleCommand("Dimmer230_RelativeFade", Dimmer230_complete);
1603 runge 180
 
1609 runge 181
 
182
Dimmer230_Demo = function(id, channel, speed, steps)
1603 runge 183
{
184
    var variables = [
185
    { "Channel"   : channel },
186
    { "Speed"     : speed },
187
    { "Steps"     : steps } ];
188
 
1609 runge 189
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Demo", variables);
190
    return "OK";
1603 runge 191
}
1609 runge 192
RegisterConsoleCommand("Dimmer230_Demo", Dimmer230_complete);