Search in sources :

Example 31 with Command

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

the class WatchProtocolEncoderTest method testEncode.

@Test
public void testEncode() throws Exception {
    WatchProtocolEncoder encoder = new WatchProtocolEncoder();
    Command command;
    command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_REBOOT_DEVICE);
    assertEquals("[CS*123456789012345*0005*RESET]", encoder.encodeCommand(command));
    command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_SOS_NUMBER);
    command.set(Command.KEY_INDEX, 1);
    command.set(Command.KEY_PHONE, "123456789");
    assertEquals("[CS*123456789012345*000e*SOS1,123456789]", encoder.encodeCommand(command));
    command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_VOICE_MESSAGE);
    command.set(Command.KEY_DATA, "3333");
    assertEquals("[CS*123456789012345*0005*TK,33]", encoder.encodeCommand(command));
    command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_CUSTOM);
    command.set(Command.KEY_DATA, "WORK,6-9,11-13,13-15,17-19");
    assertEquals("[CS*123456789012345*001a*WORK,6-9,11-13,13-15,17-19]", encoder.encodeCommand(command));
    command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_SET_TIMEZONE);
    command.set(Command.KEY_TIMEZONE, "Europe/Amsterdam");
    assertEquals("[CS*123456789012345*0006*LZ,,+1]", encoder.encodeCommand(command));
    command.set(Command.KEY_TIMEZONE, "GMT+01:30");
    assertEquals("[CS*123456789012345*0008*LZ,,+1.5]", encoder.encodeCommand(command));
    command.set(Command.KEY_TIMEZONE, "Atlantic/Azores");
    assertEquals("[CS*123456789012345*0006*LZ,,-1]", encoder.encodeCommand(command));
    command.set(Command.KEY_TIMEZONE, "GMT-11:30");
    assertEquals("[CS*123456789012345*0009*LZ,,-11.5]", encoder.encodeCommand(command));
}
Also used : Command(org.traccar.model.Command) ProtocolTest(org.traccar.ProtocolTest) Test(org.junit.Test)

Example 32 with Command

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

the class WondexProtocolEncoderTest method testEncode.

@Test
public void testEncode() throws Exception {
    WondexProtocolEncoder encoder = new WondexProtocolEncoder();
    Command command = new Command();
    command.setDeviceId(2);
    command.setType(Command.TYPE_POSITION_SINGLE);
    command.set(Command.KEY_DEVICE_PASSWORD, "0000");
    assertEquals("$WP+GETLOCATION=0000", encoder.encodeCommand(command));
}
Also used : Command(org.traccar.model.Command) ProtocolTest(org.traccar.ProtocolTest) Test(org.junit.Test)

Example 33 with Command

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

the class XirgoProtocolEncoderTest method testEncode.

@Test
public void testEncode() throws Exception {
    XirgoProtocolEncoder encoder = new XirgoProtocolEncoder();
    Command command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_OUTPUT_CONTROL);
    command.set(Command.KEY_INDEX, 0);
    command.set(Command.KEY_DATA, 1);
    assertEquals("+XT:7005,2,1", encoder.encodeCommand(command));
}
Also used : Command(org.traccar.model.Command) ProtocolTest(org.traccar.ProtocolTest) Test(org.junit.Test)

Example 34 with Command

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

the class Pt502ProtocolEncoderTest method testEncodeTimezone.

@Test
public void testEncodeTimezone() throws Exception {
    Pt502ProtocolEncoder encoder = new Pt502ProtocolEncoder();
    Command command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_SET_TIMEZONE);
    command.set(Command.KEY_TIMEZONE, "GMT+8");
    assertEquals("#TMZ8\r\n", encoder.encodeCommand(command));
}
Also used : Command(org.traccar.model.Command) ProtocolTest(org.traccar.ProtocolTest) Test(org.junit.Test)

Example 35 with Command

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

the class Pt502ProtocolEncoderTest method testEncodeCustom.

@Test
public void testEncodeCustom() throws Exception {
    Pt502ProtocolEncoder encoder = new Pt502ProtocolEncoder();
    Command command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_CUSTOM);
    command.set(Command.KEY_DATA, "#PTI300");
    assertEquals("#PTI300\r\n", encoder.encodeCommand(command));
}
Also used : Command(org.traccar.model.Command) ProtocolTest(org.traccar.ProtocolTest) Test(org.junit.Test)

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