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