|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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? |
|
#2
|
||||
|
||||
|
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");
}
}
Code:
NumberArray outputArray = new NumberArray();
outputArray.add(double1);
outputArray.add(double2);
networkTable.putValue("array",outputArray);
|
|
#3
|
||||
|
||||
|
Re: network tables and arrays
That worked. Thanks!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|