Subversion Repositories HomeAutomation

Rev

Rev 2164 | Rev 2171 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 2164 Rev 2170
1
 
1
 
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
 
7
 
8
Node_WaitClientId = null;
8
Node_WaitClientId = null;
9
 
9
 
-
 
10
Node_ResetNodeNativeId = null;
-
 
11
Node_ProgramNodeNativeId = null;
10
Node_Native_Reset = false;
12
Node_Native_Reset = false;
11
Node_Native_Program = false;
13
Node_Native_Program = false;
12
Node_Native_WaitNodeId = false;
14
Node_Native_WaitNodeId = false;
13
 
15
 
14
Node_HexData = "";
16
Node_HexData = "";
15
Node_HexNumLines = 0;
17
Node_HexNumLines = 0;
16
 
18
 
17
function Node_OnChange(node_id, available)
19
function Node_OnChange(node_id, available)
18
{
20
{
19
//Log("Node_OnChange "+Node_ResetNodeId+" "+Node_ProgramNodeId+" "+node_id+" "+available+"\n");
21
//Log("Node_OnChange "+Node_ResetNodeId+" "+Node_ProgramNodeId+" "+node_id+" "+available+"\n");
20
    if (node_id == Node_ResetNodeId && available)
22
    if (node_id == Node_ResetNodeId && available)
21
    {
23
    {
22
//Log("ResetNodeId "+Node_Native_Reset+"\n");
24
//Log("ResetNodeId "+Node_Native_Reset+"\n");
23
        Console_LogToClient(Node_ResetClientId, "\033[32m" + Node_ResetNodeId + " started okay.\033[0m\n");
25
        Console_LogToClient(Node_ResetClientId, "\033[32m" + Node_ResetNodeId + " started okay.\033[0m\n");
24
 
26
 
25
        Console_NewConnection(Node_ResetClientId); // This is a ugly hack for a bad design for multiusers
27
        Console_NewConnection(Node_ResetClientId); // This is a ugly hack for a bad design for multiusers
26
        Node_ResetNodeId = null;
28
        Node_ResetNodeId = null;
27
        Node_ResetClientId = null;
29
        Node_ResetClientId = null;
28
       
-
 
29
        Node_Native_Reset = true;
-
 
30
    }
30
    }
-
 
31
    if (node_id == Node_ResetNodeId && available)
-
 
32
    {
-
 
33
        Node_Native_Reset = true;
-
 
34
        Node_ResetNodeNativeId = null;
-
 
35
    }
31
 
36
 
32
    if (node_id == Node_ProgramNodeId && available)
37
    if (node_id == Node_ProgramNodeId && available)
33
    {
38
    {
34
//Log("ProgramNodeId "+Node_Native_Program+"\n");
39
//Log("ProgramNodeId "+Node_Native_Program+"\n");
35
        Console_LogToClient(Node_ProgramClientId, "\033[32m" + Node_ProgramNodeId + " started okay.\033[0m\n");
40
        Console_LogToClient(Node_ProgramClientId, "\033[32m" + Node_ProgramNodeId + " started okay.\033[0m\n");
36
 
41
 
37
        Console_NewConnection(Node_ProgramClientId); // This is a ugly hack for a bad design for multiusers
42
        Console_NewConnection(Node_ProgramClientId); // This is a ugly hack for a bad design for multiusers
38
        Node_ProgramNodeId = null;
43
        Node_ProgramNodeId = null;
39
        Node_ProgramClientId = null;
44
        Node_ProgramClientId = null;
-
 
45
    }
-
 
46
    if (node_id == Node_ProgramNodeId && available)
40
       
47
    {
-
 
48
        Node_ProgramNodeNativeId = null;
41
        Node_Native_Program = true;
49
        Node_Native_Program = true;
42
    }
50
    }
43
 
51
 
44
    if (Node_WaitClientId != null && available)
52
    if (Node_WaitClientId != null && available)
45
    {
53
    {
46
        var result = NodeExport_GetNodeInformation(node_id);
54
        var result = NodeExport_GetNodeInformation(node_id);
47
        Node_Native_WaitNodeId = node_id;
55
        Node_Native_WaitNodeId = node_id;
48
 
56
 
49
        if (!result)
57
        if (!result)
50
        {
58
        {
51
            Console_LogToClient(Node_WaitClientId, "\033[31mNo node with id " + node_id + " found.\033[0m\n");
59
            Console_LogToClient(Node_WaitClientId, "\033[31mNo node with id " + node_id + " found.\033[0m\n");
52
            return false;
60
            return false;
53
        }
61
        }
54
 
62
 
55
        var date = new Date(result["LastActive"] * 1000);
63
        var date = new Date(result["LastActive"] * 1000);
56
 
64
 
57
        Console_LogToClient(Node_WaitClientId, "Id: " + result["Id"] + "\n");
65
        Console_LogToClient(Node_WaitClientId, "Id: " + result["Id"] + "\n");
58
        Console_LogToClient(Node_WaitClientId, "Valid: " + result["Valid"] + "\n");
66
        Console_LogToClient(Node_WaitClientId, "Valid: " + result["Valid"] + "\n");
59
        Console_LogToClient(Node_WaitClientId, "Bios Version: " + result["BiosVersion"] + "\n");
67
        Console_LogToClient(Node_WaitClientId, "Bios Version: " + result["BiosVersion"] + "\n");
60
        Console_LogToClient(Node_WaitClientId, "Device Type: " + result["DeviceType"] + "\n");
68
        Console_LogToClient(Node_WaitClientId, "Device Type: " + result["DeviceType"] + "\n");
61
        Console_LogToClient(Node_WaitClientId, "Has Application: " + result["HasApplication"] + "\n");
69
        Console_LogToClient(Node_WaitClientId, "Has Application: " + result["HasApplication"] + "\n");
62
        Console_LogToClient(Node_WaitClientId, "Last Active: " + date.toString() + "\n");
70
        Console_LogToClient(Node_WaitClientId, "Last Active: " + date.toString() + "\n");
63
 
71
 
64
        Console_NewConnection(Node_WaitClientId); // This is a ugly hack for a bad design for multiusers
72
        Console_NewConnection(Node_WaitClientId); // This is a ugly hack for a bad design for multiusers
65
        Node_WaitClientId = null;
73
        Node_WaitClientId = null;
66
    }
74
    }
67
}
75
}
68
 
