Subversion Repositories HomeAutomation

Rev

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

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