Private Sub CommandButton2_Click()
L = 2
K = 1
‘longD = B2L(“FF”, “FF”, “FF”, “B0”)
With Worksheets(“sheet2”)
.Cells(1, 1) = “iTow”
.Cells(1, 2) = “Longtitude”
.Cells(1, 3) = “Latitude”
.Cells(1, 4) = “reliTOW”
.Cells(1, 5) = “relN”
.Cells(1, 6) = “relE”
.Cells(1, 7) = “relD”
.Cells(1, 8) = “relLen”
.Cells(1, 9) = “relHead”
.Cells(1, 10) = “SeaHeight”
.Cells(1, 11) = “HAcc_mm”
.Cells(1, 12) = “VAcc_mm”
End With
With Worksheets(“Sheet1”)
‘PVT B5620107 ->RELPOSNED B562013C 順で出力される
Maxrow = .Range(“A1”).End(xlDown).Row
MaxCol = .Range(“A1”).End(xlToRight).Column
For i = 1 To Maxrow ‘nFileLen – 1
‘ header = Right(“0” & Hex(bData(i)), 2) + Right(“0” & Hex(bData(i + 1)), 2) + Right(“0” & Hex(bData(i + 2)), 2) + Right(“0” & Hex(bData(i + 3)), 2)
If .Cells(i, 4) = “7” Then ‘PVT
L = L + 1
c1 = .Cells(i, 7)
X1 = CLng(“&H” & .Cells(i, 7))
iTOW = B2L(.Cells(i, 10), .Cells(i, 9), .Cells(i, 8), .Cells(i, 7))
‘iTOW = CLng(“&H” & .Cells(i, 7)) + CLng(“&H” & .Cells(i, 8)) * 256 + CLng(“&H” & .Cells(i, 9)) * 65536 + CLng(“&H” & .Cells(i, 10)) * 16777216
Lon = B2L(.Cells(i, 34), .Cells(i, 33), .Cells(i, 32), .Cells(i, 31))
‘Lon = CLng(“&H” & .Cells(i, 31)) + CLng(“&H” & .Cells(i, 32)) * 256 + CLng(“&H” & .Cells(i, 33)) * 65536 + CLng(“&H” & .Cells(i, 34)) * 16777216
Lat = B2L(.Cells(i, 38), .Cells(i, 37), .Cells(i, 36), .Cells(i, 35))
‘Lat = CLng(“&H” & .Cells(i, 35)) + CLng(“&H” & .Cells(i, 36)) * 256 + CLng(“&H” & .Cells(i, 37)) * 65536 + CLng(“&H” & .Cells(i, 38)) * 16777216
X1 = .Cells(i, 43)
X2 = .Cells(i, 44)
X3 = .Cells(i, 45)
X4 = .Cells(i, 46)
SeaHeight = B2L(.Cells(i, 46), .Cells(i, 45), .Cells(i, 44), .Cells(i, 43))
‘ CLng(“&H” & .Cells(i, 43)) + CLng(“&H” & .Cells(i, 44)) * 256 + CLng(“&H” & .Cells(i, 45)) * 65536 + CLng(“&H” & .Cells(i, 46)) * 16777216
HAcc = B2L(.Cells(i, 50), .Cells(i, 49), .Cells(i, 48), .Cells(i, 47))
‘HAcc = CLng(“&H” & .Cells(i, 47)) + CLng(“&H” & .Cells(i, 48)) * 256 + CLng(“&H” & .Cells(i, 49)) * 65536 + CLng(“&H” & .Cells(i, 50)) * 16777216
VAcc = B2L(.Cells(i, 54), .Cells(i, 53), .Cells(i, 52), .Cells(i, 51))
‘ VAcc = CLng(“&H” & .Cells(i, 51)) + CLng(“&H” & .Cells(i, 52)) * 256 + CLng(“&H” & .Cells(i, 53)) * 65536 + CLng(“&H” & .Cells(i, 54)) * 16777216
Worksheets(“sheet2”).Cells(L, 1) = iTOW
Worksheets(“sheet2”).Cells(L, 2) = Lon * 1.1 ‘cm
Worksheets(“sheet2”).Cells(L, 3) = Lat * 1.1 ‘cm
Worksheets(“sheet2”).Cells(L, 10) = SeaHeight / 1000 ‘cm
Worksheets(“sheet2”).Cells(L, 11) = HAcc ‘cm
Worksheets(“sheet2”).Cells(L, 12) = VAcc ‘cm
End If
If .Cells(i, 4) = “3C” Then ‘RELPOSNED
relTow = B2L(.Cells(i, 14), .Cells(i, 13), .Cells(i, 12), .Cells(i, 11))
‘relTow = CLng(“&H” & .Cells(i, 11)) + CLng(“&H” & .Cells(i, 12)) * 256 + CLng(“&H” & .Cells(i, 13)) * 65536 + CLng(“&H” & .Cells(i, 14)) * 16777216
relN = B2L(.Cells(i, 18), .Cells(i, 17), .Cells(i, 16), .Cells(i, 15))
‘relN = CLng(“&H” & .Cells(i, 15)) + CLng(“&H” & .Cells(i, 16)) * 256 + CLng(“&H” & .Cells(i, 17)) * 65536 + CLng(“&H” & .Cells(i, 18)) * 16777216
relE = B2L(.Cells(i, 22), .Cells(i, 21), .Cells(i, 20), .Cells(i, 19))
‘ relE = CLng(“&H” & .Cells(i, 19)) + CLng(“&H” & .Cells(i, 20)) * 256 + CLng(“&H” & .Cells(i, 21)) * 65536 + CLng(“&H” & .Cells(i, 22)) * 16777216
relD = B2L(.Cells(i, 26), .Cells(i, 25), .Cells(i, 24), .Cells(i, 23))
‘relD = CLng(“&H” & .Cells(i, 23)) + CLng(“&H” & .Cells(i, 24)) * 256 + CLng(“&H” & .Cells(i, 25)) * 65536 + CLng(“&H” & .Cells(i, 26)) * 16777216
relLen = B2L(.Cells(i, 30), .Cells(i, 29), .Cells(i, 28), .Cells(i, 27))
‘relLen = CLng(“&H” & .Cells(i, 27)) + CLng(“&H” & .Cells(i, 28)) * 256 + CLng(“&H” & .Cells(i, 29)) * 65536 + CLng(“&H” & .Cells(i, 30)) * 16777216
relHeadn = B2L(.Cells(i, 34), .Cells(i, 33), .Cells(i, 32), .Cells(i, 31))
‘relHead = CLng(“&H” & .Cells(i, 31)) + CLng(“&H” & .Cells(i, 32)) * 256 + CLng(“&H” & .Cells(i, 33)) * 65536 + CLng(“&H” & .Cells(i, 34)) * 16777216
X1 = CLng(“&H” & .Cells(i, 15))
X2 = CLng(“&H” & .Cells(i, 16))
X3 = CLng(“&H” & .Cells(i, 17))
‘X4 = CLng(“&H” & .Cells(i, 18)) * 16777216
‘ If .Cells(i, 18) <> “FF” Then
‘relN = CLng(“&H” & .Cells(i, 15)) + CLng(“&H” & .Cells(i, 16)) * 256 + CLng(“&H” & .Cells(i, 17)) * 65536 + CLng(“&H” & .Cells(i, 18)) * 16777216
‘If .Cells(i, 18) >= 12 Then
‘ relN = relN – 4294967296#
‘ End If
‘ End If
‘If .Cells(i, 22) <> “FF” Then
‘relE = CLng(“&H” & .Cells(i, 19)) + CLng(“&H” & .Cells(i, 20)) * 256 + CLng(“&H” & .Cells(i, 21)) * 65536 + CLng(“&H” & .Cells(i, 22)) * 16777216
‘ If .Cells(i, 22) >= 128 Then
‘ relE = relE – 4294967296#
‘ End If
‘End If
‘ If .Cells(i, 26) <> “FF” Then
‘ relD = CLng(“&H” & .Cells(i, 23)) + CLng(“&H” & .Cells(i, 24)) * 256 + CLng(“&H” & .Cells(i, 25)) * 65536 + CLng(“&H” & .Cells(i, 26)) * 16777216
‘If .Cells(i, 26) >= 128 Then
‘ relD = relD – 4294967296#
‘End If
‘End If
‘If .Cells(i, 30) <> “FF” Then
‘ relLen = CLng(“&H” & .Cells(i, 27)) + CLng(“&H” & .Cells(i, 28)) * 256 + CLng(“&H” & .Cells(i, 29)) * 65536 + CLng(“&H” & .Cells(i, 30)) * 16777216
‘End If
‘If .Cells(i, 34) <> “FF” Then
‘ relHead = CLng(“&H” & .Cells(i, 31)) + CLng(“&H” & .Cells(i, 32)) * 256 + CLng(“&H” & .Cells(i, 33)) * 65536 + CLng(“&H” & .Cells(i, 34)) * 16777216
‘End If
Worksheets(“sheet2”).Cells(L, 4) = relTow
Worksheets(“sheet2”).Cells(L, 5) = relN ‘cm
Worksheets(“sheet2”).Cells(L, 6) = relE ‘cm
Worksheets(“sheet2”).Cells(L, 7) = relD ‘cm
Worksheets(“sheet2”).Cells(L, 8) = relLen ‘cm
Worksheets(“sheet2”).Cells(L, 9) = relHead / 100000 ‘deg
End If
‘Cells(L, K) = “‘” & Right(“0” & Hex(bData(i + j)), 2)
‘ K = K + 1
Next i
End With
End Sub
Function B2L(ByRef b4 As String, ByRef b3 As String, ByRef b2 As String, ByRef b1 As String) As Long
‘MsgBox Left(b4, 1)
If Left(b4, 1) <> “F” Then ‘最上位Fでなければ正のLONG
B2L = CLng(“&H” & b1) + CLng(“&H” & b2) * 256 + CLng(“&H” & b3) * 256 * 256 + CLng(“&H” & b4) * 256 * 256 * 256
Else
B2L = -(256 – CLng(“&H” & b1)) + (255 – CLng(“&H” & b2)) * 256 + (255 – CLng(“&H” & b3)) * 256 * 256 + (255 – CLng(“&H” & b4)) * 256 * 256 * 256
End If
End Function |