Subversion Repositories HomeAutomation

Rev

Rev 1603 | Rev 1610 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1603 Rev 1609
Line 4... Line 4...
4
    this.Module(name);
4
    this.Module(name);
-
 
5
    Dimmer230.instance_ = this;
5
}
6
}
6
 
7
 
7
Extend(Dimmer230, Module);
8
Extend(Dimmer230, Module);
-
 
9
 
-
 
10
Dimmer230.instance_ = null;
8
 
11
 
9
Dimmer230.prototype.ReceiveMessage = function(id, command, variables)
12
Dimmer230.prototype.ReceiveMessage = function(id, command, variables)
10
{
13
{
11
    switch (command)
14
    switch (command)
12
    {
15
    {
13
        case "Netinfo":
16
        case "Netinfo":
14
        {
17
        {
15
            break;
18
            break;
16
        }
19
        }
17
    }
20
    }
18
   
21
   
19
    this.Module.prototype.ReceiveMessage.call(this, id, command, variables);
22
    this.Module.prototype.ReceiveMessage.call(this, id, command, variables);
20
}
23
}
21
 
24
 
22
Dimmer230.prototype.StartFade = function(id, channel, speed, direction)
25
Dimmer230_complete = function(args)
23
{
26
{
-
 
27
    var result = new Array();
-
 
28
   
24
    var variables = [
29
    var arg_index = args.length - 1;
-
 
30
   
-
 
31
    if (arg_index == 1) // id
-
 
32
    {
-
 
33
        result = Dimmer230.instance_.GetAvailableIds();
-
 
34
    }
25
    { "Channel"   : channel },
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
        {
26
    { "Speed"     : speed },
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");
27
    { "Direction" : direction } ];
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
    }
28
   
127
   
29
    this.Module.prototype.SendMessage.call(this, id, "Start_Fade", variables);
128
    return result;
30
}
129
}
31
 
130
 
32
Dimmer230.prototype.StopFade = function(id, channel)
131
Dimmer230_StartFade = function(id, channel, speed, direction)
33
{
132
{
34
    var variables = [
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 = [
35
    { "Channel"  : channel } ];
147
    { "Channel"  : channel } ];
36
   
148
   
37
    this.Module.prototype.SendMessage.call(this, id, "Stop_Fade", variables);
149
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Stop_Fade", variables);
-
 
150
    return "OK";
38
}
151
}
-
 
152
RegisterConsoleCommand("Dimmer230_StopFade", Dimmer230_complete);
-
 
153
 
39
 
154
 
40
Dimmer230.prototype.AbsoluteFade = function(id, channel, speed, end_value)
155
Dimmer230_AbsoluteFade = function(id, channel, speed, end_value)
41
{
156
{
42
    var variables = [
157
    var variables = [
43
    { "Channel"  : channel },
158
    { "Channel"  : channel },
44
    { "Speed"    : speed },
159
    { "Speed"    : speed },
45
    { "EndValue" : end_value } ];
160
    { "EndValue" : end_value } ];
46
   
161
   
47
    this.Module.prototype.SendMessage.call(this, id, "Abs_Fade", variables);
162
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Abs_Fade", variables);
-
 
163
    return "OK";
48
}
164
}
-
 
165
RegisterConsoleCommand("Dimmer230_AbsoluteFade", Dimmer230_complete);
-
 
166
 
49
 
167
 
50
Dimmer230.prototype.RelativeFade = function(id, channel, speed, direction, steps)
168
Dimmer230_RelativeFade = function(id, channel, speed, direction, steps)
51
{
169
{
52
    var variables = [
170
    var variables = [
53
    { "Channel"   : channel },
171
    { "Channel"   : channel },
54
    { "Speed"     : speed },
172
    { "Speed"     : speed },
55
    { "Direction" : direction },
173
    { "Direction" : direction },
56
    { "Steps"     : steps } ];
174
    { "Steps"     : steps } ];
57
   
175
   
58
    this.Module.prototype.SendMessage.call(this, id, "Rel_Fade", variables);
176
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Rel_Fade", variables);
-
 
177
    return "OK";
59
}
178
}
-
 
179
RegisterConsoleCommand("Dimmer230_RelativeFade", Dimmer230_complete);
-
 
180
 
60
 
181
 
61
Dimmer230.prototype.Demo = function(id, channel, speed, steps)
182
Dimmer230_Demo = function(id, channel, speed, steps)
62
{
183
{
63
    var variables = [
184
    var variables = [
64
    { "Channel"   : channel },
185
    { "Channel"   : channel },
65
    { "Speed"     : speed },
186
    { "Speed"     : speed },
66
    { "Steps"     : steps } ];
187
    { "Steps"     : steps } ];
67
   
188
   
68
    this.Module.prototype.SendMessage.call(this, id, "Demo", variables);
189
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Demo", variables);
-
 
190
    return "OK";
69
}
191
}
-
 
192
RegisterConsoleCommand("Dimmer230_Demo", Dimmer230_complete);