Here is the structure view of the Gps Design:
Define the provider interface
public interface IGpsDataProvider
{
void Close();
event GpsDataReceivedEventHandler GpsDataReceived;
void Open();
bool IsOpen();
}
Later we can derive a test provider
Here are the event helpers
public delegate void GPSDataEventHandler(object sender, GPSDataEventArgs e);
public class GPSDataEventArgs : EventArgs
{
#region Members
private GPSFix m_FixState = GPSFix.NoFix;
private double m_Longitude = 0;
private double m_Latitude = 0;
private double m_SpeedMetresPerSec = 0;
private double m_BearingDegrees = 0;
#endregion
#region Properties
public GPSFix FixState { get { return m_FixState; } }
public double Longitude { get { return m_Longitude; } }
public double Latitude { get { return m_Latitude; } }
public string CoordinateSystem { get { return GpsListener.coordindateSystem; } }
public double SpeedMetresPerSec { get { return m_SpeedMetresPerSec; } }
public double BearingDegrees { get { return m_BearingDegrees; } }
#endregion
#region Constructor
public GPSDataEventArgs(GPSFix a_FixState, double a_Longitude,
double a_Latitude, double a_SpeedMetresPerSec,
double a_BearingDegrees)
{
m_FixState = a_FixState;
m_Longitude = a_Longitude;
m_Latitude = a_Latitude;
m_SpeedMetresPerSec = a_SpeedMetresPerSec;
m_BearingDegrees = a_BearingDegrees;
}
#endregion
public override string ToString()
{
StringBuilder sb = new StringBuilder(128);
sb.Append(" FixState=" + m_FixState.ToString());
sb.Append(" Long=" + m_Longitude.ToString());
sb.Append(" Long=" + m_Longitude.ToString());
sb.Append(" Lat=" + m_Latitude.ToString());
sb.Append(" Speed=" + m_SpeedMetresPerSec.ToString());
sb.Append(" Bearing=" + m_BearingDegrees.ToString());
return sb.ToString();
}
}
public delegate void GpsDataReceivedEventHandler(object sender,
GpsDataLineEventArgs e);
public class GpsDataLineEventArgs : EventArgs
{
#region Members
private string m_Data = string.Empty;
#endregion
#region Properties
public string Data
{
get { return m_Data; }
set { m_Data = value; }
}
#endregion
#region Constructor
public GpsDataLineEventArgs(string data)
{
m_Data = data;
}
#endregion
}
Here is the Listener:
No comments:
Post a Comment