www.pudn.com > mo_gps.zip > RMC.cls


VERSION 1.0 CLASS 
BEGIN 
  MultiUse = -1  'True 
END 
Attribute VB_Name = "GPRMC" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = True 
Attribute VB_PredeclaredId = False 
Attribute VB_Exposed = False 
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes" 
Attribute VB_Ext_KEY = "Top_Level" ,"Yes" 
'Class name:    RMC.cls 
'Author:        Ray Bivens, Applications Prototype Lab, ESRI 
'Date:          Dec 98 
'Description:   Factors an NMEA (GPS) 'GPRMC' sentence to its string components. 
'Comments:      Create an instance of the class and assign a GPRMC string to the 
'               Sentence property. 
' 
'Revisions: 
 
Option Explicit 
 
Private mvarSentence As String 
Private mvarUTC As String 
Private mvarStatus As String 
Private mvarLatitude As String 
Private mvarLongitude As String 
Private mvarLatHemis As String 
Private mvarLonHemis As String 
Private mvarSpeed As String 
Private mvarTrackMadeGood As String 
Private mvarUTDate As String 
Private mvarMagneticVariation As String 
Private mvarMagDeviation As String 
Private mvarChecksum As String 
 
Public Enum GPRMCError 
    InvalidOrCorruptGPRMC = vbObjectError + 512 + 3 
End Enum 
 
Public Property Get Checksum() As String 
Attribute Checksum.VB_Description = "Returns the checksum of the NMEA string." 
    Checksum = mvarChecksum 
End Property 
 
Public Property Get MagDeviation() As String 
Attribute MagDeviation.VB_Description = "Returns the magnetic deviation (E or W)." 
    MagDeviation = mvarMagDeviation 
End Property 
 
Public Property Get MagneticVariation() As String 
Attribute MagneticVariation.VB_Description = "Returns the magnetic variation in degrees; easterly variation subtracts from true course." 
    MagneticVariation = mvarMagneticVariation 
End Property 
 
Public Property Get UTDate() As String 
Attribute UTDate.VB_Description = "Returns the UTD (Date)." 
    UTDate = mvarUTDate 
End Property 
 
Public Property Get TrackMadeGood() As String 
Attribute TrackMadeGood.VB_Description = "Returns track made good in degrees (true north)." 
    TrackMadeGood = mvarTrackMadeGood 
End Property 
 
Public Property Get Speed() As String 
Attribute Speed.VB_Description = "Returns speed over ground in knots." 
    Speed = mvarSpeed 
End Property 
 
Public Property Get LonHemis() As String 
Attribute LonHemis.VB_Description = "Returns a string indicating east or west longitude." 
    LonHemis = mvarLonHemis 
End Property 
 
Public Property Get LatHemis() As String 
Attribute LatHemis.VB_Description = "Returns a string indicating north or south latitude." 
    LatHemis = mvarLatHemis 
End Property 
 
Public Property Get Longitude() As String 
Attribute Longitude.VB_Description = "Returns the Longitude of the object." 
    Longitude = mvarLongitude 
End Property 
 
Public Property Get Latitude() As String 
Attribute Latitude.VB_Description = "Returns the Latitude of the object." 
    Latitude = mvarLatitude 
End Property 
 
Public Property Get Status() As String 
Attribute Status.VB_Description = "Returns a string indicating the data status of the object. V = navigation receiver warning." 
    Status = mvarStatus 
End Property 
 
Public Property Get UTC() As String 
Attribute UTC.VB_Description = "Returns the UTC from the object." 
    UTC = mvarUTC 
End Property 
 
Public Property Let Sentence(ByVal RMC_Sentence As String) 
Attribute Sentence.VB_Description = "Sets/Returns NMEA sentence for object." 
    Dim Utils As New CParseUtils 
     
        'check for correct header and number 
        'of place holders in sentence first... 
        If Utils.Parse(RMC_Sentence, 1) = "$GPRMC" And Utils.CountParts(RMC_Sentence) = 12 Then 
             
            Dim sUTC As String 
            Dim sStatus As String 
            Dim sLatitude As String 
            Dim sLatHemis As String 
            Dim sLongitude As String 
            Dim sLonHemis As String 
            Dim sSpeed As String 
            Dim sTrackMadeGood As String 
            Dim sUTDate As String 
            Dim sMagneticVariation As String 
            Dim sMagDeviation As String 
            Dim sChecksum As String 
            Dim sTempMagDeviation As String 
            Dim sTempChecksum As String 
             
            mvarSentence = RMC_Sentence 
             
            ' parse NMEA sentence and check quality 
            ' if qc conditions not met, leave var as empty... 
            sUTC = Utils.Parse(mvarSentence, 2)             'UTC 
                If IsNumeric(sUTC) Then 
                    mvarUTC = sUTC 
                End If 
                 
            sStatus = Utils.Parse(mvarSentence, 3)          'Status 
            mvarStatus = sStatus 
                 
            sLatitude = Utils.Parse(mvarSentence, 4)        'Latitude 
                If IsNumeric(sLatitude) Then 
                    mvarLatitude = sLatitude 
                End If 
                 
            sLatHemis = Utils.Parse(mvarSentence, 5)        'LatHemis 
                If sLatHemis = "N" Or sLatHemis = "S" Then 
                    mvarLatHemis = sLatHemis 
                End If 
                 
            sLongitude = Utils.Parse(mvarSentence, 6)       'Longitude 
                If IsNumeric(sLongitude) Then 
                    mvarLongitude = sLongitude 
                End If 
                 
            sLonHemis = Utils.Parse(mvarSentence, 7)        'LonHemis 
                If sLonHemis = "E" Or sLonHemis = "W" Then 
                    mvarLonHemis = sLonHemis 
                End If 
                 
            sSpeed = Utils.Parse(mvarSentence, 8)           'Speed 
                If IsNumeric(sSpeed) Then 
                    mvarSpeed = sSpeed 
                End If 
                 
            sTrackMadeGood = Utils.Parse(mvarSentence, 9)   'TrackMadeGood 
                If IsNumeric(sTrackMadeGood) Then 
                    mvarTrackMadeGood = sTrackMadeGood 
                End If 
                 
            sUTDate = Utils.Parse(mvarSentence, 10)         'UTDate 
                If IsNumeric(sUTDate) Then 
                    mvarUTDate = sUTDate 
                End If 
             
            sMagneticVariation = Utils.Parse(mvarSentence, 11) 'Magnetic Variation 
                If IsNumeric(sMagneticVariation) Then 
                    mvarMagneticVariation = sMagneticVariation 
                End If 
                 
            sTempMagDeviation = Utils.Parse(mvarSentence, 12)   'temp var 
            sMagDeviation = Utils.Parse(sTempMagDeviation, 1, "*") 'Magnetic Deviation 
            mvarMagDeviation = sMagDeviation 
                 
                 
            sTempChecksum = Utils.Parse(mvarSentence, 12)   'temp var 
            sChecksum = Utils.Parse(sTempChecksum, 2, "*")  'Checksum 
            mvarChecksum = sChecksum 
         
        Else 
            Err.Raise InvalidOrCorruptGPRMC, "GPRMC::Sentence", "Invalid or corrupt GPRMC sentence." 
        End If 
         
    Set Utils = Nothing 
End Property 
 
Public Property Get Sentence() As String 
    Sentence = mvarSentence 
End Property