summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2006-11-28 12:00:00 +0100
committerMartin Burnicki <martin.burnicki@meinberg.de>2006-11-28 12:00:00 +0100
commitd9e748cb67988cbec215da10c96f0973e1cba4b2 (patch)
tree128431d8a4333f849e841daf0d584ce334cb833c
parent95e8386fc771aea71e2b36a13ef439a6f7dd8414 (diff)
downloadmbgsdk-win-d9e748cb67988cbec215da10c96f0973e1cba4b2.tar.gz
mbgsdk-win-d9e748cb67988cbec215da10c96f0973e1cba4b2.zip
Update unit mbgdevio-vb6 and the example codembgdevio-demo-vb6-2.18
-rw-r--r--common/mbgdevio-vb6.bas85
-rw-r--r--mbgdevio-demo-vb6.frm98
-rw-r--r--mbgdevio-demo-vb6.vbp2
3 files changed, 174 insertions, 11 deletions
diff --git a/common/mbgdevio-vb6.bas b/common/mbgdevio-vb6.bas
index 48ac7c3..24716c3 100644
--- a/common/mbgdevio-vb6.bas
+++ b/common/mbgdevio-vb6.bas
@@ -2,7 +2,7 @@ Attribute VB_Name = "mbgdevio"
'**************************************************************************
'
-' $Id: mbgdevio-vb6.bas 1.3 2006/05/31 13:27:29Z martin REL_M $
+' $Id: mbgdevio-vb6.bas 1.4 2006/11/28 10:33:24Z martin REL_M $
'
' Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
'
@@ -13,15 +13,19 @@ Attribute VB_Name = "mbgdevio"
' This module is for Visual Basic 6 which provides only limited support
' for complex data types.
'
-' If there are any questions or enhancemetnt requests, please contact
+' If there are any questions or enhancement requests, please contact
' Meinberg: support@meinberg.de
'
' -----------------------------------------------------------------------
' $Log: mbgdevio-vb6.bas $
+' Revision 1.4 2006/11/28 10:33:24Z martin
+' Added definitions required to read the GPS receiver position.
+' Added definition for PCPS_SUCCESS.
+' Fixed a typo inside a comment.
' Revision 1.3 2006/05/31 13:27:29Z martin
' Added declarations used to deal with HR time.
' Added declarations to deal with user capture events.
-' Renamed this file to mbgdevio-vb6.bas since it is not compatible
+' Renamed this file to mbgdevio-vb6.bas since it is not compatible
' with VB.NET.
' Revision 1.2 2004/02/25 11:14:47Z martin
' Added definitions of the PCPS_TIME status bits.
@@ -135,6 +139,66 @@ Public Const PCPS_UCAP_BUFFER_FULL = &H4000 ' events read too slow
+' The definitions below are used with geographic positions.
+
+' The type below is used to hold a geographic position
+' in kartesian coordinates.
+
+Public Type MBG_POS_XYZ
+ x As Double ' x coordinate, in meters
+ y As Double ' y coordinate, in meters
+ z As Double ' z coordinate, in maters
+End Type
+
+' The type below is used to pass a geographic position
+' in raw geographic coordinates.
+
+Public Type MBG_POS_LLA
+ lat As Double ' latitude, in radians
+ lon As Double ' longitude, in radians
+ alt As Double ' altitude (height above ellipsoid), in meters
+End Type
+
+' The type below is used to store a geographic coordinate
+' in broken-down (human readable) format.
+
+Public Type MBG_DMS
+ prefix As Integer ' ASCII code of 'N', 'E', 'S' or 'W'
+ deg As Integer ' [0...90 (lat) or 0...180 (lon)]
+ min As Integer ' [0...59]
+ ' The next field should be a double value which holds the seconds
+ ' and fractions of the second of the geographic angle.
+ 'sec As Double ' [0...59.999]
+
+ ' However, VB6 only supports 32 bit (DWORD) alignment of data
+ ' types whose size is 4 bytes or more, so due to the layout of
+ ' this structure a 2 byte gap would be inserted before the "double"
+ ' type. In this case the DLL functions would write the output data
+ ' to a memory location which does not match the structure layout.
+ ' As a workaround we specify 4 integer fields which use
+ ' the same size of memory, but are word aligned only and thus
+ ' do not cause a gap to be inserted.
+ ' The 4 sec_ fields below could be consequently copied to the memory
+ ' location of another "double" type variable, which could then
+ ' be displayed properly.
+ sec_0 As Integer
+ sec_1 As Integer
+ sec_2 As Integer
+ sec_3 As Integer
+End Type
+
+
+
+Public Type MBG_RCVR_POS
+ xyz As MBG_POS_XYZ ' always WGS84 ECEF coordinates
+ lla As MBG_POS_LLA ' depending on the ellipsoid used for reference
+ longitude As MBG_DMS ' longitude in degrees, minutes, seconds
+ latitude As MBG_DMS ' latitude in degrees, minutes, seconds
+ ellipsoid As Integer ' ellipsoid used for reference
+End Type
+
+
+
'
' Some of the functions exported by the mbgdevio DLL
' --------------------------------------------------
@@ -149,6 +213,9 @@ Public Const PCPS_UCAP_BUFFER_FULL = &H4000 ' events read too slow
' whether such an API call is supported by the specific device. API calls
' which are not supported by each device are commented accordingly.
+' This value is returned by the API functions on success.
+Public Const PCPS_SUCCESS As Integer = 0
+
' Return the number of radio clock devices detected
' If this function returns 0, then no devices has been detected.
@@ -222,3 +289,15 @@ Public Declare Function mbg_get_ucap_entries Lib "mbgdevio" (ByVal h As Long, By
Public Declare Function mbg_get_ucap_event Lib "mbgdevio" (ByVal h As Long, ByRef t As PCPS_HR_TIME) As Long
+'--------------------------------------------------------------------------------
+' The functions below can be used to read the receiver position from GPS add-in
+' cards. This is NOT supported by non-GPS add-in cards, so there's another
+' function which checks whether a specific device is a GPS receiver.
+
+' Check whether the device referenced by handle h is a GPS receiver.
+' If it is then the value returned for f is not 0.
+Public Declare Function mbg_dev_is_gps Lib "mbgdevio" (ByVal h As Long, ByRef f As Long) As Long
+
+' Read the current receiver position.
+Public Declare Function mbg_get_gps_pos Lib "mbgdevio" (ByVal h As Long, ByRef p As MBG_RCVR_POS) As Long
+
diff --git a/mbgdevio-demo-vb6.frm b/mbgdevio-demo-vb6.frm
index a3b3ad1..0b4c025 100644
--- a/mbgdevio-demo-vb6.frm
+++ b/mbgdevio-demo-vb6.frm
@@ -35,7 +35,7 @@ Attribute VB_Exposed = False
'**************************************************************************
'
-' $Id: mbgdevio-demo-vb6.frm 1.3 2006/05/31 14:03:04Z martin REL_M $
+' $Id: mbgdevio-demo-vb6.frm 1.4 2006/11/28 10:38:29Z martin REL_M $
'
' Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
'
@@ -56,6 +56,12 @@ Attribute VB_Exposed = False
'
' -----------------------------------------------------------------------
' $Log: mbgdevio-demo-vb6.frm $
+' Revision 1.4 2006/11/28 10:38:29Z martin
+' Added some code which display the GPS receiver position.
+' This is not quite complete, though, due to limitations of VB6.
+' See notes for MBG_DMS in the mbgdevio module.
+' Added missing return type to MbgSyncStatusStr function.
+' Pass structures to functions ByRef.
' Revision 1.3 2006/05/31 14:03:04Z martin
' Also read and display HR time, and user capture events.
' Renamed project and form.
@@ -69,7 +75,7 @@ Attribute VB_Exposed = False
' returns a string which indicates whether the device
' is synchronized, or not.
-Private Function MbgSyncStatusStr(status As Integer)
+Private Function MbgSyncStatusStr(status As Integer) As String
' If the PCPS_FREER bit is set in the status
' then the device is not synchronized
@@ -86,7 +92,7 @@ End Function
' The function below takes a PCPS_TIME structure and returns
' a string which represents the date and time from that structure.
-Private Function PcpsTimeToString(t As PCPS_TIME) As String
+Private Function PcpsTimeToString(ByRef t As PCPS_TIME) As String
Dim LongYear As Integer
Dim offs_utc As Integer
@@ -125,7 +131,7 @@ End Function
' The function below takes a PCPS_TIME_STAMP structure and returns
' a string of seconds and fractions represented as hex numbers
-Private Function PcpsTimeStampToHexString(t As PCPS_TIME_STAMP) As String
+Private Function PcpsTimeStampToHexString(ByRef t As PCPS_TIME_STAMP) As String
PcpsTimeStampToHexString = Format(Hex(t.sec), "00000000") + "." _
+ Format(Hex(t.frac), "00000000")
@@ -136,7 +142,7 @@ End Function
' The function below takes a PCPS_TIME_STAMP structure and returns
' a string which represents the date and time.
-Private Function PcpsTimeStampToString(t As PCPS_TIME_STAMP) As String
+Private Function PcpsTimeStampToString(ByRef t As PCPS_TIME_STAMP) As String
Const DaysPerYear As Double = 86400#
Const EpocheOffs1970 As Double = 25569#
@@ -175,7 +181,7 @@ End Function
' The function below takes a PCPS_HR_TIME structure and returns
' a string representing the UTC time.
-Private Function PcpsHrTimeToUtcTimeString(ht As PCPS_HR_TIME) As String
+Private Function PcpsHrTimeToUtcTimeString(ByRef ht As PCPS_HR_TIME) As String
PcpsHrTimeToUtcTimeString = PcpsTimeStampToString(ht.tstamp) + " UTC"
@@ -187,7 +193,7 @@ End Function
' a string representing the local time according to the time zone offset
' which in turn depends on the time zone configuration of the board.
-Private Function PcpsHrTimeToLocalTimeString(ht As PCPS_HR_TIME) As String
+Private Function PcpsHrTimeToLocalTimeString(ByRef ht As PCPS_HR_TIME) As String
Dim tmp_ht As PCPS_HR_TIME
Dim hours As Integer
@@ -220,6 +226,55 @@ End Function
+' The function below takes a MBG_POS_LLA structure and returns
+' a string representing the raw geographic coordinates, with
+' angles converted from radians to degrees.
+
+Private Function MbgPosLlaStr(ByRef lla As MBG_POS_LLA) As String
+ Dim r2d As Double
+
+ r2d = 180 / 3.1415
+
+ MbgPosLlaStr = "Lat: " + Format(lla.lat * r2d, "0.0000") + " deg, " _
+ + "Lon: " + Format(lla.lon * r2d, "0.0000") + " deg, " _
+ + "Alt: " + Format(lla.alt, "0") + " m"
+
+End Function
+
+
+
+' The function below takes a MBG_DMS structure and returns a string
+' representing a geographic angle in human readable format.
+
+Private Function MbgPosDms(ByRef dms As MBG_DMS) As String
+ MbgPosDms = Chr(dms.prefix) + " " _
+ + Format(dms.deg, "0") + ":" _
+ + Format(dms.min, "00") + ":" _
+ + "xx.xxxx"
+
+ ' The last line above should read similar to
+ '+ Format(dms.sec, "00.00")
+ ' However, due to limitations in alignment of structures in VB6
+ ' the MBG_DMS structure can not be defined properly according
+ ' to the reqirements of the DLLs. See also the definition
+ ' of the MBG_DMS structure in the mbgdevio module.
+
+End Function
+
+
+
+' The function below takes a MBG_RCVR_POS structure and returns a string
+' representing the geographic coordinates in human readable format.
+
+Private Function MbgRcvrPosStr(ByRef pos As MBG_RCVR_POS) As String
+ MbgRcvrPosStr = MbgPosDms(pos.latitude) + ", " _
+ + MbgPosDms(pos.longitude) + ", " _
+ + Format(pos.lla.alt, "0") + " m"
+
+End Function
+
+
+
' The subroutine below is executed whenever the "Update" button is clicked.
' It opens the device, read and display some information, and finally
' closes the device.
@@ -304,6 +359,35 @@ Private Sub UpdateCommandButton_Click()
Me.InfoTextBox.Text = Me.InfoTextBox.Text + Chr(13) + Chr(10) + Chr(13) + Chr(10)
+ rc = mbg_dev_is_gps(h, f)
+
+ If rc = PCPS_SUCCESS Then
+ ' could check successfully
+ If f <> 0 Then
+ ' device is a GPS receiver
+ Dim pos As MBG_RCVR_POS
+
+ rc = mbg_get_gps_pos(h, pos)
+
+ If rc = PCPS_SUCCESS Then
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text _
+ + "Receiver position: " + Chr(13) + Chr(10) _
+ + MbgPosLlaStr(pos.lla) + Chr(13) + Chr(10) _
+ + MbgRcvrPosStr(pos)
+ Else
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + "Error reading receiver position."
+ End If
+ Else
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + "Device does not support receiver position."
+ End If
+ Else
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + "Error checking if device supports receiver position."
+ End If
+
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + Chr(13) + Chr(10) + Chr(13) + Chr(10)
+
+
+
' If the device supports user capture inputs, also display user capture info
rc = mbg_dev_has_ucap(h, f)
diff --git a/mbgdevio-demo-vb6.vbp b/mbgdevio-demo-vb6.vbp
index 385751d..7fbd0b2 100644
--- a/mbgdevio-demo-vb6.vbp
+++ b/mbgdevio-demo-vb6.vbp
@@ -1,6 +1,6 @@
Type=Exe
Form=mbgdevio-demo-vb6.frm
-Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\WINNT\system32\stdole2.tlb#OLE Automation
+Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\WINNT\system32\stdole2.tlb#OLE Automation
Module=mbgdevio; common\mbgdevio-vb6.bas
IconForm="mbgdevio_demo_vb6"
Startup="mbgdevio_demo_vb6"