Rev 1887 | Rev 1968 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1887 | Rev 1889 | ||
|---|---|---|---|
| 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_HexData = ""; |
10 | Node_HexData = ""; |
| 11 | 11 | ||
| 12 | function Node_OnChange(node_id, available) |
12 | function Node_OnChange(node_id, available) |
| 13 | { |
13 | { |
| 14 | if (node_id == Node_ResetNodeId && available) |
14 | if (node_id == Node_ResetNodeId && available) |
| 15 | { |
15 | { |
| 16 | Console_LogToClient(Node_ResetClientId, "\033[32m" + Node_ResetNodeId + " started okay.\033[0m\n"); |
16 | Console_LogToClient(Node_ResetClientId, "\033[32m" + Node_ResetNodeId + " started okay.\033[0m\n"); |
| 17 | Node_ResetNodeId = null; |
17 | Node_ResetNodeId = null; |
| 18 | Node_ResetClientId = null; |
18 | Node_ResetClientId = null; |
| 19 | Console_SetDefaultPrompt(); |
19 | Console_SetDefaultPrompt(); |
| 20 | } |
20 | } |
| 21 | 21 | ||
| 22 | if (node_id == Node_ProgramNodeId && available) |
22 | if (node_id == Node_ProgramNodeId && available) |
| 23 | { |
23 | { |
| 24 | Console_LogToClient(Node_ProgramClientId, "\033[32m" + Node_ProgramNodeId + " started okay.\033[0m\n"); |
24 | Console_LogToClient(Node_ProgramClientId, "\033[32m" + Node_ProgramNodeId + " started okay.\033[0m\n"); |
| 25 | Node_ProgramNodeId = null; |
25 | Node_ProgramNodeId = null; |
| 26 | Node_ProgramClientId = null; |
26 | Node_ProgramClientId = null; |
| 27 | Console_SetDefaultPrompt(); |
27 | Console_SetDefaultPrompt(); |
| 28 | } |
28 | } |
| 29 | 29 | ||
| 30 | if (Node_WaitClientId != null && available) |
30 | if (Node_WaitClientId != null && available) |
| 31 | { |
31 | { |
| 32 | var result = NodeExport_GetNodeInformation(node_id); |
32 | var result = NodeExport_GetNodeInformation(node_id); |
| 33 | 33 | ||
| 34 | if (!result) |
34 | if (!result) |
| 35 | { |
35 | { |
| 36 | Console_LogToClient(Node_WaitClientId, "\033[31mNo node with id " + node_id + " found.\033[0m\n"); |
36 | Console_LogToClient(Node_WaitClientId, "\033[31mNo node with id " + node_id + " found.\033[0m\n"); |
| 37 | return false; |
37 | return false; |
| 38 | } |
38 | } |
| 39 | 39 | ||
| 40 | var date = new Date(result["LastActive"] * 1000); |
40 | var date = new Date(result["LastActive"] * 1000); |
| 41 | 41 | ||
| 42 | Console_LogToClient(Node_WaitClientId, "Id: " + result["Id"] + "\n"); |
42 | Console_LogToClient(Node_WaitClientId, "Id: " + result["Id"] + "\n"); |
| 43 | Console_LogToClient(Node_WaitClientId, "Valid: " + result["Valid"] + "\n"); |
43 | Console_LogToClient(Node_WaitClientId, "Valid: " + result["Valid"] + "\n"); |
| 44 | Console_LogToClient(Node_WaitClientId, "Bios Version: " + result["BiosVersion"] + "\n"); |
44 | Console_LogToClient(Node_WaitClientId, "Bios Version: " + result["BiosVersion"] + "\n"); |
| 45 | Console_LogToClient(Node_WaitClientId, "Device Type: " + result["DeviceType"] + "\n"); |
45 | Console_LogToClient(Node_WaitClientId, "Device Type: " + result["DeviceType"] + "\n"); |
| 46 | Console_LogToClient(Node_WaitClientId, "Has Application: " + result["HasApplication"] + "\n"); |
46 | Console_LogToClient(Node_WaitClientId, "Has Application: " + result["HasApplication"] + "\n"); |
| 47 | Console_LogToClient(Node_WaitClientId, "Last Active: " + date.toString() + "\n"); |
47 | Console_LogToClient(Node_WaitClientId, "Last Active: " + date.toString() + "\n"); |
| 48 | 48 | ||
| 49 | Node_WaitClientId = null; |
49 | Node_WaitClientId = null; |
| 50 | Console_SetDefaultPrompt(); |
50 | Console_SetDefaultPrompt(); |
| 51 | } |
51 | } |
| 52 | } |
52 | } |
| 53 | 53 | ||
| 54 | function Node_GetAvailableIds() |
54 | function Node_GetAvailableIds() |
| 55 | { |
55 | { |
| 56 | var result_list = []; |
56 | var result_list = []; |
| 57 | var available_nodes = NodeExport_GetAvailableNodes(); |
57 | var available_nodes = NodeExport_GetAvailableNodes(); |
| 58 | 58 | ||
| 59 | for (var n in available_nodes) |
59 | for (var n in available_nodes) |
| 60 | { |
60 | { |
| 61 | var id_parts = available_nodes[n].split(",", 2); |
61 | var id_parts = available_nodes[n].split(",", 2); |
| 62 | 62 | ||
| 63 | result_list.push(id_parts[0]); |
63 | result_list.push(id_parts[0]); |
| 64 | } |
64 | } |
| 65 | 65 | ||
| 66 | return result_list; |
66 | return result_list; |
| 67 | } |
67 | } |
| 68 | 68 | ||
| 69 | function Node_ListAvailable() |
69 | function Node_ListAvailable() |
| 70 | { |
70 | { |
| 71 | var available_nodes = NodeExport_GetAvailableNodes(); |
71 | var available_nodes = NodeExport_GetAvailableNodes(); |
| 72 | 72 | ||
| 73 | var lines = [["Id", "Modules"]]; |
73 | var lines = [["Id", "Modules"]]; |
| 74 | 74 | ||
| 75 | for (var n in available_nodes) |
75 | for (var n in available_nodes) |
| 76 | { |
76 | { |
| 77 | var parts = available_nodes[n].split(","); |
77 | var parts = available_nodes[n].split(","); |
| 78 | var id = parts.shift(); |
78 | var id = parts.shift(); |
| 79 | var modules = "<none>"; |
79 | var modules = "<none>"; |
| 80 | 80 | ||
| 81 | if (parts.length > 0) |
81 | if (parts.length > 0) |
| 82 | { |
82 | { |
| 83 | modules = parts.join(", "); |
83 | modules = parts.join(", "); |
| 84 | } |
84 | } |
| 85 | 85 | ||
| 86 | lines.push([id, modules]); |
86 | lines.push([id, modules]); |
| 87 | } |
87 | } |
| 88 | 88 | ||
| 89 | var table_lines = create_table(lines); |
89 | var table_lines = create_table(lines); |
| 90 | 90 | ||
| 91 | Log("\033[29;1m" + table_lines[0] + "\033[0m\n"); |
91 | Log("\033[29;1m" + table_lines[0] + "\033[0m\n"); |
| 92 | 92 | ||
| 93 | for (var n = 1; n < table_lines.length; n++) |
93 | for (var n = 1; n < table_lines.length; n++) |
| 94 | { |
94 | { |
| 95 | Log(table_lines[n] + "\n"); |
95 | Log(table_lines[n] + "\n"); |
| 96 | } |
96 | } |
| 97 | 97 | ||
| 98 | return true; |
98 | return true; |
| 99 | } |
99 | } |
| 100 | Console_RegisterCommand(Node_ListAvailable); |
100 | Console_RegisterCommand(Node_ListAvailable); |
| 101 | 101 | ||
| 102 | function Node_Reset(node_id) |
102 | function Node_Reset(node_id) |
| 103 | { |
103 | { |
| 104 | if (arguments.length < 1) |
104 | if (arguments.length < 1) |
| 105 | { |
105 | { |
| 106 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
106 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 107 | return false; |
107 | return false; |
| 108 | } |
108 | } |
| 109 | 109 | ||
| 110 | Log("Sending reset to " + node_id + "...\n"); |
110 | Log("Sending reset to " + node_id + "...\n"); |
| 111 | 111 | ||
| 112 | if (!NodeExport_ResetNode(node_id)) |
112 | if (!NodeExport_ResetNode(node_id)) |
| 113 | { |
113 | { |
| 114 | Log("\033[31mFailed to send reset.\033[0m\n"); |
114 | Log("\033[31mFailed to send reset.\033[0m\n"); |
| 115 | return false; |
115 | return false; |
| 116 | } |
116 | } |
| 117 | 117 | ||
| 118 | Node_ProgramClientId = Console_GetClientId(); |
118 | Node_ProgramClientId = Console_GetClientId(); |
| 119 | Node_ProgramNodeId = node_id; |
119 | Node_ProgramNodeId = node_id; |
| 120 | Console_PreventDefaultPrompt(); |
120 | Console_PreventDefaultPrompt(); |
| 121 | 121 | ||
| 122 | return true; |
122 | return true; |
| 123 | } |
123 | } |
| 124 | Console_RegisterCommand(Node_Reset, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); }); |
124 | Console_RegisterCommand(Node_Reset, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); }); |
| 125 | 125 | ||
| 126 | function Node_Program(node_id, bios, filename) |
126 | function Node_Program(node_id, bios, filename) |
| 127 | { |
127 | { |
| 128 | if (arguments.length < 3) |
128 | if (arguments.length < 3) |
| 129 | { |
129 | { |
| 130 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
130 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 131 | return false; |
131 | return false; |
| 132 | } |
132 | } |
| 133 | 133 | ||
| 134 | Log("Initiating programming of " + node_id + "...\n"); |
134 | Log("Initiating programming of " + node_id + "...\n"); |
| 135 | 135 | ||
| 136 | if (!NodeExport_ProgramNode(node_id, bios > 0, filename)) |
136 | if (!NodeExport_ProgramNode(node_id, bios > 0, filename)) |
| 137 | { |
137 | { |
| 138 | Log("\033[31mFailed to start programming.\033[0m\n"); |
138 | Log("\033[31mFailed to start programming.\033[0m\n"); |
| 139 | return false; |
139 | return false; |
| 140 | } |
140 | } |
| 141 | 141 | ||
| 142 | Node_ResetClientId = Console_GetClientId(); |
142 | Node_ResetClientId = Console_GetClientId(); |
| 143 | Node_ResetNodeId = node_id; |
143 | Node_ResetNodeId = node_id; |
| 144 | Console_PreventDefaultPrompt(); |
144 | Console_PreventDefaultPrompt(); |
| 145 | 145 | ||
| 146 | return true; |
146 | return true; |
| 147 | } |
147 | } |
| 148 | Console_RegisterCommand(Node_Program, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); }); |
148 | Console_RegisterCommand(Node_Program, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); }); |
| 149 | 149 | ||
| 150 | function Node_ProgramHex(node_id, bios) |
150 | function Node_ProgramHex(node_id, bios) |
| 151 | { |
151 | { |
| 152 | if (arguments.length < 2) |
152 | if (arguments.length < 2) |
| 153 | { |
153 | { |
| 154 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
154 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 155 | return false; |
155 | return false; |
| 156 | } |
156 | } |
| 157 | 157 | ||
| 158 | Log("Initiating programming of " + node_id + "...\n"); |
158 | Log("Initiating programming of " + node_id + "...\n"); |
| 159 | 159 | ||
| 160 | if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData)) |
160 | if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData)) |
| 161 | { |
161 | { |
| 162 | Log("\033[31mFailed to start programming.\033[0m\n"); |
162 | Log("\033[31mFailed to start programming.\033[0m\n"); |
| 163 | return false; |
163 | return false; |
| 164 | } |
164 | } |
| 165 | 165 | ||
| 166 | Node_ResetClientId = Console_GetClientId(); |
166 | Node_ResetClientId = Console_GetClientId(); |
| 167 | Node_ResetNodeId = node_id; |
167 | Node_ResetNodeId = node_id; |
| 168 | Console_PreventDefaultPrompt(); |
168 | Console_PreventDefaultPrompt(); |
| 169 | 169 | ||
| 170 | Node_HexData = ""; |
170 | Node_HexData = ""; |
| 171 | 171 | ||
| 172 | return true; |
172 | return true; |
| 173 | } |
173 | } |
| 174 | Console_RegisterCommand(Node_ProgramHex, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); }); |
174 | Console_RegisterCommand(Node_ProgramHex, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); }); |
| 175 | 175 | ||
| 176 | function Node_ClearHex() |
176 | function Node_ClearHex() |
| 177 | { |
177 | { |
| 178 |
|
178 | // Log("Clearing hexdata...\n"); |
| 179 | 179 | ||
| 180 | Node_HexData = ""; |
180 | Node_HexData = ""; |
| 181 | 181 | ||
| 182 | return true; |
182 | return true; |
| 183 | } |
183 | } |
| 184 | Console_RegisterCommand(Node_ClearHex); |
184 | Console_RegisterCommand(Node_ClearHex); |
| 185 | 185 | ||
| 186 | function Node_AppendHex(hexrow) |
186 | function Node_AppendHex(hexrow) |
| 187 | { |
187 | { |
| 188 | if (arguments.length < 1) |
188 | if (arguments.length < 1) |
| 189 | { |
189 | { |
| 190 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
190 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 191 | return false; |
191 | return false; |
| 192 | } |
192 | } |
| 193 | 193 | ||
| 194 |
|
194 | // Log("Appending hexrow...\n"); |
| 195 | 195 | ||
| 196 | Node_HexData = Node_HexData + hexrow + "\n"; |
196 | Node_HexData = Node_HexData + hexrow + "\n"; |
| 197 | 197 | ||
| 198 | return true; |
198 | return true; |
| 199 | } |
199 | } |
| 200 | Console_RegisterCommand(Node_AppendHex); |
200 | Console_RegisterCommand(Node_AppendHex); |
| 201 | 201 | ||
| 202 | function Node_GetInformation(node_id) |
202 | function Node_GetInformation(node_id) |
| 203 | { |
203 | { |
| 204 | if (arguments.length < 1) |
204 | if (arguments.length < 1) |
| 205 | { |
205 | { |
| 206 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
206 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 207 | return false; |
207 | return false; |
| 208 | } |
208 | } |
| 209 | 209 | ||
| 210 | var result = NodeExport_GetNodeInformation(node_id); |
210 | var result = NodeExport_GetNodeInformation(node_id); |
| 211 | 211 | ||
| 212 | if (!result) |
212 | if (!result) |
| 213 | { |
213 | { |
| 214 | Log("\033[31mNo node with id " + node_id + " found.\033[0m\n"); |
214 | Log("\033[31mNo node with id " + node_id + " found.\033[0m\n"); |
| 215 | return false; |
215 | return false; |
| 216 | } |
216 | } |
| 217 | 217 | ||
| 218 | var date = new Date(result["LastActive"] * 1000); |
218 | var date = new Date(result["LastActive"] * 1000); |
| 219 | 219 | ||
| 220 | Log("\033[96mId: \033[0;1m" + result["Id"] + "\033[0m\n"); |
220 | Log("\033[96mId: \033[0;1m" + result["Id"] + "\033[0m\n"); |
| 221 | Log("\033[96mValid: \033[0;1m" + result["Valid"] + "\033[0m\n"); |
221 | Log("\033[96mValid: \033[0;1m" + result["Valid"] + "\033[0m\n"); |
| 222 | Log("\033[96mBios Version: \033[0;1m" + result["BiosVersion"] + "\033[0m\n"); |
222 | Log("\033[96mBios Version: \033[0;1m" + result["BiosVersion"] + "\033[0m\n"); |
| 223 | Log("\033[96mDevice Type: \033[0;1m" + result["DeviceType"] + "\033[0m\n"); |
223 | Log("\033[96mDevice Type: \033[0;1m" + result["DeviceType"] + "\033[0m\n"); |
| 224 | Log("\033[96mHas Application: \033[0;1m" + result["HasApplication"] + "\033[0m\n"); |
224 | Log("\033[96mHas Application: \033[0;1m" + result["HasApplication"] + "\033[0m\n"); |
| 225 | Log("\033[96mLast Active: \033[0;1m" + date.toString() + "\033[0m\n"); |
225 | Log("\033[96mLast Active: \033[0;1m" + date.toString() + "\033[0m\n"); |
| 226 | 226 | ||
| 227 | return true; |
227 | return true; |
| 228 | } |
228 | } |
| 229 | Console_RegisterCommand(Node_GetInformation, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); }); |
229 | Console_RegisterCommand(Node_GetInformation, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); }); |
| 230 | 230 | ||
| 231 | function Node_WaitForInformation() |
231 | function Node_WaitForInformation() |
| 232 | { |
232 | { |
| 233 | Node_WaitClientId = Console_GetClientId(); |
233 | Node_WaitClientId = Console_GetClientId(); |
| 234 | Console_PreventDefaultPrompt(); |
234 | Console_PreventDefaultPrompt(); |
| 235 | 235 | ||
| 236 | return true; |
236 | return true; |
| 237 | } |
237 | } |
| 238 | Console_RegisterCommand(Node_WaitForInformation); |
238 | Console_RegisterCommand(Node_WaitForInformation); |
| 239 | 239 | ||