10 int main(
int argc,
char * argv[])
12 int rc = GALIL_EXAMPLE_OK;
21 cout <<
"Library versions: " << buf <<
"\n";
29 cout <<
"Controllers without IP Address:\n";
31 cout << buf <<
"\n\n";
42 x_e(
GAssign(
"192.168.42.100",
"00:50:4C:20:52:90"));
52 cout <<
"Available addresses:\n";
54 cout << buf <<
"\n\n";
59 cout <<
"Connecting to hardware\n";
62 x_e(
GOpen(
"192.168.42.100 --subscribe ALL", &g));
109 const char* file_path =
"C:/dev/test/gcb/test.gcb";
111 cout <<
"Setup file " << file_path << endl;
112 cout <<
"Parameters " << (opt & 0x02 ?
"present" :
"absent") << endl;
113 cout <<
"Variables " << (opt & 0x08 ?
"present" :
"absent") << endl;
114 cout <<
"Arrays " << (opt & 0x10 ?
"present" :
"absent") << endl;
115 cout <<
"Program " << (opt & 0x20 ?
"present" :
"absent") << endl;
127 if (gr == GALIL_EXAMPLE_ERROR)
128 cout <<
"ERROR: Example code failed\n";
131 cout <<
"Function returned " << gr <<
'\n';
132 GError(gr, buf,
sizeof(buf));
134 GSize size =
sizeof(buf);
143 rc = GALIL_EXAMPLE_ERROR;
146 catch (std::exception&
e)
148 std::cerr <<
"Unexpected std::exception... Kaboom. " <<
e.what() << std::endl;
149 rc = GALIL_EXAMPLE_ERROR;
154 cout <<
"Unexpected error... Kaboom." << endl;
155 rc = GALIL_EXAMPLE_ERROR;
161 cout << endl << endl;
162 if (rc == GALIL_EXAMPLE_OK)
163 cout <<
"examples.cpp executed OK\n";
165 cout <<
"examples.cpp returning error " << rc <<
'\n';
167 cout <<
"main() is finished. Press Enter to exit:";
GCLIB_DLL_EXPORTED GReturn GCALL GUtility(GCon g, GOption request, GMemory memory1, GMemory memory2)
Provides read/write access to driver settings and convenience features based on the request variable.
GCLIB_DLL_EXPORTED GReturn GCALL GFirmwareDownload(GCon g, GCStringIn filepath)
Upgrade firmware.
GCLIB_DLL_EXPORTED GReturn GCALL GAssign(GCStringIn ip, GCStringIn mac)
Uses GUtility(), G_UTIL_GCAPS_ASSIGN or G_UTIL_ASSIGN to assign an IP address over the Ethernet to a ...
GCLIB_DLL_EXPORTED GReturn GCALL GClose(GCon g)
Closes a connection to a Galil Controller.
GCLIB_DLL_EXPORTED GReturn GCALL GIpRequests(GCStringOut requests, GSize requests_len)
Uses GUtility(), G_UTIL_GCAPS_IPREQUEST or G_UTIL_IPREQUEST to provide a list of all Galil controller...
GCLIB_DLL_EXPORTED GReturn GCALL GSetupDownloadFile(GCon g, GCStringIn file_path, GOption options, GCStringOut info, GSize info_len)
Download a saved controller configuration from a file.
GCLIB_DLL_EXPORTED GReturn GCALL GVersion(GCStringOut ver, GSize ver_len)
Uses GUtility(), G_UTIL_VERSION and G_UTIL_GCAPS_VERSION to provide the library and gcaps version num...
GCLIB_DLL_EXPORTED void GCALL GError(GReturn rc, GCStringOut error, GSize error_len)
Provides a human-readable description string for return codes.
GCLIB_DLL_EXPORTED GReturn GCALL GInfo(GCon g, GCStringOut info, GSize info_len)
Uses GUtility() and G_UTIL_INFO to provide a useful connection string.
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...
GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon *g)
Open a connection to a Galil Controller.
int GReturn
Every function returns a value of type GReturn. See gclib_errors.h for possible values.
int GOption
Option integer for various formatting, etc.
#define G_SMALL_BUFFER
Most reads from Galil are small. This value will easily hold most, e.g. TH, TZ, etc.
unsigned int GSize
Size of buffers, etc.
void * GCon
Connection handle. Unique for each connection in process. Assigned a non-zero value in GOpen().
#define G_UTIL_ERROR_CONTEXT
GUtility(), provides additional error context, where available.
int main(int argc, char *argv[])
Main function for Commands Example.
void e(GReturn rc)
A trivial, C++ style return code check used in Galil's examples and demos.
int x_arrays(GCon g)
Example GArrayDownload() and GArrayUpload() usage.
int x_grecord(GCon g)
Example GRecord() usage.
int x_gcommand(GCon g)
Example GCommand() usage.
int x_gread_gwrite(GCon g)
Example GRead() and GWrite() usage.
int x_ginterrupt(GCon g)
Example GInterrupt() usage.
void x_e(GReturn rc)
A trivial, C++ style return code check used in Galil's examples and demos.
int x_nonblocking(GCon g)
Examples of using non-blocking operation of GRecord(), GInterrupt(), and GMessage().
int x_gmotioncomplete(GCon g)
Example GMotionComplete() usage.
int x_programs(GCon g)
Example GProgramDownload() and GProgramUpload() usage.
int x_gmessage(GCon g)
Example GMessage() usage.