Sei sulla pagina 1di 5

Live tracker documentation

Live tracker is an GPS tracking system for the GPS tracking device from TrakMate.
GPS Listener is written in Java. TrakMate GPS device is configured to send lat/long packets to a
particular server and port. In this application, GPS devices are pre-configured to send data to host ec254-173-220-171.compute-1.amazonaws.com and port -1339.
GPS Listener listens for incoming data from each device and stores data in database.
Below is db details which is mentioned in Config.xml of Listener component.
<DB_IP>trackdb.cf53zztlzwqg.us-east-1.rds.amazonaws.com:3360</DB_IP>
<DB_NAME>trackdb</DB_NAME>
<DB_USER>trackuser</DB_USER>
<DB_PWD>trackmaster</DB_PWD><!-- DB Connection End-->

Along with mysql database, PubNub is used in this application for realtime data streaming. PubNub
utilizes Publish/Subscribe model where incoming data from GPS devices are published to
corresponding channels and same is being subscribed in the front end. Whenever new packet arrives in
the server , same packet is being subscribed in the front end and marker(vehicle) is moved to that
position.
Note :- TrakMate has configuration settings to set packet rate. By default it is 1 packet per min per
device.
Java classes used in the GPS listener:
1. Main.java This is the main class of the application. It is multithreaded application handles
parsing/storing packets in database as well as publish data to PubNub data stream.
There are 2 formats of packets.
1. Periodic packet This is normal packet generated from device at every update interval.
It stats with ^TMPER. There is separate handler for periodic packet and these packets
are stored in the table PERIODIC_PACKET in mysql database.
2. Alert packet These packets are generated when there is alert from device such as
device down or error in packet etc. Prefix for alert packet is ^TMALT. These packets
are stored under ALERT_PACKET table of mysql database.
2. JDBC.java This class is used to create and maintain mysql database connection.
Steps to install GPS listener:
1. git clone https://santushet@bitbucket.org/santushet/vehicle-tracking.git
2. Goto folder vehicle_tracking
3. run command mvn install. This command compiles and executes class files.
4. After compiling and executing class files, jar file is available under folder target
5. Goto folder target and run command- java -jar trackApp-0.0.1-SNAPSHOT.jar &
Troublshooting:
Now we can check whether data is being received or not by checking row count in mysql. Also we can
check using PubNub debug console by providing channel name and subscriber key/publish key.(same
keys are mentioned in the java publish code). If everything is fine, published messages are displayed in
messages tab. Here is the link for debug console.https://www.pubnub.com/console/

Screenshot of pubnub debug console


Log files are stored under /log folder (in datewise order format ddmmyyyy).

Web app components:


backend:
Simple NodeJS/Express REST server for storing Leaflet Draw features.
Tools;
Angular, bower, Leaflet, mapbox, google map,mongodb
Usage:
bower install
install mongodb

Live WOC:
This page provides live status of each vehicle. Different color notions are used to identify the state of
vehicle.
Color

Meaning

Gray

Device disconnected

Green

Ignition ON

Red

Ignition OFF

Implementation:
Steps:
1. Each devices are publishing data to different channels. For example, vehicle1 is publishing data to
channel-1. In frontend we are subscribing to same channel and whenever data is updated, marker is
moved to that position. When marker enters into geofence or exits from geofence, record with
timestamp,fence name etc are stored in database. These records are shown in reports page. To check
vehicle inside or outside geofence, leaflet-pip is used.
2. Pubnub.history is used to get last location of data to show on the map when web page is opened.
3. Leaflet is used to show map.
4. REST call used to show all the fences on live track page.

Geofence:
I have used Leaflet.draw to draw polygons and rectangles on a map. Leaflet.draw does not support
storage of these objects out-of-the-box. This is solved by using
the draw:edited, draw:deleted and draw:created events to store the objects to a database using a REST
API.
Leaflet-pip is used to check vehicle inside the fence or not.If it is inside the fence, alert message is
recorded in the database and same is shown in report.
Mongodb is used to store geoJson data. The reason to choose mongodb is it provides good support for
geoJson data.
Mongodb config is mentioned in server.js file. Db name-leaflet_map. Currently it is mentioned as
localhost. We need to install in other machine and give host name in place of localhost.
Collection name to hold fence details- layercollection
Collection name to hold fence status such as outside or inside- fencestatus.
The code related to this part is available in server.js file.
History Playback:
This feature is used to see history data. Animation of vehicle is implemented in javascript. It has feature
of reverse movement of vehicle. Also it draws polyline along the path.

Potrebbero piacerti anche