Files
cycafe/PyCafeDefs_pub.pxi
2021-03-16 09:33:22 +01:00

214 lines
7.5 KiB
Cython

cdef object py_cb_handle = None
cdef object py_cb_handle_open = None
cdef object cbobjt = None
# ***********public or api***************
# For when with pvdata
cdef public void cy_data_event_handler_wrapper(void * callback,
unsigned int handle,
string pvname,
PVDataHolder pvd) with gil:
global py_cb
#print(" cy_data_event_handler_wrapper=====+++++++++++++++PVDATA++++++(1)= Handle/PVNAME :", handle, pvname)
cdef pvdata data = PVDataHolderToStruct(pvd)
#data.show()
py_cb = <object>(<void *> callback)
#print(" cy_data_event_handler_wrapper=====+++++++++++++++PVDATA++++++(2)= Handle/PVNAME :", handle, pvname)
#print( <object>py_cb)
'''
global handleMonDictGlobal
if handleMonDictGlobal is not None:
for cbobjt, v in handleMonDictGlobal.items():
print("handle", v, "cbobjt", cbobjt)
if v == handle:
cbobjt(handle, pvname, data)
'''
if callback:
cbobjt=<object> (<void *> callback)
#print(" cy_data_event_handler_wrapper=====+++++++++++++++PVDATA++++++(3)= Handle/PVNAME :", handle, pvname)
cbobjt(handle, pvname, data)
#print(" cy_data_event_handler_wrapper=====+++++++++++++++PVDATA++++++(4)= Handle/PVNAME :", handle, pvname)
#with nogil:
#return
cdef public void cy_ctrl_event_handler_wrapper(void * callback,
unsigned int handle,
string pvname,
PVCtrlHolder pvc) with gil:
#print(" cy_data_event_handler_wrapper=====+++++++++++++++PVCTRL++++++= Handle/PVNAME :", handle, pvname)
cdef pvctrl data = PVCtrlHolderToStruct(pvc)
cbobjt=<object> (<void *> callback)
cbobjt(handle, pvname, data)
with nogil:
return
cdef public void cy_event_handler_wrapper(void * callback,
unsigned int handle,
string pvname) with gil:
#print(" cy_event_handler_wrapper=====+++++++++++++++HANDLEPV++++++= Handle/PVNAME :", handle, pvname)
cbobjt=<object> callback
cbobjt(handle, pvname)
with nogil:
return
cdef public void cy_connect_handler_wrapper(void * callback,
unsigned int handle,
string pvname,
int status) with gil:
#print(" cy_connect_handler_wrapper ====+++CONNECT++++++++++= Handle/PV/Status:", handle, pvname, status)
#print(" callback is ", <object> callback)
if callback:
#print(" callback is not None ")
cbobjt=<object> callback
cbobjt(handle, pvname, status)
#print(" cy_connect_handler_wrapper ====+++CONNECT++++++++++ SUCCESS")
#else:
# if str(pvname) in openDictGlobal.keys():
# cbobjt = openDictGlobal[pvname]
# cbobjt(handle, pvname, status)
with nogil:
return
cdef public void py_cb_wrapper(PVDataHolder pvd, unsigned int handle, string pvname) with gil:
print(" py_cb_wrapper ====================================================+++++++++++++++PVDATA++++++= Handle/PVNAME :", handle, pvname)
cdef pvdata pv1 = PVDataHolderToStruct(pvd)
'''
cdef string val
_c_cafe.getCacheString(handle, val)
#print(val, " ", pv1.value[0])
cdef HandleHelper hh
cdef vector[void *] widgetV
widgetV.reserve(2)
widgetList = []
status = hh.getWidgets(handle, widgetV)
for i in range(0, widgetV.size()):
cbobjt = < object > widgetV[i]
cbobjt(pv1, handle, pvname)
widgetList.append( < object > widgetV[i])
#print(widgetList)
'''
'''
global handleMonDictGlobal
if handleMonDictGlobal is not None:
for cbobjt, v in handleMonDictGlobal.items():
print("handle", v, "cbobjt", cbobjt)
if v == handle:
cbobjt(pv1, handle, pvname)
'''
with nogil:
return
cdef public void py_cb_ctrl_wrapper(PVCtrlHolder pvc, unsigned int handle, string pvname) with gil:
#print(" py_cb_ctrl_wrapper ====================================================+++++++++++++++++CTRL+++++= Handle/PVNAME :", handle, pvname)
cdef pvctrl c1 = PVCtrlHolderToStruct(pvc)
'''
global handleMonDictGlobal
cdef object cbobjt = None
for cbobjt, v in handleMonDictGlobal.items():
if v == handle:
cbobjt(c1, handle, pvname)
'''
with nogil:
return
cdef public void py_cb_handle_wrapper(unsigned int handle) with gil:
print(" py_cb_handle_wrapper ====================================================+++++++++++++++++HANDLE+++++= Handle :", handle)
py_cb_handle(handle)
with nogil:
return
# Default
cdef public void py_cb_handle_monid_wrapper(unsigned int handle, unsigned long monid) with gil:
print(" py_cb_handle_monid_wrapper ====================================================+++++++++++++MONID++++++++++= Handle:", handle)
'''
cdef string val
_c_cafe.getCacheString(handle, val)
print(val, " is val")
'''
# if monDictGlobal.has_key(monid):
global monDictGlobal
if monid in monDictGlobal.keys():
cbobjt = monDictGlobal[monid]
cbobjt(handle)
else:
print("CALLBACK NOT FOUND FOR handle/monid", handle, monid)
with nogil:
return
cdef public void py_cb_handle_get_wrapper(unsigned int handle) with gil:
#print(" py_cb_handle_get_wrapper ====================================================+++++++++++++GET++++++++++= Handle:", handle)
# py_cb_handle_get(handle)
global getDictGlobal
if handle in getDictGlobal.keys():
cbobjt = getDictGlobal[handle]
cbobjt(handle)
else:
print("GET CALLBACK NOT FOUND FOR handle", handle)
with nogil:
return
cdef public void py_cb_handle_put_wrapper(unsigned int handle) with gil:
#print(" py_cb_handle_put_wrapper ====================================================+++++++++++++PUT++++++++++= Handle:", handle)
# py_cb_handle_put(handle)
global putDictGlobal
if handle in putDictGlobal.keys():
cbobjt = putDictGlobal[handle]
cbobjt(handle)
else:
print("PUT CALLBACK NOT FOUND FOR handle", handle)
with nogil:
return
cdef public void py_cb_handle_open_wrapper(unsigned int handle, int status) with gil:
# status reports ICAFE_CS_CONN (602) or ICAFE_CS_DISCONN (604)
print(" py_cb_handle_open_wrapper ====================================================+++++++++++++OPEN++++++++++= Handle/Status:", handle, status)
py_cb_handle_open(handle, status)
with nogil:
return
cdef public void py_cb_handle_connect_wrapper(unsigned int handle,
string pvname,
int status) with gil:
print(" py_cb_handle_connect_wrapper ===========================+++CONNECT++++++++++= Handle/PV/Status:", handle, pvname, status)
#py_cb_handle_connect(handle, pvname, status)
global openDictGlobal
for k, y in openDictGlobal.items():
print(k, y)
# if openDictGlobal.has_key(pvname):
if str(pvname) in openDictGlobal.keys():
cbobjt = openDictGlobal[pvname]
cbobjt(handle, pvname, status)
with nogil:
return
# ***********public***************