diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-10-08 13:03:01 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-10-08 13:03:01 -0700 |
commit | b6dfdef54b8fab3c7bca9b6a2057d8a27f9df4a8 (patch) | |
tree | b6cf8408286e8d57a3345f07b3eb4c32c3e306bc /src/main | |
parent | 647cd1cd82b82f6b42cc253fdfd84b2ab790da11 (diff) | |
download | trackermap-server-b6dfdef54b8fab3c7bca9b6a2057d8a27f9df4a8.tar.gz trackermap-server-b6dfdef54b8fab3c7bca9b6a2057d8a27f9df4a8.tar.bz2 trackermap-server-b6dfdef54b8fab3c7bca9b6a2057d8a27f9df4a8.zip |
Decode CAREU P2 alarms
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/protocol/IntellitracProtocolDecoder.java | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/src/main/java/org/traccar/protocol/IntellitracProtocolDecoder.java b/src/main/java/org/traccar/protocol/IntellitracProtocolDecoder.java index 897606270..e5339bded 100644 --- a/src/main/java/org/traccar/protocol/IntellitracProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/IntellitracProtocolDecoder.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. @@ -44,7 +44,7 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { .number("(d+.?d*),") // course .number("(-?d+.?d*),") // altitude .number("(d+),") // satellites - .number("(d+),") // index + .number("(d+),") // event .number("(d+),") // input .number("(d+),?") // output .number("(d+.d+)?,?") // adc1 @@ -65,6 +65,26 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { .any() .compile(); + private String decodeAlarm(int value) { + switch (value) { + case 164: + return Position.ALARM_GEOFENCE_ENTER; + case 165: + return Position.ALARM_GEOFENCE_EXIT; + case 168: + case 169: + return Position.ALARM_LOW_POWER; + case 170: + return Position.ALARM_POWER_OFF; + case 176: + return Position.ALARM_POWER_RESTORED; + case 225: + return Position.ALARM_JAMMING; + default: + return null; + } + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -74,12 +94,12 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { return null; } - Position position = new Position(getProtocolName()); - DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); if (deviceSession == null) { return null; } + + Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); position.setTime(parser.nextDateTime()); @@ -92,7 +112,11 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { position.setAltitude(parser.nextDouble()); position.set(Position.KEY_SATELLITES, parser.nextInt()); - position.set(Position.KEY_INDEX, parser.nextLong()); + + int event = parser.nextInt(); + position.set(Position.KEY_ALARM, decodeAlarm(event)); + position.set(Position.KEY_EVENT, event); + position.set(Position.KEY_INPUT, parser.nextInt()); position.set(Position.KEY_OUTPUT, parser.nextInt()); @@ -100,16 +124,18 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + 2, parser.nextDouble()); // J1939 data - position.set(Position.KEY_OBD_SPEED, parser.nextInt()); - position.set(Position.KEY_RPM, parser.nextInt()); - position.set("coolant", parser.nextInt()); - position.set(Position.KEY_FUEL_LEVEL, parser.nextInt()); - position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextInt()); - position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); - position.set("chargerPressure", parser.nextInt()); - position.set("tpl", parser.nextInt()); - position.set(Position.KEY_AXLE_WEIGHT, parser.nextInt()); - position.set(Position.KEY_OBD_ODOMETER, parser.nextInt()); + if (parser.hasNext(10)) { + position.set(Position.KEY_OBD_SPEED, parser.nextInt()); + position.set(Position.KEY_RPM, parser.nextInt()); + position.set("coolant", parser.nextInt()); + position.set(Position.KEY_FUEL_LEVEL, parser.nextInt()); + position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextInt()); + position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); + position.set("chargerPressure", parser.nextInt()); + position.set("tpl", parser.nextInt()); + position.set(Position.KEY_AXLE_WEIGHT, parser.nextInt()); + position.set(Position.KEY_OBD_ODOMETER, parser.nextInt()); + } return position; } |