24 void print_client_message(
const char*
message)
27 std::cout <<
message << std::endl;
34 void print_servers_list(
const std::vector<std::string>& server_list)
39 if (server_list.size() == 0)
41 print_client_message(
"none");
45 for (
int i = 0; i < server_list.size(); i++)
47 std::string test = server_list[i];
48 sprintf(buf,
"<%d> %s", i, test.c_str());
49 print_client_message(buf);
54 void servers_to_list(std::vector<std::string>& server_list, std::string servers)
58 if (servers.length() == 0)
63 while (index < servers.length())
65 if (servers[index] ==
'\n')
67 server_list.push_back(server);
72 server += servers[index];
77 server_list.push_back(server);
94 std::vector<std::string> server_list;
96 char instructions[] =
"<s> List available servers on the network\n"
97 "<h> List available hardware on currently connected server\n"
98 "<0-9> Enter numbers 0-9 to connect to a server by index\n"
99 "<l> Set active server back to local server\n"
103 cout << instructions << std::endl;
109 printw(instructions);
115 char input = _getch();
117 char input = getch();
121 else if (input ==
's')
123 print_client_message(
"Available Servers:");
126 servers_to_list(server_list, servers);
128 print_servers_list(server_list);
130 else if(input >=
'0' && input <=
'9')
132 int index = input -
'0';
133 if (server_list.size() > 0 && index < server_list.size())
136 sprintf(buf,
"Server set to: %s", server_list[index].c_str());
137 print_client_message(buf);
140 else if (input ==
'l')
143 print_client_message(
"Server set to: Local");
145 else if (input ==
'h')
148 print_client_message(buf);
156 return GALIL_EXAMPLE_OK;
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...
GCLIB_DLL_EXPORTED GReturn GCALL GSetServer(GCStringIn server_name)
Uses GUtility(), G_UTIL_GCAPS_SET_SERVER to set the new active server.
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...
int GReturn
Every function returns a value of type GReturn. See gclib_errors.h for possible values.
#define G_SMALL_BUFFER
Most reads from Galil are small. This value will easily hold most, e.g. TH, TZ, etc.
void e(GReturn rc)
A trivial, C++ style return code check used in Galil's examples and demos.
GReturn message(GCon g)
Demonstrates how to receive messages from the controller and detect differences in Trace and crashed ...
GReturn remote_client()
Lists available remote servers and allows connection to remote server.