Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

c# app acting as a GPS antenna

Status
Not open for further replies.

guttaboys

Programmer
Oct 28, 2003
17
NO
Hi,

is it possible to make a little C# application that pretends it's a GPS and send data to a COM port that another GPS application can use, like Microsoft's Autoroute.

I would like the C# app to act like a GPS Antenna that spews out the data, so when I start a map program like ex Autoroute and select a GPS device, I can select/connect it to my dummy GPS throug a COM port and receive the data.

If you have any idea of what to do, or if it's even possible, please reply.
 
i'm not sure i totally follow. Do you want c# to generate the condinates, or pass the cordinates along to another program? If i read you post correctly you want C# to get lat/lng from a GPS unit and pass that to AutoRoute.

you'll need an API to communicate with the GPS and another API to communicate with Autoroute. these would be provided by the manufacturer of the respective products. your c# app would be a simple adapter to pass information along. in it's simplest form I would think you need to get lat/lng from the GPS and send it to AutoRoute.
Code:
public class Cordinates
{
   string latitude, longitude;

   public Cordinates(string latitude, string longitude)
   {
      this.latitude = latitude;
      this.longitude = longitude;
   }

   public string Latitude
   {
      get { return latitude; }
   }

   public string Longitude
   {
      get { return longitude; }
   }

}

public interface IOutputAdapter
{
   Cordinates GetCordinates();
}

public interface IInputAdapter
{
   void SetCordinates(Cordinates cordinates);
}

public class GPSOutputAdatper : IOutputAdapter
{
   private GPSObject gps;

   public GPSOutputAdatper(GPSObject gps)
   {
      this.gps = gps;
   }

   public Cordinates GetCordinates()
   {
      sting lat = gps.GetLatitude();
      sting lng = gps.GetLongitude();
      return new Cordinates(lat, lng);
   }
}

public class AutoRouteInputAdapter : IInputAdapter
{
   private autoRoute route;

   public AutoRouteInputAdapter(AutoRouteObject route)
   {
      this.route = route;
   }

   public void SetCordinates(Cordinates cordinates)
   {
      route.GoTo(cordinates.Latitude, cordinates.Longitude);
   }
}

public class AdapterFactory
{
   public static IOutputAdapter CreateOuput()
   {
      return new GPSOutputAdatper(new GPSObject());
   }

   public static IInputAdapter CreateInput()
   {
      return new AutoRouteInputAdapter(new AutoRoute());
   }
}

//main program
public static main(string[] args)
{
   IOutputAdapter output = AdapterFactory.CreateOutput();
   IInputAdapter input = AdapterFactory.CreateInput();
   input.SetCordinates(output.GetCordinates());
}
this is a very simple model. what I have done is abstracted the product specific commands away from my code. now if I use a different gps unit, or set my cordinates to another input device I can do so without changing my core application. I just need to add new input/ouput adapters. and update the factory.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I believe the request was to emulate a GPS unit much like the Microsoft GPS Antenna.

This should acutally be fairly easy - you just have to accept a serial port connection and when the connection is active, start writing your strings to that port.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top