Connection time optimized
This commit is contained in:
61
PyCafe.pxd
61
PyCafe.pxd
@@ -770,42 +770,8 @@ cdef extern from "statusCodes.h":
|
||||
string message(int)
|
||||
void report(int)
|
||||
|
||||
'''
|
||||
cdef extern from "cafeService.h":
|
||||
|
||||
cdef cppclass DBPMData:
|
||||
double getValue()
|
||||
epicsTimeStamp getEpicsTimeStamp()
|
||||
int getStatus()
|
||||
|
||||
cdef cppclass DBPMKeeper:
|
||||
DBPMKeeper()
|
||||
#DBPMKeeper(vector[string], vector[unsigned int], multimap[float, string])
|
||||
DBPMKeeper(vector[string], vector[unsigned int], vector[string], vector[float])
|
||||
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()
|
||||
'''
|
||||
|
||||
cdef extern from "PVDataHolder.h":
|
||||
|
||||
@@ -970,11 +936,31 @@ cdef extern from "cafe.h":
|
||||
int init()
|
||||
int open(char *, unsigned int &) except +
|
||||
int openV(vector[string], vector[unsigned int] &) except +
|
||||
|
||||
void openNoWait() nogil
|
||||
void openPrepare() nogil
|
||||
void openGroupPrepare() nogil
|
||||
|
||||
void openNow() nogil
|
||||
void openNowAndWait(double) nogil
|
||||
void openGroupNowAndWait(double) nogil
|
||||
|
||||
void openGroupNowAndWaitForInput(double, vector[unsigned int]) nogil
|
||||
void groupOpenNowAndWait(double, vector[unsigned int]) nogil
|
||||
|
||||
void openMonitorPrepare() nogil
|
||||
void openMonitorNow() nogil
|
||||
void openMonitorNowAndWait(double) nogil
|
||||
|
||||
int closeHandlesV(vector[unsigned int]) nogil
|
||||
int close(unsigned int) nogil
|
||||
int closeChannels() nogil
|
||||
|
||||
int closeChannelKeepHandle(unsigned int) nogil
|
||||
int closeChannelsKeepHandles(vector[unsigned int]) nogil
|
||||
vector[unsigned int] closeDisconnectedChannelsFromWithinGroupV(unsigned int) nogil
|
||||
|
||||
bint allChannelsConnected()
|
||||
bint allChannelsConnected()
|
||||
bint isChannelConnected(unsigned int)
|
||||
int printDisconnectedHandles()
|
||||
int printHandle(unsigned int)
|
||||
@@ -1121,13 +1107,12 @@ cdef extern from "cafe.h":
|
||||
int setAndMatch(const unsigned int, double, const unsigned int, double tolerance, double timeout, bint printFlag) nogil
|
||||
int setAndMatchMany(vector[unsigned int], vector[double], vector[unsigned int], double tolerance, double timeout, bint printFlag) nogil
|
||||
|
||||
int gameSetAndMatch(vector[unsigned int], vector[double], vector[unsigned int], vector[string], vector[unsigned int], double tolerance, double timeout, bint printFlag) nogil
|
||||
|
||||
int match(double, const unsigned int, double tolerance, double timeout, bint printFlag) nogil
|
||||
int matchMany(vector[double], vector[unsigned int], double tolerance, double timeout, bint printFlag) nogil
|
||||
|
||||
|
||||
#int readDBPMOffsets(DBPMKeeper)
|
||||
#int getDBPM(DBPMKeeper &) nogil
|
||||
#int prepareDBPM(vector[string] &, vector[unsigned int] &, vector[string] &, vector[float] &) nogil
|
||||
|
||||
|
||||
|
||||
|
||||
406
PyCafe.pyx
406
PyCafe.pyx
@@ -5,7 +5,6 @@ cimport PyCafe as ccafe
|
||||
import numpy as np
|
||||
cimport numpy as cnp
|
||||
|
||||
|
||||
from cpython cimport array
|
||||
|
||||
import array
|
||||
@@ -32,7 +31,6 @@ include "PyCafeDefs.pxi"
|
||||
|
||||
cdef dict monDictGlobal={}
|
||||
|
||||
|
||||
##################################################################################
|
||||
cdef class CyCafe:
|
||||
|
||||
@@ -65,22 +63,14 @@ cdef class CyCafe:
|
||||
|
||||
str exString
|
||||
|
||||
cdef vector[string] bpmList
|
||||
vector[unsigned int] bpmHandles
|
||||
#multimap[float, string] floatStringMap
|
||||
#map[float, string] bpmPosDev
|
||||
vector[float] bpmPos
|
||||
vector[string] bpmDev
|
||||
###DBPMData dbpmData
|
||||
###DBPMKeeper dbpm
|
||||
###bint dbpmInitialized
|
||||
|
||||
|
||||
|
||||
def __cinit__(self):
|
||||
self._c_cafe = new ccafe.CAFE()
|
||||
if self._c_cafe is NULL:
|
||||
raise MemoryError()
|
||||
|
||||
###self.dbpmInitialized=False
|
||||
|
||||
self.cs =self._c_cafe.getCafeStatus()
|
||||
##self.css=self._c_cafe_getCafeStatusSeverity()
|
||||
@@ -98,11 +88,9 @@ cdef class CyCafe:
|
||||
#However seems to work without this call
|
||||
####Py_Initialize()
|
||||
####PyEval_InitThreads()
|
||||
|
||||
|
||||
def __dealloc__(self):
|
||||
del self._c_cafe
|
||||
|
||||
|
||||
##################################################################################
|
||||
def init(self):
|
||||
@@ -139,7 +127,7 @@ cdef class CyCafe:
|
||||
pvV.push_back( (<bytes>pv[i]).encode('utf8') )
|
||||
else:
|
||||
print ("Unknown type in {}".format(_METHOD_))
|
||||
try:
|
||||
try:
|
||||
status=self._c_cafe.openV(pvV, handleV)
|
||||
except RuntimeError as e:
|
||||
if isinstance (e.args, tuple):
|
||||
@@ -159,8 +147,8 @@ cdef class CyCafe:
|
||||
|
||||
cdef unsigned int handle=0
|
||||
|
||||
try:
|
||||
status=self._c_cafe.open(pv, handle)
|
||||
try:
|
||||
self._c_cafe.open(pv, handle)
|
||||
except RuntimeError as e:
|
||||
if isinstance (e.args, tuple):
|
||||
if 'CAFEException' in (e.args[0]):
|
||||
@@ -176,18 +164,24 @@ cdef class CyCafe:
|
||||
|
||||
##################################################################################
|
||||
def openNoWait(self):
|
||||
self._c_cafe.channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
self._c_cafe.channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT)
|
||||
#self._c_cafe.channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
#self._c_cafe.channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT)
|
||||
with nogil:
|
||||
self._c_cafe.openNoWait()
|
||||
return
|
||||
|
||||
def openPrepare(self):
|
||||
self._c_cafe.channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
self._c_cafe.channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT)
|
||||
#self._c_cafe.channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
#self._c_cafe.channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT)
|
||||
with nogil:
|
||||
self._c_cafe.openPrepare()
|
||||
return
|
||||
|
||||
def openGroupPrepare(self):
|
||||
self._c_cafe.channelOpenGroupPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
self._c_cafe.channelOpenGroupPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT)
|
||||
#self._c_cafe.channelOpenGroupPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
#self._c_cafe.channelOpenGroupPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT)
|
||||
with nogil:
|
||||
self._c_cafe.openGroupPrepare()
|
||||
return
|
||||
|
||||
def setOpenDefaultPendTime(self, double timeout):
|
||||
@@ -199,47 +193,91 @@ cdef class CyCafe:
|
||||
|
||||
##################################################################################
|
||||
def openNow(self):
|
||||
self._c_cafe.channelOpenPolicy.flushSendBufferNow()
|
||||
self._c_cafe.channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_NOW)
|
||||
self._c_cafe.channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
#self._c_cafe.channelOpenPolicy.flushSendBufferNow()
|
||||
#self._c_cafe.channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_NOW)
|
||||
#self._c_cafe.channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
with nogil:
|
||||
self._c_cafe.openNow()
|
||||
return
|
||||
|
||||
##################################################################################
|
||||
def openNowAndWait(self, double timeout):
|
||||
self._c_cafe.channelOpenPolicy.setTimeout(timeout)
|
||||
self._c_cafe.channelOpenPolicy.flushSendBufferNow()
|
||||
#self._c_cafe.channelOpenPolicy.setTimeout(timeout)
|
||||
#self._c_cafe.channelOpenPolicy.flushSendBufferNow()
|
||||
#reset
|
||||
self._c_cafe.channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_NOW)
|
||||
self._c_cafe.channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
self._c_cafe.channelOpenPolicy.setTimeoutToDefault()
|
||||
#self._c_cafe.channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_NOW)
|
||||
#self._c_cafe.channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
#self._c_cafe.channelOpenPolicy.setTimeoutToDefault()
|
||||
with nogil:
|
||||
self._c_cafe.openNowAndWait(timeout)
|
||||
return
|
||||
|
||||
##################################################################################
|
||||
|
||||
|
||||
##################################################################################
|
||||
def openGroupNowAndWait(self, double timeout):
|
||||
self._c_cafe.channelOpenGroupPolicy.setTimeout(timeout)
|
||||
self._c_cafe.channelOpenGroupPolicy.flushSendBufferNow()
|
||||
#self._c_cafe.channelOpenGroupPolicy.setTimeout(timeout)
|
||||
#self._c_cafe.channelOpenGroupPolicy.flushSendBufferNow()
|
||||
#reset
|
||||
self._c_cafe.channelOpenGroupPolicy.setWhenToFlushSendBuffer(FLUSH_NOW)
|
||||
self._c_cafe.channelOpenGroupPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
self._c_cafe.channelOpenGroupPolicy.setTimeoutToDefault()
|
||||
#self._c_cafe.channelOpenGroupPolicy.setWhenToFlushSendBuffer(FLUSH_NOW)
|
||||
#self._c_cafe.channelOpenGroupPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
#self._c_cafe.channelOpenGroupPolicy.setTimeoutToDefault()
|
||||
with nogil:
|
||||
self._c_cafe.openGroupNowAndWait(timeout)
|
||||
return
|
||||
|
||||
##################################################################################
|
||||
|
||||
|
||||
##################################################################################
|
||||
def openGroupNowAndWaitForInputGroups(self, double timeout, groupHandles):
|
||||
cdef str _METHOD_="openGroupNowAndWaitForInputGroups"
|
||||
|
||||
cdef vector[unsigned int] hList
|
||||
|
||||
if isinstance(groupHandles, (list)) == 1:
|
||||
for i in range (0, len(groupHandles)):
|
||||
if isinstance(groupHandles[i], (int,long)) == 1:
|
||||
hList.push_back(groupHandles[i])
|
||||
elif isinstance(groupHandles[i], (str)) == 1:
|
||||
hList.push_back(self.hh.getGroupHandleFromGroupName(groupHandles[i]))
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"List input arguments, should be <type 'int'> if group handle, else <type 'str'> if group name"))
|
||||
|
||||
elif isinstance(groupHandles, (int,long)) == 1:
|
||||
hList.push_back(groupHandles)
|
||||
elif isinstance(groupHandles, (str)) == 1:
|
||||
hList.push_back(self.hh.getGroupHandleFromGroupName(groupHandles))
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"Second input argument (if not a list), should be <type 'int'> if group handle, else <type 'str'> if group name"))
|
||||
|
||||
|
||||
#list to vector
|
||||
with nogil:
|
||||
self._c_cafe.groupOpenNowAndWait(timeout, hList)
|
||||
return
|
||||
|
||||
##################################################################################
|
||||
|
||||
def openMonitorPrepare(self):
|
||||
self._c_cafe.channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO)
|
||||
self._c_cafe.channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT)
|
||||
#self._c_cafe.channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO)
|
||||
#self._c_cafe.channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT)
|
||||
with nogil:
|
||||
self._c_cafe.openMonitorPrepare()
|
||||
return
|
||||
|
||||
|
||||
##################################################################################
|
||||
def openMonitorNow(self):
|
||||
self._c_cafe.channelMonitorPolicy.flushSendBufferNow()
|
||||
#self._c_cafe.channelMonitorPolicy.flushSendBufferNow()
|
||||
#reset
|
||||
self._c_cafe.channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_NOW)
|
||||
self._c_cafe.channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO)
|
||||
#self._c_cafe.channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_NOW)
|
||||
#self._c_cafe.channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO)
|
||||
with nogil:
|
||||
self._c_cafe.openMonitorNow()
|
||||
time.sleep(0.1)
|
||||
return
|
||||
|
||||
@@ -256,30 +294,34 @@ cdef class CyCafe:
|
||||
|
||||
##################################################################################
|
||||
def openMonitorNowAndWait(self, double timeout):
|
||||
self._c_cafe.channelMonitorPolicy.setTimeout(timeout)
|
||||
self._c_cafe.channelMonitorPolicy.flushSendBufferNow()
|
||||
time.sleep(timeout)
|
||||
#self._c_cafe.channelMonitorPolicy.setTimeout(timeout)
|
||||
#self._c_cafe.channelMonitorPolicy.flushSendBufferNow()
|
||||
#time.sleep(timeout)
|
||||
#reset
|
||||
self._c_cafe.channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_NOW)
|
||||
self._c_cafe.channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO)
|
||||
#self._c_cafe.channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_NOW)
|
||||
#self._c_cafe.channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO)
|
||||
with nogil:
|
||||
self._c_cafe.openMonitorNowAndWait(timeout)
|
||||
return
|
||||
|
||||
##################################################################################
|
||||
|
||||
def ca_pend_event(self, double timeout):
|
||||
def ca_pend_event(self, double timeout):
|
||||
self._c_cafe._ca_pend_event(timeout)
|
||||
return
|
||||
|
||||
def ca_pend_io(self, timeout):
|
||||
def ca_pend_io(self, double timeout):
|
||||
self._c_cafe._ca_pend_io(timeout)
|
||||
return
|
||||
|
||||
def ca_poll(self):
|
||||
self._c_cafe._ca_poll()
|
||||
with nogil:
|
||||
self._c_cafe._ca_poll()
|
||||
return
|
||||
|
||||
def ca_flush_io(self):
|
||||
self._c_cafe._ca_flush_io()
|
||||
with nogil:
|
||||
self._c_cafe._ca_flush_io()
|
||||
return
|
||||
|
||||
##################################################################################
|
||||
@@ -599,7 +641,7 @@ cdef class CyCafe:
|
||||
def closeHandles(self, list handleList):
|
||||
cdef str _METHOD_="closeHandlesV"
|
||||
if isinstance(handleList[0], (str)):
|
||||
handleList=self.checkForHandleList(handleList)
|
||||
handleList=self.checkForHandleList(handleList, force=False)
|
||||
elif not isinstance(handleList[0], (int, long)):
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be a 'list' of <type 'int'> if handles or <type 'str'> if PVs"))
|
||||
@@ -613,6 +655,67 @@ cdef class CyCafe:
|
||||
stat=self._c_cafe.closeHandlesV(v)
|
||||
return stat
|
||||
|
||||
|
||||
##################################################################################
|
||||
def closeDisconnectedChannelsWithinGroup(self, ghandleName):
|
||||
cdef str _METHOD_="closeDisconnectedChannelsWithinGroup"
|
||||
cdef vector[unsigned int] hList
|
||||
cdef vector[unsigned int] disHandles
|
||||
|
||||
if isinstance(ghandleName, (list)) == 1:
|
||||
for i in range (0, len(ghandleName)):
|
||||
if isinstance(ghandleName[i], (int,long)) == 1:
|
||||
hList.push_back(ghandleName[i])
|
||||
elif isinstance(ghandleName[i], (str)) == 1:
|
||||
hList.push_back(self.checkForGroupHandle(ghandleName[i]))
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"List input arguments, should be <type 'int'> if group handle, else <type 'str'> if group name"))
|
||||
|
||||
elif isinstance(ghandleName, (int,long)) == 1:
|
||||
hList.push_back(ghandleName)
|
||||
elif isinstance(ghandleName, (str)) == 1:
|
||||
hList.push_back(self.checkForGroupHandle(ghandleName))
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument (if not list), should be <type 'int'> if group handle, else <type 'str'> if group name"))
|
||||
|
||||
for i in range (0, len(hList)):
|
||||
with nogil:
|
||||
self._c_cafe.closeDisconnectedChannelsFromWithinGroupV(hList[i])
|
||||
return
|
||||
|
||||
|
||||
##################################################################################
|
||||
def closeChannelKeepHandle(self, handlePV):
|
||||
cdef str _METHOD_="closeChannelKeepHandle"
|
||||
|
||||
cdef vector[unsigned int] hList
|
||||
cdef int statusClose
|
||||
|
||||
if isinstance(handlePV, (list)) == 1:
|
||||
for i in range (0, len(handlePV)):
|
||||
if isinstance(handlePV[i], (int,long)) == 1:
|
||||
hList.push_back(handlePV[i])
|
||||
elif isinstance(handlePV[i], (str)) == 1:
|
||||
hList.push_back(self.checkForHandle(handlePV[i]))
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"List input arguments, should be <type 'int'> if group handle, else <type 'str'> if group name"))
|
||||
|
||||
elif isinstance(handlePV, (int,long)) == 1:
|
||||
hList.push_back(handlePV)
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
hList.push_back(self.checkForHandle(handlePV))
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument (if not list), should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
|
||||
with nogil:
|
||||
statusClose= self._c_cafe.closeChannelsKeepHandles(hList)
|
||||
return statusClose
|
||||
|
||||
|
||||
##################################################################################
|
||||
def allConnected(self):
|
||||
return <bint>self._c_cafe.allChannelsConnected()
|
||||
@@ -3065,12 +3168,11 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
|
||||
statusNoWait=self._c_cafe.getCachePVArrayNoWait(v, pvd)
|
||||
|
||||
|
||||
statusList=[]
|
||||
statusFlag=True
|
||||
statusLocal=ICAFE_NORMAL
|
||||
if (cacheFlag==True):
|
||||
|
||||
|
||||
if (cacheFlag==True):
|
||||
for i in range(0, len(handleList)):
|
||||
statusList.append(pvd[i].getStatus())
|
||||
if pvd[i].getStatus() != ICAFE_NORMAL:
|
||||
@@ -3082,8 +3184,6 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
statusLocal =pvd[i].getStatus()
|
||||
statusFlag=False
|
||||
|
||||
|
||||
|
||||
cdef unsigned int dtn
|
||||
|
||||
localList=[]
|
||||
@@ -4225,7 +4325,7 @@ No of group members doe not match the length of callback object list")
|
||||
if status == ECA_TIMEOUT :
|
||||
print ("======================================================")
|
||||
self._c_cafe.printStatusMessage(status)
|
||||
print ("TIMEOUT in getGroup; swithing to getCompoundList")
|
||||
print ("TIMEOUT in getGroup; switching to getCompoundList")
|
||||
print ("======================================================")
|
||||
return self.getCompoundList(pvg.getNameAsString(), dt)
|
||||
|
||||
@@ -5649,6 +5749,120 @@ Unknown data input; should be one of <type 'int'> , <type 'str'>, <type 'float'>
|
||||
##################################################################################
|
||||
|
||||
|
||||
|
||||
##################################################################################
|
||||
def gameSetAndMatch(self, list handlePVSet, list valSet, handlePVAction, valAction, list handlePVMatch, double tolerance, double timeout, bint printFlag):
|
||||
cdef str _METHOD_="setAndMatchMany(list handlePVSet, list valSet, list handlePVMatch, double tolerance, double timeout, bint printFlag)"
|
||||
|
||||
if not isinstance(handlePVSet, (list)):
|
||||
raise Exception ("EXCEPTION RAISED IN PyCafe def setAndMatchMany. \n\
|
||||
First input argument, should be <type 'list'> of handles or PVs")
|
||||
|
||||
if not isinstance(valSet, (list)):
|
||||
raise Exception ("EXCEPTION RAISED IN PyCafe def setAndMatchMany. \n\
|
||||
Second input argument, should be <type 'list'> of scalar values")
|
||||
|
||||
if not isinstance(handlePVMatch, (list)):
|
||||
raise Exception ("EXCEPTION RAISED IN PyCafe def setAndMatchMany. \n\
|
||||
Third input argument, should be <type 'list'> of handles or PVs")
|
||||
|
||||
if (len(handlePVSet) != len(valSet)):
|
||||
raise Exception ("EXCEPTION RAISED IN PyCafe def setAndMatchMany. \n\
|
||||
Lengths of first (handlePVSet) and second (valSet) input lists must match!")
|
||||
|
||||
if (len(handlePVSet) != len(handlePVMatch)):
|
||||
raise Exception ("EXCEPTION RAISED IN PyCafe def setAndMatchMany. \n\
|
||||
Lengths of first (handlePVSet) and third (handlePVMatch) input lists must match!")
|
||||
|
||||
|
||||
|
||||
if not isinstance(handlePVAction, (list)):
|
||||
tmp = handlePVAction
|
||||
handlePVAction = []
|
||||
handlePVAction.append(tmp)
|
||||
|
||||
if not isinstance(valAction, (list)):
|
||||
tmp = valAction
|
||||
valAction = []
|
||||
valAction.append(tmp)
|
||||
|
||||
|
||||
cdef vector[unsigned int] handleSet
|
||||
handleSet.reserve(len(handlePVSet))
|
||||
|
||||
cdef vector[unsigned int] handleMatch
|
||||
handleMatch.reserve(len(handlePVMatch))
|
||||
|
||||
cdef vector[double] valSetV
|
||||
valSetV.reserve(len(valSet))
|
||||
|
||||
|
||||
cdef vector[unsigned int] handleAction
|
||||
handleAction.reserve(len(handlePVAction))
|
||||
|
||||
|
||||
cdef vector[string] valActionV
|
||||
valActionV.reserve(len(valAction))
|
||||
|
||||
|
||||
for i in range(0, len(handlePVSet)):
|
||||
if isinstance(handlePVSet[i], (int,long)) == 1:
|
||||
handleSet.push_back(handlePVSet[i])
|
||||
elif isinstance(handlePVSet[i], (str)) == 1:
|
||||
handleSet.push_back(self.checkForHandle(handlePVSet))
|
||||
else:
|
||||
_cyCafeException = CyCafeException(_type='cafe',_source=_METHOD_, \
|
||||
_ei="ThandlePVSet list member should be <type 'int'> if handle, else <type 'str'> if PV")
|
||||
raise Exception(_cyCafeException)
|
||||
|
||||
for i in range(0, len(handlePVMatch)):
|
||||
if isinstance(handlePVMatch[i], (int,long)) == 1:
|
||||
handleMatch.push_back(handlePVMatch[i])
|
||||
elif isinstance(handlePVMatch[i], (str)) == 1:
|
||||
handleMatch.push_back(self.checkForHandle(handlePVMatch))
|
||||
else:
|
||||
_cyCafeException = CyCafeException(_type='cafe',_source=_METHOD_, \
|
||||
_ei="handleMatch list member should be <type 'int'> if handle, else <type 'str'> if PV")
|
||||
raise Exception(_cyCafeException)
|
||||
|
||||
|
||||
for i in range(0, len(handlePVAction)):
|
||||
if isinstance(handlePVAction[i], (int,long)) == 1:
|
||||
handleAction.push_back(handlePVAction[i])
|
||||
elif isinstance(handlePVAction[i], (str)) == 1:
|
||||
handleAction.push_back(self.checkForHandle(handlePVAction))
|
||||
else:
|
||||
_cyCafeException = CyCafeException(_type='cafe',_source=_METHOD_, \
|
||||
_ei="handlePVAction list member should be <type 'int'> if handle, else <type 'str'> if PV")
|
||||
raise Exception(_cyCafeException)
|
||||
|
||||
for i in range(0, len(valAction)):
|
||||
if not isinstance(valAction[i], (str)):
|
||||
valActionV.push_back(str(valAction[i]))
|
||||
else:
|
||||
valActionV.push_back(valAction[i])
|
||||
|
||||
|
||||
for i in range(0, len(valSet)):
|
||||
valSetV.push_back(valSet[i])
|
||||
|
||||
cdef int status
|
||||
|
||||
|
||||
with nogil:
|
||||
status=self._c_cafe.gameSetAndMatch(handleSet, valSetV, handleAction, valActionV, handleMatch, tolerance, timeout, printFlag)
|
||||
|
||||
if status !=ICAFE_NORMAL:
|
||||
if PYCAFE_PRINT_LEVEL>=PYCAFE_PRINT_LOW:
|
||||
self._c_cafe.printStatusMessage(status)
|
||||
raise Exception("EXCEPTION RAISED in PyCafe def gameSetAndMatch. Status = %d" %status)
|
||||
|
||||
return status
|
||||
##################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
##################################################################################
|
||||
def setAndMatchMany(self, list handlePVSet, list valSet, list handlePVMatch, double tolerance, double timeout, bint printFlag):
|
||||
cdef str _METHOD_="setAndMatchMany(list handlePVSet, list valSet, list handlePVMatch, double tolerance, double timeout, bint printFlag)"
|
||||
@@ -5960,86 +6174,8 @@ First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"
|
||||
##################################################################################
|
||||
|
||||
|
||||
'''
|
||||
##################################################################################
|
||||
def prepareSFdbpm(self):
|
||||
##################################################################################
|
||||
self._c_cafe.prepareDBPM(self.bpmList, self.bpmHandles, self.bpmDev, self.bpmPos) #self.bpmPosDev)
|
||||
|
||||
#for i in range(0, self.bpmDev.size()):
|
||||
#print (self.bpmPos[i], self.bpmDev[i] )
|
||||
|
||||
if not self.dbpmInitialized:
|
||||
self.dbpm= DBPMKeeper(self.bpmList,self.bpmHandles, self.bpmDev, self.bpmPos) #self.bpmPosDev)
|
||||
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
|
||||
|
||||
with nogil:
|
||||
status=self._c_cafe.getDBPM(self.dbpm)
|
||||
|
||||
if status !=ICAFE_NORMAL:
|
||||
if PYCAFE_PRINT_LEVEL>=PYCAFE_PRINT_LOW:
|
||||
self._c_cafe.printStatusMessage(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()
|
||||
|
||||
|
||||
###################################################################################
|
||||
##################################################################################
|
||||
#END: cdef CAFE###################################################################
|
||||
##################################################################################
|
||||
'''
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
source /opt/gfa/python 3.5
|
||||
python setup3.5_release.py build_ext -i
|
||||
export PYTHONPATH=.:/opt/gfa/cafe/python/python-3.5/pycafe-1.3.0-final-2/lib
|
||||
export PYTHONPATH=.:/opt/gfa/cafe/python/python-3.5/pycafe-1.5.0-final-1/lib
|
||||
export LD_LIBRARY_PATH=./
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
##### CHANGE AS APPROPRIATE #################
|
||||
#Cython Version to install
|
||||
CYCAFE_VERSION=pycafe-1.3.0-final-2
|
||||
CYCAFE_VERSION=pycafe-1.5.0-final-1
|
||||
|
||||
#CAFE project base
|
||||
#CAFE_BASE=${EPICS_EXTENSIONS}/CAFE
|
||||
|
||||
@@ -13,14 +13,14 @@ setup(
|
||||
'/usr/local/epics/base/include/os/Linux',
|
||||
'/opt/gfa/cafe/boost/boost_1_61_0/include',
|
||||
'/opt/gfa/cafe/boost/boost_1_61_0/include/boost',
|
||||
'/opt/gfa/cafe/python/python-3.5/pycafe-1.3.0-final-2/include',
|
||||
'/opt/gfa/cafe/python/python-3.5/pycafe-1.5.0-final-1/include',
|
||||
'.', get_include()],
|
||||
library_dirs=[ '/usr/local/epics/base/lib/SL6-x86_64',
|
||||
'/opt/gfa/cafe/python/python-3.5/pycafe-1.3.0-final-2/lib',
|
||||
'/opt/gfa/cafe/python/python-3.5/pycafe-1.5.0-final-1/lib',
|
||||
'/opt/gfa/python-3.5/latest/lib'
|
||||
],
|
||||
runtime_library_dirs=['/usr/local/epics/base/lib/SL6-x86_64',
|
||||
'/opt/gfa/cafe/python/python-3.5/pycafe-1.3.0-final-2/lib',
|
||||
'/opt/gfa/cafe/python/python-3.5/pycafe-1.5.0-final-1/lib',
|
||||
'/opt/gfa/python-3.5/latest/lib'
|
||||
],
|
||||
libraries=['ca','Com','dl','cafe'])
|
||||
|
||||
Reference in New Issue
Block a user