gclib  2.0.8
Communications API for Galil controllers and PLCs
Position_Tracking_Example.vb
Go to the documentation of this file.
1 Module Position_Tracking_Example
2  Function Main() As Integer
3  Dim rc As Integer = Examples.GALIL_EXAMPLE_OK
4  Dim gclib As Gclib = New Gclib()
5  Dim args() As String = Environment.GetCommandLineArgs()
6  Dim speed As Integer = 0
7  Try
8  If args.Count = 2 Then
9  speed = 5000
10  ElseIf args.Count = 3 Then
11 
12  Dim ok As Boolean = Byte.TryParse(args(2), speed)
13 
14  If Not ok Then
15  Console.WriteLine("An invalid speed was entered. " +
16  "Please enter a valid integer for speed.")
17  Console.WriteLine("Usage: position_tracking_example.exe <ADDRESS> <SPEED=5000>")
18 
19  Console.Write(vbCrLf + "Press any key to close the example.")
20  Console.ReadKey()
21  Return Examples.GALIL_EXAMPLE_ERROR
22  End If
23 
24  Else
25  Console.WriteLine("Incorrect number of arguments provided")
26  Console.WriteLine("Usage: position_tracking_example.exe <ADDRESS> <SPEED=5000>")
27 
28  Console.Write(vbCrLf + "Press any key to close the example.")
29  Console.ReadKey()
30  Return Examples.GALIL_EXAMPLE_ERROR
31  End If
32 
33 
34  Dim address As String = args(1) 'Retrieve address from command line
35  gclib.GOpen(address) 'Open a connection at the provided address
36 
37  rc = Examples.Position_Tracking(gclib, speed) 'Begin position tracking mode
38  Catch ex As Exception
40  rc = Examples.GALIL_EXAMPLE_ERROR
41  Finally
42  gclib.GClose()
43  End Try
44 
45  Console.Write(vbCrLf + "Press any key to close the example.")
46  Console.ReadKey()
47 
48  Return rc
49  End Function
50 End Module
Provides a class that binds to gclib's unmanaged dll. Wraps each call and provides a more user-friend...
Definition: gclib.cs:68
GCLIB_DLL_EXPORTED GReturn GCALL GClose(GCon g)
Closes a connection to a Galil Controller.
GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon *g)
Open a connection to a Galil Controller.
int Main()
partial Module Examples
Definition: Commands.vb:4
void PrintError(Gclib gclib, Exception ex)
Prints the exception to the console And queries the controller for the most recent error message.