gclib examples  0
Example Projects for the Communications API for Galil controllers and PLCs
contour_example.cpp
Go to the documentation of this file.
1 
17 #include "examples.h"
18 
19 #include <iostream> //std::cout
20 using namespace std;
21 
23 
28 int main(int argc, char * argv[])
29 {
30  GReturn rc = GALIL_EXAMPLE_OK;
31  char buf[G_SMALL_BUFFER];
32 
33  //var used to refer to a unique connection. A valid connection is nonzero.
34  GCon g = 0;
35 
36  try
37  {
38  if (argc != 4) //Invalid number of arguments
39  {
40  cerr << "Incorrect number of arguments provided\n";
41  cerr << "Usage: contour_example.exe <ADDRESS>\n";
42  return GALIL_EXAMPLE_ERROR;
43  }
44 
45  char* fileA = argv[2];
46  char* fileB = argv[3];
47  char* address = argv[1]; //Retrieve address from command line
48  e(GOpen(address, &g)); //Opens a connection at the provided address
49 
50  // Record user's training and plays back training through contour mode
51  rc = contour(g, fileA, fileB);
52  }
53  catch (GReturn gr)
54  {
55  GError(gr, buf, G_SMALL_BUFFER); //Get Error Information
56  cout << buf << '\n';
57  if (g)
58  {
59  GSize size = sizeof(buf);
60  GUtility(g, G_UTIL_ERROR_CONTEXT, buf, &size);
61  cout << buf << '\n'; //further context
62  }
63  return GALIL_EXAMPLE_ERROR;
64  }
65 
66  return rc;
67 }
int main(int argc, char *argv[])
Main function for Contour Example.
GReturn contour(GCon g, char *fileA, char *fileB)
Record user's training and plays back training through contour mode.
Definition: contour.cpp:16
void e(GReturn rc)
A trivial, C++ style return code check used in Galil's examples and demos.
Definition: examples.h:22