SIM UNIVERSITY SCHOOL OF SCIENCE AND TECHNOLOGY APPLICATIONS OF GPS IN LOW COST OBJECT TRACKING SYSTEM STUDENT : TAN YONG PENG, CHARLES (J0704259) SUPERVISOR : DR. TAN BEE KOON PROJECT CODE : JAN2010/ENG/0047 A project report submitted to SIM University
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
SIM UNIVERSITYSCHOOL OF SCIENCE AND TECHNOLOGY
APPLICATIONS OF GPS IN LOW COST OBJECT TRACKING SYSTEM
STUDENT : TAN YONG PENG, CHARLES (J0704259)
SUPERVISOR : DR. TAN BEE KOON PROJECT CODE : JAN2010/ENG/0047
A project report submitted to SIM Universityin partial fulfilment of the requirements for the degree of
Bachelor of Engineering (or Bachelor of Electronics)
January 2010
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
ABSTRACT
The Global Positioning System (GPS) is a location system based on a constellation of 24 to
32 satellites, orbiting round the earth at altitudes of 11,000 miles. In its earlier years, GPS
was developed in the US, for the military Department of Defense (DOD). Through the years
of development and improvement, we have advanced to being able to use GPS for the
purpose of tracking our precise location worldwide, and as an aiding tool for non-military
usage. Currently, GPS device is used as a navigation tool that assists the user on finding
directions and navigating to the destination. GPS can be used either in the forest for
assistance on finding the way out or in a vehicle to travel to the desired location. As such, it
saves our time, energy and petrol. Eventually, overall GPS improves efficiency in our life.
The main objective in this project is to develop a low cost object tracking system using
limited resources, with the possibility of an added security feature. The low cost GPS object
tracking systems would track the movement and determine the exact location of objectives.
This allows the owner/company to track the delivery objects like goods, cargo, vehicles, etc.
Thus, drivers would not be able to use the vehicle for personal usage, which in return
increases the efficiency. This helps the company save money spent on fuel/petrol and
increases its profit. The GPS can be used as an added security to deter vehicle theft and in
notifying the vehicle owner once the vehicle is being stolen.
In this project, a GPS-enabled tracker, a mobile phone, mobile broadband adaptor,
laptop and application using C# programming language will be used for integration to fulfil
the project objectives. Several functions like retrieving the position, sending SMS, calculation
of coordination will be implemented on the GPS tracker and customized application. In
addition, an application on the laptop or computer will plot the map of the log file of the
coordination (Longitude & Latitude) which the vehicle has travelled.
This report will include topics like objectives, literature review on GPS, SMS technology and
project and time management. More importantly, it will also cover tasks like development
and implementation of conceptualised idea, testing, evaluation and
troubleshooting/debugging of the programmes and systems. These will be covered in greater
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
TABLE OF CONTENTS Page
ABSTRACT..............................................................................................................................................................iACKNOWLEGDEMENTS.....................................................................................................................................iiTABLE OF CONTENTS........................................................................................................................................iiiLIST OF FIGURES..................................................................................................................................................vLIST OF TABLES..................................................................................................................................................viLIST OF APPENDICES.........................................................................................................................................vi1 INTRODUCTION............................................................................................................................................1
1.1 Overview of Background.........................................................................................................................11.2 Project Objectives....................................................................................................................................11.3 Scope of the Project..................................................................................................................................2
1.3.1 GPS Technology................................................................................................................................21.3.2 Selection of Hardware Devices..........................................................................................................21.3.3 Selection of Programming Language.................................................................................................31.3.4 Concept of SMS Technology.............................................................................................................4
1.4 Project Application...................................................................................................................................41.5 Terms of Reference.................................................................................................................................5
1.5.1 Project Design and Development.......................................................................................................51.5.2 Project Testing and Evaluation..........................................................................................................51.5.3 Results and Enhancement...................................................................................................................61.5.4 Troubleshooting and Evaluation........................................................................................................6
1.6 Layout of Project Report..........................................................................................................................62 Project Management.........................................................................................................................................8
3 Literature Review...........................................................................................................................................113.1 Global Positioning System (GPS) Introduction.....................................................................................113.2 Overview of GPS...................................................................................................................................113.3 GPS Segments........................................................................................................................................123.4 Operation of GPS...................................................................................................................................13
3.5 GPS Applications...................................................................................................................................173.6 Short Message Service (SMS) Technology...........................................................................................17
4 System Integration..........................................................................................................................................204.1 System Overview...................................................................................................................................204.2 System Architecture...............................................................................................................................22
5 System Design Considerations.......................................................................................................................255.1 GPS tracker SMS format........................................................................................................................255.2 GPS Data source....................................................................................................................................265.3 Export SMS data....................................................................................................................................265.4 GPS Errors.............................................................................................................................................26
6.4 Mapping Module....................................................................................................................................497 TESTING AND EVALUATION..................................................................................................................52
7.1 Troubleshooting and Debugging..................................................................................................................537.1.1 Test Condition 1: GPS Tracking System.........................................................................................547.1.2 Test Condition 2: Security Features.................................................................................................567.1.3 Test Condition 3: Track Vehicle position using SMS......................................................................587.1.4 Test Condition 4: Mapping Feature.................................................................................................60
7.2 Functional Test – GPS Tracking System...............................................................................................628 PROBLEMS AND DISCUSSION................................................................................................................63
9 CONCLUSIONS AND RECOMMENDATIONS........................................................................................689.1 CONCLUSIONS....................................................................................................................................689.2 RECOMMENDATION...............................................................................................................................68
10 CRITICAL REVIEWS AND REFLECTIONS.........................................................................................69References [Books]................................................................................................................................................70References [Websites]............................................................................................................................................71Appendix A............................................................................................................................................................74
Specification of GPS Tracker Device, MT80....................................................................................................74Specification of Huawei E1550 Mobile Adaptor...............................................................................................75Appendix B-1: Gantt chart................................................................................................................................76Appendix B-2: Activities Breakdown Chart......................................................................................................77Appendix B-3: Bill of Material (BOM).............................................................................................................78
Appendix E.............................................................................................................................................................90Field Testing Results..........................................................................................................................................91Appendix E-1: Journey from Alexandra to Ang Mo Kio...................................................................................91Appendix E-2: Journey from SIM University to Singapore Polytechnic and back to SIM University.............93
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
LIST OF FIGURES
Figure 1.1: Different Views of MT80 GPS Tracker................................................................................................3Figure 1.2: Mobile Adapter......................................................................................................................................3Figure 2.1: Work Breakdown Structure (WBS).......................................................................................................8Figure 3.1: The Three Components of the elements of GPS.................................................................................13Figure 3.2: GPS – The Error Budget.....................................................................................................................15Figure 3.3: Principle of Doppler Shift....................................................................................................................16Figure 4.1: System Process Flow...........................................................................................................................20Figure 4.2: Security setting of GPS tracker using Movement Alarm....................................................................21Figure 4.3: Security setting of GPS tracker using Geo-Fence...............................................................................22Figure 4.4: System Architecture of GPS tracking..................................................................................................22Figure 4.5: MT80 GPS tracker Parameter Editor...................................................................................................23Figure 4.6: Illustration of SMS interval setting to 60 minutes interval..................................................................23Figure 4.7: Illustration of Security setting to 60 minutes interval.........................................................................24Figure 6.1: Flowchart of GPS Tracker with Mobile Adaptor................................................................................29Figure 6.2: Flowchart of GPS Tracking Application.............................................................................................30Figure 6.3: GPS Tracking System - Graphical User Interface (GUI)....................................................................31Figure 6.4: Flowchart of rdGPSLive_CheckedChanged() function.......................................................................32Figure 6.5: Flowchart of rdGPSHis_CheckedChanged() function........................................................................33Figure 6.6: Flowchart of btnBrowse_Click () function..........................................................................................34Figure 6.7: Flowchart of btnRead_Click() function...............................................................................................35Figure 6.8: Flowchart of btnView_Click () function.............................................................................................36Figure 6.9: Flowchart of btnClear_Click () function.............................................................................................37Figure 6.10: Flowchart of btnReset_Click () function...........................................................................................38Figure 6.11: Flowchart of btnExit_Click () function.............................................................................................38Figure 6.3.12: Flowchart of ReadLiveGPSData(string strpath) function..............................................................41Figure 6.13: Flowchart of ReadHistoryData() function.........................................................................................44Figure 6.14: Flowchart of ConvertFromDMS2DD(string strData) function........................................................46Figure 6.15: Flowchart of Mid(string strData, int iPos1, int iPos2) Function.......................................................47Figure 6.16: Flowchart of KillProcess() function..................................................................................................48Figure 6.17: Flowchart of Mapping Module..........................................................................................................50Figure 6.18: Google Map with Location Markers..................................................................................................51Figure 7.1: Actual Field Testing Equipments........................................................................................................52Figure 7.2: Process Flow Chart of Troubleshooting..............................................................................................53Figure 7.3: Process Flow chart of GPS Tracking System Debugging...................................................................54Figure 7.4: Screenshot of GPS Tracking System GUI with data from SMS.DTC................................................55Figure 7.5: Movement Alarm setting and Alert.....................................................................................................56Figure 7.6: Illustration of Geo-Fence setting and Alert.........................................................................................57Figure 7.7: Track by SMS......................................................................................................................................58Figure 7.8: Track on Demand................................................................................................................................59Figure 7.9: Process Flow Chart of Google Map Debugging..................................................................................60Figure 7.10: Confirmation of markers information with log file...........................................................................61Figure 7.11: Functional Testing of the GPS Tracking System..............................................................................62Figure 8.1: USB-to-Serial Adaptor........................................................................................................................63Figure 8.2: Illustration of Sending SMS to GPS Tracker to set 1 minute..............................................................64Figure 8.3: Illustration of GPS Tracker Time Zone Set.........................................................................................65Figure 8.4: Properties setting of GPS tracking software on Compatibility tab......................................................66Figure 8.5: Google Map API loaded on Mozilla Firefox Browser........................................................................67Figure 8.6: Google Map API loaded on Microsoft Internet Explorer....................................................................67
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
LIST OF TABLES
Table 3.1: Concept development and standardisation of SMS.............................................................................19Table 3.2: Development of SMS in the market.....................................................................................................19Table 5.1: GPS data information............................................................................................................................25Table 6.1: Format of Latitude and Longitude in Degrees Minutes Seconds..........................................................45
LIST OF APPENDICES
Figure E-1: Journey of field testing from Alexandra Road to Ang Mo Kio..........................................................92Figure E-2: Journey of field testing from SIM University to Singapore Polytechnic and back to SIM University................................................................................................................................................................................94Figure E-3: SIM University...................................................................................................................................94Figure E-4: Ngee Ann Polytechnic........................................................................................................................95Figure E-5: Sunset Way.........................................................................................................................................95Figure E-6: Singapore Polytechnic........................................................................................................................96Figure E-7: SingTel Tower at Dover......................................................................................................................96Figure E-8: National University of Singapore (NUS)............................................................................................97Figure E-9: Ministry of Education (MOE) at Buona Vista....................................................................................97
Figure 6.3.12: Flowchart of ReadLiveGPSData(string strpath) function
End
Yes
Yes
Prompt “*Exception Error*” error message
No
B
Add all data to grid view table in order of Date Time, Latitude, Longitude and Speed respectively
Count and display row numbers of record at Total GPS Records field
Create and write data to “C:\GPS_Livelog.txt” in order of Date Time, Latitude, Longitude, Speed respectively.Latitude and Longitude are converted from Degrees Minutes Seconds format to Decimal Degrees format using ConvertFromDMS2DD(string strData function
No
End
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
Figure 6.13: Flowchart of ReadHistoryData() function
No
No
Yes
Yes
No
Prompt “*Exception Error*” error message
Is the length of each SMS data contains 6 data field which are phone name, Latitude and Longitude, Speed, Date, time and extra information?
Yes
B
Clear all the prefix text: “Latitude=”, “Longitude=”and “Speed=”
Add all data to grid view table in order of Date Time, Latitude, Longitude, Speed respectively
C
End
No
No
C
Count and display row numbers of record at Total GPS Records field
Create and write data to “C:\GPS_Hislog.txt” in order of Date Time, Latitude, Longitude, Speed respectively.Latitude and Longitude are converted from Degrees Minutes Seconds format to Decimal Degrees format using ConvertFromDMS2DD(string strData function
Yes
End
Prompt “*Exception Error*” error message
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
References [Books]
[1] Robert I. Egbert and Joseph E. King, The GPS handbook: an outdoorsman’s guide. Canada: Burford Books Inc, 2003.
[2] Natalie M. Rosinsky, Satellites and the GPS. United States of America: Compass Point Books, 2004.
[3] Jeanne Sturm, GPS: Global Positioning System. United States of America: Rourke Publishing , 2009.
[4] Ahmed El-Rabbany, Introduction to GPS: The Global Positioning System, Second Edition. United States of America: Artech House, Inc, 2006.
[5] Gwenael Le Bodic, Mobile Messaging Technologies and Services: SMS, EMS and MMS. England: John Wiley & Sons Ltd, 2003.
[6] Bowditch, N., “The America Practical Navigator”, Bicentennial Edition, NIMA, Pub. No. 9, 2002. CD-ROM
[7] Parkinson, B. W., “A History of Satellite Navigation,” Navigation: Journal of The Institute of Navigation, Vol. 42, No. 1, Special Issue, 1995, pp.109-164
[8] Wright, Peter 2006, 'Beginning Visual C# 2005 Express Edition From Novice to Professional', Apress, United States of America.
[9] Foxall, James, 'Teach Yourself C# in 24 Hours', Sams Publishing, United States of America, 2002
[10] Nash, Trey, 'Accelerated C# 2008', Apress, United States of America, 2007
[11] Drayton Peter, Albahari Ben, Neward Ted, 'C# In A Nutshell', O’ Reilly & Associates Inc., United States of America, 2002
[12] FRP, U.S. Federal Radionavigation Plan, 2001
[13] Langley, R. B., “Why is the GPS Signal so Complex?” GPS World, Vol. 1 No. 3, May/June 1990, pp. 56-59.
[14] Wells, D. E., et al., Guide to GPS Positioning, Fredericton, New Brunswick: Canadian GPS Associates, 1987
[15] Seeber, G., Satellite Geodesy, 2nd revision edition, Berlin, Germany: Walter de Gruyter, 2003
[16] Friedhelm Hillebrand (editor); Finn Trosby, Kevin Holley, Ian Harris, ‘Short message service (SMS): the creation of personal global text messaging’, Wiley & Sons, New Jersey, 2010
[17] Wells D.E., et al., Guide to GPS Positioning, Fredericton, New Brunwick: Canadian GPS Associates 1987
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
[18] Linyuan X., Multipath in GPS Navigation and Positioning, GPS solutions, Vol. 8, 2004, pp.49-50
[19] Weill, L. R., Conquering Multipath: The GPS Accuracy Battle, GPS world, Vol. 8, No. 4, April 1997, pp. 59-66
[20] Langley, R. B., Time, Clocks and GPS, GPS World, Vol. 2, No. 10, November/December 1991, pp.38-42
[21] El-Rabbany, A., The Effect of Physical Correlations on the Ambiguity Resolution and Accuracy Estimation in GPS Different Positioning, Technical Report No. 170, Department of Geodesy and Geomatics Engineering, University of New Brunswick: Canadian GPS Associates, 1987
References [Websites]
[1] Aerospace Corporation (2007) GPS Primer, Elements of GPShttp://www.aero.org/education/primers/gps/elements.html
[2] Appleseed, Johnny (1999-2009) The Theory and Practice of GPShttp://www.ja-gps.com.au/whatisgps.html#anchor5186443
[3] Article by Darren Griffin, How does the Global Positioning System works?http://www.pocketgpsworld.com/howgpsworks.php
[4] Garmin, What is GPS?http://www8.garmin.com/aboutGPS/
[5] First U.S. Publication in June, 1996 by: Corvallis Microtechnology, Inc, Introduction to the Global Positioning System for GIS and TRAVERSEhttp://www.cmtinc.com/gpsbook/
[7] Maps-GPS-Info.com, GPS History, How it all startedhttp://www.maps-gps-info.com/gps-history.html
[8] Maps-gps-info.com, GPS Cell Phone Tracking - I Know Where You Arehttp://www.maps-gps-info.com/gps-cell-phone-tracking.html
[9] National Space-Based Positioning, Navigation, and Timing Coordination Office, The Global Positioning Systemhttp://www.gps.gov/systems/gps/index.html
[10] Nelson, Robert A. (1999), The Global Positioning Systemhttp://www.aticourses.com/global_positioning_system.htm
[13] Smithsonian Institution, How Does GPS Workshttp://www.nasm.si.edu/gps/work.html
[14] Starcom Systems (2004-2009) Fleet Managementhttp://www.starcomsystems.com/services_fleeta.asp
[15] SunSat Statellite Solution Co., GSM mobile phone tracking system via the GPS-TRACK satellite networkhttp://www.themobiletracker.com/english/index.html
[16] The Aerospace Corporation, How GPS Workshttp://www.aero.org/education/primers/gps/howgpsworks.html
[17] Topbits, How GPS Tracking Workshttp://www.topbits.com/how-gps-tracking-works.html
[18] Wikipedia, the free encyclopedia, Global Positioning Systemshttp://en.wikipedia.org/wiki/Global_Positioning_System
[19] Wikipedia, the free encyclopedia, GPS Satellite http://en.wikipedia.org/wiki/GPS_satellite
[20] Wikipedia, the free encyclopedia, Compasshttp://en.wikipedia.org/wiki/Compass
[21] Wikipedia, the free encyclopedia, Sextanthttp://en.wikipedia.org/wiki/Sextant
[22] Wikipedia, the free encyclopedia, GPS Tracking Devicehttp://en.wikipedia.org/wiki/GPS_tracking_unit
[23] Wikipedia, the free encyclopedia, Trilaterationhttp://en.wikipedia.org/wiki/Trilateration
[24] Wikipedia, the free encyclopedia, GPS tracking unithttp://en.wikipedia.org/wiki/GPS_tracking_unit
[25] Wikipedia, the free encyclopedia, Trilaterationhttp://en.wikipedia.org/wiki/Trilateration
[26] Wikipedia, the free encyclopedia, Doppler Effecthttp://en.wikipedia.org/wiki/Doppler_effect
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
[27] Wikipedia, the free encyclopedia, Beidou Navigation Systemhttp://zh.wikipedia.org/wiki/%E5%8C%97%E6%96%97%E5%AF%BC%E8%88%AA%E7%B3%BB%E7%BB%9F
[28] Wikipedia, the free encyclopedia, Galileo Positioning Systemhttp://zh.wikipedia.org/w/index.php?title=%E4%BC%BD%E5%88%A9%E7%95%A5%E5%8D%AB%E6%98%9F%E5%AE%9A%E4%BD%8D%E7%B3%BB%E7%BB%9F&variant=zh-cn
[29] Wikipedia, the free encyclopedia, SMShttp://en.wikipedia.org/wiki/SMS
[30] Developer’s home, Basic Concepts of SMS Technologyhttp://www.developershome.com/sms/sms_tutorial.asp?page=basicConcepts
[31] Geneq inc., GPS – The Error Budgethttp://www.sxbluegps.com/gps-error-Budget.html#gpsworks
[32] IGS (International GNSS Service, IGS Product Tablehttp://igscb.jpl.nasa.gov/components/prods.html
[33] U.S Observatory, USNO GPS Time Transferhttp://tycho.usno.navy.mil/gpstt.html
[32] George Birbilis @zoomicon, Start/kill process with VB.nethttp://zoomicon.wordpress.com/2007/04/15/startkill-processes-with-vb-net
[33] ASCII Control Characters Definitionhttp://www.lammertbies.nl/comm/info/ascii-characters.html#endt
[34] ASCII Tablehttp://www.asciitable.com/
[35] Koobmeei blogspot, Convert Degrees, Minutes, and Second to Decimal Degreeshttp://koobmeej.blogspot.com/2008/08/convert-degrees-minutes-and-seconds-to.html
[36] Sparky Spider's Discoveries blogspot, Javascript: Convert DMS to DDhttp://sparkyspider.blogspot.com/2006/12/javascript-object-convert-from-dms-to.html
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
Appendix A
Specification of GPS Tracker Device, MT80
Items SpecificationDeviceCharging Voltage DC 4.2-5.5V/400mA (Mini USB port)Battery Rechargeable and removable 700 mAh battery (3.7V)Dimension 61x42x15mmWeight 50g (with battery)Operating temperature
-20° to 55° C
Humidity 5% to 95% Non-condensingWork time 96 hours in standby mode and 10 hours in continuous working mode
LED 2 LEDs showing GPS, GSM statusButton One SOS panic button and one power On/Off buttonMicrophone Built-in microphone for wiretappingMemory 4MBGSMGSM module Quad-band GSM 850/900/1800/1900MHzSIM Card Interface Support SIM card: 1.8V, 3VGPSGPS Chipset Latest SiRF Star III high sensitivity single-chip GPS receiverGPS Sensitivity -159dBGPS Frequency L1, 1575.42 MHzC/A Code 1.023 MHz chip rateChannels 20 channel all-in-view trackingPosition Accuracy 10 meters, 2D RMSVelocity Accuracy 0.1 m/sTime Accuracy 1 us synchronized to GPS timeDefault datum WGS-84Reacquisition 0.1 sec., averageHot start <2 sec., averageWarm start 38 sec., averageCold start 42 sec., averageAltitude Limit 18,000 meters (60,000 feet) max.Velocity Limit 515 meters/second (1000 knots) max.Acceleration Limit Less than 4gJerk Limit 20 m/secCertificationModule Approvals CE, GCF, FCC, RoHS, PTCRB, IC
OFD.Filter = "Comma Separated File (*.csv)|*.csv"; // Set filter for History Data. OFD.ShowDialog(); if (OFD.FileName.ToString().Trim() != "") // If file name is not empty. { txtFileName.Text = OFD.FileName.ToString().Trim(); strFN = txtFileName.Text.Trim(); // Get the file name. } else return; // IF empty, exit the function and do nothing.
private void btnReset_Click(object sender, EventArgs e) { // Kill Process and Restart Process Idea got from this link. // http://zoomicon.wordpress.com/2007/04/15/startkill-processes-with-vb-net
// First Kill the process. if (KillProcess()) { // If Successfully kill the Mobile Partner.exe, delete master and data file. // Now start deleting the file. string strDTSFile = @"C:\Program Files\Mobile Partner\userdata\SMS.DTC"; string strBAFile = @"C:\Program Files\Mobile Partner\userdata\SMS";
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
// If master file process finished, go to each individual BA* file. for (int i = 1; i < 4; i++) { try { string strFile = Path.Combine(strBAFile, "SMS.BA" + i); if (File.Exists(strFile) == true) { File.Delete(strFile); } } catch (Exception ex) { MessageBox.Show("System failed to process SMS details file.\n\r" + "Error Detail: " + ex.Message, "GPS Tracker", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } // End of Try Catch for Data file. } // End of For Loop for Data File.
try { // After all finish, restart Mobile Partner.exe process. ProcessStartInfo proc = new ProcessStartInfo(); proc.FileName = @"C:\Program files\Mobile Partner\Mobile Partner.exe "; Process.Start(proc); } catch (Exception ex) { MessageBox.Show("System failed to start Mobile Partner Process.\n\r" + "Error Detail: " + ex.Message, "GPS Tracker", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } } // End of DTC file exist If else. } // End of KillProcess Success If else.
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
#region [User Defined Functions]
private void ReadLiveGPSData(string strPath) { try { // First check whether the output log file is exist or not. if (File.Exists(@"C:\GPS_LiveLog.txt")) File.Delete(@"C:\GPS_LiveLog.txt"); // If exist, delete it.
strFN = strPath;
// File browser must pass a file name to carry on. If empty or file not exist, exit this method. if (strFN == "") return;
string str = "";
if (File.Exists(strFN) == false) return;
// Read the file contents. StreamReader sr = new StreamReader(strFN); str = sr.ReadToEnd(); // Read all data from Master file. sr.Close(); // After successfully read, must close StreamReader object. sr = null; // Set to nothing(Null) in order to avoid unnecessary error like 'file is in use'.
// If content is empty, exit the method. if (str.Trim() == "") return;
// \0 means NUL in ASCII. str = str.Replace("\0", ""); // Clear unnecessary data.
string[] stringSeparators = new string[] { "jL", "L+" }; // Declare a string array which contains Delimeters.
// Split master data with delimeters.// After splitting with the delimeters, strC will contains data in line by line format.// In Array, line by line means each record/line will be 1 row in array.// Array row are in position of 0,1,2,3,4,5, etc. We call it 'Index' (array index). string[] strC = str.Split(stringSeparators, StringSplitOptions.None); // Split master data with delimeters.
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
return; // Exit function.
string strTmp = "";
// For loop. Loop through each line in strC array string object until strC.Length.// strC.Length is the array size (records/line number we got from above after trimming in master data file).
for (int i = 0; i < strC.Length; i++) { if (strC[i].ToUpper().Contains("LATITUDE") == false && strC[i].ToUpper().Contains("LONGITUDE") == false && strC[i].ToUpper().Contains("SPEED") == false) continue;
string[] strB = strC[i].Split((char)1); if (strB.Length > 0) strTmp = strB[0]; else strTmp = strC[i]; string[] strD = strTmp.Split(','); if (strD.Length != 4) // If length is not 4. continue; // Continue for next loop.
private void ReadHistoryData() { try { // First check whether the output log file is exist or not. if (File.Exists(@"C:\GPS_HisLog.txt")) File.Delete(@"C:\GPS_HisLog.txt"); // If exist, delete it.
strFN = txtFileName.Text.Trim();
// File browser must pass a file name to carry on. If empty or file not exist, exit this method. if (strFN == "") return;
string str = "";
if (File.Exists(strFN) == false) return;
// Read the file contents. StreamReader sr = new StreamReader(strFN); str = sr.ReadToEnd(); // Read all the contents from the file. sr.Close(); // Clos ethe StreamReader object. sr = null;
// If file is empty. if (str.Trim() == "") return; // Exit.
string[] strSeparator = new string[] { "," }; // Delimeter.
str = str.Replace("\"", ""); // Clear unnecessary data from Read Data. str = str.Replace("Name/Number,Content,Time,", ""); // Replace or clear Title. string[] strData = str.Split('\n'); // Split the Read Data line by line. for (int i = 0; i < strData.Length; i++) { if (strData[i].Trim() == "") // If this is an empty line. continue; // Continue or Go to Next 'i' number.
// Trim out white space, remove \r at line end if has any. // Replace 'Last' data with empty. string strTmp = strData[i].Trim().Replace("\r", "").Replace("Last:", "").Replace("LAST:", "");
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
string[] strD = strTmp.Split(','); // Split again with ',' (Comma). if (strD.Length != 6) // If Count is not 6, return; // Exit function (Somewhere wrong in Read Data).
Appendix C-12 Mid(string strData, int iPos1, int iPos2) Function
// Mid function which return the string from Start and End Position. public static string Mid(string strData, int iPos1, int iPos2) { // If Empty, return empty. if (strData.Trim() == "") return "";
private bool KillProcess() { try { // First get all the process list running in Task Manager. Process[] plist = Process.GetProcesses();
// Follow by loop through the list and find Mobile Partner softwar process name. foreach (Process p in plist) { try { // If found, Kill it. (Stop the process/End task the process.) if (p.MainModule.ModuleName.ToUpper() == "MOBILE PARTNER.EXE") { p.Kill(); return true; // Return from the function. } } catch (Exception e) { Console.WriteLine(e); // seems listing modules for some processes fails, so better ignore any exceptions here. } }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html> <head> <title>GPS Live Data on Google Map</title> <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAwL0hBKXKlI2xKObyfhKE9BSpJbTgDT5ZInO2WrTXInp1vxnZqRQFvtE0ku7XDAx1QfD7juyFQwCC1g" type="text/javascript"></script> </head> <body onunload="GUnload()">
<!-- you can use tables or divs for the overall layout --> <table border=1> <tr> <td> <div id="map" style="width: 1200px; height: 650px"></div> </td> <td width = 200 valign="top" style="text-decoration: underline; color: #4444ff;"> </td> </tr> </table>
<noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b> However, it seems JavaScript is either disabled or not supported by your browser. To view Google Maps, enable JavaScript by changing your browser options, and then try again. </noscript>
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
// Example Got from here --> http: //www.codeproject.com/KB/scripting/GetURLParameters.aspxfunction getURLParameters()
{ var sURL = document.URL.toString();
if (sURL.indexOf("?") > 0) {
var arrParams = sURL.split("?");
var arrURLParams = arrParams[1].split("&");
var arrParamNames = new Array(arrURLParams.length); var arrParamValues = new Array(arrURLParams.length);
var i = 0; for (i = 0; i < arrURLParams.length; i++) { var sParam = arrURLParams[i].split("="); arrParamNames[i] = sParam[0]; if (sParam[1] != "") arrParamValues[i] = unescape(sParam[1]); else arrParamValues[i] = ""; }
return arrParamValues[0]; } else { return "";
}}
if (GBrowserIsCompatible()) { var gmarkers = [];
var markers = []; var realaddress;
// Right now this function is not used. Just for future extension. // User can pass the parameter in URL and below javascript will grab the parameter // based on that parameter, it will load related text file (Live or History GPS Data).
// A function to create the marker and set up the event window function createMarker(point,time,lat,lng,speed) { var marker = new GMarker(point); GEvent.addListener(marker, "click", function() {
map.panTo(point); var geocoder = new GClientGeocoder();
geocoder.getLocations(point, function(response){ var place = response.Placemark[0];
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
// create the map var map = new GMap2(document.getElementById("map")); var mgr = new GMarkerManager(map); var customUI = map.getDefaultUI(); customUI.maptypes.hybrid = true; map.setUI(customUI); map.setCenter(new GLatLng(1.31401,103.795221), 12); // === Define the function thats going to process the text file === process_GPS_logfile = function(doc) { // === split the document into lines === lines = doc.split("\n"); for (var i=0; i<lines.length; i++) { if (lines[i].length > 1) { // === split each line into parts separated by "," and use the contents === parts = lines[i].split(","); var time = parts[0]; var lat = parseFloat(parts[1]); var lng = parseFloat(parts[2]);
var speed = parts[3]; var point = new GLatLng(lat,lng);
// create the marker var marker = createMarker(point,time,lat,lng,speed); markers.push(marker); } } mgr.addMarkers(markers,0,17); mgr.refresh(); }
Student Name/ Student No.: Tan Yong Peng Charles / J0704259
Appendix E
Field Testing ResultsListed below are parts of the field testing from Alexandra Road to Ang Mo Kio. These log files was exported from Mobile Partner for the justification of few successful field testing. Some pictures were taken during the field testing can be located in Appendix E-2.
Appendix E-1: Journey from Alexandra to Ang Mo Kio