Subversion Repositories HomeAutomation

Rev

Rev 2164 | Rev 2171 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 2164 Rev 2170
Line 5... Line 5...
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;
-
 
11
Node_ProgramNodeNativeId = null;
10
Node_Native_Reset = false;
12
Node_Native_Reset = false;
11
Node_Native_Program = false;
13
Node_Native_Program = false;
12
Node_Native_WaitNodeId = false;
14
Node_Native_WaitNodeId = false;
13
 
15
 
14
Node_HexData = "";
16
Node_HexData = "";
Line 23... Line 25...
23
        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");
24
 
26
 
25
        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
26
        Node_ResetNodeId = null;
28
        Node_ResetNodeId = null;
27
        Node_ResetClientId = null;
29
        Node_ResetClientId = null;
28
       
-
 
29
        Node_Native_Reset = true;
-
 
30
    }
30
    }
-
 
31
    if (node_id == Node_ResetNodeId && available)
-
 
32
    {
-
 
33
        Node_Native_Reset = true;
-
 
34
        Node_ResetNodeNativeId = null;
-
 
35
    }
31
 
36
 
32
    if (node_id == Node_ProgramNodeId && available)
37
    if (node_id == Node_ProgramNodeId && available)
33
    {
38
    {
34
//Log("ProgramNodeId "+Node_Native_Program+"\n");
39
//Log("ProgramNodeId "+Node_Native_Program+"\n");
35
        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");
36
 
41
 
37
        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
38
        Node_ProgramNodeId = null;
43
        Node_ProgramNodeId = null;
39
        Node_ProgramClientId = null;
44
        Node_ProgramClientId = null;
-
 
45
    }
-
 
46
    if (node_id == Node_ProgramNodeId && available)
40
       
47
    {
-
 
48
        Node_ProgramNodeNativeId = null;
41
        Node_Native_Program = true;
49
        Node_Native_Program = true;
42
    }
50
    }
43
 
51
 
44
    if (Node_WaitClientId != null && available)
52
    if (Node_WaitClientId != null && available)
45
    {
53
    {
Line 77... Line 85...
77
 
85
 
78
        result_list.push(id_parts[0]);
86
        result_list.push(id_parts[0]);
79
    }
87
    }
80
 
88
 
81
    return result_list;
89
    return result_list;
82
}
90
}
83
 
91
 
84
function Node_ListAvailable()
92
function Node_ListAvailable()
85
{
93
{
86
    var available_nodes = NodeExport_GetAvailableNodes();
94
    var available_nodes = NodeExport_GetAvailableNodes();
87
 
95
 
88
    var lines = [["Id", "Modules"]];
96
    var lines = [["Id", "Modules"]];
89
 
97
 
90
    for (var n in available_nodes)
98
    for (var n in available_nodes)
91
    {
99
    {
92
        var parts = available_nodes[n].split(",");
100
        var parts = available_nodes[n].split(",");
93
        var id = parts.shift();
101
        var id = parts.shift();
94
        var modules = "<none>";
102
        var modules = "<none>";
95
 
103
 
96
        if (parts.length > 0)
104
        if (parts.length > 0)
97
        {
105
        {
98
            modules = parts.join(", ");
106
            modules = parts.join(", ");
99
        }
107
        }
100
 
108
 
101
        lines.push([id, modules]);
109
        lines.push([id, modules]);
102
    }
110
    }
103
 
111
 
104
    var table_lines = create_table(lines);
112
    var table_lines = create_table(lines);
105
 
113
 
106
    Log("\033[29;1m" + table_lines[0] + "\033[0m\n");
114
    Log("\033[29;1m" + table_lines[0] + "\033[0m\n");
107
 
115
 
108
    for (var n = 1; n < table_lines.length; n++)
116
    for (var n = 1; n < table_lines.length; n++)
109
    {
117
    {
Line 111... Line 119...
111
    }
119
    }
112
 
120
 
113
    return true;
121
    return true;
114
}
122
}
115
Console_RegisterCommand(Node_ListAvailable);
123
Console_RegisterCommand(Node_ListAvailable);
116
 
124
 
117
function Node_WaitNodePollNative()
125
function Node_WaitNodePollNative()
118
{
126
{
119
    if (Node_Native_WaitNodeId)
127
    if (Node_Native_WaitNodeId)
120
    {
128
    {
121
        var result = NodeExport_GetNodeInformation(Node_Native_WaitNodeId);
129
        var result = NodeExport_GetNodeInformation(Node_Native_WaitNodeId);
Line 162... Line 170...
162
    if (!NodeExport_ResetNode(node_id))
170
    if (!NodeExport_ResetNode(node_id))
163
    {
171
    {
164
        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";
165
    }
173
    }
166
 
174
 
167
    Node_ResetClientId = Console_GetClientId();
-
 
168
    Node_ResetNodeId = node_id;
175
    Node_ResetNodeNativeId = node_id;
169
 
176
 
170
    return "Reset command sent successfully";
177
    return "Reset command sent successfully";
171
}
178
}
172
 
179
 
173
function Node_Reset(node_id)
180
function Node_Reset(node_id)
Line 242... Line 249...
242
    if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData))
249
    if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData))
243
    {
250
    {
244
        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";
245
    }
252
    }
246
 
253
 
247
    Node_ProgramClientId = Console_GetClientId();
-
 
248
    Node_ProgramNodeId = node_id;
254
    Node_ProgramNodeNativeId = node_id;
249
    Node_HexData = "";
255
    Node_HexData = "";
250
    Node_HexNumLines = 0;
256
    Node_HexNumLines = 0;
251
 
257
 
252
    return "Program command sent successfully";
258
    return "Program command sent successfully";
253
}
259
}