gclib  2.0.8
Communications API for Galil controllers and PLCs
Remote_Client.vb
Go to the documentation of this file.
1 Partial Public Module Examples
2  ''' <summary>
3  ''' Demonstrates various uses of GListServers() and GSetServer()
4  ''' </summary>
5  ''' <returns>The success status Or error code of the function.</returns>
6  ''' <remarks>See remote_client_example.cs for an example.</remarks>
7  Function Remote_Client() As Integer
8  Dim gclib = New Gclib()
9 
10  Console.WriteLine("<s> List available servers on the network" + vbNewLine +
11  "<h> List available hardware on currently connected server" + vbNewLine +
12  "<0-9> Enter numbers 0-9 to connect to a server by index" + vbNewLine +
13  "<l> Set active server back to local server" + vbNewLine +
14  "<q> Quit")
15 
16  Dim loop_bool = True
17  Dim servers_list As String() = Array.Empty(Of String)
18 
19  While loop_bool
20  Dim input As Char = Console.ReadKey(True).KeyChar
21 
22  If input = "q" Then
23  loop_bool = False
24  ElseIf input = "s" Then
25  Console.WriteLine("Available Servers:")
26  servers_list = gclib.GListServers()
27  Print_Servers_List(servers_list)
28  ElseIf input >= "0" And input <= "9" Then
29  Dim index As Integer = Convert.ToInt16(input) - Convert.ToInt16("0"c)
30  If servers_list.Length > 0 And index < servers_list.Length Then
31  gclib.GSetServer(servers_list(index))
32  Console.WriteLine("Server set to: " + servers_list(index))
33  End If
34  ElseIf input = "l" Then
35  gclib.GSetServer("Local")
36  Console.WriteLine("Server set to: Local")
37  ElseIf input = "h" Then
38  Dim addresses As String() = gclib.GAddresses()
39 
40  For Each address As String In addresses
41  Console.WriteLine(address)
42  Next
43  End If
44  End While
45 
46  Return Examples.GALIL_EXAMPLE_OK
47  End Function
48 
49  Private Sub Print_Servers_List(servers_list As String())
50  If servers_list.Length = 0 Then
51  Console.WriteLine("none")
52  Else
53  For i As Integer = 0 To servers_list.Length - 1
54  Console.WriteLine("<" + i.ToString() + "> " + servers_list(i))
55  Next
56  End If
57 
58  End Sub
59 End Module
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 GListServers(GCStringOut servers, GSize servers_len)
Uses GUtility(), G_UTIL_GCAPS_LIST_SERVERS to provide a list of all available gcaps services on the l...
Definition: gclibo.c:169
GCLIB_DLL_EXPORTED GReturn GCALL GSetServer(GCStringIn server_name)
Uses GUtility(), G_UTIL_GCAPS_SET_SERVER to set the new active server.
Definition: gclibo.c:128
GCLIB_DLL_EXPORTED GReturn GCALL GAddresses(GCStringOut addresses, GSize addresses_len)
Uses GUtility(), G_UTIL_GCAPS_ADDRESSES or G_UTIL_ADDRESSES to provide a listing of all available con...
Definition: gclibo.c:54
void error(GCon g, GReturn rc)
An example of error handling and debugging information.
Definition: examples.h:40
partial Module Examples
Definition: Commands.vb:4
int Remote_Client()
Demonstrates various uses of GListServers() and GSetServer()