76
 
69
function Node_GetAvailableIds()
77
function Node_GetAvailableIds()
70
{
78
{
71
    var result_list = [];
79
    var result_list = [];
72
    var available_nodes = NodeExport_GetAvailableNodes();
80
    var available_nodes = NodeExport_GetAvailableNodes();
73
 
81
 
74
    for (var n in available_nodes)
82
    for (var n in available_nodes)
75
    {
83
    {
76
        var id_parts = available_nodes[n].split(",", 2);
84
        var id_parts = available_nodes[n].split(",", 2);
77
 
85
 
78
        result_list.push(id_parts[0]);
86
        result_list.push(id_parts[0]);
79
    }
87
    }
80
 
88
 
81
    return result_list;
89
    return result_list;
82
}
90
}
83
 
91
 
84
function Node_ListAvailable()
92
function Node_ListAvailable()
85
{
93
{
86
    var available_nodes = NodeExport_GetAvailableNodes();
94
    var available_nodes = NodeExport_GetAvailableNodes();
87
 
95
 
88
    var lines = [["Id", "Modules"]];
96
    var lines = [["Id", "Modules"]];
89
 
97
 
90
    for (var n in available_nodes)
98
    for (var n in available_nodes)
91
    {
99
    {
92
        var parts = available_nodes[n].split(",");
100
        var parts = available_nodes[n].split(",");
93
        var id = parts.shift();
101
        var id = parts.shift();
94
        var modules = "<none>";
102
        var modules = "<none>";
95
 
103
 
96
        if (parts.length > 0)
104
        if (parts.length > 0)
97
        {
105
        {
98
            modules = parts.join(", ");
106
            modules = parts.join(", ");
99
        }
107
        }
100
 
108
 
101
        lines.push([id, modules]);
109
        lines.push([id, modules]);
102
    }
110
    }
103
 
111
 
104
    var table_lines = create_table(lines);
112
    var table_lines = create_table(lines);
105
 
113
 
106
    Log("\033[29;1m" + table_lines[0] + "\033[0m\n");
114
    Log("\033[29;1m" + table_lines[0] + "\033[0m\n");
107
 
115
 
108
    for (var n = 1; n < table_lines.length; n++)
116
    for (var n = 1; n < table_lines.length; n++)
109
    {
117
    {
110
        Log(table_lines[n] + "\n");
118
        Log(table_lines[n] + "\n");
111
    }
119
    }
112
 
120
 
113
    return true;
121
    return true;
114
}
122
}
115
Console_RegisterCommand(Node_ListAvailable);
123
Console_RegisterCommand(Node_ListAvailable);
116
 
