diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-24 16:49:54 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-24 16:49:54 +1300 |
commit | ebe64e810bd8e57a805a571cfd6110fbc3cd57c1 (patch) | |
tree | 90d8bb347c6081116df225d5c1e08f9469458675 /src/org/traccar/protocol/MeiligaoProtocolEncoder.java | |
parent | 04f33e6ba29b3a73a65b081d2a8b6ac3e0e0ebee (diff) | |
parent | 03fb12d4a9453d6845198a167a70e720726df2e2 (diff) | |
download | trackermap-server-ebe64e810bd8e57a805a571cfd6110fbc3cd57c1.tar.gz trackermap-server-ebe64e810bd8e57a805a571cfd6110fbc3cd57c1.tar.bz2 trackermap-server-ebe64e810bd8e57a805a571cfd6110fbc3cd57c1.zip |
Merge pull request #2593 from Abyss777/attributes_helpers
Attributes helpers
Diffstat (limited to 'src/org/traccar/protocol/MeiligaoProtocolEncoder.java')
-rw-r--r-- | src/org/traccar/protocol/MeiligaoProtocolEncoder.java | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/MeiligaoProtocolEncoder.java b/src/org/traccar/protocol/MeiligaoProtocolEncoder.java index a91b33a60..268bae392 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolEncoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolEncoder.java @@ -24,7 +24,6 @@ import org.traccar.model.Command; import javax.xml.bind.DatatypeConverter; import java.nio.charset.StandardCharsets; -import java.util.Map; public class MeiligaoProtocolEncoder extends BaseProtocolEncoder { @@ -62,13 +61,12 @@ public class MeiligaoProtocolEncoder extends BaseProtocolEncoder { protected Object encodeCommand(Command command) { ChannelBuffer content = ChannelBuffers.dynamicBuffer(); - Map<String, Object> attributes = command.getAttributes(); switch (command.getType()) { case Command.TYPE_POSITION_SINGLE: return encodeContent(command.getDeviceId(), MSG_TRACK_ON_DEMAND, content); case Command.TYPE_POSITION_PERIODIC: - content.writeShort(((Number) attributes.get(Command.KEY_FREQUENCY)).intValue() / 10); + content.writeShort(command.getInteger(Command.KEY_FREQUENCY) / 10); return encodeContent(command.getDeviceId(), MSG_TRACK_BY_INTERVAL, content); case Command.TYPE_ENGINE_STOP: content.writeByte(0x01); @@ -77,10 +75,10 @@ public class MeiligaoProtocolEncoder extends BaseProtocolEncoder { content.writeByte(0x00); return encodeContent(command.getDeviceId(), MSG_OUTPUT_CONTROL, content); case Command.TYPE_ALARM_GEOFENCE: - content.writeShort(((Number) attributes.get(Command.KEY_RADIUS)).intValue()); + content.writeShort(command.getInteger(Command.KEY_RADIUS)); return encodeContent(command.getDeviceId(), MSG_MOVEMENT_ALARM, content); case Command.TYPE_SET_TIMEZONE: - int offset = ((Number) attributes.get(Command.KEY_TIMEZONE)).intValue() / 60; + int offset = command.getInteger(Command.KEY_TIMEZONE) / 60; content.writeBytes(String.valueOf(offset).getBytes(StandardCharsets.US_ASCII)); return encodeContent(command.getDeviceId(), MSG_TIME_ZONE, content); case Command.TYPE_REBOOT_DEVICE: |