Subversion Repositories HomeAutomation

Rev

Rev 2164 | Rev 2171 | Go to most recent revision | Show entire file | Regard 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
    {
46
        var result = NodeExport_GetNodeInformation(node_id);
54
        var result = NodeExport_GetNodeInformation(node_id);
47
        Node_Native_WaitNodeId = node_id;
55
        Node_Native_WaitNodeId = node_id;
48
 
56
 
49
        if (!result)
57
        if (!result)
50
        {
58
        {
51
            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");
52
            return false;
60
            return false;
53
        }
61
        }
54
 
62
 
55
        var date = new Date(result["LastActive"] * 1000);
63
        var date = new Date(result["LastActive"] * 1000);
56
 
64
 
57
        Console_LogToClient(Node_WaitClientId, "Id: " + result["Id"] + "\n");
65
        Console_LogToClient(Node_WaitClientId, "Id: " + result["Id"] + "\n");
58
        Console_LogToClient(Node_WaitClientId, "Valid: " + result["Valid"] + "\n");
66
        Console_LogToClient(Node_WaitClientId, "Valid: " + result["Valid"] + "\n");
59
        Console_LogToClient(Node_WaitClientId, "Bios Version: " + result["BiosVersion"] + "\n");
67
        Console_LogToClient(Node_WaitClientId, "Bios Version: " + result["BiosVersion"] + "\n");
60
        Console_LogToClient(Node_WaitClientId, "Device Type: " + result["DeviceType"] + "\n");
68
        Console_LogToClient(Node_WaitClientId, "Device Type: " + result["DeviceType"] + "\n");
61
        Console_LogToClient(Node_WaitClientId, "Has Application: " + result["HasApplication"] + "\n");
69
        Console_LogToClient(Node_WaitClientId, "Has Application: " + result["HasApplication"] + "\n");
62
        Console_LogToClient(Node_WaitClientId, "Last Active: " + date.toString() + "\n");
70
        Console_LogToClient(Node_WaitClientId, "Last Active: " + date.toString() + "\n");
63
 
71
 
64
        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
65
        Node_WaitClientId = null;
73
        Node_WaitClientId = null;
66
    }
74
    }
67
}
75
}
68
 
76
 
69
function Node_GetAvailableIds()
77
function Node_GetAvailableIds()
70
{
78
{
71
    var result_list = [];
79
    var result_list = [];
72
    var available_nodes = NodeExport_GetAvailableNodes();
80
    var available_nodes = NodeExport_GetAvailableNodes();
73
 
81
 
74
    for (var n in available_nodes)
82
    for (var n in available_nodes)
75
    {
83
    {
76
        var id_parts = available_nodes[n].split(",", 2);
84
        var id_parts = available_nodes[n].split(",", 2);
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
{
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
}