use of org.traccar.model.Command in project traccar by tananaev.
the class CommandsManager method getSupportedCommands.
public Collection<Long> getSupportedCommands(long deviceId) {
List<Long> result = new ArrayList<>();
Position lastPosition = Context.getIdentityManager().getLastPosition(deviceId);
for (long commandId : getAllDeviceItems(deviceId)) {
Command command = getById(commandId);
if (lastPosition != null) {
BaseProtocol protocol = Context.getServerManager().getProtocol(lastPosition.getProtocol());
if (command.getTextChannel() && protocol.getSupportedTextCommands().contains(command.getType()) || !command.getTextChannel() && protocol.getSupportedDataCommands().contains(command.getType())) {
result.add(commandId);
}
} else if (command.getType().equals(Command.TYPE_CUSTOM)) {
result.add(commandId);
}
}
return result;
}
use of org.traccar.model.Command in project traccar by tananaev.
the class AdmProtocolEncoderTest method testEncode.
@Test
public void testEncode() throws Exception {
AdmProtocolEncoder encoder = new AdmProtocolEncoder();
Command command = new Command();
command.setDeviceId(1);
command.setType(Command.TYPE_GET_DEVICE_STATUS);
assertEquals("STATUS\r\n", encoder.encodeCommand(command));
command = new Command();
command.setDeviceId(1);
command.setType(Command.TYPE_CUSTOM);
command.set(Command.KEY_DATA, "INPUT 0");
assertEquals("INPUT 0\r\n", encoder.encodeCommand(command));
}
use of org.traccar.model.Command in project traccar by tananaev.
the class CastelProtocolEncoderTest method testEncode.
@Test
public void testEncode() throws Exception {
CastelProtocolEncoder encoder = new CastelProtocolEncoder();
Command command = new Command();
command.setDeviceId(1);
command.setType(Command.TYPE_ENGINE_STOP);
verifyCommand(encoder, command, binary("40402000013132333435363738393031323334350000000000458301a94a0d0a"));
}
use of org.traccar.model.Command in project traccar by tananaev.
the class GalileoProtocolEncoderTest method testEncode.
@Test
public void testEncode() throws Exception {
GalileoProtocolEncoder encoder = new GalileoProtocolEncoder();
Command command = new Command();
command.setDeviceId(1);
command.setType(Command.TYPE_CUSTOM);
command.set(Command.KEY_DATA, "status");
verifyCommand(encoder, command, binary("01200003313233343536373839303132333435040000e000000000e1067374617475731f64"));
}
use of org.traccar.model.Command in project traccar by tananaev.
the class Gps103ProtocolEncoderTest method testEncodePositionPeriodic.
@Test
public void testEncodePositionPeriodic() throws Exception {
Gps103ProtocolEncoder encoder = new Gps103ProtocolEncoder();
Command command = new Command();
command.setDeviceId(1);
command.setType(Command.TYPE_POSITION_PERIODIC);
command.set(Command.KEY_FREQUENCY, 300);
assertEquals("**,imei:123456789012345,C,05m", encoder.encodeCommand(command));
}
Aggregations