17 throw string(
"1010 TIMEOUT ERROR. Galil::command() took longer than timeout to return\n");
21 throw string(
"5002 OPEN ERROR. Galil::Galil() failed to open device\n");
25 throw string(
"7020 INVALID COMMAND ERROR. DL, ED, and QD are not allowed from Galil::command()\n");
29 throw string(
"6150 WRONG BUS ERROR. Galil::record(\"DR\") not supported on RS-232. Use Ethernet or Galil::record(\"QR\")\n");
33 throw string(
"6130 WRONG BUS ERROR. Galil::firmwareDownloadFile() isn't allowed via Ethernet. Use RS-232\n");
37 throw string(
"7060 INVALID CHARACTER ERROR. Galil::programDownload() can't download program with backslash \\ character. Use {^92} in MG commands\n");
41 throw string(
"7061 INVALID LENGTH ERROR. Galil::programDownload() can't compress\n");
45 throw string(
"2010 COMMAND ERROR. Galil::command() got ? instead of : response.\n");
49 throw string(
"4000 FILE ERROR. Galil::Galil() failed to open file\n");
53 throw string(
"6000 WRONG BUG ERROR. Function isn't allowed on this bus\n");
83 throw string(
"5005 OPEN ERROR. Null string specified in Galil::Galil()\n");
86 throw string(
"5001 OPEN ERROR. OFFLINE specified to Galil::Galil()\n");
109 for (
i = 0;
i <
args.size() - 1;
i++)
113 else if (
args[
i] ==
"-udp")
address.append(
"--command UDP ");
114 else if ((
args[
i] ==
"-ei") && (
args[++
i] ==
"0"))
ei =
false;
115 else if ((
args[
i] ==
"-mg") && (
args[++
i] ==
"0"))
mg =
false;
116 else if ((
args[
i] ==
"-dr") && (
args[++
i] ==
"0"))
dr =
false;
118 else if (
args[
i] ==
"-s")
125 else if (
args[
i] ==
"-d") ++
i;
126 else if (
args[
i] ==
"-l") ++
i;
127 else if (
args[
i].
find(
"COM") != string::npos)
144string Galil::libraryVersion()
148 return "Galil2.dll wrapper, gclib " + string(
buf);
161 for (
size_t i = 0;
i < len;
i++)
186Galil::Galil(std::string
address)
192 d->InitializeDataRecord();
201string Galil::connection()
203 ec(
GInfo(d->g, d->tbuf,
sizeof(d->tbuf)));
204 return string(d->tbuf);
207string Galil::command(
const std::string& command,
const std::string&
terminator,
const std::string&
ack,
bool trim)
214 ec(
GTimeout(d->g, (
short)timeout_ms));
218 ec(
GCmdT(d->g, command.c_str(), d->tbuf,
sizeof(d->tbuf), &
response));
229double Galil::commandValue(
const std::string& command)
232 ec(
GTimeout(d->g, (
short)timeout_ms));
238string Galil::message(
int timeout_ms)
254 rc =
GMessage(d->g, d->tbuf,
sizeof(d->tbuf));
263 return string(d->tbuf);
267int Galil::interrupt(
int timeout_ms)
269 ec(
GTimeout(d->g, (
short)timeout_ms));
277string Galil::programUpload()
279 ec(
GTimeout(d->g, (
short)timeout_ms));
282 return string(d->tbuf);
285void Galil::programDownload(
const std::string&
program)
287 ec(
GTimeout(d->g, (
short)timeout_ms));
292void Galil::programUploadFile(
const std::string&
file)
294 ec(
GTimeout(d->g, (
short)timeout_ms));
299void Galil::programDownloadFile(
const std::string&
file)
301 ec(
GTimeout(d->g, (
short)timeout_ms));
308 ec(
GTimeout(d->g, (
short)timeout_ms));
313 int len =
strlen(d->tbuf);
314 char*
start = d->tbuf;
315 for (
int i = 0;
i < len;
i++)
317 if (d->tbuf[
i] ==
'\r')
327void Galil::arrayDownload(
const std::vector<double>&
array,
const std::string& name)
331 for (
size_t i = 0;
i <
array.size();
i++)
336 ec(
GTimeout(d->g, (
short)timeout_ms));
339 string command =
"DA " + name +
"[]";
340 ec(
GCmd(d->g, command.c_str()));
342 ec(
GCmd(d->g, command.c_str()));
348void Galil::arrayUploadFile(
const std::string&
file,
const std::string&
names)
350 ec(
GTimeout(d->g, (
short)timeout_ms));
355void Galil::arrayDownloadFile(
const std::string&
file)
357 ec(
GTimeout(d->g, (
short)timeout_ms));
362void Galil::firmwareDownloadFile(
const std::string&
file)
364 ec(
GTimeout(d->g, (
short)timeout_ms));
369int Galil::write(
const std::string&
bytes)
371 ec(
GTimeout(d->g, (
short)timeout_ms));
374 return bytes.length();
379 ec(
GTimeout(d->g, (
short)timeout_ms));
string AddressConvert(const string &gcl_address)
Takes a GCL address string and returns the equivalent gclib address string.
#define G_BAD_RESPONSE_QUESTION_MARK
Operation received a ?, indicating controller has a TC error.
#define G_DATA_RECORD_ERROR
Data record error, e.g. DR attempted on serial connection.
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.
#define G_COMMAND_CALLED_WITH_ILLEGAL_COMMAND
GCommand() was called with an illegal command, e.g. ED, DL or QD.
#define G_CR
For GArrayUpload(), use this value in the delim field to delimit with carriage returns.
GCLIB_DLL_EXPORTED GReturn GCALL GArrayDownloadFile(GCon g, GCStringIn file_path)
Array download from file.
int GReturn
Every function returns a value of type GReturn. See gclib_errors.h for possible values.
GCLIB_DLL_EXPORTED GReturn GCALL GFirmwareDownload(GCon g, GCStringIn filepath)
Upgrade firmware.
GCLIB_DLL_EXPORTED GReturn GCALL GArrayUploadFile(GCon g, GCStringIn file_path, GCStringIn names)
Array upload to file.
GCLIB_DLL_EXPORTED GReturn GCALL GClose(GCon g)
Closes a connection to a Galil Controller.
GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownloadFile(GCon g, GCStringIn file_path, GCStringIn preprocessor)
Program download from file.
#define G_SMALL_BUFFER
Most reads from Galil are small. This value will easily hold most, e.g. TH, TZ, etc.
GCLIB_DLL_EXPORTED GReturn GCALL GTimeout(GCon g, short timeout_ms)
Uses GUtility() and G_UTIL_TIMEOUT_OVERRIDE to set the library timeout.
unsigned char GStatus
Interrupt status byte.
GCLIB_DLL_EXPORTED GReturn GCALL GVersion(GCStringOut ver, GSize ver_len)
Uses GUtility(), G_UTIL_VERSION and G_UTIL_GCAPS_VERSION to provide the library and gcaps version num...
#define G_OPEN_ERROR
Device could not be opened. E.G. Serial port or PCI device already open.
#define G_NO_ERROR
Return value if function succeeded.
#define G_BOUNDS
For functions that take range options, e.g. GArrayUpload(), use this value for full range.
GCLIB_DLL_EXPORTED GReturn GCALL GCommand(GCon g, GCStringIn command, GBufOut buffer, GSize buffer_len, GSize *bytes_returned)
Performs a command-and-response transaction on the connection.
GCLIB_DLL_EXPORTED GReturn GCALL GInterrupt(GCon g, GStatus *status_byte)
Provides access to PCI and UDP interrupts from the controller.
unsigned int GSize
Size of buffers, etc.
GCLIB_DLL_EXPORTED GReturn GCALL GWrite(GCon g, GBufIn buffer, GSize buffer_len)
Performs a write on the connection.
GCLIB_DLL_EXPORTED GReturn GCALL GArrayDownload(GCon g, const GCStringIn array_name, GOption first, GOption last, GCStringIn buffer)
Downloads array data to a pre-dimensioned array in the controller's array table.
GCLIB_DLL_EXPORTED GReturn GCALL GProgramUpload(GCon g, GBufOut buffer, GSize buffer_len)
Uploads a program from the controller's program buffer.
#define G_FIRMWARE_LOAD_NOT_SUPPORTED
Firmware is not supported on this bus, e.g. Ethernet for the DMC-21x3 series.
void * GCon
Connection handle. Unique for each connection in process. Assigned a non-zero value in GOpen().
GCLIB_DLL_EXPORTED void GCALL GError(GReturn rc, GCStringOut error, GSize error_len)
Provides a human-readable description string for return codes.
GCLIB_DLL_EXPORTED GReturn GCALL GProgramUploadFile(GCon g, GCStringIn file_path)
Program upload to file.
GCLIB_DLL_EXPORTED GReturn GCALL GMessage(GCon g, GCStringOut buffer, GSize buffer_len)
Provides access to unsolicited messages from the controller.
#define G_UNSUPPORTED_FUNCTION
Function cannot be called on this bus. E.G. GInterrupt() on serial.
#define G_BAD_FILE
Bad file path, bad file contents, or bad write.
GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownload(GCon g, GCStringIn program, GCStringIn preprocessor)
Downloads a program to the controller's program buffer.
GCLIB_DLL_EXPORTED GReturn GCALL GInfo(GCon g, GCStringOut info, GSize info_len)
Uses GUtility() and G_UTIL_INFO to provide a useful connection string.
GCLIB_DLL_EXPORTED GReturn GCALL GCmdD(GCon g, GCStringIn command, double *value)
Wrapper around GCommand that provides the return value of a command parsed into a double.
#define G_GCLIB_NON_BLOCKING_READ_EMPTY
GMessage, GInterrupt, and GRecord can be called with a zero timeout. If there wasn't data waiting in ...
GCLIB_DLL_EXPORTED GReturn GCALL GRead(GCon g, GBufOut buffer, GSize buffer_len, GSize *bytes_read)
Performs a read on the connection.
GCLIB_DLL_EXPORTED GReturn GCALL GCmd(GCon g, GCStringIn command)
Wrapper around GCommand for use when the return value is not desired.
#define G_UNABLE_TO_COMPRESS_PROGRAM_TO_FIT
Program preprocessor could not compress the program within the user's constraints.
GCLIB_DLL_EXPORTED GReturn GCALL GAddresses(GCStringOut addresses, GSize addresses_len)
Uses GUtility(), G_UTIL_GCAPS_ADDRESSES or G_UTIL_ADDRESSES to provide a listing of all available con...
GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon *g)
Open a connection to a Galil Controller.
#define G_TIMEOUT
Operation timed out. Timeout is set by the –timeout option in GOpen() and can be overriden by GSettin...
GCLIB_DLL_EXPORTED GReturn GCALL GArrayUpload(GCon g, const GCStringIn array_name, GOption first, GOption last, GOption delim, GBufOut buffer, GSize buffer_len)
Uploads array data from the controller's array table.
#define G_ILLEGAL_DATA_IN_PROGRAM
Data to download not valid, e.g. \ in data.
GReturn vector(GCon g, char *file)
Puts controller into Vector Mode and accepts a file defining vector points.