Subversion Repositories HomeAutomation

Rev

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

Rev Author Line No. Line
1489 arune 1
 
2
function irTransceive(type, name, id)
3
{
4
    this.CanService(type, name, id);
5
}
6
 
7
extend(irTransceive, CanService);
8
 
9
irTransceive.prototype.canMessageHandler = function(canMessage)
10
{
11
    /*if (canMessage.getDirectionFlag() == "From_Owner")
12
    {
13
        switch (canMessage.getCommandName())
14
        {
15
        case "IR":
16
        break;
17
        }
18
    }*/
19
 
20
    this.CanService.prototype.canMessageHandler.call(this, canMessage);
21
}
22
 
1492 arune 23
irTransceive.prototype.sendClick = function(channel, remoteName, buttonName, time)
1489 arune 24
{
1492 arune 25
    this.sendButton(channel, remoteName, buttonName, true);
1489 arune 26
 
27
    if (time)
28
    {
29
        sleep(time);
30
    }
31
    else
32
    {
33
        sleep(50000);
34
    }
35
 
1492 arune 36
    this.sendButton(channel, remoteName, buttonName, false);
1489 arune 37
}
38
 
1492 arune 39
irTransceive.prototype.sendButton = function(channel, remoteName, buttonName, down)
1489 arune 40
{
41
    var remotesStore = DataStore.getStore("IRRemotes");
42
 
43
    if (remotesStore)
44
    {
45
        for (var n = 0; n < remotesStore['remotes'].length; n++)
46
        {
47
            if (remotesStore['remotes'][n]['name'] == remoteName)
48
            {
49
                for (var code in remotesStore['remotes'][n]['codes'])
50
                {
51
                    if (remotesStore['remotes'][n]['codes'][code] == buttonName)
52
                    {
1492 arune 53
                        this.sendData(channel, remotesStore['remotes'][n]['protocol'], code, down ? "Pressed" : "Released");
1489 arune 54
                        return;
55
                    }
56
                }
57
            }
58
        }
59
    }
60
}
61
 
1492 arune 62
irTransceive.prototype.sendData = function(channel, protocol, data, status)
1489 arune 63
{
64
    var canMessage = new CanMessage("sns", "To_Owner", this.myName, this.myId, "IR");
1492 arune 65
    canMessage.setData("Channel", channel);
1489 arune 66
    canMessage.setData("Status", status);
67
    canMessage.setData("Protocol", protocol);
68
    canMessage.setData("IRdata", data);
69
    sendMessage(canMessage);
70
}