Subversion Repositories HomeAutomation

Rev

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

Rev 1007 Rev 1008
Line 15... Line 15...
15
    }
15
    }
16
    else
16
    else
17
    {
17
    {
18
        log(text);
18
        log(text);
19
    }
19
    }
-
 
20
}
-
 
21
 
-
 
22
function printTo(clientId, text)
-
 
23
{
-
 
24
    _print(ClientId, text);
20
}
25
}
21
 
26
 
22
function services()
27
function services()
23
{
28
{
24
    var list = new Array();
29
    var list = new Array();
Line 27... Line 32...
27
   
32
   
28
    row[row.length] = "Type";
33
    row[row.length] = "Type";
29
    row[row.length] = "Name";
34
    row[row.length] = "Name";
30
    row[row.length] = "Id";
35
    row[row.length] = "Id";
31
    row[row.length] = "Online";
36
    row[row.length] = "Online";
32
   
37
   
33
    list[list.length] = row;
38
    list[list.length] = row;
34
   
39
   
35
    for (var n in ServiceManager.Services)
40
    for (var n in ServiceManager.Services)
36
    {
41
    {
37
        var row = new Array();
42
        var row = new Array();
38
       
43
       
39
        row[row.length] = ServiceManager.Services[n].getType();
44
        row[row.length] = ServiceManager.Services[n].getType();
40
        row[row.length] = ServiceManager.Services[n].getName();
45
        row[row.length] = ServiceManager.Services[n].getName();
41
        row[row.length] = ServiceManager.Services[n].getId();
46
        row[row.length] = ServiceManager.Services[n].getId();
42
        if (ServiceManager.Services[n].getType() == "CAN")
47
        if (ServiceManager.Services[n].getType() == "Can")
43
        {
48
        {
44
            row[row.length] = ServiceManager.Services[n].isOnline();
49
            row[row.length] = ServiceManager.Services[n].isOnline();
45
        }
50
        }
46
        else
51
        else
47
        {
52
        {
48
            row[row.length] = "";
53
            row[row.length] = "";
49
        }
54
        }
50
       
55
       
51
        list[list.length] = row;
56
        list[list.length] = row;
52
    }
57
    }
53
 
58
 
54
    var lines = TextTable.create(list);
59
    var lines = TextTable.create(list);
55
   
60
   
56
    for (var n in lines)
61
    for (var n in lines)
57
    {
62
    {
58
        print(lines[n] + "\n");
63
        print(lines[n] + "\n");
59
    }
64
    }
60
}
65
}
61
 
66
 
62
function getService(id, name)
67
function getService(id, name)
63
{
68
{
64
    var fullId = name + id;
69
    var fullId = name + id;
65
 
70
 
66
    if (!ServiceManager.Services[fullId])
71
    if (!ServiceManager.Services[fullId])
67
    {
72
    {
68
        print("No such service found.\n");
73
        print("No such service found.\n");
69
    }
74
    }
70
   
75
   
71
    return ServiceManager.Services[fullId];
76
    return ServiceManager.Services[fullId];
-
 
77
}
-
 
78
 
-
 
79
var ProgrammingClientId = null;
-
 
80
 
-
 
81
function programNodeCallback(status, text)
-
 
82
{
-
 
83
    printTo(ProgrammingClientId, text + "\n");
-
 
84
}
-
 
85
 
-
 
86
function programNode(hardwareId, hexData, bios)
-
 
87
{
-
 
88
    ProgrammingClientId = ClientId;
-
 
89
 
-
 
90
    var node = CanNodes[hardwareId];
-
 
91
   
-
 
92
    if (!node)
-
 
93
    {
-
 
94
        print("Failed. No node is online that has that hardware id, " + hardwareId + "\n");
-
 
95
        return;
-
 
96
    }
-
 
97
   
-
 
98
    hexData = unescape(hexData);
-
 
99
   
-
 
100
    //var hexData = getFileContents(hexFilename);
-
 
101
   
-
 
102
    if (hexData)
-
 
103
    {
-
 
104
        var hexLinesOrg = hexData.split('\n');
-
 
105
        var hexLines = new Array();
-
 
106
       
-
 
107
        for (var n = 0; n < hexLinesOrg.length; n++)
-
 
108
        {
-
 
109
            var line = hexLinesOrg[n].trim(' ');
-
 
110
           
-
 
111
            if (line != "")
-
 
112
            {
-
 
113
                hexLines[hexLines.length] = line;
-
 
114
            }
-
 
115
        }
-
 
116
       
-
 
117
        node.startProgramming(hexLines, programNodeCallback, bios);
-
 
118
    }
-
 
119
    else
-
 
120
    {
-
 
121
        print("File was not found, " + hexFilename + "\n");
-
 
122
    }
72
}
123
}