Subversion Repositories HomeAutomation

Rev

Rev 1609 | Rev 1614 | 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
 
1610 runge 25
function Dimmer230_complete(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
    {
1610 runge 37
        result = [ 0 ];
1609 runge 38
    }
39
    else if (arg_index > 2)
40
    {
41
        if (args[0] == "Dimmer230_StartFade")
42
        {
43
            if (arg_index == 3) // speed
44
            {
1610 runge 45
                result = [ 50, 135, 200, 255 ];
1609 runge 46
            }
47
            else if (arg_index == 4) // direction
48
            {
1610 runge 49
                result = [ "Increase", "Decrease" ];
1609 runge 50
            }
51
        }
52
        else if (args[0] == "Dimmer230_AbsoluteFade")
53
        {
54
            if (arg_index == 3) // speed
55
            {
1610 runge 56
                result = [ 50, 135, 200, 255 ];
1609 runge 57
            }
58
            else if (arg_index == 4) // end_value
59
            {
1610 runge 60
                result = [ 0, 50, 100, 150, 200, 255 ];
1609 runge 61
            }
62
        }
63
        else if (args[0] == "Dimmer230_RelativeFade")
64
        {
65
            if (arg_index == 3) // speed
66
            {
1610 runge 67
                result = [ 50, 135, 200, 255 ];
1609 runge 68
            }
69
            else if (arg_index == 4) // direction
70
            {
1610 runge 71
                result = [ "Increase", "Decrease" ];
1609 runge 72
            }
73
            else if (arg_index == 5) // steps
74
            {
1610 runge 75
                result = [ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 ];
1609 runge 76
            }
77
        }
78
        else if (args[0] == "Dimmer230_Demo")
79
        {
80
            if (arg_index == 3) // speed
81
            {
1610 runge 82
                result = [ 50, 135, 200, 255 ];
1609 runge 83
            }
84
            else if (arg_index == 4) // steps
85
            {
1610 runge 86
                result = [ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 ];
1609 runge 87
            }
88
        }
89
    }
90
 
91
    return result;
92
}
93
 
1610 runge 94
function Dimmer230_StartFade(id, channel, speed, direction)
1609 runge 95
{
1603 runge 96
    var variables = [
97
    { "Channel"   : channel },
98
    { "Speed"     : speed },
99
    { "Direction" : direction } ];
100
 
1609 runge 101
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Start_Fade", variables);
102
    return "OK";
1603 runge 103
}
1610 runge 104
RegisterConsoleCommand(Dimmer230_StartFade, Dimmer230_complete);
1603 runge 105
 
1609 runge 106
 
1610 runge 107
function Dimmer230_StopFade(id, channel)
1603 runge 108
{
109
    var variables = [
110
    { "Channel"  : channel } ];
111
 
1609 runge 112
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Stop_Fade", variables);
113
    return "OK";
1603 runge 114
}
1610 runge 115
RegisterConsoleCommand(Dimmer230_StopFade, Dimmer230_complete);
1603 runge 116
 
1609 runge 117
 
1610 runge 118
function Dimmer230_AbsoluteFade(id, channel, speed, end_value)
1603 runge 119
{
120
    var variables = [
121
    { "Channel"  : channel },
122
    { "Speed"    : speed },
123
    { "EndValue" : end_value } ];
124
 
1609 runge 125
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Abs_Fade", variables);
126
    return "OK";
1603 runge 127
}
1610 runge 128
RegisterConsoleCommand(Dimmer230_AbsoluteFade, Dimmer230_complete);
1603 runge 129
 
1609 runge 130
 
1610 runge 131
function Dimmer230_RelativeFade(id, channel, speed, direction, steps)
1603 runge 132
{
133
    var variables = [
134
    { "Channel"   : channel },
135
    { "Speed"     : speed },
136
    { "Direction" : direction },
137
    { "Steps"     : steps } ];
138
 
1609 runge 139
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Rel_Fade", variables);
140
    return "OK";
1603 runge 141
}
1610 runge 142
RegisterConsoleCommand(Dimmer230_RelativeFade, Dimmer230_complete);
1603 runge 143
 
1609 runge 144
 
1610 runge 145
function Dimmer230_Demo(id, channel, speed, steps)
1603 runge 146
{
147
    var variables = [
148
    { "Channel"   : channel },
149
    { "Speed"     : speed },
150
    { "Steps"     : steps } ];
151
 
1609 runge 152
    Dimmer230.instance_.Module.prototype.SendMessage.call(Dimmer230.instance_, id, "Demo", variables);
153
    return "OK";
1603 runge 154
}
1610 runge 155
RegisterConsoleCommand(Dimmer230_Demo, Dimmer230_complete);