GPS Event [1] – Sensor

gpsI was inspired by RuleCore Marco’s recent posts and have decided to put together a simple EP/CEP example, just for fun of doing it. The idea is to use a GPS, write an adapter to capture the GPS data, transfer it to a CEP server, tinker with events, and blog along the way.

I have a handheld Magellan GPS with an option to output data in several formats. By selecting the V2.1 option in the NMEA setup, the GPS constantly transmits data over the RS232 port—this can be simply monitored using HyperTerminal in Windows. Here is an example:

$PMGNST,04.02,2,T,699,09.5,+00740,00*4D
$GPGLL,4338.8243,N,07923.9149,W,172020.197,A*24
$GPGGA,172020.20,4338.8243,N,07923.9149,W,2,05,10.0,00119,M,,,,*02
$GPRMC,172020.20,A,4338.8243,N,07923.9149,W,00.0,000.0,291208,11,W*49
$GPGSA,A,2,02,09,12,05,04,,,,,,,,10.0,10.0,*14
$GPGSV,3,1,10,04,85,312,36,17,52,094,,02,41,248,48,12,30,312,39*75
$GPGSV,3,2,10,20,21,045,,05,18,317,39,28,16,160,,09,14,265,41*78
$GPGSV,3,3,10,23,07,081,,32,03,031,,135,17,243,44,138,32,217,44*7C
$GPGLL,4338.8243,N,07923.9149,W,172021.205,A*2D
$GPGGA,172021.20,4338.8243,N,07923.9149,W,2,05, 9.9,00119,M,,,,*12
$GPRMC,172021.20,A,4338.8243,N,07923.9149,W,00.0,000.0,291208,11,W*48
$GPGSA,A,2,02,09,12,05,04,,,,,,,,09.9,09.9,*14
$PMGNST,04.02,2,T,699,09.5,+00740,00*4D

Looks a bit confusing, but each row is a NMEA sentence.

The data set contains lots of information, some of it redundant—for basics only one sentence is needed:

Basic data
$GPRMC,172021.20,A,4338.8243,N,07923.9149,W,00.0,000.0,291208,11,W*48

where:

Field Description
$ Start of NMEA sentence
GP Talker Id; GP = GPS
RMC Message type; RMC = Recommended minimum data
172021.20 Time-stamp; 17:20:21.20 UTC
A Status; A=active, V=Void
4338.8243 Latitude 43deg 38.8243′
N North
07923.9149 Longitude 79deg 23.9149′
W West
00.0 Speed over the ground in knots
000.0 Course made good
291208 Date; 2008-12-29
11 Magnetic variation
W West
*48 Checksum

 

So now the objective is to:

  1. Capture this data using an application written in something (VB,VBA, C++, Python).
  2. Parse the data and create an event object.
  3. Serialize the object, probably to XML or JSON.
  4. Transfer the event-object to a CEP application—thinking Coral8—running on a different machine to simulate real-world GPS usage.
  5. Use the CEP application to generate notifications when something happens—not quite sure what at this time.

 

First things first, let’s define the event object using XML.

<event>
	<head>
		<id>bbc32a3b-8cdc-475f-bbf0-47a81ccca4cf</id>
		<type>GPS</type>
		<time_stamp>2008-12-29T17:20:21Z</time_stamp>
		<entity>DS_GPS_001</entity>
	</head>
	<body>
		<latitude>43 38.8243 N</latitude>
		<longitude>079 23.9149 W</longitude>
		<speed>00.0</speed>
		<course>000.0</course>
		<valid>True</valid>
	</body>
</event>

 

OK, this is what I would like to get—all the data is from the above example. In addition to the GPS data we have:

Field Description
id Unique event Id, always different.
entity Unique id of the device generating the event.
type Type of the event (GPS).

 

To be continued.