Rev 2083 | Rev 2162 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2083 | Rev 2160 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 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 | ||
| - | 10 | Node_Native_Reset = false; |
|
| - | 11 | Node_Native_Program = false; |
|
| - | 12 | //Node_Native_WaitNodeId = null; |
|
| 9 | 13 | ||
| 10 | Node_HexData = ""; |
14 | Node_HexData = ""; |
| 11 | Node_HexNumLines = 0; |
15 | Node_HexNumLines = 0; |
| 12 | 16 | ||
| 13 | function Node_OnChange(node_id, available) |
17 | function Node_OnChange(node_id, available) |
| 14 | { |
18 | { |
| - | 19 | Log("Node_OnChange "+Node_ResetNodeId+" "+Node_ProgramNodeId+" "+node_id+" "+available+"\n"); |
|
| 15 | if (node_id == Node_ResetNodeId && available) |
20 | if (node_id == Node_ResetNodeId && available) |
| 16 | { |
21 | { |
| - | 22 | Log("ResetNodeId "+Node_Native_Reset+"\n"); |
|
| 17 | Console_LogToClient(Node_ResetClientId, "\033[32m" + Node_ResetNodeId + " started okay.\033[0m\n"); |
23 | Console_LogToClient(Node_ResetClientId, "\033[32m" + Node_ResetNodeId + " started okay.\033[0m\n"); |
| 18 | 24 | ||
| 19 | Console_NewConnection(Node_ResetClientId); // This is a ugly hack for a bad design for multiusers |
25 | Console_NewConnection(Node_ResetClientId); // This is a ugly hack for a bad design for multiusers |
| 20 | Node_ResetNodeId = null; |
26 | Node_ResetNodeId = null; |
| 21 | Node_ResetClientId = null; |
27 | Node_ResetClientId = null; |
| - | 28 | ||
| - | 29 | Node_Native_Reset = true; |
|
| 22 | } |
30 | } |
| 23 | 31 | ||
| 24 | if (node_id == Node_ProgramNodeId && available) |
32 | if (node_id == Node_ProgramNodeId && available) |
| 25 | { |
33 | { |
| - | 34 | Log("ProgramNodeId "+Node_Native_Program+"\n"); |
|
| 26 | Console_LogToClient(Node_ProgramClientId, "\033[32m" + Node_ProgramNodeId + " started okay.\033[0m\n"); |
35 | Console_LogToClient(Node_ProgramClientId, "\033[32m" + Node_ProgramNodeId + " started okay.\033[0m\n"); |
| 27 | 36 | ||
| 28 | Console_NewConnection(Node_ProgramClientId); // This is a ugly hack for a bad design for multiusers |
37 | Console_NewConnection(Node_ProgramClientId); // This is a ugly hack for a bad design for multiusers |
| 29 | Node_ProgramNodeId = null; |
38 | Node_ProgramNodeId = null; |
| 30 | Node_ProgramClientId = null; |
39 | Node_ProgramClientId = null; |
| - | 40 | ||
| - | 41 | Node_Native_Program = true; |
|
| 31 | } |
42 | } |
| 32 | 43 | ||
| 33 | if (Node_WaitClientId != null && available) |
44 | if (Node_WaitClientId != null && available) |
| 34 | { |
45 | { |
| 35 | var result = NodeExport_GetNodeInformation(node_id); |
46 | var result = NodeExport_GetNodeInformation(node_id); |
| Line 49... | Line 60... | ||
| 49 | Console_LogToClient(Node_WaitClientId, "Has Application: " + result["HasApplication"] + "\n"); |
60 | Console_LogToClient(Node_WaitClientId, "Has Application: " + result["HasApplication"] + "\n"); |
| 50 | Console_LogToClient(Node_WaitClientId, "Last Active: " + date.toString() + "\n"); |
61 | Console_LogToClient(Node_WaitClientId, "Last Active: " + date.toString() + "\n"); |
| 51 | 62 | ||
| 52 | Console_NewConnection(Node_WaitClientId); // This is a ugly hack for a bad design for multiusers |
63 | Console_NewConnection(Node_WaitClientId); // This is a ugly hack for a bad design for multiusers |
| 53 | Node_WaitClientId = null; |
64 | Node_WaitClientId = null; |
| 54 | } |
65 | } |
| 55 | } |
66 | } |
| 56 | 67 | ||
| 57 | function Node_GetAvailableIds() |
68 | function Node_GetAvailableIds() |
| 58 | { |
69 | { |
| 59 | var result_list = []; |
70 | var result_list = []; |
| 60 | var available_nodes = NodeExport_GetAvailableNodes(); |
71 | var available_nodes = NodeExport_GetAvailableNodes(); |
| 61 | 72 | ||
| 62 | for (var n in available_nodes) |
73 | for (var n in available_nodes) |
| 63 | { |
74 | { |
| 64 | var id_parts = available_nodes[n].split(",", 2); |
75 | var id_parts = available_nodes[n].split(",", 2); |
| 65 | 76 | ||
| 66 | result_list.push(id_parts[0]); |
77 | result_list.push(id_parts[0]); |
| 67 | } |
78 | } |
| 68 | 79 | ||
| 69 | return result_list; |
80 | return result_list; |
| 70 | } |
81 | } |
| 71 | 82 | ||
| 72 | function Node_ListAvailable() |
83 | function Node_ListAvailable() |
| 73 | { |
84 | { |
| Line 99... | Line 110... | ||
| 99 | } |
110 | } |
| 100 | 111 | ||
| 101 | return true; |
112 | return true; |
| 102 | } |
113 | } |
| 103 | Console_RegisterCommand(Node_ListAvailable); |
114 | Console_RegisterCommand(Node_ListAvailable); |
| - | 115 | ||
| - | 116 | function Node_ResetPollNative() |
|
| - | 117 | { |
|
| - | 118 | return Node_Native_Reset; |
|
| - | 119 | } |
|
| - | 120 | ||
| - | 121 | function Node_ResetNative(node_id) |
|
| - | 122 | { |
|
| - | 123 | if (arguments.length < 1) |
|
| - | 124 | { |
|
| - | 125 | return "\033[31mError: Not enough parameters given.\033[0m"; |
|
| - | 126 | } |
|
| - | 127 | ||
| - | 128 | Node_Native_Reset = false; |
|
| - | 129 | if (!NodeExport_ResetNode(node_id)) |
|
| - | 130 | { |
|
| - | 131 | 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"; |
|
| - | 132 | } |
|
| - | 133 | ||
| - | 134 | Node_ResetClientId = Console_GetClientId(); |
|
| - | 135 | Node_ResetNodeId = node_id; |
|
| - | 136 | ||
| - | 137 | return "Reset command sent successfully"; |
|
| - | 138 | } |
|
| 104 | 139 | ||
| 105 | function Node_Reset(node_id) |
140 | function Node_Reset(node_id) |
| 106 | { |
141 | { |
| 107 | if (arguments.length < 1) |
142 | if (arguments.length < 1) |
| 108 | { |
143 | { |
| 109 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
144 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 110 | return false; |
145 | return false; |
| 111 | } |
146 | } |
| 112 | 147 | ||
| 113 | Log("Sending reset to " + node_id + "...\n"); |
148 | Log("Sending reset to " + node_id + "...\n"); |
| 114 | 149 | ||
| 115 | if (!NodeExport_ResetNode(node_id)) |
150 | if (!NodeExport_ResetNode(node_id)) |
| 116 | { |
151 | { |
| 117 | Log("\033[31mFailed to send |
152 | 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"); |
| 118 | return false; |
153 | return false; |
| 119 | } |
154 | } |
| 120 | 155 | ||
| 121 |
|
156 | Node_ResetClientId = Console_GetClientId(); |
| 122 |
|
157 | Node_ResetNodeId = node_id; |
| 123 | Console_PreventDefaultPrompt(); |
158 | Console_PreventDefaultPrompt(); |
| 124 | 159 | ||
| 125 | return true; |
160 | return true; |
| 126 | } |
161 | } |
| 127 | Console_RegisterCommand(Node_Reset, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); }); |
162 | Console_RegisterCommand(Node_Reset, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); }); |
| - | 163 | ||
| - | 164 | function Node_ProgramPollNative() |
|
| - | 165 | { |
|
| - | 166 | return Node_Native_Program; |
|
| - | 167 | } |
|
| - | 168 | ||
| - | 169 | function Node_AppendHexNative(hexrow) |
|
| - | 170 | { |
|
| - | 171 | if (arguments.length < 1) |
|
| - | 172 | { |
|
| - | 173 | return "\033[31mError: Not enough parameters given.\033[0m"; |
|
| - | 174 | } |
|
| - | 175 | ||
| - | 176 | Node_HexData = Node_HexData + hexrow + "\n"; |
|
| - | 177 | Node_HexNumLines += 1; |
|
| - | 178 | ||
| - | 179 | return true; |
|
| - | 180 | } |
|
| - | 181 | ||
| - | 182 | function Node_ProgramNative(node_id, bios, hexnumlines) |
|
| - | 183 | { |
|
| - | 184 | if (arguments.length < 3) |
|
| - | 185 | { |
|
| - | 186 | return "\033[31mError: Not enough parameters given.\033[0m"; |
|
| - | 187 | } |
|
| - | 188 | if (Node_HexNumLines != hexnumlines) |
|
| - | 189 | { |
|
| - | 190 | return "\033[31mError: Number of hex lines does not match received (" + Node_HexNumLines + " received, should be " + hexnumlines + ").\033[0m"; |
|
| - | 191 | } |
|
| - | 192 | ||
| - | 193 | Node_Native_Program = false; |
|
| - | 194 | if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData)) |
|
| - | 195 | { |
|
| - | 196 | 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"; |
|
| - | 197 | } |
|
| - | 198 | ||
| - | 199 | Node_ProgramClientId = Console_GetClientId(); |
|
| - | 200 | Node_ProgramNodeId = node_id; |
|
| - | 201 | Node_HexData = ""; |
|
| - | 202 | Node_HexNumLines = 0; |
|
| - | 203 | ||
| - | 204 | return "Program command sent successfully"; |
|
| - | 205 | } |
|
| 128 | 206 | ||
| 129 | function Node_Program(node_id, bios, filename) |
207 | function Node_Program(node_id, bios, filename) |
| 130 | { |
208 | { |
| 131 | if (arguments.length < 3) |
209 | if (arguments.length < 3) |
| 132 | { |
210 | { |
| Line 136... | Line 214... | ||
| 136 | 214 | ||
| 137 | Log("Initiating programming of " + node_id + "...\n"); |
215 | Log("Initiating programming of " + node_id + "...\n"); |
| 138 | 216 | ||
| 139 | if (!NodeExport_ProgramNode(node_id, bios > 0, filename)) |
217 | if (!NodeExport_ProgramNode(node_id, bios > 0, filename)) |
| 140 | { |
218 | { |
| 141 | Log("\033[31mFailed to start |
219 | 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"); |
| 142 | return false; |
220 | return false; |
| 143 | } |
221 | } |
| 144 | 222 | ||
| 145 |
|
223 | Node_ProgramClientId = Console_GetClientId(); |
| 146 |
|
224 | Node_ProgramNodeId = node_id; |
| 147 | Console_PreventDefaultPrompt(); |
225 | Console_PreventDefaultPrompt(); |
| 148 | 226 | ||
| 149 | return true; |
227 | return true; |
| 150 | } |
228 | } |
| 151 | Console_RegisterCommand(Node_Program, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); }); |
229 | Console_RegisterCommand(Node_Program, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); }); |
| Line 165... | Line 243... | ||
| 165 | 243 | ||
| 166 | Log("Initiating programming of " + node_id + "...\n"); |
244 | Log("Initiating programming of " + node_id + "...\n"); |
| 167 | 245 | ||
| 168 | if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData)) |
246 | if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData)) |
| 169 | { |
247 | { |
| 170 | Log("\033[31mFailed to start |
248 | 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"); |
| 171 | return false; |
249 | return false; |
| 172 | } |
250 | } |
| 173 | 251 | ||
| 174 |
|
252 | Node_ProgramClientId = Console_GetClientId(); |
| 175 |
|
253 | Node_ProgramNodeId = node_id; |
| 176 | Console_PreventDefaultPrompt(); |
254 | Console_PreventDefaultPrompt(); |
| 177 | 255 | ||
| 178 | Node_HexData = ""; |
256 | Node_HexData = ""; |
| 179 | Node_HexNumLines = 0; |
257 | Node_HexNumLines = 0; |
| 180 | 258 | ||