469,938 Members | 2,472 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,938 developers. It's quick & easy.

Help with events & Franson Gps Tools...

Hi Guys,

I am trying to write/copy some code that uses events with a GPS.
Everytime the GPS position updates the event fires.

The GPS code is from a SDK Library that I got called GPS Tools from
www.franson.com

For some reason my code below doesnt work - the GpsFixEvent never seems
to "fire" as it were.

I have attached both my code and the original SDK.

Hope someone can please help point out where I am going wrong.

All I want to do at this stage is impliment a simple for with two
labels that shows the new position when it updates.

As my friend put it "Where do you find these horrible SDK's?"

Thanks

-Al

[my code]

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace GPS_Events_Test

{

public partial class Form1 : Form

{

private GpsToolsNET.NmeaParser objParser = null;

private int count = 0;

public Form1()

{

InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)

{

GpsToolsNET.License objLicense = new GpsToolsNET.License();

objLicense.LicenseKey = "o8h1j88qlSqkaJHiu27oixldj7redk4YoCh3";

// Create parser

objParser = new GpsToolsNET.NmeaParser();

// Events are called in main/GUI thread - "single threaded"

objParser.Parent = this;

// Events are called in a new thread - "multi threaded"

objParser.Parent = null;

// Assign event handlers

objParser.Generic += new GpsToolsNET.Generic(this.objParser_Generic);

//objParser.OnComStatus += new
GpsToolsNET.OnComStatus(this.objParser_OnComStatus );

objParser.OnGpsFix += new
GpsToolsNET.OnGpsFix(this.objParser_OnGpsFix);

//objParser.OnMovement += new
GpsToolsNET.OnMovement(this.objParser_OnMovement);

//objParser.OnSatellites += new
GpsToolsNET.OnSatellites(this.objParser_OnSatellit es);

this.Closing += new
System.ComponentModel.CancelEventHandler(this.frmM ain_Closing);

//bStop.Enabled = false;

//bStart.Enabled = true;

//init_ddPorts();

//init_ddDatum();

//init_ddGrid();

}

private void frmMain_Closing(object sender,
System.ComponentModel.CancelEventArgs e)

{

// You must dispose NmeaParser or the app wont close

objParser.Dispose();

Application.Exit();

}

private void objParser_OnGpsFix(GpsToolsNET.GpsFix objFix)

{

double d;

GpsToolsNET.Position objPos;

objPos = objFix.Position;

// Convert radians to degrees

//d = objPos.Latitude;

//txtLatitude.Text = d.ToString();

// Convert radians to degrees

//d = objPos.Longitude;

//txtLongitude.Text = d.ToString();

objPos.Grid = GpsToolsNET.Grid.NZMG;

label1.Text = objPos.Easting.ToString();

label2.Text = objPos.Northing.ToString();

//txtZone.Text = objPos.Zone;

//if (objFix.FixType == 3)

//{

// txtAltSea.Text = objPos.Altitude(0).ToString();

// txtAltDatum.Text = objPos.Altitude(1).ToString();

//}

}

private void objParser_Generic(GpsToolsNET.NmeaSentence objSentence)

{

count = count + 1;

//lPosCnt.Text = count.ToString();

}

}

}

[/code]

[his example]

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

namespace SerialPort

