Subversion Repositories HomeAutomation

Rev

Rev 1666 | Rev 1673 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1666 Rev 1669
Line 2... Line 2...
2
Node_ResetNodeId = null;
2
Node_ResetNodeId = null;
3
Node_ResetClientId = null;
3
Node_ResetClientId = null;
4
 
4
 
5
Node_ProgramNodeId = null;
5
Node_ProgramNodeId = null;
6
Node_ProgramClientId = null;
6
Node_ProgramClientId = null;
-
 
7
 
-
 
8
Node_WaitClientId = null;
7
 
9
 
8
function Node_OnChange(node_id, available)
10
function Node_OnChange(node_id, available)
9
{
11
{
10
    if (node_id == Node_ResetNodeId && available)
12
    if (node_id == Node_ResetNodeId && available)
11
    {
13
    {
Line 18... Line 20...
18
    if (node_id == Node_ProgramNodeId && available)
20
    if (node_id == Node_ProgramNodeId && available)
19
    {
21
    {
20
        Console_LogToClient(Node_ProgramClientId, "\033[32m" + Node_ProgramNodeId + " started okay.\033[0m\n");
22
        Console_LogToClient(Node_ProgramClientId, "\033[32m" + Node_ProgramNodeId + " started okay.\033[0m\n");
21
        Node_ProgramNodeId = null;
23
        Node_ProgramNodeId = null;
22
        Node_ProgramClientId = null;
24
        Node_ProgramClientId = null;
23
        Console_SetDefaultPrompt();
25
        Console_SetDefaultPrompt();
24
    }
26
    }
-
 
27
   
-
 
28
    if (Node_WaitClientId != null && available)
-
 
29
    {    
-
 
30
        var result = NodeExport_GetNodeInformation(node_id);
-
 
31
   
-
 
32
        if (!result)
-
 
33
        {
-
 
34
            Console_LogToClient(Node_WaitClientId, "\033[31mNo node with id " + node_id + " found.\033[0m\n");
-
 
35
            return false;
-
 
36
        }
-
 
37
       
-
 
38
        var date = new Date(result["LastActive"] * 1000);
-
 
39
       
-
 
40
        Console_LogToClient(Node_WaitClientId, "Id: " + result["Id"] + "\n");
-
 
41
        Console_LogToClient(Node_WaitClientId, "Valid: " + result["Valid"] + "\n");
-
 
42
        Console_LogToClient(Node_WaitClientId, "Bios Version: " + result["BiosVersion"] + "\n");
-
 
43
        Console_LogToClient(Node_WaitClientId, "Device Type: " + result["DeviceType"] + "\n");
-
 
44
        Console_LogToClient(Node_WaitClientId, "Has Application: " + result["HasApplication"] + "\n");
-
 
45
        Console_LogToClient(Node_WaitClientId, "Last Active: " + date.toString() + "\n");
-
 
46
       
-
 
47
        Node_WaitClientId = null;
-
 
48
        Console_SetDefaultPrompt();
-
 
49
    }
25
}
50
}
26
 
51
 
27
function Node_GetAvailableIds()
52
function Node_GetAvailableIds()
28
{
53
{
29
    var result_list = [];
54
    var result_list = [];
30
    var available_nodes = NodeExport_GetAvailableNodes();
55
    var available_nodes = NodeExport_GetAvailableNodes();
Line 55... Line 80...
55
        {
80
        {
56
            modules = parts.join(", ");
81
            modules = parts.join(", ");
57
        }
82
        }
58
       
83
       
59
        lines.push([id, modules]);
84
        lines.push([id, modules]);
60
    }
85
    }
61
   
86
   
62
    var table_lines = create_table(lines);
87
    var table_lines = create_table(lines);
63
   
88
   
64
    Log("\033[29;1m" + table_lines[0] + "\033[0m\n");
89
    Log("\033[29;1m" + table_lines[0] + "\033[0m\n");
65
   
90
   
Line 89... Line 114...
89
    }
114
    }
90
   
115
   
91
    Node_ProgramClientId = Console_GetClientId();
116
    Node_ProgramClientId = Console_GetClientId();
92
    Node_ProgramNodeId = node_id;
117
    Node_ProgramNodeId = node_id;
93
    Console_PreventDefaultPrompt();
118
    Console_PreventDefaultPrompt();
94
 
119
 
95
    return true;
120
    return true;
96
}
121
}
97
Console_RegisterCommand(Node_Reset, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); });
122
Console_RegisterCommand(Node_Reset, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); });
98
 
123
 
99
function Node_Program(node_id, bios, filename)
124
function Node_Program(node_id, bios, filename)
Line 101... Line 126...
101
    if (arguments.length < 3)
126
    if (arguments.length < 3)
102
    {
127
    {
103
        Log("\033[31mNot enough parameters given.\033[0m\n");
128
        Log("\033[31mNot enough parameters given.\033[0m\n");
104
        return false;
129
        return false;
105
    }
130
    }
106
   
131
   
107
    Log("Initiating programming of " + node_id + "...\n");
132
    Log("Initiating programming of " + node_id + "...\n");
108
   
133
   
109
    if (!NodeExport_ProgramNode(node_id, bios > 0, filename))
134
    if (!NodeExport_ProgramNode(node_id, bios > 0, filename))
110
    {
135
    {
111
        Log("\033[31mFailed to start programming.\033[0m\n");
136
        Log("\033[31mFailed to start programming.\033[0m\n");
112
        return false;
137
        return false;
113
    }
138
    }
114
   
139
   
115
    Node_ResetClientId = Console_GetClientId();
140
    Node_ResetClientId = Console_GetClientId();
116
    Node_ResetNodeId = node_id;
141
    Node_ResetNodeId = node_id;
117
    Console_PreventDefaultPrompt();
142
    Console_PreventDefaultPrompt();
118
   
143
   
Line 123... Line 148...
123
function Node_GetInformation(node_id)
148
function Node_GetInformation(node_id)
124
{
149
{
125
    if (arguments.length < 1)
150
    if (arguments.length < 1)
126
    {
151
    {
127
        Log("\033[31mNot enough parameters given.\033[0m\n");
152
        Log("\033[31mNot enough parameters given.\033[0m\n");
128
        return false;
153
        return false;
129
    }
154
    }
130
   
155
   
131
    var result = NodeExport_GetNodeInformation(node_id);
156
    var result = NodeExport_GetNodeInformation(node_id);
132
   
157
   
133
    if (!result)
158
    if (!result)
134
    {
159
    {
135
        Log("\033[31mNo node with id " + node_id + " found.\033[0m\n");
160
        Log("\033[31mNo node with id " + node_id + " found.\033[0m\n");
136
        return false;
161
        return false;
137
    }
162
    }
138
   
163
   
139
    var date = new Date(result["LastActive"] * 1000);
164
    var date = new Date(result["LastActive"] * 1000);
140
   
165
   
141
    Log("Id: " + result["Id"] + "\n");
166
    Log("Id: " + result["Id"] + "\n");
142
    Log("Valid: " + result["Valid"] + "\n");
167
    Log("Valid: " + result["Valid"] + "\n");
143
    Log("BiosVersion: " + result["BiosVersion"] + "\n");
168
    Log("Bios Version: " + result["BiosVersion"] + "\n");
144
    Log("DeviceType: " + result["DeviceType"] + "\n");
169
    Log("Device Type: " + result["DeviceType"] + "\n");
145
    Log("HasApplication: " + result["HasApplication"] + "\n");
170
    Log("Has Application: " + result["HasApplication"] + "\n");
146
    Log("LastActive: " + date.toString() + "\n");
171
    Log("Last Active: " + date.toString() + "\n");
-
 
172
   
-
 
173
    return true;
-
 
174
}
-
 
175
Console_RegisterCommand(Node_GetInformation, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); });
-
 
176
 
-
 
177
function Node_WaitForInformation()
-
 
178
{
-
 
179
    Node_WaitClientId = Console_GetClientId();
-
 
180
    Console_PreventDefaultPrompt();
147
   
181
   
148
    return true;
182
    return true;
149
}
183
}
150
Console_RegisterCommand(Node_GetInformation, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); });
184
Console_RegisterCommand(Node_WaitForInformation);