diff options
author | Martin Burnicki <martin.burnicki@meinberg.de> | 2009-01-22 12:06:00 +0100 |
---|---|---|
committer | Martin Burnicki <martin.burnicki@meinberg.de> | 2009-01-22 12:06:00 +0100 |
commit | 61b7b71fb04ce99a281ed7befd877cdc919c8430 (patch) | |
tree | 429e2704baa6643a8ebfce5420de32b5fbf8a56a | |
parent | 142534d6df609d147d7561cc5f9e10c5a3a88172 (diff) | |
download | mbgsdk-win-61b7b71fb04ce99a281ed7befd877cdc919c8430.tar.gz mbgsdk-win-61b7b71fb04ce99a281ed7befd877cdc919c8430.zip |
Add example programs for VB.NET
Definitions for VB.NET are not compatible with those for VB6,
so the VB6 code has been ported to VB.NET.
-rw-r--r-- | vb.net/demo/mbgdevio/assemblyinfo.vb | 33 | ||||
-rw-r--r-- | vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.designer.vb | 91 | ||||
-rw-r--r-- | vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.sln | 20 | ||||
-rw-r--r-- | vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.vb | 429 | ||||
-rw-r--r-- | vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.vbproj | 101 | ||||
-rw-r--r-- | vb.net/demo/mbgsvcio/assemblyinfo.vb | 33 | ||||
-rw-r--r-- | vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.designer.vb | 181 | ||||
-rw-r--r-- | vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.sln | 20 | ||||
-rw-r--r-- | vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.vb | 100 | ||||
-rw-r--r-- | vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.vbproj | 100 | ||||
-rw-r--r-- | vb.net/mbglib/mbgdefs-vb.net.vb | 78 | ||||
-rw-r--r-- | vb.net/mbglib/mbgdevio-vb.net.vb | 246 | ||||
-rw-r--r-- | vb.net/mbglib/mbgsvcio-vb.net.vb | 68 |
13 files changed, 1500 insertions, 0 deletions
diff --git a/vb.net/demo/mbgdevio/assemblyinfo.vb b/vb.net/demo/mbgdevio/assemblyinfo.vb new file mode 100644 index 0000000..5f6a71a --- /dev/null +++ b/vb.net/demo/mbgdevio/assemblyinfo.vb @@ -0,0 +1,33 @@ +Imports System.Reflection +Imports System.Runtime.CompilerServices +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + + +' TODO: Review the values of the assembly attributes + + +<Assembly: AssemblyTitle("")> +<Assembly: AssemblyDescription("")> +<Assembly: AssemblyCompany("Meinberg")> +<Assembly: AssemblyProduct("")> +<Assembly: AssemblyCopyright("")> +<Assembly: AssemblyTrademark("")> +<Assembly: AssemblyCulture("")> + +' Version information for an assembly consists of the following four values: + +' Major version +' Minor Version +' Build Number +' Revision + +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + +<Assembly: AssemblyVersion("1.0.*")> + + diff --git a/vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.designer.vb b/vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.designer.vb new file mode 100644 index 0000000..115e036 --- /dev/null +++ b/vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.designer.vb @@ -0,0 +1,91 @@ +<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> Partial Class mbgdevio_demo_vb_net +#Region "Windows Form Designer generated code " + <System.Diagnostics.DebuggerNonUserCode()> Public Sub New() + MyBase.New() + 'This call is required by the Windows Form Designer. + InitializeComponent() + End Sub + 'Form overrides dispose to clean up the component list. + <System.Diagnostics.DebuggerNonUserCode()> Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean) + If Disposing Then + If Not components Is Nothing Then + components.Dispose() + End If + End If + MyBase.Dispose(Disposing) + End Sub + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + Public ToolTip1 As System.Windows.Forms.ToolTip + Public WithEvents UpdateCommandButton As System.Windows.Forms.Button + Public WithEvents InfoTextBox As System.Windows.Forms.TextBox + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() + Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(mbgdevio_demo_vb_net)) + Me.components = New System.ComponentModel.Container() + Me.ToolTip1 = New System.Windows.Forms.ToolTip(components) + Me.UpdateCommandButton = New System.Windows.Forms.Button + Me.InfoTextBox = New System.Windows.Forms.TextBox + Me.SuspendLayout() + Me.ToolTip1.Active = True + Me.Text = "Check Radio Clock Sync Status" + Me.ClientSize = New System.Drawing.Size(433, 308) + Me.Location = New System.Drawing.Point(4, 23) + Me.StartPosition = System.Windows.Forms.FormStartPosition.WindowsDefaultLocation + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.SystemColors.Control + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable + Me.ControlBox = True + Me.Enabled = True + Me.KeyPreview = False + Me.MaximizeBox = True + Me.MinimizeBox = True + Me.Cursor = System.Windows.Forms.Cursors.Default + Me.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.ShowInTaskbar = True + Me.HelpButton = False + Me.WindowState = System.Windows.Forms.FormWindowState.Normal + Me.Name = "mbgdevio_demo_vb6" + Me.UpdateCommandButton.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.UpdateCommandButton.Text = "Update" + Me.UpdateCommandButton.Size = New System.Drawing.Size(129, 33) + Me.UpdateCommandButton.Location = New System.Drawing.Point(152, 264) + Me.UpdateCommandButton.TabIndex = 1 + Me.UpdateCommandButton.BackColor = System.Drawing.SystemColors.Control + Me.UpdateCommandButton.CausesValidation = True + Me.UpdateCommandButton.Enabled = True + Me.UpdateCommandButton.ForeColor = System.Drawing.SystemColors.ControlText + Me.UpdateCommandButton.Cursor = System.Windows.Forms.Cursors.Default + Me.UpdateCommandButton.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.UpdateCommandButton.TabStop = True + Me.UpdateCommandButton.Name = "UpdateCommandButton" + Me.InfoTextBox.AutoSize = False + Me.InfoTextBox.Size = New System.Drawing.Size(401, 233) + Me.InfoTextBox.Location = New System.Drawing.Point(16, 16) + Me.InfoTextBox.MultiLine = True + Me.InfoTextBox.TabIndex = 0 + Me.InfoTextBox.AcceptsReturn = True + Me.InfoTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Left + Me.InfoTextBox.BackColor = System.Drawing.SystemColors.Window + Me.InfoTextBox.CausesValidation = True + Me.InfoTextBox.Enabled = True + Me.InfoTextBox.ForeColor = System.Drawing.SystemColors.WindowText + Me.InfoTextBox.HideSelection = True + Me.InfoTextBox.ReadOnly = False + Me.InfoTextBox.Maxlength = 0 + Me.InfoTextBox.Cursor = System.Windows.Forms.Cursors.IBeam + Me.InfoTextBox.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.InfoTextBox.ScrollBars = System.Windows.Forms.ScrollBars.None + Me.InfoTextBox.TabStop = True + Me.InfoTextBox.Visible = True + Me.InfoTextBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D + Me.InfoTextBox.Name = "InfoTextBox" + Me.Controls.Add(UpdateCommandButton) + Me.Controls.Add(InfoTextBox) + Me.ResumeLayout(False) + Me.PerformLayout() + End Sub +#End Region +End Class
\ No newline at end of file diff --git a/vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.sln b/vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.sln new file mode 100644 index 0000000..f0e0481 --- /dev/null +++ b/vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "mbgdevio-demo-vb.net", "mbgdevio-demo-vb.net.vbproj", "{BB995D00-9BBC-4C80-8200-78E383C77C51}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BB995D00-9BBC-4C80-8200-78E383C77C51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB995D00-9BBC-4C80-8200-78E383C77C51}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB995D00-9BBC-4C80-8200-78E383C77C51}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB995D00-9BBC-4C80-8200-78E383C77C51}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.vb b/vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.vb new file mode 100644 index 0000000..59acd29 --- /dev/null +++ b/vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.vb @@ -0,0 +1,429 @@ +Option Strict Off +Option Explicit On +Friend Class mbgdevio_demo_vb_net + Inherits System.Windows.Forms.Form + + '************************************************************************** + ' + ' $Id: mbgdevio-demo-vb.net.vb 1.1 2008/05/23 11:04:54Z 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 Meinberg driver software package v2.12 or newer for Windows + ' must be installed because this application requires a DLL that is + ' provided by the driver package. + ' + ' This module for VB.NET may contain some declarations which are not + ' supported by VB6, so for VB6 there's a specific module available. + ' + ' The modules mbgdevio and mbgdefs must be added to applications. + ' By default, those modules are located in the Meinberg library + ' subdirectory "..\mbglib\". Meinberg library modules should be + ' used and left unchanged in order to simplify upgrades when + ' newer versions are released. + ' + ' If there are any questions or enhancement requests, please contact + ' Meinberg: support@meinberg.de + ' + ' ----------------------------------------------------------------------- + ' $Log: mbgdevio-demo-vb.net.vb $ + ' Revision 1.1 2008/05/23 11:04:54Z martin + ' Initial revision for VB.NET 2005, based on v1.4 for VB6. + ' + '************************************************************************** + + + ' The function below takes a device status value and + ' returns a string which indicates whether the device + ' is synchronized, or not. + + Private Function MbgSyncStatusStr(ByRef status As Short) 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 c As Char + + Dim LongYear As Short + Dim offs_utc As Short + + ' 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 = VB6.Format(LongYear, "000#") & "-" _ + & VB6.Format(t.month, "0#") & "-" _ + & VB6.Format(t.mday, "0#") & " " _ + & VB6.Format(t.hour, "0#") & ":" _ + & VB6.Format(t.min, "0#") & ":" _ + & VB6.Format(t.sec, "0#") & "." _ + & VB6.Format(t.sec100, "0#") _ + & " UTC" & c _ + & VB6.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 = VB6.Format(Hex(t.sec), "00000000") & "." _ + & VB6.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.0# + Const EpocheOffs1970 As Double = 25569.0# + Const frac_scale As Double = 4294967296.0# ' &H100000000 + Dim dt As Date + Dim frac As Double + + ' Convert seconds since 1970 to the VB date format + dt = System.Date.FromOADate(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.0# + + PcpsTimeStampToString = VB6.Format(dt, "yyyy-mm-dd hh:MM:ss") & "." _ + & VB6.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 Short + Dim Mins As Short + 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 & VB6.Format(hours, "0#") & ":" & VB6.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: " & VB6.Format(lla.lat * r2d, "0.0000") & " deg, " & "Lon: " & VB6.Format(lla.lon * r2d, "0.0000") & " deg, " & "Alt: " & VB6.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) & " " _ + & VB6.Format(dms.deg, "0") & ":" _ + & VB6.Format(dms.min, "00") & ":" _ + & VB6.Format(dms.sec, "00.00") + + 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) & ", " _ + & VB6.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(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles UpdateCommandButton.Click + + Dim LongYear As Integer + Dim n As Short ' number of devices found + Dim h As Integer ' device handle + Dim rc As Integer ' return code from API functions + Dim currTime As PCPS_TIME + Dim f As Integer ' flag + + ' Find out 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(CShort(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) + + Dim ht As PCPS_HR_TIME + If rc = PCPS_SUCCESS Then + ' could check successfully + If f <> 0 Then + ' device supports 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) + + Dim pos As MBG_RCVR_POS + If rc = PCPS_SUCCESS Then + ' could check successfully + If f <> 0 Then + ' device is a GPS receiver + + 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) + + Dim ucap_entries As PCPS_UCAP_ENTRIES + Dim ucap As PCPS_HR_TIME + If rc = PCPS_SUCCESS Then + ' could check successfully + If f <> 0 Then + ' device supports user captures + + rc = mbg_get_ucap_entries(h, ucap_entries) + + If rc = PCPS_SUCCESS Then + Me.InfoTextBox.Text = Me.InfoTextBox.Text _ + & "Ucap Entries: " & VB6.Format(ucap_entries.used, "0") _ + & "/" & VB6.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" & VB6.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 +End Class diff --git a/vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.vbproj b/vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.vbproj new file mode 100644 index 0000000..bf8932e --- /dev/null +++ b/vb.net/demo/mbgdevio/mbgdevio-demo-vb.net.vbproj @@ -0,0 +1,101 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <ProjectType>Local</ProjectType> + <MyType>WindowsForms</MyType> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{BB995D00-9BBC-4C80-8200-78E383C77C51}</ProjectGuid> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>mbgdevio_demo</AssemblyName> + <OutputType>WinExe</OutputType> + <StartupObject>mbgdevio_demo.mbgdevio_demo_vb_net</StartupObject> + <AssemblyMajorVersion>1</AssemblyMajorVersion> + <AssemblyMinorVersion>0</AssemblyMinorVersion> + <AssemblyRevisionNumber>0</AssemblyRevisionNumber> + <GenerateRevisionNumber>False</GenerateRevisionNumber> + <AssemblyCompanyName>Meinberg</AssemblyCompanyName> + <StartWithIE>False</StartWithIE> + <RootNamespace>mbgdevio_demo</RootNamespace> + <FileUpgradeFlags> + </FileUpgradeFlags> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <OutputPath>.\bin\</OutputPath> + <DocumentationFile>mbgdevio_demo.xml</DocumentationFile> + <DebugSymbols>True</DebugSymbols> + <DefineDebug>True</DefineDebug> + <DefineTrace>True</DefineTrace> + <DefineConstants>Win32=True</DefineConstants> + <PlatformTarget>x86</PlatformTarget> + <NoWarn>42016,42017,42018,42019,42032</NoWarn> + <DebugType>full</DebugType> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <OutputPath>.\bin\</OutputPath> + <DocumentationFile>mbgdevio_demo.xml</DocumentationFile> + <DebugSymbols>False</DebugSymbols> + <DefineDebug>False</DefineDebug> + <DefineTrace>True</DefineTrace> + <DefineConstants>Win32=True</DefineConstants> + <PlatformTarget>x86</PlatformTarget> + <NoWarn>42016,42017,42018,42019,42032</NoWarn> + <DebugType>none</DebugType> + </PropertyGroup> + <ItemGroup> + <Reference Include="Microsoft.VisualBasic.Compatibility"> + <Name>Microsoft.VisualBasic.Compatibility</Name> + </Reference> + <Reference Include="System"> + <Name>System</Name> + </Reference> + <Reference Include="System.Data"> + <Name>System.Data</Name> + </Reference> + <Reference Include="System.Drawing"> + <Name>System.Drawing</Name> + </Reference> + <Reference Include="System.Windows.Forms"> + <Name>System.Windows.Forms</Name> + </Reference> + <Reference Include="System.XML"> + <Name>System.XML</Name> + </Reference> + </ItemGroup> + <ItemGroup> + <Import Include="Microsoft.VisualBasic" /> + <Import Include="Microsoft.VisualBasic.Compatibility" /> + <Import Include="System" /> + <Import Include="System.Collections" /> + <Import Include="System.Data" /> + <Import Include="System.Diagnostics" /> + <Import Include="System.Drawing" /> + <Import Include="System.Windows.Forms" /> + </ItemGroup> + <ItemGroup> + <Compile Include="..\..\mbglib\mbgdefs-vb.net.vb"> + <Link>mbgdefs-vb.net.vb</Link> + </Compile> + <Compile Include="..\..\mbglib\mbgdevio-vb.net.vb"> + <Link>mbgdevio-vb.net.vb</Link> + </Compile> + <Compile Include="AssemblyInfo.vb" /> + <Compile Include="mbgdevio-demo-vb.net.Designer.vb"> + <SubType>Code</SubType> + <DependentUpon>mbgdevio-demo-vb.net.vb</DependentUpon> + </Compile> + <Compile Include="mbgdevio-demo-vb.net.vb"> + <SubType>Form</SubType> + </Compile> + </ItemGroup> + <ItemGroup> + <Folder Include="My Project\" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" /> + <PropertyGroup> + <PreBuildEvent> + </PreBuildEvent> + <PostBuildEvent> + </PostBuildEvent> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/vb.net/demo/mbgsvcio/assemblyinfo.vb b/vb.net/demo/mbgsvcio/assemblyinfo.vb new file mode 100644 index 0000000..5f6a71a --- /dev/null +++ b/vb.net/demo/mbgsvcio/assemblyinfo.vb @@ -0,0 +1,33 @@ +Imports System.Reflection +Imports System.Runtime.CompilerServices +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + + +' TODO: Review the values of the assembly attributes + + +<Assembly: AssemblyTitle("")> +<Assembly: AssemblyDescription("")> +<Assembly: AssemblyCompany("Meinberg")> +<Assembly: AssemblyProduct("")> +<Assembly: AssemblyCopyright("")> +<Assembly: AssemblyTrademark("")> +<Assembly: AssemblyCulture("")> + +' Version information for an assembly consists of the following four values: + +' Major version +' Minor Version +' Build Number +' Revision + +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + +<Assembly: AssemblyVersion("1.0.*")> + + diff --git a/vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.designer.vb b/vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.designer.vb new file mode 100644 index 0000000..f7e63e5 --- /dev/null +++ b/vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.designer.vb @@ -0,0 +1,181 @@ +<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> Partial Class mbgsvcio_demo +#Region "Windows Form Designer generated code " + <System.Diagnostics.DebuggerNonUserCode()> Public Sub New() + MyBase.New() + 'This call is required by the Windows Form Designer. + InitializeComponent() + End Sub + 'Form overrides dispose to clean up the component list. + <System.Diagnostics.DebuggerNonUserCode()> Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean) + If Disposing Then + If Not components Is Nothing Then + components.Dispose() + End If + End If + MyBase.Dispose(Disposing) + End Sub + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + Public ToolTip1 As System.Windows.Forms.ToolTip + Public WithEvents ButtonUpdate As System.Windows.Forms.Button + Public WithEvents LabelVal3 As System.Windows.Forms.Label + Public WithEvents LabelVal2 As System.Windows.Forms.Label + Public WithEvents LabelVal1 As System.Windows.Forms.Label + Public WithEvents Label3 As System.Windows.Forms.Label + Public WithEvents Label2 As System.Windows.Forms.Label + Public WithEvents Label1 As System.Windows.Forms.Label + Public WithEvents StatusInfo As System.Windows.Forms.GroupBox + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container + Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) + Me.ButtonUpdate = New System.Windows.Forms.Button + Me.StatusInfo = New System.Windows.Forms.GroupBox + Me.LabelVal3 = New System.Windows.Forms.Label + Me.LabelVal2 = New System.Windows.Forms.Label + Me.LabelVal1 = New System.Windows.Forms.Label + Me.Label3 = New System.Windows.Forms.Label + Me.Label2 = New System.Windows.Forms.Label + Me.Label1 = New System.Windows.Forms.Label + Me.CheckBox1 = New System.Windows.Forms.CheckBox + Me.StatusInfo.SuspendLayout() + Me.SuspendLayout() + ' + 'ButtonUpdate + ' + Me.ButtonUpdate.BackColor = System.Drawing.SystemColors.Control + Me.ButtonUpdate.Cursor = System.Windows.Forms.Cursors.Default + Me.ButtonUpdate.ForeColor = System.Drawing.SystemColors.ControlText + Me.ButtonUpdate.Location = New System.Drawing.Point(296, 160) + Me.ButtonUpdate.Name = "ButtonUpdate" + Me.ButtonUpdate.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.ButtonUpdate.Size = New System.Drawing.Size(81, 25) + Me.ButtonUpdate.TabIndex = 4 + Me.ButtonUpdate.Text = "Update" + Me.ButtonUpdate.UseVisualStyleBackColor = False + ' + 'StatusInfo + ' + Me.StatusInfo.BackColor = System.Drawing.SystemColors.Control + Me.StatusInfo.Controls.Add(Me.CheckBox1) + Me.StatusInfo.Controls.Add(Me.LabelVal3) + Me.StatusInfo.Controls.Add(Me.LabelVal2) + Me.StatusInfo.Controls.Add(Me.LabelVal1) + Me.StatusInfo.Controls.Add(Me.Label3) + Me.StatusInfo.Controls.Add(Me.Label2) + Me.StatusInfo.Controls.Add(Me.Label1) + Me.StatusInfo.ForeColor = System.Drawing.SystemColors.ControlText + Me.StatusInfo.Location = New System.Drawing.Point(8, 8) + Me.StatusInfo.Name = "StatusInfo" + Me.StatusInfo.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.StatusInfo.Size = New System.Drawing.Size(385, 137) + Me.StatusInfo.TabIndex = 0 + Me.StatusInfo.TabStop = False + Me.StatusInfo.Text = "Status Info" + ' + 'LabelVal3 + ' + Me.LabelVal3.BackColor = System.Drawing.SystemColors.Control + Me.LabelVal3.Cursor = System.Windows.Forms.Cursors.Default + Me.LabelVal3.ForeColor = System.Drawing.SystemColors.ControlText + Me.LabelVal3.Location = New System.Drawing.Point(208, 72) + Me.LabelVal3.Name = "LabelVal3" + Me.LabelVal3.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.LabelVal3.Size = New System.Drawing.Size(153, 17) + Me.LabelVal3.TabIndex = 7 + Me.LabelVal3.Text = "N/A" + ' + 'LabelVal2 + ' + Me.LabelVal2.BackColor = System.Drawing.SystemColors.Control + Me.LabelVal2.Cursor = System.Windows.Forms.Cursors.Default + Me.LabelVal2.ForeColor = System.Drawing.SystemColors.ControlText + Me.LabelVal2.Location = New System.Drawing.Point(208, 48) + Me.LabelVal2.Name = "LabelVal2" + Me.LabelVal2.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.LabelVal2.Size = New System.Drawing.Size(153, 17) + Me.LabelVal2.TabIndex = 6 + Me.LabelVal2.Text = "N/A" + ' + 'LabelVal1 + ' + Me.LabelVal1.BackColor = System.Drawing.SystemColors.Control + Me.LabelVal1.Cursor = System.Windows.Forms.Cursors.Default + Me.LabelVal1.ForeColor = System.Drawing.SystemColors.ControlText + Me.LabelVal1.Location = New System.Drawing.Point(208, 24) + Me.LabelVal1.Name = "LabelVal1" + Me.LabelVal1.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.LabelVal1.Size = New System.Drawing.Size(153, 17) + Me.LabelVal1.TabIndex = 5 + Me.LabelVal1.Text = "N/A" + ' + 'Label3 + ' + Me.Label3.BackColor = System.Drawing.SystemColors.Control + Me.Label3.Cursor = System.Windows.Forms.Cursors.Default + Me.Label3.ForeColor = System.Drawing.SystemColors.ControlText + Me.Label3.Location = New System.Drawing.Point(16, 72) + Me.Label3.Name = "Label3" + Me.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.Label3.Size = New System.Drawing.Size(177, 17) + Me.Label3.TabIndex = 3 + Me.Label3.Text = "Ref Time Status:" + ' + 'Label2 + ' + Me.Label2.BackColor = System.Drawing.SystemColors.Control + Me.Label2.Cursor = System.Windows.Forms.Cursors.Default + Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText + Me.Label2.Location = New System.Drawing.Point(16, 48) + Me.Label2.Name = "Label2" + Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.Label2.Size = New System.Drawing.Size(177, 17) + Me.Label2.TabIndex = 2 + Me.Label2.Text = "Ref Time Source Accessible:" + ' + 'Label1 + ' + Me.Label1.BackColor = System.Drawing.SystemColors.Control + Me.Label1.Cursor = System.Windows.Forms.Cursors.Default + Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText + Me.Label1.Location = New System.Drawing.Point(16, 24) + Me.Label1.Name = "Label1" + Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.Label1.Size = New System.Drawing.Size(177, 17) + Me.Label1.TabIndex = 1 + Me.Label1.Text = "Time Adjustment Service Active:" + ' + 'CheckBox1 + ' + Me.CheckBox1.AutoSize = True + Me.CheckBox1.ForeColor = System.Drawing.SystemColors.GrayText + Me.CheckBox1.Location = New System.Drawing.Point(94, 105) + Me.CheckBox1.Name = "CheckBox1" + Me.CheckBox1.Size = New System.Drawing.Size(81, 17) + Me.CheckBox1.TabIndex = 8 + Me.CheckBox1.Text = "CheckBox1" + Me.CheckBox1.UseVisualStyleBackColor = True + ' + 'mbgsvcio_demo + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.SystemColors.Control + Me.ClientSize = New System.Drawing.Size(407, 196) + Me.Controls.Add(Me.ButtonUpdate) + Me.Controls.Add(Me.StatusInfo) + Me.Cursor = System.Windows.Forms.Cursors.Default + Me.Location = New System.Drawing.Point(4, 23) + Me.Name = "mbgsvcio_demo" + Me.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.Text = "Meinberg mbgsvcio Demo for VB.NET" + Me.StatusInfo.ResumeLayout(False) + Me.StatusInfo.PerformLayout() + Me.ResumeLayout(False) + + End Sub + Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox +#End Region +End Class
\ No newline at end of file diff --git a/vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.sln b/vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.sln new file mode 100644 index 0000000..e1b480f --- /dev/null +++ b/vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "mbgsvcio-demo-vb.net", "mbgsvcio-demo-vb.net.vbproj", "{2FA22EDE-7D36-4D6A-BC30-A847AB1CB038}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2FA22EDE-7D36-4D6A-BC30-A847AB1CB038}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2FA22EDE-7D36-4D6A-BC30-A847AB1CB038}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2FA22EDE-7D36-4D6A-BC30-A847AB1CB038}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2FA22EDE-7D36-4D6A-BC30-A847AB1CB038}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.vb b/vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.vb new file mode 100644 index 0000000..eec8a40 --- /dev/null +++ b/vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.vb @@ -0,0 +1,100 @@ +Option Strict Off +Option Explicit On +Friend Class mbgsvcio_demo + Inherits System.Windows.Forms.Form + + '************************************************************************** + ' + ' $Id: mbgsvcio-demo-vb.net.vb 1.1 2008/05/23 11:06:30Z martin REL_M $ + ' + ' Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany + ' + ' Description: + ' Sample Visual Basic code demonstrating how to query the status of + ' the Meinberg time adjustment service and its reference time source. + ' + ' The Meinberg driver software package v2.12 or newer for Windows + ' must be installed because this application requires a DLL that is + ' provided by the driver package. + ' + ' This module for VB.NET may contain some declarations which are not + ' supported by VB6, so for VB6 there's a specific module available. + ' + ' The modules mbgsvcio and mbgdefs must be added to applications. + ' By default, those modules are located in the Meinberg library + ' subdirectory "..\mbglib\". Meinberg library modules should be + ' used and left unchanged in order to simplify upgrades when + ' newer versions are released. + ' + ' If there are any questions or enhancement requests, please contact + ' Meinberg: support@meinberg.de + ' + ' ----------------------------------------------------------------------- + ' $Log: mbgsvcio-demo-vb.net.vb $ + ' Revision 1.1 2008/05/23 11:06:30Z martin + ' Initial revision for VB.NET 2005, based on v1.2 for VB6. + ' + '************************************************************************** + + + Private Sub ButtonUpdate_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles ButtonUpdate.Click + Dim SvcActive As Short + Dim RefAccessible As Short + Dim RefTimeStatus As Short + + ' First check if the time adjustment service is active. + SvcActive = mbg_time_adjustment_active + + If SvcActive <> 0 Then + ' The time adjustment service is in deed active + LabelVal1.Text = "Yes" + LabelVal1.ForeColor = System.Drawing.Color.Green + + ' Now we can check if the ref time source (radio clock) + ' is accessible + RefAccessible = mbg_ref_time_accessible + + If RefAccessible > 0 Then + ' The ref time source is accessible + LabelVal2.Text = "Yes" + LabelVal2.ForeColor = System.Drawing.Color.Green + + ' Now we can query the status of the ref time source + RefTimeStatus = mbg_get_ref_time_status + + ' If PCPS_FREER bit is set then th clock is currently + ' not synchronized + If RefTimeStatus And PCPS_FREER Then + LabelVal3.Text = "NOT synchronized" + LabelVal3.ForeColor = System.Drawing.Color.Red + Else + LabelVal3.Text = "synchronized" + LabelVal3.ForeColor = System.Drawing.Color.Green + End If + Else + ' The ref time source is not accessible + ' Maybe the cable to an external clock is broken + ' or the device is powered off. + LabelVal2.Text = "No" + LabelVal2.ForeColor = System.Drawing.Color.Red + + ' So the status flags are not available + LabelVal3.Text = "N/A" + LabelVal3.ForeColor = System.Drawing.Color.Gray + End If + Else + ' The time adjustment service is not active + LabelVal1.Text = "No" + LabelVal1.ForeColor = System.Drawing.Color.Red + + ' There's no other status information available + LabelVal2.Text = "N/A" + LabelVal2.ForeColor = System.Drawing.Color.Gray + + LabelVal3.Text = "N/A" + LabelVal3.ForeColor = System.Drawing.Color.Gray + End If + + End Sub + +End Class
\ No newline at end of file diff --git a/vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.vbproj b/vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.vbproj new file mode 100644 index 0000000..426a2fb --- /dev/null +++ b/vb.net/demo/mbgsvcio/mbgsvcio-demo-vb.net.vbproj @@ -0,0 +1,100 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <ProjectType>Local</ProjectType> + <MyType>WindowsForms</MyType> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{2FA22EDE-7D36-4D6A-BC30-A847AB1CB038}</ProjectGuid> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>mbgsvcio_demo_vb.net</AssemblyName> + <OutputType>WinExe</OutputType> + <StartupObject>mbgsvcio_demo_vb.net.mbgsvcio_demo</StartupObject> + <AssemblyMajorVersion>1</AssemblyMajorVersion> + <AssemblyMinorVersion>0</AssemblyMinorVersion> + <AssemblyRevisionNumber>0</AssemblyRevisionNumber> + <GenerateRevisionNumber>False</GenerateRevisionNumber> + <AssemblyCompanyName>Meinberg</AssemblyCompanyName> + <RootNamespace>mbgsvcio_demo_vb.net</RootNamespace> + <FileUpgradeFlags> + </FileUpgradeFlags> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <OutputPath>.\bin\</OutputPath> + <DocumentationFile>mbgsvcio_demo_vb.xml</DocumentationFile> + <DebugSymbols>True</DebugSymbols> + <DefineDebug>True</DefineDebug> + <DefineTrace>True</DefineTrace> + <DefineConstants>Win32=True</DefineConstants> + <PlatformTarget>x86</PlatformTarget> + <NoWarn>42016,42017,42018,42019,42032</NoWarn> + <DebugType>full</DebugType> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <OutputPath>.\bin\</OutputPath> + <DocumentationFile>mbgsvcio_demo_vb.xml</DocumentationFile> + <DebugSymbols>False</DebugSymbols> + <DefineDebug>False</DefineDebug> + <DefineTrace>True</DefineTrace> + <DefineConstants>Win32=True</DefineConstants> + <PlatformTarget>x86</PlatformTarget> + <NoWarn>42016,42017,42018,42019,42032</NoWarn> + <DebugType>none</DebugType> + </PropertyGroup> + <ItemGroup> + <Reference Include="Microsoft.VisualBasic.Compatibility"> + <Name>Microsoft.VisualBasic.Compatibility</Name> + </Reference> + <Reference Include="System"> + <Name>System</Name> + </Reference> + <Reference Include="System.Data"> + <Name>System.Data</Name> + </Reference> + <Reference Include="System.Drawing"> + <Name>System.Drawing</Name> + </Reference> + <Reference Include="System.Windows.Forms"> + <Name>System.Windows.Forms</Name> + </Reference> + <Reference Include="System.XML"> + <Name>System.XML</Name> + </Reference> + </ItemGroup> + <ItemGroup> + <Import Include="Microsoft.VisualBasic" /> + <Import Include="Microsoft.VisualBasic.Compatibility" /> + <Import Include="System" /> + <Import Include="System.Collections" /> + <Import Include="System.Data" /> + <Import Include="System.Diagnostics" /> + <Import Include="System.Drawing" /> + <Import Include="System.Windows.Forms" /> + </ItemGroup> + <ItemGroup> + <Compile Include="..\..\mbglib\mbgdefs-vb.net.vb"> + <Link>mbgdefs-vb.net.vb</Link> + </Compile> + <Compile Include="..\..\mbglib\mbgsvcio-vb.net.vb"> + <Link>mbgsvcio-vb.net.vb</Link> + </Compile> + <Compile Include="AssemblyInfo.vb" /> + <Compile Include="mbgsvcio-demo-vb.net.Designer.vb"> + <SubType>Code</SubType> + <DependentUpon>mbgsvcio-demo-vb.net.vb</DependentUpon> + </Compile> + <Compile Include="mbgsvcio-demo-vb.net.vb"> + <SubType>Form</SubType> + </Compile> + </ItemGroup> + <ItemGroup> + <Folder Include="My Project\" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" /> + <PropertyGroup> + <PreBuildEvent> + </PreBuildEvent> + <PostBuildEvent> + </PostBuildEvent> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/vb.net/mbglib/mbgdefs-vb.net.vb b/vb.net/mbglib/mbgdefs-vb.net.vb new file mode 100644 index 0000000..11d4747 --- /dev/null +++ b/vb.net/mbglib/mbgdefs-vb.net.vb @@ -0,0 +1,78 @@ +Option Strict Off +Option Explicit On +Imports System.Runtime.InteropServices + +Module mbgdefs + + '************************************************************************** + ' + ' $Id: mbgdefs-vb.net.vb 1.1 2008/05/23 11:18:33Z martin REL_M $ + ' + ' Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany + ' + ' Description: + ' Some common Visual Basic declarations used by API functions + ' exported by Meinberg DLLs. + ' + ' This module for VB.NET may contain some declarations which are not + ' supported by VB6, so for VB6 there's a specific module available. + ' + ' The module should be added to applications as-is in order to simplify + ' upgrades if newer versions are released. + ' + ' If there are any questions or enhancement requests, please contact + ' Meinberg: support@meinberg.de + ' + ' ----------------------------------------------------------------------- + ' $Log: mbgdefs-vb.net.vb $ + ' Revision 1.1 2008/05/23 11:18:33Z martin + ' Initial revision for VB.NET 2005. + ' + '************************************************************************** + + + ' This value is returned by the API functions on success: + Public Const PCPS_SUCCESS As Short = 0 + + + ' Bit masks used with both the status fields of the PCPS_TIME structure + ' and the PCPS_HR_TIME structure: + + Public Const PCPS_FREER As Short = &H1S ' DCF77 clock running on xtal + ' GPS receiver has not verified its position + + Public Const PCPS_DL_ENB As Short = &H2S ' Daylight saving enabled + + Public Const PCPS_SYNCD As Short = &H4S ' Clock has sync'ed at least once after pwr up + + Public Const PCPS_DL_ANN As Short = &H8S ' A change in daylight saving is announced + + Public Const PCPS_UTC As Short = &H10S ' The returned time is UTC + + Public Const PCPS_LS_ANN As Short = &H20S ' Leap second is announced + + Public Const PCPS_IFTM As Short = &H40S ' The current time was set via PC interface + + Public Const PCPS_INVT As Short = &H80S ' Invalid time because battery was disconnected. + + ' Please note: + ' IRIG receiver cards may set the PCPS_INVT bit also if the card's ref time offset + ' to UTC has not yet been configured, or if the on-board date does not match the + ' day-of-year number of the incoming IRIG signal. The reason for this is to avoid + ' accepting wrong times from the IRIG signal due to the ambiguity of the time and + ' day-of-year from the IRIG signal. + + + ' Bit masks used with the status fields of the PCPS_HR_TIME structure only: + + Public Const PCPS_LS_ENB As Short = &H100S ' current second is leap second + Public Const PCPS_ANT_FAIL As Short = &H200S ' 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 As Short = &H2000S ' events interval too short + Public Const PCPS_UCAP_BUFFER_FULL As Short = &H4000S ' events read too slow + +End Module
\ No newline at end of file diff --git a/vb.net/mbglib/mbgdevio-vb.net.vb b/vb.net/mbglib/mbgdevio-vb.net.vb new file mode 100644 index 0000000..e036c24 --- /dev/null +++ b/vb.net/mbglib/mbgdevio-vb.net.vb @@ -0,0 +1,246 @@ +Option Strict Off +Option Explicit On +Imports System.Runtime.InteropServices + +Module mbgdevio + + '************************************************************************** + ' + ' $Id: mbgdevio-vb.net.vb 1.1 2008/05/23 10:56:21Z 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 API from Visual Basic. + ' + ' This module for VB.NET may contain some declarations which are not + ' supported by VB6, so for VB6 there's a specific module available. + ' + ' The module should be added to applications as-is in order to simplify + ' upgrades if newer versions are released. + ' + ' If there are any questions or enhancement requests, please contact + ' Meinberg: support@meinberg.de + ' + ' ----------------------------------------------------------------------- + ' $Log: mbgdevio-vb.net.vb $ + ' Revision 1.1 2008/05/23 10:56:21Z martin + ' Initial revision for VB.NET 2005, based v1.4 for VB6. + ' + '************************************************************************** + + + ' The DLL version required by this interface specification + Public Const MBGDEVIO_VERSION As Short = &H212S + + + ' The structure below is passed to the function mbg_get_time + ' to read date, time, and status + + <StructLayout(LayoutKind.Sequential, Pack:=1)> _ + Public Structure PCPS_TIME + Dim sec100 As Byte ' 0..99 + Dim sec As Byte ' 0..59, 60 if leap second + Dim min As Byte ' 0..59 + Dim hour As Byte ' 0..23 + Dim mday As Byte ' 1..31 + Dim wday As Byte ' 1..7, 1 = Monday + Dim month As Byte ' 1..12 + Dim year As Byte ' 0..99 (year modulo 100) + Dim status As Byte ' flag bits, see below + Dim signal As Byte ' 0..255 + Dim offs_utc As Byte ' [h] signed!! (UTC = t - offs_utc) + End Structure + + + ' The structure below has been introduced to be able to handle + ' high resolution time stamps. + + <StructLayout(LayoutKind.Sequential, Pack:=1)> _ + Public Structure PCPS_TIME_STAMP + Dim sec As Integer ' UInt32, seconds since 1970 (UTC) + Dim frac As Integer ' UInt32, fractions of second ( &HFFFFFFFF == 0.9999.. sec) + End Structure + + + ' The structure below holds a HR time stamp, plus UTC offset and status info + + <StructLayout(LayoutKind.Sequential, Pack:=1)> _ + Public Structure PCPS_HR_TIME + Dim tstamp As PCPS_TIME_STAMP + Dim utc_offs As Integer ' [sec] signed!! (local time = tstamp + offs_utc) + Dim status As Short ' flag bits, see below + Dim signal As Byte ' 0..255 + End Structure + + + + ' 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. + + <StructLayout(LayoutKind.Sequential, Pack:=1)> _ + Public Structure PCPS_HR_TIME_CYCLES + Dim cycles As Long ' UInt64, performance counter value + Dim t As PCPS_HR_TIME ' associated HR time + End Structure + + + ' The structure below contains the maximum number of entries of an on-board + ' user capture FIFO buffer plus the number of currently used entries. + + <StructLayout(LayoutKind.Sequential, Pack:=1)> _ + Public Structure PCPS_UCAP_ENTRIES + Dim used As Integer ' the number of saved capture events + Dim max As Integer ' capture buffer size + End Structure + + + ' The definitions below are used with geographic positions. + + ' The type below is used to hold a geographic position + ' in kartesian coordinates. + + <StructLayout(LayoutKind.Sequential, Pack:=1)> _ + Public Structure MBG_POS_XYZ + Dim x As Double ' x coordinate, in meters + Dim y As Double ' y coordinate, in meters + Dim z As Double ' z coordinate, in maters + End Structure + + + ' The type below is used to pass a geographic position + ' in raw geographic coordinates. + + <StructLayout(LayoutKind.Sequential, Pack:=1)> _ + Public Structure MBG_POS_LLA + Dim lat As Double ' latitude, in radians + Dim lon As Double ' longitude, in radians + Dim alt As Double ' altitude (height above ellipsoid), in meters + End Structure + + + ' The type below is used to store a geographic coordinate + ' in broken-down (human readable) format. + + <StructLayout(LayoutKind.Sequential, Pack:=1)> _ + Public Structure MBG_DMS + Dim prefix As Short ' ASCII code of 'N', 'E', 'S' or 'W' + Dim deg As Short ' [0...90 (lat) or 0...180 (lon)] + Dim min As Short ' [0...59] + Dim sec As Double ' [0...59.999] + End Structure + + + <StructLayout(LayoutKind.Sequential, Pack:=1)> _ + Public Structure MBG_RCVR_POS + Dim xyz As MBG_POS_XYZ ' always WGS84 ECEF coordinates + Dim lla As MBG_POS_LLA ' depending on the ellipsoid used for reference + Dim longitude As MBG_DMS ' longitude in degrees, minutes, seconds + Dim latitude As MBG_DMS ' latitude in degrees, minutes, seconds + Dim ellipsoid As Short ' ellipsoid used for reference + End Structure + + + ' + ' 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. + + ' 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 Integer + + ' 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 Integer) As Integer + + ' 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 Integer) As Integer + + + '-------------------------------------------------------------------------------- + ' 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 Integer, ByRef t As PCPS_TIME) As Integer + + + '-------------------------------------------------------------------------------- + ' 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 Integer, ByRef f As Integer) As Integer + + ' 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 Integer, ByRef t As PCPS_HR_TIME) As Integer + + ' 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 Integer, ByRef p As PCPS_HR_TIME_CYCLES) As Integer + + ' 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 Integer, ByRef t As PCPS_HR_TIME, ByRef l As Integer) As Integer + + + '-------------------------------------------------------------------------------- + ' 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 Integer, ByRef f As Integer) As Integer + + ' Clear the on-board user capture FIFO buffer + Public Declare Function mbg_clr_ucap_buff Lib "mbgdevio" (ByVal h As Integer) As Integer + + ' 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 Integer, ByRef p As PCPS_UCAP_ENTRIES) As Integer + + ' 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 Integer, ByRef t As PCPS_HR_TIME) As Integer + + + '-------------------------------------------------------------------------------- + ' 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 Integer, ByRef f As Integer) As Integer + + ' Read the current receiver position. + Public Declare Function mbg_get_gps_pos Lib "mbgdevio" (ByVal h As Integer, ByRef p As MBG_RCVR_POS) As Integer + +End Module
\ No newline at end of file diff --git a/vb.net/mbglib/mbgsvcio-vb.net.vb b/vb.net/mbglib/mbgsvcio-vb.net.vb new file mode 100644 index 0000000..4fb2475 --- /dev/null +++ b/vb.net/mbglib/mbgsvcio-vb.net.vb @@ -0,0 +1,68 @@ +Option Strict Off +Option Explicit On +Module mbgsvcio + + '************************************************************************** + ' + ' $Id: mbgsvcio-vb.net.vb 1.1 2008/05/23 10:57:00Z martin REL_M $ + ' + ' Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany + ' + ' Description: + ' Types and function declarations used to query the status of the + ' Meinberg time adjustment service and its reference time source. + ' + ' This module for VB.NET may contain some declarations which are not + ' supported by VB6, so for VB6 there's a specific module available. + ' + ' The module should be added to applications as-is in order to simplify + ' upgrades if newer versions are released. + ' + ' If there are any questions or enhancement requests, please contact + ' Meinberg: support@meinberg.de + ' + ' ----------------------------------------------------------------------- + ' $Log: mbgsvcio-vb.net.vb $ + ' Revision 1.1 2008/05/23 10:57:00Z martin + ' Initial revision for VB.NET 2005, based on v1.2 for VB6. + ' + '************************************************************************** + + + ' The DLL version required by this interface specification + Public Const MBGSVCIO_VERSION As Short = &H212s + + + ' + ' The functions exported by the mbgsvcio DLL + ' ------------------------------------------ + ' + + ' Return the version number of the DLL + Public Declare Function mbgsvcio_get_version Lib "mbgsvcio" () As Short + + ' Check that the DLL interface specification version is compatible with the + ' DLL version. Pass the MBGSVCIO_VERSION code specified above as parameter. + ' Returns PCPS_SUCCESS on success. + Public Declare Function mbgsvcio_check_version Lib "mbgsvcio" (ByVal i As Short) As Short + + ' Check if the Meinberg time adjustment service is active. + ' Returns: a positive value if the service is active + ' 0 if the service is not active + Public Declare Function mbg_time_adjustment_active Lib "mbgsvcio" () As Short + + ' Check if the ref time source (e.g. radio clock) used by the Meinberg + ' time adjustment service is accessible. This should be always the case + ' with PCI plug-in boards, but this can also fail with an external clock + ' if for example the serial connection is broken or the device is powered + ' off. + ' Returns: a positive value if the ref time source is accessible + ' 0 if the ref time source is not accessible + ' a negative number if the status could not be determined. + Public Declare Function mbg_ref_time_accessible Lib "mbgsvcio" () As Short + + ' Query the status of the ref time source (e.g. radio clock) used by the + ' Meinberg time adjustment service. + ' Returns: A set of status flags as specified above. + Public Declare Function mbg_get_ref_time_status Lib "mbgsvcio" () As Short +End Module
\ No newline at end of file |