VisionBox .NET Library
VIBSystem_Example.vb

Visual Basic example for using the VIBSystem factory

1 
2 Public Class VIBSystem_Example
3  Public Shared Sub VIBSystem()
4  Console.Clear()
5  'acquire a new factory
6  Dim pVIBSystem As VIB_NET.VIBSystem = New VIB_NET.VIBSystem()
7  Try
8  'get API version
9  Dim Version As VIB_NET.VIBSystem.Version4Parts = pVIBSystem.API_Version
10  System.Console.WriteLine("API version: " + Version.ToString())
11 
12  'get VIB_NET version
13  System.Console.WriteLine("VIB_NET version: " + pVIBSystem.VIB_NET_Version.ToString())
14 
15  'get version string
16  System.Console.WriteLine("Version string:" + vbNewLine + pVIBSystem.VersionString)
17 
18  'get system string
19  System.Console.WriteLine("System string:" + vbNewLine + pVIBSystem.SystemString)
20 
21  'get number of device types
22  Dim NumberOfDeviceTypes As Int32 = pVIBSystem.NumberOfDeviceTypes
23  System.Console.WriteLine("Number of device types: " + NumberOfDeviceTypes.ToString())
24 
25  'get list of hardware devices
26  Dim DeviceList As ArrayList = pVIBSystem.DeviceInfoList
27 
28  'search for the led(s)
29  For Each DevInfo As VIB_NET.DeviceInfo In DeviceList
30  If (DevInfo IsNot Nothing) Then
31  If (DevInfo.Type = VIB_NET.eDEVICE_TYPE.LED) Then
32  System.Console.WriteLine(vbNewLine + "Number of LED devices: " + DevInfo.NumberOfEntities.ToString())
33  End If
34  End If
35  Next
36  'get device informations of led devices
37  Dim LedInfo As VIB_NET.DeviceInfo = pVIBSystem.GetDeviceInfo(VIB_NET.eDEVICE_TYPE.LED)
38  If (LedInfo IsNot Nothing) Then
39  System.Console.WriteLine(LedInfo.Type.ToString() + " has " + LedInfo.NumberOfEntities.ToString() + " Entitie(s).")
40 
41  'open device: Led number 0
42  Dim pLed As VIB_NET.Led = DirectCast(pVIBSystem.OpenDevice(VIB_NET.eDEVICE_TYPE.LED, 0), VIB_NET.Led)
43  'close device
44  If (pLed IsNot Nothing) Then
45  'Set Led 1 ON and all other OFF
46  pLed.Set(2, 255)
47  System.Threading.Thread.Sleep(1000)
48  'Set all Leds OFF
49  pLed.Set(0, 255)
50 
51  ' close Led device
52  pVIBSystem.CloseDevice(pLed)
53  pLed = Nothing
54  End If
55  End If
56  Catch e As System.Exception
57  Console.WriteLine(e.Message)
58  Finally
59  'release factory
60  pVIBSystem = Nothing
61  End Try
62  Console.WriteLine(vbNewLine + "Press enter to proceed...")
63  System.Console.ReadLine()
64  End Sub
65 End Class
66