diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-11-14 11:30:06 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-11-14 11:30:06 -0800 |
commit | f3d1281d421a83677fbbcd25426e3440efc4c00a (patch) | |
tree | 7bdcfadb97d9806bd0398f009d62bddcad0f1b11 /src/main/java/org/traccar/protocol/TaipProtocolDecoder.java | |
parent | ebd0688d342d26be078f89ca6b5fbd0d5717bbdc (diff) | |
download | trackermap-server-f3d1281d421a83677fbbcd25426e3440efc4c00a.tar.gz trackermap-server-f3d1281d421a83677fbbcd25426e3440efc4c00a.tar.bz2 trackermap-server-f3d1281d421a83677fbbcd25426e3440efc4c00a.zip |
Support ControlSat CST-10
Diffstat (limited to 'src/main/java/org/traccar/protocol/TaipProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/TaipProtocolDecoder.java | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/TaipProtocolDecoder.java b/src/main/java/org/traccar/protocol/TaipProtocolDecoder.java index 8a0cb870b..285e68ddd 100644 --- a/src/main/java/org/traccar/protocol/TaipProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TaipProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2013 - 2020 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. @@ -49,7 +49,7 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { .groupEnd("?") .number("(d{5})") // seconds .or() - .expression("(?:RGP|RCQ|RCV|RBR)") // type + .expression("(?:RGP|RCQ|RCV|RBR|RUS00),?") // type .number("(dd)?") // event .number("(dd)(dd)(dd)") // date (mmddyy) .number("(dd)(dd)(dd)") // time (hhmmss) @@ -67,8 +67,20 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { .number("([023])") // fix mode .number("xx") // data age .number("(xx)") // input + .groupBegin() + .number(",d+") // flow meter + .number(",(d+)") // odometer + .number(",(d{4})(d{4})") // power / battery + .number(",(d+)") // rpm + .groupBegin() + .number(",(-?d+)") // temperature 1 + .number(",(-?d+)") // temperature 2 + .groupEnd("?") + .number(",(xx)") // alarm + .or() .number("(dd)") // event .number("(dd)") // hdop + .groupEnd() .or() .groupBegin() .number("(xx)") // input @@ -108,6 +120,17 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { return DateUtil.correctDay(dateBuilder.getDate()); } + private String decodeAlarm(int value) { + switch (value) { + case 0x01: + return Position.ALARM_SOS; + case 0x02: + return Position.ALARM_POWER_CUT; + default: + return null; + } + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -156,11 +179,24 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble(0))); position.setCourse(parser.nextDouble(0)); - if (parser.hasNext(4)) { + if (parser.hasNext(2)) { valid = parser.nextInt() > 0; int input = parser.nextHexInt(); position.set(Position.KEY_IGNITION, BitUtil.check(input, 7)); position.set(Position.KEY_INPUT, input); + } + + if (parser.hasNext(7)) { + position.set(Position.KEY_ODOMETER, parser.nextInt()); + position.set(Position.KEY_POWER, parser.nextInt() * 0.01); + position.set(Position.KEY_BATTERY, parser.nextInt() * 0.01); + position.set(Position.KEY_RPM, parser.nextInt()); + position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); + position.set(Position.PREFIX_TEMP + 2, parser.nextInt()); + position.set(Position.KEY_ALARM, decodeAlarm(parser.nextHexInt())); + } + + if (parser.hasNext(2)) { event = parser.nextInt(); position.set(Position.KEY_HDOP, parser.nextInt()); } |