aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-10-09 11:44:24 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-10-09 11:44:24 -0700
commit11aec11f7a4d65f08fb32dd7604c4cbf8ee2e0de (patch)
tree235ac55896961274ab983c8a4ea08f51f0c3d140 /src/main
parent3c9db2f713de21292a1109004f141744b789a660 (diff)
downloadtrackermap-server-11aec11f7a4d65f08fb32dd7604c4cbf8ee2e0de.tar.gz
trackermap-server-11aec11f7a4d65f08fb32dd7604c4cbf8ee2e0de.tar.bz2
trackermap-server-11aec11f7a4d65f08fb32dd7604c4cbf8ee2e0de.zip
Support per device attributes
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java b/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java
index 155f26c5b..7ba41ad56 100644
--- a/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java
@@ -49,8 +49,8 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
.number("xx") // checksum
.compile();
- private String[] dataTags;
- private DateFormat dateFormat;
+ private String format;
+ private String dateFormat;
public StarLinkProtocolDecoder(Protocol protocol) {
super(protocol);
@@ -62,13 +62,24 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
setDateFormat(Context.getConfig().getString(getProtocolName() + ".dateFormat", "yyMMddHHmmss"));
}
+ public String[] getFormat(long deviceId) {
+ return Context.getIdentityManager().lookupAttributeString(
+ deviceId, getProtocolName() + ".format", format, false, false).split(",");
+ }
+
public void setFormat(String format) {
- dataTags = format.split(",");
+ this.format = format;
+ }
+
+ public DateFormat getDateFormat(long deviceId) {
+ DateFormat dateFormat = new SimpleDateFormat(Context.getIdentityManager().lookupAttributeString(
+ deviceId, getProtocolName() + ".dateFormat", this.dateFormat, false, false));
+ dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ return dateFormat;
}
public void setDateFormat(String dateFormat) {
- this.dateFormat = new SimpleDateFormat(dateFormat);
- this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ this.dateFormat = dateFormat;
}
private double parseCoordinate(String value) {
@@ -130,6 +141,9 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
Integer lac = null, cid = null;
int event = 0;
+ String[] dataTags = getFormat(deviceSession.getDeviceId());
+ DateFormat dateFormat = getDateFormat(deviceSession.getDeviceId());
+
for (int i = 0; i < Math.min(data.length, dataTags.length); i++) {
if (data[i].isEmpty()) {
continue;