diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-17 22:51:09 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-17 22:51:09 +1200 |
commit | 466e704934894ed44458bec798fa9fad0532bb4c (patch) | |
tree | eaf48175234c9d4d1b0456a542887a90c1377d00 /src/org/traccar/protocol/Gps103Protocol.java | |
parent | 6bfaa4bdedcf6719de75afa905a309296aa1bd9d (diff) | |
parent | ff640cf8eb19cfeb3c8475ffd9b0aeccbd769f96 (diff) | |
download | trackermap-server-466e704934894ed44458bec798fa9fad0532bb4c.tar.gz trackermap-server-466e704934894ed44458bec798fa9fad0532bb4c.tar.bz2 trackermap-server-466e704934894ed44458bec798fa9fad0532bb4c.zip |
Merge commands implementation (fix #7)
Diffstat (limited to 'src/org/traccar/protocol/Gps103Protocol.java')
-rw-r--r-- | src/org/traccar/protocol/Gps103Protocol.java | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/src/org/traccar/protocol/Gps103Protocol.java b/src/org/traccar/protocol/Gps103Protocol.java index 84275a556..59d8e62a7 100644 --- a/src/org/traccar/protocol/Gps103Protocol.java +++ b/src/org/traccar/protocol/Gps103Protocol.java @@ -15,6 +15,7 @@ */ package org.traccar.protocol; +import java.util.List; import org.jboss.netty.bootstrap.ConnectionlessBootstrap; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; @@ -23,35 +24,17 @@ import org.jboss.netty.handler.codec.string.StringEncoder; import org.traccar.BaseProtocol; import org.traccar.CharacterDelimiterFrameDecoder; import org.traccar.TrackerServer; -import org.traccar.command.CommandType; -import org.traccar.command.Duration; -import org.traccar.command.FixPositioningCommand; -import org.traccar.command.GpsCommand; -import org.traccar.command.CommandTemplate; -import org.traccar.command.CommandValueConversion; -import org.traccar.command.StringCommandTemplate; - -import java.util.List; -import java.util.Map; +import org.traccar.model.Command; public class Gps103Protocol extends BaseProtocol { public Gps103Protocol() { super("gps103"); - } - - @Override - protected void initCommandsTemplates(Map<CommandType, CommandTemplate> templates) { - templates.put(CommandType.STOP_POSITIONING, new StringCommandTemplate("**,imei:[%s],A", GpsCommand.UNIQUE_ID)); - templates.put(CommandType.FIX_POSITIONING, new StringCommandTemplate("**,imei:[%s],C,[%s]", GpsCommand.UNIQUE_ID, FixPositioningCommand.FREQUENCY) - .addConverter(Duration.class, new CommandValueConversion<Duration>() { - @Override - public String convert(Duration value) { - return String.format("%02d%s", value.getValue(), value.getUnit().getCommandFormat()); - } - })); - templates.put(CommandType.RESUME_ENGINE, new StringCommandTemplate("**,imei:[%s],J", GpsCommand.UNIQUE_ID)); - templates.put(CommandType.STOP_ENGINE, new StringCommandTemplate("**,imei:[%s],K", GpsCommand.UNIQUE_ID)); + setSupportedCommands( + Command.TYPE_POSITION_STOP, + Command.TYPE_POSITION_FIX, + Command.TYPE_ENGINE_STOP, + Command.TYPE_ENGINE_RESUME); } @Override @@ -63,6 +46,7 @@ public class Gps103Protocol extends BaseProtocol { pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("stringEncoder", new StringEncoder()); pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(Gps103Protocol.this)); + pipeline.addLast("objectEncoder", new Gps103ProtocolEncoder()); } }); serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { @@ -71,6 +55,7 @@ public class Gps103Protocol extends BaseProtocol { pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("stringEncoder", new StringEncoder()); pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(Gps103Protocol.this)); + pipeline.addLast("objectEncoder", new Gps103ProtocolEncoder()); } }); } |