diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-04-14 14:11:24 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-04-14 14:11:24 -0700 |
commit | 9a404bd07c221912fff3b8e498caab0645fa4d2b (patch) | |
tree | fdaeb2120bc4eb2bc8c0b23eeb71eba77ca85114 | |
parent | 142fe572e6cb3c44b79844464b9efdaf501755a9 (diff) | |
download | traccar-server-9a404bd07c221912fff3b8e498caab0645fa4d2b.tar.gz traccar-server-9a404bd07c221912fff3b8e498caab0645fa4d2b.tar.bz2 traccar-server-9a404bd07c221912fff3b8e498caab0645fa4d2b.zip |
Support ITS EMR messages
-rw-r--r-- | src/main/java/org/traccar/protocol/ItsProtocolDecoder.java | 8 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java | 5 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java index 482f34e65..17833dda9 100644 --- a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java @@ -45,7 +45,7 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { .number("d+,") .expression("[LH],") // history .or() - .expression("[^,]+,") // type + .expression("([^,]+),") // type .groupEnd() .number("(d{15}),") // imei .groupBegin() @@ -121,6 +121,8 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { return null; } + String type = parser.next(); + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); if (deviceSession == null) { return null; @@ -129,6 +131,10 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); + if (type != null && type.equals("EMR")) { + position.set(Position.KEY_ALARM, Position.ALARM_SOS); + } + if (parser.hasNext()) { position.set(Position.KEY_ALARM, decodeAlarm(parser.next())); } diff --git a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java index 94095b2f2..f833cb6b9 100644 --- a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java @@ -2,6 +2,7 @@ package org.traccar.protocol; import org.junit.Test; import org.traccar.ProtocolTest; +import org.traccar.model.Position; public class ItsProtocolDecoderTest extends ProtocolTest { @@ -10,6 +11,10 @@ public class ItsProtocolDecoderTest extends ProtocolTest { ItsProtocolDecoder decoder = new ItsProtocolDecoder(null); + verifyAttribute(decoder, text( + "$EPB,EMR,869867036066035,NM,03042019,192008,V,000.00000000,N,000.00000000,E,0000000000.0,0000.0,00.000,G,,0,404,22,ECFB,36EF*226F7BD1"), + Position.KEY_ALARM, Position.ALARM_SOS); + verifyPosition(decoder, text( "$,CP,ATL,1.4D3_AIS140_1.0,EA,10,H,868728037717441,,1,31032019,140054,28.533699,N,77.269020,E,0.0,188.00,14,76.0,1.3,0.0,Idea,0,1,12.7,3.9,1,O,22,404,11,69,979c,fc1,69,18,fbf,69,15,e36e,69,14,ba2f,3ff,13,0111,00,249404,")); |