aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-11 22:45:01 +1300
committerGitHub <noreply@github.com>2016-11-11 22:45:01 +1300
commit1d5da9a3686a8bad2f7c661864917e7403ad4b73 (patch)
tree85accc491eeb73d2914251290da7869d63219d2f /src/org/traccar/protocol
parent96fc52072ba760d46520f7b7235bf9ac76c9869f (diff)
parent2b5f9090882a4ddb5ca72d47b74ca6466e2240d0 (diff)
downloadtrackermap-server-1d5da9a3686a8bad2f7c661864917e7403ad4b73.tar.gz
trackermap-server-1d5da9a3686a8bad2f7c661864917e7403ad4b73.tar.bz2
trackermap-server-1d5da9a3686a8bad2f7c661864917e7403ad4b73.zip
Merge pull request #2525 from Abyss777/granit_adc
Analog input values tuning for Granit
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/GranitProtocolDecoder.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/GranitProtocolDecoder.java b/src/org/traccar/protocol/GranitProtocolDecoder.java
index 63b1671c6..5fa786e4d 100644
--- a/src/org/traccar/protocol/GranitProtocolDecoder.java
+++ b/src/org/traccar/protocol/GranitProtocolDecoder.java
@@ -19,6 +19,7 @@ import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
@@ -36,8 +37,17 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
private static final int HEADER_LENGTH = 6;
+ private double adc1Ratio;
+ private double adc2Ratio;
+ private double adc3Ratio;
+ private double adc4Ratio;
+
public GranitProtocolDecoder(GranitProtocol protocol) {
super(protocol);
+ adc1Ratio = Context.getConfig().getDouble("granit.adc1Ratio", 1);
+ adc2Ratio = Context.getConfig().getDouble("granit.adc2Ratio", 1);
+ adc3Ratio = Context.getConfig().getDouble("granit.adc3Ratio", 1);
+ adc4Ratio = Context.getConfig().getDouble("granit.adc4Ratio", 1);
}
public static void appendChecksum(ChannelBuffer buffer, int length) {
@@ -68,7 +78,7 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
channel.write(response);
}
- private static void decodeStructure(ChannelBuffer buf, Position position) {
+ private void decodeStructure(ChannelBuffer buf, Position position) {
short flags = buf.readUnsignedByte();
position.setValid(BitUtil.check(flags, 7));
if (BitUtil.check(flags, 1)) {
@@ -118,10 +128,10 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
analogIn3 = analogInHi << 4 & 0x300 | analogIn3;
analogIn4 = analogInHi << 2 & 0x300 | analogIn4;
- position.set(Position.PREFIX_ADC + 1, analogIn1);
- position.set(Position.PREFIX_ADC + 2, analogIn2);
- position.set(Position.PREFIX_ADC + 3, analogIn3);
- position.set(Position.PREFIX_ADC + 4, analogIn4);
+ position.set(Position.PREFIX_ADC + 1, analogIn1 * adc1Ratio);
+ position.set(Position.PREFIX_ADC + 2, analogIn2 * adc2Ratio);
+ position.set(Position.PREFIX_ADC + 3, analogIn3 * adc3Ratio);
+ position.set(Position.PREFIX_ADC + 4, analogIn4 * adc4Ratio);
position.setAltitude(buf.readUnsignedByte() * 10);