Go to Post "I have cut this piece 4 times and it is still too short!" - Betty_Krocker [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 21-03-2013, 13:08
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
network tables and arrays

have a labview robot, want to write to it's network tables from a java app on driver station. That works great, but now I want to write an array of numbers.

If I write a array of numbers to the network table from labview, Java sees it as an Object[] containing Doubles. If I try to construct the same using

networkTable.putValue ("array", new Object[] { double1, double2 } );

I get an IllegalArgumentType: Invalid Type exception.

Is what I am attempting doable?
Reply With Quote
  #2   Spotlight this post!  
Unread 21-03-2013, 15:48
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: network tables and arrays

Here's the method that's throwing the exception (from edu.wpi.first.wpilibj.networktables2.NetworkTableN ode):
Code:
	public void putValue(String name, Object value) throws IllegalArgumentException{
            if(value instanceof Double){
                    putValue(name, DefaultEntryTypes.DOUBLE, value);
            } else if (value instanceof String){
                    putValue(name, DefaultEntryTypes.STRING, value);
            } else if(value instanceof Boolean){
                    putValue(name, DefaultEntryTypes.BOOLEAN, value);
            } else if(value instanceof ComplexData){
                    putValue(name, ((ComplexData)value).getType(), value);
            } else if(value==null) {
                throw new NullPointerException("Cannot put a null value into networktables");
            } else {
                throw new IllegalArgumentException("Invalid Type");
            }
	}
NetworkTables can only contain Doubles, Strings, Booleans, and ComplexData. ComplexData is implemented by ArrayData, which is extended by BooleanArray, StringArray, and NumberArray. I think you want to use NumberArray, and as far as I can tell, you'd use it like this:
Code:
NumberArray outputArray = new NumberArray();
outputArray.add(double1);
outputArray.add(double2);
networkTable.putValue("array",outputArray);
__________________
I code stuff.
Reply With Quote
  #3   Spotlight this post!  
Unread 29-03-2013, 10:42
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: network tables and arrays

That worked. Thanks!
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 22:33.

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