124
 
117
function Node_WaitNodePollNative()
125
function Node_WaitNodePollNative()
118
{
126
{
119
    if (Node_Native_WaitNodeId)
127
    if (Node_Native_WaitNodeId)
120
    {
128
    {
121
        var result = NodeExport_GetNodeInformation(Node_Native_WaitNodeId);
129
        var result = NodeExport_GetNodeInformation(Node_Native_WaitNodeId);
122
 
130
 
123
        if (!result)
131
        if (!result)
124
        {
132
        {
125
            return "\033[31mError: No node with id " + Node_Native_WaitNodeId + " found.\033[0m";
133
            return "\033[31mError: No node with id " + Node_Native_WaitNodeId + " found.\033[0m";
126
        }
134
        }
127
 
135
 
128
        var date = new Date(result["LastActive"] * 1000);
136
        var date = new Date(result["LastActive"] * 1000);
129
 
137
 
130
        return "Id: " + result["Id"] + "\t"+
138
        return "Id: " + result["Id"] + "\t"+
131
        "Valid: " + result["Valid"] + "\t"+
139
        "Valid: " + result["Valid"] + "\t"+
132
        "Bios Version: " + result["BiosVersion"] + "\t"+
140
        "Bios Version: " + result["BiosVersion"] + "\t"+
133
        "Device Type: " + result["DeviceType"] + "\t"+
141
        "Device Type: " + result["DeviceType"] + "\t"+
134
        "Has Application: " + result["HasApplication"] + "\t"+
142
        "Has Application: " + result["HasApplication"] + "\t"+
135
        "Last Active: " + date.toString();
143
        "Last Active: " + date.toString();
136
    }
144
    }
137
    else
145
    else
138
    {
146
    {
139
        return false;
147
        return false;
140
    }
148
    }
141
}
149
}
142
 
150
 
143
function Node_WaitForInformationNative()
151
function Node_WaitForInformationNative()
144
{
152
{
145
    Node_WaitClientId = Console_GetClientId();
153
    Node_WaitClientId = Console_GetClientId();
146
    Node_Native_WaitNodeId = false;
154
    Node_Native_WaitNodeId = false;
147
}
155
}
148
 
156
 
149
function Node_ResetPollNative()
157
function Node_ResetPollNative()
150
{
158
{
151
    return Node_Native_Reset;
159
    return Node_Native_Reset;
152
}
160
}
153
 
161
 
154
function Node_ResetNative(node_id)
162
function Node_ResetNative(node_id)
155
{
163
{
156
    if (arguments.length < 1)
164
    if (arguments.length < 1)
157
    {
165
    {
158
        return "\033[31mError: Not enough parameters given.\033[0m";
166
        return "\033[31mError: Not enough parameters given.\033[0m";
159
    }
167
    }
160
 
168
 
161
    Node_Native_Reset = false;
169
    Node_Native_Reset = false;
162
    if (!NodeExport_ResetNode(node_id))
170
    if (!NodeExport_ResetNode(node_id))
163
    {
171
    {
164
        return "\033[31mError: Failed to send reset, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m";
172
        return "\033[31mError: Failed to send reset, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m";
165
    }
173
    }
166
 
174
 
167
    Node_ResetClientId = Console_GetClientId();
-
 
168
    Node_ResetNodeId = node_id;
175
    Node_ResetNodeNativeId = node_id;
169
 
176
 
170
    return "Reset command sent successfully";
177
    return "Reset command sent successfully";
171
}
178
}
172
 
179
 