{

/// <summary>

/// Summary description for Form1.

/// </summary>

public class frmMain : System.Windows.Forms.Form

{

private System.Windows.Forms.GroupBox groupBox1;

private System.Windows.Forms.Label label1;

private System.Windows.Forms.Label label2;

private System.Windows.Forms.TextBox txtLatitude;

private System.Windows.Forms.TextBox txtLongitude;

private System.Windows.Forms.Label label3;

private System.Windows.Forms.Button bStart;

private System.Windows.Forms.Button bStop;

private System.Windows.Forms.Button bClear;

private System.Windows.Forms.Label label4;

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container components = null;

private System.Windows.Forms.GroupBox groupBox2;

private System.Windows.Forms.Label lComStatus;

private System.Windows.Forms.Label label5;

private System.Windows.Forms.Label label6;

private System.Windows.Forms.ComboBox ddDatum;

private System.Windows.Forms.ComboBox ddPort;

private System.Windows.Forms.ComboBox ddBaudRate;

private System.Windows.Forms.GroupBox groupBox3;

private System.Windows.Forms.TextBox txtEasting;

private System.Windows.Forms.TextBox txtNorthing;

private System.Windows.Forms.TextBox txtZone;

private System.Windows.Forms.ComboBox ddGrid;

private System.Windows.Forms.Label label7;

private System.Windows.Forms.Label label8;

private System.Windows.Forms.Label label9;

private System.Windows.Forms.Label label10;

private System.Windows.Forms.GroupBox groupBox4;

private System.Windows.Forms.TextBox txtAltSea;

private System.Windows.Forms.TextBox txtAltDatum;

private System.Windows.Forms.Label label11;

private System.Windows.Forms.Label label12;

private System.Windows.Forms.GroupBox groupBox5;

private System.Windows.Forms.TextBox txtSpeed;

private System.Windows.Forms.TextBox txtHeading;

private System.Windows.Forms.TextBox txtMagneticVariation;

private System.Windows.Forms.Label label13;

private System.Windows.Forms.Label label14;

private System.Windows.Forms.Label label15;

private System.Windows.Forms.GroupBox groupBox6;

private System.Windows.Forms.ListBox lstSats;

private System.Windows.Forms.Label lPosCnt;

private GpsToolsNET.NmeaParser objParser = null;

private int count = 0;

public frmMain()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: Add any constructor code after InitializeComponent call

//

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.groupBox1 = new System.Windows.Forms.GroupBox();

this.label3 = new System.Windows.Forms.Label();

this.ddDatum = new System.Windows.Forms.ComboBox();

this.txtLongitude = new System.Windows.Forms.TextBox();

this.label2 = new System.Windows.Forms.Label();

this.label1 = new System.Windows.Forms.Label();

this.txtLatitude = new System.Windows.Forms.TextBox();

this.bStart = new System.Windows.Forms.Button();

this.bStop = new System.Windows.Forms.Button();

this.bClear = new System.Windows.Forms.Button();

this.label4 = new System.Windows.Forms.Label();

this.groupBox2 = new System.Windows.Forms.GroupBox();

this.ddBaudRate = new System.Windows.Forms.ComboBox();

this.label6 = new System.Windows.Forms.Label();

this.ddPort = new System.Windows.Forms.ComboBox();

this.lComStatus = new System.Windows.Forms.Label();

this.label5 = new System.Windows.Forms.Label();

this.groupBox3 = new System.Windows.Forms.GroupBox();

this.label10 = new System.Windows.Forms.Label();

this.label9 = new System.Windows.Forms.Label();

this.label8 = new System.Windows.Forms.Label();

this.label7 = new System.Windows.Forms.Label();

this.ddGrid = new System.Windows.Forms.ComboBox();

this.txtZone = new System.Windows.Forms.TextBox();

this.txtNorthing = new System.Windows.Forms.TextBox();

this.txtEasting = new System.Windows.Forms.TextBox();

this.groupBox4 = new System.Windows.Forms.GroupBox();

this.txtAltSea = new System.Windows.Forms.TextBox();

this.label11 = new System.Windows.Forms.Label();

this.txtAltDatum = new System.Windows.Forms.TextBox();

this.label12 = new System.Windows.Forms.Label();

this.groupBox5 = new System.Windows.Forms.GroupBox();

this.txtMagneticVariation = new System.Windows.Forms.TextBox();

this.label15 = new System.Windows.Forms.Label();

this.label14 = new System.Windows.Forms.Label();

this.label13 = new System.Windows.Forms.Label();

this.txtHeading = new System.Windows.Forms.TextBox();

this.txtSpeed = new System.Windows.Forms.TextBox();

this.groupBox6 = new System.Windows.Forms.GroupBox();

this.lstSats = new System.Windows.Forms.ListBox();

this.lPosCnt = new System.Windows.Forms.Label();

this.groupBox1.SuspendLayout();

this.groupBox2.SuspendLayout();

this.groupBox3.SuspendLayout();

this.groupBox4.SuspendLayout();

this.groupBox5.SuspendLayout();

this.groupBox6.SuspendLayout();

this.SuspendLayout();

//

// groupBox1

//

this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {

this.label3,

this.ddDatum,

this.txtLongitude,

this.label2,

this.label1,

this.txtLatitude});

this.groupBox1.Location = new System.Drawing.Point(8, 8);

this.groupBox1.Name = "groupBox1";

this.groupBox1.TabIndex = 0;

this.groupBox1.TabStop = false;

this.groupBox1.Text = "Lat / Long";

//

// label3

//

this.label3.Location = new System.Drawing.Point(8, 64);

this.label3.Name = "label3";

this.label3.Size = new System.Drawing.Size(56, 23);

this.label3.TabIndex = 4;

this.label3.Text = "Datum";

//

// ddDatum

//

this.ddDatum.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;

this.ddDatum.Location = new System.Drawing.Point(80, 64);

this.ddDatum.Name = "ddDatum";

this.ddDatum.Size = new System.Drawing.Size(104, 21);

this.ddDatum.TabIndex = 3;

this.ddDatum.SelectedIndexChanged += new
System.EventHandler(this.ddDatum_SelectedIndexChan ged);

//

// txtLongitude

//

this.txtLongitude.Location = new System.Drawing.Point(80, 40);

this.txtLongitude.Name = "txtLongitude";

this.txtLongitude.TabIndex = 2;

this.txtLongitude.Text = "";

//

// label2

//

this.label2.Location = new System.Drawing.Point(8, 40);

this.label2.Name = "label2";

this.label2.Size = new System.Drawing.Size(64, 23);

this.label2.TabIndex = 1;

this.label2.Text = "Longitude";

//

// label1

//

this.label1.Location = new System.Drawing.Point(8, 16);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(64, 23);

this.label1.TabIndex = 0;

this.label1.Text = "Latitude";

//

// txtLatitude

//

this.txtLatitude.Location = new System.Drawing.Point(80, 16);

this.txtLatitude.Name = "txtLatitude";

this.txtLatitude.TabIndex = 1;

this.txtLatitude.Text = "";

//

// bStart

//

this.bStart.Location = new System.Drawing.Point(360, 376);

this.bStart.Name = "bStart";

this.bStart.TabIndex = 1;

this.bStart.Text = "Start";

this.bStart.Click += new System.EventHandler(this.bStart_Click);

//

// bStop

//

this.bStop.Location = new System.Drawing.Point(272, 376);

this.bStop.Name = "bStop";

this.bStop.TabIndex = 2;

this.bStop.Text = "Stop";

this.bStop.Click += new System.EventHandler(this.bStop_Click);

//

// bClear

//

this.bClear.Location = new System.Drawing.Point(16, 376);

this.bClear.Name = "bClear";

this.bClear.TabIndex = 3;

this.bClear.Text = "Clear";

this.bClear.Click += new System.EventHandler(this.bClear_Click);

//

// label4

//

this.label4.Location = new System.Drawing.Point(104, 376);

this.label4.Name = "label4";

this.label4.Size = new System.Drawing.Size(136, 23);

this.label4.TabIndex = 4;

this.label4.Text = "http://franson.biz/gpstools";

//

// groupBox2

//

this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {

this.ddBaudRate,

this.label6,

this.ddPort,

this.lComStatus,

this.label5});

