Subversion Repositories HomeAutomation

Rev

Rev 2188 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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