Subversion Repositories HomeAutomation

Rev

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

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