aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java b/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java
index 7a6b6f4fe..193005e28 100644
--- a/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/StarLinkProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 - 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,8 +17,9 @@ package org.traccar.protocol;
import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.Context;
-import org.traccar.DeviceSession;
+import org.traccar.config.Keys;
+import org.traccar.helper.model.AttributeUtil;
+import org.traccar.session.DeviceSession;
import org.traccar.Protocol;
import org.traccar.helper.DataConverter;
import org.traccar.helper.Parser;
@@ -55,17 +56,21 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
public StarLinkProtocolDecoder(Protocol protocol) {
super(protocol);
+ }
- setFormat(Context.getConfig().getString(
- getProtocolName() + ".format", "#EDT#,#EID#,#PDT#,#LAT#,#LONG#,#SPD#,#HEAD#,#ODO#,"
+ @Override
+ protected void init() {
+ setFormat(getConfig().getString(
+ Keys.PROTOCOL_FORMAT.withPrefix(getProtocolName()), "#EDT#,#EID#,#PDT#,#LAT#,#LONG#,#SPD#,#HEAD#,#ODO#,"
+ "#IN1#,#IN2#,#IN3#,#IN4#,#OUT1#,#OUT2#,#OUT3#,#OUT4#,#LAC#,#CID#,#VIN#,#VBAT#,#DEST#,#IGN#,#ENG#"));
- setDateFormat(Context.getConfig().getString(getProtocolName() + ".dateFormat", "yyMMddHHmmss"));
+ setDateFormat(getConfig().getString(Keys.PROTOCOL_DATE_FORMAT.withPrefix(getProtocolName()), "yyMMddHHmmss"));
}
public String[] getFormat(long deviceId) {
- return Context.getIdentityManager().lookupAttributeString(
- deviceId, getProtocolName() + ".format", format, false, false).split(",");
+ String value = AttributeUtil.lookup(
+ getCacheManager(), Keys.PROTOCOL_FORMAT.withPrefix(getProtocolName()), deviceId);
+ return (value != null ? value : format).split(",");
}
public void setFormat(String format) {
@@ -73,8 +78,9 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
}
public DateFormat getDateFormat(long deviceId) {
- DateFormat dateFormat = new SimpleDateFormat(Context.getIdentityManager().lookupAttributeString(
- deviceId, getProtocolName() + ".dateFormat", this.dateFormat, false, false));
+ String value = AttributeUtil.lookup(
+ getCacheManager(), Keys.PROTOCOL_DATE_FORMAT.withPrefix(getProtocolName()), deviceId);
+ DateFormat dateFormat = new SimpleDateFormat(value != null ? value : this.dateFormat);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
return dateFormat;
}
@@ -313,7 +319,7 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
}
if (lac != null && cid != null) {
- position.setNetwork(new Network(CellTower.fromLacCid(lac, cid)));
+ position.setNetwork(new Network(CellTower.fromLacCid(getConfig(), lac, cid)));
}
if (event == 20) {