diff options
author | Abyss777 <abyss@fox5.ru> | 2016-11-11 11:30:29 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-11-11 11:30:29 +0500 |
commit | f80ce6d7a36e753aa6e5c7197d39a9e08caa848e (patch) | |
tree | 3d3978b09b80072d869302b431d27a104fe717ef /src/org/traccar/protocol | |
parent | 96fc52072ba760d46520f7b7235bf9ac76c9869f (diff) | |
download | traccar-server-f80ce6d7a36e753aa6e5c7197d39a9e08caa848e.tar.gz traccar-server-f80ce6d7a36e753aa6e5c7197d39a9e08caa848e.tar.bz2 traccar-server-f80ce6d7a36e753aa6e5c7197d39a9e08caa848e.zip |
Analog input values tuning
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/GranitProtocolDecoder.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/GranitProtocolDecoder.java b/src/org/traccar/protocol/GranitProtocolDecoder.java index 63b1671c6..2940f5c71 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 static double adc1Ratio; + private static double adc2Ratio; + private static double adc3Ratio; + private static 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) { @@ -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); |