gclib 2.0.9
Communications API for Galil controllers and PLCs
 
Loading...
Searching...
No Matches
jog_example.cpp
Go to the documentation of this file.
1
11#include "examples.h"
12
13#include <iostream> //std::cout
14using namespace std;
15
17
22int main(int argc, char * argv[])
23{
24 GReturn rc = GALIL_EXAMPLE_OK;
25 char buf[G_SMALL_BUFFER];
26
27 //var used to refer to a unique connection. A valid connection is nonzero.
28 GCon g = 0;
29
30 try
31 {
32 if (argc != 2) //Invalid number of arguments
33 {
34 cerr << "Incorrect number of arguments provided\n";
35 cerr << "Usage: jog_example.exe <ADDRESS>\n";
36 pause();
37 return GALIL_EXAMPLE_ERROR;
38 }
39
40 char* address = argv[1]; //Retrieve address from command line
41 e(GOpen(address, &g)); //Opens a connection at the provided address
42
43 //Puts controller into Jog Mode and accepts user input to adjust the speed
44 rc = jog(g);
45 }
46 catch (GReturn gr)
47 {
48 error(g, gr);
49 pause();
50 return GALIL_EXAMPLE_ERROR;
51 }
52
53 pause();
54 return GALIL_EXAMPLE_OK;
55}
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
GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon *g)
Open a connection to a Galil Controller.
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
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
GReturn jog(GCon g)
Puts controller into Jog Mode and accepts user input to adjust the speed.
Definition jog.cpp:29
GReturn vector(GCon g, char *file)
Puts controller into Vector Mode and accepts a file defining vector points.
Definition vector.cpp:36