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;
}
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();
}
}
}
Aggregations