encoding/decoding str/bytes for utf_8, utf_16, latin-1
This commit is contained in:
+23189
-14318
File diff suppressed because it is too large
Load Diff
+19891
-15647
File diff suppressed because it is too large
Load Diff
+2829
-2507
File diff suppressed because it is too large
Load Diff
+36
-3
@@ -1180,12 +1180,27 @@ cdef pvdata PVDataHolderToStruct(PVDataHolder pvd, dt=None):
|
||||
cdef unsigned int dtcheck = dtn
|
||||
cdef localList = []
|
||||
|
||||
cdef bytes bytesVal
|
||||
|
||||
if dt:
|
||||
dtcheck = getMatchedDataType(dt, dtn)
|
||||
|
||||
if dtcheck == CAFE_STRING:
|
||||
for i in range(0, pvd.getNelem()):
|
||||
localList.append(pvd.getAsString(i))
|
||||
bytesVal = <bytes> pvd.getAsString(i)
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
try:
|
||||
strVal= (bytesVal).decode('latin-1')
|
||||
except UnicodeDecodeError:
|
||||
strVal = pvd.getAsString(i)
|
||||
localList.append(strVal)
|
||||
elif dtcheck == CAFE_SHORT:
|
||||
for i in range(0, pvd.getNelem()):
|
||||
localList.append(pvd.getAsLong(i)) # getAsShort(i)
|
||||
@@ -1268,6 +1283,7 @@ cdef pvctrl PVCtrlHolderToStruct(PVCtrlHolder pvc, dt=None):
|
||||
cdef unsigned int dtn = pvc.getDataType()
|
||||
|
||||
cdef unsigned int dtcheck = dtn
|
||||
cdef bytes bytesVal
|
||||
|
||||
cdef localList = []
|
||||
|
||||
@@ -1276,7 +1292,20 @@ cdef pvctrl PVCtrlHolderToStruct(PVCtrlHolder pvc, dt=None):
|
||||
|
||||
if dtcheck == CAFE_STRING:
|
||||
for i in range(0, pvc.getNelem()):
|
||||
localList.append(pvc.getAsString(i))
|
||||
bytesVal = <bytes> pvc.getAsString(i)
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
try:
|
||||
strVal= (bytesVal).decode('latin-1')
|
||||
except UnicodeDecodeError:
|
||||
strVal = pvc.getAsString(i)
|
||||
localList.append(strVal)
|
||||
elif dtcheck == CAFE_SHORT:
|
||||
for i in range(0, pvc.getNelem()):
|
||||
localList.append(pvc.getAsLong(i)) # getAsShort(i)
|
||||
@@ -1320,10 +1349,14 @@ cdef pvctrl PVCtrlHolderToStruct(PVCtrlHolder pvc, dt=None):
|
||||
|
||||
c1.enumStrings = enumList
|
||||
|
||||
cdef bytes bVal
|
||||
try:
|
||||
c1.units = pvc.getUnits()
|
||||
except UnicodeDecodeError:
|
||||
c1.units = str("")
|
||||
#c1.units = str("")
|
||||
|
||||
bVal = <bytes> pvc.getUnits()
|
||||
c1.units = (bVal).decode('latin-1')
|
||||
|
||||
'''
|
||||
result = isinstance(pvc.getUnits(), (bytes,))
|
||||
|
||||
+576
-55
@@ -418,10 +418,7 @@ cdef class CyCafe:
|
||||
("The pv name entered within list should be "
|
||||
"of type <class 'str'> or <class 'bytes'>")))
|
||||
try:
|
||||
if cb is not None:
|
||||
##for i in range(0, len(pvV)):
|
||||
##self.setPyCallbackConnect(pvV[i], cb)
|
||||
#self.setPyConnectCallbackFn(pvV[i], cb)
|
||||
if cb is not None:
|
||||
self._c_cafe.channelCreatePolicy.setPyCallbackFlag(True)
|
||||
self._c_cafe.channelCreatePolicy.setPyConnectHandler(<void *>cb)
|
||||
|
||||
@@ -470,7 +467,7 @@ cdef class CyCafe:
|
||||
cdef char * pvStr = pv
|
||||
|
||||
if cb is not None:
|
||||
####self.setPyCallbackConnect(pv, cb)
|
||||
|
||||
self._c_cafe.channelCreatePolicy.setPyCallbackFlag(True)
|
||||
self._c_cafe.channelCreatePolicy.setPyConnectHandler(<void *>cb)
|
||||
try:
|
||||
@@ -1590,7 +1587,11 @@ cdef class CyCafe:
|
||||
def getUnits(self, handlePV):
|
||||
cdef string valString
|
||||
self.hh.getUnits(handlePV, valString)
|
||||
return valString
|
||||
cdef bytes bVal
|
||||
bVal = <bytes> valString
|
||||
unicode_units = (bVal).decode('latin-1')
|
||||
return unicode_units
|
||||
|
||||
|
||||
############################################################################
|
||||
@verify_handlepv
|
||||
@@ -2152,12 +2153,44 @@ cdef class CyCafe:
|
||||
cdef unsigned int dtcheck = dtr
|
||||
dtcheck = getMatchedDataType(dt, dtr)
|
||||
|
||||
cdef bytes bVal
|
||||
|
||||
if dtcheck in [CAFE_STRING]:
|
||||
with nogil:
|
||||
status = self._c_cafe.getString(handle, self.valStr)
|
||||
|
||||
if status == ICAFE_NORMAL:
|
||||
return self.valStr
|
||||
bVal = <bytes> self.valStr
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(handle):
|
||||
try:
|
||||
valStr = (bVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
valStr = (bVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
valStr = (bVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
valStr = (bVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
valstr =self.valStr
|
||||
return valStr
|
||||
|
||||
|
||||
elif dtcheck in [CAFE_SHORT, CAFE_CHAR, CAFE_LONG]:
|
||||
with nogil:
|
||||
status = self._c_cafe.getLong(handle, self.valInt)
|
||||
@@ -2296,6 +2329,8 @@ cdef class CyCafe:
|
||||
# cdef vector[short] valShortVector
|
||||
# cdef vector[float] valFloatVector
|
||||
|
||||
cdef bytes bytesVal
|
||||
|
||||
if dtcheck in [CAFE_STRING]:
|
||||
|
||||
valStringArray = <char[40]*> malloc(
|
||||
@@ -2306,7 +2341,31 @@ cdef class CyCafe:
|
||||
|
||||
ll = []
|
||||
for i in range(0, nelemMethod):
|
||||
ll.append(valStringArray[i])
|
||||
|
||||
bytesVal = <bytes> (<string> valStringArray[i])
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(handle):
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf_8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf_16')
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = valStringArray[i]
|
||||
|
||||
ll.append(strVal)
|
||||
|
||||
free(valStringArray)
|
||||
if status == ICAFE_NORMAL:
|
||||
return ll
|
||||
@@ -2524,7 +2583,7 @@ cdef class CyCafe:
|
||||
|
||||
unsigned int i
|
||||
unsigned int ij
|
||||
array.array a
|
||||
array.array aencoding
|
||||
|
||||
cnp.uint8_t[::1] mvUInt8 # C-contiguous
|
||||
cnp.int8_t[::1] mvInt8 # C-contiguous
|
||||
@@ -2612,6 +2671,8 @@ cdef class CyCafe:
|
||||
# The element type of a typed memoryview may be a numeric scalar type (int, float)
|
||||
# It may be a ctypedef alias, or it may be a structured type declared with e.g. cdef struct
|
||||
|
||||
cdef bytes bVal
|
||||
|
||||
if dtcheck in [CAFE_STRING, CAFE_ENUM]:
|
||||
sval = < char[40]* > malloc(nelemMemory * sizeof(dbr_string_t))
|
||||
with nogil:
|
||||
@@ -2632,8 +2693,32 @@ cdef class CyCafe:
|
||||
#mvStr=np.array(self.hh.getNelemRequest(handle), dtype='S40')
|
||||
|
||||
for i in range(0, nelemMethod):
|
||||
# print sval[i].decode('utf8'), i
|
||||
mvStr[i] = str(sval[i]) # .decode('utf8')
|
||||
|
||||
encoding = False
|
||||
bVal = <bytes> (<string> sval[i])
|
||||
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(handle):
|
||||
try:
|
||||
mvStr[i] = (bVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
mvStr[i] = bVal.decode('utf_8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
mvStr[i] = bVal.decode('utf_16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
|
||||
if not encoding:
|
||||
mvStr[i] = sval[i]
|
||||
|
||||
# locallist.append(sval[i])
|
||||
|
||||
free(sval)
|
||||
@@ -3170,13 +3255,13 @@ cdef class CyCafe:
|
||||
if status != ICAFE_NORMAL:
|
||||
if PYCAFE_PRINT_LEVEL >= PYCAFE_PRINT_LOW:
|
||||
self._c_cafe.printStatusMessage(status)
|
||||
for i in range(0, <int>v.size()): #len(handleList)):
|
||||
if (pvd[i].getStatus() != ICAFE_NORMAL):
|
||||
print("Handle=", handleList[i], "PV=",
|
||||
self.hh.getPVFromHandle(handleList[i]))
|
||||
print("with error status=", pvd[i].getStatus())
|
||||
self._c_cafe.printStatusMessage(status)
|
||||
print("")
|
||||
for i in range(0, <int>v.size()): #len(handleList)):
|
||||
if (pvd[i].getStatus() != ICAFE_NORMAL):
|
||||
print("Handle=", handleList[i], "PV=",
|
||||
self.hh.getPVFromHandle(handleList[i]))
|
||||
print("with error status=", pvd[i].getStatus())
|
||||
self._c_cafe.printStatusMessage(status)
|
||||
print("")
|
||||
#raise Exception("EXCEPTION RAISED in PyCafe def getPVList. Status = %d" %status)
|
||||
|
||||
cdef unsigned int dtn
|
||||
@@ -3187,6 +3272,8 @@ cdef class CyCafe:
|
||||
pvdList = []
|
||||
cpdef pvdata p1
|
||||
|
||||
cdef bytes bytesVal
|
||||
|
||||
for i in range(0, <int>v.size()): #len(handleList)):
|
||||
dtn = pvd[i].getDataType()
|
||||
|
||||
@@ -3195,7 +3282,31 @@ cdef class CyCafe:
|
||||
|
||||
if pvd[i].getNelem() == 1:
|
||||
if dtcheck == CAFE_STRING:
|
||||
localList.append(pvd[i].getAsString())
|
||||
bytesVal = <bytes> pvd[i].getAsString()
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(v[i]):
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = pvd[i].getAsString()
|
||||
|
||||
localList.append(strVal)
|
||||
|
||||
elif dtcheck == CAFE_SHORT:
|
||||
localList.append(pvd[i].getAsLong())
|
||||
elif dtcheck == CAFE_FLOAT:
|
||||
@@ -3220,7 +3331,31 @@ cdef class CyCafe:
|
||||
localListInner = []
|
||||
if dtcheck == CAFE_STRING:
|
||||
for j in range(0, pvd[i].getNelem()):
|
||||
localListInner.append(pvd[i].getAsString(j))
|
||||
|
||||
bytesVal = <bytes> pvd[i].getAsString(j)
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(v[i]):
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = pvd[i].getAsString(j)
|
||||
localListInner.append(strVal) #pvd[i].getAsString(j))
|
||||
|
||||
elif dtcheck == CAFE_SHORT:
|
||||
for j in range(0, pvd[i].getNelem()):
|
||||
localListInner.append(pvd[i].getAsLong(j))
|
||||
@@ -3252,6 +3387,7 @@ cdef class CyCafe:
|
||||
p1 = pvdata()
|
||||
p1.value = localList
|
||||
p1.status = pvd[i].getStatus()
|
||||
p1.statusAsString = pvd[i].getStatusAsString()
|
||||
p1.nelem = pvd[i].getNelem()
|
||||
p1.alarmStatus = pvd[i].getAlarmStatus()
|
||||
p1.alarmSeverity = pvd[i].getAlarmSeverity()
|
||||
@@ -3504,6 +3640,9 @@ First input argument, should be a 'list' of of type <class 'int'> if handles or
|
||||
|
||||
#print ("dt=", dt, "dtcheck=", dtcheck)
|
||||
|
||||
localList = []
|
||||
cdef bytes bytesVal
|
||||
|
||||
if dtcheck in [CAFE_STRING]:
|
||||
|
||||
self.vStr.clear()
|
||||
@@ -3516,12 +3655,33 @@ First input argument, should be a 'list' of of type <class 'int'> if handles or
|
||||
self._c_cafe.setNelemToPrevious(
|
||||
handleList[i], nelemPrevious[i])
|
||||
|
||||
# localList=[]
|
||||
# statusList=[]
|
||||
bytesVal = <bytes> (<string> self.vStr[i] )
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(handleList[i]):
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = <string> self.vStr[i]
|
||||
|
||||
localList.append(strVal)
|
||||
|
||||
# for i in range(0, len(self.vStr)):
|
||||
# localList.append( self.vStr[i])
|
||||
return self.vStr, status, vStatus
|
||||
return localList, status, vStatus
|
||||
|
||||
|
||||
elif dtcheck in [CAFE_SHORT, CAFE_CHAR, CAFE_LONG]:
|
||||
|
||||
@@ -3648,7 +3808,32 @@ First input argument, should be a 'list' of of type <class 'int'> if handles or
|
||||
#print (pvd[i].getAsDouble())
|
||||
|
||||
if dtcheck == CAFE_STRING:
|
||||
localList.append(pvd[i].getAsString())
|
||||
bytesVal = <bytes> pvd[i].getAsString()
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(v[i]):
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = pvd[i].getAsString()
|
||||
|
||||
localList.append(strVal)
|
||||
|
||||
#localList.append(pvd[i].getAsString())
|
||||
elif dtcheck == CAFE_SHORT:
|
||||
localList.append(pvd[i].getAsLong())
|
||||
elif dtcheck == CAFE_FLOAT:
|
||||
@@ -3751,6 +3936,8 @@ First input argument, should be a 'list' of of type <class 'int'> if handles or
|
||||
cdef vector[int] vRB
|
||||
status = ICAFE_NORMAL
|
||||
|
||||
cdef bytes bytesVal
|
||||
|
||||
if (cacheFlag == False):
|
||||
# Need to copy to a vector since
|
||||
# Coercion from Python not allowed without the GIL
|
||||
@@ -3800,16 +3987,39 @@ First input argument, should be a 'list' of of type <class 'int'> if handles or
|
||||
with nogil:
|
||||
status = self._c_cafe.getCacheVStr(v, self.vStr, vStatus)
|
||||
|
||||
localList=[]
|
||||
# statusList=[]
|
||||
|
||||
for i in range(0, len(handleList)):
|
||||
self._c_cafe.setNelemToPrevious(
|
||||
handleList[i], nelemPrevious[i])
|
||||
bytesVal = <bytes> (<string> self.vStr[i] )
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(handleList[i]):
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = self.vStr[i]
|
||||
|
||||
localList.append(strVal)
|
||||
|
||||
# localList=[]
|
||||
# statusList=[]
|
||||
|
||||
# for i in range(0, len(self.vStr)):
|
||||
# localList.append( self.vStr[i])
|
||||
return self.vStr, status, vStatus
|
||||
return localList, status, vStatus
|
||||
#return self.vStr, status, vStatus
|
||||
|
||||
elif dtcheck in [CAFE_SHORT, CAFE_CHAR, CAFE_LONG]:
|
||||
|
||||
@@ -3938,7 +4148,32 @@ First input argument, should be a 'list' of of type <class 'int'> if handles or
|
||||
#print (pvd[i].getAsDouble())
|
||||
|
||||
if dtcheck == CAFE_STRING:
|
||||
localList.append(pvd[i].getAsString())
|
||||
|
||||
bytesVal = <bytes> pvd[i].getAsString()
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(v[i]):
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = pvd[i].getAsString()
|
||||
|
||||
localList.append(strVal)
|
||||
|
||||
elif dtcheck == CAFE_SHORT:
|
||||
localList.append(pvd[i].getAsLong())
|
||||
elif dtcheck == CAFE_FLOAT:
|
||||
@@ -4090,6 +4325,9 @@ First input argument, should be a 'list' of of type <class 'int'> if handles or
|
||||
cdef unsigned int dtcheck = CAFE_NOT_REQUESTED # native type not yet know
|
||||
dtcheck = getMatchedDataType(dt, dtcheck)
|
||||
|
||||
cdef bytes bytesVal
|
||||
localList = []
|
||||
|
||||
# Use Scalar
|
||||
if not flagCompound:
|
||||
|
||||
@@ -4100,8 +4338,35 @@ First input argument, should be a 'list' of of type <class 'int'> if handles or
|
||||
|
||||
with nogil:
|
||||
status = self._c_cafe.getCacheVStr(v, self.vStr, vStatus)
|
||||
|
||||
#warning: __pyx_v_i may be used uninitialized in this function
|
||||
bytesVal = <bytes> (<string> self.vStr[i] )
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(v[i]):
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = <string> self.vStr[i]
|
||||
|
||||
localList.append(strVal)
|
||||
|
||||
return self.vStr, status, vStatus
|
||||
return localList, status, vStatus
|
||||
|
||||
|
||||
elif dtcheck in [CAFE_SHORT, CAFE_CHAR, CAFE_LONG]:
|
||||
|
||||
@@ -4166,7 +4431,32 @@ First input argument, should be a 'list' of of type <class 'int'> if handles or
|
||||
|
||||
if pvd[i].getNelem() == 1:
|
||||
if dtcheck == CAFE_STRING:
|
||||
localList.append(pvd[i].getAsString())
|
||||
bytesVal = <bytes> pvd[i].getAsString()
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(v[i]):
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = pvd[i].getAsString()
|
||||
|
||||
localList.append(strVal)
|
||||
|
||||
#localList.append(pvd[i].getAsString())
|
||||
elif dtcheck == CAFE_SHORT:
|
||||
localList.append(pvd[i].getAsLong())
|
||||
elif dtcheck == CAFE_FLOAT:
|
||||
@@ -4190,7 +4480,32 @@ First input argument, should be a 'list' of of type <class 'int'> if handles or
|
||||
localListInner = []
|
||||
if dtcheck == CAFE_STRING:
|
||||
for j in range(0, pvd[i].getNelem()):
|
||||
localListInner.append(pvd[i].getAsString(j))
|
||||
|
||||
bytesVal = <bytes> pvd[i].getAsString(j)
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(v[i]):
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = pvd[i].getAsString(j)
|
||||
|
||||
localListInner.append(strVal)
|
||||
#localListInner.append(pvd[i].getAsString(j))
|
||||
elif dtcheck == CAFE_SHORT:
|
||||
for j in range(0, pvd[i].getNelem()):
|
||||
localListInner.append(pvd[i].getAsLong(j))
|
||||
@@ -4403,10 +4718,36 @@ First input argument, should be of type <class 'int'> if group handle, else <cla
|
||||
cdef unsigned int dtcheck = dtr
|
||||
dtcheck = getMatchedDataType(dt, dtr)
|
||||
|
||||
cdef bytes bVal
|
||||
|
||||
if dtcheck in [CAFE_STRING]:
|
||||
status = self._c_cafe.getCacheString(handle, self.valStr)
|
||||
if status == ICAFE_NORMAL:
|
||||
return self.valStr
|
||||
bVal = <bytes> self.valStr
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(handle):
|
||||
try:
|
||||
strVal = (bVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = self.valStr
|
||||
|
||||
return strVal
|
||||
|
||||
|
||||
elif dtcheck in [CAFE_SHORT, CAFE_CHAR, CAFE_LONG]:
|
||||
status = self._c_cafe.getCacheLong(handle, self.valInt)
|
||||
@@ -4577,7 +4918,34 @@ First input argument, should be of type <class 'int'> if group handle, else <cla
|
||||
if status == ICAFE_NORMAL:
|
||||
|
||||
for i in range(0, nelemToRetrieveFromCache):
|
||||
locallist.append(sval[i])
|
||||
|
||||
bVal = <bytes> (<string> sval[i])
|
||||
encoding = False
|
||||
if '.EGU' in self._c_cafe.getPVFromHandle(handle):
|
||||
try:
|
||||
strVal = (bVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
|
||||
if not encoding:
|
||||
try:
|
||||
valStr = bVal.decode('utf-8')
|
||||
encoded = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
valStr = bVal.decode('utf-16')
|
||||
encoded = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
|
||||
if not encoding:
|
||||
valStr = sval[i]
|
||||
|
||||
|
||||
locallist.append(valStr) #sval[i])
|
||||
|
||||
free(sval)
|
||||
return locallist
|
||||
@@ -5154,9 +5522,7 @@ First input argument, should be of type <class 'int'> if handle, else <class 'st
|
||||
"dbr base type should be one of DBR_PLAIN, DBR_STS, DBR_TIME, DBR_GR, DBR_CTRL")
|
||||
print("Assuming DBR_TIME")
|
||||
dbr = DBR_TIME
|
||||
# Legacy
|
||||
|
||||
|
||||
|
||||
cdef vector[MonitorPolicy] mpV
|
||||
cdef unsigned long mpid
|
||||
|
||||
@@ -5248,8 +5614,6 @@ First input argument, should be of type <class 'int'> if handle, else <class 'st
|
||||
raise Exception("EXCEPTION RAISED IN PyCafe def groupMonitorStartWithCBList. \n\
|
||||
Input cb should be of type<list> and give the list of cb objects")
|
||||
|
||||
|
||||
|
||||
cdef vector[MonitorPolicy] mpV
|
||||
cdef unsigned long mpid
|
||||
# cdef void *ptr_mpid
|
||||
@@ -5392,6 +5756,7 @@ No of group members doe not match the length of callback object list")
|
||||
localList = []
|
||||
statusList = []
|
||||
cdef unsigned int dtn, dtcheck
|
||||
cdef bytes bytesVal
|
||||
|
||||
for i in range(0, pvg.getNPV()):
|
||||
dtn = pvd[i].getDataType()
|
||||
@@ -5402,7 +5767,31 @@ No of group members doe not match the length of callback object list")
|
||||
|
||||
if pvd[i].getNelem() == 1:
|
||||
if dtcheck == CAFE_STRING:
|
||||
localList.append(pvd[i].getAsString())
|
||||
|
||||
bytesVal = <bytes> pvd[i].getAsString()
|
||||
encoding = False
|
||||
if '.EGU' in pvd[i].getPVName():
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf_8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf_16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = pvd[i].getAsString()
|
||||
|
||||
localList.append(strVal) #pvd[i].getAsString())
|
||||
elif dtcheck == CAFE_SHORT:
|
||||
localList.append(pvd[i].getAsLong())
|
||||
elif dtcheck == CAFE_FLOAT:
|
||||
@@ -5427,7 +5816,32 @@ No of group members doe not match the length of callback object list")
|
||||
localListInner = []
|
||||
if dtcheck == CAFE_STRING:
|
||||
for j in range(0, pvd[i].getNelem()):
|
||||
localListInner.append(pvd[i].getAsString(j))
|
||||
|
||||
bytesVal = <bytes> pvd[i].getAsString(j)
|
||||
encoding = False
|
||||
if '.EGU' in pvd[i].getPVName():
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = pvd[i].getAsString(j)
|
||||
|
||||
localListInner.append(strVal) #pvd[i].getAsString(j))
|
||||
|
||||
elif dtcheck == CAFE_SHORT:
|
||||
for j in range(0, pvd[i].getNelem()):
|
||||
localListInner.append(pvd[i].getAsLong(j))
|
||||
@@ -5500,6 +5914,7 @@ No of group members doe not match the length of callback object list")
|
||||
localList = []
|
||||
statusList = []
|
||||
cdef unsigned int dtn, dtcheck
|
||||
cdef bytesVal
|
||||
|
||||
for i in range(0, pvg.getNPV()):
|
||||
dtn = pvd[i].getDataType()
|
||||
@@ -5510,7 +5925,31 @@ No of group members doe not match the length of callback object list")
|
||||
|
||||
if pvd[i].getNelem() == 1:
|
||||
if dtcheck == CAFE_STRING:
|
||||
localList.append(pvd[i].getAsString())
|
||||
|
||||
bytesVal = <bytes> pvd[i].getAsString()
|
||||
encoding = False
|
||||
if '.EGU' in pvd[i].getPVName():
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf_8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf_16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = pvd[i].getAsString()
|
||||
|
||||
localList.append(strVal) #pvd[i].getAsString())
|
||||
elif dtcheck == CAFE_SHORT:
|
||||
localList.append(pvd[i].getAsLong())
|
||||
elif dtcheck == CAFE_FLOAT:
|
||||
@@ -5535,7 +5974,31 @@ No of group members doe not match the length of callback object list")
|
||||
localListInner = []
|
||||
if dtcheck == CAFE_STRING:
|
||||
for j in range(0, pvd[i].getNelem()):
|
||||
localListInner.append(pvd[i].getAsString(j))
|
||||
|
||||
bytesVal = <bytes> pvd[i].getAsString(j)
|
||||
encoding = False
|
||||
if '.EGU' in pvd[i].getPVName():
|
||||
try:
|
||||
strVal = (bytesVal).decode('latin-1')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
strVal = (bytesVal).decode('utf-16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
strVal = pvd[i].getAsString(j)
|
||||
|
||||
localListInner.append(strVal) #pvd[i].getAsString(j))
|
||||
elif dtcheck == CAFE_SHORT:
|
||||
for j in range(0, pvd[i].getNelem()):
|
||||
localListInner.append(pvd[i].getAsLong(j))
|
||||
@@ -6406,11 +6869,39 @@ No of group members doe not match the length of callback object list")
|
||||
vecS.reserve(len(valSet))
|
||||
for i in range(0, len(valSet)):
|
||||
if isinstance(valSet[i], str):
|
||||
#valSet[i] = (<unicode>valSet[i]).encode('utf_8')
|
||||
temp = (valSet[i]).encode('latin-1')
|
||||
#valSet[i] = (<unicode>valSet[i]).encode('utf_8')
|
||||
temp = (valSet[i]).encode('utf_8')
|
||||
elif isinstance(valSet[i], (bytes, bytearray)):
|
||||
encoding = False
|
||||
if not encoding:
|
||||
try:
|
||||
temp = (valSet[i]).decode('utf_8')
|
||||
encoding = True
|
||||
print('utf-8')
|
||||
vecS.push_back(temp.encode('utf_8'))
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
temp = (valSet[i]).decode('utf_16')
|
||||
encoding = True
|
||||
print('utf-16')
|
||||
vecS.push_back(<string>temp.encode('utf_16').decode('utf_16'))
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
temp = (valSet[i]).decode('utf_32')
|
||||
encoding = True
|
||||
print('utf-32')
|
||||
vecS.push_back(temp.encode('utf_32'))
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
else:
|
||||
temp = valSet[i]
|
||||
vecS.push_back(<string> temp)
|
||||
print('utf-none', type(valSet[i]))
|
||||
temp = valSet[i]
|
||||
vecS.push_back(<string> temp)
|
||||
|
||||
with nogil:
|
||||
status = self._c_cafe.setVString(handle, vecS)
|
||||
|
||||
@@ -6476,20 +6967,50 @@ No of group members doe not match the length of callback object list")
|
||||
status = self._c_cafe.setLong(handle, valSetI)
|
||||
elif isinstance(valSet, (str)):
|
||||
#print("str type", valSet)
|
||||
|
||||
valSetS = valSet
|
||||
encoding = False
|
||||
try:
|
||||
valSetS = valSet.encode('utf_8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
valSetS = valSet.encode('utf_16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
|
||||
with nogil:
|
||||
status = self._c_cafe.setString(handle, valSetS)
|
||||
elif isinstance(valSet, (bytes, bytearray)):
|
||||
#print("bytes,bytearray")
|
||||
valSetS = valSet.decode('utf8')
|
||||
encoding = False
|
||||
try:
|
||||
valSetS = valSet.decode('utf_8')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if not encoding:
|
||||
try:
|
||||
valSetS = <string> valSet.decode('utf_16')
|
||||
encoding = True
|
||||
except UnicodeDecodeError:
|
||||
print('decode utf_16 error')
|
||||
pass
|
||||
except UnicodeEncodeError as ex:
|
||||
print('encode utf_16 error', ex)
|
||||
pass
|
||||
if not encoding:
|
||||
print('no encoding done')
|
||||
valSetS = <string> valSet
|
||||
with nogil:
|
||||
status = self._c_cafe.setString(handle, valSetS)
|
||||
elif isinstance(valSet, (unicode)):
|
||||
#print("unicode")
|
||||
valSetS = valSet
|
||||
valSetS = valSet.encode('utf-8')
|
||||
with nogil:
|
||||
status = self._c_cafe.setString(handle, valSetS)
|
||||
|
||||
else:
|
||||
print("PyCafe def set WARNING: DATA TYPE NOT SUPPORTED")
|
||||
print("Input data (whether within a 'list','array.array','cython.view.memoryview','memoryview' \n\
|
||||
|
||||
+4
-2
@@ -636,11 +636,13 @@ cdef extern from "policies.h":
|
||||
void setHandler(pCallback)
|
||||
void setDefaultHandler()
|
||||
void setNotifyDeltaMilliSeconds(unsigned short)
|
||||
void setNoCyCallbackParameters(unsigned short)
|
||||
void setCyCallback(void *)
|
||||
void setPyHandler()
|
||||
void setPyHandlerData()
|
||||
void setPyCyHandler(void *)
|
||||
void setPyCyHandlerData(void *)
|
||||
void setPyCyHandlerHandle(void *)
|
||||
void setUserArgs(void *)
|
||||
unsigned int getMask()
|
||||
unsigned int getNelem()
|
||||
@@ -681,8 +683,8 @@ cdef extern from "policies.h":
|
||||
pCallback getHandler()
|
||||
int getCallbackStatus()
|
||||
void setHandler(pCallback h)
|
||||
void setPyHandlerGet()
|
||||
void setPyHandlerPut()
|
||||
void setPyHandlerGet(void *)
|
||||
void setPyHandlerPut(void *)
|
||||
void setMethodKind(ChannelRequestPolicyKind)
|
||||
void setWhenToFlushSendBuffer(ChannelWhenToFlushSendBufferPolicyKind)
|
||||
void setWaitKind(ChannelWaitForResponsePolicyKind)
|
||||
|
||||
+652
-279
File diff suppressed because it is too large
Load Diff
+4
-2
@@ -1,9 +1,11 @@
|
||||
module unload gcc
|
||||
module load gcc/7.3.0
|
||||
rm -f PyCafe_sf.cpp
|
||||
rm -f PyCafe_sf.h
|
||||
rm -f PyCafe.cpp
|
||||
rm -f PyCafe.h
|
||||
rm -f PyCafe.pxd
|
||||
ln -s PyCafe_sf.pxd PyCafe.pxd
|
||||
rm -f PyCafe.pyx
|
||||
ln -s PyCafe_sf.pyx PyCafe.pyx
|
||||
source /opt/gfa/python 3.7
|
||||
python setup_py37_sf.py build_ext -b ./python3.7-sf/lib/${EPICS_HOST_ARCH}
|
||||
cp examples.py ./python3.7-sf/lib/${EPICS_HOST_ARCH}
|
||||
|
||||
@@ -4,6 +4,8 @@ rm -f PyCafe.cpp
|
||||
rm -f PyCafe.h
|
||||
rm -f PyCafe.pxd
|
||||
ln -s PyCafe_sls.pxd PyCafe.pxd
|
||||
rm -f PyCafe.pyx
|
||||
ln -s PyCafe_sls.pyx PyCafe.pyx
|
||||
source /opt/gfa/python 3.7
|
||||
python setup_py37_sls2.py build_ext -b ./python3.7-sls2/lib/${EPICS_HOST_ARCH}
|
||||
cp examples.py ./python3.7-sls2/lib/${EPICS_HOST_ARCH}
|
||||
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
639d638
|
||||
< void setNoCyCallbackParameters(unsigned short)
|
||||
645d643
|
||||
< void setPyCyHandlerHandle(void *)
|
||||
686,687c684,685
|
||||
< void setPyHandlerGet(void *)
|
||||
< void setPyHandlerPut(void *)
|
||||
---
|
||||
> void setPyHandlerGet()
|
||||
> void setPyHandlerPut()
|
||||
956,1041d953
|
||||
< cdef extern from "zbsDataHolders.h":
|
||||
<
|
||||
< cdef cppclass BSChannel:
|
||||
< BSChannel(string) except +
|
||||
< void setType()
|
||||
< void setOffset()
|
||||
< void setModulo()
|
||||
< void setBSEnabled()
|
||||
< string getName()
|
||||
< string getType()
|
||||
< int getModulo()
|
||||
< int getOffset()
|
||||
< unsigned int getNelem()
|
||||
< bint isBSEnabled()
|
||||
<
|
||||
< cdef cppclass BSDataHolder:
|
||||
< BSDataHolder() except +
|
||||
< BSDataHolder(vector[string]) except +
|
||||
< void init(vector[string])
|
||||
< BSChannel getBSChannel(unsigned int)
|
||||
< int getIdxFromName(string)
|
||||
< etsNorm getGlobal_timestamp()
|
||||
< unsigned long long getPulse_id()
|
||||
< vector[unsigned int] getHandles()
|
||||
< vector[string] getPV()
|
||||
< vector[PVDataHolder] getPVDataV()
|
||||
< vector[string] getAsStringV()
|
||||
< vector[double] getAsDoubleV()
|
||||
< vector[float] getAsFloatV()
|
||||
< vector[int] getAsIntV()
|
||||
< int reconnect()
|
||||
< void closeBS()
|
||||
< int resetBS()
|
||||
< int setBS(bint)
|
||||
< int setCA(bint)
|
||||
< void setTimeout(int)
|
||||
< void setHWM(int)
|
||||
< bint getIsBS()
|
||||
< void setBSModulo(string, int)
|
||||
< void setBSOffset(string, int)
|
||||
< void setBSModuloOffset(string, int, int)
|
||||
< void printHeader()
|
||||
< unsigned int getNPV()
|
||||
< unsigned int getHWM()
|
||||
< int getTimeout()
|
||||
< unsigned int getNChannels()
|
||||
< unsigned int getNNullData()
|
||||
< float getPGoodData()
|
||||
< void zero()
|
||||
< int getStatus()
|
||||
<
|
||||
< cdef cppclass DBPMData:
|
||||
< double getValue()
|
||||
< epicsTimeStamp getEpicsTimeStamp()
|
||||
< int getStatus()
|
||||
<
|
||||
< cdef cppclass DBPMKeeper:
|
||||
< DBPMKeeper() except +
|
||||
< # DBPMKeeper(vector[string], vector[unsigned int], multimap[float, string])
|
||||
< DBPMKeeper(vector[string], vector[unsigned int], vector[string], vector[float]) except +
|
||||
< vector[unsigned int] getHandle()
|
||||
< vector[string] getPV()
|
||||
< vector[string] getDevice()
|
||||
<
|
||||
< vector[double] getS()
|
||||
< vector[DBPMData] getX()
|
||||
< vector[DBPMData] getY()
|
||||
< vector[DBPMData] getQ()
|
||||
< vector[DBPMData] getEnergy()
|
||||
<
|
||||
< vector[double] getOffsetX()
|
||||
< vector[double] getOffsetY()
|
||||
<
|
||||
< bint getIsAllXOK()
|
||||
< bint getIsAllYOK()
|
||||
< bint getIsAllQOK()
|
||||
< bint getIsAllEnergyOK()
|
||||
< bint getIsAllOK()
|
||||
< bint setBS(bint)
|
||||
< bint resetBS()
|
||||
< void closeBS()
|
||||
< int getStatus()
|
||||
< PVDataHolder * pvd
|
||||
< int getNPV()
|
||||
<
|
||||
<
|
||||
1432,1433c1344,1345
|
||||
< int readDBPMOffsets(DBPMKeeper &)
|
||||
< int getDBPM(DBPMKeeper &) nogil
|
||||
---
|
||||
> #int readDBPMOffsets(DBPMKeeper &)
|
||||
> #int getDBPM(DBPMKeeper &) nogil
|
||||
1435c1347
|
||||
< int prepareDBPM(vector[string] & , vector[unsigned int] & , vector[string] & , vector[float] & ) nogil
|
||||
---
|
||||
> #int prepareDBPM(vector[string] & , vector[unsigned int] & , vector[string] & , vector[float] & ) nogil
|
||||
1445,1449c1357,1361
|
||||
< int initBSwithCA(BSDataHolder &) nogil
|
||||
< int setBS(BSDataHolder &) nogil
|
||||
< int setBS2CAGroup(BSDataHolder &) nogil
|
||||
< int getBS(BSDataHolder &) nogil
|
||||
< int closeBS(BSDataHolder &) nogil
|
||||
---
|
||||
> #int initBSwithCA(BSDataHolder &) nogil
|
||||
> #int setBS(BSDataHolder &) nogil
|
||||
> #int setBS2CAGroup(BSDataHolder &) nogil
|
||||
> #int getBS(BSDataHolder &) nogil
|
||||
> #int closeBS(BSDataHolder &) nogil
|
||||
+717
@@ -0,0 +1,717 @@
|
||||
44c44
|
||||
< _pymodule = "PyCafe.pyx"
|
||||
---
|
||||
> _pymodule = "PyCafe.pyx" # os.path.basename(__file__)
|
||||
49a50,52
|
||||
> cdef object py_cb
|
||||
>
|
||||
> cdef dict openCallbackDictGlobal = {}
|
||||
50a54,59
|
||||
> cdef dict handleMonDictGlobal = {}
|
||||
> cdef dict monDictGlobal = {}
|
||||
> cdef dict openDictGlobal = {}
|
||||
>
|
||||
> cdef dict getDictGlobal = {}
|
||||
> cdef dict putDictGlobal = {}
|
||||
52c61,64
|
||||
< include "PyCafeDefs_sf.pxi"
|
||||
---
|
||||
> #cdef ccafe.CAFE * _c_cafe
|
||||
> #_c_cafe = new ccafe.CAFE()
|
||||
>
|
||||
> include "PyCafeDefs.pxi"
|
||||
83a96
|
||||
>
|
||||
172,179c185
|
||||
<
|
||||
< DBPMKeeper dbpm
|
||||
<
|
||||
< bint dbpmInitialized
|
||||
< bint BSInitialized
|
||||
< bint isBSinCAOnly
|
||||
< BSDataHolder bsd
|
||||
<
|
||||
---
|
||||
>
|
||||
213,216c219
|
||||
< self.dbpmInitialized = False
|
||||
< self.BSInitialized = False
|
||||
< self.isBSinCAOnly = False
|
||||
<
|
||||
---
|
||||
>
|
||||
235,240c238
|
||||
< def CAFE_version(self):
|
||||
< return CAFE_VERSION
|
||||
<
|
||||
< def EPICS_version(self):
|
||||
< return EPICS_VERSION
|
||||
<
|
||||
---
|
||||
>
|
||||
245c243,250
|
||||
< pv_name = handlePV
|
||||
---
|
||||
> pv_name = handlePV
|
||||
> #global openCallbackDictGlobal
|
||||
> #openCallbackDictGlobal[cb] = handlePV
|
||||
> #september 21 2021
|
||||
> global openDictGlobal
|
||||
> openDictGlobal[pv_name] = cb
|
||||
>
|
||||
> #handle = self.hh.getHandleFromPV(pv_name)
|
||||
247a253,264
|
||||
> #self._c_cafe.channelCreatePolicy.setPyCallbackFlag(True)
|
||||
> #self._c_cafe.channelCreatePolicy.setPyConnectHandler(<void *>cb)
|
||||
> #open
|
||||
> #false
|
||||
>
|
||||
> def setPyCallbackConnect(self, pv: str = None, cb: object = None):
|
||||
> if None in (pv, cb):
|
||||
> return
|
||||
> global openDictGlobal
|
||||
> openDictGlobal[pv] = cb
|
||||
>
|
||||
> ##self.hh.setPyConnectCallbackFn(handle, <void *>cb)
|
||||
274c291,299
|
||||
< self.cs.info(ECA_ALLOCMEM)))
|
||||
---
|
||||
> self.cs.info(ECA_ALLOCMEM)))
|
||||
> '''
|
||||
> _cafeException = CafeException(
|
||||
> _type='CafeError', _source=_METHOD,
|
||||
> _error_code=ECA_ALLOCMEM,
|
||||
> _error_text=self.cs.code(ECA_ALLOCMEM),
|
||||
> _error_info=self.cs.info(ECA_ALLOCMEM))
|
||||
> raise _cafeException
|
||||
> '''
|
||||
422,424c447,448
|
||||
< ##for i in range(0, len(pvV)):
|
||||
< ##self.setPyCallbackConnect(pvV[i], cb)
|
||||
< #self.setPyConnectCallbackFn(pvV[i], cb)
|
||||
---
|
||||
> for i in range(0, len(pvV)):
|
||||
> self.setPyCallbackConnect(pvV[i], cb)
|
||||
473c497
|
||||
< ####self.setPyCallbackConnect(pv, cb)
|
||||
---
|
||||
> self.setPyCallbackConnect(pv, cb)
|
||||
481c505
|
||||
< #print("OPEN WITH NO GIL//==>", pvStr, handle)
|
||||
---
|
||||
> #print("OPEN WITH NO GIL//==>", pvStr)
|
||||
486c510
|
||||
< except RuntimeError as e:
|
||||
---
|
||||
> except RuntimeError as e:
|
||||
501c525
|
||||
< raise Exception("{} {} \n{}".format(self._exception_text, _METHOD, e))
|
||||
---
|
||||
> raise Exception("{} {} \n{}".format(self._exception_text, _METHOD, e))
|
||||
791c815,816
|
||||
<
|
||||
---
|
||||
> global getDictGlobal
|
||||
>
|
||||
800,801c825,827
|
||||
< if cb is not None:
|
||||
< crp.setPyHandlerGet(<void *> cb) # forces when=WITH_CALLBACK_USER_SUPPLIED
|
||||
---
|
||||
> if cb is not None:
|
||||
> getDictGlobal[handle] = cb
|
||||
> crp.setPyHandlerGet() # forces when=WITH_CALLBACK_USER_SUPPLIED
|
||||
859,861c885,888
|
||||
<
|
||||
< if cb is not None:
|
||||
< crp.setPyHandlerGet(<void *>cb) # forces when=WITH_CALLBACK_USER_SUPPLIED
|
||||
---
|
||||
> global getDictGlobal
|
||||
> if cb is not None:
|
||||
> getDictGlobal[handle] = cb
|
||||
> crp.setPyHandlerGet() # forces when=WITH_CALLBACK_USER_SUPPLIED
|
||||
886,888c913,917
|
||||
<
|
||||
< if cb is not None:
|
||||
< crp.setPyHandlerPut(<void *>cb) # forces when=WITH_CALLBACK_USER_SUPPLIED
|
||||
---
|
||||
>
|
||||
> global putDictGlobal
|
||||
> if cb is not None:
|
||||
> putDictGlobal[handle] = cb
|
||||
> crp.setPyHandlerPut() # forces when=WITH_CALLBACK_USER_SUPPLIED
|
||||
1402c1431
|
||||
< #decorator casts handlePV to int
|
||||
---
|
||||
> #decorator casts to handlePV to int
|
||||
4021c4050
|
||||
< return pvdict, statusOverall, status
|
||||
---
|
||||
> return pvdict
|
||||
5148a5178,5180
|
||||
> global monDictGlobal
|
||||
> global handleMonDictGlobal
|
||||
>
|
||||
5158c5190
|
||||
<
|
||||
---
|
||||
> #global py_cb
|
||||
5185,5189d5216
|
||||
< mp.setUserArgs(< void * > mpid)
|
||||
< mp.setNoCyCallbackParameters(len(sig.parameters))
|
||||
< mp.setPyCyHandler(<void *> cb)
|
||||
<
|
||||
<
|
||||
5198c5225,5245
|
||||
<
|
||||
---
|
||||
>
|
||||
> mp[i].setUserArgs( < void*> mpid)
|
||||
>
|
||||
> if len(sig.parameters) == 1:
|
||||
> monDictGlobal[mpid] = cb
|
||||
> mp[i].setPyHandler()
|
||||
>
|
||||
> elif len(sig.parameters) == 2:
|
||||
> mp[i].setPyCyHandler(<void *> cb)
|
||||
>
|
||||
> elif len(sig.parameters) == 3:
|
||||
> handleMonDictGlobal[cb] = handleList[i]
|
||||
> mp[i].setPyCyHandlerData(<void *> cb)
|
||||
>
|
||||
> else:
|
||||
> _cafeException = CafeException(_type='CafeError', _source=_METHOD,
|
||||
> _error_info="The signature of the monitor callback function is not supported. \
|
||||
> Supported fns are: \
|
||||
> 1) callback(handle) or 2) callback(pvdata, handle, pv_name) ")
|
||||
> raise _cafeException
|
||||
>
|
||||
5236a5284,5285
|
||||
> global monDictGlobal
|
||||
> global handleMonDictGlobal
|
||||
5251c5300,5301
|
||||
<
|
||||
---
|
||||
> # April 2020 Legacy
|
||||
> #global py_cb
|
||||
5286,5290c5336
|
||||
< sig = inspect.signature(cb[i])
|
||||
<
|
||||
< mp[i].setUserArgs(< void * > mpid) # (<unsigned long *> ptr_mpid)[0])
|
||||
< mp[i].setNoCyCallbackParameters(len(sig.parameters))
|
||||
< mp[i].setPyCyHandler(<void *> cb[i])
|
||||
---
|
||||
> sig = inspect.signature(cb[i])
|
||||
5301c5347,5366
|
||||
<
|
||||
---
|
||||
> mp[i].setUserArgs( < void * > mpid) # (<unsigned long *> ptr_mpid)[0])
|
||||
>
|
||||
> if len(sig.parameters) == 1:
|
||||
> monDictGlobal[mpid] = cb[i]
|
||||
> mp[i].setPyHandler()
|
||||
>
|
||||
> elif len(sig.parameters) == 2:
|
||||
> mp[i].setPyCyHandler(<void *> cb[i])
|
||||
>
|
||||
> elif len(sig.parameters) == 3:
|
||||
> handleMonDictGlobal[cb[i]] = handleList[i]
|
||||
> mp[i].setPyCyHandlerData(<void *> cb[i])
|
||||
>
|
||||
> else:
|
||||
> _cafeException = CafeException(_type='CafeError', _source=_METHOD,
|
||||
> _error_info="The signature of the monitor callback function is not supported. \
|
||||
> Supported fns are: \
|
||||
> 1) callback(handle) or 2) callback(pvdata, handle, pv_name) ")
|
||||
> raise _cafeException
|
||||
>
|
||||
5940a6006
|
||||
>
|
||||
5948c6014
|
||||
<
|
||||
---
|
||||
>
|
||||
5969c6035,6036
|
||||
<
|
||||
---
|
||||
>
|
||||
>
|
||||
6044a6112,6114
|
||||
> global monDictGlobal
|
||||
> global handleMonDictGlobal
|
||||
> global py_cb
|
||||
6046c6116,6117
|
||||
<
|
||||
---
|
||||
>
|
||||
> py_cb = cb
|
||||
6049,6050c6120,6121
|
||||
< hmd[cb] = mpid ##otherwise cb gets ovewritten when casting to an object
|
||||
<
|
||||
---
|
||||
> hmd[cb] = handle ##otherwise cb gets ovewritten when casting to an object
|
||||
> #print(hmd)
|
||||
6052c6123,6133
|
||||
<
|
||||
---
|
||||
> '''
|
||||
> print('SIGNATURE//3//:')
|
||||
> print(str(sig))
|
||||
> for param in sig.parameters.values():
|
||||
> print('Parameter:', param, type(param))
|
||||
> print('len1', len(sig.parameters.values()))
|
||||
> print('len2', len(sig.parameters))
|
||||
>
|
||||
> print('monitorid', mpid)
|
||||
> '''
|
||||
>
|
||||
6056,6057c6137,6165
|
||||
< mp.setNoCyCallbackParameters(len(sig.parameters))
|
||||
< mp.setPyCyHandler(<void *> cb)
|
||||
---
|
||||
>
|
||||
>
|
||||
> if len(sig.parameters) == 1:
|
||||
> ###monDictGlobal[mpid] = cb
|
||||
>
|
||||
> mp.setPyHandler()
|
||||
> # print (<long>mp.getUserArgs())
|
||||
>
|
||||
> elif len(sig.parameters) == 2:
|
||||
> mp.setPyCyHandler(<void *> cb)
|
||||
> #mp.setPyHandler()
|
||||
> #mp.setCyCallback(<void *> cb)
|
||||
>
|
||||
> elif len(sig.parameters) == 3:
|
||||
> #py_cb=cb
|
||||
> #self.hh.addWidget(handle, <void *> cb)
|
||||
>
|
||||
> mp.setPyCyHandlerData(<void *> ( py_cb))
|
||||
> #handleMonDictGlobal[cb] = handle
|
||||
>
|
||||
> #mp.setPyHandlerData()
|
||||
> #mp.setCyCallback(<void *> cb)
|
||||
> else:
|
||||
> _cafeException = CafeException(
|
||||
> _type='CafeError', _source=_METHOD,
|
||||
> _error_info="The signature of the monitor callback function \
|
||||
> given by the user is not supported. Valid fns are: \
|
||||
> 1) callback(handle) or 2) callback(pvdata, handle, pv_name) ")
|
||||
> raise _cafeException
|
||||
6096c6204
|
||||
< cdef unsigned int mpid_no_coercion
|
||||
---
|
||||
> cdef unsigned int mpidUI
|
||||
6097a6206,6207
|
||||
> global monDictGlobal
|
||||
> #global handleMonDictGlobal
|
||||
6099c6209,6210
|
||||
<
|
||||
---
|
||||
>
|
||||
>
|
||||
6101d6211
|
||||
< mpid_no_coercion = mpid
|
||||
6103c6213
|
||||
< mpid_no_coercion = mpid
|
||||
---
|
||||
> mpidUI = mpid
|
||||
6105,6113c6215,6226
|
||||
< status = self._c_cafe.monitorStopWithID(handle, mpid_no_coercion)
|
||||
< time.sleep(0.001)
|
||||
< l = None
|
||||
< if mpid not in list(hmd.values()):
|
||||
< pass #happens when is direct mode in table widget
|
||||
< else:
|
||||
< l = list(hmd.keys())[list(hmd.values()).index(mpid)]
|
||||
< if l is not None:
|
||||
< del hmd[l]
|
||||
---
|
||||
> status = self._c_cafe.monitorStopWithID(handle, mpidUI)
|
||||
> time.sleep(0.01)
|
||||
>
|
||||
> if (status == ICAFE_NORMAL):
|
||||
> #pass
|
||||
> #print (monDictGlobal)
|
||||
> # DELETE ENTRY ONLY IF IT EXISTS!
|
||||
> # if monDictGlobal.has_key(mpidUI):
|
||||
> # Sep 2020 - try without del for testing!
|
||||
> if mpidUI in monDictGlobal.keys():
|
||||
> del monDictGlobal[mpidUI]
|
||||
>
|
||||
6118d6230
|
||||
< mids = self.hh.getMonitorIDs(handle)
|
||||
6121,6129c6233,6265
|
||||
< time.sleep(0.001)
|
||||
<
|
||||
< for monid in mids:
|
||||
< if monid not in list(hmd.values()):
|
||||
< continue
|
||||
< l = list(hmd.keys())[list(hmd.values()).index(monid)]
|
||||
< if l is not None:
|
||||
< del hmd[l]
|
||||
<
|
||||
---
|
||||
> time.sleep(0.01)
|
||||
>
|
||||
> _ncount = 0
|
||||
> for key, value in hmd.items():
|
||||
> if value == handle:
|
||||
> _ncount += 1
|
||||
>
|
||||
> for i in range (0, _ncount):
|
||||
> try:
|
||||
> l = list(hmd.keys())[list(hmd.values()).index(handle)]
|
||||
> #print (l)
|
||||
> if l is not None:
|
||||
> del hmd[l]
|
||||
> except ValueError:
|
||||
> print("List does not contain handle {0}".format(handle))
|
||||
> #{k:v for k,v in hmd.items() if v != handle}
|
||||
> ##for a, v in hmd.items():
|
||||
> ##print(a, v)
|
||||
> ##print ("DEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEELLLLLLLETE")
|
||||
> # Find handle with monitor ID and STOP thst one monitor!
|
||||
>
|
||||
> if (status == ICAFE_NORMAL):
|
||||
>
|
||||
> # print "size", self.hh.getNmonitor(handle)
|
||||
> mpidUIV = self.hh.getMonitorIDs(handle)
|
||||
> # print "size", mpidUIV.size()
|
||||
>
|
||||
> for i in range(0, mpidUIV.size()):
|
||||
>
|
||||
> # if monDictGlobal.has_key(mpidUIV[i]):
|
||||
> if mpidUIV[i] in monDictGlobal.keys():
|
||||
> del monDictGlobal[mpidUIV[i]]
|
||||
>
|
||||
6137a6274
|
||||
> # 3
|
||||
6143d6279
|
||||
< cdef int status
|
||||
6144a6281,6282
|
||||
> global monDictGlobal
|
||||
> global handleMonDictGlobal
|
||||
6145a6284
|
||||
> cdef int status
|
||||
6152c6291,6292
|
||||
< hmd.clear()
|
||||
---
|
||||
> monDictGlobal.clear()
|
||||
> handleMonDictGlobal.clear()
|
||||
6181a6322
|
||||
>
|
||||
7232,7545d7372
|
||||
<
|
||||
< #if HAVE_BSREAD==1:
|
||||
<
|
||||
< ################################################################################
|
||||
<
|
||||
< def prepareSFdbpm(self):
|
||||
< cdef:
|
||||
< vector[string] bpmList
|
||||
< vector[unsigned int] bpmHandles
|
||||
< vector[string] bpmDev
|
||||
< vector[float] bpmPos
|
||||
<
|
||||
< self._c_cafe.prepareDBPM(bpmList, bpmHandles, bpmDev, bpmPos)
|
||||
<
|
||||
< # for i in range(0, self.bpmDev.size()):
|
||||
< #print (bpmPos[i], bpmDev[i] )
|
||||
<
|
||||
< if not self.dbpmInitialized:
|
||||
< self.dbpm = DBPMKeeper(
|
||||
< bpmList, bpmHandles, bpmDev, bpmPos)
|
||||
< self.dbpmInitialized = True
|
||||
< return
|
||||
<
|
||||
< ##################################################################################
|
||||
< # END def prepareSFdbpm(self)
|
||||
< ##################################################################################
|
||||
<
|
||||
< def setSFdbpmBS(self, bint bsFlag=True):
|
||||
< return self.dbpm.setBS(bsFlag)
|
||||
<
|
||||
< def resetSFdbpmBS(self):
|
||||
< return self.dbpm.resetBS()
|
||||
<
|
||||
< def closeSFdbpmBS(self):
|
||||
< return self.dbpm.closeBS()
|
||||
<
|
||||
< def readSFdbpmOffsets(self):
|
||||
< return self._c_cafe.readDBPMOffsets(self.dbpm)
|
||||
<
|
||||
< def getSFdbpm(self):
|
||||
<
|
||||
< cdef str _METHOD = "getSFdbpm"
|
||||
<
|
||||
< cdef int status
|
||||
< cdef vector[unsigned int] handleV
|
||||
< with nogil:
|
||||
< status = self._c_cafe.getDBPM(self.dbpm)
|
||||
<
|
||||
< if status >= ICAFE_ERRNO_BASE:
|
||||
< self._c_cafe.printStatusMessage(status)
|
||||
< elif status != ICAFE_NORMAL:
|
||||
< if PYCAFE_PRINT_LEVEL >= PYCAFE_PRINT_LOW:
|
||||
< # self._c_cafe.printStatusMessage(status)
|
||||
<
|
||||
< handleV = self.dbpm.getHandle()
|
||||
< # for i in range(0, self.dbpm.getNDBPM()):
|
||||
< # if x[i].getStatus !=
|
||||
< #print (self.bpmPos[i], self.bpmDev[i] )
|
||||
< for i in range(0, self.dbpm.getNPV()):
|
||||
< if (self.dbpm.pvd[i].getStatus() != ICAFE_NORMAL):
|
||||
< self._c_cafe.printStatus(handleV[i], status)
|
||||
<
|
||||
< return dbpmHolderToStruct(self.dbpm)
|
||||
<
|
||||
< ##################################################################################
|
||||
< # END def getSFdbpm(self):
|
||||
< ##################################################################################
|
||||
<
|
||||
<
|
||||
< def getSFdbpmOffs_x(self):
|
||||
< return self.dbpm.getOffsetX()
|
||||
<
|
||||
< def getSFdbpmOffs_y(self):
|
||||
< return self.dbpm.getOffsetY()
|
||||
<
|
||||
< ################################################################################
|
||||
<
|
||||
< def setBS(self, list pv=None, modulo=None, offset=None, int timeoutMS=0):
|
||||
<
|
||||
< cdef str _METHOD = "setBS"
|
||||
< cdef int status = ICAFE_NORMAL
|
||||
< cdef unsigned int i
|
||||
< cdef bint pFlag = False
|
||||
<
|
||||
< if isinstance(modulo, numbers.Number):
|
||||
< if int(modulo) <= 0:
|
||||
< raise ValueError("{} {} \n{}".format(
|
||||
< self._exception_text, _METHOD,
|
||||
< "modulo input argument must be positive!"))
|
||||
< elif not TypeError(modulo, dict):
|
||||
< raise Exception("{} {} \n{}".format(
|
||||
< self._exception_text, _METHOD,
|
||||
< ("modulo input arg, should be of type <class 'numbers.Number'>, "
|
||||
< "else <class 'dict'> {pv_name : modulo}")))
|
||||
<
|
||||
< if isinstance(offset, (numbers.Number)):
|
||||
< if int(offset) < 0:
|
||||
< raise ValueError("{} {} \n{}".format(
|
||||
< self._exception_text, _METHOD,
|
||||
< "offset input argument cannot be negative!"))
|
||||
< elif not isinstance(offset, (dict)):
|
||||
< raise TypeError("{} {} \n{}".format(
|
||||
< self._exception_text, _METHOD,
|
||||
< ("offset input arg, should be of type <class 'numbers.Number'>, "
|
||||
< "else <class 'dict'> {pv_name : offset} ")))
|
||||
<
|
||||
< if self.BSInitialized == True:
|
||||
< print("Message from setBS: ONLY A SINGLE STREAM IS ALLOWED")
|
||||
< return status
|
||||
<
|
||||
< cdef vector[string] v
|
||||
<
|
||||
< if timeoutMS > 0:
|
||||
< self.bsd.setTimeout(timeoutMS)
|
||||
<
|
||||
< if pv is not None:
|
||||
< # do this to avoid compiler warning messages
|
||||
< for i in range(0, len(pv)):
|
||||
< v.push_back(pv[i])
|
||||
< self.bsd.init(v)
|
||||
<
|
||||
< if isinstance(modulo, (numbers.Number)):
|
||||
< modulo = dict([(pv[i], int(modulo))
|
||||
< for i in range(0, len(pv))])
|
||||
<
|
||||
< if isinstance(offset, (numbers.Number)):
|
||||
< offset = dict([(pv[i], int(offset))
|
||||
< for i in range(0, len(pv))])
|
||||
<
|
||||
< if modulo is not None:
|
||||
< for eachKey in modulo:
|
||||
< self.bsd.setBSModulo(eachKey, modulo[eachKey])
|
||||
< if offset is not None:
|
||||
< for eachKey in offset:
|
||||
< self.bsd.setBSOffset(eachKey, offset[eachKey])
|
||||
<
|
||||
< # self.initBSwithCA()
|
||||
< with nogil:
|
||||
< self._c_cafe.initBSwithCA(self.bsd)
|
||||
<
|
||||
< with nogil:
|
||||
< self._c_cafe.getBS(self.bsd)
|
||||
<
|
||||
< with nogil:
|
||||
< # status=self._c_cafe.setBS_Step1(self.bsd)
|
||||
< status = self._c_cafe.setBS(self.bsd)
|
||||
<
|
||||
< if status == ICAFE_NORMAL:
|
||||
< self.BSInitialized = True
|
||||
< self.isBSinCAOnly = False
|
||||
<
|
||||
< return status
|
||||
<
|
||||
< ################################################################################
|
||||
<
|
||||
< def initBSwithCA(self):
|
||||
<
|
||||
< # self.openPrepare()
|
||||
< with nogil:
|
||||
< self._c_cafe.initBSwithCA(self.bsd)
|
||||
<
|
||||
< # self.openNowAndWait(0.4)
|
||||
<
|
||||
<
|
||||
< ################################################################################
|
||||
< def setBS2CA(self, list pv=None):
|
||||
<
|
||||
< cdef vector[string] v
|
||||
< if pv is not None:
|
||||
< # do this to avoid compiler warning messages
|
||||
< for i in range(0, len(pv)):
|
||||
< v.push_back(pv[i])
|
||||
< self.bsd.init(v)
|
||||
<
|
||||
< with nogil:
|
||||
< self._c_cafe.setBS2CAGroup(self.bsd)
|
||||
< self.isBSinCAOnly = True
|
||||
<
|
||||
<
|
||||
< def getBSSlim(self):
|
||||
< if self.BSInitialized == False:
|
||||
< if self.isBSinCAOnly == False:
|
||||
< print(("Message from getBS: BS stream not initialized;"
|
||||
< "cafe.setBS(pvList) has first to be called."))
|
||||
< return None
|
||||
<
|
||||
< with nogil:
|
||||
< self._c_cafe.getBS(self.bsd)
|
||||
<
|
||||
<
|
||||
< t1= time.time()
|
||||
< PVDataV = self.bsd.getPVDataV()
|
||||
<
|
||||
< pvlist = [None] * <int>self.bsd.getNPV()
|
||||
< #cdef pvdata p1
|
||||
<
|
||||
< for i in range (0, self.bsd.getNPV()):
|
||||
< #p1 = pvdata()
|
||||
< #p1 = PVDataHolderToStruct(self.bsd.pvdata[i])
|
||||
< pvlist[i]=PVDataHolderToStruct(PVDataV[i])
|
||||
<
|
||||
<
|
||||
< bs_slim = {}
|
||||
<
|
||||
< for data, handle in zip(pvlist, self.bsd.getHandles()): # self.bsd.getIsBS()):
|
||||
< bs_slim[handle] = data
|
||||
<
|
||||
< t2= time.time()
|
||||
< print("diff in reading BSDataHolderToStruc", t2 - t1)
|
||||
<
|
||||
<
|
||||
< return bs_slim
|
||||
<
|
||||
< ################################################################################
|
||||
< def getBS(self):
|
||||
<
|
||||
< if self.BSInitialized == False:
|
||||
< if self.isBSinCAOnly == False:
|
||||
< print(("Message from getBS: BS stream not initialized;"
|
||||
< "cafe.setBS(pvList) has first to be called."))
|
||||
<
|
||||
< return None
|
||||
< # CHECK STATUS!!!!
|
||||
< #print("getBS in cycafe"
|
||||
< #start = time.time()
|
||||
<
|
||||
< with nogil:
|
||||
< self._c_cafe.getBS(self.bsd)
|
||||
<
|
||||
< _bsd = BSDataHolderToStruct(self.bsd)
|
||||
< #_bsd.show()
|
||||
< return _bsd #BSDataHolderToStruct(self.bsd)
|
||||
<
|
||||
< '''
|
||||
< cdef double _pid = 0
|
||||
< _handle = self._c_cafe.getHandleFromPV(str('SIN-TIMAST-EVG0:TX-PULSEID'))
|
||||
< _stat = self._c_cafe.getCacheDouble(_handle, _pid)
|
||||
< print("cython/cafe/diff in cython ", self.bsd.getPulse_id(), _pid, _pid - self.bsd.getPulse_id())
|
||||
< t1= time.time()
|
||||
< print("diff in cython", t1 - start)
|
||||
< #print("pulse_id in cycafe", self.bsd.getPulse_id())
|
||||
<
|
||||
< BSd = BSDataHolderToStruct(self.bsd)
|
||||
< t2= time.time()
|
||||
< print("diff totol in reading BSDataHolderToStruc", t2 - start)
|
||||
<
|
||||
< return BSd
|
||||
< '''
|
||||
<
|
||||
< ################################################################################
|
||||
<
|
||||
< def closeBS(self):
|
||||
< with nogil:
|
||||
< self._c_cafe.closeBS(self.bsd)
|
||||
< self.BSInitialized = False
|
||||
< self.isBSinCAOnly = False
|
||||
<
|
||||
<
|
||||
< def getTimeoutMSBS(self):
|
||||
< return self.bsd.getTimeout()
|
||||
<
|
||||
< def setTimeoutMSBS(self, int timeoutMS):
|
||||
< self.bsd.setTimeout(timeoutMS)
|
||||
<
|
||||
<
|
||||
< def reconnectBS(self):
|
||||
< self.bsd.reconnect()
|
||||
<
|
||||
<
|
||||
< def flushBS(self):
|
||||
< self.bsd.reconnect()
|
||||
<
|
||||
<
|
||||
< def monitorPulseID(self):
|
||||
< with nogil:
|
||||
< self._c_cafe.monitorPulseID()
|
||||
<
|
||||
<
|
||||
< def monitorStopPulseID(self):
|
||||
< with nogil:
|
||||
< self._c_cafe.monitorStopPulseID()
|
||||
<
|
||||
<
|
||||
< def setPulseIDBufferSize(self, handlePV, int bufferSize = 10):
|
||||
< cdef str _METHOD = "setPulseIDBufferSize"
|
||||
<
|
||||
< cdef unsigned int handle = 0
|
||||
< if isinstance(handlePV, (int, long)):
|
||||
< handle = handlePV
|
||||
< elif isinstance(handlePV, (str)):
|
||||
< handle = self.checkForHandle(handlePV)
|
||||
< else:
|
||||
< raise Exception("{} {} \n{}".format(
|
||||
< self._exception_text, _METHOD,
|
||||
< ("First Input argument should be of type <class 'int'> if handle "
|
||||
< "else <class 'str'> if PV.")))
|
||||
<
|
||||
< self._c_cafe.setPulseIDBufferSize(handle, bufferSize)
|
||||
<
|
||||
<
|
||||
< def setPulseIDBufferSizeAll(self, int bufferSize = 10):
|
||||
< self._c_cafe.setPulseIDBufferSizeAll(bufferSize)
|
||||
<
|
||||
<
|
||||
< ###################################################################################
|
||||
<
|
||||
< def setBSInit(self, list pv):
|
||||
< self.bsd.init(pv)
|
||||
<
|
||||
<
|
||||
<
|
||||
< ##################################################################################
|
||||
< #END: cdef CAFE###################################################################
|
||||
< ##################################################################################
|
||||
@@ -1,182 +1,448 @@
|
||||
51a52,60
|
||||
> cdef dict openCallbackDictGlobal = {}
|
||||
> cdef dict hmd = {}
|
||||
> cdef dict handleMonDictGlobal = {}
|
||||
> cdef dict monDictGlobal = {}
|
||||
> cdef dict openDictGlobal = {}
|
||||
> #cdef dict getDictGlobal = {}
|
||||
> #cdef dict putDictGlobal = {}
|
||||
>
|
||||
>
|
||||
245c254,257
|
||||
< pv_name = handlePV
|
||||
52c52
|
||||
< include "PyCafeDefs_sf.pxi"
|
||||
---
|
||||
> pv_name = handlePV
|
||||
> global openDictGlobal
|
||||
> openDictGlobal[pv_name] = cb
|
||||
> print("HANDLE ===========================================================", handlePV)
|
||||
247a260,269
|
||||
> #Used internally
|
||||
> def setPyCallbackConnect(self, pv: str = None, cb: object = None):
|
||||
> if None in (pv, cb):
|
||||
> return
|
||||
> global openDictGlobal
|
||||
> openDictGlobal[pv] = cb
|
||||
> #handle=self.hh.getHandleFromPV(pv)
|
||||
> #print("HANDLE ===========================================================", handle)
|
||||
> #self.hh.setPyConnectCallbackFn(handle, <void *>cb)
|
||||
>
|
||||
274c296,304
|
||||
> include "PyCafeDefs.pxi"
|
||||
83a84
|
||||
>
|
||||
172,179c173
|
||||
<
|
||||
< DBPMKeeper dbpm
|
||||
<
|
||||
< bint dbpmInitialized
|
||||
< bint BSInitialized
|
||||
< bint isBSinCAOnly
|
||||
< BSDataHolder bsd
|
||||
<
|
||||
---
|
||||
>
|
||||
213,216c207
|
||||
< self.dbpmInitialized = False
|
||||
< self.BSInitialized = False
|
||||
< self.isBSinCAOnly = False
|
||||
<
|
||||
---
|
||||
>
|
||||
274c265,266
|
||||
< self.cs.info(ECA_ALLOCMEM)))
|
||||
---
|
||||
> self.cs.info(ECA_ALLOCMEM)))
|
||||
> '''
|
||||
> _cafeException = CafeException(
|
||||
> _type='CafeError', _source=_METHOD,
|
||||
> _error_code=ECA_ALLOCMEM,
|
||||
> _error_text=self.cs.code(ECA_ALLOCMEM),
|
||||
> _error_info=self.cs.info(ECA_ALLOCMEM))
|
||||
> raise _cafeException
|
||||
> '''
|
||||
791c821,822
|
||||
>
|
||||
421c413,414
|
||||
< if cb is not None:
|
||||
---
|
||||
> if cb is not None:
|
||||
>
|
||||
470c463
|
||||
<
|
||||
---
|
||||
>
|
||||
483c476
|
||||
< except RuntimeError as e:
|
||||
---
|
||||
> except RuntimeError as e:
|
||||
498c491
|
||||
< raise Exception("{} {} \n{}".format(self._exception_text, _METHOD, e))
|
||||
---
|
||||
> raise Exception("{} {} \n{}".format(self._exception_text, _METHOD, e))
|
||||
788c781
|
||||
<
|
||||
---
|
||||
> ###R###global getDictGlobal
|
||||
>
|
||||
800c831,832
|
||||
797c790
|
||||
< if cb is not None:
|
||||
---
|
||||
> if cb is not None:
|
||||
> ###R###getDictGlobal[handle] = cb
|
||||
859,860c891,893
|
||||
> if cb is not None:
|
||||
856,857c849
|
||||
<
|
||||
< if cb is not None:
|
||||
---
|
||||
> ###R###global getDictGlobal
|
||||
> if cb is not None:
|
||||
> ###R###getDictGlobal[handle] = cb
|
||||
886,887c919,922
|
||||
883,884c875,876
|
||||
<
|
||||
< if cb is not None:
|
||||
---
|
||||
>
|
||||
> ###R###global putDictGlobal
|
||||
> if cb is not None:
|
||||
> ###R###putDictGlobal[handle] = cb
|
||||
4021c4056
|
||||
< return pvdict, statusOverall, status
|
||||
5154c5146
|
||||
<
|
||||
---
|
||||
> return pvdict
|
||||
5150c5185
|
||||
< #global handleMonDictGlobal
|
||||
---
|
||||
> global handleMonDictGlobal
|
||||
5188,5193d5222
|
||||
< mp.setUserArgs(< void * > mpid)
|
||||
< mp.setNoCyCallbackParameters(len(sig.parameters))
|
||||
< mp.setPyCyHandler(<void *> cb)
|
||||
<
|
||||
>
|
||||
5184d5175
|
||||
<
|
||||
<
|
||||
5203,5204c5232,5233
|
||||
<
|
||||
< '''
|
||||
---
|
||||
> mp[i].setUserArgs( < void*> mpid)
|
||||
>
|
||||
5213c5242
|
||||
< ##handleMonDictGlobal[cb] = handleList[i]
|
||||
---
|
||||
> handleMonDictGlobal[cb] = handleList[i]
|
||||
5222c5251
|
||||
< '''
|
||||
5193c5184
|
||||
<
|
||||
---
|
||||
>
|
||||
5261,5262c5290,5291
|
||||
< #global monDictGlobal
|
||||
< #global handleMonDictGlobal
|
||||
---
|
||||
> global monDictGlobal
|
||||
> global handleMonDictGlobal
|
||||
5313,5317c5342
|
||||
5232d5222
|
||||
<
|
||||
5279,5280c5269
|
||||
< sig = inspect.signature(cb[i])
|
||||
<
|
||||
< mp[i].setUserArgs(< void * > mpid) # (<unsigned long *> ptr_mpid)[0])
|
||||
< mp[i].setNoCyCallbackParameters(len(sig.parameters))
|
||||
< mp[i].setPyCyHandler(<void *> cb[i])
|
||||
---
|
||||
> sig = inspect.signature(cb[i])
|
||||
5328,5329c5353,5354
|
||||
<
|
||||
< '''
|
||||
---
|
||||
> mp[i].setUserArgs( < void * > mpid) # (<unsigned long *> ptr_mpid)[0])
|
||||
>
|
||||
5338c5363
|
||||
< #handleMonDictGlobal[cb[i]] = handleList[i]
|
||||
---
|
||||
> handleMonDictGlobal[cb[i]] = handleList[i]
|
||||
5347c5372
|
||||
< '''
|
||||
5294c5283
|
||||
<
|
||||
---
|
||||
>
|
||||
6091,6092c6116,6117
|
||||
< #global monDictGlobal
|
||||
< #global handleMonDictGlobal
|
||||
5933a5923
|
||||
>
|
||||
5941c5931
|
||||
<
|
||||
---
|
||||
> global monDictGlobal
|
||||
> global handleMonDictGlobal
|
||||
6094c6119
|
||||
< #global hmd
|
||||
>
|
||||
5962c5952,5953
|
||||
<
|
||||
---
|
||||
>
|
||||
>
|
||||
6039c6030
|
||||
<
|
||||
---
|
||||
>
|
||||
6043c6034
|
||||
<
|
||||
---
|
||||
>
|
||||
6045c6036
|
||||
<
|
||||
---
|
||||
>
|
||||
6091,6092c6082,6083
|
||||
< global hmd
|
||||
<
|
||||
---
|
||||
> global hmd
|
||||
6099,6100c6124,6125
|
||||
< ##hmd[cb] = handle ##otherwise cb gets ovewritten when casting to an object
|
||||
< ##monDictGlobal[mpid] = cb
|
||||
>
|
||||
6106c6097
|
||||
< del hmd[l]
|
||||
---
|
||||
> hmd[cb] = handle ##otherwise cb gets ovewritten when casting to an object
|
||||
> monDictGlobal[mpid] = cb
|
||||
6188c6213
|
||||
< ##global monDictGlobal
|
||||
> del hmd[l]
|
||||
6115c6106
|
||||
<
|
||||
---
|
||||
> global monDictGlobal
|
||||
6190c6215
|
||||
< ##global hmd
|
||||
---
|
||||
> global hmd
|
||||
6218,6219c6243,6244
|
||||
< time.sleep(0.002)
|
||||
< '''
|
||||
---
|
||||
> time.sleep(0.01)
|
||||
>
|
||||
6245,6246c6270,6271
|
||||
< '''
|
||||
< ##if (status == ICAFE_NORMAL):
|
||||
>
|
||||
6122c6113
|
||||
<
|
||||
---
|
||||
>
|
||||
> if (status == ICAFE_NORMAL):
|
||||
6249c6274
|
||||
< ##mpidUIV = self.hh.getMonitorIDs(handle)
|
||||
6131c6122
|
||||
<
|
||||
---
|
||||
> mpidUIV = self.hh.getMonitorIDs(handle)
|
||||
6251c6276
|
||||
>
|
||||
6174a6166
|
||||
>
|
||||
7225,7538d7216
|
||||
<
|
||||
< #if HAVE_BSREAD==1:
|
||||
<
|
||||
< ################################################################################
|
||||
<
|
||||
< def prepareSFdbpm(self):
|
||||
< cdef:
|
||||
< vector[string] bpmList
|
||||
< vector[unsigned int] bpmHandles
|
||||
< vector[string] bpmDev
|
||||
< vector[float] bpmPos
|
||||
<
|
||||
< self._c_cafe.prepareDBPM(bpmList, bpmHandles, bpmDev, bpmPos)
|
||||
<
|
||||
< # for i in range(0, self.bpmDev.size()):
|
||||
< #print (bpmPos[i], bpmDev[i] )
|
||||
<
|
||||
< if not self.dbpmInitialized:
|
||||
< self.dbpm = DBPMKeeper(
|
||||
< bpmList, bpmHandles, bpmDev, bpmPos)
|
||||
< self.dbpmInitialized = True
|
||||
< return
|
||||
<
|
||||
< ##################################################################################
|
||||
< # END def prepareSFdbpm(self)
|
||||
< ##################################################################################
|
||||
<
|
||||
< def setSFdbpmBS(self, bint bsFlag=True):
|
||||
< return self.dbpm.setBS(bsFlag)
|
||||
<
|
||||
< def resetSFdbpmBS(self):
|
||||
< return self.dbpm.resetBS()
|
||||
<
|
||||
< def closeSFdbpmBS(self):
|
||||
< return self.dbpm.closeBS()
|
||||
<
|
||||
< def readSFdbpmOffsets(self):
|
||||
< return self._c_cafe.readDBPMOffsets(self.dbpm)
|
||||
<
|
||||
< def getSFdbpm(self):
|
||||
<
|
||||
< cdef str _METHOD = "getSFdbpm"
|
||||
<
|
||||
< cdef int status
|
||||
< cdef vector[unsigned int] handleV
|
||||
< with nogil:
|
||||
< status = self._c_cafe.getDBPM(self.dbpm)
|
||||
<
|
||||
< if status >= ICAFE_ERRNO_BASE:
|
||||
< self._c_cafe.printStatusMessage(status)
|
||||
< elif status != ICAFE_NORMAL:
|
||||
< if PYCAFE_PRINT_LEVEL >= PYCAFE_PRINT_LOW:
|
||||
< # self._c_cafe.printStatusMessage(status)
|
||||
<
|
||||
< handleV = self.dbpm.getHandle()
|
||||
< # for i in range(0, self.dbpm.getNDBPM()):
|
||||
< # if x[i].getStatus !=
|
||||
< #print (self.bpmPos[i], self.bpmDev[i] )
|
||||
< for i in range(0, self.dbpm.getNPV()):
|
||||
< if (self.dbpm.pvd[i].getStatus() != ICAFE_NORMAL):
|
||||
< self._c_cafe.printStatus(handleV[i], status)
|
||||
<
|
||||
< return dbpmHolderToStruct(self.dbpm)
|
||||
<
|
||||
< ##################################################################################
|
||||
< # END def getSFdbpm(self):
|
||||
< ##################################################################################
|
||||
<
|
||||
<
|
||||
< def getSFdbpmOffs_x(self):
|
||||
< return self.dbpm.getOffsetX()
|
||||
<
|
||||
< def getSFdbpmOffs_y(self):
|
||||
< return self.dbpm.getOffsetY()
|
||||
<
|
||||
< ################################################################################
|
||||
<
|
||||
< def setBS(self, list pv=None, modulo=None, offset=None, int timeoutMS=0):
|
||||
<
|
||||
< cdef str _METHOD = "setBS"
|
||||
< cdef int status = ICAFE_NORMAL
|
||||
< cdef unsigned int i
|
||||
< cdef bint pFlag = False
|
||||
<
|
||||
< if isinstance(modulo, numbers.Number):
|
||||
< if int(modulo) <= 0:
|
||||
< raise ValueError("{} {} \n{}".format(
|
||||
< self._exception_text, _METHOD,
|
||||
< "modulo input argument must be positive!"))
|
||||
< elif not TypeError(modulo, dict):
|
||||
< raise Exception("{} {} \n{}".format(
|
||||
< self._exception_text, _METHOD,
|
||||
< ("modulo input arg, should be of type <class 'numbers.Number'>, "
|
||||
< "else <class 'dict'> {pv_name : modulo}")))
|
||||
<
|
||||
< if isinstance(offset, (numbers.Number)):
|
||||
< if int(offset) < 0:
|
||||
< raise ValueError("{} {} \n{}".format(
|
||||
< self._exception_text, _METHOD,
|
||||
< "offset input argument cannot be negative!"))
|
||||
< elif not isinstance(offset, (dict)):
|
||||
< raise TypeError("{} {} \n{}".format(
|
||||
< self._exception_text, _METHOD,
|
||||
< ("offset input arg, should be of type <class 'numbers.Number'>, "
|
||||
< "else <class 'dict'> {pv_name : offset} ")))
|
||||
<
|
||||
< if self.BSInitialized == True:
|
||||
< print("Message from setBS: ONLY A SINGLE STREAM IS ALLOWED")
|
||||
< return status
|
||||
<
|
||||
< cdef vector[string] v
|
||||
<
|
||||
< if timeoutMS > 0:
|
||||
< self.bsd.setTimeout(timeoutMS)
|
||||
<
|
||||
< if pv is not None:
|
||||
< # do this to avoid compiler warning messages
|
||||
< for i in range(0, len(pv)):
|
||||
< v.push_back(pv[i])
|
||||
< self.bsd.init(v)
|
||||
<
|
||||
< if isinstance(modulo, (numbers.Number)):
|
||||
< modulo = dict([(pv[i], int(modulo))
|
||||
< for i in range(0, len(pv))])
|
||||
<
|
||||
< if isinstance(offset, (numbers.Number)):
|
||||
< offset = dict([(pv[i], int(offset))
|
||||
< for i in range(0, len(pv))])
|
||||
<
|
||||
< if modulo is not None:
|
||||
< for eachKey in modulo:
|
||||
< self.bsd.setBSModulo(eachKey, modulo[eachKey])
|
||||
< if offset is not None:
|
||||
< for eachKey in offset:
|
||||
< self.bsd.setBSOffset(eachKey, offset[eachKey])
|
||||
<
|
||||
< # self.initBSwithCA()
|
||||
< with nogil:
|
||||
< self._c_cafe.initBSwithCA(self.bsd)
|
||||
<
|
||||
< with nogil:
|
||||
< self._c_cafe.getBS(self.bsd)
|
||||
<
|
||||
< with nogil:
|
||||
< # status=self._c_cafe.setBS_Step1(self.bsd)
|
||||
< status = self._c_cafe.setBS(self.bsd)
|
||||
<
|
||||
< if status == ICAFE_NORMAL:
|
||||
< self.BSInitialized = True
|
||||
< self.isBSinCAOnly = False
|
||||
<
|
||||
< return status
|
||||
<
|
||||
< ################################################################################
|
||||
<
|
||||
< def initBSwithCA(self):
|
||||
<
|
||||
< # self.openPrepare()
|
||||
< with nogil:
|
||||
< self._c_cafe.initBSwithCA(self.bsd)
|
||||
<
|
||||
< # self.openNowAndWait(0.4)
|
||||
<
|
||||
<
|
||||
< ################################################################################
|
||||
< def setBS2CA(self, list pv=None):
|
||||
<
|
||||
< cdef vector[string] v
|
||||
< if pv is not None:
|
||||
< # do this to avoid compiler warning messages
|
||||
< for i in range(0, len(pv)):
|
||||
< v.push_back(pv[i])
|
||||
< self.bsd.init(v)
|
||||
<
|
||||
< with nogil:
|
||||
< self._c_cafe.setBS2CAGroup(self.bsd)
|
||||
< self.isBSinCAOnly = True
|
||||
<
|
||||
<
|
||||
< def getBSSlim(self):
|
||||
< if self.BSInitialized == False:
|
||||
< if self.isBSinCAOnly == False:
|
||||
< print(("Message from getBS: BS stream not initialized;"
|
||||
< "cafe.setBS(pvList) has first to be called."))
|
||||
< return None
|
||||
<
|
||||
< with nogil:
|
||||
< self._c_cafe.getBS(self.bsd)
|
||||
<
|
||||
<
|
||||
< t1= time.time()
|
||||
< PVDataV = self.bsd.getPVDataV()
|
||||
<
|
||||
< pvlist = [None] * <int>self.bsd.getNPV()
|
||||
< #cdef pvdata p1
|
||||
<
|
||||
< for i in range (0, self.bsd.getNPV()):
|
||||
< #p1 = pvdata()
|
||||
< #p1 = PVDataHolderToStruct(self.bsd.pvdata[i])
|
||||
< pvlist[i]=PVDataHolderToStruct(PVDataV[i])
|
||||
<
|
||||
<
|
||||
< bs_slim = {}
|
||||
<
|
||||
< for data, handle in zip(pvlist, self.bsd.getHandles()): # self.bsd.getIsBS()):
|
||||
< bs_slim[handle] = data
|
||||
<
|
||||
< t2= time.time()
|
||||
< print("diff in reading BSDataHolderToStruc", t2 - t1)
|
||||
<
|
||||
<
|
||||
< return bs_slim
|
||||
<
|
||||
< ################################################################################
|
||||
< def getBS(self):
|
||||
<
|
||||
< if self.BSInitialized == False:
|
||||
< if self.isBSinCAOnly == False:
|
||||
< print(("Message from getBS: BS stream not initialized;"
|
||||
< "cafe.setBS(pvList) has first to be called."))
|
||||
<
|
||||
< return None
|
||||
< # CHECK STATUS!!!!
|
||||
< #print("getBS in cycafe"
|
||||
< #start = time.time()
|
||||
<
|
||||
< with nogil:
|
||||
< self._c_cafe.getBS(self.bsd)
|
||||
<
|
||||
< _bsd = BSDataHolderToStruct(self.bsd)
|
||||
< #_bsd.show()
|
||||
< return _bsd #BSDataHolderToStruct(self.bsd)
|
||||
<
|
||||
< '''
|
||||
< cdef double _pid = 0
|
||||
< _handle = self._c_cafe.getHandleFromPV(str('SIN-TIMAST-EVG0:TX-PULSEID'))
|
||||
< _stat = self._c_cafe.getCacheDouble(_handle, _pid)
|
||||
< print("cython/cafe/diff in cython ", self.bsd.getPulse_id(), _pid, _pid - self.bsd.getPulse_id())
|
||||
< t1= time.time()
|
||||
< print("diff in cython", t1 - start)
|
||||
< #print("pulse_id in cycafe", self.bsd.getPulse_id())
|
||||
<
|
||||
< BSd = BSDataHolderToStruct(self.bsd)
|
||||
< t2= time.time()
|
||||
< print("diff totol in reading BSDataHolderToStruc", t2 - start)
|
||||
<
|
||||
< return BSd
|
||||
< '''
|
||||
---
|
||||
> '''
|
||||
6258c6283
|
||||
< '''
|
||||
---
|
||||
> '''
|
||||
6274,6275c6299,6300
|
||||
< #global monDictGlobal
|
||||
< #global handleMonDictGlobal
|
||||
---
|
||||
> global monDictGlobal
|
||||
> global handleMonDictGlobal
|
||||
6284,6285c6309,6310
|
||||
< #monDictGlobal.clear()
|
||||
< #handleMonDictGlobal.clear()
|
||||
---
|
||||
> monDictGlobal.clear()
|
||||
> handleMonDictGlobal.clear()
|
||||
<
|
||||
< ################################################################################
|
||||
<
|
||||
< def closeBS(self):
|
||||
< with nogil:
|
||||
< self._c_cafe.closeBS(self.bsd)
|
||||
< self.BSInitialized = False
|
||||
< self.isBSinCAOnly = False
|
||||
<
|
||||
<
|
||||
< def getTimeoutMSBS(self):
|
||||
< return self.bsd.getTimeout()
|
||||
<
|
||||
< def setTimeoutMSBS(self, int timeoutMS):
|
||||
< self.bsd.setTimeout(timeoutMS)
|
||||
<
|
||||
<
|
||||
< def reconnectBS(self):
|
||||
< self.bsd.reconnect()
|
||||
<
|
||||
<
|
||||
< def flushBS(self):
|
||||
< self.bsd.reconnect()
|
||||
<
|
||||
<
|
||||
< def monitorPulseID(self):
|
||||
< with nogil:
|
||||
< self._c_cafe.monitorPulseID()
|
||||
<
|
||||
<
|
||||
< def monitorStopPulseID(self):
|
||||
< with nogil:
|
||||
< self._c_cafe.monitorStopPulseID()
|
||||
<
|
||||
<
|
||||
< def setPulseIDBufferSize(self, handlePV, int bufferSize = 10):
|
||||
< cdef str _METHOD = "setPulseIDBufferSize"
|
||||
<
|
||||
< cdef unsigned int handle = 0
|
||||
< if isinstance(handlePV, (int, long)):
|
||||
< handle = handlePV
|
||||
< elif isinstance(handlePV, (str)):
|
||||
< handle = self.checkForHandle(handlePV)
|
||||
< else:
|
||||
< raise Exception("{} {} \n{}".format(
|
||||
< self._exception_text, _METHOD,
|
||||
< ("First Input argument should be of type <class 'int'> if handle "
|
||||
< "else <class 'str'> if PV.")))
|
||||
<
|
||||
< self._c_cafe.setPulseIDBufferSize(handle, bufferSize)
|
||||
<
|
||||
<
|
||||
< def setPulseIDBufferSizeAll(self, int bufferSize = 10):
|
||||
< self._c_cafe.setPulseIDBufferSizeAll(bufferSize)
|
||||
<
|
||||
<
|
||||
< ###################################################################################
|
||||
<
|
||||
< def setBSInit(self, list pv):
|
||||
< self.bsd.init(pv)
|
||||
<
|
||||
<
|
||||
<
|
||||
< ##################################################################################
|
||||
< #END: cdef CAFE###################################################################
|
||||
< ##################################################################################
|
||||
|
||||
+18
-9
@@ -7,26 +7,34 @@ default_options['emit_linenums'] = True
|
||||
from Cython.Build import cythonize
|
||||
from numpy import get_include
|
||||
|
||||
|
||||
_CAFE_VERSION='1.14.2'
|
||||
_EPICS_VERSION='7.0.5'
|
||||
|
||||
|
||||
setup(
|
||||
ext_modules = cythonize([Extension('PyCafe',['PyCafe.pyx'],
|
||||
language="c++",
|
||||
include_dirs=[ '/opt/gfa/python-3.7/latest/include/python3.7m',
|
||||
os.environ['EPICS'] + '/base-7.0.4.1/include',
|
||||
os.environ['EPICS'] + '/base-7.0.4.1/include/os/Linux',
|
||||
os.environ['EPICS'] + '/base-7.0.4.1/include/compiler/gcc',
|
||||
os.environ['EPICS'] + '/base-7/include',
|
||||
os.environ['EPICS'] + '/base-7/include/os/Linux',
|
||||
os.environ['EPICS'] + '/base-7/include/compiler/gcc',
|
||||
'/opt/gfa/cafe/boost/boost_1_61_0/include',
|
||||
'/opt/gfa/cafe/boost/boost_1_61_0/include/boost',
|
||||
'/opt/gfa/cafe/cpp/cafe-1.13.0-sls2-py37-gcc-7.3.0/include',
|
||||
'/opt/gfa/cafe/cpp/cafe-' + _CAFE_VERSION +
|
||||
'-sls2-py37-gcc-7.3.0/include',
|
||||
'.', get_include()],
|
||||
library_dirs=[ os.environ['EPICS'] + '/base-7.0.4.1/lib/' + os.environ['EPICS_HOST_ARCH'],
|
||||
'/opt/gfa/cafe/cpp/cafe-1.13.0-sls2-py37-gcc-7.3.0/lib/' + os.environ['EPICS_HOST_ARCH'],
|
||||
library_dirs=[ os.environ['EPICS'] + '/base-7/lib/' + os.environ['EPICS_HOST_ARCH'],
|
||||
'/opt/gfa/cafe/cpp/cafe-' + _CAFE_VERSION +
|
||||
'-sls2-py37-gcc-7.3.0/lib/' + os.environ['EPICS_HOST_ARCH'],
|
||||
'/opt/gfa/python-3.7/latest/lib',
|
||||
os.environ['PSI_PREFIX'] + '/Programming/gcc/7.3.0/lib64',
|
||||
os.environ['PSI_PREFIX'] + '/Programming/gcc/7.3.0/lib'
|
||||
],
|
||||
runtime_library_dirs=[
|
||||
os.environ['EPICS'] + '/base-7.0.4.1/lib/' + os.environ['EPICS_HOST_ARCH'],
|
||||
'/opt/gfa/cafe/cpp/cafe-1.13.0-sls2-py37-gcc-7.3.0/lib/' + os.environ['EPICS_HOST_ARCH'],
|
||||
os.environ['EPICS'] + '/base-7/lib/' + os.environ['EPICS_HOST_ARCH'],
|
||||
'/opt/gfa/cafe/cpp/cafe-' + _CAFE_VERSION +
|
||||
'-sls2-py37-gcc-7.3.0/lib/' + os.environ['EPICS_HOST_ARCH'],
|
||||
'/opt/gfa/python-3.7/latest/lib',
|
||||
os.environ['PSI_PREFIX'] + '/Programming/gcc/7.3.0/lib64',
|
||||
os.environ['PSI_PREFIX'] + '/Programming/gcc/7.3.0/lib'
|
||||
@@ -38,6 +46,7 @@ setup(
|
||||
'py2_import': False, 'warn.unreachable': False,
|
||||
'remove_unreachable': False},
|
||||
compile_time_env={'PY_VERSION_HEX':sys.hexversion,
|
||||
'PY_EXT_C': True, 'BS_CAFE': False }
|
||||
'PY_EXT_C': True, 'BS_CAFE': False,
|
||||
'CAFE_VERSION': _CAFE_VERSION, 'EPICS_VERSION': _EPICS_VERSION }
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user