173
function Node_Reset(node_id)
180
function Node_Reset(node_id)
174
{
181
{
175
    if (arguments.length < 1)
182
    if (arguments.length < 1)
176
    {
183
    {
177
        Log("\033[31mNot enough parameters given.\033[0m\n");
184
        Log("\033[31mNot enough parameters given.\033[0m\n");
178
        return false;
185
        return false;
179
    }
186
    }
180
 
187
 
181
    Log("Sending reset to " + node_id + "...\n");
188
    Log("Sending reset to " + node_id + "...\n");
182
 
189
 
183
    if (!NodeExport_ResetNode(node_id))
190
    if (!NodeExport_ResetNode(node_id))
184
    {
191
    {
185
        Log("\033[31mFailed to send reset, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m\n");
192
        Log("\033[31mFailed to send reset, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m\n");
186
        return false;
193
        return false;
187
    }
194
    }
188
 
195
 
189
    Node_ResetClientId = Console_GetClientId();
196
    Node_ResetClientId = Console_GetClientId();
190
    Node_ResetNodeId = node_id;
197
    Node_ResetNodeId = node_id;
191
    Console_PreventDefaultPrompt();
198
    Console_PreventDefaultPrompt();
192
 
199
 
193
    return true;
200
    return true;
194
}
201
}
195
Console_RegisterCommand(Node_Reset, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); });
202
Console_RegisterCommand(Node_Reset, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); });
196
 
203
 
197
function Node_ProgramPollNative()
204
function Node_ProgramPollNative()
198
{
205
{
199
    return Node_Native_Program;
206
    return Node_Native_Program;
200
}
207
}
201
 
208
 
202
function Node_AppendHexNative(hexrow)
209
function Node_AppendHexNative(hexrow)
203
{
210
{
204
    if (arguments.length < 1)
211
    if (arguments.length < 1)
205
    {
212
    {
206
        return "\033[31mError: Not enough parameters given.\033[0m";
213
        return "\033[31mError: Not enough parameters given.\033[0m";
207
    }
214
    }
208
 
215
 
209
    Node_HexData = Node_HexData + hexrow + "\n";
216
    Node_HexData = Node_HexData + hexrow + "\n";
210
    Node_HexNumLines += 1;
217
    Node_HexNumLines += 1;
211
 
218
 
212
    return true;
219
    return true;
213
}
220
}
214
 
221
 
215
function Node_GetProgramProgress(node_id)
222
function Node_GetProgramProgress(node_id)
216
{
223
{
217
    if (arguments.length < 1)
224
    if (arguments.length < 1)
218
    {
225
    {
219
        return "\033[31mError: Not enough parameters given.\033[0m";
226
        return "\033[31mError: Not enough parameters given.\033[0m";
220
    }
227
    }
221
   
228
   
222
    //if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData))
229
    //if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData))
223
    //{
230
    //{
224
    //    return "\033[31mError: Failed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m";
231
    //    return "\033[31mError: Failed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m";
225
    //}
232
    //}
226
 
233
 
227
    return NodeExport_GetProgramProgress(node_id);
234
    return NodeExport_GetProgramProgress(node_id);
228
}
235
}
229
 
236
 
230
function Node_ProgramNative(node_id, bios, hexnumlines)
237
function Node_ProgramNative(node_id, bios, hexnumlines)
231
{
238
{
232
    if (arguments.length < 3)
239
    if (arguments.length < 3)
233
    {
240
    {
234
        return "\033[31mError: Not enough parameters given.\033[0m";
241
        return "\033[31mError: Not enough parameters given.\033[0m";
235
    }
242
    }
236
    if (Node_HexNumLines != hexnumlines)
243
    if (Node_HexNumLines != hexnumlines)
237
    {
244
    {
238
        return "\033[31mError: Number of hex lines does not match received (" + Node_HexNumLines + " received, should be " + hexnumlines + ").\033[0m";
245
        return "\033[31mError: Number of hex lines does not match received (" + Node_HexNumLines + " received, should be " + hexnumlines + ").\033[0m";
239
    }
246
    }
240
   
247
   
241
    Node_Native_Program = false;
248
    Node_Native_Program = false;
242
    if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData))
249
    if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData))
243
    {
250
    {
244
        return "\033[31mError: Failed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m";
251
        return "\033[31mError: Failed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m";
245
    }
252
    }
246
 
253
 
247
    Node_ProgramClientId = Console_GetClientId();
-
 
248
    Node_ProgramNodeId = node_id;
254
    Node_ProgramNodeNativeId = node_id;
249
    Node_HexData = "";
