Go to Post Analyze, adjust, anticipate. Don't panic. - PayneTrain [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-02-2014, 10:03
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 330
fovea1959 will become famous soon enough
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...
Reply With Quote
  #2   Spotlight this post!  
Unread 14-02-2014, 10:25
Aero Aero is offline
consumes pizza, produces code
AKA: Ari Lotter
FRC #0865 (Warp7)
Team Role: Programmer
 
Join Date: May 2013
Rookie Year: 2013
Location: Toronto
Posts: 30
Aero is on a distinguished road
Re: How do I use NetworkTables' SubTables?

Quote:
Originally Posted by fovea1959 View Post
...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...
Awesome! We're using a custom piece of software for the client-side, as the SmartDashboard didn't really offer what we were looking for. Is there any example code for adding an ITableListener (I think that's what I want, not sure)? I can probably figure it out tonight, but I'm just wondering.
Thanks again!
Reply With Quote
  #3   Spotlight this post!  
Unread 14-02-2014, 11:06
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 330
fovea1959 will become famous soon enough
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[]) {
 for (Object o1 : (Object[]) o) {
  sb.append("\t");
  sb.append(o1.toString());
 } else {
 sb.append("\t");
 sb.append(o.toString());
}
You *could* also get the type by going back to the client.getEntryStore().getEntry(name).getType(), but I didn't need it. I did grab client.getEntryStore().getEntry(name).getSequenceN umber() so I could see if we had updates that didn't get to the client (this is from our telemetry receiver).
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:45.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi