Next we connect to the custom namespace and call the function in Java

This namespace takes in a list of numbers and a divisor. It will divide each number by the divisor in C and then return the result in an array of fixed point (1k) decimals.

import com.neuronrobotics.sdk.common.BowlerAbstractDevice
import com.neuronrobotics.sdk.common.BowlerDatagram
import com.neuronrobotics.sdk.ui.ConnectionDialog
public class DeviceSpike extends BowlerAbstractDevice {
@Override
public void onAsyncResponse(BowlerDatagram data) {
println data
}
public double [] callTest(double divisor, Integer [] data32) throws DeviceConnectionException {
def dargs = [divisor,data32]as Object[];
Object[] ret = send("test.ns",
BowlerMethod.GET,
"test",
dargs);
int charval = (Integer)ret[0];
boolean boolVal = (Boolean)ret[1];
println "Char value should be 37:"+ charval+" \nbool value should be true: "+boolVal
return (double []) ret[2];
}
}
DeviceSpike testDev= new DeviceSpike()
if (!ConnectionDialog.getBowlerDevice(testDev)){
System.err.println("Dialog failed");
return;
}
try{
println "If device is responging ok this will say true: "+testDev.ping()
println "If device is responging ok this will say [11.0, 22.0, 33.0, 40.0, 15.666]: "+
testDev.callTest((double)3.0,[33,66,99,120,47]as Integer[]);
}catch (Exception ex){
testDev.disconnect()
throw ex;
}
testDev.disconnect()