255
    Node_HexData = "";
250
    Node_HexNumLines = 0;
256
    Node_HexNumLines = 0;
251
 
257
 
252
    return "Program command sent successfully";
258
    return "Program command sent successfully";
253
}
259
}
254
 
260
 
255
function Node_Program(node_id, bios, filename)
261
function Node_Program(node_id, bios, filename)
256
{
262
{
257
    if (arguments.length < 3)
263
    if (arguments.length < 3)
258
    {
264
    {
259
        Log("\033[31mNot enough parameters given.\033[0m\n");
265
        Log("\033[31mNot enough parameters given.\033[0m\n");
260
        return false;
266
        return false;
261
    }
267
    }
262
 
268
 
263
    Log("Initiating programming of " + node_id + "...\n");
269
    Log("Initiating programming of " + node_id + "...\n");
264
 
270
 
265
    if (!NodeExport_ProgramNode(node_id, bios > 0, filename))
271
    if (!NodeExport_ProgramNode(node_id, bios > 0, filename))
266
    {
272
    {
267
        Log("\033[31mFailed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m\n");
273
        Log("\033[31mFailed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m\n");
268
        return false;
274
        return false;
269
    }
275
    }
270
 
276
 
271
    Node_ProgramClientId = Console_GetClientId();
277
    Node_ProgramClientId = Console_GetClientId();
272
    Node_ProgramNodeId = node_id;
278
    Node_ProgramNodeId = node_id;
273
    Console_PreventDefaultPrompt();
279
    Console_PreventDefaultPrompt();
274
 
280
 
275
    return true;
281
    return true;
276
}
282
}
277
Console_RegisterCommand(Node_Program, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); });
283
Console_RegisterCommand(Node_Program, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); });
278
 
284
 
279
function Node_ProgramHex(node_id, bios, hexnumlines)
285
function Node_ProgramHex(node_id, bios, hexnumlines)
280
{
286
{
281
    if (arguments.length < 2)
287
    if (arguments.length < 2)
282
    {
288
    {
283
        Log("\033[31mNot enough parameters given.\033[0m\n");
289
        Log("\033[31mNot enough parameters given.\033[0m\n");
284
        return false;
290
        return false;
285
    }
291
    }
286
    if (Node_HexNumLines != hexnumlines)
292
    if (Node_HexNumLines != hexnumlines)
287
    {
293
    {
288
        Log("\033[31mNumber of hex lines does not match received (" + Node_HexNumLines + " received, should be " + hexnumlines + ").\033[0m\n");
294
        Log("\033[31mNumber of hex lines does not match received (" + Node_HexNumLines + " received, should be " + hexnumlines + ").\033[0m\n");
289
        return false;
295
        return false;
290
    }
296
    }
291
 
297
 
292
    Log("Initiating programming of " + node_id + "...\n");
298
    Log("Initiating programming of " + node_id + "...\n");
293
 
299
 
294
    if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData))
300
    if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData))
295
    {
301
    {
296
        Log("\033[31mFailed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m\n");
302
        Log("\033[31mFailed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m\n");
297
        return false;
303
        return false;
298
    }
304
    }
299
 
305
 
300
    Node_ProgramClientId = Console_GetClientId();
306
    Node_ProgramClientId = Console_GetClientId();
301
    Node_ProgramNodeId = node_id;
307
    Node_ProgramNodeId = node_id;
302
    Console_PreventDefaultPrompt();
308
    Console_PreventDefaultPrompt();
303
 
309
 
304
    Node_HexData = "";
310
    Node_HexData = "";
305
    Node_HexNumLines = 0;
311
    Node_HexNumLines = 0;
306
 
312
 
307
 
313
 
308
    return true;
314
    return true;
309
}
315
}
310
Console_RegisterCommand(Node_ProgramHex, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); });
316
Console_RegisterCommand(Node_ProgramHex, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); });
311
 
317
 
312
function Node_ClearHex()
318
function Node_ClearHex()
313
{
319
{
314
//    Log("Clearing hexdata...\n");
320
//    Log("Clearing hexdata...\n");
315
 
321
 
316
    Node_HexData = "";
322
    Node_HexData = "";
317
    Node_HexNumLines = 0;
323
    Node_HexNumLines = 0;
318
 
324
 
319
    return true;
325
    return true;
320
}
326
}
321
Console_RegisterCommand(Node_ClearHex);
327
Console_RegisterCommand(Node_ClearHex);
322
 