this.groupBox2.Location = new System.Drawing.Point(232, 8);

this.groupBox2.Name = "groupBox2";

this.groupBox2.TabIndex = 5;

this.groupBox2.TabStop = false;

this.groupBox2.Text = "Com port";

//

// ddBaudRate

//

this.ddBaudRate.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;

this.ddBaudRate.Location = new System.Drawing.Point(96, 56);

this.ddBaudRate.Name = "ddBaudRate";

this.ddBaudRate.Size = new System.Drawing.Size(96, 21);

this.ddBaudRate.TabIndex = 4;

//

// label6

//

this.label6.Location = new System.Drawing.Point(96, 40);

this.label6.Name = "label6";

this.label6.TabIndex = 3;

this.label6.Text = "Baud rate";

//

// ddPort

//

this.ddPort.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;

this.ddPort.Location = new System.Drawing.Point(16, 56);

this.ddPort.Name = "ddPort";

this.ddPort.Size = new System.Drawing.Size(72, 21);

this.ddPort.TabIndex = 1;

//

// lComStatus

//

this.lComStatus.Location = new System.Drawing.Point(16, 16);

this.lComStatus.Name = "lComStatus";

this.lComStatus.Size = new System.Drawing.Size(176, 23);

this.lComStatus.TabIndex = 0;

