diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-03-14 07:09:40 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-03-14 07:09:40 +1300 |
commit | 0aa78a779f764cad80d54d4710118212d52402c1 (patch) | |
tree | 942179b97cb88a3e37d0edaeb7db764b59c86e1f | |
parent | 4ae3297dde98d292cd0c87141440f94312459b65 (diff) | |
download | traccar-server-0aa78a779f764cad80d54d4710118212d52402c1.tar.gz traccar-server-0aa78a779f764cad80d54d4710118212d52402c1.tar.bz2 traccar-server-0aa78a779f764cad80d54d4710118212d52402c1.zip |
Decode Xirgo events and alarms
-rw-r--r-- | src/org/traccar/model/Position.java | 1 | ||||
-rw-r--r-- | src/org/traccar/protocol/XirgoProtocolDecoder.java | 65 |
2 files changed, 64 insertions, 2 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 981c2292f..49e3231c3 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -115,6 +115,7 @@ public class Position extends Message { public static final String ALARM_GPS_ANTENNA_CUT = "gpsAntennaCut"; public static final String ALARM_ACCIDENT = "accident"; public static final String ALARM_TOW = "tow"; + public static final String ALARM_IDLE = "idle"; public static final String ALARM_ACCELERATION = "hardAcceleration"; public static final String ALARM_BRAKING = "hardBraking"; public static final String ALARM_CORNERING = "hardCornering"; diff --git a/src/org/traccar/protocol/XirgoProtocolDecoder.java b/src/org/traccar/protocol/XirgoProtocolDecoder.java index 10dd298fd..1a753cb3e 100644 --- a/src/org/traccar/protocol/XirgoProtocolDecoder.java +++ b/src/org/traccar/protocol/XirgoProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2018 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. @@ -95,6 +95,67 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder { .any() .compile(); + private void decodeEvent(Position position, int event) { + + position.set(Position.KEY_EVENT, event); + + switch (event) { + case 4005: + position.set(Position.KEY_CHARGE, false); + break; + case 6002: + position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED); + break; + case 6006: + position.set(Position.KEY_ALARM, Position.ALARM_ACCELERATION); + break; + case 6007: + position.set(Position.KEY_ALARM, Position.ALARM_BRAKING); + break; + case 6008: + position.set(Position.KEY_ALARM, Position.ALARM_LOW_POWER); + break; + case 6009: + position.set(Position.KEY_ALARM, Position.ALARM_POWER_CUT); + break; + case 6010: + position.set(Position.KEY_ALARM, Position.ALARM_POWER_RESTORED); + break; + case 6011: + case 6013: + position.set(Position.KEY_IGNITION, true); + break; + case 6012: + case 6014: + position.set(Position.KEY_IGNITION, false); + break; + case 6016: + position.set(Position.KEY_ALARM, Position.ALARM_IDLE); + break; + case 6017: + position.set(Position.KEY_ALARM, Position.ALARM_TOW); + break; + case 6030: + case 6071: + position.set(Position.KEY_MOTION, true); + break; + case 6031: + position.set(Position.KEY_MOTION, false); + break; + case 6032: + position.set(Position.KEY_ALARM, Position.ALARM_PARKING); + break; + case 6090: + position.set(Position.KEY_ALARM, Position.ALARM_REMOVING); + break; + case 6091: + position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY); + break; + default: + break; + } + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -133,7 +194,7 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(deviceSession.getDeviceId()); - position.set(Position.KEY_EVENT, parser.next()); + decodeEvent(position, parser.nextInt()); position.setTime(parser.nextDateTime()); |