gclib 2.0.9
Communications API for Galil controllers and PLCs
 
Loading...
Searching...
No Matches
x_gmotioncomplete.cpp
Go to the documentation of this file.
1
7#include "x_examples.h"
8
10{
11 cout << "\n************************************************************************\n";
12 cout << "Example GMotionComplete() usage\n";
13 cout << "************************************************************************\n";
14
15 char buf[1024]; //traffic buffer
16 char* trimmed; //trimmed string pointer
17
18 x_e(GCmd(g, "ST")); //stop all motion and programs
19
20 //-------------------------------------------------------------------------
21 // Independent motion
22 x_e(GCmd(g, "DP 0")); //define A position zero
23 x_e(GCmdT(g, "RP", buf, sizeof(buf), &trimmed));
24 cout << "\nPosition: " << trimmed << '\n';
25 x_e(GCmd(g, "SP 4000")); //set up speed
26 x_e(GCmd(g, "AC 1280000")); //acceleration
27 x_e(GCmd(g, "DC 1280000")); //deceleration
28 x_e(GCmd(g, "PR 8000")); //Postion Relative.
29 x_e(GCmd(g, "SH A")); //Servo Here
30 cout << "Beginning independent motion... ";
31 x_e(GCmd(g, "BG A")); //Begin motion
32 x_e(GMotionComplete(g, "A")); //Block until motion is complete on axis A
33 cout << "Motion Complete on A\n";
34 x_e(GCmdT(g, "RP", buf, sizeof(buf), &trimmed));
35 cout << "Position: " << trimmed << '\n';;
36
37 //-------------------------------------------------------------------------
38 // Vector motion
39 x_e(GCmd(g, "DP 0")); //define position zero on A
40 x_e(GCmdT(g, "RP", buf, sizeof(buf), &trimmed));
41 cout << "\nPosition: " << trimmed << '\n';;
42 x_e(GCmd(g, "VS 2000")); //set up vector speed, S plane
43 x_e(GCmd(g, "VA 100000")); //vector Acceleration
44 x_e(GCmd(g, "VD 100000")); //vector deceleration
45 x_e(GCmd(g, "VM AN")); //invoke vector mode, use virtual axis for 1-axis controllers
46 x_e(GCmd(g, "VP 3000, 3000")); //buffer Vector Position
47 x_e(GCmd(g, "VP 6000,0")); //buffer Vector Position
48 x_e(GCmd(g, "VE")); //indicate Vector End
49 cout << "Beginning vector motion... ";
50 x_e(GCmd(g, "BG S")); //begin S plane
51 x_e(GMotionComplete(g, "S")); //Block until motion is complete on vector plane S
52 cout << "Motion Complete on vector plane S\n";
53 x_e(GCmdT(g, "RP", buf, sizeof(buf), &trimmed));
54 cout << "Position: " << trimmed << '\n';;
55
56 return GALIL_EXAMPLE_OK;
57}
GCLIB_DLL_EXPORTED GReturn GCALL GMotionComplete(GCon g, GCStringIn axes)
Blocking call that returns once all axes specified have completed their motion.
Definition gclibo.c:300
GCLIB_DLL_EXPORTED GReturn GCALL GCmdT(GCon g, GCStringIn command, GCStringOut trimmed_response, GSize response_len, GCStringOut *front)
Wrapper around GCommand that trims the response.
Definition gclibo.c:243
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 GCmd(GCon g, GCStringIn command)
Wrapper around GCommand for use when the return value is not desired.
Definition gclibo.c:237
GReturn vector(GCon g, char *file)
Puts controller into Vector Mode and accepts a file defining vector points.
Definition vector.cpp:36
void x_e(GReturn rc)
A trivial, C++ style return code check used in Galil's examples and demos.
Definition x_examples.h:30
int x_gmotioncomplete(GCon g)
Example GMotionComplete() usage.