Search in sources :

Example 61 with Command

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

the class Tk103ProtocolEncoderTest method testEncodeRebootDeviceAlternative.

@Test
public void testEncodeRebootDeviceAlternative() {
    var encoder = new Tk103ProtocolEncoder(null, true);
    Command command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_REBOOT_DEVICE);
    assertEquals("[begin]sms2,88888888,[end]", encoder.encodeCommand(command));
}
Also used : Command(org.traccar.model.Command) ProtocolTest(org.traccar.ProtocolTest) Test(org.junit.Test)

Example 62 with Command

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

the class Tk103ProtocolEncoderTest method testEncodePositionStop.

@Test
public void testEncodePositionStop() {
    var encoder = new Tk103ProtocolEncoder(null);
    Command command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_POSITION_STOP);
    assertEquals("(123456789012345AR0000000000)", encoder.encodeCommand(command));
}
Also used : Command(org.traccar.model.Command) ProtocolTest(org.traccar.ProtocolTest) Test(org.junit.Test)

Example 63 with Command

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

the class PretraceProtocolEncoderTest method testEncodeCustom.

@Test
public void testEncodeCustom() throws Exception {
    var encoder = new PretraceProtocolEncoder(null);
    Command command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_CUSTOM);
    command.set(Command.KEY_DATA, "D21012");
    assertEquals("(123456789012345D21012^44)", encoder.encodeCommand(command));
}
Also used : Command(org.traccar.model.Command) ProtocolTest(org.traccar.ProtocolTest) Test(org.junit.Test)

Example 64 with Command

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

the class Pt502ProtocolEncoderTest method testEncodeOutputControl.

@Test
public void testEncodeOutputControl() throws Exception {
    var encoder = new Pt502ProtocolEncoder(null);
    Command command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_OUTPUT_CONTROL);
    command.set(Command.KEY_INDEX, 2);
    command.set(Command.KEY_DATA, "1");
    assertEquals("#OPC2,1\r\n", encoder.encodeCommand(command));
}
Also used : Command(org.traccar.model.Command) ProtocolTest(org.traccar.ProtocolTest) Test(org.junit.Test)

Example 65 with Command

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

the class Pt502ProtocolEncoderTest method testEncodeAlarmSpeed.

@Test
public void testEncodeAlarmSpeed() throws Exception {
    var encoder = new Pt502ProtocolEncoder(null);
    Command command = new Command();
    command.setDeviceId(1);
    command.setType(Command.TYPE_ALARM_SPEED);
    command.set(Command.KEY_DATA, 120);
    assertEquals("#SPD120\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)129 Test (org.junit.Test)120 ProtocolTest (org.traccar.ProtocolTest)120 Ignore (org.junit.Ignore)4 ArrayList (java.util.ArrayList)3 Position (org.traccar.model.Position)3 BaseProtocol (org.traccar.BaseProtocol)2 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)1 QueryStringDecoder (io.netty.handler.codec.http.QueryStringDecoder)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 DeviceSession (org.traccar.DeviceSession)1 CommandsManager (org.traccar.database.CommandsManager)1 Network (org.traccar.model.Network)1