The i-Technology Media!
Register | Log in
   
 
.NET  ·  AJAX  ·  CLOUD  ·  ECLIPSE  ·  FLEX  ·  OPEN WEB  ·  iPHONE  ·  JAVA  ·  LINUX  ·  OPEN SOURCE  ·  ORACLE  ·  PBDJ  ·  SEARCH  ·  SILVERLIGHT  ·  SOA  ·  VIRTUALIZATION  ·  WEB 2.0  ·  WIRELESS  ·  XML
Comments
Drool, Britannia? Is the UK Failing the Cloud?
By Roger Strukhoff
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Jan. 8, 2012 11:38 AM EST
read more & respond »
Cloud Expo on Google News
Did you read today's front page stories & breaking news?

Cloud Expo & Virtualization 2011 West
Keynotes
Oracle
Opening Keynote | An Enterprise Cloud for Business-Critical Applications
Abiquo
Day 2 Keynote | The Enterprise Cloud Tightrope - Balancing for Success
Akamai
Day 3 Keynote | The DNA of an Enterprise Cloud
DIAMOND SPONSOR:
Oracle
Many Clouds, Many Choices'Cloud
PLATINUM PLUS SPONSORS:
Abiquo
Enterprise Cloud Best Practices - Town Hall - Join the discussion…
PLATINUM SPONSORS:
Intel
Progressing Toward the Federated, Automated and Client-Aware Cloud
New Relic
How to build an app with Twitter-like throughput
Rackspace
Computing in the Cloud Era
GOLD SPONSORS:
Gale Technologies
Practical Cloud Migration
IBM
Re-think IT. Re-inventing Business.
Intel/McAfee
Identity Driven Security in the Cloud
PerspecSys
Hackers Hackers Everywhere, Is My Public Cloud That Safe?
Red Hat
Unlock the Value of the Cloud
SHI
Mission Critical Applications and the Cloud - Myth or Reality?
SoftLayer
Not Your Grandpa's Cloud
Terremark
Integrating Enterprise Clouds
VMware
Upgrade to a vCloud
POWER PANELS:
Cloud Expo Silicon Valley: CTO Power Panel
Cloud Expo Silicon Valley: CEO Power Panel
Cloud Expo Silicon Valley: Cloud SuperStars Panel
Cloud Expo Silicon Valley: CloudNOW Panel
Click For 2010 West
Event Webcasts
Cloud Expo & Virtualization 2011 East
DIAMOND SPONSOR:
Dell
Dell & VMware Deliver the Enterprise Hybrid Cloud
PLATINUM PLUS SPONSORS:
Abiquo
Are Financial Services Organizations Risking Security by Avoiding Cloud Computing?
Oracle
From Consolidation to Enterprise Private PaaS
PLATINUM SPONSORS:
Intel
Driving the Transformation to Next Generation Cloud Data Centers
Rackspace
The Inevitability of an Open Cloud
GOLD SPONSORS:
CA Technologies
Follow YOUR path to Cloud Computing
Interxion
Who Keeps the Cloud in the Air?
Microsoft
Patterns for Cloud Computing
PerspecSys
War in the Clouds: Are you ready?
ServiceMesh
The Big Win: Stop Playing Small-Ball with Your Cloud Strategy
Terremark
Evaluating Enterprise Clouds
Xiotech
Cloud Storage: Myths and Realities
POWER PANELS:
Cloud Expo New York: CTO Power Panel
Cloud Expo New York: CEO Power Panel
Cloud Expo New York: CMO Power Panel
Cloud Expo New York: Wrap-Up Power Panel
Click For 2010 West
Event Webcasts
Live Google News by SYS-CON!
Top Three Links You Must Click On


PowerBuilder
Integrate Real-Time GPS Data Into Your PowerBuilder Applications
would you want to integrate real-time GPS data into your PowerBuilder applications anyway?

By: Deanne M. Chance
Feb. 19, 2006 12:30 PM
  • 1
  • 2
  • next ›
  • last »

We begin this article by asking the question: Why would you want to integrate real-time GPS data into your PowerBuilder applications anyway? After all, it's not likely you are going to connect a GPS receiver to your desktop computer and ask yourself where you are currently located. (At least I hope not!)

More likely, you will be utilizing some sort of field service application where you need to know how to get from point A to point B, for example, an insurance assessor who needs to know how to get to the next accident site. For this, the user might use a tablet PC connected to a GPS receiver with some sort of integrated mapping solution. However, as PowerBuilder programmers, how are we to write such applications? Currently, unlike PocketBuilder, there is no built-in support for hardware devices such as GPS receivers. That being said, we will go about the task of "rolling our own" and integrating it with Microsoft MapPoint 2004 to create an application that can plot your location on a map as a function of your current position.

In order to complete this exercise you will need the following:

  • A GPS receiver (the Pharos Bluetooth GPS receiver is used in this example)
  • Microsoft MapPoint 2004
  • PowerBuilder 9.x
  • Ian Thain's NMEA parser (look on CodeExchange in the special hardware section)
  • Some time to learn!
