summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2009-01-21 12:32:00 +0100
committerMartin Burnicki <martin.burnicki@meinberg.de>2009-01-21 12:32:00 +0100
commitd578cd1b41510aabd394e785ed2b04ad5e050f8a (patch)
treeeec5bf78919f98e4a508cdf22a1c8f50d8565e5c
parent13364f3c64b13c8bac5dabcbf3a8d7448569bdc2 (diff)
parent3effaa6447e166cd75b96fae16babd8c04e11d87 (diff)
downloadmbgsdk-win-d578cd1b41510aabd394e785ed2b04ad5e050f8a.tar.gz
mbgsdk-win-d578cd1b41510aabd394e785ed2b04ad5e050f8a.zip
Merge branch 'mbgdevio-demo-vb6'
-rw-r--r--vb6/demo/mbgdevio/mbgdevio-demo-vb6.exebin0 -> 32768 bytes
-rw-r--r--vb6/demo/mbgdevio/mbgdevio-demo-vb6.frm465
-rw-r--r--vb6/demo/mbgdevio/mbgdevio-demo-vb6.vbp38
-rw-r--r--vb6/mbglib/mbgdevio-vb6.bas303
4 files changed, 806 insertions, 0 deletions
diff --git a/vb6/demo/mbgdevio/mbgdevio-demo-vb6.exe b/vb6/demo/mbgdevio/mbgdevio-demo-vb6.exe
new file mode 100644
index 0000000..babd669
--- /dev/null
+++ b/vb6/demo/mbgdevio/mbgdevio-demo-vb6.exe
Binary files differ
diff --git a/vb6/demo/mbgdevio/mbgdevio-demo-vb6.frm b/vb6/demo/mbgdevio/mbgdevio-demo-vb6.frm
new file mode 100644
index 0000000..0b4c025
--- /dev/null
+++ b/vb6/demo/mbgdevio/mbgdevio-demo-vb6.frm
@@ -0,0 +1,465 @@
+VERSION 5.00
+Begin VB.Form mbgdevio_demo_vb6
+ Caption = "Check Radio Clock Sync Status"
+ ClientHeight = 4620
+ ClientLeft = 60
+ ClientTop = 345
+ ClientWidth = 6495
+ LinkTopic = "Form1"
+ ScaleHeight = 4620
+ ScaleWidth = 6495
+ StartUpPosition = 3 'Windows Default
+ Begin VB.CommandButton UpdateCommandButton
+ Caption = "Update"
+ Height = 495
+ Left = 2280
+ TabIndex = 1
+ Top = 3960
+ Width = 1935
+ End
+ Begin VB.TextBox InfoTextBox
+ Height = 3495
+ Left = 240
+ MultiLine = -1 'True
+ TabIndex = 0
+ Text = "mbgdevio-demo-vb6.frx":0000
+ Top = 240
+ Width = 6015
+ End
+End
+Attribute VB_Name = "mbgdevio_demo_vb6"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = False
+Attribute VB_PredeclaredId = True
+Attribute VB_Exposed = False
+
+'**************************************************************************
+'
+' $Id: mbgdevio-demo-vb6.frm 1.4 2006/11/28 10:38:29Z martin REL_M $
+'
+' Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+'
+' Description:
+' Sample Visual Basic code demonstrating how to access
+' Meinberg radio clock devices using the mbgdevio module
+' which contains the interface to the mbgdevio DLL shipped with
+' the driver software package.
+'
+' The module mbgdevio must be added to the project. By default,
+' the module is located in the subdirectory "common\".
+'
+' This sample code is for Visual Basic 6 which provides only limited
+' support for complex data types.
+'
+' If there are any questions or enhancement requests, please contact
+' Meinberg: support@meinberg.de
+'
+' -----------------------------------------------------------------------
+' $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.
+' Revision 1.2 2004/02/25 11:15:37Z martin
+' Added standard file header, and some comments.
+'
+'**************************************************************************
+
+
+' The function below takes a device status value and
+' returns a string which indicates whether the device
+' is synchronized, or not.
+
+Private Function MbgSyncStatusStr(status As Integer) As String
+
+ ' If the PCPS_FREER bit is set in the status
+ ' then the device is not synchronized
+ If status And PCPS_FREER Then
+ MbgSyncStatusStr = "NOT synchronized"
+ Else
+ MbgSyncStatusStr = "synchronized"
+ End If
+
+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(ByRef t As PCPS_TIME) As String
+
+ Dim LongYear As Integer
+ Dim offs_utc As Integer
+
+ ' Convert 2 digit year number to 4 digit year
+ If t.year < 90 Then
+ LongYear = t.year + 2000
+ Else
+ LongYear = t.year + 1900
+ End If
+
+ ' Negative UTC offset values require special handling since VB6 only
+ ' provides unsigned 8 bit values whereas the t.offs_utc value's nature
+ ' is signed.
+
+ If t.offs_utc > 127 Then
+ offs_utc = 256 - t.offs_utc
+ c = "-"
+ Else
+ offs_utc = t.offs_utc
+ c = "+"
+ End If
+
+ PcpsTimeToString = Format(LongYear, "000#") + "-" _
+ + Format(t.month, "0#") + "-" _
+ + Format(t.mday, "0#") + " " _
+ + Format(t.hour, "0#") + ":" _
+ + Format(t.min, "0#") + ":" _
+ + Format(t.sec, "0#") + "." _
+ + Format(t.sec100, "0#") + " UTC" _
+ + c + Format(offs_utc) + "h"
+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(ByRef t As PCPS_TIME_STAMP) As String
+
+ PcpsTimeStampToHexString = Format(Hex(t.sec), "00000000") + "." _
+ + Format(Hex(t.frac), "00000000")
+End Function
+
+
+
+' The function below takes a PCPS_TIME_STAMP structure and returns
+' a string which represents the date and time.
+
+Private Function PcpsTimeStampToString(ByRef t As PCPS_TIME_STAMP) As String
+
+ Const DaysPerYear As Double = 86400#
+ Const EpocheOffs1970 As Double = 25569#
+ Const frac_scale As Double = 4294967296# ' &H100000000
+ Dim dt As Date
+ Dim frac As Double
+
+ ' Convert seconds since 1970 to the VB date format
+ dt = CDate(CDbl(t.sec) / DaysPerYear + EpocheOffs1970)
+
+ ' Convert the fractions of the second to decimal fractions
+ ' (&HFFFFFFFF = 0.999999...)
+ frac = CDbl(t.frac)
+
+ ' Negative frac values require special handling since VB6 only
+ ' provides signed 32 bit values whereas the frac value's nature
+ ' is unsigned
+ If t.frac < 0 Then
+ frac = frac + frac_scale
+ End If
+
+ frac = frac / frac_scale
+
+ ' Re-scale the fractions depending on the number of decimal
+ ' digits we want to print, e.g. if we want to print 7 digits
+ ' (100 nanosecond units) then we must multiply by 1E7
+ ' and specify the format string accordingly.
+ frac = frac * 10000000#
+
+ PcpsTimeStampToString = Format(dt, "yyyy-mm-dd hh:MM:ss") + "." _
+ + Format(frac, "0000000")
+End Function
+
+
+
+' The function below takes a PCPS_HR_TIME structure and returns
+' a string representing the UTC time.
+
+Private Function PcpsHrTimeToUtcTimeString(ByRef ht As PCPS_HR_TIME) As String
+
+ PcpsHrTimeToUtcTimeString = PcpsTimeStampToString(ht.tstamp) + " UTC"
+
+End Function
+
+
+
+' The function below takes a PCPS_HR_TIME structure and returns
+' 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(ByRef ht As PCPS_HR_TIME) As String
+
+ Dim tmp_ht As PCPS_HR_TIME
+ Dim hours As Integer
+ Dim Mins As Integer
+ Dim c As String
+
+ ' Add the UTC offset to the seconds field in order to yield local time
+ ' according to the time zone configuration on the board.
+ tmp_ht = ht
+ tmp_ht.tstamp.sec = tmp_ht.tstamp.sec + tmp_ht.utc_offs
+
+ ' Save the sign of the offset and make sure the value is not negative
+ If tmp_ht.utc_offs < 0 Then
+ c = "-"
+ tmp_ht.utc_offs = -tmp_ht.utc_offs
+ Else
+ c = "+"
+ End If
+
+ ' Convert the UTC offset which is in seconds to hours and minutes
+ Mins = tmp_ht.utc_offs / 60 ' now we have total minutes
+ hours = Mins / 60 ' determine the number of hours
+ Mins = Mins - hours * 60 ' determine remaining minutes
+
+ PcpsHrTimeToLocalTimeString = PcpsTimeStampToString(tmp_ht.tstamp) _
+ + " UTC" + c + Format(hours, "0#") _
+ + ":" + Format(Mins, "0#") + "h"
+
+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.
+
+Private Sub UpdateCommandButton_Click()
+
+ Dim n As Integer ' number of devices found
+ Dim h As Long ' device handle
+ Dim rc As Long ' return code from API functions
+ Dim currTime As PCPS_TIME
+ Dim f As Long ' flag
+
+ ' Find how how many devices are installed
+ n = mbg_find_devices
+
+ If n = 0 Then
+ Me.InfoTextBox.Text = "No device found."
+ Exit Sub
+ End If
+
+
+ ' Always use first device (index 0), even if more devices
+ ' have been found
+ h = mbg_open_device(0)
+
+ If h = -1 Then ' -1 means INVALID_HANDLE_VALUE (Win API)
+ Me.InfoTextBox.Text = "Unable to open device."
+ Exit Sub
+ End If
+
+
+ ' Read the current time and status
+ rc = mbg_get_time(h, currTime)
+
+ If rc <> 0 Then
+ Me.InfoTextBox.Text = "Error accessing the device."
+ GoTo done
+ End If
+
+ If currTime.year < 90 Then
+ LongYear = currTime.year + 2000
+ Else
+ LongYear = currTime.year + 1900
+ End If
+
+ Me.InfoTextBox.Text = "Current local time" + " (" _
+ + MbgSyncStatusStr(CInt(currTime.status)) + "):" + Chr(13) + Chr(10)
+
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text _
+ + PcpsTimeToString(currTime) + Chr(13) + Chr(10)
+
+
+ ' If the device supports HR time, also read the HR time
+ rc = mbg_dev_has_hr_time(h, f)
+
+ If rc = PCPS_SUCCESS Then
+ ' could check successfully
+ If f <> 0 Then
+ ' device supports HR time
+ Dim ht As PCPS_HR_TIME
+
+ rc = mbg_get_hr_time(h, ht)
+
+ If rc = PCPS_SUCCESS Then
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text _
+ + Chr(13) + Chr(10) _
+ + "HR time " + " (" _
+ + MbgSyncStatusStr(ht.status) + "):" + Chr(13) + Chr(10) _
+ + PcpsHrTimeToUtcTimeString(ht) + Chr(13) + Chr(10) _
+ + PcpsHrTimeToLocalTimeString(ht) + Chr(13) + Chr(10) _
+ + "Raw: " + PcpsTimeStampToHexString(ht.tstamp)
+ Else
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + "Error reading HR time."
+ End If
+ Else
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + "Device does not support HR time."
+ End If
+ Else
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + "Error checking if device supports HR time."
+ End If
+
+ 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)
+
+ If rc = PCPS_SUCCESS Then
+ ' could check successfully
+ If f <> 0 Then
+ ' device supports user captures
+ Dim ucap_entries As PCPS_UCAP_ENTRIES
+ Dim ucap As PCPS_HR_TIME
+
+ rc = mbg_get_ucap_entries(h, ucap_entries)
+
+ If rc = PCPS_SUCCESS Then
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + "Ucap Entries: " _
+ + Format(ucap_entries.used, "0") + "/" _
+ + Format(ucap_entries.max, "0") + " used" + Chr(13) + Chr(10)
+ Else
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + "Error reading ucap entries."
+ End If
+
+ ' Though it's only useful to read a capture event if ucap_entries.used
+ ' is not 0, we do it anyway. If there's no entry in the user capture
+ ' buffer then the returned time stamp will be 0.
+ rc = mbg_get_ucap_event(h, ucap)
+
+ If rc = PCPS_SUCCESS Then
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text _
+ + "Ucap read: Raw: " + PcpsTimeStampToHexString(ucap.tstamp) + Chr(13) + Chr(10)
+
+ If ucap.tstamp.sec = 0 And ucap.tstamp.frac = 0 Then
+ ' No capture event has been available in the buffer
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text _
+ + "(No ucap event available)"
+ Else
+ ' Print the user capture input channel number and the time stamp.
+ ' Any of the PcpsHrTime.. or PcpsTimeStamp.. functions could be
+ ' used here to print the time stamp.
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text _
+ + "Ch" + Format(ucap.signal) + ": " _
+ + PcpsHrTimeToLocalTimeString(ucap)
+
+ ' Check the ucap event status to see if an overrun has occurred
+ ' (i.e. the interval between 2 events has been too short)
+ If ucap.status And PCPS_UCAP_OVERRUN Then
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text _
+ + " << OVR"
+ End If
+
+ ' Check the ucap event status to see if a buffer overflow has
+ ' occurred (i.e. more events have occurred than could be stored
+ ' in the FIF buffer)
+ If ucap.status And PCPS_UCAP_BUFFER_FULL Then
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text _
+ + " << FULL"
+ End If
+
+ End If
+ Else
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + "Error reading ucap entries."
+ End If
+ Else
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + "Device does not support user captures."
+ End If
+ Else
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + "Error checking if device supports user captures."
+ End If
+
+ Me.InfoTextBox.Text = Me.InfoTextBox.Text + Chr(13) + Chr(10)
+
+
+done:
+ mbg_close_device (h)
+
+End Sub
+
diff --git a/vb6/demo/mbgdevio/mbgdevio-demo-vb6.vbp b/vb6/demo/mbgdevio/mbgdevio-demo-vb6.vbp
new file mode 100644
index 0000000..7fbd0b2
--- /dev/null
+++ b/vb6/demo/mbgdevio/mbgdevio-demo-vb6.vbp
@@ -0,0 +1,38 @@
+Type=Exe
+Form=mbgdevio-demo-vb6.frm
+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"
+HelpFile=""
+Title="Project1"
+ExeName32="mbgdevio-demo-vb6.exe"
+Command32=""
+Name="mbgdevio_demo"
+HelpContextID="0"
+CompatibleMode="0"
+MajorVer=1
+MinorVer=0
+RevisionVer=0
+AutoIncrementVer=0
+ServerSupportFiles=0
+VersionCompanyName="Meinberg"
+CompilationType=0
+OptimizationType=0
+FavorPentiumPro(tm)=0
+CodeViewDebugInfo=0
+NoAliasing=0
+BoundsCheck=0
+OverflowCheck=0
+FlPointCheck=0
+FDIVCheck=0
+UnroundedFP=0
+StartMode=0
+Unattended=0
+Retained=0
+ThreadPerObject=0
+MaxNumberOfThreads=1
+DebugStartupOption=0
+
+[MS Transaction Server]
+AutoRefresh=1
diff --git a/vb6/mbglib/mbgdevio-vb6.bas b/vb6/mbglib/mbgdevio-vb6.bas
new file mode 100644
index 0000000..24716c3
--- /dev/null
+++ b/vb6/mbglib/mbgdevio-vb6.bas
@@ -0,0 +1,303 @@
+Attribute VB_Name = "mbgdevio"
+
+'**************************************************************************
+'
+' $Id: mbgdevio-vb6.bas 1.4 2006/11/28 10:33:24Z martin REL_M $
+'
+' Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+'
+' Description:
+' Types and function declarations used to access Meinberg radio clock
+' devices using the mbgdevio DLL from Visual Basic.
+'
+' This module is for Visual Basic 6 which provides only limited support
+' for complex data types.
+'
+' 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
+' with VB.NET.
+' Revision 1.2 2004/02/25 11:14:47Z martin
+' Added definitions of the PCPS_TIME status bits.
+' Revision 1.1 2004/02/23 11:19:45Z martin
+' Initial revision
+'
+'**************************************************************************
+
+
+'
+' Some declarations used by the Meinberg mbgdevio DLL API
+' -------------------------------------------------------
+'
+
+' The structure below is passed to the function mbg_get_time
+' to read date, time, and status
+
+Public Type PCPS_TIME
+ sec100 As Byte ' 0..99
+ sec As Byte ' 0..59, 60 if leap second
+ min As Byte ' 0..59
+ hour As Byte ' 0..23
+ mday As Byte ' 1..31
+ wday As Byte ' 1..7, 1 = Monday
+ month As Byte ' 1..12
+ year As Byte ' 0..99 (year modulo 100)
+ status As Byte ' flag bits, see below
+ signal As Byte ' 0..255
+ offs_utc As Byte ' [h] signed!! (UTC = t - offs_utc)
+End Type
+
+
+' The structure below has been introduced to be able to handle
+' high resolution time stamps.
+
+Public Type PCPS_TIME_STAMP
+ sec As Long ' UInt32, seconds since 1970 (UTC)
+ frac As Long ' UInt32, fractions of second ( &HFFFFFFFF == 0.9999.. sec)
+End Type
+
+
+' The structure below holds a HR time stamp, plus UTC offset and status info
+
+Public Type PCPS_HR_TIME
+ tstamp As PCPS_TIME_STAMP
+ utc_offs As Long ' [sec] signed!! (local time = tstamp + offs_utc)
+ status As Integer ' flag bits, see below
+ signal As Byte ' 0..255
+End Type
+
+
+
+' The structure below holds a HR time plus an associated Windows
+' performance counter value which can be used to relate performance
+' counter values to the current time. Please note that an application
+' must also determine the Windows performance counter frequency in order
+' to convert differences of performance counter values to time intervals.
+
+Public Type LongLong
+ lo As Long
+ hi As Long
+End Type
+
+Public Type PCPS_HR_TIME_CYCLES
+ cycles As LongLong ' UInt64, performance counter value
+ t As PCPS_HR_TIME ' associated HR time
+End Type
+
+
+' The structure below contains the maximum number of entries of an on-board
+' user capture FIFO buffer plus the number of currently used entries.
+
+Public Type PCPS_UCAP_ENTRIES
+ used As Long ' the number of saved capture events
+ max As Long ' capture buffer size
+End Type
+
+
+' Bit masks used with both the status fields of the PCPS_TIME structure
+' and the PCPS_HR_TIME structure:
+
+Public Const PCPS_FREER = &H1 ' DCF77 clock running on xtal
+ ' GPS receiver has not verified its position
+
+Public Const PCPS_DL_ENB = &H2 ' daylight saving enabled
+
+Public Const PCPS_SYNCD = &H4 ' clock has sync'ed at least once after pwr up
+
+Public Const PCPS_DL_ANN = &H8 ' a change in daylight saving is announced
+
+Public Const PCPS_UTC = &H10 ' a special UTC firmware is installed
+
+Public Const PCPS_LS_ANN = &H20 ' leap second is announced
+
+Public Const PCPS_IFTM = &H40 ' the current time was set via PC interface
+
+Public Const PCPS_INVT = &H80 ' invalid time because battery was disconnected
+
+
+' Bit masks used with the status fields of the PCPS_HR_TIME structure only:
+
+Public Const PCPS_LS_ENB = &H100 ' current second is leap second
+Public Const PCPS_ANT_FAIL = &H200 ' antenna failure
+
+
+' The next two status bits are used only if the PCPS_HR_TIME structure
+' PCPS_HR_TIME contains a user capture event:
+
+Public Const PCPS_UCAP_OVERRUN = &H2000 ' events interval too short
+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
+' --------------------------------------------------
+'
+
+' GENERAL NOTE:
+' Not all API calls described below are supported by any Meinberg
+' plug-in card. Calls to functions which are not supported by a device
+' don't do any harm, they just return an error code to the application.
+' However, every API call to an unsupported function results in a log entry
+' in the Windows application event log, so an application should first check
+' 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.
+Public Declare Function mbg_find_devices Lib "mbgdevio" () As Long
+
+' Open the device with given index and retrieve a handle to the device
+' E.g. if n devices have been found, valid indices are 0..n-1
+Public Declare Function mbg_open_device Lib "mbgdevio" (ByVal i As Long) As Long
+
+' Close the device and release the device handle.
+' The device handle value will be set to 0.
+Public Declare Function mbg_close_device Lib "mbgdevio" (ByRef h As Long) As Long
+
+
+'--------------------------------------------------------------------------------
+' Read date, time, and status from the device referenced by handle h.
+' This function is supported by all Meinberg plug-in boards and returns
+' date and time in human readable format (calendar date and time).
+' However, the resolution of time is limited to 10 milliseconds.
+Public Declare Function mbg_get_time Lib "mbgdevio" (ByVal h As Long, ByRef t As PCPS_TIME) As Long
+
+
+'--------------------------------------------------------------------------------
+' The functions below read high resolution time plus status from the device
+' referenced by handle h.
+' These functions are NOT supported by all Meinberg plug-in boards, and the
+' effective resolution of the HR time depends on the characteristics of the
+' specific device.
+
+' Check whether the device referenced by handle h supports HR time.
+' If it does then the value returned for f is not 0.
+Public Declare Function mbg_dev_has_hr_time Lib "mbgdevio" (ByVal h As Long, ByRef f As Long) As Long
+
+' Read a HR time stamp from the board. The returned time stamp may be biased
+' by a latency due to the IOCTL call performed by the function.
+Public Declare Function mbg_get_hr_time Lib "mbgdevio" (ByVal h As Long, ByRef t As PCPS_HR_TIME) As Long
+
+' Read a HR time stamp from the board plus a performance counter value
+' associated to that time stamp. The performance counter value can be used
+' by the application to compensate the latency mentioned above.
+Public Declare Function mbg_get_hr_time_cycles Lib "mbgdevio" (ByVal h As Long, ByRef p As PCPS_HR_TIME_CYCLES) As Long
+
+' Read a HR time stamp from the board and compensate the latency. Return the compensated
+' time stamp, and optionally also return the latency value in 100 nanosecond units.
+' If the application does not need the latency value then a null pointer may be passed
+' for parameter l.
+Public Declare Function mbg_get_hr_time_comp Lib "mbgdevio" (ByVal h As Long, ByRef t As PCPS_HR_TIME, ByRef l As Long) As Long
+
+
+'--------------------------------------------------------------------------------
+' The functions below can be used with the capture buffer available on some cards.
+' These functions are NOT supported by all Meinberg plug-in boards, and the
+' effective accuracy of the time capture events depends on the characteristics
+' of the specific device.
+
+' Check whether the device referenced by handle h provides support for
+' user capture events.
+' If it does then the value returned for f is not 0.
+Public Declare Function mbg_dev_has_ucap Lib "mbgdevio" (ByVal h As Long, ByRef f As Long) As Long
+
+' Clear the on-board user capture FIFO buffer
+Public Declare Function mbg_clr_ucap_buff Lib "mbgdevio" (ByVal h As Long) As Long
+
+' Retrieve the maximum number of events that can be stored in the on-board
+' FIFO buffer, and the number of events currently saved in the buffer.
+Public Declare Function mbg_get_ucap_entries Lib "mbgdevio" (ByVal h As Long, ByRef p As PCPS_UCAP_ENTRIES) As Long
+
+' Retrieve an entry from the on-board user capture FIFO buffer. The returned entry
+' is removed from the buffer. If no event is available in the buffer, i.e. the buffer
+' is empty, then then both the seconds and fractions of the returned time stamp are 0.
+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
+