View Single Post
  #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