Search in sources :

Example 51 with Command

use of org.traccar.model.Command in project traccar by tananaev.

the class BaseProtocolEncoder method encode.

@Override
protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
    if (msg instanceof Command) {
        Command command = (Command) msg;
        Object encodedCommand = encodeCommand(command);
        // Log command
        StringBuilder s = new StringBuilder();
        s.append(String.format("[%08X] ", channel.getId()));
        s.append("id: ").append(getUniqueId(command.getDeviceId())).append(", ");
        s.append("command type: ").append(command.getType()).append(" ");
        if (encodedCommand != null) {
            s.append("sent");
        } else {
            s.append("not sent");
        }
        Log.info(s.toString());
        return encodedCommand;
    }
    return msg;
}
Also used : Command(org.traccar.model.Command)

Example 52 with Command

use of org.traccar.model.Command in project traccar by tananaev.

the class CommandsManager method sendQueuedCommands.

public void sendQueuedCommands(ActiveDevice activeDevice) {
    Queue<Command> deviceQueue = deviceQueues.get(activeDevice.getDeviceId());
    if (deviceQueue != null) {
        Command command = deviceQueue.poll();
        while (command != null) {
            activeDevice.sendCommand(command);
            command = deviceQueue.poll();
        }
    }
}
Also used : Command(org.traccar.model.Command)

Aggregations

Command (org.traccar.model.Command)52 Test (org.junit.Test)49 ProtocolTest (org.traccar.ProtocolTest)49 Ignore (org.junit.Ignore)2 ArrayList (java.util.ArrayList)1 BaseProtocol (org.traccar.BaseProtocol)1 Position (org.traccar.model.Position)1