this.lComStatus.Text = "Port not enabled";

//

// label5

//

this.label5.Location = new System.Drawing.Point(16, 40);

this.label5.Name = "label5";

this.label5.Size = new System.Drawing.Size(80, 16);

this.label5.TabIndex = 2;

this.label5.Text = "Serial port";

//

// groupBox3

//

this.groupBox3.Controls.AddRange(new System.Windows.Forms.Control[] {

this.label10,

this.label9,

this.label8,

this.label7,

this.ddGrid,

this.txtZone,

this.txtNorthing,

this.txtEasting});

this.groupBox3.Location = new System.Drawing.Point(8, 112);

this.groupBox3.Name = "groupBox3";

this.groupBox3.Size = new System.Drawing.Size(200, 128);

this.groupBox3.TabIndex = 6;

this.groupBox3.TabStop = false;

this.groupBox3.Text = "Grid / Map projection";

//

// label10

//

this.label10.Location = new System.Drawing.Point(16, 96);

this.label10.Name = "label10";

this.label10.Size = new System.Drawing.Size(56, 23);

this.label10.TabIndex = 7;

this.label10.Text = "Grid";

//

// label9

//

this.label9.Location = new System.Drawing.Point(16, 72);

this.label9.Name = "label9";

this.label9.Size = new System.Drawing.Size(56, 23);

this.label9.TabIndex = 6;

this.label9.Text = "Zone";

//

// label8

//

this.label8.Location = new System.Drawing.Point(16, 48);

this.label8.Name = "label8";

this.label8.Size = new System.Drawing.Size(56, 23);

this.label8.TabIndex = 5;

this.label8.Text = "Northing";

//

// label7

//

this.label7.Location = new System.Drawing.Point(16, 24);

this.label7.Name = "label7";

this.label7.Size = new System.Drawing.Size(56, 23);

this.label7.TabIndex = 4;

this.label7.Text = "Easting";

//

// ddGrid

//

this.ddGrid.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;

this.ddGrid.Location = new System.Drawing.Point(80, 96);

this.ddGrid.Name = "ddGrid";

this.ddGrid.Size = new System.Drawing.Size(104, 21);

this.ddGrid.TabIndex = 3;

//

// txtZone

//

this.txtZone.Location = new System.Drawing.Point(80, 72);

this.txtZone.Name = "txtZone";

this.txtZone.TabIndex = 2;

this.txtZone.Text = "";

//

// txtNorthing

//

this.txtNorthing.Location = new System.Drawing.Point(80, 48);

this.txtNorthing.Name = "txtNorthing";

this.txtNorthing.TabIndex = 1;

this.txtNorthing.Text = "";

//

// txtEasting

//

this.txtEasting.Location = new System.Drawing.Point(80, 24);

this.txtEasting.Name = "txtEasting";

this.txtEasting.TabIndex = 0;

this.txtEasting.Text = "";

//

// groupBox4

//

this.groupBox4.Controls.AddRange(new System.Windows.Forms.Control[] {

this.txtAltSea,

this.label11,

this.txtAltDatum,

this.label12});

this.groupBox4.Location = new System.Drawing.Point(8, 248);

this.groupBox4.Name = "groupBox4";

