14 char buf[G_SMALL_BUFFER];
19 cout <<
"*****************************************************************************\n";
20 cout <<
"************************** GCmdT() example *****************************\n";
21 cout <<
"*****************************************************************************\n";
22 cout <<
"GCmdT() will return a trimmed response of GCommand()\n";
23 cout <<
"The command 'PR ?,?' will return the relative " 24 "position of the A and B axes\n";
25 e(GCommand(g,
"PR ?,?", buf, G_SMALL_BUFFER, &read_bytes));
26 cout <<
"<<PR ?,? with GCommand(): " << buf <<
">>\n";
27 e(GCmdT(g,
"PR ?,?", buf, G_SMALL_BUFFER, NULL));
28 cout <<
"<<PR ?,? with GCmdT(): " << buf <<
">>\n";
30 e(GCmdT(g,
"MG TIME", buf,
sizeof(buf), &front));
31 cout <<
"<<MG TIME with GCmdT() and front trimmed: " << front <<
">>" <<
"\n\n";
33 cout <<
"*****************************************************************************\n";
34 cout <<
"************************** GCmdI() example *****************************\n";
35 cout <<
"*****************************************************************************\n";
36 cout <<
"GCmdI() will return the value of GCommand() parsed as an int\n";
37 cout <<
"The command 'MG _LMS' will return the available " 38 "space in the vector buffer of the S plane.\n";
39 e(GCmdT(g,
"MG _LMS", buf, G_SMALL_BUFFER, NULL));
40 cout <<
"MG _LMS with GCmdT(): " << buf <<
"\n";
41 e(GCmdI(g,
"MG _LMS", &value));
42 cout <<
"MG _LMS with GCmdI(): " << value <<
"\n\n";
44 cout <<
"*****************************************************************************\n";
45 cout <<
"************************** GCmd() example ******************************\n";
46 cout <<
"*****************************************************************************\n";
47 cout <<
"GCmd() will execute the given command but does not return a value.\n";
48 cout <<
"GCmd is useful for basic operations such as beginning" 49 " motion or setting speed\n";
51 e(GCmd(g,
"SP 5000"));
52 cout <<
"GCmd(g, \"BG A\");\n";
53 cout <<
"GCmd(g, \"SP 5000\");\n\n";
56 cout <<
"*****************************************************************************\n";
57 cout <<
"************************** GCmdD() example ******************************\n";
58 cout <<
"*****************************************************************************\n";
59 cout <<
"GCmdD() will return the value of GCommand parsed as a double\n";
60 cout <<
"The command 'MG @AN[1]' will return the value of Analog Input 1\n";
61 e(GCmdD(g,
"MG @AN[1]", &d_value));
62 cout <<
"MG @AN[1] with GCmdD(): " << d_value <<
"\n\n";
64 cout <<
"*****************************************************************************\n";
65 cout <<
"************************ Galil Double Format ***************************\n";
66 cout <<
"*****************************************************************************\n";
67 double d_val = 0.00235;
68 sprintf(buf,
"%.4f", d_val);
69 cout <<
"Galil Controllers expect double values to be formatted to 4 " 71 cout <<
"Unformatted double value: " << d_val <<
"\n";
72 cout <<
"Formatted double value rounded to 4 decimal places: " << buf <<
"\n\n";
74 cout <<
"*****************************************************************************\n";
75 cout <<
"******************* G_UTIL_ERROR_CONTEXT example ***********************\n";
76 cout <<
"*****************************************************************************\n";
78 GSize size =
sizeof(buf);
79 GUtility(g, G_UTIL_ERROR_CONTEXT, buf, &size);
80 cout <<
"GUtility() with G_UTIL_ERROR_CONTEXT: " << buf <<
"\n";
82 return GALIL_EXAMPLE_OK;
GReturn commands(GCon g)
Demonstrates various uses of GCommand() and GUtility().
void e(GReturn rc)
A trivial, C++ style return code check used in Galil's examples and demos.