After reading this article you should be able to:
  • Write the serial communications necessary to communicate with your Bluetooth GPS receiver
  • Understand the basics of the NMEA protocol and the primary sentence returned by the receiver
  • Parse the NMEA messages returned by the GPS receiver
  • Convert the latitude and longitude returned by the receiver to decimal degrees (this is necessary for interfacing with MapPoint.)
  • Use Microsoft MapPoint 2004 to plot your current latitude and longitude on a map
That being said, we will go step-by-step to create an application that works by reading your current location from the GPS receiver and then sends the latitude and longitude to MapPoint for display on the map. In other words, using this code, you can always see where you are as a function of your current position. Figure 1 provides a picture of the finished product.

Now, how to create it!

Step 1: Make sure you, your computer, and GPS receiver are in an area where you can get decent satellite coverage. Outside is best, but probably not practical, so try near a window. If you are using Bluetooth, you have about 30 feet to play with in regards to the location of your GPS receiver and computer.

Note, for an excellent explanation of how GPS receivers work, see http://electronics.howstuffworks.com/gps.htm.

Step 2: Create a main window and drop a Microsoft MapPoint control on it. Add a button for the purpose of retrieving the GPS data and plotting your position on the map as a function of your current coordinates. Initialize the control with the following code:

ioo_Map = ole_MapControl.Object.NewMap(1)
ole_MapControl.Object.Units = 1

The first statement assigns an instance variable to a new occurrence of the map. In this case, we are specifying the map of North America. We will use the instance variable later as a "pointer" to perform more operations on the control. The second line specifies that we would like our units to be interpreted as kilometers. This is necessary since the GPS receiver will return the current altitude in meters.

Step 3: Declare the global external function prototypes for performing the serial I/O necessary to "talk to" your GPS receiver. You might be wondering why not just use the built-in PowerBuilder I/O functions, for example, FileOpen and FileRead? The underlying reason is that PowerBuilder will buffer the data for you (on top of the native buffering that the OS provides). That can be problematic for serial I/O devices. That is why we are using the kernel calls. Here are their prototypes.

  • Function Long CreateFile(ref string lpszName, long fdwAccess, long fdwShareMode, long lpsa, long fdwCreate, long fdwAttrsAndFlags, long hTemplateFile) Library "Kernel32.dll"
  • Function Long CloseHandle(Long hObject) Library "Kernel32.dll"
  • Function Long ReadFile(Long hFile, ref string lpBuffer, long nBytesToRead, ref Long & nBytesRead, Long lNull) Library "Kernel32.dll"
  • Function Long WriteFile(Long hFile, ref string lpBuffer, long nBytesToWrite, ref Long & nBytesWritten, LONG lNull) Library "Kernel32.dll"
Step 4: Add the following functions to your main window. These will be used to get the GPS data out of the receiver. In the next section we will show how to use them together to achieve our means. However first, a little explanation is in order.
  • Boolean wf_detect_bt() (see Listing 1)
  • Boolean wf_close_bt() (see Listing 2)
  • Boolean wf_write_gps() (see Listing 3)
  • Boolean wf_read_gps (see Listing 4)
  • String wf_get_token(ref string as_string, string as_token) (see Listing 5)
The most interesting of these functions is wf_read_gps(). This does the actual work of reading and parsing the NMEA sentences returned by the receiver. You might be wondering what NMEA is. In a nutshell, it's a protocol for returning real-time position information to a hardware device such as a GPS receiver. An excellent source for information regarding this protocol can be found at www.gpsinformation.org/dale/nmea.htm.

The next order of business is to see how Ian Thain wrote his object to go about parsing a particular NMEA stream. For that, all we have to do is look at the format of an example sentence. Since our code picks off GGA, essential fix data that provide 3D location and accuracy data, we will look at that. Here is a sample:

$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47

Where:
GGA Global Positioning System Fix Data
123519 Fix taken at 12:35:19 UTC
4807.038,N Latitude 48 deg 07.038' N
01131.000,E Longitude 11 deg 31.000' E
1      Fix quality: 0 = invalid
      1 = GPS fix (SPS)
      2 = DGPS fix
      3 = PPS fix
      4 = Real Time Kinematic
      5 = Float RTK
      6 = estimated (dead reckoning) (2.3 feature)
      7 = Manual input mode
      8 = Simulation mode
08      Number of satellites being tracked
0.9      Horizontal dilution of position
45.4,M      Altitude, Meters, above mean sea level
46.9,M      Height of geoid (mean sea level) above WGS84
         ellipsoid
(empty field) time in seconds since last DGPS update
(empty field) DGPS station ID number

What you can see from this example is that the data is comma-delimited. This makes it a prime candidate for easy parsing by storing it in an external DataWindow using the ImportString function. To get at the individual elements, we only need to index them by their position within the DataWindow.

  • 1
  • 2
  • next ›
  • last »