this.groupBox4.Size = new System.Drawing.Size(200, 104);

this.groupBox4.TabIndex = 7;

this.groupBox4.TabStop = false;

this.groupBox4.Text = "Altitude";

//

// txtAltSea

//

this.txtAltSea.Location = new System.Drawing.Point(16, 32);

this.txtAltSea.Name = "txtAltSea";

this.txtAltSea.TabIndex = 0;

this.txtAltSea.Text = "";

//

// label11

//

this.label11.Location = new System.Drawing.Point(16, 16);

this.label11.Name = "label11";

this.label11.Size = new System.Drawing.Size(144, 23);

this.label11.TabIndex = 2;

this.label11.Text = "Meters over mean sea level";

//

// txtAltDatum

//

this.txtAltDatum.Location = new System.Drawing.Point(16, 72);

this.txtAltDatum.Name = "txtAltDatum";

this.txtAltDatum.TabIndex = 1;

this.txtAltDatum.Text = "";

//

// label12

//

this.label12.Location = new System.Drawing.Point(16, 56);

this.label12.Name = "label12";

this.label12.Size = new System.Drawing.Size(136, 23);

this.label12.TabIndex = 3;

this.label12.Text = "Meters over ellipsoid";

//

// groupBox5

//

this.groupBox5.Controls.AddRange(new System.Windows.Forms.Control[] {

this.txtMagneticVariation,

this.label15,

this.label14,

this.label13,

this.txtHeading,

this.txtSpeed});

this.groupBox5.Location = new System.Drawing.Point(232, 112);

this.groupBox5.Name = "groupBox5";

this.groupBox5.Size = new System.Drawing.Size(200, 112);

this.groupBox5.TabIndex = 8;

this.groupBox5.TabStop = false;

this.groupBox5.Text = "Movement";

//

// txtMagneticVariation

//

this.txtMagneticVariation.Location = new System.Drawing.Point(88, 72);

this.txtMagneticVariation.Name = "txtMagneticVariation";

this.txtMagneticVariation.TabIndex = 2;

this.txtMagneticVariation.Text = "";

//

// label15

//

this.label15.Location = new System.Drawing.Point(16, 72);

this.label15.Name = "label15";

this.label15.Size = new System.Drawing.Size(80, 24);

this.label15.TabIndex = 5;

this.label15.Text = "Magnetic varation";

//

// label14

//

this.label14.Location = new System.Drawing.Point(16, 48);

this.label14.Name = "label14";

this.label14.Size = new System.Drawing.Size(72, 23);

this.label14.TabIndex = 4;

this.label14.Text = "Heading";

//

// label13

//

this.label13.Location = new System.Drawing.Point(16, 24);

this.label13.Name = "label13";

this.label13.Size = new System.Drawing.Size(72, 23);

this.label13.TabIndex = 3;

this.label13.Text = "Speed (m/s)";

//

// txtHeading

//

this.txtHeading.Location = new System.Drawing.Point(88, 48);

this.txtHeading.Name = "txtHeading";

this.txtHeading.TabIndex = 1;

this.txtHeading.Text = "";

//

// txtSpeed

//

this.txtSpeed.Location = new System.Drawing.Point(88, 24);

this.txtSpeed.Name = "txtSpeed";

this.txtSpeed.TabIndex = 0;

this.txtSpeed.Text = "";

//

// groupBox6

//

this.groupBox6.Controls.AddRange(new System.Windows.Forms.Control[] {

this.lstSats});

this.groupBox6.Location = new System.Drawing.Point(232, 232);

this.groupBox6.Name = "groupBox6";

this.groupBox6.Size = new System.Drawing.Size(200, 120);

this.groupBox6.TabIndex = 9;

this.groupBox6.TabStop = false;

this.groupBox6.Text = "Satellites";

//

// lstSats

//

this.lstSats.Location = new System.Drawing.Point(8, 16);

this.lstSats.Name = "lstSats";

this.lstSats.Size = new System.Drawing.Size(184, 95);

this.lstSats.TabIndex = 0;

//

// lPosCnt

//

