src/p/y/python-cookbook-HEAD/cb2_examples/cb2_17_4_sol_1.py python-cookbook(Download)
from ctypes import windll, c_int, c_string, byref
# load 'Ehllapi.dll' (from current dir), and function 'hllapi' from the DLL
Ehllap32 = windll.ehllapi
hllapi = Ehllap32.hllapi
# prepare the arguments with types and initial values
h_func = c_int(1)
h_text = c_string('A')
h_len = c_int(1)
h_ret = c_int(999)
src/p/y/pysundials-HEAD/2.3.0/examples/cvodes/serial/cvsadjdenx.py pysundials(Download)
cvodes.CVodeSetQuadErrCon(cvode_mem, True, cvodes.CV_SS, reltolQ, abstolQ) time = cvodes.realtype(0.0) ncheck = ctypes.c_int(0) steps = 150 cvadj_mem = cvodes.CVadjMalloc(cvode_mem, steps, cvodes.CV_HERMITE)
src/p/y/pysundials-HEAD/2.3.0/examples/cvodes/serial/cvsadjkryx_pnt.py pysundials(Download)
tnext = 1e-08 t = cvodes.realtype(T0) ncheck = ctypes.c_int(0) rewt = cvodes.NVector([0]*NEQ) wdata = WebData() for i in range(NGRP):
src/p/y/pysundials-HEAD/2.3.0/examples/cvodes/serial/cvsadjkryx_int.py pysundials(Download)
tnext = 1e-08 t = cvodes.realtype(T0) ncheck = ctypes.c_int(0) rewt = cvodes.NVector([0]*(NEQ+1)) wdata = WebData() for i in range(NGRP):
src/p/y/pysundials-HEAD/2.3.0/examples/cvodes/serial/cvsadjbanx.py pysundials(Download)
#begin main code t = cvodes.realtype(0) ncheck = ctypes.c_int(0) reltol = 0 abstol = 1.0e-5
src/d/a/DAQpy-HEAD/examples/test_system.py DAQpy(Download)
DATA_BUFFER_SIZE = samplesPerChannel / iterations DataBuffer = ctypes.c_double * DATA_BUFFER_SIZE data = DataBuffer() samplesRead = ctypes.c_int() c_daqmx.DAQmxReadAnalogF64(taskHandle, DATA_BUFFER_SIZE, 10.0, c_daqmx.DAQmx_Val_GroupByChannel, data, DATA_BUFFER_SIZE, ctypes.byref(samplesRead), None) assert samplesRead.value == DATA_BUFFER_SIZE, "%s != %s" % (samplesRead.value, DATA_BUFFER_SIZE) totalSamples += samplesRead.value
DATA_BUFFER_SIZE = nSamples DataBuffer = ctypes.c_double * DATA_BUFFER_SIZE data = DataBuffer() samplesRead = ctypes.c_int() try: c_daqmx.DAQmxReadAnalogF64(taskHandle, DATA_BUFFER_SIZE, 10.0, c_daqmx.DAQmx_Val_GroupByChannel, data, DATA_BUFFER_SIZE, ctypes.byref(samplesRead), None)
src/d/a/DAQpy-HEAD/examples/daqmxtest.py DAQpy(Download)
DATA_BUFFER_SIZE = 1000 DataBuffer = ctypes.c_double * DATA_BUFFER_SIZE data = DataBuffer() samplesRead = ctypes.c_int() c_daqmx.DAQmxReadAnalogF64(taskHandle, DATA_BUFFER_SIZE, 10.0, c_daqmx.DAQmx_Val_GroupByChannel, data, DATA_BUFFER_SIZE, ctypes.byref(samplesRead), None) print "Acquired %d points" % samplesRead.value
def every_n_callback(taskHandle, everyNSamplesEventType, nSamples, callbackData): # Read Code DATA_BUFFER_SIZE = nSamples DataBuffer = ctypes.c_double * DATA_BUFFER_SIZE data = DataBuffer() samplesRead = ctypes.c_int() c_daqmx.DAQmxReadAnalogF64(taskHandle, DATA_BUFFER_SIZE, 10.0, c_daqmx.DAQmx_Val_GroupByChannel, data, DATA_BUFFER_SIZE, ctypes.byref(samplesRead), None)
src/p/y/pycamiface-HEAD/motmot/cam_iface/cam_iface_ctypes.py pycamiface(Download)
def get_num_modes(device_number):
num_modes = ctypes.c_int()
c_cam_iface.cam_iface_get_num_modes(device_number,
ctypes.byref(num_modes))
return num_modes.value
def get_mode_string(device_number, mode_number):
def grab_next_frame_blocking(self,timeout=-1.0):
if THREAD_DEBUG:
if self.mythread!=threading.currentThread():
raise RuntimeError("Camera class is not thread safe!")
l = ctypes.c_int(0)
t = ctypes.c_int(0)
w = ctypes.c_int(0)
h = ctypes.c_int(0)
def grab_next_frame_into_alloced_buf_blocking(self,buf_alloc,bypass_buffer_checks=False):
"""grab frame into a newly allocated buffer using user allocation function"""
if THREAD_DEBUG:
if self.mythread!=threading.currentThread():
raise RuntimeError("Camera class is not thread safe!")
l = ctypes.c_int(0)
t = ctypes.c_int(0)
h = ctypes.c_int(0)
w = ctypes.c_int(0)
def get_num_camera_properties(self):
if THREAD_DEBUG:
if self.mythread!=threading.currentThread():
raise RuntimeError("Camera class is not thread safe!")
val = ctypes.c_int()
c_cam_iface.CamContext_get_num_camera_properties(self.cval,ctypes.byref(val))
_check_error()
def get_camera_property(self,property_number):
if THREAD_DEBUG:
if self.mythread!=threading.currentThread():
raise RuntimeError("Camera class is not thread safe!")
Value = ctypes.c_long(0)
Auto = ctypes.c_int(0)
c_cam_iface.CamContext_get_camera_property(self.cval,
def get_max_width(self):
if THREAD_DEBUG:
if self.mythread!=threading.currentThread():
raise RuntimeError("Camera class is not thread safe!")
max_width = ctypes.c_int(0)
max_height = ctypes.c_int(0)
c_cam_iface.CamContext_get_max_frame_size(self.cval,
def get_max_height(self):
if THREAD_DEBUG:
if self.mythread!=threading.currentThread():
raise RuntimeError("Camera class is not thread safe!")
max_width = ctypes.c_int(0)
max_height = ctypes.c_int(0)
c_cam_iface.CamContext_get_max_frame_size(self.cval,
def get_frame_roi(self):
if THREAD_DEBUG:
if self.mythread!=threading.currentThread():
raise RuntimeError("Camera class is not thread safe!")
left = ctypes.c_int(0)
top = ctypes.c_int(0)
width = ctypes.c_int(0)
height = ctypes.c_int(0)
def get_num_trigger_modes(self):
if THREAD_DEBUG:
if self.mythread!=threading.currentThread():
raise RuntimeError("Camera class is not thread safe!")
num_modes = ctypes.c_int(0)
c_cam_iface.CamContext_get_num_trigger_modes(self.cval,
ctypes.byref(num_modes))
def get_trigger_mode_number(self):
if THREAD_DEBUG:
if self.mythread!=threading.currentThread():
raise RuntimeError("Camera class is not thread safe!")
val = ctypes.c_int(0)
c_cam_iface.CamContext_get_trigger_mode_number(self.cval,
ctypes.byref(val))
def set_trigger_mode_number(self,source):
if THREAD_DEBUG:
if self.mythread!=threading.currentThread():
raise RuntimeError("Camera class is not thread safe!")
source = ctypes.c_int(source)
c_cam_iface.CamContext_set_trigger_mode_number(self.cval, source)
_check_error()
def get_num_framebuffers(self):
if THREAD_DEBUG:
if self.mythread!=threading.currentThread():
raise RuntimeError("Camera class is not thread safe!")
val = ctypes.c_int(0)
c_cam_iface.CamContext_get_num_framebuffers(self.cval,
ctypes.byref(val))
src/p/y/pysces-HEAD/trunk/pysces_pysundials/pysundials/cvodes.py pysces(Download)
def CVodeGetLastOrder(cvodememobj):
"""CVodeGetLastOrder returns the order used during the last internal step\n\tcvodememobj\ta CvodeMemObj as returned by CvodeCreate()"""
retval = ctypes.c_int()
ret = cvodes.CVodeGetLastOrder(cvodememobj.obj, ctypes.byref(retval))
if ret < 0:
raise AssertionError("SUNDIALS ERROR: CVodeGetLastOrder() failed with flag %i"%(ret))
return retval.value
cvodes.CVodeGetLastOrder.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_int)]
cvodes.CVodeGetLastOrder.restype = ctypes.c_int
def CVodeGetCurrentOrder(cvodememobj):
"""CVodeGetCurrentOrder returns the order to be used on the next internal step\n\tcvodememobj\ta CvodeMemObj as returned by CvodeCreate()"""
retval = ctypes.c_int()
def CVodeGetIntegratorStats(cvodememobj): """A convenience function which returns a tuple of all available integrator stats.\n\tcvodememobj\ta CvodeMemObj as returned by CvodeCreate()\n\nReturn tuple is of he format:\n \n\t(nsteps, nfevals, nlinsetups, netfails, qlast, qcur, hinused, hlast, hcur, tcur) where: \n\t\tnsteps: cumulative number of internal steps taken by the solver \n\t\tnfevals: number of rhs evaluations \n\t\tnlinsetups: number of calls to the linear setup function \n\t\tnetfails: number of local error test failures \n\t\tqlast: order used during ast internal step \n\t\tqcur: order to be used on next internal step \n\t\thinused: actual initial step size ised by CVODES \n\t\thlast: last step size used by CVODES \n\t\thcur: next step size to be used by CVODES \n\t\ttcur = current time""" nsteps = ctypes.c_long() nfevals = ctypes.c_long() nlinsetups = ctypes.c_long() netfails = ctypes.c_long() qlast = ctypes.c_int() qcur = ctypes.c_int()
def CVodeGetSensDky(cvodememobj):
t = ctypes.c_int(0)
ret = cvodes.CVodeGetSensDky(cvodememobj.obj, ctypes.byref(t), k, dkyA.data)
if ret < 0:
raise AssertionError("SUNDIALS ERROR: CVodeGetSensDky() failed with flag %i"%(ret))
return t.value
cvodes.CVodeGetSensDky.argtypes = [ctypes.c_void_p, realtype, ctypes.c_int, ctypes.POINTER(ctypes.POINTER(nvecserial._NVector))]
def CVadjGetCurrentCheckPoint(cvadj_mem):
addr = ctypes.c_int(0)
ret = cvodes.CVadjGetCurrentCheckPoint(cvadj_mem, ctypes.byref(addr))
if ret < 0:
raise AssertionError("SUNDIALS ERROR: CVadjGetCurrentCheckPoint() failed with flag %i"%(ret))
return addr.value
cvodes.CVadjGetCurrentCheckPoint.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)]
def CVDiagGetLastFlag(cvodes_mem):
"""CVDiagGetLastFlag returns the last error flag set by any of the CVDIAG interface functions."""
retval = ctypes.c_int(0)
ret = cvodes.CVDiagGetLastFlag(cvodes_mem, ctypes.byref(retval))
if ret < 0:
raise AssertionError("SUNDIALS ERROR: CVDiagGetLastFlag() failed with flag %i"%(ret))
return retval
def CVBandGetLastFlag(cvodememobj):
"""CVBandGetLastFlag returns the last error flag set by any of the CVBAND interface functions."""
retval = ctypes.c_int()
ret = cvodes.CVBandGetLastFlag(cvodememobj.obj, ctypes.byref(retval))
if ret < 0:
raise AssertionError("SUNDIALS ERROR: CVBandGetNumRhsEvals() failed with flag %i"%(ret))
return retval.value
def CVDenseGetLastFlag(cvodememobj):
"""CVDenseGetLastFlag returns the last error flag set by any of the CVDENSE interface functions."""
retval = ctypes.c_int()
ret = cvodes.CVDenseGetLastFlag(cvodememobj.obj, ctypes.byref(retval))
if ret < 0:
raise AssertionError("SUNDIALS ERROR: CVDenseGetNumRhsEvals() failed with flag %i"%(ret))
return retval.value
def CVSpilsGetLastFlag(cvodememobj):
"""CVSpilsGetLastFlag returns the last error flag set by any of the CVSPILS interface functions."""
flag = ctypes.c_int(0)
ret = cvodes.CVSpilsGetLastFlag(cvodememobj.obj, ctypes.byref(flag))
if ret < 0:
raise AssertionError("SUNDIALS ERROR: CVSpilsGetLastFlag() failed with flag %i"%(ret))
return flag.value
src/p/y/pysces-HEAD/trunk/pysces_pysundials/pysundials/ida.py pysces(Download)
def IDAGetLastOrder(ida_mem):
klast = ctypes.c_int(0)
ret = ida.IDAGetLastOrder(ida_mem.obj, ctypes.byref(klast))
if ret < 0:
raise AssertionError("SUNDIALS ERROR: IDAGetLastOrder() failed with flag %i"%(ret))
return klast.value
ida.IDAGetLastOrder.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_int)]
ida.IDAGetLastOrder.restype = ctypes.c_int
def IDAGetCurrentOrder(ida_mem):
kcur = ctypes.c_int(0)
def IDAGetActualInitStep(ida_mem):
hinused = ctypes.c_int(0)
ret = ida.IDAGetActualInitStep(ida_mem.obj, ctypes.byref(hinused))
if ret < 0:
raise AssertionError("SUNDIALS ERROR: IDAGetActualInitStep() failed with flag %i"%(ret))
return hinused.value
ida.IDAGetActualInitStep.argtypes = [ctypes.c_void_p, ctypes.POINTER(realtype )]
def IDAGetIntegratorStats(ida_mem): nsteps = ctypes.c_long(0) nrevals = ctypes.c_long(0) nlinsetups = ctypes.c_long(0) netfails = ctypes.c_long(0) qlast = ctypes.c_int(0) qcur = ctypes.c_int(0)
def IDABandGetLastFlag(ida_mem):
flag = ctypes.c_int(0)
ret = ida.IDABandGetLastFlag(ida_mem.obj, ctypes.byref(flag))
if ret < 0:
raise AssertionError("SUNDIALS ERROR: IDABandGetLastFlag() failed with flag %i"%(ret))
return flag.value
ida.IDABandGetLastFlag.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_int)]
def IDADenseGetLastFlag(ida_mem):
flag = ctypes.c_int(0)
ret = ida.IDADenseGetLastFlag(ida_mem.obj, ctypes.byref(flag))
if ret < 0:
raise AssertionError("SUNDIALS ERROR: IDADenseGetLastFlag() failed with flag %i"%(ret))
return flag.value
ida.IDADenseGetLastFlag.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_int)]
def IDASpilsGetLastFlag(ida_mem):
flag = ctypes.c_int(0)
ret = ida.IDASpilsGetLastFlag(ida_mem.obj, ctypes.byref(flag))
if ret < 0:
raise AssertionError("SUNDIALS ERROR: IDASpilsGetLastFlag() failed with flag %i"%(ret))
return flag.value
ida.IDASpilsGetLastFlag.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_int)]
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next