From f7198adaf371e08a72a837d417b29531c117c6ba Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 29 Apr 2015 13:41:15 +1200 Subject: Store other data in position --- src/org/traccar/protocol/ApelProtocolDecoder.java | 35 ++++------ .../traccar/protocol/AplicomProtocolDecoder.java | 58 ++++++++--------- .../traccar/protocol/Ardi01ProtocolDecoder.java | 15 ++--- .../traccar/protocol/AtrackProtocolDecoder.java | 30 ++++----- .../traccar/protocol/AutoFon45ProtocolDecoder.java | 15 ++--- .../traccar/protocol/AutoFonProtocolDecoder.java | 17 ++--- .../traccar/protocol/Avl301ProtocolDecoder.java | 21 +++--- src/org/traccar/protocol/BceProtocolDecoder.java | 28 ++++---- src/org/traccar/protocol/BoxProtocolDecoder.java | 14 ++-- .../traccar/protocol/CalAmpProtocolDecoder.java | 29 ++++----- .../traccar/protocol/CarTrackProtocolDecoder.java | 20 ++---- .../traccar/protocol/CarscopProtocolDecoder.java | 12 +--- .../protocol/CellocatorProtocolDecoder.java | 12 +--- .../traccar/protocol/EasyTrackProtocolDecoder.java | 20 ++---- .../traccar/protocol/EelinkProtocolDecoder.java | 23 ++----- .../traccar/protocol/EnforaProtocolDecoder.java | 7 +- src/org/traccar/protocol/Ev603ProtocolDecoder.java | 8 +-- .../traccar/protocol/FreedomProtocolDecoder.java | 8 +-- .../traccar/protocol/GalileoProtocolDecoder.java | 16 ++--- src/org/traccar/protocol/GatorProtocolDecoder.java | 20 ++---- src/org/traccar/protocol/Gl100ProtocolDecoder.java | 8 +-- src/org/traccar/protocol/Gl200ProtocolDecoder.java | 20 ++---- .../traccar/protocol/GlobalSatProtocolDecoder.java | 17 ++--- .../traccar/protocol/GoSafeProtocolDecoder.java | 11 +--- src/org/traccar/protocol/GotopProtocolDecoder.java | 10 +-- .../traccar/protocol/Gps103ProtocolDecoder.java | 19 ++---- .../traccar/protocol/GpsGateProtocolDecoder.java | 8 +-- src/org/traccar/protocol/Gt02ProtocolDecoder.java | 10 +-- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 29 ++++----- src/org/traccar/protocol/H02ProtocolDecoder.java | 16 ++--- .../traccar/protocol/HaicomProtocolDecoder.java | 23 +++---- .../protocol/IntellitracProtocolDecoder.java | 40 +++++------- src/org/traccar/protocol/Jt600ProtocolDecoder.java | 32 ++++------ src/org/traccar/protocol/KhdProtocolDecoder.java | 10 +-- .../traccar/protocol/LaipacProtocolDecoder.java | 8 +-- src/org/traccar/protocol/M2mProtocolDecoder.java | 10 +-- .../traccar/protocol/ManPowerProtocolDecoder.java | 11 +--- .../traccar/protocol/MegastekProtocolDecoder.java | 46 ++++++-------- .../traccar/protocol/MeiligaoProtocolDecoder.java | 22 +++---- .../traccar/protocol/MeitrackProtocolDecoder.java | 65 ++++++++----------- .../protocol/MiniFinderProtocolDecoder.java | 14 ++-- src/org/traccar/protocol/Mta6ProtocolDecoder.java | 74 ++++++++++------------ src/org/traccar/protocol/MtxProtocolDecoder.java | 17 ++--- .../traccar/protocol/NavigilProtocolDecoder.java | 48 +++++--------- src/org/traccar/protocol/NavisProtocolDecoder.java | 42 ++++++------ src/org/traccar/protocol/NoranProtocolDecoder.java | 14 ++-- src/org/traccar/protocol/OrionProtocolDecoder.java | 16 ++--- .../traccar/protocol/OsmAndProtocolDecoder.java | 18 ++---- .../traccar/protocol/PiligrimProtocolDecoder.java | 14 ++-- .../traccar/protocol/ProgressProtocolDecoder.java | 29 ++++----- .../traccar/protocol/Pt3000ProtocolDecoder.java | 8 +-- src/org/traccar/protocol/Pt502ProtocolDecoder.java | 9 +-- src/org/traccar/protocol/RitiProtocolDecoder.java | 18 ++---- .../traccar/protocol/RuptelaProtocolDecoder.java | 20 ++---- src/org/traccar/protocol/SanavProtocolDecoder.java | 8 +-- .../traccar/protocol/SkypatrolProtocolDecoder.java | 20 ++---- .../traccar/protocol/Stl060ProtocolDecoder.java | 19 ++---- .../traccar/protocol/SuntechProtocolDecoder.java | 13 +--- src/org/traccar/protocol/SyrusProtocolDecoder.java | 8 +-- src/org/traccar/protocol/T55ProtocolDecoder.java | 22 ++----- src/org/traccar/protocol/TelikProtocolDecoder.java | 13 +--- .../traccar/protocol/TeltonikaProtocolDecoder.java | 34 ++++------ src/org/traccar/protocol/Tk102ProtocolDecoder.java | 8 +-- src/org/traccar/protocol/Tk103ProtocolDecoder.java | 12 +--- src/org/traccar/protocol/Tlt2hProtocolDecoder.java | 12 +--- .../protocol/TopflytechProtocolDecoder.java | 8 +-- src/org/traccar/protocol/TotemProtocolDecoder.java | 49 ++++++-------- src/org/traccar/protocol/Tr20ProtocolDecoder.java | 9 +-- src/org/traccar/protocol/Tr900ProtocolDecoder.java | 20 ++---- .../traccar/protocol/TrackboxProtocolDecoder.java | 15 ++--- .../traccar/protocol/TramigoProtocolDecoder.java | 14 +--- src/org/traccar/protocol/TytanProtocolDecoder.java | 31 ++++----- .../traccar/protocol/UlbotechProtocolDecoder.java | 7 +- src/org/traccar/protocol/V680ProtocolDecoder.java | 18 ++---- .../traccar/protocol/VisiontekProtocolDecoder.java | 27 +++----- .../traccar/protocol/WialonProtocolDecoder.java | 23 +++---- .../traccar/protocol/WondexProtocolDecoder.java | 24 +++---- .../traccar/protocol/Xexun2ProtocolDecoder.java | 21 ++---- src/org/traccar/protocol/XexunProtocolDecoder.java | 8 +-- src/org/traccar/protocol/XirgoProtocolDecoder.java | 21 ++---- src/org/traccar/protocol/Xt013ProtocolDecoder.java | 16 ++--- src/org/traccar/protocol/Xt7ProtocolDecoder.java | 25 +++----- src/org/traccar/protocol/YwtProtocolDecoder.java | 12 +--- 83 files changed, 577 insertions(+), 1104 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/ApelProtocolDecoder.java b/src/org/traccar/protocol/ApelProtocolDecoder.java index 4184172fa..75153d0d8 100644 --- a/src/org/traccar/protocol/ApelProtocolDecoder.java +++ b/src/org/traccar/protocol/ApelProtocolDecoder.java @@ -20,7 +20,6 @@ import java.nio.charset.Charset; import java.util.Calendar; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -29,11 +28,8 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.Context; -import org.traccar.database.DataManager; import org.traccar.helper.Crc; import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class ApelProtocolDecoder extends BaseProtocolDecoder { @@ -162,15 +158,15 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder { for (int j = 0; j < recordCount; j++) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); // Message index int subtype = type; if (type == MSG_TYPE_LOG_RECORDS) { - extendedInfo.set("archive", true); + position.set("archive", true); lastIndex = buf.readUnsignedInt() + 1; - extendedInfo.set("index", lastIndex); + position.set("index", lastIndex); subtype = buf.readUnsignedShort(); if (subtype != MSG_TYPE_CURRENT_GPS_DATA && subtype != MSG_TYPE_STATE_FULL_INFO_T104) { @@ -197,7 +193,7 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder { int speed = buf.readUnsignedByte(); position.setValid(speed != 255); position.setSpeed(speed * 0.539957); - extendedInfo.set("hdop", buf.readByte()); + position.set("hdop", buf.readByte()); } else { int speed = buf.readShort(); position.setValid(speed != -1); @@ -213,35 +209,32 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder { if (subtype == MSG_TYPE_STATE_FULL_INFO_T104) { // Satellites - extendedInfo.set("satellites", buf.readUnsignedByte()); + position.set("satellites", buf.readUnsignedByte()); // Cell signal - extendedInfo.set("gsm", buf.readUnsignedByte()); + position.set("gsm", buf.readUnsignedByte()); // Event type - extendedInfo.set("event", buf.readUnsignedShort()); + position.set("event", buf.readUnsignedShort()); // Milage - extendedInfo.set("milage", buf.readUnsignedInt()); + position.set("milage", buf.readUnsignedInt()); // Input/Output - extendedInfo.set("input", buf.readUnsignedByte()); - extendedInfo.set("output", buf.readUnsignedByte()); + position.set("input", buf.readUnsignedByte()); + position.set("output", buf.readUnsignedByte()); // Analog sensors for (int i = 1; i <= 8; i++) { - extendedInfo.set("adc" + i, buf.readUnsignedShort()); + position.set("adc" + i, buf.readUnsignedShort()); } // Counters - extendedInfo.set("c0", buf.readUnsignedInt()); - extendedInfo.set("c1", buf.readUnsignedInt()); - extendedInfo.set("c2", buf.readUnsignedInt()); + position.set("c0", buf.readUnsignedInt()); + position.set("c1", buf.readUnsignedInt()); + position.set("c2", buf.readUnsignedInt()); } - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - positions.add(position); } diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index 2234b6e19..60eb7a74c 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -26,7 +26,6 @@ import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; import org.traccar.Context; import org.traccar.helper.ChannelBufferTools; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class AplicomProtocolDecoder extends BaseProtocolDecoder { @@ -130,7 +129,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); if (!identify(imei)) { return null; } @@ -139,7 +138,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { // Event int event = buf.readUnsignedByte(); - extendedInfo.set("event", event); + position.set("event", event); buf.readUnsignedByte(); // Validity @@ -159,7 +158,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { position.setTime(new Date(buf.readUnsignedInt() * 1000)); position.setLatitude(buf.readInt() / 1000000.0); position.setLongitude(buf.readInt() / 1000000.0); - extendedInfo.set("satellites", buf.readUnsignedByte()); + position.set("satellites", buf.readUnsignedByte()); } // Speed and heading @@ -171,21 +170,21 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { // Input if ((selector & 0x0040) != 0) { - extendedInfo.set("input", buf.readUnsignedByte()); + position.set("input", buf.readUnsignedByte()); } // ADC if ((selector & 0x0020) != 0) { - extendedInfo.set("adc1", buf.readUnsignedShort()); - extendedInfo.set("adc2", buf.readUnsignedShort()); - extendedInfo.set("adc3", buf.readUnsignedShort()); - extendedInfo.set("adc4", buf.readUnsignedShort()); + position.set("adc1", buf.readUnsignedShort()); + position.set("adc2", buf.readUnsignedShort()); + position.set("adc3", buf.readUnsignedShort()); + position.set("adc4", buf.readUnsignedShort()); } // Power if ((selector & 0x8000) != 0) { - extendedInfo.set("power", buf.readUnsignedShort() / 1000.0); - extendedInfo.set("battery", buf.readUnsignedShort()); + position.set("power", buf.readUnsignedShort() / 1000.0); + position.set("battery", buf.readUnsignedShort()); } // Pulse rate 1 @@ -202,17 +201,17 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { // Trip 1 if ((selector & 0x0080) != 0) { - extendedInfo.set("trip1", buf.readUnsignedInt()); + position.set("trip1", buf.readUnsignedInt()); } // Trip 2 if ((selector & 0x0100) != 0) { - extendedInfo.set("trip2", buf.readUnsignedInt()); + position.set("trip2", buf.readUnsignedInt()); } // Output if ((selector & 0x0040) != 0) { - extendedInfo.set("output", buf.readUnsignedByte()); + position.set("output", buf.readUnsignedByte()); } // Button @@ -294,37 +293,36 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { ChannelBuffer value = values.get(i); switch (buf.readInt()) { case 0x40C: - extendedInfo.set("suction-temperature1", ChannelBuffers.swapShort(value.readShort()) * 0.1); - extendedInfo.set("suction-temperature2", ChannelBuffers.swapShort(value.readShort()) * 0.1); - extendedInfo.set("suction-temperature3", ChannelBuffers.swapShort(value.readShort()) * 0.1); - extendedInfo.set("evaporator-fan", ChannelBuffers.swapShort(value.readShort())); + position.set("suction-temperature1", ChannelBuffers.swapShort(value.readShort()) * 0.1); + position.set("suction-temperature2", ChannelBuffers.swapShort(value.readShort()) * 0.1); + position.set("suction-temperature3", ChannelBuffers.swapShort(value.readShort()) * 0.1); + position.set("evaporator-fan", ChannelBuffers.swapShort(value.readShort())); break; case 0x50C: - extendedInfo.set("evaporator-temperature1", ChannelBuffers.swapShort(value.readShort()) * 0.1); - extendedInfo.set("evaporator-temperature2", ChannelBuffers.swapShort(value.readShort()) * 0.1); - extendedInfo.set("evaporator-temperature3", ChannelBuffers.swapShort(value.readShort()) * 0.1); + position.set("evaporator-temperature1", ChannelBuffers.swapShort(value.readShort()) * 0.1); + position.set("evaporator-temperature2", ChannelBuffers.swapShort(value.readShort()) * 0.1); + position.set("evaporator-temperature3", ChannelBuffers.swapShort(value.readShort()) * 0.1); break; case 0x20D: - extendedInfo.set("diesel-rpm", ChannelBuffers.swapShort(value.readShort())); - extendedInfo.set("diesel-temperature", ChannelBuffers.swapShort(value.readShort()) * 0.1); - extendedInfo.set("battery", ChannelBuffers.swapShort(value.readShort()) * 0.01); - extendedInfo.set("air-temperature", ChannelBuffers.swapShort(value.readShort()) * 0.1); + position.set("diesel-rpm", ChannelBuffers.swapShort(value.readShort())); + position.set("diesel-temperature", ChannelBuffers.swapShort(value.readShort()) * 0.1); + position.set("battery", ChannelBuffers.swapShort(value.readShort()) * 0.01); + position.set("air-temperature", ChannelBuffers.swapShort(value.readShort()) * 0.1); break; case 0x30D: - extendedInfo.set("alarms", ChannelBufferTools.readHexString(value, 16)); + position.set("alarms", ChannelBufferTools.readHexString(value, 16)); break; case 0x40D: - extendedInfo.set("cold-unit-status", ChannelBufferTools.readHexString(value, 16)); + position.set("cold-unit-status", ChannelBufferTools.readHexString(value, 16)); break; case 0x50D: - extendedInfo.set("coolant-pressure", ChannelBuffers.swapShort(value.readShort()) * 0.1); - extendedInfo.set("suction-pressure", ChannelBuffers.swapShort(value.readShort()) * 0.1); + position.set("coolant-pressure", ChannelBuffers.swapShort(value.readShort()) * 0.1); + position.set("suction-pressure", ChannelBuffers.swapShort(value.readShort()) * 0.1); break; } } } - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/Ardi01ProtocolDecoder.java b/src/org/traccar/protocol/Ardi01ProtocolDecoder.java index 4e90134ae..8e1185d25 100644 --- a/src/org/traccar/protocol/Ardi01ProtocolDecoder.java +++ b/src/org/traccar/protocol/Ardi01ProtocolDecoder.java @@ -18,13 +18,9 @@ package org.traccar.protocol; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -64,7 +60,7 @@ public class Ardi01ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Detect device @@ -94,18 +90,17 @@ public class Ardi01ProtocolDecoder extends BaseProtocolDecoder { // Satellites int satellites = Integer.valueOf(parser.group(index++)); position.setValid(satellites >= 3); - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); // Event - extendedInfo.set("event", parser.group(index++)); + position.set("event", parser.group(index++)); // Input - extendedInfo.set("battery", parser.group(index++)); + position.set("battery", parser.group(index++)); // Output - extendedInfo.set("temperature", parser.group(index++)); + position.set("temperature", parser.group(index++)); - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java index 29070f6e1..b898d9e92 100644 --- a/src/org/traccar/protocol/AtrackProtocolDecoder.java +++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java @@ -20,7 +20,6 @@ import java.nio.charset.Charset; import java.util.Date; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; @@ -28,9 +27,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class AtrackProtocolDecoder extends BaseProtocolDecoder { @@ -106,7 +102,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(getDeviceId()); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Date and time position.setTime(new Date(buf.readUnsignedInt() * 1000)); // gps time @@ -122,41 +118,39 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { position.setCourse(buf.readUnsignedShort()); // Report type - extendedInfo.set("type", buf.readUnsignedByte()); + position.set("type", buf.readUnsignedByte()); // Milage - extendedInfo.set("milage", buf.readUnsignedInt() * 0.1); + position.set("milage", buf.readUnsignedInt() * 0.1); // Accuracy - extendedInfo.set("hdop", buf.readUnsignedShort() * 0.1); + position.set("hdop", buf.readUnsignedShort() * 0.1); // Input - extendedInfo.set("input", buf.readUnsignedByte()); + position.set("input", buf.readUnsignedByte()); // Speed position.setSpeed(buf.readUnsignedShort() * 0.539957); // Output - extendedInfo.set("output", buf.readUnsignedByte()); + position.set("output", buf.readUnsignedByte()); // ADC - extendedInfo.set("adc", buf.readUnsignedShort() * 0.001); + position.set("adc", buf.readUnsignedShort() * 0.001); // Driver - extendedInfo.set("driver", readString(buf)); + position.set("driver", readString(buf)); // Temperature - extendedInfo.set("temperature1", buf.readShort() * 0.1); - extendedInfo.set("temperature2", buf.readShort() * 0.1); + position.set("temperature1", buf.readShort() * 0.1); + position.set("temperature2", buf.readShort() * 0.1); // Text Message - extendedInfo.set("message", readString(buf)); + position.set("message", readString(buf)); // With AT$FORM Command you can extend atrack protocol. // For example adding AT$FORM %FC /Fuel used you can add the line in this position: - // extendedInfo.set("fuelused", buf.readUnsignedInt() * 0.1); - - position.setExtendedInfo(extendedInfo.toString()); + // position.set("fuelused", buf.readUnsignedInt() * 0.1); positions.add(position); } diff --git a/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java b/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java index 967799f95..3b56c8fc4 100644 --- a/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java +++ b/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java @@ -23,10 +23,7 @@ import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; import java.util.*; @@ -69,16 +66,16 @@ public class AutoFon45ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); short status = buf.readUnsignedByte(); - extendedInfo.set("alarm", (status & 0x80) != 0); - extendedInfo.set("battery", status & 0x7F); + position.set("alarm", (status & 0x80) != 0); + position.set("battery", status & 0x7F); buf.skipBytes(2); // remaining time - extendedInfo.set("temperature", buf.readByte()); + position.set("temperature", buf.readByte()); buf.skipBytes(2); // timer (interval and units) buf.readByte(); // mode @@ -89,7 +86,7 @@ public class AutoFon45ProtocolDecoder extends BaseProtocolDecoder { // GPS status int valid = buf.readUnsignedByte(); position.setValid((valid & 0xc0) != 0); - extendedInfo.set("satellites", valid & 0x3f); + position.set("satellites", valid & 0x3f); // Date and time int timeOfDay = buf.readUnsignedByte() << 16 | buf.readUnsignedByte() << 8 | buf.readUnsignedByte(); @@ -112,8 +109,6 @@ public class AutoFon45ProtocolDecoder extends BaseProtocolDecoder { position.setCourse(buf.readUnsignedByte() << 8 | buf.readUnsignedByte()); buf.readUnsignedByte(); // checksum - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/AutoFonProtocolDecoder.java b/src/org/traccar/protocol/AutoFonProtocolDecoder.java index 48e30b72b..ceeb0b29d 100644 --- a/src/org/traccar/protocol/AutoFonProtocolDecoder.java +++ b/src/org/traccar/protocol/AutoFonProtocolDecoder.java @@ -20,10 +20,7 @@ import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; import java.util.*; @@ -48,7 +45,7 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); if (!history) { @@ -59,7 +56,7 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { if (!history) { buf.readUnsignedShort(); } - extendedInfo.set("battery", buf.readUnsignedByte()); + position.set("battery", buf.readUnsignedByte()); buf.skipBytes(6); // time // Timers @@ -71,8 +68,8 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { } } - extendedInfo.set("temperature", buf.readByte()); - extendedInfo.set("gsm", buf.readUnsignedByte()); + position.set("temperature", buf.readByte()); + position.set("gsm", buf.readUnsignedByte()); buf.readUnsignedShort(); // mcc buf.readUnsignedShort(); // mnc buf.readUnsignedShort(); // lac @@ -81,7 +78,7 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { // GPS status int valid = buf.readUnsignedByte(); position.setValid((valid & 0xc0) != 0); - extendedInfo.set("satellites", valid & 0x3f); + position.set("satellites", valid & 0x3f); // Date and time Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -101,12 +98,10 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(buf.readUnsignedByte()); position.setCourse(buf.readUnsignedByte() * 2.0); - extendedInfo.set("hdop", buf.readUnsignedShort()); + position.set("hdop", buf.readUnsignedShort()); buf.readUnsignedShort(); // reserved buf.readUnsignedByte(); // checksum - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/Avl301ProtocolDecoder.java b/src/org/traccar/protocol/Avl301ProtocolDecoder.java index 66db5b55a..c74e10f5e 100644 --- a/src/org/traccar/protocol/Avl301ProtocolDecoder.java +++ b/src/org/traccar/protocol/Avl301ProtocolDecoder.java @@ -20,7 +20,6 @@ import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; import java.util.Calendar; @@ -85,7 +84,7 @@ public class Avl301ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(getDeviceId()); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Date and time(6) Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -100,7 +99,7 @@ public class Avl301ProtocolDecoder extends BaseProtocolDecoder { // GPS length and Satellites count int gpsLength = buf.readUnsignedByte(); - extendedInfo.set("satellites", gpsLength & 0xf); + position.set("satellites", gpsLength & 0xf); gpsLength >>= 4; //Skip Satellite numbers @@ -122,21 +121,19 @@ public class Avl301ProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(longitude); if ((union & 0x4000) != 0) { - extendedInfo.set("acc", (union & 0x8000) != 0); + position.set("acc", (union & 0x8000) != 0); } - extendedInfo.set("lac", buf.readUnsignedShort()); - extendedInfo.set("cell", buf.readUnsignedMedium()); - extendedInfo.set("alarm", true); + position.set("lac", buf.readUnsignedShort()); + position.set("cell", buf.readUnsignedMedium()); + position.set("alarm", true); int flags = buf.readUnsignedByte(); - extendedInfo.set("acc", (flags & 0x2) != 0); + position.set("acc", (flags & 0x2) != 0); // TODO parse other flags - extendedInfo.set("power", buf.readUnsignedByte()); - extendedInfo.set("gsm", buf.readUnsignedByte()); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("power", buf.readUnsignedByte()); + position.set("gsm", buf.readUnsignedByte()); return position; } diff --git a/src/org/traccar/protocol/BceProtocolDecoder.java b/src/org/traccar/protocol/BceProtocolDecoder.java index 365d51cb3..28570b63c 100644 --- a/src/org/traccar/protocol/BceProtocolDecoder.java +++ b/src/org/traccar/protocol/BceProtocolDecoder.java @@ -19,16 +19,12 @@ import java.nio.ByteOrder; import java.util.Date; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class BceProtocolDecoder extends BaseProtocolDecoder { @@ -72,7 +68,7 @@ public class BceProtocolDecoder extends BaseProtocolDecoder { while (buf.readerIndex() < dataEnd) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); int structEnd = buf.readUnsignedByte() + buf.readerIndex(); @@ -101,24 +97,22 @@ public class BceProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(buf.readUnsignedByte()); int gps = buf.readUnsignedByte(); - extendedInfo.set("satellites", gps & 0xf); - extendedInfo.set("hdop", gps >> 4); + position.set("satellites", gps & 0xf); + position.set("hdop", gps >> 4); position.setCourse(buf.readUnsignedByte()); position.setAltitude(buf.readUnsignedShort()); - extendedInfo.set("milage", buf.readUnsignedInt()); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("milage", buf.readUnsignedInt()); } if (checkBit(mask, 1)) { - extendedInfo.set("input", buf.readUnsignedShort()); + position.set("input", buf.readUnsignedShort()); } for (int i = 1; i <= 8; i++) { if (checkBit(mask, i + 1)) { - extendedInfo.set("adc" + i, buf.readUnsignedShort()); + position.set("adc" + i, buf.readUnsignedShort()); } } @@ -128,11 +122,11 @@ public class BceProtocolDecoder extends BaseProtocolDecoder { if (checkBit(mask, 13)) buf.skipBytes(2); if (checkBit(mask, 14)) { - extendedInfo.set("mcc", buf.readUnsignedShort()); - extendedInfo.set("mnc", buf.readUnsignedByte()); - extendedInfo.set("lac", buf.readUnsignedShort()); - extendedInfo.set("cell", buf.readUnsignedShort()); - extendedInfo.set("gsm", buf.readUnsignedByte()); + position.set("mcc", buf.readUnsignedShort()); + position.set("mnc", buf.readUnsignedByte()); + position.set("lac", buf.readUnsignedShort()); + position.set("cell", buf.readUnsignedShort()); + position.set("gsm", buf.readUnsignedByte()); buf.readUnsignedByte(); } diff --git a/src/org/traccar/protocol/BoxProtocolDecoder.java b/src/org/traccar/protocol/BoxProtocolDecoder.java index 804ce059c..a34c13a58 100644 --- a/src/org/traccar/protocol/BoxProtocolDecoder.java +++ b/src/org/traccar/protocol/BoxProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class BoxProtocolDecoder extends BaseProtocolDecoder { @@ -75,7 +71,7 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(getDeviceId()); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -97,17 +93,15 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(parser.group(index++))); // Distance - extendedInfo.set("milage", parser.group(index++)); + position.set("milage", parser.group(index++)); // Event - extendedInfo.set("event", parser.group(index++)); + position.set("event", parser.group(index++)); // Status int status = Integer.valueOf(parser.group(index++)); position.setValid((status & 0x04) == 0); - extendedInfo.set("status", status); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("status", status); return position; } diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java index 786ec22f6..7cf5031f3 100644 --- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java +++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java @@ -17,7 +17,7 @@ package org.traccar.protocol; import java.net.SocketAddress; import java.util.Date; -import java.util.Properties; + import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -26,9 +26,6 @@ import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.MessageEvent; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class CalAmpProtocolDecoder extends BaseProtocolDecoder { @@ -161,7 +158,7 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(getDeviceId()); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Location data position.setTime(new Date(buf.readUnsignedInt() * 1000)); @@ -181,42 +178,42 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder { // Fix status if (type == MSG_MINI_EVENT_REPORT) { - extendedInfo.set("satellites", buf.getUnsignedByte(buf.readerIndex()) & 0xf); + position.set("satellites", buf.getUnsignedByte(buf.readerIndex()) & 0xf); position.setValid((buf.readUnsignedByte() & 0x20) == 0); } else { - extendedInfo.set("satellites", buf.readUnsignedByte()); + position.set("satellites", buf.readUnsignedByte()); position.setValid((buf.readUnsignedByte() & 0x08) == 0); } if (type != MSG_MINI_EVENT_REPORT) { // Carrier - extendedInfo.set("carrier", buf.readUnsignedShort()); + position.set("carrier", buf.readUnsignedShort()); // Cell signal - extendedInfo.set("gsm", buf.readShort()); + position.set("gsm", buf.readShort()); } // Modem state - extendedInfo.set("modem", buf.readUnsignedByte()); + position.set("modem", buf.readUnsignedByte()); // HDOP if (type != MSG_MINI_EVENT_REPORT) { - extendedInfo.set("hdop", buf.readUnsignedByte()); + position.set("hdop", buf.readUnsignedByte()); } // Inputs - extendedInfo.set("input", buf.readUnsignedByte()); + position.set("input", buf.readUnsignedByte()); // Unit status if (type != MSG_MINI_EVENT_REPORT) { - extendedInfo.set("status", buf.readUnsignedByte()); + position.set("status", buf.readUnsignedByte()); } // Event code and status if (type == MSG_EVENT_REPORT || type == MSG_MINI_EVENT_REPORT) { - extendedInfo.set("event", buf.readUnsignedByte() + " - " + buf.readUnsignedByte()); + position.set("event", buf.readUnsignedByte() + " - " + buf.readUnsignedByte()); } // Accumulators @@ -232,10 +229,8 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder { } for (int i = 0; i < accCount; i++) { - extendedInfo.set("acc" + i, buf.readUnsignedInt()); + position.set("acc" + i, buf.readUnsignedInt()); } - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/CarTrackProtocolDecoder.java b/src/org/traccar/protocol/CarTrackProtocolDecoder.java index b4e5bf134..b88f9840d 100644 --- a/src/org/traccar/protocol/CarTrackProtocolDecoder.java +++ b/src/org/traccar/protocol/CarTrackProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,9 +25,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class CarTrackProtocolDecoder extends BaseProtocolDecoder { @@ -73,7 +69,7 @@ public class CarTrackProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Get device by unique identifier @@ -83,7 +79,7 @@ public class CarTrackProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); // Command - extendedInfo.set("command", parser.group(index++)); + position.set("command", parser.group(index++)); // Time Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -127,7 +123,7 @@ public class CarTrackProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // State - extendedInfo.set("io", parser.group(index++)); + position.set("io", parser.group(index++)); /* Start : Added By Rohit Singhal, Decode Milage Data*/ // Prepare Mile Meter Data String milage = parser.group(index++); @@ -137,13 +133,11 @@ public class CarTrackProtocolDecoder extends BaseProtocolDecoder { milage = milage.replace("=", "D"); milage = milage.replace(">", "E"); milage = milage.replace("?", "F"); - extendedInfo.set("milage", Integer.parseInt(milage, 16)); - /* Commented By Rohit extendedInfo.set("milage", parser.group(index++)); */ + position.set("milage", Integer.parseInt(milage, 16)); + /* Commented By Rohit position.set("milage", parser.group(index++)); */ /*End : Added By Rohit Singhal, Decode Milage Data*/ - extendedInfo.set("alarm", parser.group(index++)); - extendedInfo.set("ad", parser.group(index++)); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("alarm", parser.group(index++)); + position.set("ad", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/CarscopProtocolDecoder.java b/src/org/traccar/protocol/CarscopProtocolDecoder.java index 2b6d70519..2e912961c 100644 --- a/src/org/traccar/protocol/CarscopProtocolDecoder.java +++ b/src/org/traccar/protocol/CarscopProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class CarscopProtocolDecoder extends BaseProtocolDecoder { @@ -76,7 +72,7 @@ public class CarscopProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(getDeviceId()); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); index = 1; // Time @@ -114,12 +110,10 @@ public class CarscopProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(parser.group(index++))); // State - extendedInfo.set("state", parser.group(index++)); + position.set("state", parser.group(index++)); // Milage - extendedInfo.set("milage", Integer.valueOf(parser.group(index++))); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("milage", Integer.valueOf(parser.group(index++))); return position; } diff --git a/src/org/traccar/protocol/CellocatorProtocolDecoder.java b/src/org/traccar/protocol/CellocatorProtocolDecoder.java index a61c5b79f..2fac487c4 100644 --- a/src/org/traccar/protocol/CellocatorProtocolDecoder.java +++ b/src/org/traccar/protocol/CellocatorProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.nio.ByteOrder; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -26,9 +25,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class CellocatorProtocolDecoder extends BaseProtocolDecoder { @@ -106,7 +102,7 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder { // Parse location if (type == MSG_CLIENT_STATUS) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Device identifier if (!identify(String.valueOf(deviceUniqueId))) { @@ -119,7 +115,7 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // protocol version // Status - extendedInfo.set("status", buf.getUnsignedByte(buf.readerIndex()) & 0x0f); + position.set("status", buf.getUnsignedByte(buf.readerIndex()) & 0x0f); int operator = (buf.readUnsignedByte() & 0xf0) << 4; operator += buf.readUnsignedByte(); @@ -131,7 +127,7 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder { operator <<= 8; operator += buf.readUnsignedByte(); - extendedInfo.set("operator", operator); + position.set("operator", operator); buf.readUnsignedInt(); // ADC buf.readUnsignedMedium(); // milage @@ -161,8 +157,6 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.MONTH, buf.readUnsignedByte() - 1); time.set(Calendar.YEAR, buf.readUnsignedShort()); position.setTime(time.getTime()); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java index 2402cbdb7..eed94843d 100644 --- a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java +++ b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class EasyTrackProtocolDecoder extends BaseProtocolDecoder { @@ -76,7 +72,7 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -87,7 +83,7 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); // Command - extendedInfo.set("command", parser.group(index++)); + position.set("command", parser.group(index++)); // Validity position.setValid(parser.group(index++).compareTo("A") == 0); @@ -116,27 +112,25 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Integer.parseInt(parser.group(index++), 16) / 100.0); // Status - extendedInfo.set("status", parser.group(index++)); + position.set("status", parser.group(index++)); // Signal - extendedInfo.set("signal", parser.group(index++)); + position.set("signal", parser.group(index++)); // Power - extendedInfo.set("power", Double.valueOf(parser.group(index++))); + position.set("power", Double.valueOf(parser.group(index++))); // Oil - extendedInfo.set("oil", Integer.parseInt(parser.group(index++), 16)); + position.set("oil", Integer.parseInt(parser.group(index++), 16)); // Milage - extendedInfo.set("milage", Integer.parseInt(parser.group(index++), 16)); + position.set("milage", Integer.parseInt(parser.group(index++), 16)); // Altitude String altitude = parser.group(index++); if (altitude != null) { position.setAltitude(Double.valueOf(altitude)); } - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java index 3dde4513c..8f403d95f 100644 --- a/src/org/traccar/protocol/EelinkProtocolDecoder.java +++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java @@ -15,10 +15,7 @@ */ package org.traccar.protocol; -import java.util.Calendar; import java.util.Date; -import java.util.Properties; -import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; @@ -26,11 +23,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; -import org.traccar.helper.Crc; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class EelinkProtocolDecoder extends BaseProtocolDecoder { @@ -102,8 +95,8 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(); position.setDeviceId(getDeviceId()); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); - extendedInfo.set("index", index); + position.setProtocol(getProtocol()); + position.set("index", index); // Location position.setTime(new Date(buf.readUnsignedInt() * 1000)); @@ -113,20 +106,18 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { position.setCourse(buf.readUnsignedShort()); // Cell - extendedInfo.set("cell", ChannelBufferTools.readHexString(buf, 18)); + position.set("cell", ChannelBufferTools.readHexString(buf, 18)); // Validity position.setValid((buf.readUnsignedByte() & 0x01) != 0); if (type == MSG_ALARM) { - extendedInfo.set("alarm", buf.readUnsignedByte()); + position.set("alarm", buf.readUnsignedByte()); } if (type == MSG_STATE) { - extendedInfo.set("status", buf.readUnsignedByte()); + position.set("status", buf.readUnsignedByte()); } - - position.setExtendedInfo(extendedInfo.toString()); return position; } @@ -143,7 +134,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gt02"); - extendedInfo.set("index", index); + position.set("index", index); // Get device id try { @@ -185,8 +176,6 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { position.setLatitude(latitude); position.setLongitude(longitude); - - position.setExtendedInfo(extendedInfo.toString()); return position; }*/ diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java index 9fd20300f..67ad1a691 100644 --- a/src/org/traccar/protocol/EnforaProtocolDecoder.java +++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.nio.charset.Charset; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,10 +26,8 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class EnforaProtocolDecoder extends BaseProtocolDecoder { @@ -97,7 +94,7 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Get device by IMEI @@ -143,8 +140,6 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); position.setTime(time.getTime()); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/Ev603ProtocolDecoder.java b/src/org/traccar/protocol/Ev603ProtocolDecoder.java index ffec5926b..49d70d433 100644 --- a/src/org/traccar/protocol/Ev603ProtocolDecoder.java +++ b/src/org/traccar/protocol/Ev603ProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,9 +25,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Ev603ProtocolDecoder extends BaseProtocolDecoder{ @@ -69,7 +65,7 @@ public class Ev603ProtocolDecoder extends BaseProtocolDecoder{ // Create new position Position position = new Position(); position.setDeviceId(getDeviceId()); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Date @@ -100,8 +96,6 @@ public class Ev603ProtocolDecoder extends BaseProtocolDecoder{ if (position.getCourse() > 360) { position.setCourse(0); } - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/FreedomProtocolDecoder.java b/src/org/traccar/protocol/FreedomProtocolDecoder.java index 9323340a9..c0e7ec7c6 100644 --- a/src/org/traccar/protocol/FreedomProtocolDecoder.java +++ b/src/org/traccar/protocol/FreedomProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class FreedomProtocolDecoder extends BaseProtocolDecoder { @@ -59,7 +55,7 @@ public class FreedomProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Identification @@ -98,8 +94,6 @@ public class FreedomProtocolDecoder extends BaseProtocolDecoder { // Speed position.setSpeed(Double.valueOf(parser.group(index++))); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java index 3af06441e..ffd859f45 100644 --- a/src/org/traccar/protocol/GalileoProtocolDecoder.java +++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java @@ -25,9 +25,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class GalileoProtocolDecoder extends BaseProtocolDecoder { @@ -92,21 +90,19 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { Set tags = new HashSet(); boolean hasLocation = false; Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); while (buf.readerIndex() < length) { // Check if new message started int tag = buf.readUnsignedByte(); if (tags.contains(tag)) { - position.setExtendedInfo(extendedInfo.toString()); if (hasLocation && position.getFixTime() != null) { positions.add(position); } tags.clear(); hasLocation = false; position = new Position(); - extendedInfo = new ExtendedInfoFormatter(getProtocol()); } tags.add(tag); @@ -139,19 +135,19 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { break; case TAG_STATUS: - extendedInfo.set("status", buf.readUnsignedShort()); + position.set("status", buf.readUnsignedShort()); break; case TAG_POWER: - extendedInfo.set("power", buf.readUnsignedShort()); + position.set("power", buf.readUnsignedShort()); break; case TAG_BATTERY: - extendedInfo.set("battery", buf.readUnsignedShort()); + position.set("battery", buf.readUnsignedShort()); break; case TAG_MILAGE: - extendedInfo.set("milage", buf.readUnsignedInt()); + position.set("milage", buf.readUnsignedInt()); break; default: @@ -160,8 +156,6 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { } } - - position.setExtendedInfo(extendedInfo.toString()); if (hasLocation && position.getFixTime() != null) { positions.add(position); } diff --git a/src/org/traccar/protocol/GatorProtocolDecoder.java b/src/org/traccar/protocol/GatorProtocolDecoder.java index df92f96cb..d277b4b3d 100644 --- a/src/org/traccar/protocol/GatorProtocolDecoder.java +++ b/src/org/traccar/protocol/GatorProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -24,10 +23,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class GatorProtocolDecoder extends BaseProtocolDecoder { @@ -72,7 +68,7 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Identification if (!identify(id)) { @@ -100,24 +96,22 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder { // Flags int flags = buf.readUnsignedByte(); position.setValid((flags & 0x80) != 0); - extendedInfo.set("satellites", flags & 0x0f); + position.set("satellites", flags & 0x0f); // Status - extendedInfo.set("status", buf.readUnsignedByte()); + position.set("status", buf.readUnsignedByte()); // Key switch - extendedInfo.set("key", buf.readUnsignedByte()); + position.set("key", buf.readUnsignedByte()); // Oil - extendedInfo.set("oil", buf.readUnsignedShort() / 10.0); + position.set("oil", buf.readUnsignedShort() / 10.0); // Power - extendedInfo.set("power", buf.readUnsignedByte() + buf.readUnsignedByte() / 100.0); + position.set("power", buf.readUnsignedByte() + buf.readUnsignedByte() / 100.0); // Milage - extendedInfo.set("milage", buf.readUnsignedInt()); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("milage", buf.readUnsignedInt()); return position; } diff --git a/src/org/traccar/protocol/Gl100ProtocolDecoder.java b/src/org/traccar/protocol/Gl100ProtocolDecoder.java index fb64d8dda..04be88121 100644 --- a/src/org/traccar/protocol/Gl100ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl100ProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Gl100ProtocolDecoder extends BaseProtocolDecoder { @@ -77,7 +73,7 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -109,8 +105,6 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++))); time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++))); position.setTime(time.getTime()); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 7137ff975..dfff90e70 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Gl200ProtocolDecoder extends BaseProtocolDecoder { @@ -73,7 +69,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -122,19 +118,17 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // Cell information - extendedInfo.set("mcc", parser.group(index++)); - extendedInfo.set("mnc", parser.group(index++)); - extendedInfo.set("lac", parser.group(index++)); - extendedInfo.set("cell", parser.group(index++)); + position.set("mcc", parser.group(index++)); + position.set("mnc", parser.group(index++)); + position.set("lac", parser.group(index++)); + position.set("cell", parser.group(index++)); // Other String milage = parser.group(index++); if (milage != null && Double.valueOf(milage) != 0) { - extendedInfo.set("milage", milage); + position.set("milage", milage); } - extendedInfo.set("battery", parser.group(index++)); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("battery", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java index 1a0132c4a..05521c476 100644 --- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java +++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java @@ -26,9 +26,6 @@ import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; import org.traccar.Context; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { @@ -92,7 +89,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { // Parse data Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); for (int formatIndex = 0, valueIndex = 1; formatIndex < format.length() && valueIndex < values.length; formatIndex++) { String value = values[valueIndex]; @@ -170,7 +167,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(value)); break; case 'N': - extendedInfo.set("battery", value); + position.set("battery", value); break; default: // Unsupported @@ -179,8 +176,6 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { valueIndex += 1; } - - position.setExtendedInfo(extendedInfo.toString()); return position; } @@ -211,7 +206,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Identification @@ -258,12 +253,10 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(parser.group(index++))); // Satellites - extendedInfo.set("satellites", Integer.valueOf(parser.group(index++))); + position.set("satellites", Integer.valueOf(parser.group(index++))); // HDOP - extendedInfo.set("hdop", parser.group(index++)); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("hdop", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java index 3d981bb60..477845090 100644 --- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java +++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.net.SocketAddress; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,9 +25,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class GoSafeProtocolDecoder extends BaseProtocolDecoder { @@ -68,7 +64,7 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -108,10 +104,7 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(Double.valueOf(parser.group(index++))); position.setCourse(Double.valueOf(parser.group(index++))); position.setAltitude(Double.valueOf(parser.group(index++))); - extendedInfo.set("hdop", parser.group(index++)); - - // Extended info - position.setExtendedInfo(extendedInfo.toString()); + position.set("hdop", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/GotopProtocolDecoder.java b/src/org/traccar/protocol/GotopProtocolDecoder.java index 587b9180a..932a84f1b 100644 --- a/src/org/traccar/protocol/GotopProtocolDecoder.java +++ b/src/org/traccar/protocol/GotopProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class GotopProtocolDecoder extends BaseProtocolDecoder { @@ -63,7 +59,7 @@ public class GotopProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Get device by IMEI @@ -100,15 +96,13 @@ public class GotopProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(Double.valueOf(parser.group(index++)) * 0.539957); // Status - extendedInfo.set("status", parser.group(index++)); + position.set("status", parser.group(index++)); // Course String course = parser.group(index++); if (course != null) { position.setCourse(Double.valueOf(course)); } - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index f14f80239..3c0cc6726 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.net.SocketAddress; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,9 +25,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Gps103ProtocolDecoder extends BaseProtocolDecoder { @@ -94,7 +90,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -105,7 +101,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); // Alarm message - extendedInfo.set("alarm", parser.group(index++)); + position.set("alarm", parser.group(index++)); // Date Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -193,13 +189,10 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { } // Additional data - extendedInfo.set("io1", parser.group(index++)); - extendedInfo.set("io2", parser.group(index++)); - extendedInfo.set("io3", parser.group(index++)); - extendedInfo.set("io4", parser.group(index++)); - - // Extended info - position.setExtendedInfo(extendedInfo.toString()); + position.set("io1", parser.group(index++)); + position.set("io2", parser.group(index++)); + position.set("io3", parser.group(index++)); + position.set("io4", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/GpsGateProtocolDecoder.java b/src/org/traccar/protocol/GpsGateProtocolDecoder.java index 6b19fbe0a..14f665d18 100644 --- a/src/org/traccar/protocol/GpsGateProtocolDecoder.java +++ b/src/org/traccar/protocol/GpsGateProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,10 +24,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.Crc; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class GpsGateProtocolDecoder extends BaseProtocolDecoder { @@ -102,7 +98,7 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); Integer index = 1; @@ -147,8 +143,6 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); position.setTime(time.getTime()); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/Gt02ProtocolDecoder.java b/src/org/traccar/protocol/Gt02ProtocolDecoder.java index 5d2c9eb06..d5da01efb 100644 --- a/src/org/traccar/protocol/Gt02ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt02ProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Gt02ProtocolDecoder extends BaseProtocolDecoder { @@ -80,8 +76,8 @@ public class Gt02ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); - extendedInfo.set("index", index); + position.setProtocol(getProtocol()); + position.set("index", index); // Get device id if (!identify(imei)) { @@ -122,8 +118,6 @@ public class Gt02ProtocolDecoder extends BaseProtocolDecoder { position.setLatitude(latitude); position.setLongitude(longitude); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 73c3f6004..f2ccea794 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -21,10 +21,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; import org.traccar.Context; -import org.traccar.database.DataManager; import org.traccar.helper.Crc; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; import java.util.Calendar; @@ -145,7 +142,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(getDeviceId()); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Date and time Calendar time = Calendar.getInstance(timeZone); @@ -160,7 +157,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { // GPS length and Satellites count int gpsLength = buf.readUnsignedByte(); - extendedInfo.set("satellites", gpsLength & 0xf); + position.set("satellites", gpsLength & 0xf); gpsLength >>= 4; // Latitude @@ -183,7 +180,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(longitude); if ((union & 0x4000) != 0) { - extendedInfo.set("acc", (union & 0x8000) != 0); + position.set("acc", (union & 0x8000) != 0); } buf.skipBytes(gpsLength - 12); // skip reserved @@ -197,27 +194,27 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } // Cell information - extendedInfo.set("mcc", buf.readUnsignedShort()); - extendedInfo.set("mnc", buf.readUnsignedByte()); - extendedInfo.set("lac", buf.readUnsignedShort()); - extendedInfo.set("cell", buf.readUnsignedShort() << 8 + buf.readUnsignedByte()); + position.set("mcc", buf.readUnsignedShort()); + position.set("mnc", buf.readUnsignedByte()); + position.set("lac", buf.readUnsignedShort()); + position.set("cell", buf.readUnsignedShort() << 8 + buf.readUnsignedByte()); buf.skipBytes(lbsLength - 9); // Status if (type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2 || type == MSG_GPS_LBS_STATUS_3) { - extendedInfo.set("alarm", true); + position.set("alarm", true); int flags = buf.readUnsignedByte(); - extendedInfo.set("acc", (flags & 0x2) != 0); + position.set("acc", (flags & 0x2) != 0); // TODO parse other flags // Voltage - extendedInfo.set("power", buf.readUnsignedByte()); + position.set("power", buf.readUnsignedByte()); // GSM signal - extendedInfo.set("gsm", buf.readUnsignedByte()); + position.set("gsm", buf.readUnsignedByte()); } } @@ -226,10 +223,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(buf.readableBytes() - 6); } int index = buf.readUnsignedShort(); - extendedInfo.set("index", index); + position.set("index", index); sendResponse(channel, type, index); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index c4e8c232d..3d1eadf14 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.nio.charset.Charset; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,10 +26,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class H02ProtocolDecoder extends BaseProtocolDecoder { @@ -62,7 +58,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); buf.readByte(); // marker @@ -99,9 +95,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { position.setCourse((buf.readUnsignedByte() & 0x0f) * 100.0 + ChannelBufferTools.readHexInteger(buf, 2)); // Status - extendedInfo.set("status", ChannelBufferTools.readHexString(buf, 8)); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("status", ChannelBufferTools.readHexString(buf, 8)); return position; } @@ -132,7 +126,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -180,9 +174,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // Status - extendedInfo.set("status", parser.group(index++)); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("status", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/HaicomProtocolDecoder.java b/src/org/traccar/protocol/HaicomProtocolDecoder.java index fe33d44df..b685a40c5 100644 --- a/src/org/traccar/protocol/HaicomProtocolDecoder.java +++ b/src/org/traccar/protocol/HaicomProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class HaicomProtocolDecoder extends BaseProtocolDecoder { @@ -70,7 +66,7 @@ public class HaicomProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -81,7 +77,7 @@ public class HaicomProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); // Firmware version - extendedInfo.set("version", parser.group(index++)); + position.set("version", parser.group(index++)); // Date Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -117,15 +113,12 @@ public class HaicomProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(parser.group(index++)) / 10); // Additional data - extendedInfo.set("status", parser.group(index++)); - extendedInfo.set("gprs", parser.group(index++)); - extendedInfo.set("gps", parser.group(index++)); - extendedInfo.set("input", parser.group(index++)); - extendedInfo.set("output", parser.group(index++)); - extendedInfo.set("battery", Double.valueOf(parser.group(index++)) / 10); - - // Extended info - position.setExtendedInfo(extendedInfo.toString()); + position.set("status", parser.group(index++)); + position.set("gprs", parser.group(index++)); + position.set("gps", parser.group(index++)); + position.set("input", parser.group(index++)); + position.set("output", parser.group(index++)); + position.set("battery", Double.valueOf(parser.group(index++)) / 10); return position; } diff --git a/src/org/traccar/protocol/IntellitracProtocolDecoder.java b/src/org/traccar/protocol/IntellitracProtocolDecoder.java index 3b03a6b2d..c621b07e7 100644 --- a/src/org/traccar/protocol/IntellitracProtocolDecoder.java +++ b/src/org/traccar/protocol/IntellitracProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class IntellitracProtocolDecoder extends BaseProtocolDecoder { @@ -79,7 +75,7 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Detect device @@ -109,36 +105,34 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { // Satellites int satellites = Integer.valueOf(parser.group(index++)); position.setValid(satellites >= 3); - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); // Report identifier - extendedInfo.set("index", Long.valueOf(parser.group(index++))); + position.set("index", Long.valueOf(parser.group(index++))); // Input - extendedInfo.set("input", parser.group(index++)); + position.set("input", parser.group(index++)); // Output - extendedInfo.set("output", parser.group(index++)); + position.set("output", parser.group(index++)); // ADC1 - extendedInfo.set("adc1", parser.group(index++)); + position.set("adc1", parser.group(index++)); // ADC2 - extendedInfo.set("adc2", parser.group(index++)); + position.set("adc2", parser.group(index++)); // J1939 data - extendedInfo.set("vss", parser.group(index++)); - extendedInfo.set("rpm", parser.group(index++)); - extendedInfo.set("coolant", parser.group(index++)); - extendedInfo.set("fuel", parser.group(index++)); - extendedInfo.set("consumption", parser.group(index++)); - extendedInfo.set("temperature", parser.group(index++)); - extendedInfo.set("charger", parser.group(index++)); - extendedInfo.set("tpl", parser.group(index++)); - extendedInfo.set("axle", parser.group(index++)); - extendedInfo.set("milage", parser.group(index++)); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("vss", parser.group(index++)); + position.set("rpm", parser.group(index++)); + position.set("coolant", parser.group(index++)); + position.set("fuel", parser.group(index++)); + position.set("consumption", parser.group(index++)); + position.set("temperature", parser.group(index++)); + position.set("charger", parser.group(index++)); + position.set("tpl", parser.group(index++)); + position.set("axle", parser.group(index++)); + position.set("milage", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index e840db8b8..54110b101 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.nio.charset.Charset; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,10 +26,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Jt600ProtocolDecoder extends BaseProtocolDecoder { @@ -42,7 +38,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { private Position decodeNormalMessage(ChannelBuffer buf) throws Exception { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); buf.readByte(); // header @@ -96,33 +92,31 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { if (version == 1) { - extendedInfo.set("satellites", buf.readUnsignedByte()); + position.set("satellites", buf.readUnsignedByte()); // Power - extendedInfo.set("power", buf.readUnsignedByte()); + position.set("power", buf.readUnsignedByte()); buf.readByte(); // other flags and sensors // Altitude position.setAltitude(buf.readUnsignedShort()); - extendedInfo.set("cell", buf.readUnsignedShort()); - extendedInfo.set("lac", buf.readUnsignedShort()); - extendedInfo.set("gsm", buf.readUnsignedByte()); + position.set("cell", buf.readUnsignedShort()); + position.set("lac", buf.readUnsignedShort()); + position.set("gsm", buf.readUnsignedByte()); } else if (version == 2) { int fuel = buf.readUnsignedByte() << 8; - extendedInfo.set("status", buf.readUnsignedInt()); - extendedInfo.set("milage", buf.readUnsignedInt()); + position.set("status", buf.readUnsignedInt()); + position.set("milage", buf.readUnsignedInt()); fuel += buf.readUnsignedByte(); - extendedInfo.set("fuel", fuel); + position.set("fuel", fuel); } - - position.setExtendedInfo(extendedInfo.toString()); return position; } @@ -157,8 +151,8 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); - extendedInfo.set("alert", "true"); + position.setProtocol(getProtocol()); + position.set("alert", "true"); Integer index = 1; // Get device by identifier @@ -200,9 +194,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(parser.group(index++))); // Power - extendedInfo.set("power", Double.valueOf(parser.group(index++))); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("power", Double.valueOf(parser.group(index++))); return position; } diff --git a/src/org/traccar/protocol/KhdProtocolDecoder.java b/src/org/traccar/protocol/KhdProtocolDecoder.java index 39164c2ca..cb2cf161a 100644 --- a/src/org/traccar/protocol/KhdProtocolDecoder.java +++ b/src/org/traccar/protocol/KhdProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -25,11 +24,8 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; import org.traccar.helper.Crc; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class KhdProtocolDecoder extends BaseProtocolDecoder { @@ -76,7 +72,7 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Device identification if (!identify(readSerialNumber(buf))) { @@ -112,7 +108,7 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder { } else { // Milage - extendedInfo.set("milage", buf.readUnsignedMedium()); + position.set("milage", buf.readUnsignedMedium()); // Status buf.skipBytes(4); @@ -123,8 +119,6 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder { } // TODO: parse extra data - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java index 95c38ae97..efc6b0514 100644 --- a/src/org/traccar/protocol/LaipacProtocolDecoder.java +++ b/src/org/traccar/protocol/LaipacProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,10 +24,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.Crc; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class LaipacProtocolDecoder extends BaseProtocolDecoder { @@ -74,7 +70,7 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Identification @@ -137,8 +133,6 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { if (response != null && channel != null) { channel.write(response + "\r\n"); } - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/M2mProtocolDecoder.java b/src/org/traccar/protocol/M2mProtocolDecoder.java index 606f3b8ab..026a067b4 100644 --- a/src/org/traccar/protocol/M2mProtocolDecoder.java +++ b/src/org/traccar/protocol/M2mProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -24,9 +23,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class M2mProtocolDecoder extends BaseProtocolDecoder { @@ -73,7 +69,7 @@ public class M2mProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); // Date and time @@ -120,12 +116,10 @@ public class M2mProtocolDecoder extends BaseProtocolDecoder { if (satellites == 0) { return null; // cell information } - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); position.setValid(true); // TODO decode everything else - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/ManPowerProtocolDecoder.java b/src/org/traccar/protocol/ManPowerProtocolDecoder.java index 5e62c1cc9..840a1a032 100644 --- a/src/org/traccar/protocol/ManPowerProtocolDecoder.java +++ b/src/org/traccar/protocol/ManPowerProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class ManPowerProtocolDecoder extends BaseProtocolDecoder { @@ -67,7 +63,7 @@ public class ManPowerProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -78,7 +74,7 @@ public class ManPowerProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); // Alarm message - extendedInfo.set("status", parser.group(index++)); + position.set("status", parser.group(index++)); // Date Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -109,9 +105,6 @@ public class ManPowerProtocolDecoder extends BaseProtocolDecoder { // Speed position.setSpeed(Double.valueOf(parser.group(index++))); - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - return position; } diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java index f67a89726..77b1fb5ca 100644 --- a/src/org/traccar/protocol/MegastekProtocolDecoder.java +++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class MegastekProtocolDecoder extends BaseProtocolDecoder { @@ -174,7 +170,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Parse location data if (!parseGPRMC(gprmc, position)) { @@ -192,7 +188,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { int index = 1; // Alarm - extendedInfo.set("alarm", parser.group(index++)); + position.set("alarm", parser.group(index++)); // IMEI if (!identify(parser.group(index++), false)) { @@ -203,7 +199,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); // Satellites - extendedInfo.set("satellites", parser.group(index++)); + position.set("satellites", parser.group(index++)); // Altitude String altitude = parser.group(index++); @@ -212,17 +208,17 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { } // Battery - extendedInfo.set("power", Double.valueOf(parser.group(index++))); + position.set("power", Double.valueOf(parser.group(index++))); // Charger String charger = parser.group(index++); if (charger != null) { - extendedInfo.set("charger", Integer.valueOf(charger) == 1); + position.set("charger", Integer.valueOf(charger) == 1); } - extendedInfo.set("mcc", parser.group(index++)); - extendedInfo.set("mnc", parser.group(index++)); - extendedInfo.set("lac", parser.group(index++)); + position.set("mcc", parser.group(index++)); + position.set("mnc", parser.group(index++)); + position.set("lac", parser.group(index++)); } else { @@ -239,25 +235,23 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(getDeviceId()); - extendedInfo.set("mcc", parser.group(index++)); - extendedInfo.set("mnc", parser.group(index++)); - extendedInfo.set("lac", parser.group(index++)); - extendedInfo.set("gsm", parser.group(index++)); + position.set("mcc", parser.group(index++)); + position.set("mnc", parser.group(index++)); + position.set("lac", parser.group(index++)); + position.set("gsm", parser.group(index++)); // Battery - extendedInfo.set("battery", Double.valueOf(parser.group(index++))); + position.set("battery", Double.valueOf(parser.group(index++))); - extendedInfo.set("flags", parser.group(index++)); - extendedInfo.set("input", parser.group(index++)); - extendedInfo.set("output", parser.group(index++)); - extendedInfo.set("adc1", parser.group(index++)); - extendedInfo.set("adc2", parser.group(index++)); - extendedInfo.set("adc3", parser.group(index++)); - extendedInfo.set("alarm", parser.group(index++)); + position.set("flags", parser.group(index++)); + position.set("input", parser.group(index++)); + position.set("output", parser.group(index++)); + position.set("adc1", parser.group(index++)); + position.set("adc2", parser.group(index++)); + position.set("adc3", parser.group(index++)); + position.set("alarm", parser.group(index++)); } - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 648901678..d35a75885 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -30,10 +30,7 @@ import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; import org.traccar.Context; -import org.traccar.database.DataManager; import org.traccar.helper.Crc; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { @@ -170,11 +167,11 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Custom data if (command == MSG_ALARM) { - extendedInfo.set("alarm", buf.readUnsignedByte()); + position.set("alarm", buf.readUnsignedByte()); } else if (command == MSG_POSITION_LOGGED) { buf.skipBytes(6); } @@ -240,7 +237,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // Dilution of precision - extendedInfo.set("hdop", parser.group(index++)); + position.set("hdop", parser.group(index++)); // Altitude String altitude = parser.group(index++); @@ -251,38 +248,35 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { // State String state = parser.group(index++); if (state != null) { - extendedInfo.set("state", state); + position.set("state", state); } // ADC for (int i = 1; i <= 8; i++) { String adc = parser.group(index++); if (adc != null) { - extendedInfo.set("adc" + i, Integer.parseInt(adc, 16)); + position.set("adc" + i, Integer.parseInt(adc, 16)); } } // Cell identifier String cell = parser.group(index++); if (cell != null) { - extendedInfo.set("cell", cell); + position.set("cell", cell); } // GSM signal String gsm = parser.group(index++); if (gsm != null) { - extendedInfo.set("gsm", Integer.parseInt(gsm, 16)); + position.set("gsm", Integer.parseInt(gsm, 16)); } // Milage String milage = parser.group(index++); if (milage != null) { - extendedInfo.set("milage", Integer.parseInt(milage, 16)); + position.set("milage", Integer.parseInt(milage, 16)); } - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - return position; } diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index 25a86552c..d96afba01 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -20,7 +20,6 @@ import java.util.Calendar; import java.util.Date; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -30,10 +29,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class MeitrackProtocolDecoder extends BaseProtocolDecoder { @@ -86,7 +82,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -98,7 +94,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { // Event int event = Integer.valueOf(parser.group(index++)); - extendedInfo.set("event", event); + position.set("event", event); // Coordinates position.setLatitude(Double.valueOf(parser.group(index++))); @@ -119,10 +115,10 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { position.setValid(parser.group(index++).compareTo("A") == 0); // Satellites - extendedInfo.set("satellites", parser.group(index++)); + position.set("satellites", parser.group(index++)); // GSM Signal - extendedInfo.set("gsm", parser.group(index++)); + position.set("gsm", parser.group(index++)); // Speed position.setSpeed(Double.valueOf(parser.group(index++)) * 0.539957); @@ -131,39 +127,39 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(parser.group(index++))); // HDOP - extendedInfo.set("hdop", parser.group(index++)); + position.set("hdop", parser.group(index++)); // Altitude position.setAltitude(Double.valueOf(parser.group(index++))); // Other - extendedInfo.set("milage", parser.group(index++)); - extendedInfo.set("runtime", parser.group(index++)); - extendedInfo.set("cell", parser.group(index++)); - extendedInfo.set("state", parser.group(index++)); + position.set("milage", parser.group(index++)); + position.set("runtime", parser.group(index++)); + position.set("cell", parser.group(index++)); + position.set("state", parser.group(index++)); // ADC String adc1 = parser.group(index++); if (adc1 != null) { - extendedInfo.set("adc1", Integer.parseInt(adc1, 16)); + position.set("adc1", Integer.parseInt(adc1, 16)); } String adc2 = parser.group(index++); if (adc2 != null) { - extendedInfo.set("adc2", Integer.parseInt(adc2, 16)); + position.set("adc2", Integer.parseInt(adc2, 16)); } String adc3 = parser.group(index++); if (adc3 != null) { - extendedInfo.set("adc3", Integer.parseInt(adc3, 16)); + position.set("adc3", Integer.parseInt(adc3, 16)); } - extendedInfo.set("battery", Integer.parseInt(parser.group(index++), 16)); - extendedInfo.set("power", Integer.parseInt(parser.group(index++), 16)); + position.set("battery", Integer.parseInt(parser.group(index++), 16)); + position.set("power", Integer.parseInt(parser.group(index++), 16)); // Event specific String data = parser.group(index++); if (data != null && !data.isEmpty()) { switch (event) { case 37: - extendedInfo.set("rfid", data); + position.set("rfid", data); break; } } @@ -171,13 +167,10 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { // Fuel String fuel = parser.group(index++); if (fuel != null) { - extendedInfo.set("fuel", + position.set("fuel", Integer.parseInt(fuel.substring(0, 2), 16) + Integer.parseInt(fuel.substring(2), 16) * 0.01); } - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - return position; } @@ -198,11 +191,11 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { while (buf.readableBytes() >= 0x34) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); // Event - extendedInfo.set("event", buf.readUnsignedByte()); + position.set("event", buf.readUnsignedByte()); // Location position.setLatitude(buf.readInt() * 0.000001); @@ -215,10 +208,10 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { position.setValid(buf.readUnsignedByte() == 1); // Satellites - extendedInfo.set("satellites", buf.readUnsignedByte()); + position.set("satellites", buf.readUnsignedByte()); // GSM Signal - extendedInfo.set("gsm", buf.readUnsignedByte()); + position.set("gsm", buf.readUnsignedByte()); // Speed position.setSpeed(buf.readUnsignedShort() * 0.539957); @@ -227,27 +220,25 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { position.setCourse(buf.readUnsignedShort()); // HDOP - extendedInfo.set("hdop", buf.readUnsignedShort() * 0.1); + position.set("hdop", buf.readUnsignedShort() * 0.1); // Altitude position.setAltitude(buf.readUnsignedShort()); // Other - extendedInfo.set("milage", buf.readUnsignedInt()); - extendedInfo.set("runtime", buf.readUnsignedInt()); - extendedInfo.set("cell", + position.set("milage", buf.readUnsignedInt()); + position.set("runtime", buf.readUnsignedInt()); + position.set("cell", buf.readUnsignedShort() + "|" + buf.readUnsignedShort() + "|" + buf.readUnsignedShort() + "|" + buf.readUnsignedShort()); - extendedInfo.set("state", buf.readUnsignedShort()); + position.set("state", buf.readUnsignedShort()); // ADC - extendedInfo.set("adc1", buf.readUnsignedShort()); - extendedInfo.set("battery", buf.readUnsignedShort() * 0.01); - extendedInfo.set("power", buf.readUnsignedShort()); + position.set("adc1", buf.readUnsignedShort()); + position.set("battery", buf.readUnsignedShort() * 0.01); + position.set("power", buf.readUnsignedShort()); buf.readUnsignedInt(); // geo-fence - - position.setExtendedInfo(extendedInfo.toString()); positions.add(position); } diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java index c37e44659..09e8dcafe 100644 --- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java +++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { @@ -74,7 +70,7 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); Integer index = 1; @@ -98,19 +94,17 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { // Flags String flags = parser.group(index++); - extendedInfo.set("flags", flags); + position.set("flags", flags); position.setValid((Integer.parseInt(flags, 16) & 0x01) != 0); // Altitude position.setAltitude(Double.valueOf(parser.group(index++))); // Battery - extendedInfo.set("battery", parser.group(index++)); + position.set("battery", parser.group(index++)); // Satellites - extendedInfo.set("satellites", parser.group(index++)); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("satellites", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java index 72c23637e..69b3ee673 100644 --- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java +++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java @@ -20,7 +20,6 @@ import java.util.Calendar; import java.util.Date; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -34,10 +33,7 @@ import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.jboss.netty.handler.codec.http.HttpVersion; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Mta6ProtocolDecoder extends BaseProtocolDecoder { @@ -132,7 +128,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { while (buf.readable()) { Position position = new Position(); position.setDeviceId(getDeviceId()); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); short flags = buf.readUnsignedByte(); @@ -166,43 +162,41 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { } if (checkBit(flags, 3)) { - extendedInfo.set("milage", buf.readUnsignedShort()); + position.set("milage", buf.readUnsignedShort()); } if (checkBit(flags, 4)) { - extendedInfo.set("fuel1", buf.readUnsignedInt()); - extendedInfo.set("fuel2", buf.readUnsignedInt()); - extendedInfo.set("hours1", buf.readUnsignedShort()); - extendedInfo.set("hours2", buf.readUnsignedShort()); + position.set("fuel1", buf.readUnsignedInt()); + position.set("fuel2", buf.readUnsignedInt()); + position.set("hours1", buf.readUnsignedShort()); + position.set("hours2", buf.readUnsignedShort()); } if (checkBit(flags, 5)) { - extendedInfo.set("adc1", buf.readUnsignedShort() & 0x03ff); - extendedInfo.set("adc2", buf.readUnsignedShort() & 0x03ff); - extendedInfo.set("adc3", buf.readUnsignedShort() & 0x03ff); - extendedInfo.set("adc4", buf.readUnsignedShort() & 0x03ff); + position.set("adc1", buf.readUnsignedShort() & 0x03ff); + position.set("adc2", buf.readUnsignedShort() & 0x03ff); + position.set("adc3", buf.readUnsignedShort() & 0x03ff); + position.set("adc4", buf.readUnsignedShort() & 0x03ff); } if (checkBit(flags, 6)) { - extendedInfo.set("temperature", buf.readByte()); + position.set("temperature", buf.readByte()); buf.getUnsignedByte(buf.readerIndex()); // control (>> 4) - extendedInfo.set("sensor", buf.readUnsignedShort() & 0x0fff); + position.set("sensor", buf.readUnsignedShort() & 0x0fff); buf.readUnsignedShort(); // old sensor state (& 0x0fff) } if (checkBit(flags, 7)) { - extendedInfo.set("battery", buf.getUnsignedByte(buf.readerIndex()) >> 2); - extendedInfo.set("power", buf.readUnsignedShort() & 0x03ff); + position.set("battery", buf.getUnsignedByte(buf.readerIndex()) >> 2); + position.set("power", buf.readUnsignedShort() & 0x03ff); buf.readByte(); // microcontroller temperature - extendedInfo.set("gsm", (buf.getUnsignedByte(buf.readerIndex()) >> 4) & 0x07); + position.set("gsm", (buf.getUnsignedByte(buf.readerIndex()) >> 4) & 0x07); int satellites = buf.readUnsignedByte() & 0x0f; position.setValid(satellites >= 3); - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); } - - position.setExtendedInfo(extendedInfo.toString()); positions.add(position); } } catch (IndexOutOfBoundsException error) { @@ -214,7 +208,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { private Position parseFormatA1(ChannelBuffer buf) { Position position = new Position(); position.setDeviceId(getDeviceId()); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); short flags = buf.readUnsignedByte(); @@ -240,52 +234,50 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { position.setAltitude(buf.readUnsignedShort()); position.setSpeed(buf.readUnsignedByte()); position.setCourse(buf.readByte()); - extendedInfo.set("milage", new FloatReader().readFloat(buf)); + position.set("milage", new FloatReader().readFloat(buf)); } if (checkBit(flags, 1)) { new FloatReader().readFloat(buf); // fuel consumtion - extendedInfo.set("hours", new FloatReader().readFloat(buf)); - extendedInfo.set("tank", buf.readUnsignedByte() * 0.4); + position.set("hours", new FloatReader().readFloat(buf)); + position.set("tank", buf.readUnsignedByte() * 0.4); } if (checkBit(flags, 2)) { - extendedInfo.set("engine", buf.readUnsignedShort() * 0.125); - extendedInfo.set("pedals", buf.readUnsignedByte()); - extendedInfo.set("temperature", buf.readUnsignedByte() - 40); + position.set("engine", buf.readUnsignedShort() * 0.125); + position.set("pedals", buf.readUnsignedByte()); + position.set("temperature", buf.readUnsignedByte() - 40); buf.readUnsignedShort(); // service milage } if (checkBit(flags, 3)) { - extendedInfo.set("fuel", buf.readUnsignedShort()); - extendedInfo.set("adc2", buf.readUnsignedShort()); - extendedInfo.set("adc3", buf.readUnsignedShort()); - extendedInfo.set("adc4", buf.readUnsignedShort()); + position.set("fuel", buf.readUnsignedShort()); + position.set("adc2", buf.readUnsignedShort()); + position.set("adc3", buf.readUnsignedShort()); + position.set("adc4", buf.readUnsignedShort()); } if (checkBit(flags, 4)) { - extendedInfo.set("temperature", buf.readByte()); + position.set("temperature", buf.readByte()); buf.getUnsignedByte(buf.readerIndex()); // control (>> 4) - extendedInfo.set("sensor", buf.readUnsignedShort() & 0x0fff); + position.set("sensor", buf.readUnsignedShort() & 0x0fff); buf.readUnsignedShort(); // old sensor state (& 0x0fff) } if (checkBit(flags, 5)) { - extendedInfo.set("battery", buf.getUnsignedByte(buf.readerIndex()) >> 2); - extendedInfo.set("power", buf.readUnsignedShort() & 0x03ff); + position.set("battery", buf.getUnsignedByte(buf.readerIndex()) >> 2); + position.set("power", buf.readUnsignedShort() & 0x03ff); buf.readByte(); // microcontroller temperature - extendedInfo.set("gsm", buf.getUnsignedByte(buf.readerIndex()) >> 5); + position.set("gsm", buf.getUnsignedByte(buf.readerIndex()) >> 5); int satellites = buf.readUnsignedByte() & 0x1f; position.setValid(satellites >= 3); - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); } // TODO: process other data - position.setExtendedInfo(extendedInfo.toString()); - return position; } diff --git a/src/org/traccar/protocol/MtxProtocolDecoder.java b/src/org/traccar/protocol/MtxProtocolDecoder.java index 713193c49..809b26c25 100644 --- a/src/org/traccar/protocol/MtxProtocolDecoder.java +++ b/src/org/traccar/protocol/MtxProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class MtxProtocolDecoder extends BaseProtocolDecoder { @@ -74,7 +70,7 @@ public class MtxProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -103,12 +99,11 @@ public class MtxProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(parser.group(index++))); // Other - extendedInfo.set("milage", Double.valueOf(parser.group(index++))); - extendedInfo.set("input", parser.group(index++)); - extendedInfo.set("output", parser.group(index++)); - extendedInfo.set("adc1", parser.group(index++)); - extendedInfo.set("adc2", parser.group(index++)); - position.setExtendedInfo(extendedInfo.toString()); + position.set("milage", Double.valueOf(parser.group(index++))); + position.set("input", parser.group(index++)); + position.set("output", parser.group(index++)); + position.set("adc1", parser.group(index++)); + position.set("adc2", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/NavigilProtocolDecoder.java b/src/org/traccar/protocol/NavigilProtocolDecoder.java index 501f1bb39..76859aa05 100644 --- a/src/org/traccar/protocol/NavigilProtocolDecoder.java +++ b/src/org/traccar/protocol/NavigilProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.nio.ByteOrder; import java.util.Date; -import java.util.Properties; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; @@ -25,10 +24,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.Crc; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class NavigilProtocolDecoder extends BaseProtocolDecoder { @@ -83,10 +79,10 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { private Position parseUnitReport(ChannelBuffer buf, int sequenceNumber) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setValid(true); - extendedInfo.set("index", sequenceNumber); + position.set("index", sequenceNumber); position.setDeviceId(getDeviceId()); buf.readUnsignedShort(); // report trigger @@ -106,24 +102,22 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedInt(); // distance buf.readUnsignedInt(); // delta distance - extendedInfo.set("battery", buf.readUnsignedShort() * 0.001); + position.set("battery", buf.readUnsignedShort() * 0.001); buf.readUnsignedShort(); // battery charger status position.setTime(convertTimestamp(buf.readUnsignedInt())); // TODO: a lot of other stuff - - position.setExtendedInfo(extendedInfo.toString()); return position; } private Position parseTg2Report(ChannelBuffer buf, int sequenceNumber) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setValid(true); - extendedInfo.set("index", sequenceNumber); + position.set("index", sequenceNumber); position.setDeviceId(getDeviceId()); buf.readUnsignedShort(); // report trigger @@ -149,19 +143,17 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedShort(); // VSAUT1 voltage buf.readUnsignedShort(); // VSAUT2 voltage buf.readUnsignedShort(); // solar voltage - extendedInfo.set("battery", buf.readUnsignedShort() * 0.001); + position.set("battery", buf.readUnsignedShort() * 0.001); // TODO: a lot of other stuff - - position.setExtendedInfo(extendedInfo.toString()); return position; } private Position parsePositionReport(ChannelBuffer buf, int sequenceNumber, long timestamp) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); - extendedInfo.set("index", sequenceNumber); + position.set("index", sequenceNumber); position.setDeviceId(getDeviceId()); position.setTime(convertTimestamp(timestamp)); @@ -175,16 +167,14 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { position.setValid((flags & 0x80) == 0x80 && (flags & 0x40) == 0x40); buf.readUnsignedByte(); // reserved - - position.setExtendedInfo(extendedInfo.toString()); return position; } private Position parsePositionReport2(ChannelBuffer buf, int sequenceNumber, long timestamp) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); - extendedInfo.set("index", sequenceNumber); + position.set("index", sequenceNumber); position.setDeviceId(getDeviceId()); position.setTime(convertTimestamp(timestamp)); @@ -200,16 +190,14 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { int x = buf.readUnsignedByte(); // satellites in fix buf.readUnsignedInt(); // distance - - position.setExtendedInfo(extendedInfo.toString()); return position; } private Position parseSnapshot4(ChannelBuffer buf, int sequenceNumber) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); - extendedInfo.set("index", sequenceNumber); + position.set("index", sequenceNumber); position.setDeviceId(getDeviceId()); buf.readUnsignedByte(); // report trigger @@ -238,19 +226,17 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // supply voltage 1 buf.readUnsignedByte(); // supply voltage 2 - extendedInfo.set("battery", buf.readUnsignedShort() * 0.001); + position.set("battery", buf.readUnsignedShort() * 0.001); // TODO: a lot of other stuff - - position.setExtendedInfo(extendedInfo.toString()); return position; } private Position parseTrackingData(ChannelBuffer buf, int sequenceNumber, long timestamp) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); - extendedInfo.set("index", sequenceNumber); + position.set("index", sequenceNumber); position.setDeviceId(getDeviceId()); position.setTime(convertTimestamp(timestamp)); @@ -269,11 +255,9 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // satellites in fix - extendedInfo.set("battery", buf.readUnsignedShort() * 0.001); + position.set("battery", buf.readUnsignedShort() * 0.001); buf.readUnsignedInt(); // distance - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java index e98b8d15a..1407a16db 100644 --- a/src/org/traccar/protocol/NavisProtocolDecoder.java +++ b/src/org/traccar/protocol/NavisProtocolDecoder.java @@ -28,7 +28,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class NavisProtocolDecoder extends BaseProtocolDecoder { @@ -80,7 +79,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { private ParseResult parsePosition(ChannelBuffer buf) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); @@ -91,13 +90,13 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { } else { format = buf.readUnsignedByte(); } - extendedInfo.set("format", format); + position.set("format", format); long index = buf.readUnsignedInt(); - extendedInfo.set("index", index); + position.set("index", index); // Event type - extendedInfo.set("event", buf.readUnsignedShort()); + position.set("event", buf.readUnsignedShort()); // Event time Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -108,44 +107,44 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.DAY_OF_MONTH, buf.readUnsignedByte()); time.set(Calendar.MONTH, buf.readUnsignedByte()); time.set(Calendar.YEAR, 2000 + buf.readUnsignedByte()); - extendedInfo.set("time", time.getTimeInMillis()); + position.set("time", time.getTimeInMillis()); // Alarm status - extendedInfo.set("alarm", buf.readUnsignedByte()); + position.set("alarm", buf.readUnsignedByte()); // Modules status - extendedInfo.set("status", buf.readUnsignedByte()); + position.set("status", buf.readUnsignedByte()); // GSM signal - extendedInfo.set("gsm", buf.readUnsignedByte()); + position.set("gsm", buf.readUnsignedByte()); // Output if (isFormat(format, F10, F20, F30)) { - extendedInfo.set("output", buf.readUnsignedShort()); + position.set("output", buf.readUnsignedShort()); } else if (isFormat(format, F40, F50, F51, F52)) { - extendedInfo.set("output", buf.readUnsignedByte()); + position.set("output", buf.readUnsignedByte()); } // Input if (isFormat(format, F10, F20, F30, F40)) { - extendedInfo.set("input", buf.readUnsignedShort()); + position.set("input", buf.readUnsignedShort()); } else if (isFormat(format, F50, F51, F52)) { - extendedInfo.set("input", buf.readUnsignedByte()); + position.set("input", buf.readUnsignedByte()); } - extendedInfo.set("power", buf.readUnsignedShort() / 1000.0); + position.set("power", buf.readUnsignedShort() / 1000.0); // Battery power - extendedInfo.set("battery", buf.readUnsignedShort()); + position.set("battery", buf.readUnsignedShort()); // Temperature if (isFormat(format, F10, F20, F30)) { - extendedInfo.set("temperature", buf.readShort()); + position.set("temperature", buf.readShort()); } if (isFormat(format, F10, F20, F50, F52)) { - extendedInfo.set("adc1", buf.readUnsignedShort()); - extendedInfo.set("adc2", buf.readUnsignedShort()); + position.set("adc1", buf.readUnsignedShort()); + position.set("adc2", buf.readUnsignedShort()); } if (isFormat(format, F20, F50, F51, F52)) { @@ -176,10 +175,10 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { position.setCourse(buf.readUnsignedShort()); // Milage - extendedInfo.set("milage", buf.readFloat()); + position.set("milage", buf.readFloat()); // Last segment - extendedInfo.set("segment", buf.readFloat()); + position.set("segment", buf.readFloat()); // Segment times buf.readUnsignedShort(); @@ -207,9 +206,6 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { buf.readByte(); } - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - return new ParseResult(index, position); } diff --git a/src/org/traccar/protocol/NoranProtocolDecoder.java b/src/org/traccar/protocol/NoranProtocolDecoder.java index 5021f6cd4..a93f16872 100644 --- a/src/org/traccar/protocol/NoranProtocolDecoder.java +++ b/src/org/traccar/protocol/NoranProtocolDecoder.java @@ -19,7 +19,6 @@ import java.net.SocketAddress; import java.nio.ByteOrder; import java.nio.charset.Charset; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -28,9 +27,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class NoranProtocolDecoder extends BaseProtocolDecoder { @@ -76,7 +72,7 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); if (type == MSG_CONTROL_RESPONSE) { buf.readUnsignedInt(); // GIS ip @@ -88,7 +84,7 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder { position.setValid((flags & 0x01) != 0); // Alarm type - extendedInfo.set("alarm", buf.readUnsignedByte()); + position.set("alarm", buf.readUnsignedByte()); // Location position.setSpeed(buf.readUnsignedByte()); @@ -116,12 +112,10 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); // IO status - extendedInfo.set("io", buf.readUnsignedByte()); + position.set("io", buf.readUnsignedByte()); // Fuel - extendedInfo.set("fuel", buf.readUnsignedByte()); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("fuel", buf.readUnsignedByte()); return position; } diff --git a/src/org/traccar/protocol/OrionProtocolDecoder.java b/src/org/traccar/protocol/OrionProtocolDecoder.java index fdcbe23b6..3c533664b 100644 --- a/src/org/traccar/protocol/OrionProtocolDecoder.java +++ b/src/org/traccar/protocol/OrionProtocolDecoder.java @@ -18,7 +18,6 @@ package org.traccar.protocol; import java.util.Calendar; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -27,9 +26,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class OrionProtocolDecoder extends BaseProtocolDecoder { @@ -86,12 +82,12 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(getDeviceId()); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); - extendedInfo.set("event", buf.readUnsignedByte()); + position.set("event", buf.readUnsignedByte()); buf.readUnsignedByte(); // length - extendedInfo.set("flag1", buf.readUnsignedByte()); - extendedInfo.set("flag2", buf.readUnsignedByte()); + position.set("flag1", buf.readUnsignedByte()); + position.set("flag2", buf.readUnsignedByte()); // Location position.setLatitude(convertCoordinate(buf.readInt())); @@ -113,10 +109,8 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder { // Accuracy int satellites = buf.readUnsignedByte(); - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); position.setValid(satellites >= 3); - - position.setExtendedInfo(extendedInfo.toString()); positions.add(position); } diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index 11966e0bd..e6b5476b1 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -21,7 +21,6 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Map; -import java.util.Properties; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelFutureListener; @@ -34,9 +33,6 @@ import org.jboss.netty.handler.codec.http.HttpVersion; import org.jboss.netty.handler.codec.http.QueryStringDecoder; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class OsmAndProtocolDecoder extends BaseProtocolDecoder { @@ -61,7 +57,7 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Identification String id = params.get(params.containsKey("id") ? "id" : "deviceid").get(0); @@ -101,27 +97,25 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { } if (params.containsKey("hdop")) { - extendedInfo.set("hdop", params.get("hdop").get(0)); + position.set("hdop", params.get("hdop").get(0)); } if (params.containsKey("vacc")) { - extendedInfo.set("vacc", params.get("vacc").get(0)); + position.set("vacc", params.get("vacc").get(0)); } if (params.containsKey("hacc")) { - extendedInfo.set("hacc", params.get("hacc").get(0)); + position.set("hacc", params.get("hacc").get(0)); } if (params.containsKey("batt")) { - extendedInfo.set("battery", params.get("batt").get(0)); + position.set("battery", params.get("batt").get(0)); } if (params.containsKey("desc")) { - extendedInfo.set("description", params.get("desc").get(0)); + position.set("description", params.get("desc").get(0)); } - position.setExtendedInfo(extendedInfo.toString()); - // Send response if (channel != null) { HttpResponse response = new DefaultHttpResponse( diff --git a/src/org/traccar/protocol/PiligrimProtocolDecoder.java b/src/org/traccar/protocol/PiligrimProtocolDecoder.java index 652b2cd37..f4eafd833 100644 --- a/src/org/traccar/protocol/PiligrimProtocolDecoder.java +++ b/src/org/traccar/protocol/PiligrimProtocolDecoder.java @@ -20,7 +20,6 @@ import java.nio.charset.Charset; import java.util.Calendar; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -35,9 +34,6 @@ import org.jboss.netty.handler.codec.http.HttpVersion; import org.jboss.netty.handler.codec.http.QueryStringDecoder; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class PiligrimProtocolDecoder extends BaseProtocolDecoder { @@ -102,7 +98,7 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder { if (type == MSG_GPS || type == MSG_GPS_SENSORS) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); // Time @@ -137,7 +133,7 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder { // Satellites int satellites = buf.readUnsignedByte(); - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); position.setValid(satellites >= 3); // Speed @@ -155,18 +151,16 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder { // External power double power = buf.readUnsignedByte(); power += buf.readUnsignedByte() << 8; - extendedInfo.set("power", power / 100); + position.set("power", power / 100); // Battery double battery = buf.readUnsignedByte(); battery += buf.readUnsignedByte() << 8; - extendedInfo.set("battery", battery / 100); + position.set("battery", battery / 100); buf.skipBytes(6); } - - position.setExtendedInfo(extendedInfo.toString()); positions.add(position); } else if (type == MSG_EVENTS) { diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java index 95fda1f48..2678c3c90 100644 --- a/src/org/traccar/protocol/ProgressProtocolDecoder.java +++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java @@ -20,7 +20,6 @@ import java.nio.charset.Charset; import java.util.Calendar; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -29,9 +28,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class ProgressProtocolDecoder extends BaseProtocolDecoder { @@ -118,22 +114,22 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { for (int j = 0; j < recordCount; j++) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); // Message index if (type == MSG_LOGMSG) { - extendedInfo.set("archive", true); + position.set("archive", true); int subtype = buf.readUnsignedShort(); if (subtype == MSG_ALARM) { - extendedInfo.set("alarm", true); + position.set("alarm", true); } if (buf.readUnsignedShort() > buf.readableBytes()) { lastIndex += 1; break; // workaround for device bug } lastIndex = buf.readUnsignedInt(); - extendedInfo.set("index", lastIndex); + position.set("index", lastIndex); } else { newIndex = buf.readUnsignedInt(); } @@ -161,16 +157,16 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { // Satellites int satellitesNumber = buf.readUnsignedByte(); - extendedInfo.set("satellites", satellitesNumber); + position.set("satellites", satellitesNumber); // Validity position.setValid(satellitesNumber >= 3); // TODO: probably wrong // Cell signal - extendedInfo.set("gsm", buf.readUnsignedByte()); + position.set("gsm", buf.readUnsignedByte()); // Milage - extendedInfo.set("milage", buf.readUnsignedInt()); + position.set("milage", buf.readUnsignedInt()); long extraFlags = buf.readLong(); @@ -178,7 +174,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { if ((extraFlags & 0x1) == 0x1) { int count = buf.readUnsignedShort(); for (int i = 1; i <= count; i++) { - extendedInfo.set("adc" + i, buf.readUnsignedShort()); + position.set("adc" + i, buf.readUnsignedShort()); } } @@ -186,7 +182,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { // CAN adapter if ((extraFlags & 0x2) == 0x2) { int size = buf.readUnsignedShort(); - extendedInfo.set("can", buf.toString(buf.readerIndex(), size, Charset.defaultCharset())); + position.set("can", buf.toString(buf.readerIndex(), size, Charset.defaultCharset())); buf.skipBytes(size); } @@ -202,7 +198,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { hex.append(HEX_CHARS.charAt((b & 0x0F))); } - extendedInfo.set("passenger", hex); + position.set("passenger", hex); buf.skipBytes(size); } @@ -212,15 +208,12 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { byte[] response = {(byte)0xC9,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; channel.write(ChannelBuffers.wrappedBuffer(response)); - extendedInfo.set("alarm", true); + position.set("alarm", true); } // Skip CRC buf.readUnsignedInt(); - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - positions.add(position); } diff --git a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java index 125afc287..bef5f138d 100644 --- a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Pt3000ProtocolDecoder extends BaseProtocolDecoder { @@ -65,7 +61,7 @@ public class Pt3000ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -114,8 +110,6 @@ public class Pt3000ProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); position.setTime(time.getTime()); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java index 702fdfd27..6647f7e20 100644 --- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,9 +25,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Pt502ProtocolDecoder extends BaseProtocolDecoder { @@ -66,7 +62,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -121,9 +117,6 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); position.setTime(time.getTime()); - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - return position; } } diff --git a/src/org/traccar/protocol/RitiProtocolDecoder.java b/src/org/traccar/protocol/RitiProtocolDecoder.java index fa98398a9..06aa39a71 100644 --- a/src/org/traccar/protocol/RitiProtocolDecoder.java +++ b/src/org/traccar/protocol/RitiProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.nio.charset.Charset; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,10 +26,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class RitiProtocolDecoder extends BaseProtocolDecoder { @@ -61,7 +57,7 @@ public class RitiProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); buf.skipBytes(2); // header @@ -71,16 +67,16 @@ public class RitiProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(getDeviceId()); - extendedInfo.set("mode", buf.readUnsignedByte()); - extendedInfo.set("command", buf.readUnsignedByte()); - extendedInfo.set("power", buf.readUnsignedShort()); + position.set("mode", buf.readUnsignedByte()); + position.set("command", buf.readUnsignedByte()); + position.set("power", buf.readUnsignedShort()); buf.skipBytes(5); buf.readUnsignedShort(); buf.readUnsignedShort(); - extendedInfo.set("distance", buf.readUnsignedInt()); - extendedInfo.set("milage", buf.readUnsignedInt()); + position.set("distance", buf.readUnsignedInt()); + position.set("milage", buf.readUnsignedInt()); // Parse GPRMC Integer end = ChannelBufferTools.find(buf, buf.readerIndex(), buf.readerIndex() + 80, "*"); @@ -132,8 +128,6 @@ public class RitiProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); position.setTime(time.getTime()); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/org/traccar/protocol/RuptelaProtocolDecoder.java index b83d9f721..c68a7cedd 100644 --- a/src/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -18,7 +18,6 @@ package org.traccar.protocol; import java.util.Date; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; @@ -26,9 +25,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class RuptelaProtocolDecoder extends BaseProtocolDecoder { @@ -63,7 +59,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { for (int i = 0; i < count; i++) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); // Time @@ -80,40 +76,38 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { // Validity int satellites = buf.readUnsignedByte(); - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); position.setValid(satellites >= 3); position.setSpeed(buf.readUnsignedShort() * 0.539957); - extendedInfo.set("hdop", buf.readUnsignedByte() / 10.0); + position.set("hdop", buf.readUnsignedByte() / 10.0); buf.readUnsignedByte(); // Read 1 byte data int cnt = buf.readUnsignedByte(); for (int j = 0; j < cnt; j++) { - extendedInfo.set("io" + buf.readUnsignedByte(), buf.readUnsignedByte()); + position.set("io" + buf.readUnsignedByte(), buf.readUnsignedByte()); } // Read 2 byte data cnt = buf.readUnsignedByte(); for (int j = 0; j < cnt; j++) { - extendedInfo.set("io" + buf.readUnsignedByte(), buf.readUnsignedShort()); + position.set("io" + buf.readUnsignedByte(), buf.readUnsignedShort()); } // Read 4 byte data cnt = buf.readUnsignedByte(); for (int j = 0; j < cnt; j++) { - extendedInfo.set("io" + buf.readUnsignedByte(), buf.readUnsignedInt()); + position.set("io" + buf.readUnsignedByte(), buf.readUnsignedInt()); } // Read 8 byte data cnt = buf.readUnsignedByte(); for (int j = 0; j < cnt; j++) { - extendedInfo.set("io" + buf.readUnsignedByte(), buf.readLong()); + position.set("io" + buf.readUnsignedByte(), buf.readLong()); } - - position.setExtendedInfo(extendedInfo.toString()); positions.add(position); } diff --git a/src/org/traccar/protocol/SanavProtocolDecoder.java b/src/org/traccar/protocol/SanavProtocolDecoder.java index c29762075..0e84832de 100644 --- a/src/org/traccar/protocol/SanavProtocolDecoder.java +++ b/src/org/traccar/protocol/SanavProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class SanavProtocolDecoder extends BaseProtocolDecoder { @@ -65,7 +61,7 @@ public class SanavProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Identification @@ -111,8 +107,6 @@ public class SanavProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); position.setTime(time.getTime()); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java index 6fdacb871..09eacacd3 100644 --- a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java +++ b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.nio.charset.Charset; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -25,9 +24,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { @@ -79,11 +76,11 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Status code if (checkBit(mask, 1)) { - extendedInfo.set("status", buf.readUnsignedInt()); + position.set("status", buf.readUnsignedInt()); } // Device id @@ -174,7 +171,7 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { // Satellites if (checkBit(mask, 16)) { - extendedInfo.set("satellites", buf.readUnsignedByte()); + position.set("satellites", buf.readUnsignedByte()); } // Battery percentage @@ -184,12 +181,12 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { // Trip milage if (checkBit(mask, 20)) { - extendedInfo.set("trip", buf.readUnsignedInt()); + position.set("trip", buf.readUnsignedInt()); } // Milage if (checkBit(mask, 21)) { - extendedInfo.set("milage", buf.readUnsignedInt()); + position.set("milage", buf.readUnsignedInt()); } // Time of message generation @@ -199,7 +196,7 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { // Battery level if (checkBit(mask, 24)) { - extendedInfo.set("power", buf.readUnsignedShort() / 1000.0); + position.set("power", buf.readUnsignedShort() / 1000.0); } // GPS overspeed @@ -214,12 +211,9 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { // Sequence number if (checkBit(mask, 28)) { - extendedInfo.set("index", buf.readUnsignedShort()); + position.set("index", buf.readUnsignedShort()); } - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - return position; } diff --git a/src/org/traccar/protocol/Stl060ProtocolDecoder.java b/src/org/traccar/protocol/Stl060ProtocolDecoder.java index 15bb3ddd4..d5ad651e7 100644 --- a/src/org/traccar/protocol/Stl060ProtocolDecoder.java +++ b/src/org/traccar/protocol/Stl060ProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Stl060ProtocolDecoder extends BaseProtocolDecoder { @@ -70,7 +66,7 @@ public class Stl060ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -112,18 +108,15 @@ public class Stl060ProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(parser.group(index++))); // Other - extendedInfo.set("milage", Integer.valueOf(parser.group(index++))); - extendedInfo.set("ignition", Integer.valueOf(parser.group(index++))); - extendedInfo.set("dip1", Integer.valueOf(parser.group(index++))); - extendedInfo.set("dip2", Integer.valueOf(parser.group(index++))); - extendedInfo.set("fuel", Integer.valueOf(parser.group(index++))); + position.set("milage", Integer.valueOf(parser.group(index++))); + position.set("ignition", Integer.valueOf(parser.group(index++))); + position.set("dip1", Integer.valueOf(parser.group(index++))); + position.set("dip2", Integer.valueOf(parser.group(index++))); + position.set("fuel", Integer.valueOf(parser.group(index++))); // Validity position.setValid(parser.group(index++).compareTo("A") == 0); - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - return position; } diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java index 4b12c556f..5ebf175d8 100644 --- a/src/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class SuntechProtocolDecoder extends BaseProtocolDecoder { @@ -66,7 +62,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); int index = 1; // Identifier @@ -76,7 +72,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); // Version - extendedInfo.set("version", parser.group(index++)); + position.set("version", parser.group(index++)); // Date and Time Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -90,7 +86,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // Cell - extendedInfo.set("cell", parser.group(index++)); + position.set("cell", parser.group(index++)); // Coordinates position.setLatitude(Double.valueOf(parser.group(index++))); @@ -103,9 +99,6 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { // Course position.setCourse(Double.valueOf(parser.group(index++))); - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - return position; } diff --git a/src/org/traccar/protocol/SyrusProtocolDecoder.java b/src/org/traccar/protocol/SyrusProtocolDecoder.java index af2c60a26..56975d09d 100644 --- a/src/org/traccar/protocol/SyrusProtocolDecoder.java +++ b/src/org/traccar/protocol/SyrusProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.util.Calendar; import java.util.Date; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,9 +25,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class SyrusProtocolDecoder extends BaseProtocolDecoder { @@ -131,7 +127,7 @@ public class SyrusProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); Integer index = 1; @@ -162,8 +158,6 @@ public class SyrusProtocolDecoder extends BaseProtocolDecoder { // Validity position.setValid(Integer.valueOf(parser.group(index++)) == 2); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java index be9fc80ac..a1a325c75 100644 --- a/src/org/traccar/protocol/T55ProtocolDecoder.java +++ b/src/org/traccar/protocol/T55ProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class T55ProtocolDecoder extends BaseProtocolDecoder { @@ -140,7 +136,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); Integer index = 1; @@ -184,8 +180,6 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); position.setTime(time.getTime()); - - position.setExtendedInfo(extendedInfo.toString()); return position; } @@ -200,7 +194,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); Integer index = 1; @@ -227,8 +221,6 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { longitude += Double.valueOf(parser.group(index++)) / 60; if (parser.group(index++).compareTo("W") == 0) longitude = -longitude; position.setLongitude(longitude); - - position.setExtendedInfo(extendedInfo.toString()); return position; } @@ -243,7 +235,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); Integer index = 1; @@ -277,8 +269,6 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { if (course != null) { position.setCourse(Double.valueOf(course)); } - - position.setExtendedInfo(extendedInfo.toString()); return position; } @@ -293,7 +283,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); Integer index = 1; @@ -320,9 +310,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { position.setAltitude(Double.valueOf(parser.group(index++))); // Battery - extendedInfo.set("battery", parser.group(index++)); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("battery", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/TelikProtocolDecoder.java b/src/org/traccar/protocol/TelikProtocolDecoder.java index de6b1929f..edbf10548 100644 --- a/src/org/traccar/protocol/TelikProtocolDecoder.java +++ b/src/org/traccar/protocol/TelikProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class TelikProtocolDecoder extends BaseProtocolDecoder { @@ -65,7 +61,7 @@ public class TelikProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -76,7 +72,7 @@ public class TelikProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); // Message type - extendedInfo.set("type", parser.group(index++)); + position.set("type", parser.group(index++)); // Time Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -103,10 +99,7 @@ public class TelikProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(parser.group(index++))); // Satellites - extendedInfo.set("satellites", parser.group(index++)); - - // Extended info - position.setExtendedInfo(extendedInfo.toString()); + position.set("satellites", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index 6a4a35b20..0cd3a9c73 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -19,7 +19,6 @@ import java.nio.charset.Charset; import java.util.Date; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; @@ -27,9 +26,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { @@ -79,7 +75,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { for (int i = 0; i < count; i++) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(deviceId); @@ -117,28 +113,28 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { if (checkBit(locationMask, 4)) { int satellites = buf.readUnsignedByte(); - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); position.setValid(satellites >= 3); } if (checkBit(locationMask, 5)) { - extendedInfo.set("area", buf.readUnsignedShort()); - extendedInfo.set("cell", buf.readUnsignedShort()); + position.set("area", buf.readUnsignedShort()); + position.set("cell", buf.readUnsignedShort()); } if (checkBit(locationMask, 6)) { - extendedInfo.set("gsm", buf.readUnsignedByte()); + position.set("gsm", buf.readUnsignedByte()); } if (checkBit(locationMask, 7)) { - extendedInfo.set("operator", buf.readUnsignedInt()); + position.set("operator", buf.readUnsignedInt()); } } else { position.setTime(new Date(buf.readLong())); - extendedInfo.set("priority", buf.readUnsignedByte()); + position.set("priority", buf.readUnsignedByte()); position.setLongitude(buf.readInt() / 10000000.0); position.setLatitude(buf.readInt() / 10000000.0); @@ -146,13 +142,13 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { position.setCourse(buf.readUnsignedShort()); int satellites = buf.readUnsignedByte(); - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); position.setValid(satellites != 0); position.setSpeed(buf.readUnsignedShort() * 0.539957); - extendedInfo.set("event", buf.readUnsignedByte()); + position.set("event", buf.readUnsignedByte()); buf.readUnsignedByte(); // total IO data records @@ -164,9 +160,9 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { for (int j = 0; j < cnt; j++) { int id = buf.readUnsignedByte(); if (id == 1) { - extendedInfo.set("power", buf.readUnsignedByte()); + position.set("power", buf.readUnsignedByte()); } else { - extendedInfo.set("io" + id, buf.readUnsignedByte()); + position.set("io" + id, buf.readUnsignedByte()); } } } @@ -176,7 +172,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { if (checkBit(globalMask, 2)) { int cnt = buf.readUnsignedByte(); for (int j = 0; j < cnt; j++) { - extendedInfo.set("io" + buf.readUnsignedByte(), buf.readUnsignedShort()); + position.set("io" + buf.readUnsignedByte(), buf.readUnsignedShort()); } } @@ -184,7 +180,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { if (checkBit(globalMask, 3)) { int cnt = buf.readUnsignedByte(); for (int j = 0; j < cnt; j++) { - extendedInfo.set("io" + buf.readUnsignedByte(), buf.readUnsignedInt()); + position.set("io" + buf.readUnsignedByte(), buf.readUnsignedInt()); } } @@ -192,11 +188,9 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { if (codec == CODEC_FM4X00) { int cnt = buf.readUnsignedByte(); for (int j = 0; j < cnt; j++) { - extendedInfo.set("io" + buf.readUnsignedByte(), buf.readLong()); + position.set("io" + buf.readUnsignedByte(), buf.readLong()); } } - - position.setExtendedInfo(extendedInfo.toString()); positions.add(position); } diff --git a/src/org/traccar/protocol/Tk102ProtocolDecoder.java b/src/org/traccar/protocol/Tk102ProtocolDecoder.java index b6f7e2212..c1dcd9bd4 100644 --- a/src/org/traccar/protocol/Tk102ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk102ProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Tk102ProtocolDecoder extends BaseProtocolDecoder { @@ -82,7 +78,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); Integer index = 1; @@ -117,8 +113,6 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); position.setTime(time.getTime()); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java index 493287011..948fd9fd5 100644 --- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Tk103ProtocolDecoder extends BaseProtocolDecoder { @@ -85,7 +81,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Get device by IMEI @@ -135,15 +131,13 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(parser.group(index++))); // State - extendedInfo.set("state", parser.group(index++)); + position.set("state", parser.group(index++)); // Milage String milage = parser.group(index++); if (milage != null) { - extendedInfo.set("milage", Long.parseLong(milage, 16)); + position.set("milage", Long.parseLong(milage, 16)); } - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java index f42e92c8f..b70811dd5 100644 --- a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java +++ b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java @@ -18,7 +18,6 @@ package org.traccar.protocol; import java.util.Calendar; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,9 +26,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { @@ -89,13 +85,13 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { parser = patternPosition.matcher(message); if (parser.matches()) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); Integer index = 1; // Cell - extendedInfo.set("cell", parser.group(index++)); + position.set("cell", parser.group(index++)); // Time Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -139,9 +135,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // Status - extendedInfo.set("status", status); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("status", status); positions.add(position); } } diff --git a/src/org/traccar/protocol/TopflytechProtocolDecoder.java b/src/org/traccar/protocol/TopflytechProtocolDecoder.java index b00551763..0d97f112a 100644 --- a/src/org/traccar/protocol/TopflytechProtocolDecoder.java +++ b/src/org/traccar/protocol/TopflytechProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class TopflytechProtocolDecoder extends BaseProtocolDecoder { @@ -67,7 +63,7 @@ public class TopflytechProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Identifier @@ -107,8 +103,6 @@ public class TopflytechProtocolDecoder extends BaseProtocolDecoder { // Course position.setCourse(Double.valueOf(parser.group(index++))); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index 716e2b49c..faff9d300 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class TotemProtocolDecoder extends BaseProtocolDecoder { @@ -162,7 +158,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -173,7 +169,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); // Alarm type - extendedInfo.set("alarm", parser.group(index++)); + position.set("alarm", parser.group(index++)); if (format == MessageFormat.first || format == MessageFormat.second) { @@ -231,26 +227,26 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // Accuracy - extendedInfo.set("hdop", parser.group(index++)); + position.set("hdop", parser.group(index++)); // IO Status - extendedInfo.set("io", parser.group(index++)); + position.set("io", parser.group(index++)); // Power - extendedInfo.set("battery", parser.group(index++)); - extendedInfo.set("power", Double.valueOf(parser.group(index++))); + position.set("battery", parser.group(index++)); + position.set("power", Double.valueOf(parser.group(index++))); // ADC - extendedInfo.set("adc", parser.group(index++)); + position.set("adc", parser.group(index++)); // Location Code - extendedInfo.set("lac", parser.group(index++)); + position.set("lac", parser.group(index++)); // Temperature - extendedInfo.set("temperature", parser.group(index++)); + position.set("temperature", parser.group(index++)); // Milage - extendedInfo.set("milage", parser.group(index++)); + position.set("milage", parser.group(index++)); } else if (format == MessageFormat.third) { @@ -266,28 +262,28 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // IO Status - extendedInfo.set("io", parser.group(index++)); + position.set("io", parser.group(index++)); // Power - extendedInfo.set("battery", Double.valueOf(parser.group(index++)) / 10); - extendedInfo.set("power", Double.valueOf(parser.group(index++))); + position.set("battery", Double.valueOf(parser.group(index++)) / 10); + position.set("power", Double.valueOf(parser.group(index++))); // ADC - extendedInfo.set("adc1", parser.group(index++)); - extendedInfo.set("adc2", parser.group(index++)); + position.set("adc1", parser.group(index++)); + position.set("adc2", parser.group(index++)); // Temperature - extendedInfo.set("temperature1", parser.group(index++)); - extendedInfo.set("temperature2", parser.group(index++)); + position.set("temperature1", parser.group(index++)); + position.set("temperature2", parser.group(index++)); // Location Code - extendedInfo.set("lac", parser.group(index++)); + position.set("lac", parser.group(index++)); // Validity position.setValid(parser.group(index++).compareTo("A") == 0); // Satellites - extendedInfo.set("satellites", parser.group(index++)); + position.set("satellites", parser.group(index++)); // Course position.setCourse(Double.valueOf(parser.group(index++))); @@ -296,10 +292,10 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(Double.valueOf(parser.group(index++))); // PDOP - extendedInfo.set("pdop", parser.group(index++)); + position.set("pdop", parser.group(index++)); // Milage - extendedInfo.set("milage", parser.group(index++)); + position.set("milage", parser.group(index++)); // Latitude Double latitude = Double.valueOf(parser.group(index++)); @@ -315,9 +311,6 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { } - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - return position; } diff --git a/src/org/traccar/protocol/Tr20ProtocolDecoder.java b/src/org/traccar/protocol/Tr20ProtocolDecoder.java index 085a87771..cbf1f34c0 100644 --- a/src/org/traccar/protocol/Tr20ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tr20ProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Tr20ProtocolDecoder extends BaseProtocolDecoder { @@ -80,7 +76,7 @@ public class Tr20ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -124,9 +120,6 @@ public class Tr20ProtocolDecoder extends BaseProtocolDecoder { // Course position.setCourse(Double.valueOf(parser.group(index++))); - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - return position; } diff --git a/src/org/traccar/protocol/Tr900ProtocolDecoder.java b/src/org/traccar/protocol/Tr900ProtocolDecoder.java index e24063218..b118161e2 100644 --- a/src/org/traccar/protocol/Tr900ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tr900ProtocolDecoder.java @@ -18,13 +18,9 @@ package org.traccar.protocol; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -72,7 +68,7 @@ public class Tr900ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Identification @@ -116,14 +112,12 @@ public class Tr900ProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(parser.group(index++))); // Other - extendedInfo.set("gsm", parser.group(index++)); - extendedInfo.set("event", Integer.valueOf(parser.group(index++))); - extendedInfo.set("adc1", Integer.valueOf(parser.group(index++))); - extendedInfo.set("battery", Integer.valueOf(parser.group(index++))); - extendedInfo.set("input", parser.group(index++)); - extendedInfo.set("status", parser.group(index++)); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("gsm", parser.group(index++)); + position.set("event", Integer.valueOf(parser.group(index++))); + position.set("adc1", Integer.valueOf(parser.group(index++))); + position.set("battery", Integer.valueOf(parser.group(index++))); + position.set("input", parser.group(index++)); + position.set("status", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/TrackboxProtocolDecoder.java b/src/org/traccar/protocol/TrackboxProtocolDecoder.java index 5be74b15d..f53d0a2ed 100644 --- a/src/org/traccar/protocol/TrackboxProtocolDecoder.java +++ b/src/org/traccar/protocol/TrackboxProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class TrackboxProtocolDecoder extends BaseProtocolDecoder { @@ -80,7 +76,7 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(getDeviceId()); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -105,14 +101,14 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(longitude); // HDOP - extendedInfo.set("hdop", parser.group(index++)); + position.set("hdop", parser.group(index++)); // Altitude position.setAltitude(Double.valueOf(parser.group(index++))); // Validity int fix = Integer.valueOf(parser.group(index++)); - extendedInfo.set("fix", fix); + position.set("fix", fix); position.setValid(fix > 0); // Course @@ -129,10 +125,7 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // Satellites - extendedInfo.set("satellites", parser.group(index++)); - - // Extended info - position.setExtendedInfo(extendedInfo.toString()); + position.set("satellites", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/TramigoProtocolDecoder.java b/src/org/traccar/protocol/TramigoProtocolDecoder.java index e6318a3ee..c36ee91b1 100644 --- a/src/org/traccar/protocol/TramigoProtocolDecoder.java +++ b/src/org/traccar/protocol/TramigoProtocolDecoder.java @@ -20,9 +20,6 @@ import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; import java.nio.charset.Charset; @@ -31,7 +28,6 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; -import java.util.Properties; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -63,8 +59,8 @@ public class TramigoProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); - extendedInfo.set("index", index); + position.setProtocol(getProtocol()); + position.set("index", index); position.setValid(true); // Get device id @@ -93,15 +89,13 @@ public class TramigoProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedInt(); // distance - extendedInfo.set("battery", buf.readUnsignedShort()); + position.set("battery", buf.readUnsignedShort()); buf.readUnsignedShort(); // battery charger status position.setTime(new Date(buf.readUnsignedInt() * 1000)); // TODO: parse other data - - position.setExtendedInfo(extendedInfo.toString()); return position; } else if (protocol == 0x80) { @@ -137,8 +131,6 @@ public class TramigoProtocolDecoder extends BaseProtocolDecoder { } DateFormat dateFormat = new SimpleDateFormat("HH:mm MMM d yyyy", Locale.ENGLISH); position.setTime(dateFormat.parse(matcher.group(1) + " " + Calendar.getInstance().get(Calendar.YEAR))); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java index d86e5872e..72de2068b 100644 --- a/src/org/traccar/protocol/TytanProtocolDecoder.java +++ b/src/org/traccar/protocol/TytanProtocolDecoder.java @@ -27,7 +27,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.ChannelBufferTools; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class TytanProtocolDecoder extends BaseProtocolDecoder { @@ -62,7 +61,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { while (buf.readable()) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); int end = buf.readerIndex() + buf.readUnsignedByte(); @@ -70,8 +69,8 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { position.setTime(new Date(buf.readUnsignedInt() * 1000)); int flags = buf.readUnsignedByte(); - extendedInfo.set("gps", flags >> 5); - extendedInfo.set("gsm", flags & 0x07); + position.set("gps", flags >> 5); + position.set("gsm", flags & 0x07); position.setValid(((flags & 0x08) != 0) ^ ((flags & 0x10) != 0)); // Latitude @@ -98,33 +97,33 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { while (buf.readerIndex() < end) { switch (buf.readUnsignedByte()) { case 2: - extendedInfo.set("milage", buf.readUnsignedMedium()); + position.set("milage", buf.readUnsignedMedium()); break; case 4: buf.readUnsignedShort(); // device start break; case 5: - extendedInfo.set("input", buf.readUnsignedByte()); + position.set("input", buf.readUnsignedByte()); break; case 6: buf.readUnsignedShort(); - extendedInfo.set("adc", buf.readFloat()); + position.set("adc", buf.readFloat()); break; case 7: - extendedInfo.set("alarm", buf.readUnsignedShort()); + position.set("alarm", buf.readUnsignedShort()); break; case 8: - extendedInfo.set("antihijack", buf.readUnsignedByte()); + position.set("antihijack", buf.readUnsignedByte()); break; case 9: - extendedInfo.set("authorized", ChannelBufferTools.readHexString(buf, 16)); + position.set("authorized", ChannelBufferTools.readHexString(buf, 16)); break; case 10: - extendedInfo.set("unauthorized", ChannelBufferTools.readHexString(buf, 16)); + position.set("unauthorized", ChannelBufferTools.readHexString(buf, 16)); break; case 24: buf.readUnsignedByte(); - extendedInfo.set("temperature", buf.readUnsignedByte()); + position.set("temperature", buf.readUnsignedByte()); break; case 25: buf.readUnsignedByte(); @@ -134,7 +133,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(buf.readUnsignedByte() * 2); // flowmeter break; case 28: - extendedInfo.set("weight", buf.readUnsignedShort()); + position.set("weight", buf.readUnsignedShort()); buf.readUnsignedByte(); break; case 29: @@ -180,7 +179,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // engine load break; case 107: - extendedInfo.set("fuel", buf.readUnsignedShort() & 0x3fff); + position.set("fuel", buf.readUnsignedShort() & 0x3fff); break; case 108: buf.readUnsignedInt(); // total distance @@ -210,12 +209,10 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedShort(); // fuel rate break; case 150: - extendedInfo.set("door", buf.readUnsignedByte()); + position.set("door", buf.readUnsignedByte()); break; } } - - position.setExtendedInfo(extendedInfo.toString()); positions.add(position); } diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java index 42cda7bad..04b39d078 100644 --- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java +++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java @@ -20,7 +20,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.ChannelBufferTools; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; import java.util.Date; @@ -56,7 +55,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Get device id String imei = ChannelBufferTools.readHexString(buf, 16).substring(1); @@ -86,7 +85,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(buf.readInt() / 1000000.0); position.setSpeed(buf.readUnsignedShort() * 0.539957); position.setCourse(buf.readUnsignedShort()); - extendedInfo.set("hdop", buf.readUnsignedShort()); + position.set("hdop", buf.readUnsignedShort()); break; default: @@ -95,8 +94,6 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { } } - position.setExtendedInfo(extendedInfo.toString()); - if (hasLocation) { return position; } diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java index d507a48e0..a6b5e1bc1 100644 --- a/src/org/traccar/protocol/V680ProtocolDecoder.java +++ b/src/org/traccar/protocol/V680ProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class V680ProtocolDecoder extends BaseProtocolDecoder { @@ -77,7 +73,7 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Get device by IMEI @@ -91,22 +87,22 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); // User - extendedInfo.set("user", parser.group(index++)); + position.set("user", parser.group(index++)); // Validity position.setValid(Integer.valueOf(parser.group(index++)) > 0); // Password - extendedInfo.set("password", parser.group(index++)); + position.set("password", parser.group(index++)); // Event - extendedInfo.set("event", parser.group(index++)); + position.set("event", parser.group(index++)); // Packet number - extendedInfo.set("packet", parser.group(index++)); + position.set("packet", parser.group(index++)); // GSM base station - extendedInfo.set("gsm", parser.group(index++)); + position.set("gsm", parser.group(index++)); // Longitude String lon = parser.group(index++); @@ -146,8 +142,6 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++))); time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++))); position.setTime(time.getTime()); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java index 47ad5a59b..2c3dad570 100644 --- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java +++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class VisiontekProtocolDecoder extends BaseProtocolDecoder { @@ -74,7 +70,7 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -122,23 +118,20 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder { } // Additional data - extendedInfo.set("satellites", parser.group(index++)); - extendedInfo.set("milage", parser.group(index++)); - extendedInfo.set("ignition", parser.group(index++)); - extendedInfo.set("input1", parser.group(index++)); - extendedInfo.set("input2", parser.group(index++)); - extendedInfo.set("immobilizer", parser.group(index++)); - extendedInfo.set("power", parser.group(index++)); - extendedInfo.set("gsm", parser.group(index++)); + position.set("satellites", parser.group(index++)); + position.set("milage", parser.group(index++)); + position.set("ignition", parser.group(index++)); + position.set("input1", parser.group(index++)); + position.set("input2", parser.group(index++)); + position.set("immobilizer", parser.group(index++)); + position.set("power", parser.group(index++)); + position.set("gsm", parser.group(index++)); // Validity position.setValid(parser.group(index++).compareTo("A") == 0); // RFID - extendedInfo.set("rfid", parser.group(index++)); - - // Extended info - position.setExtendedInfo(extendedInfo.toString()); + position.set("rfid", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java index b01dc24f7..6f0223112 100644 --- a/src/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/org/traccar/protocol/WialonProtocolDecoder.java @@ -18,7 +18,6 @@ package org.traccar.protocol; import java.util.Calendar; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,9 +26,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class WialonProtocolDecoder extends BaseProtocolDecoder { @@ -79,7 +75,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); position.setDeviceId(getDeviceId()); Integer index = 1; @@ -129,27 +125,27 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { String satellites = parser.group(index++); if (satellites != null) { position.setValid(Integer.valueOf(satellites) >= 3); - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); } else { position.setValid(false); } // Other - extendedInfo.set("hdop", parser.group(index++)); - extendedInfo.set("inputs", parser.group(index++)); - extendedInfo.set("outputs", parser.group(index++)); + position.set("hdop", parser.group(index++)); + position.set("inputs", parser.group(index++)); + position.set("outputs", parser.group(index++)); // ADC String adc = parser.group(index++); if (adc != null) { String[] values = adc.split(","); for (int i = 0; i < values.length; i++) { - extendedInfo.set("adc" + (i + 1), values[i]); + position.set("adc" + (i + 1), values[i]); } } // iButton - extendedInfo.set("ibutton", parser.group(index++)); + position.set("ibutton", parser.group(index++)); // Params String params = parser.group(index); @@ -158,14 +154,11 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { for (String param : values) { Matcher paramParser = Pattern.compile( "(.*):[1-3]:(.*)").matcher(param); if (paramParser.matches()) { - extendedInfo.set(paramParser.group(1).toLowerCase(), paramParser.group(2)); + position.set(paramParser.group(1).toLowerCase(), paramParser.group(2)); } } } - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - return position; } diff --git a/src/org/traccar/protocol/WondexProtocolDecoder.java b/src/org/traccar/protocol/WondexProtocolDecoder.java index 98b75b0d2..cf4a3fedd 100644 --- a/src/org/traccar/protocol/WondexProtocolDecoder.java +++ b/src/org/traccar/protocol/WondexProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class WondexProtocolDecoder extends BaseProtocolDecoder { @@ -68,7 +64,7 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); int index = 1; // Device identifier @@ -98,28 +94,26 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder { // Satellites int satellites = Integer.valueOf(parser.group(index++)); position.setValid(satellites >= 3); - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); // Event - extendedInfo.set("event", parser.group(index++)); + position.set("event", parser.group(index++)); // Battery - extendedInfo.set("battery", parser.group(index++)); + position.set("battery", parser.group(index++)); // Milage - extendedInfo.set("milage", parser.group(index++)); + position.set("milage", parser.group(index++)); // Input - extendedInfo.set("input", parser.group(index++)); + position.set("input", parser.group(index++)); // ADC - extendedInfo.set("adc1", parser.group(index++)); - extendedInfo.set("adc2", parser.group(index++)); + position.set("adc1", parser.group(index++)); + position.set("adc2", parser.group(index++)); // Output - extendedInfo.set("output", parser.group(index++)); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("output", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java index eff4fcdbd..420dfc8d0 100644 --- a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java +++ b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Xexun2ProtocolDecoder extends BaseProtocolDecoder { @@ -75,15 +71,15 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; // Serial - extendedInfo.set("serial", parser.group(index++)); + position.set("serial", parser.group(index++)); // Number - extendedInfo.set("number", parser.group(index++)); + position.set("number", parser.group(index++)); // Time Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -124,10 +120,10 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // Signal - extendedInfo.set("signal", parser.group(index++)); + position.set("signal", parser.group(index++)); // Alarm - extendedInfo.set("alarm", parser.group(index++)); + position.set("alarm", parser.group(index++)); // Get device by IMEI if (!identify(parser.group(index++))) { @@ -136,7 +132,7 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); // Satellites - extendedInfo.set("satellites", parser.group(index++).replaceFirst ("^0*(?![\\.$])", "")); + position.set("satellites", parser.group(index++).replaceFirst ("^0*(?![\\.$])", "")); // Altitude String altitude = parser.group(index++); @@ -145,10 +141,7 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder { } // Power - extendedInfo.set("power", Double.valueOf(parser.group(index++))); - - // Extended info - position.setExtendedInfo(extendedInfo.toString()); + position.set("power", Double.valueOf(parser.group(index++))); return position; } diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index 737a15096..d54e6fb20 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.text.ParseException; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,9 +25,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class XexunProtocolDecoder extends BaseProtocolDecoder { @@ -65,7 +61,7 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -115,8 +111,6 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { return null; } position.setDeviceId(getDeviceId()); - - position.setExtendedInfo(extendedInfo.toString()); return position; } diff --git a/src/org/traccar/protocol/XirgoProtocolDecoder.java b/src/org/traccar/protocol/XirgoProtocolDecoder.java index cec36c866..813a7a995 100644 --- a/src/org/traccar/protocol/XirgoProtocolDecoder.java +++ b/src/org/traccar/protocol/XirgoProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.net.SocketAddress; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,9 +25,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class XirgoProtocolDecoder extends BaseProtocolDecoder { @@ -71,7 +67,7 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -81,7 +77,7 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(getDeviceId()); - extendedInfo.set("event", parser.group(index++)); + position.set("event", parser.group(index++)); // Date Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -102,18 +98,15 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder { position.setCourse(Double.valueOf(parser.group(index++))); // Additional data - extendedInfo.set("satellites", parser.group(index++)); - extendedInfo.set("hdop", parser.group(index++)); - extendedInfo.set("battery", parser.group(index++)); - extendedInfo.set("gsm", parser.group(index++)); - extendedInfo.set("milage", parser.group(index++)); + position.set("satellites", parser.group(index++)); + position.set("hdop", parser.group(index++)); + position.set("battery", parser.group(index++)); + position.set("gsm", parser.group(index++)); + position.set("milage", parser.group(index++)); // Validity position.setValid(Integer.valueOf(parser.group(index++)) == 1); - // Extended info - position.setExtendedInfo(extendedInfo.toString()); - return position; } diff --git a/src/org/traccar/protocol/Xt013ProtocolDecoder.java b/src/org/traccar/protocol/Xt013ProtocolDecoder.java index e471ea349..c1e1c3e65 100644 --- a/src/org/traccar/protocol/Xt013ProtocolDecoder.java +++ b/src/org/traccar/protocol/Xt013ProtocolDecoder.java @@ -18,14 +18,10 @@ package org.traccar.protocol; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; import java.text.ParseException; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -73,7 +69,7 @@ public class Xt013ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; @@ -103,12 +99,10 @@ public class Xt013ProtocolDecoder extends BaseProtocolDecoder { position.setValid(parser.group(index++).equals("F")); // Other - extendedInfo.set("gps", parser.group(index++)); - extendedInfo.set("gsm", parser.group(index++)); - extendedInfo.set("battery", parser.group(index++)); - extendedInfo.set("charging", parser.group(index++)); - - position.setExtendedInfo(extendedInfo.toString()); + position.set("gps", parser.group(index++)); + position.set("gsm", parser.group(index++)); + position.set("battery", parser.group(index++)); + position.set("charging", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/Xt7ProtocolDecoder.java b/src/org/traccar/protocol/Xt7ProtocolDecoder.java index bcc17cfb2..564cbaf67 100644 --- a/src/org/traccar/protocol/Xt7ProtocolDecoder.java +++ b/src/org/traccar/protocol/Xt7ProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar.protocol; import java.nio.charset.Charset; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,9 +26,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class Xt7ProtocolDecoder extends BaseProtocolDecoder { @@ -70,7 +66,7 @@ public class Xt7ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); // Get device by id String id = buf.readBytes(16).toString(Charset.defaultCharset()).trim(); @@ -130,31 +126,28 @@ public class Xt7ProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // IMSI - extendedInfo.set("imsi", parser.group(index++)); + position.set("imsi", parser.group(index++)); // Cell - extendedInfo.set("cell", parser.group(index++)); + position.set("cell", parser.group(index++)); // GSM signal quality - extendedInfo.set("gsm", parser.group(index++)); + position.set("gsm", parser.group(index++)); // Battery - extendedInfo.set("power", Double.valueOf(parser.group(index++))); + position.set("power", Double.valueOf(parser.group(index++))); // Flags - extendedInfo.set("flags", parser.group(index++)); + position.set("flags", parser.group(index++)); // Sensors - extendedInfo.set("sensors", parser.group(index++)); + position.set("sensors", parser.group(index++)); // Fuel - extendedInfo.set("fuel", parser.group(index++)); + position.set("fuel", parser.group(index++)); // Alarm - extendedInfo.set("alarm", parser.group(index++)); - - // Extended info - position.setExtendedInfo(extendedInfo.toString()); + position.set("alarm", parser.group(index++)); return position; } diff --git a/src/org/traccar/protocol/YwtProtocolDecoder.java b/src/org/traccar/protocol/YwtProtocolDecoder.java index babf23d77..833ec4771 100644 --- a/src/org/traccar/protocol/YwtProtocolDecoder.java +++ b/src/org/traccar/protocol/YwtProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.Properties; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; -import org.traccar.helper.Log; -import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; public class YwtProtocolDecoder extends BaseProtocolDecoder { @@ -84,7 +80,7 @@ public class YwtProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); + position.setProtocol(getProtocol()); Integer index = 1; String type = parser.group(index++); @@ -132,13 +128,13 @@ public class YwtProtocolDecoder extends BaseProtocolDecoder { // Satellites int satellites = Integer.valueOf(parser.group(index++)); position.setValid(satellites >= 3); - extendedInfo.set("satellites", satellites); + position.set("satellites", satellites); // Report identifier String reportId = parser.group(index++); // Status - extendedInfo.set("status", parser.group(index++)); + position.set("status", parser.group(index++)); // Send response if (type.equals("KP") || type.equals("EP") || type.equals("EP")) { @@ -146,8 +142,6 @@ public class YwtProtocolDecoder extends BaseProtocolDecoder { channel.write("%AT+" + type + "=" + reportId + "\r\n"); } } - - position.setExtendedInfo(extendedInfo.toString()); return position; } -- cgit v1.2.3