this.lPosCnt.Location = new System.Drawing.Point(104, 400);

this.lPosCnt.Name = "lPosCnt";

this.lPosCnt.TabIndex = 10;

this.lPosCnt.Text = "0";

//

// frmMain

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(472, 429);

this.Controls.AddRange(new System.Windows.Forms.Control[] {

this.lPosCnt,

this.groupBox6,

this.groupBox5,

this.groupBox4,

this.groupBox3,

this.groupBox2,

this.label4,

this.bClear,

this.bStop,

this.bStart,

this.groupBox1});

this.Name = "frmMain";

this.Text = "GpsTools .NET (Serial Port C#)";

this.Load += new System.EventHandler(this.frmMain_Load);

this.groupBox1.ResumeLayout(false);

this.groupBox2.ResumeLayout(false);

this.groupBox3.ResumeLayout(false);

this.groupBox4.ResumeLayout(false);

this.groupBox5.ResumeLayout(false);

this.groupBox6.ResumeLayout(false);

this.ResumeLayout(false);

}

#endregion

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new frmMain());

}

private void frmMain_Load(object sender, System.EventArgs e)

{

// You can get a valid evaluation key at

// http://franson.com/gpstools/

// That key will be valid for 30 days. Just cut and paste that key into
the statement below.

// To get a key that do not expire you need to purchase a license

GpsToolsNET.License objLicense = new GpsToolsNET.License();

objLicense.LicenseKey = "o8h1j88qlSqkaJHiu27oixldj7redk4YoCh3";
// Create parser

objParser = new GpsToolsNET.NmeaParser();

// Events are called in main/GUI thread - "single threaded"

objParser.Parent = this;

// Events are called in a new thread - "multi threaded"

// objParser.Parent = null;

// Assign event handlers

objParser.Generic += new GpsToolsNET.Generic(this.objParser_Generic);

objParser.OnComStatus += new
GpsToolsNET.OnComStatus(this.objParser_OnComStatus );

objParser.OnGpsFix += new
GpsToolsNET.OnGpsFix(this.objParser_OnGpsFix);

objParser.OnMovement += new
GpsToolsNET.OnMovement(this.objParser_OnMovement);

objParser.OnSatellites += new
GpsToolsNET.OnSatellites(this.objParser_OnSatellit es);

this.Closing += new
System.ComponentModel.CancelEventHandler(this.frmM ain_Closing);

bStop.Enabled = false;

bStart.Enabled = true;

init_ddPorts();

init_ddDatum();

init_ddGrid();

}

private void frmMain_Closing(object sender,
System.ComponentModel.CancelEventArgs e)

{

// You must dispose NmeaParser or the app wont close

objParser.Dispose();

Application.Exit();

}

private void objParser_OnGpsFix(GpsToolsNET.GpsFix objFix)

{

double d;

GpsToolsNET.Position objPos;

objPos = objFix.Position;

// Convert radians to degrees

//d = objPos.Latitude;

//txtLatitude.Text = d.ToString();

// Convert radians to degrees

//d = objPos.Longitude;

//txtLongitude.Text = d.ToString();

objPos.Grid = GpsToolsNET.Grid.NZMG;
label1.Text = objPos.Easting.ToString();

label2.Text = objPos.Northing.ToString();

/*

txtZone.Text = objPos.Zone;
if(objFix.FixType == 3)

{

txtAltSea.Text = objPos.Altitude(0).ToString();

txtAltDatum.Text = objPos.Altitude(1).ToString();

}*/

}

private void objParser_OnSatellites(GpsToolsNET.Satellites objSats)

{

short inx;

short sat_count;

GpsToolsNET.Satellite sat;

lstSats.Items.Clear();

sat_count = objSats.Count;

for(inx = 1; inx < sat_count; inx++)

{

sat = objSats.Item(inx);

lstSats.Items.Add("PRN: " + sat.ID + " SNR: " + sat.SNR);

}

}

private void objParser_OnMovement(GpsToolsNET.Movement objMove)

