![]() |
Can I loop through a NetworkTable?
Hey! I'm trying to get NetworkTables working, and I have a list of things I want to send to the driver station. So I'm putting values into a Subtable on the robot, and trying to read them on the DS.
Is there a way to loop through every value in an ITable (which NetworkTables extends)? I assume there is, because the TableViewer program can do it (I compiled it but can't figure it out) Here's the code I use for putting the info into the NetworkTable. Code:
public void sendSubsystemInfo() { |
Re: How do I use NetworkTables' SubTables?
The TableViewer application does not use NetworkTable objects exclusively, there's quite a bit of back-end.
You know the names of your subsystems; is there a reason you can't just use ITable.getBoolean("NAME_HERE")? |
Re: How do I use NetworkTables' SubTables?
Quote:
|
Re: How do I use NetworkTables' SubTables?
Once you connect, you can call NetworkTableClient.getEntryStore().list() to get a list of all the existing key names in your client's copy of the table.
A listener will give you updated keys and values as they come in, so even if you don't get all the existing key names when you first connect, you'll be able to build a complete list of keys pretty quickly if you are sending them out in periodic(). |
Re: How do I use NetworkTables' SubTables?
I just reread your post, and something hit me...
Where are you trying to see what values are in the table? The FRC Driver Station software, the dashboard, or another team-written program running on the driver station PC? |
Re: How do I use NetworkTables' SubTables?
...and I just checked, and dumping the keys at the beginning is unnecessary. When you connect, it appears you get update events for every existing value in the table, so you can just set up a listener and watch the names and values stream in...
|
Re: How do I use NetworkTables' SubTables?
Quote:
Thanks again! |
Re: How do I use NetworkTables' SubTables?
super straightforward: I implemented ITableListener, then called networkTableClient.addTableListener (this, true).
If you need to see connections and disconnections, implement IRemoteConnectionListener, and call networkTableClient.addTableListener(this,true). of course, you can have different objects for your listener (so you wouldn't use this), but hopefully you'll get the gist of it. your valueChanged() can be a little tricky: you could get back an array or just a single variable of unknown type, and you don't know ahead of time what it will be. I had a few instance operators in there to sort stuff out. For display purposes, this worked nice: Code:
if (o instanceof Object[]) { |
| All times are GMT -5. The time now is 11:45. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi