Sub Class_Globals
Dim Gps_String As String
Dim I As Int
Dim sText() As String
Dim myfields() As String
Dim got_an_error As Boolean
Dim error_msg As String
'
' GGA variables
'
Dim UTC_time As String
' Dim latitude As Double
Dim lat_type As String
' Dim longitude As Double
Dim long_type As String
' Dim quality As String
' Dim height_MSL As Double
Dim geoidal_sepn As Double
Dim height_units As String
' Dim age As Int
Dim ref_stn As String
'
' GSA variables
'
Dim mode As String
Dim current_mode As String
Dim sat_prn(12) As Int
Dim num_sat_prn As Int
' Public pdop As Double
' Dim hdop As Double
' Dim vdop As Double
'
' GST variables
'
Dim lat_error As Double
Dim long_error As Double
Dim horz_error As Double
Dim height_error As Double
'
' RMC variables
'
Dim rmc_status As String
Dim speedOG As Double
Dim trackMG As Double
Dim rmc_date As String
Dim magvar As Double
Dim dirn_magvar As String
Dim modeind As String
Dim Geo As Geodesy
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
Geo.Initialize
End Sub
Sub CheckGPS(A As String) ''(myval As Boolean)
Dim I, sCount As Int
Gps_String=A
''current_string = "None"
sText = Regex.Split(CRLF, Gps_String)
I=0
sCount=Regex.Split(CRLF,Gps_String).Length
For I=0 To sCount-1
Try
Select Case sText(I).SubString2(3,6)
Case "GGA"
Parse_GGA
Case "GSA"
Parse_GSA
Case "GST"
Parse_GST
Case "RMC"
End Select
Catch
Log(LastException)
End Try
Next
End Sub
Sub Parse_GGA
'
' parses a GGA string
'
Dim myval1, myval2 As Double
' Dim mystr As String
myfields = Regex.Split(",",sText(I))
If(myfields.Length < 14) Then
Return
End If
'
' check if we actually have data
'
CGlobals.Status = "No GPS"
got_an_error = False
error_msg="no error"
'
Try
If myfields(2)="" Then Return
UTC_time=myfields(1).SubString2(0,2) & ":" & myfields(1).SubString2(2,4) & ":" & myfields(1).SubString2(4,6)
myval1=myfields(2).SubString2(0,2)
myval2=myfields(2).SubString(2)
myval2=myval2/60.0
CGlobals.Lat=Round2(myval1+myval2,12)
lat_type=myfields(3)
myval1=myfields(4).SubString2(0,3)
myval2=myfields(4).SubString(3)
myval2=myval2/60.0
CGlobals.Lon=Round2(myval1+myval2,12)
long_type=myfields(5)
CGlobals.Status=""
If(myfields(6)="0") Then
CGlobals.Status="No GPS"
End If
If(myfields(6)="1") Then
CGlobals.Status="GPS"
End If
If(myfields(6)="2") Then
CGlobals.Status="DGPS"
End If
If(myfields(6)="4") Then
CGlobals.Status="Fix"
End If
If(myfields(6)="5") Then
CGlobals.Status="Float"
End If
'
CGlobals.SatNo=myfields(7)
If IsNumber(myfields(8))=True Then CGlobals.HDOP=myfields(8) Else CGlobals.HDOP=0
CGlobals.LevHgt=myfields(9)
height_units=myfields(10)
geoidal_sepn=myfields(11)
'
If(myfields(13) <> "") Then
CGlobals.Age=myfields(13)
Else
CGlobals.Age=0
End If
'
ref_stn="??"
If(myfields(14) <> "") Then
If(myfields(14).substring2(0,4) = "0100") Then
ref_stn = "VBS"
End If
If(myfields(14).substring2(0,4) = "1000") Then
ref_stn = "HP"
End If
If(myfields(14).substring2(0,4) = "1008") Then
ref_stn = "XP"
End If
If(myfields(14).substring2(0,4) = "1016") Then
ref_stn = "HP & XP"
End If
End If
CheckCoords
Catch
error_msg=LastException.Message
'
End Try
'
End Sub
Sub Parse_GSA
'
' parses a GSA string
'
Dim isat As Int
myfields = Regex.Split(",",sText(I))
If(myfields.length < 17) Then
Return
End If
'
Try
'
mode=myfields(1)
If(mode="M") Then
mode="Manual"
Else
mode="Automatic"
End If
If(myfields(2)="1") Then
current_mode="No fix"
Else If (myfields(2)="2") Then
current_mode="2D fix"
Else If (myfields(2)="3") Then
current_mode="3D fix"
End If
'
num_sat_prn=0
For isat=1 To 12
sat_prn(isat-1)=0
If(myfields(isat+2)<>"") Then
num_sat_prn=num_sat_prn+1
sat_prn(isat-1)=myfields(isat+2)
End If
Next
'
CGlobals.Pdop=0.0
CGlobals.Hdop=0.0
CGlobals.Vdop=0.0
'
If(myfields(15)<>"") Then
CGlobals.Pdop=myfields(15)
End If
If(myfields(16)<>"") Then
CGlobals.Hdop=myfields(16)
End If
If(myfields(17)<>"") Then
CGlobals.Vdop=myfields(17).SubString2(0,3)
End If
Catch
End Try
End Sub
Sub Parse_GST
Dim i1 As Int
myfields = Regex.Split(",",sText(I))
If(myfields.Length < 8) Then
Return
End If
Try
i1=myfields(8).IndexOf("*")
myfields(8)=myfields(8).SubString2(0,i1)
If (myfields(6) <> "") Then
lat_error = myfields(6)
lat_error=100.0*lat_error
lat_error = Round2(lat_error,1)
Else
lat_error = 0
End If
CGlobals.LatError= myfields(6)
If (myfields(7) <> "") Then
long_error = myfields(7)
long_error=100.0*long_error
long_error = Round2(long_error,1)
Else
long_error = 0
End If
CGlobals.LonError= myfields(7)
If (myfields(8) <> "") Then
height_error = myfields(8)
height_error=100.0*height_error
height_error = Round2(height_error,1)
Else
height_error = 0
End If
CGlobals.HgtError= myfields(8)
'
' calc horizontal error
'
horz_error = Sqrt((lat_error * lat_error) + (long_error * long_error))
horz_error = Round2(horz_error, 1)
Catch
End Try
End Sub
Sub Parse_RMC
'
' parses an RMC string
'
Dim myval1, myval2 As Double
' Dim mystr As String
myfields = Regex.Split(",",sText(I))
If(myfields.Length < 12) Then
Return
End If
'
' check if we actually have data
'
got_an_error = False
error_msg="no error"
'
Try
UTC_time=myfields(1).SubString2(0,2) & ":" & myfields(1).SubString2(2,4) & ":" & myfields(1).SubString2(4,6)
'
' status=myfields(2)
' If(status="A") Then
' status="Valid"
' Else
' status="Warning"
' End If
'
myval1=myfields(3).SubString2(0,2)
myval2=myfields(3).SubString(2)
myval2=myval2/60.0
CGlobals.Lat=Round2(myval1+myval2,7)
lat_type=myfields(4)
'
myval1=myfields(5).SubString2(0,3)
myval2=myfields(5).SubString(3)
myval2=myval2/60.0
CGlobals.Lon=Round2(myval1+myval2,7)
long_type=myfields(6)
'
speedOG=myfields(7)
trackMG=myfields(8)
' date=myfields(9)
magvar=myfields(10)
dirn_magvar=myfields(11)
If(myfields(12) = "A") Then
modeind="Autonomous"
Else If (myfields(12)="D") Then
modeind="Differential"
Else If (myfields(12)="N") Then
modeind="Data not valid"
End If
'
Catch
error_msg=LastException.Message
'
End Try
'
End Sub
Sub CheckCoords
' If CGlobals.Li=2 And (CGlobals.DF(50)=3 Or CGlobals.DF(31)=3 Or CGlobals.DF(50)=2 Or CGlobals.DF(31)=2) And lat_type="S" Then
' If CGlobals.lat>0 Then
' CGlobals.lat=0-CGlobals.lat
' End If
' End If
Select Case CGlobals.DF(50),CGlobals.DF(31)
Case 1
'Leica
Case 2
'Emlid
Case 3,4,5,10
'Foif, RinoNav, E-Survey, StoneX
CGlobals.lat=0-CGlobals.lat
Case 6
'Tersus
' Log(CGlobals.lat & " " & CGlobals.Lon)
CGlobals.lat=0-CGlobals.lat
' CGlobals.lat=CGlobals.lat/1000
' CGlobals.Lon=CGlobals.lon/1000
Case 7
'Geomax
Case 8
'ComNav
Case 9
'CHC
End Select
Geo.Get_point_to_Local(CGlobals.Lat ,CGlobals.Lon)
' Log(Engine.Y & " " & Engine.X & " " & CGlobals.LevHgt)
Select Case CGlobals.Code
Case 20,70
'Fix A Point, Calibrate NMEA
CGlobals.Y3=CGlobals.Y3 + Engine.Y
CGlobals.X3=CGlobals.X3 + Engine.X
CGlobals.Z3 = CGlobals.Z3 + CGlobals.LevHgt - CGlobals.GPSPH
CGlobals.Count=CGlobals.Count+1
Case 1,2,3,4,10,21,22
'Setout
CGlobals.Y3=NumberFormat2(Engine.Y,1,3,3,False)
CGlobals.X3=NumberFormat2(Engine.X,1,3,3,False)
CGlobals.Z3 = CGlobals.LevHgt - CGlobals.GPSPH
CGlobals.Z3 = NumberFormat2(CGlobals.Z3,1,3,3,False)
Case 31,32,33,86,87
'Topo
CGlobals.Y3=NumberFormat2(Engine.Y,1,3,3,False)
CGlobals.X3=NumberFormat2(Engine.X,1,3,3,False)
CGlobals.Z3 = CGlobals.LevHgt - CGlobals.GPSPH
CGlobals.Z3 = NumberFormat2(CGlobals.Z3,1,3,3,False)
Case 40,41,42,43,50
'Batterboards
CGlobals.Y3=NumberFormat2(Engine.Y,1,3,3,False)
CGlobals.X3=NumberFormat2(Engine.X,1,3,3,False)
CGlobals.Z3 = CGlobals.LevHgt - CGlobals.GPSPH
CGlobals.Z3 = NumberFormat2(CGlobals.Z3,1,3,3,False)
Case 60,61,62,63,67,70,71,90,91,92,93,94,300
'Elevations
CGlobals.Y3=NumberFormat2(Engine.Y,1,3,3,False)
CGlobals.X3=NumberFormat2(Engine.X,1,3,3,False)
CGlobals.Z3 = CGlobals.LevHgt - CGlobals.GPSPH
CGlobals.Z3 = NumberFormat2(CGlobals.Z3,1,3,3,False)
End Select
CGlobals.X3=CGlobals.X3 + CGlobals.XCorr
CGlobals.Y3=CGlobals.Y3 + CGlobals.YCorr
CGlobals.Z3=CGlobals.Z3 + CGlobals.ZCorr
End Sub