Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit On
- Option Strict On
- Module EM3000
- Sub Main()
- Dim SingleStatus As sSimRad
- Dim DataOK As Boolean = SingleStatus.ParseData(New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 0})
- End Sub
- End Module
- Public Structure sSimRad
- Public Enum eStatus As Byte
- Normal = &H90
- Reduced = &H91
- Invalid = &HA0
- End Enum
- Public Status As eStatus
- Public Header As Byte
- Public Roll As Single
- Public Pitch As Single
- Public Heave As Int16
- Public Heading As Single
- ''' <summary>
- ''' Extraxts values from binary motion data
- ''' </summary>
- ''' <param name="Data">EM3000 Binary data 10 bytes</param>
- ''' <returns>True or False</returns>
- Public Function ParseData(ByVal Data() As Byte) As Boolean
- If Data.Length <> 10 Then
- Return False
- Else
- Status = CType(Data(0), eStatus)
- Header = Data(1)
- Roll = CSng(BitConverter.ToInt16(New Byte() {Data(2), Data(3)}, 0) / 100)
- Pitch = CSng(BitConverter.ToInt16(New Byte() {Data(4), Data(5)}, 0) / 100)
- Heave = BitConverter.ToInt16(New Byte() {Data(6), Data(7)}, 0)
- Heading = CSng(BitConverter.ToUInt16(New Byte() {Data(8), Data(9)}, 0) / 100)
- Return True
- End If
- End Function
- End Structure
Add Comment
Please, Sign In to add comment