try: while True: # Get dynamic data (spindle load, feed, speed) dyn_data = focas.cnc_rddynamic(handle, 0) # 0 = current block
# Example pattern: open connection, call function, close lib = focas handle = UDINT(0) # cnc_connect is cnc_allclibhndl3 or cnc_allclibhndl? # use appropriate function names and signatures from FOCAS manual # pseudo: # ret = lib.cnc_allclibhndl3(b"127.0.0.1", 8193, ctypes.byref(handle)) # if ret == 0: ... call functions ... lib.cnc_freelibhndl(handle) fanuc focas python
def disconnect(self): if self.handle: focas.cnc_freelibhndl(self.handle) try: while True: # Get dynamic data (spindle
# Load FOCAS2 DLL focas = ctypes.CDLL("focas1.dll") # or focas2.dll # typedefs UDINT = ctypes.c_uint32 SHORT = ctypes.c_short # example: read system info (CNC alarm or macro programs vary by machine) cnc_getinfo = focas.cnc_getinfo # placeholder function name # set argtypes/restype per FOCAS docs before calling # cnc_getinfo.argtypes = [...] # cnc_getinfo.restype = SHORT speed) dyn_data = focas.cnc_rddynamic(handle