gclib  2.0.8
Communications API for Galil controllers and PLCs
Commands_Example.vb
Go to the documentation of this file.
1 ''' <summary>
2 ''' Demonstrates various uses of GCommand() And basic controller queries.
3 ''' </summary>
4 ''' <remarks>The first argument should be the IP Address of a Galil controller.</remarks>
5 Module Commands_Example
6 
7  ''' <summary>
8  ''' Main function for the commands example.
9  ''' </summary>
10  ''' <returns>The success status Or error code of the function.</returns>
11  ''' <remarks>The first argument should be the IP Address of a Galil controller.</remarks>
12  Function Main() As Integer
13  Dim rc As Integer = Examples.GALIL_EXAMPLE_OK
14  Dim gclib As Gclib = New Gclib()
15  Dim args() As String = Environment.GetCommandLineArgs()
16  Try
17  If args.Count() <> 2 Then
18  Console.WriteLine("Incorrect number of arguments provided")
19  Console.WriteLine("Usage: commands_example.exe <ADDRESS>")
20 
21  Console.Write(vbCrLf + "Press any key to close the example.")
22  Console.ReadKey()
23  Return Examples.GALIL_EXAMPLE_ERROR
24  End If
25 
26  Dim address As String = args(1)
27 
28  gclib.GOpen(address)
29 
30  rc = Examples.Commands(gclib)
31  Catch ex As Exception
33  rc = Examples.GALIL_EXAMPLE_ERROR
34  Finally
35  gclib.GClose()
36  End Try
37 
38  Console.Write(vbCrLf + "Press any key to close the example.")
39  Console.ReadKey()
40 
41  Return rc
42  End Function
43 
44 End Module
Definition: Galil.h:26
Provides a class of shared constants and methods for gclib's example projects.
Definition: commands.cs:16
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 GCommand(GCon g, GCStringIn command, GBufOut buffer, GSize buffer_len, GSize *bytes_returned)
Performs a command-and-response transaction on the connection.
GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon *g)
Open a connection to a Galil Controller.
GReturn commands(GCon g)
Demonstrates various uses of GCommand() and GUtility().
Definition: commands.cpp:16
void error(GCon g, GReturn rc)
An example of error handling and debugging information.
Definition: examples.h:40
int Main()
int Commands(Gclib gclib)
Demonstrates various uses of GCommand() And basic controller queries.
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.