⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gsv.cls

📁 GPS实时定位的程序实现,GPS实时定位的程序实现 希望对大家有帮助
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "GPGSV"
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:    GSV.cls
'Author:        Ray Bivens, Applications Prototype Lab, ESRI
'Date:          Dec 98
'Description:   Factors an NMEA (GPS) 'GPGSV' sentence to its string components.
'Comments:      Create an instance of the class and assign a GPGSV string to the
'               Sentence property.
'
'Revisions:

Option Explicit
Option Base 0

'local variables to hold property values
Private mvarChecksum As String
Private mvarSentence As String
Private mvarSatsInView As String
Private mvarMessageCount As String
Private mvarMessageNumber As String
Private mvarPRN As String
Private mvarElevation As String
Private mvarAzimuth As String
Private mvarSNR As String

Public Enum GPGSVError
    InvalidOrCorruptGPGSV = vbObjectError + 512 + 4
    SNRitemOutOfRange = vbObjectError + 512 + 5
    AzimuthItemOutOfRange = vbObjectError + 512 + 6
    ElevationItemOutOfRange = vbObjectError + 512 + 7
    PRNItemOutOfRange = vbObjectError + 512 + 8
End Enum

Public Property Get SNR(Item As Integer) As String
Attribute SNR.VB_Description = "Returns the Signal-to-Noise Ratio (SNR) from the specified item."
    Select Case Item
        Case 0 To 3
            Call getSNR(Item)
        Case Else
            Err.Raise SNRitemOutOfRange, "GPGSV::SNR", "SNR 'Item' parameter must be 0..3"
        End Select
    SNR = mvarSNR
End Property

Public Property Get Azimuth(Item As Integer) As String
Attribute Azimuth.VB_Description = "Returns the azimuth from the specified item."
    Select Case Item
        Case 0 To 3
            Call getAzimuth(Item)
        Case Else
            Err.Raise AzimuthItemOutOfRange, "GPGSV::Azimuth", "Azimuth 'Item' parameter must be 0..3"
        End Select
    Azimuth = mvarAzimuth
End Property

Public Property Get Elevation(Item As Integer) As String
Attribute Elevation.VB_Description = "Returns the elevation from the specified item."
    Select Case Item
        Case 0 To 3
            Call getElevation(Item)
        Case Else
            Err.Raise ElevationItemOutOfRange, "GPGSV::Elevation", "Elevation 'Item' parameter must be 0..3"
        End Select
    Elevation = mvarElevation
End Property

Public Property Get PRN(Item As Integer) As String
Attribute PRN.VB_Description = "Returns the PRN from the specified item."
    Select Case Item
        Case 0 To 3
            Call getPRN(Item)
        Case Else
            Err.Raise PRNItemOutOfRange, "GPGSV::PRN", "PRN 'Item' parameter must be 0..3"
        End Select
    PRN = mvarPRN
End Property

Public Property Get MessageNumber() As String
Attribute MessageNumber.VB_Description = "Returns the current GPGSV message number in the current cycle."
    MessageNumber = mvarMessageNumber
End Property

Public Property Get MessageCount() As String
Attribute MessageCount.VB_Description = "Returns the total number of GPGSV messages in the current cycle."
    MessageCount = mvarMessageCount
End Property

Public Property Get SatsInView() As String
Attribute SatsInView.VB_Description = "Returns the current number of satellites in view."
    SatsInView = mvarSatsInView
End Property

Public Property Let Sentence(ByVal GSV_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(GSV_Sentence, 1) = "$GPGSV" And Utils.CountParts(GSV_Sentence) = 20 Then
        
        Dim sChecksum As String
        Dim sSatsInView As String
        Dim sMessageCount As String
        Dim sMessageNumber As String
        Dim sTempChecksum As String
        
        ' assign value to local variable...
        mvarSentence = GSV_Sentence
        
        ' parse NMEA sentence and check quality
        ' if qc conditions not met, leave var as empty...
        sMessageCount = Utils.Parse(mvarSentence, 2)        'MessageCount
            If IsNumeric(sMessageCount) Then
                mvarMessageCount = sMessageCount
            End If
            
        sMessageNumber = Utils.Parse(mvarSentence, 3)        'MessageNumber
            If IsNumeric(sMessageNumber) Then
                mvarMessageNumber = sMessageNumber
            End If
            
        sSatsInView = Utils.Parse(mvarSentence, 4)            'SatsInView
            If IsNumeric(sSatsInView) Then
                mvarSatsInView = sSatsInView
            End If
            
        sTempChecksum = Utils.Parse(mvarSentence, 20)       'Checksum
        sChecksum = Utils.Parse(sTempChecksum, 2, "*")
        mvarChecksum = sChecksum
        
        Else
            Err.Raise InvalidOrCorruptGPGSV, "GPGSV::Sentence", "Invalid or corrupt GPGSV sentence."
        End If
         
    Set Utils = Nothing
End Property

Public Property Get Sentence() As String
    Sentence = mvarSentence
End Property

Public Property Get Checksum() As String
Attribute Checksum.VB_Description = "Returns the checksum of the NMEA string."
    Checksum = mvarChecksum
End Property

Private Sub getSNR(Item As Integer)
Dim Utils As New CParseUtils
Dim sTempSNR
Dim SNR_Array(3) As String    'string array to hold SNR values
Dim sSkip As Byte
Dim i As Byte

    sSkip = 0
    For i = 0 To 3
        If sSkip < 12 Then
            SNR_Array(i) = Utils.Parse(mvarSentence, 8 + sSkip)
        Else
            sTempSNR = Utils.Parse(mvarSentence, 20)
            SNR_Array(i) = Utils.Parse(sTempSNR, 1, "*")
        End If
        sSkip = sSkip + 4     'skip to next SNR value in the sentence...
    Next i
        
    If IsNumeric(SNR_Array(Item)) Then
        mvarSNR = SNR_Array(Item)
    End If
    
Set Utils = Nothing
End Sub

Private Sub getAzimuth(Item As Integer)
Dim Utils As New CParseUtils
Dim AZ_Array(3) As String    'string array to hold Azimuth values
Dim sSkip As Byte
Dim i As Byte

    sSkip = 0
    For i = 0 To 3
        AZ_Array(i) = Utils.Parse(mvarSentence, 7 + sSkip)
        sSkip = sSkip + 4     'skip to next Azimuth value in the sentence...
    Next i
        
    If IsNumeric(AZ_Array(Item)) Then
        mvarAzimuth = AZ_Array(Item)
    End If
    
Set Utils = Nothing
End Sub

Private Sub getElevation(Item As Integer)
Dim Utils As New CParseUtils
Dim EL_Array(3) As String    'string array to hold Elevation values
Dim sSkip As Byte
Dim i As Byte

    sSkip = 0
    For i = 0 To 3
        EL_Array(i) = Utils.Parse(mvarSentence, 6 + sSkip)
        sSkip = sSkip + 4     'skip to next Elevation value in the sentence...
    Next i
        
    If IsNumeric(EL_Array(Item)) Then
        mvarElevation = EL_Array(Item)
    End If
    
Set Utils = Nothing
End Sub

Private Sub getPRN(Item As Integer)
Dim Utils As New CParseUtils
Dim PRN_Array(3) As String    'string array to hold PRN values
Dim sSkip As Byte
Dim i As Byte

    sSkip = 0
    For i = 0 To 3
        PRN_Array(i) = Utils.Parse(mvarSentence, 5 + sSkip)
        sSkip = sSkip + 4     'skip to next PRN value in the sentence...
    Next i
        
    mvarPRN = PRN_Array(Item)
    
Set Utils = Nothing
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -