gclib  2.0.8
Communications API for Galil controllers and PLCs
contour_example.cpp
Go to the documentation of this file.
1 
10 #include "examples.h"
11 
12 #include <iostream> //std::cout
13 using namespace std;
14 
16 
21 int main(int argc, char * argv[])
22 {
23  GReturn rc = GALIL_EXAMPLE_OK;
24  char buf[G_SMALL_BUFFER];
25 
26  //var used to refer to a unique connection. A valid connection is nonzero.
27  GCon g = 0;
28 
29  try
30  {
31  if (argc != 4) //Invalid number of arguments
32  {
33  cerr << "Incorrect number of arguments provided\n";
34  cerr << "Usage: contour_example.exe <ADDRESS> <FileA> <FileB>\n";
35  pause();
36  return GALIL_EXAMPLE_ERROR;
37  }
38 
39  char* fileA = argv[2];
40  char* fileB = argv[3];
41  char* address = argv[1]; //Retrieve address from command line
42  e(GOpen(address, &g)); //Opens a connection at the provided address
43 
44  // Record user's training and plays back training through contour mode
45  rc = contour(g, fileA, fileB);
46  }
47  catch (GReturn gr)
48  {
49  error(g, gr); //see examples.h for error handling
50  pause();
51  return GALIL_EXAMPLE_ERROR;
52  }
53 
54  pause();
55  return GALIL_EXAMPLE_OK;
56 }
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.
Definition: gclib.h:93
#define G_SMALL_BUFFER
Most reads from Galil are small. This value will easily hold most, e.g. TH, TZ, etc.
Definition: gclib.h:89
void * GCon
Connection handle. Unique for each connection in process. Assigned a non-zero value in GOpen().
Definition: gclib.h:94
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.
Definition: examples.h:33
GReturn contour(GCon g, char *fileA, char *fileB)
Record user's training and plays back training through contour mode.
Definition: contour.cpp:20
void error(GCon g, GReturn rc)
An example of error handling and debugging information.
Definition: examples.h:40
int pause()
Pauses console apps for a user key stroke.
Definition: examples.h:62