{

txtSpeed.Text = objMove.Speed(1).ToString();

txtHeading.Text = objMove.Heading.ToString();

txtMagneticVariation.Text = objMove.MagneticVariation.ToString();

}

private void objParser_OnComStatus(GpsToolsNET.ComStatus objComStatus)

{

int baud_rate;

short port;

if(objComStatus.ValidNmea)

{

baud_rate = objComStatus.BaudRate;

port = objComStatus.ComPort;

if(objComStatus.ComPort == -1)

{

lComStatus.Text = "GPS OK! GpsGate Direct";

}

else

{

lComStatus.Text = "GPS OK! COM" + objComStatus.ComPort + ", " +
objComStatus.BaudRate;

}

}

else

{

lComStatus.Text = "Trying to connect...";

}

}

private void objParser_Generic(GpsToolsNET.NmeaSentence objSentence)

{

count = count + 1;

lPosCnt.Text = count.ToString();

}

private void bStart_Click(object sender, System.EventArgs e)

{

objParser.GpsDatum = (GpsToolsNET.Datum) ddDatum.SelectedIndex;
objParser.ComPort = (short) ddPort.SelectedIndex;
if(ddBaudRate.SelectedIndex == 0)

{

objParser.BaudRate = 0;

}

else

{

string s = ddBaudRate.SelectedItem.ToString();

objParser.BaudRate = Convert.ToInt32(s);

}

try

{

objParser.PortEnabled = true;

lComStatus.Text = "Trying to connect...";

bStart.Enabled = false;

bStop.Enabled = true;

}

catch(Exception ex)

{

MessageBox.Show(this, ex.Source + ": " + ex.Message);

return;

}

}

private void bStop_Click(object sender, System.EventArgs e)

{

objParser.PortEnabled = false;

bStart.Enabled = true;

bStop.Enabled = false;
lComStatus.Text = "Port not enabled";

}

private void ddDatum_SelectedIndexChanged(object sender,
System.EventArgs e)

{

try

{

objParser.GpsDatum = (GpsToolsNET.Datum) ddDatum.SelectedIndex;

}

catch(Exception)

{

}

}

private void init_ddDatum()

{

ddDatum.Items.Add("No datum");

ddDatum.Items.Add("WGS 84"); // World, gps standard

ddDatum.Items.Add("ETRS 89"); // Europe

ddDatum.Items.Add("OSGB 36"); // UK

ddDatum.Items.Add("CH 1903+"); // Switzerland

ddDatum.Items.Add("RT 90"); // Sweden

ddDatum.Items.Add("IRELAND 65"); // Ireland

ddDatum.Items.Add("FINLAND HAYFORD"); // Finland

ddDatum.Items.Add("LUREF"); // Luxembourg

ddDatum.Items.Add("WGS 72"); // World

ddDatum.Items.Add("AGD 84"); // Australian Geodetic Datum

ddDatum.Items.Add("GDA 94"); // Geodetic Datum of Australia

ddDatum.Items.Add("MGI"); // Austria

ddDatum.Items.Add("NZGD 49"); // New Zealand Geodetic Datum 1949

ddDatum.Items.Add("NZGD 2000"); // New Zealand Geodetic Datum 2000

ddDatum.Items.Add("NTF"); // France

ddDatum.Items.Add("BD 72"); // Belgium

ddDatum.Items.Add("ED 50"); // Europe

ddDatum.Items.Add("POTSDAM"); // Germany

ddDatum.Items.Add("NAD 83"); // North America

ddDatum.Items.Add("NAD 27 Alaska");

ddDatum.Items.Add("NAD 27 East");

ddDatum.Items.Add("NAD 27 Conus");

ddDatum.Items.Add("NAD 27 West");

ddDatum.Items.Add("AMERSFOORT"); // Netherlands

ddDatum.Items.Add("ROME 40"); // Italy

ddDatum.Items.Add("NGO 48"); // Norway

ddDatum.SelectedIndex = 1;

}

private void init_ddGrid()

