Measurement Computing   Easy to Use | Easy to Integrate | Easy to Support catalog banner

Add code to your application to find the device by name (not...

Expand / Collapse
 

Add code to your application to find the device by name (not InstaCal board number)


if you need to add code to your application and you are not really sure what the board number will be in InstaCal, or you want your app to work with any product from a certain family of device.

For example, let's say you want to write an application that will work with any of our products containing the name "PDISO", AND you don't know what the board number will be in InstaCal, here is a snippet of code to add to your form load event:

        Dim BoardNum As Integer
        Dim Numboards As Integer = 99

        Dim Boardfound As Boolean = False
        For BoardNum = 0 To Numboards - 1
            daqboard = New MccDaq.MccBoard(BoardNum)
            If daqboard.BoardName.Contains("PDISO") Then
                Boardfound = True
                daqboard = New MccDaq.MccBoard(BoardNum)
                daqboard.FlashLED()
                Exit For
            End If
        Next

        If Boardfound = False Then  'if not board is found in InstaCal, pop up this message
            MsgBox("No compatible board found in system.  Please run InstaCal.", _
            MsgBoxStyle.Critical, "No Board detected")
            End
        End If

        'when the board is found, you can display the board name in the forms title text         
        Dim mystring As String = daqboard.BoardName.Substring(0, daqboard.BoardName.Trim.Length - 1) + _
            " found as board number: " + BoardNum.ToString
        Me.Text = mystring

If you want to discriminate a bit more and figure out if it is a PDISO8 or PDISO16, then replace this syntax in the for loop:

           If daqboard.BoardName.Contains("PDISO") Then
                Boardfound = True
                daqboard = New MccDaq.MccBoard(BoardNum)
                daqboard.FlashLED()
                Exit For
            End If
           
with this syntax:

           If daqboard.BoardName.Contains("PDISO8") Then
                Boardfound = True
                daqboard = New MccDaq.MccBoard(BoardNum)
                daqboard.FlashLED()
                Exit For
            End If
            If daqboard.BoardName.Contains("PDISO16") Then
                Boardfound = True
                daqboard = New MccDaq.MccBoard(BoardNum)
                daqboard.FlashLED()
                Exit For
            End If

The above syntax will stop at the first of the following MCC devices it finds:

USB-PDISO8
PCI-PDISO8
PCI-PDISO16
E-PDISO16
CIO-PDISO8
CIO-PDISO16
PC104-PDISO8

it will then Instantiate it so you can start to use it in your VB.NET program.



Rate this Article:

Add Your Comments


For comments email TechSupport@mccdaq.com.

Details
Article ID: 50264

Last Modified:1/30/2012 1:18:54 PM

Article has been viewed 2,615 times.

Options