Published Feb. 19, 2006— Reads 23,295 — Feedback 4
Copyright © 2006 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
About Deanne M. Chance
Ms. Chance graduated in 1996 with a degree in computer science from the University of Illinois. She has been a frequent contributor to the PowerBuilder Developer's Journal and gave a key presentation at Sybase TechWave 2005 entitled "A Real-Time Physical Inventory Solution Using PocketBuilder ASA and a WiFi Connection." She has held several engineering positions, starting a career at Motorola where she focused on mobile I.P. by doing real-time embedded programming for the base radio controller group as part of the iDEN/Nextel project.

Add Your Feedback

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

#4
josen30308 commented on 6 May 2009

I just got a simple question. wich is the code NMEA and where am I supposed to put this code?
Josen30308@hotmail.com

sincerely

Jose

#3
SYS-CON Belgium News Desk commented on 19 Feb 2006

We begin this article by asking the question: Why would you want to integrate real-time GPS data into your PowerBuilder applications anyway? After all, it's not likely you are going to connect a GPS receiver to your desktop computer and ask yourself where you are currently located. (At least I hope not!)

#2
news desk commented on 18 Feb 2006

We begin this article by asking the question: Why would you want to integrate real-time GPS data into your PowerBuilder applications anyway? After all, it's not likely you are going to connect a GPS receiver to your desktop computer and ask yourself where you are currently located. (At least I hope not!)

#1
SYS-CON Belgium News Desk commented on 18 Feb 2006

We begin this article by asking the question: Why would you want to integrate real-time GPS data into your PowerBuilder applications anyway? After all, it's not likely you are going to connect a GPS receiver to your desktop computer and ask yourself where you are currently located. (At least I hope not!)


Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers

ADS BY GOOGLE

Breaking Java News
NASA Selects Rhode Island Teacher to be "Agent of Change" for Stem Education
75 Per Cent of Keystone XL Pipe would be 'Made in North America'
comScore Media Metrix Ranks Top 50 U.S. Web Properties for January 2012
Endo Pharmaceuticals to Present at J.P. Morgan Annual Global High Yield & Leveraged Finance Conference
National Education Association's 'Read Across America Tour - Driven by Mazda' To Raise $1 Million for Public School Libraries
Midland Exploration Announces the Grant of Options
TDb Split Corp.: Regular Monthly Dividend Declaration for Class A and Preferred Share
NASA Selects Virginia Teacher To Be "Agent of Change" for STEM Education
Income STREAMS III: Monthly Distribution Declared for Equity Dividend Share
Capital Gains Income STREAMS: Monthly Distribution Declared for Equity Dividend Share

ADVERTISE   |   MAGAZINE SUBSCRIPTIONS   |   FREE BREAKING-NEWSLETTERS!   |   SYS-CON.TV   |   BLOG-N-PLAY!   |   WEBCAST   |   EDUCATION   |   RESEARCH

.NET Developer's Journal - .NETDJ   |   ColdFusion Developer's Journal - CFDJ   |   Eclipse Developer's Journal - EDJ   |   Enterprise Open Source Magazine - EOS
Open Web Developer's Journal - OPENWEB   |   iPhone Developer's Journal - iPHONE   |   Virtualization - Virtualization   |   Java Developer's Journal - JDJ   |   Linux.SYS-CON.com
PowerBuilder Developer's Journal - PBDJ   |   SEO / SEM Journal - SJ   |   SOAWorld Magazine - SOAWM   |   IT Solutions Guide - ITSG   |   Symbian Developer's Journal - SDJ
WebLogic Developer's Journal - WLDJ   |   WebSphere Journal - WJ   |   Wireless Business & Technology - WBT   |   XML-Journal - XMLJ   |   Internet Video - iTV
Flex Developer's Journal - Flex   |   AJAXWorld Magazine - AWM   |   Silverlight Developer's Journal - SLDJ   |   PHP.SYS-CON.com   |   Web 2.0 Journal - WEB2
Apache   |   CMS   |   CRM   |   HP   |   Oracle Journal   |   Perl   |   Python   |   Red Hat   |   Ruby on Rails   |   SAP   |   SaaS

SYS-CON MEDIA:   ABOUT US   |   CONTACT US   |   COMPANY NEWS   |   CAREERS   |   SITE MAP
SYS-CON EVENTS:   |  AJAXWorld Conference & Expo  |  iPhone Developer Summit  |  Cloud Computing Conference & Expo  |  SOA World Conference & Expo  |  Virtualization Conference & Expo
INTERNATIONAL SITES:   India  |  U.K.  |  Canada  |  Germany  |  France  |  Australia  |  Italy  |  Spain  |  Netherlands  |  Brazil  |  Belgium
 Terms of Use & Our Privacy Statement     About Newsfeeds / Video Feeds
Copyright ©1994-2008 SYS-CON Publications, Inc. All Rights Reserved. All marks are trademarks of SYS-CON Media.
Reproduction in whole or in part in any form or medium without express written permission of SYS-CON Publications, Inc. is prohibited.
 
close this window