16 bool load_buf(
GCon g,
const std::vector<int>& positions_A,
17 const std::vector<int>& positions_B,
int capacity,
int& cmd);
25 int positionA = 0, positionB = 0;
37 e(
GCmd(g,
"PA 0, 0"));
49 if (positions_A.size() != positions_B.size())
51 cout <<
"Error: The two datasets are not the same size\n";
52 return GALIL_EXAMPLE_ERROR;
61 e(
GCmdI(g,
"CM?", &capacity));
63 }
while (
load_buf(g, positions_A, positions_B, capacity, cmd));
65 e(
GCmd(g,
"CD 0,0=0"));
70 return GALIL_EXAMPLE_OK;
75 const std::vector<int>& positions_B,
int capacity,
int& cmd)
78 for (capacity; capacity > 0; capacity--)
81 if (cmd + 1 < positions_A.size())
84 int cdA = positions_A[cmd + 1] - positions_A[cmd];
87 int cdB = positions_B[cmd + 1] - positions_B[cmd];
89 sprintf(buf,
"CD %d,%d", cdA, cdB);
104 std::vector<int> positions;
110 is.getline(position, 16,
',');
114 int i_position = strtol(position, &end, 10);
115 positions.push_back(i_position);
GCLIB_DLL_EXPORTED GReturn GCALL GMotionComplete(GCon g, GCStringIn axes)
Blocking call that returns once all axes specified have completed their motion.
GCLIB_DLL_EXPORTED void GCALL GSleep(unsigned int timeout_ms)
Uses GUtility() and G_UTIL_SLEEP to provide a blocking sleep call which can be useful for timing-base...
GCLIB_DLL_EXPORTED GReturn GCALL GCmdI(GCon g, GCStringIn command, int *value)
Wrapper around GCommand that provides the return value of a command parsed into an int.
GCLIB_DLL_EXPORTED GReturn GCALL GCmd(GCon g, GCStringIn command)
Wrapper around GCommand for use when the return value is not desired.
int GReturn
Every function returns a value of type GReturn. See gclib_errors.h for possible values.
#define G_SMALL_BUFFER
Most reads from Galil are small. This value will easily hold most, e.g. TH, TZ, etc.
void * GCon
Connection handle. Unique for each connection in process. Assigned a non-zero value in GOpen().
void e(GReturn rc)
A trivial, C++ style return code check used in Galil's examples and demos.
GReturn contour(GCon g, char *fileA, char *fileB)
Record user's training and plays back training through contour mode.
GReturn record_position(GCon g, char *fileA, char *fileB)
Record user's training and saves to a text file.
bool load_buf(GCon g, const std::vector< int > &positions_A, const std::vector< int > &positions_B, int capacity, int &cmd)
Loads contour buffer with commands from the given text file.
std::vector< int > csv_to_vector(ifstream &is)
Converts a file of comma separated values to a vector.