Skip to content

Commit

Permalink
Add device states to node information on boot
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanzemlin committed Mar 12, 2024
1 parent bae35e6 commit a62432f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion autonav_ws/src/autonav_display/src/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,13 @@ async def consumer(self, websocket):
nodes = self.get_node_names()
for i in range(len(nodes)):
nodes[i] = nodes[i].replace("/", "")
node_states = {}
for identifier in nodes:
node_states[identifier] = self.device_states[identifier] if identifier in self.device_states else 0
self.pushSendQueue(json.dumps({
"op": "get_nodes_callback",
"nodes": nodes
"nodes": nodes,
"states": node_states
}), unique_id)

if obj["op"] == "set_system_state":
Expand Down
11 changes: 11 additions & 0 deletions display/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ $(document).ready(function () {
opcode: 4,
iterator: iterate()
});

const statemap = obj.states;
if (node in statemap) {
deviceStates[node] = statemap[node];
unorderedListElement = $("#element_device_states");
unorderedListElement.empty();
for (const id in deviceStates) {
const state = deviceStates[id];
unorderedListElement.append(`<h5>${id}: <span data-state=\"${state}\">${deviceStateToName(state)}</span></h5>`);
}
}
}
}
}
Expand Down

0 comments on commit a62432f

Please sign in to comment.