Search in sources :

Example 21 with BowlerDatagram

use of com.neuronrobotics.sdk.common.BowlerDatagram in project java-bowler by NeuronRobotics.

the class BowlerCamDevice method getImageServerURL.

public String getImageServerURL(int chan) {
    // Log.info("Requesting image server URL");
    while (urls.size() < (chan + 1) && isAvailable()) {
        urls.add(null);
    }
    if (urls.get(chan) != null)
        return urls.get(chan);
    BowlerDatagram b = send(new ImageURLCommand(chan));
    urls.set(chan, b.getData().asString());
    return urls.get(chan);
}
Also used : BowlerDatagram(com.neuronrobotics.sdk.common.BowlerDatagram) ImageURLCommand(com.neuronrobotics.sdk.commands.neuronrobotics.bowlercam.ImageURLCommand)

Example 22 with BowlerDatagram

use of com.neuronrobotics.sdk.common.BowlerDatagram in project java-bowler by NeuronRobotics.

the class BowlerAbstractDeviceServer method sendSyncResponse.

/**
 * Send a sendable to the getConnection().
 *
 * @param sendable the sendable without expecting a response
 * @throws IOException
 */
public void sendSyncResponse(BowlerAbstractCommand command) throws IOException {
    BowlerDatagram bd = BowlerDatagramFactory.build(getAddress(), command);
    // Log.debug("RESP>>\n"+bd.toString());
    getConnection().sendAsync(bd);
    getConnection().getDataOuts().flush();
}
Also used : BowlerDatagram(com.neuronrobotics.sdk.common.BowlerDatagram)

Example 23 with BowlerDatagram

use of com.neuronrobotics.sdk.common.BowlerDatagram in project java-bowler by NeuronRobotics.

the class BowlerAbstractServer method processLocal.

private BowlerDatagram processLocal(BowlerDatagram data) {
    setup();
    if (getNamespaces().size() == 0) {
        throw new RuntimeException("No namespaces defined");
    }
    for (BowlerAbstractDeviceServerNamespace n : getNamespaces()) {
        // System.out.println("Checking "+n.getNamespaces().get(0));
        if (n.checkRpc(data)) {
            BowlerDatagram d = n.process(data);
            if (d != null) {
                if (!d.getRPC().contains("_err"))
                    return d;
            }
        }
    }
    Log.error("No namespace found for " + data);
    return null;
}
Also used : BowlerDatagram(com.neuronrobotics.sdk.common.BowlerDatagram)

Example 24 with BowlerDatagram

use of com.neuronrobotics.sdk.common.BowlerDatagram 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);
}
Also used : MACAddress(com.neuronrobotics.sdk.common.MACAddress) BowlerDatagram(com.neuronrobotics.sdk.common.BowlerDatagram) BowlerAbstractCommand(com.neuronrobotics.sdk.common.BowlerAbstractCommand) RpcEncapsulation(com.neuronrobotics.sdk.common.RpcEncapsulation)

Example 25 with BowlerDatagram

use of com.neuronrobotics.sdk.common.BowlerDatagram in project java-bowler by NeuronRobotics.

the class LegacyPidNamespaceImp method getPIDChannelCount.

@Override
public int getPIDChannelCount() {
    if (getChannelCount() == null) {
        BowlerDatagram dg = getDevice().send(new GetPIDChannelCountCommand());
        setChannelCount(ByteList.convertToInt(dg.getData().getBytes(0, 4)));
    }
    return getChannelCount();
}
Also used : BowlerDatagram(com.neuronrobotics.sdk.common.BowlerDatagram) GetPIDChannelCountCommand(com.neuronrobotics.sdk.commands.bcs.pid.GetPIDChannelCountCommand)

Aggregations

BowlerDatagram (com.neuronrobotics.sdk.common.BowlerDatagram)31 ByteList (com.neuronrobotics.sdk.common.ByteList)9 MACAddress (com.neuronrobotics.sdk.common.MACAddress)5 IOException (java.io.IOException)5 InvalidResponseException (com.neuronrobotics.sdk.common.InvalidResponseException)4 ArrayList (java.util.ArrayList)4 PingCommand (com.neuronrobotics.sdk.commands.bcs.core.PingCommand)3 GetChannelModeCommand (com.neuronrobotics.sdk.commands.bcs.io.GetChannelModeCommand)2 GetValueCommand (com.neuronrobotics.sdk.commands.bcs.io.GetValueCommand)2 InvalidConnectionException (com.neuronrobotics.sdk.common.InvalidConnectionException)2 RpcEncapsulation (com.neuronrobotics.sdk.common.RpcEncapsulation)2 PIDCommandException (com.neuronrobotics.sdk.pid.PIDCommandException)2 SocketException (java.net.SocketException)2 Test (org.junit.Test)2 GetChannelModeListCommand (com.neuronrobotics.sdk.commands.bcs.io.GetChannelModeListCommand)1 GetDyIOChannelCountCommand (com.neuronrobotics.sdk.commands.bcs.io.GetDyIOChannelCountCommand)1 SetChannelModeCommand (com.neuronrobotics.sdk.commands.bcs.io.setmode.SetChannelModeCommand)1 ConfigurePIDCommand (com.neuronrobotics.sdk.commands.bcs.pid.ConfigurePIDCommand)1 ControlAllPIDCommand (com.neuronrobotics.sdk.commands.bcs.pid.ControlAllPIDCommand)1 ConfigureDynamicPIDCommand (com.neuronrobotics.sdk.commands.bcs.pid.DyPID.ConfigureDynamicPIDCommand)1