328
 
323
function Node_AppendHex(hexrow)
329
function Node_AppendHex(hexrow)
324
{
330
{
325
    if (arguments.length < 1)
331
    if (arguments.length < 1)
326
    {
332
    {
327
        Log("\033[31mNot enough parameters given.\033[0m\n");
333
        Log("\033[31mNot enough parameters given.\033[0m\n");
328
        return false;
334
        return false;
329
    }
335
    }
330
 
336
 
331
//    Log("Appending hexrow...\n");
337
//    Log("Appending hexrow...\n");
332
 
338
 
333
    Node_HexData = Node_HexData + hexrow + "\n";
339
    Node_HexData = Node_HexData + hexrow + "\n";
334
    Node_HexNumLines += 1;
340
    Node_HexNumLines += 1;
335
 
341
 
336
    return true;
342
    return true;
337
}
343
}
338
Console_RegisterCommand(Node_AppendHex);
344
Console_RegisterCommand(Node_AppendHex);
339
 
345
 
340
function Node_GetInformation(node_id)
346
function Node_GetInformation(node_id)
341
{
347
{
342
    if (arguments.length < 1)
348
    if (arguments.length < 1)
343
    {
349
    {
344
        Log("\033[31mNot enough parameters given.\033[0m\n");
350
        Log("\033[31mNot enough parameters given.\033[0m\n");
345
        return false;
351
        return false;
346
    }
352
    }
347
 
353
 
348
    var result = NodeExport_GetNodeInformation(node_id);
354
    var result = NodeExport_GetNodeInformation(node_id);
349
 
355
 
350
    if (!result)
356
    if (!result)
351
    {
357
    {
352
        Log("\033[31mNo node with id " + node_id + " found.\033[0m\n");
358
        Log("\033[31mNo node with id " + node_id + " found.\033[0m\n");
353
        return false;
359
        return false;
354
    }
360
    }
355
 
361
 
356
    var date = new Date(result["LastActive"] * 1000);
362
    var date = new Date(result["LastActive"] * 1000);
357
 
363
 
358
    Log("\033[96mId: \033[0;1m" + result["Id"] + "\033[0m\n");
364
    Log("\033[96mId: \033[0;1m" + result["Id"] + "\033[0m\n");
359
    Log("\033[96mValid: \033[0;1m" + result["Valid"] + "\033[0m\n");
365
    Log("\033[96mValid: \033[0;1m" + result["Valid"] + "\033[0m\n");
360
    Log("\033[96mBios Version: \033[0;1m" + result["BiosVersion"] + "\033[0m\n");
366
    Log("\033[96mBios Version: \033[0;1m" + result["BiosVersion"] + "\033[0m\n");
361
    Log("\033[96mDevice Type: \033[0;1m" + result["DeviceType"] + "\033[0m\n");
367
    Log("\033[96mDevice Type: \033[0;1m" + result["DeviceType"] + "\033[0m\n");
362
    Log("\033[96mHas Application: \033[0;1m" + result["HasApplication"] + "\033[0m\n");
368
    Log("\033[96mHas Application: \033[0;1m" + result["HasApplication"] + "\033[0m\n");
363
    Log("\033[96mLast Active: \033[0;1m" + date.toString() + "\033[0m\n");
369
    Log("\033[96mLast Active: \033[0;1m" + date.toString() + "\033[0m\n");
364
 
370
 
365
    return true;
371
    return true;
366
}
372
}
367
Console_RegisterCommand(Node_GetInformation, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); });
373
Console_RegisterCommand(Node_GetInformation, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); });
368
 
374
 
369
function Node_WaitForInformation()
375
function Node_WaitForInformation()
370
{
376
{
371
    Node_WaitClientId = Console_GetClientId();
377
    Node_WaitClientId = Console_GetClientId();
372
    Console_PreventDefaultPrompt();
378
    Console_PreventDefaultPrompt();
373
 
379
 
374
    return true;
380
    return true;
375
}
381
}
376
Console_RegisterCommand(Node_WaitForInformation);
382
Console_RegisterCommand(Node_WaitForInformation);
377
 
383