use of com.neuronrobotics.sdk.common.BowlerAbstractCommand in project java-bowler by NeuronRobotics.
the class BowlerAbstractDeviceServerNamespace method process.
public BowlerDatagram process(BowlerDatagram data) {
Object[] dataParsed = null;
RpcEncapsulation parser = null;
for (RpcEncapsulation enc : getRpcList()) {
if (enc.getRpc().contains(data.getRPC()) && enc.getDownstreamMethod() == data.getMethod()) {
parser = enc;
}
}
if (parser == null)
return null;
dataParsed = parser.parseResponseDownstream(data);
Object[] backData = parser.getProcessor().process(dataParsed);
BowlerAbstractCommand back = parser.getCommandUpstream(backData);
return BowlerDatagramFactory.build(getAddress(), back);
}
use of com.neuronrobotics.sdk.common.BowlerAbstractCommand in project java-bowler by NeuronRobotics.
the class BowlerAbstractServer method pushAsyncPacket.
/**
* THis is the scripting interface to Bowler devices. THis allows a user to
* describe a namespace, rpc, and array or arguments to be paced into the
* packet based on the data types of the argument. The response in likewise
* unpacked into an array of objects.
*
* @param namespace
* The string of the desired namespace
* @param rpcString
* The string of the desired RPC
* @param arguments
* An array of objects corresponding to the data to be stuffed
* into the packet.
* @throws DeviceConnectionException
* If the desired RPC's are not available then this will be
* thrown
*/
public void pushAsyncPacket(int namespaceIndex, String namespace, String rpcString, Object[] arguments, BowlerDataType[] asyncArguments) {
if (arguments.length != asyncArguments.length) {
throw new RuntimeException("Arguments must match argument types exactly, your two arrays are different lengths");
}
RpcEncapsulation rpcl = new RpcEncapsulation(namespaceIndex, namespace, rpcString, BowlerMethod.ASYNCHRONOUS, asyncArguments, null, null);
BowlerAbstractCommand command = BowlerAbstractConnection.getCommand(namespace, BowlerMethod.ASYNCHRONOUS, rpcString, arguments, rpcl);
BowlerDatagram cmd = BowlerDatagramFactory.build(new MACAddress(), command);
Log.debug("Async>>" + cmd);
pushAsyncPacket(cmd);
}
Aggregations