4Python wrapper for Galil gclib.
5Contact softwaresupport@galil.com with questions, comments, and suggestions.
16 WinDLL(
r'C:\Program Files (x86)\Galil\gclib\dll\x64\libcrypto-1_1-x64.dll')
17 WinDLL(
r'C:\Program Files (x86)\Galil\gclib\dll\x64\libssl-1_1-x64.dll')
18 _gclib_path =
r'C:\Program Files (x86)\Galil\gclib\dll\x64\gclib.dll'
19 _gclibo_path =
r'C:\Program Files (x86)\Galil\gclib\dll\x64\gclibo.dll'
20 _gclib =
WinDLL(_gclib_path)
21 _gclibo =
WinDLL(_gclibo_path)
23 WinDLL(
r'C:\Program Files (x86)\Galil\gclib\dll\x86\libcrypto-1_1.dll')
24 WinDLL(
r'C:\Program Files (x86)\Galil\gclib\dll\x86\libssl-1_1.dll')
25 _gclib_path =
r'C:\Program Files (x86)\Galil\gclib\dll\x86\gclib.dll'
26 _gclibo_path =
r'C:\Program Files (x86)\Galil\gclib\dll\x86\gclibo.dll'
27 _gclib =
WinDLL(_gclib_path)
28 _gclibo =
WinDLL(_gclibo_path)
31 setattr(_gclib,
'GArrayDownload',
getattr(_gclib,
'_GArrayDownload@20'))
32 setattr(_gclib,
'GArrayUpload',
getattr(_gclib,
'_GArrayUpload@28'))
35 setattr(_gclib,
'GFirmwareDownload',
getattr(_gclib,
'_GFirmwareDownload@8'))
39 setattr(_gclib,
'GProgramDownload',
getattr(_gclib,
'_GProgramDownload@12'))
40 setattr(_gclib,
'GProgramUpload',
getattr(_gclib,
'_GProgramUpload@12'))
43 setattr(_gclibo,
'GArrayDownloadFile',
getattr(_gclibo,
'_GArrayDownloadFile@8'))
44 setattr(_gclibo,
'GArrayUploadFile',
getattr(_gclibo,
'_GArrayUploadFile@12'))
48 setattr(_gclibo,
'GIpRequests',
getattr(_gclibo,
'_GIpRequests@8'))
49 setattr(_gclibo,
'GMotionComplete',
getattr(_gclibo,
'_GMotionComplete@8'))
50 setattr(_gclibo,
'GProgramDownloadFile',
getattr(_gclibo,
'_GProgramDownloadFile@12'))
52 setattr(_gclibo,
'GProgramUploadFile',
getattr(_gclibo,
'_GProgramUploadFile@8'))
55 setattr(_gclibo,
'GSetupDownloadFile',
getattr(_gclibo,
'_GSetupDownloadFile@20'))
56 setattr(_gclibo,
'GServerStatus',
getattr(_gclibo,
'_GServerStatus@8'))
58 setattr(_gclibo,
'GListServers',
getattr(_gclibo,
'_GListServers@8'))
59 setattr(_gclibo,
'GPublishServer',
getattr(_gclibo,
'_GPublishServer@12'))
60 setattr(_gclibo,
'GRemoteConnections',
getattr(_gclibo,
'_GRemoteConnections@8'))
64 _gclib =
CDLL(
"libgclib.so.2")
66 _gclibo =
CDLL(
"libgclibo.so.2")
69 _gclib_path =
'/Applications/gclib/dylib/gclib.0.dylib'
70 _gclibo_path =
'/Applications/gclib/dylib/gclibo.0.dylib'
72 _gclib =
CDLL(_gclib_path)
74 _gclibo =
CDLL(_gclibo_path)
85_GCStringOut = c_char_p
131 """Checks return codes from gclib and raises a python error if result is exceptional."""
138 """Error class for non-zero gclib return codes."""
142 """Represents a single Python connection to a Galil Controller or PLC."""
145 """Constructor for the Connection class. Initializes gclib's handle and read buffer."""
146 self.
_gcon = _GCon(0)
152 """Destructor for the Connection class. Ensures close gets called to release Galil resource (Sockets, Kernel Driver, Com Port, etc)."""
157 """Checks if connection is established, throws error if not."""
158 if self.
_gcon.value ==
None:
163 Opens a connection a galil controller.
164 See the gclib docs for address string formatting.
173 Closes a connection to a Galil Controller.
175 if self.
_gcon.value !=
None:
177 self.
_gcon = _GCon(0)
183 Performs a command-and-response transaction on the connection.
190 return response[:-3].
strip()
195 Provides a blocking sleep call which can be useful for timing-based chores.
203 Provides the gclib version number. Please include the output of this function on all support cases.
208 def GServerStatus(self):
212 def GSetServer(self, server_name):
217 def GListServers(self):
221 def GPublishServer(self, server_name, publish, save):
226 def GRemoteConnections(self):
232 Provides a useful connection string. Please include the output of this function on all support cases.
240 Provides a dictionary of all Galil controllers requesting IP addresses via BOOT-P or DHCP.
242 Returns a dictionary mapping 'model-serial' --> 'mac address'
243 e.g. {'DMC4000-783': '00:50:4c:20:03:0f', 'DMC4103-9998': '00:50:4c:38:27:0e'}
245 Linux/OS X users must be root to use GIpRequests() and have UDP access to bind and listen on port 67.
251 if (line ==
""):
continue
254 ip_req_dict[fields[0] +
'-' + fields[1]] = fields[2]
260 Assigns IP address over the Ethernet to a controller at a given MAC address.
261 Linux/OS X users must be root to use GAssign() and have UDP access to send on port 68.
271 Provides a dictionary of all available connection addresses.
273 Returns a dictionary mapping 'address' -> 'revision reports', where possible
281 addr_dict[fields[0]] = fields[1]
283 addr_dict[fields[0]] =
''
290 Downloads a program to the controller's program buffer.
291 See the gclib docs for preprocessor options.
302 Uploads a program from the controller's program buffer.
311 Program download from file.
312 See the gclib docs for preprocessor options.
322 Program upload to file.
331 Downloads array data to a pre-dimensioned array in the controller's array table.
332 array_data should be a list of values (e.g. int or float)
337 for val
in array_data:
338 array_string +=
str(val) +
","
339 c_data = _GCStringIn(array_string[:-1].
encode(_enc))
346 Uploads the entire controller array table or a subset and saves the data as a csv file specified by file_path.
347 names is optional and should be a list of array names on the controller.
352 c_names = _GCStringIn(
''.
encode(_enc))
354 names_string += name +
' '
356 c_names = _GCStringIn(names_string[:-1].
encode(_enc))
363 Downloads a csv file containing array data at file_path.
373 Uploads array data from the controller's array table.
380 for s
in string_list:
387 Set the library timeout. Set to -1 to use the intitial library timeout, as specified in GOpen.
398 Convenience property read access to timeout value. If -1, gclib uses the initial library timeout, as specified in GOpen.
405 Convenience property write access to timeout value. Set to -1 to use the initial library timeout, as specified in GOpen.
423 Provides access to unsolicited messages from the controller.
432 Blocking call that returns once all axes specified have completed their motion.
441 Provides access to PCI and UDP interrupts from the controller.
450 Downloads specified sectors from a Galil compressed backup (gcb) file to a controller.
452 Returns a dictionary with the controller information stored in the gcb file.
453 If options is specified as 0, an additional "options" key will be in the dictionary indicating the info sectors available in the gcb
466 if (fields[0] ==
""):
continue
467 elif len(fields) >= 2:
468 info_dict[fields[0].
strip(
"\"\'")] = fields[1].
strip(
"\"\'")
470 info_dict[fields[0].
strip(
"\"\'")] =
''
473 info_dict[
"options"] = rc
GProgramUploadFile(self, file_path)
GFirmwareDownload(self, file_path)
GMotionComplete(self, axes)
GArrayUpload(self, name, first, last)
GProgramDownloadFile(self, file_path, preprocessor="")
GSetupDownloadFile(self, file_path, options)
GProgramDownload(self, program, preprocessor="")
GArrayDownloadFile(self, file_path)
GArrayDownload(self, name, first, last, array_data)
GArrayUploadFile(self, file_path, names=[])
GReturn vector(GCon g, char *file)
Puts controller into Vector Mode and accepts a file defining vector points.