VisionBox .NET Library  1.7.10.0 (2024-04-16)
Strobe_Example.vb

Visual Basic example for using the Strobe device

1 
2 Public Class Strobe_Example
3  Public Shared Sub Strobe()
4  Console.Clear()
5  'acquire a new factory
6  Dim pVIBSystem As VIB_NET.VIBSystem = New VIB_NET.VIBSystem()
7  If (pVIBSystem IsNot Nothing) Then
8  Try
9  ' Open strobe device 0
10  Dim pStrobe As VIB_NET.Strobe = DirectCast(pVIBSystem.OpenDevice(VIB_NET.eDEVICE_TYPE.STROBE, 0), VIB_NET.Strobe)
11  Try
12  If (pStrobe IsNot Nothing) Then
13  ' Initialisation of the strobe unit
14  pStrobe.Init(True)
15  Console.WriteLine(vbNewLine + "Strobe initialised")
16 
17  ' Set strobe limits
18  Console.WriteLine(vbNewLine + "Min Off Time: " + pStrobe.SetLimits(0, 24, 0, 1000, 0, 1000).ToString())
19 
20  ' Get strobe values
21  Console.WriteLine(vbNewLine + "Max Current: " + pStrobe.MaxCurrent.ToString())
22  Console.WriteLine(vbNewLine + "Max On Time: " + pStrobe.MaxOnTime.ToString())
23  Console.WriteLine(vbNewLine + "Min Off Time: " + pStrobe.MinOffTime.ToString())
24 
25  ' Get current
26  Console.WriteLine(vbNewLine + "Current: " + pStrobe.Current.ToString())
27 
28  ' Get ON time
29  Console.WriteLine(vbNewLine + "On Time: " + pStrobe.OnTime.ToString())
30 
31  ' Get trigger delay
32  Console.WriteLine(vbNewLine + "Trigger Delay: " + pStrobe.TriggerDelay.ToString())
33 
34  ' Get trigger mode
35  Console.WriteLine(vbNewLine + "Trigger Mode: " + pStrobe.TriggerMode.ToString())
36 
37  ' Get trigger source
38  Console.WriteLine(vbNewLine + "Trigger Source: " + pStrobe.TriggerSource.ToString())
39 
40  ' Get trigger source invert
41  Console.WriteLine(vbNewLine + "Trigger Source Invert: " + pStrobe.TriggerSourceInvert.ToString())
42 
43  ' Get trigger voltage
44  Console.WriteLine(vbNewLine + "Trigger Voltage: " + pStrobe.Voltage.ToString())
45 
46  ' Set current to 1000 mA without validation
47  pStrobe.Validate = False
48  pStrobe.Current = 1000
49 
50  ' Set current to 1000 mA with validation
51  pStrobe.Validate = True
52  pStrobe.Current = 1000
53 
54  ' Set ON time to 1 ms
55  pStrobe.OnTime = 1000
56 
57  ' Set trigger delay
58  pStrobe.TriggerDelay = 10
59 
60  ' Set trigger mode
61  ' Pay attention to set the trigger mode to HARDWARE before you set the trigger source and the trigger source invert
62  pStrobe.TriggerMode = VIB_NET.Strobe.eSTROBE_MODE.HARDWARE_EDGE
63 
64  ' Get new trigger mode
65  Console.WriteLine(vbNewLine + "New Trigger Mode: " + pStrobe.TriggerMode.ToString())
66 
67  ' Set trigger source
68  ' Decide if it is a AGEX Type 1-6 or 7 - 12
69  Dim pService As VIB_NET.Service = DirectCast(pVIBSystem.OpenDevice(VIB_NET.eDEVICE_TYPE.SERVICE, 0), VIB_NET.Service)
70  If pService IsNot Nothing Then
71  If (pService.SerialNumber.Substring(8, 1) = "1") Then ' for AGE-X Type 7-12
72  Dim pMultiplexer As VIB_NET.Multiplexer = DirectCast(pVIBSystem.OpenDevice(VIB_NET.eDEVICE_TYPE.MULTIPLEXER, 0), VIB_NET.Multiplexer)
73  ' Connect multiplexer output 3 with digital input 0
74  pMultiplexer.ConnectOutput(0, VIB_NET.Multiplexer.eMUX_SOURCE.DIG_IN0) ' DigIn0 > Mux0
75  pStrobe.TriggerSource = VIB_NET.Strobe.eSTROBE_SOURCE.MUX_OUT0 ' For AGEX Type 8, 9, 10 and 12
76  If (pMultiplexer IsNot Nothing) Then
77  pVIBSystem.CloseDevice(pMultiplexer)
78  pMultiplexer = Nothing
79  End If
80  Else
81  pStrobe.TriggerSource = VIB_NET.Strobe.eSTROBE_SOURCE.DIG_IN0 ' For AGEX Type 1-6
82  End If
83  pVIBSystem.CloseDevice(pService)
84  pService = Nothing
85  End If
86 
87 
88  ' Set trigger source invert
89  pStrobe.TriggerSourceInvert = False
90 
91  ' Get new values:
92  Console.WriteLine(vbNewLine + vbNewLine + "New Values: ")
93  Console.WriteLine(vbNewLine + "Current: " + pStrobe.Current.ToString())
94  Console.WriteLine(vbNewLine + "On Time: " + pStrobe.OnTime.ToString())
95  Console.WriteLine(vbNewLine + "Trigger Delay: " + pStrobe.TriggerDelay.ToString())
96  Console.WriteLine(vbNewLine + "Trigger Mode: " + pStrobe.TriggerMode.ToString())
97  Console.WriteLine(vbNewLine + "Trigger Source: " + pStrobe.TriggerSource.ToString())
98  Console.WriteLine(vbNewLine + "Trigger Source Invert: " + pStrobe.TriggerSourceInvert.ToString())
99  Console.WriteLine(vbNewLine + "Trigger Voltage: " + pStrobe.Voltage.ToString())
100 
101  ' Trigger the strobe by Software
102  pStrobe.TriggerMode = VIB_NET.Strobe.eSTROBE_MODE.SOFTWARE_EDGE
103  Console.WriteLine(vbNewLine + "New Trigger Mode: " + pStrobe.TriggerMode.ToString())
104  pStrobe.SwTrigger = True
105  Console.WriteLine(vbNewLine + "Software Trigger")
106  pStrobe.SwTrigger = False
107  pStrobe.TriggerMode = VIB_NET.Strobe.eSTROBE_MODE.HARDWARE_EDGE
108  Console.WriteLine(vbNewLine + "New Trigger Mode: " + pStrobe.TriggerMode.ToString())
109  End If
110  Catch e As System.Exception
111  Console.WriteLine(e.Message)
112  Finally
113  ' Close device
114  pVIBSystem.CloseDevice(pStrobe)
115  pStrobe = Nothing
116  End Try
117  Catch e As System.Exception
118  Console.WriteLine(e.Message)
119  Finally
120  'release factory
121  pVIBSystem = Nothing
122  End Try
123  End If
124  Console.WriteLine(vbNewLine + "Press enter to proceed...")
125  System.Console.ReadLine()
126  End Sub
127 End Class