summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2004-02-20 12:00:00 +0100
committerMartin Burnicki <martin.burnicki@meinberg.de>2004-02-20 12:00:00 +0100
commitbea274e5bd37e568bbe524938aafeebde5123f6d (patch)
tree94a3b243d2c0d86e215a918e79553c1a30af04a5
parent611ca73165bbb0585f0be45d74b17d1805fab5f2 (diff)
downloadmbgsdk-win-bea274e5bd37e568bbe524938aafeebde5123f6d.tar.gz
mbgsdk-win-bea274e5bd37e568bbe524938aafeebde5123f6d.zip
Initial revision of mbgdemo for Visual Basic 6 (VB6)mbgdemo-vb6-1.1
-rw-r--r--Demo.frm176
-rw-r--r--demo.bas1
-rw-r--r--demo.exebin0 -> 20480 bytes
-rw-r--r--demo.vbp37
-rw-r--r--demo.vbw1
5 files changed, 215 insertions, 0 deletions
diff --git a/Demo.frm b/Demo.frm
new file mode 100644
index 0000000..15c2b52
--- /dev/null
+++ b/Demo.frm
@@ -0,0 +1,176 @@
+VERSION 5.00
+Begin VB.Form Demo
+ Caption = "Check Radio Clock Sync Status"
+ ClientHeight = 1680
+ ClientLeft = 60
+ ClientTop = 345
+ ClientWidth = 4680
+ LinkTopic = "Form1"
+ ScaleHeight = 1680
+ ScaleWidth = 4680
+ StartUpPosition = 3 'Windows Default
+ Begin VB.CommandButton Command1
+ Caption = "Update"
+ Height = 495
+ Left = 1320
+ TabIndex = 1
+ Top = 960
+ Width = 1935
+ End
+ Begin VB.TextBox Text1
+ Height = 495
+ Left = 240
+ TabIndex = 0
+ Text = "Press ""Update"" to check."
+ Top = 240
+ Width = 4215
+ End
+End
+Attribute VB_Name = "Demo"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = False
+Attribute VB_PredeclaredId = True
+Attribute VB_Exposed = False
+'
+' This is a very simple demo program for Microsoft Visual Basic 6 which shows
+' how to access Meinberg radio clock devices via the API calls exported by
+' Meinberg's mbgdevio DLL.
+'
+' If there are any questions or enhancemetnt requests, please contact Meinberg:
+' Email: martin.burnicki@meinberg.de
+' Phone: +49 (0) 5281 9309 0
+'
+
+
+'
+' Some declarations used by the Meinberg mbgdevio DLL API
+' -------------------------------------------------------
+'
+
+' The structure which is normally used to read date, time, and status
+Private Type Pcps_time
+ sec100 As Byte
+ sec As Byte
+ min As Byte
+ hour As Byte
+ mday As Byte
+ wday As Byte
+ month As Byte
+ year As Byte
+ status As Byte
+ signal As Byte
+ offs_utc As Byte
+End Type
+
+
+
+'
+' Some of the functions exported by the mbgdevio DLL
+' --------------------------------------------------
+'
+
+
+' Return the number of radio clock devices detected
+' If this function returns 0, then no devices has been detected.
+Private 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
+Private 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.
+Private 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.
+Private Declare Function mbg_get_time Lib "mbgdevio" (ByVal h As Long, ByRef t As Pcps_time) As Long
+
+
+
+' The function below tries to read the status of a device.
+' If returned value is negative then an error has occurred.
+' If the return value is not negative then the 8 LSBs of
+' the return value contain the bit coded status.
+Private Function mbg_get_device_status() As Long
+
+ Dim h As Long
+ Dim rc As Long
+ Dim currTime As Pcps_time
+ Dim n As Integer
+
+ n = mbg_find_devices
+
+ If n = 0 Then
+ mbg_get_device_status = -1 ' No device found.
+ Exit Function
+ End If
+
+
+ ' Always 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)
+ mbg_get_device_status = -2 ' Unable to open device
+ Exit Function
+ End If
+
+
+ rc = mbg_get_time(h, currTime)
+
+ mbg_close_device (h)
+
+ If rc <> 0 Then
+ mbg_get_device_status = -3 ' Error accessing the device
+ Exit Function
+ End If
+
+
+ mbg_get_device_status = currTime.status ' Return the valid status
+
+End Function ' mbg_get_device_status
+
+
+
+' The function below tries to read the status of a device
+' and check if the status is 'synchronized'
+' If the return value is negative then an error has occurred.
+' If the clock is synchronized then the return value is 1,
+' otherwise the function returns 0.
+Private Function mbg_device_is_synchronized() As Long
+
+ Dim status As Long
+
+ status = mbg_get_device_status
+
+ If status < 0 Then
+ mbg_device_is_synchronized = status ' Sync status could not be retrieved
+ Exit Function
+ End If
+
+
+ If status And &O1 Then ' If PCPS_FREER bit is set
+ mbg_device_is_synchronized = 0 ' then the device is not synchronized
+ Else
+ mbg_device_is_synchronized = 1 ' otherwise it is synchronized
+ End If
+
+End Function ' mbg_device_is_synchronized
+
+
+
+Private Sub Command1_Click()
+ Dim isSynchronized As Long
+
+ isSynchronized = mbg_device_is_synchronized
+
+ If isSynchronized < 0 Then
+ Me.Text1.Text = "Sync Status could not be read."
+ Else
+ If isSynchronized > 0 Then
+ Me.Text1.Text = "Device is synchronized."
+ Else
+ Me.Text1.Text = "Device is NOT synchronized."
+ End If
+ End If
+
+End Sub
diff --git a/demo.bas b/demo.bas
new file mode 100644
index 0000000..1cd2b2c
--- /dev/null
+++ b/demo.bas
@@ -0,0 +1 @@
+Attribute VB_Name = "Module1"
diff --git a/demo.exe b/demo.exe
new file mode 100644
index 0000000..9c8b687
--- /dev/null
+++ b/demo.exe
Binary files differ
diff --git a/demo.vbp b/demo.vbp
new file mode 100644
index 0000000..f56a058
--- /dev/null
+++ b/demo.vbp
@@ -0,0 +1,37 @@
+Type=Exe
+Form=Demo.frm
+Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\WINNT\System32\stdole2.tlb#OLE Automation
+IconForm="Demo"
+Startup="Demo"
+HelpFile=""
+Title="Project1"
+ExeName32="demo.exe"
+Command32=""
+Name="Project1"
+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/demo.vbw b/demo.vbw
new file mode 100644
index 0000000..d82ae3a
--- /dev/null
+++ b/demo.vbw
@@ -0,0 +1 @@
+Demo = 138, 128, 769, 642, Z, 22, 22, 653, 536, C