T3SP-D4MX Operator’s Manual
3.2.3 Python
Interfacing the
cDMXU.dll
shared library from Python can be achieved by
using the
ctypes
foreign function library. It provides C compatible data
types, and allows calling functions in shared libraries. It can be used to wrap
these libraries in pure Python, as shown in the following example:
import
os
from
ctypes
import
*
# set DLL path and check availability
dll = "c:\\MY_PATH\\cDMXUD.dll"
assert(os.path.isfile(dll)), "MUX error: DLL not found"
# load DLL
mux = cdll.LoadLibrary(dll)
# setup argument and result types
mux.cDMXU_Init.restype = c_int
mux.cDMXU_Init.argtypes = [c_char_p]
mux.cDMXU_IsInitialized.restype = c_int
mux.cDMXU_IsInitialized.argtypes = []
mux.cDMXU_SetChannel.restype = c_int
mux.cDMXU_SetChannel.argtypes = [c_int]
mux.cDMXU_GetChannel.restype = c_int
mux.cDMXU_GetChannel.argtypes = []
mux.cDMXU_GetSerialNumber.restype = c_int
mux.cDMXU_GetSerialNumber.argtypes = []
mux.cDMXU_GetNumberOfChannels.restype = c_int
mux.cDMXU_GetNumberOfChannels.argtypes = []
mux.cDMXU_Release.restype = c_int
mux.cDMXU_Release.argtypes = []
14
933407 Rev1