{

ddGrid.Items.Add("No Grid");

ddGrid.Items.Add("UTM North");

ddGrid.Items.Add("UTM South");

ddGrid.Items.Add("British Grid");

ddGrid.Items.Add("Irish Grid");

ddGrid.Items.Add("Irish Grid ITM");

ddGrid.Items.Add("Swedish Grid");

ddGrid.Items.Add("Swiss Grid");

ddGrid.Items.Add("Swiss Grid Lv95");

ddGrid.Items.Add("Finnish Grid Zone1");

ddGrid.Items.Add("Finnish Grid Zone2");

ddGrid.Items.Add("Finnish Grid Zone3");

ddGrid.Items.Add("Finnish Grid Zone4");

ddGrid.Items.Add("UTM ETRS 89");

ddGrid.Items.Add("Luxembourg (LUREF)");

ddGrid.Items.Add("Australian Map Grid");

ddGrid.Items.Add("Map Grid of Australia");

ddGrid.Items.Add("Austrain Grid M28");

ddGrid.Items.Add("Austrain Grid M31");

ddGrid.Items.Add("Austrain Grid M34");

ddGrid.Items.Add("New Zealand 2000");

ddGrid.Items.Add("New Zealand 1972");

ddGrid.Items.Add("Belgium Grid");

ddGrid.Items.Add("French Grid Zone 1");

ddGrid.Items.Add("French Grid Zone 2");

ddGrid.Items.Add("French Grid Zone 3");

ddGrid.Items.Add("French Grid Zone 4");

ddGrid.Items.Add("French Grid Lambert 93");

ddGrid.Items.Add("UTM ED 50");

ddGrid.Items.Add("DHDN (Germany)");

ddGrid.Items.Add("-");

ddGrid.Items.Add("-");

ddGrid.Items.Add("UTM NAD 27");

ddGrid.Items.Add("UTM NAD 83");

ddGrid.Items.Add("RD / Amersfoort");

ddGrid.Items.Add("Italian Grid Zone 1");

ddGrid.Items.Add("Italian Grid Zone 2");

ddGrid.Items.Add("Norwegian Grid Zone 1");

ddGrid.Items.Add("Norwegian Grid Zone 2");

ddGrid.Items.Add("Norwegian Grid Zone 3");

ddGrid.Items.Add("Norwegian Grid Zone 4");

ddGrid.Items.Add("Norwegian Grid Zone 5");

ddGrid.Items.Add("Norwegian Grid Zone 6");

ddGrid.Items.Add("Norwegian Grid Zone 7");

ddGrid.Items.Add("Norwegian Grid Zone 8");
ddGrid.SelectedIndex = 1;

}

private void bClear_Click(object sender, System.EventArgs e)

{

lstSats.Items.Clear();

txtLatitude.Text = "";

txtLongitude.Text = "";

txtEasting.Text = "";

txtNorthing.Text = "";

txtZone.Text = "";

txtSpeed.Text = "";

txtHeading.Text = "";

txtMagneticVariation.Text = "";

lPosCnt.Text = "0";

txtAltDatum.Text = "";

txtAltSea.Text = "";

count = 0;

}

private void init_ddPorts()

{

// Init serial port dropdown

short i;

ddPort.Items.Add("AutoDetect");

for(i = 1; i <= 16; i++)

{

ddPort.Items.Add("COM" + i + ":");

}

ddPort.SelectedIndex = 0;

// Init Baud rate drop down

ddBaudRate.Items.Add("AutoDetect");

ddBaudRate.Items.Add("4800");

ddBaudRate.Items.Add("9600");

ddBaudRate.Items.Add("19200");

ddBaudRate.Items.Add("14400");

ddBaudRate.Items.Add("38400");

ddBaudRate.Items.Add("57600");

ddBaudRate.SelectedIndex = 0;

}

}

}

Aug 24 '06 #1
0 2006

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Kevin | last post: by
2 posts views Thread by Goober | last post: by
16 posts views Thread by Merlin | last post: by
3 posts views Thread by Lance | last post: by
30 posts views Thread by Burkhard | last post: by
3 posts views Thread by BigAl.NZ | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.