gclib examples  0
Example Projects for the Communications API for Galil controllers and PLCs
jog_example.cpp
Go to the documentation of this file.
1 
39 #include "examples.h"
40 
41 #include <iostream> //std::cout
42 using namespace std;
43 
45 
50 int main(int argc, char * argv[])
51 {
52  GReturn rc = GALIL_EXAMPLE_OK;
53  char buf[G_SMALL_BUFFER];
54 
55  //var used to refer to a unique connection. A valid connection is nonzero.
56  GCon g = 0;
57 
58  try
59  {
60  if (argc != 2) //Invalid number of arguments
61  {
62  cerr << "Incorrect number of arguments provided\n";
63  cerr << "Usage: jog_example.exe <ADDRESS>\n";
64  return GALIL_EXAMPLE_ERROR;
65  }
66 
67  char* address = argv[1]; //Retrieve address from command line
68  e(GOpen(address, &g)); //Opens a connection at the provided address
69 
70  //Puts controller into Jog Mode and accepts user input to adjust the speed
71  rc = jog(g);
72  }
73  catch (GReturn gr)
74  {
75  GError(gr, buf, G_SMALL_BUFFER); //Get Error Information
76  cout << buf << '\n';
77  if (g)
78  {
79  GSize size = sizeof(buf);
80  GUtility(g, G_UTIL_ERROR_CONTEXT, buf, &size);
81  cout << buf << '\n'; //further context
82  }
83  return GALIL_EXAMPLE_ERROR;
84  }
85 
86  return rc;
87 }
GReturn jog(GCon g)
Puts controller into Jog Mode and accepts user input to adjust the speed.
Definition: jog.cpp:25
int main(int argc, char *argv[])
Main function for Jog Example.
Definition: jog_example.cpp:50
void e(GReturn rc)
A trivial, C++ style return code check used in Galil's examples and demos.
Definition: examples.h:22