Compare commits
3 Commits
pycafe-1.5
...
cafe-1.8.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 603eda7531 | |||
| a3690b06e4 | |||
| 8e1a1595e0 |
216
PyCafe.pxd
216
PyCafe.pxd
@@ -77,6 +77,29 @@ cdef extern from "cadef.h":
|
||||
int ca_poll()
|
||||
|
||||
|
||||
cdef extern from "defines.h":
|
||||
unsigned short BSREAD_ZEROMQ_HIGH_WATER_MARK
|
||||
short BSREAD_ZEROMQ_TIMEOUT_MS
|
||||
const short PVNAME_SIZE
|
||||
ctypedef struct etsDate:
|
||||
int year
|
||||
int mon
|
||||
int day
|
||||
int hour
|
||||
int min
|
||||
int sec
|
||||
unsigned long nsec
|
||||
int wday
|
||||
int yday
|
||||
int isdst
|
||||
pass
|
||||
|
||||
ctypedef struct etsNorm:
|
||||
unsigned int secPastEpoch
|
||||
unsigned int nsec
|
||||
pass
|
||||
|
||||
|
||||
cdef extern from "caeventmask.h":
|
||||
#ctypedef enum DBE_TYPE:
|
||||
# DBE_VALUE=1
|
||||
@@ -286,10 +309,49 @@ cdef extern from "caopCodes.h":
|
||||
show()
|
||||
|
||||
|
||||
cdef extern from "defines.h":
|
||||
const short PVNAME_SIZE
|
||||
#cdef extern from "defines.h":
|
||||
# const short PVNAME_SIZE
|
||||
|
||||
|
||||
|
||||
cdef extern from "tmDateMap.h":
|
||||
ctypedef enum TM_WDAY:
|
||||
TM_SUNDAY = 0
|
||||
TM_MONDAY = 1
|
||||
TM_TUESDAY = 2
|
||||
TM_WEDNESDAY = 3
|
||||
TM_THURSDAY = 4
|
||||
TM_FRIDAY = 5
|
||||
TM_SATURDAY = 6
|
||||
|
||||
ctypedef enum TM_MONTHP:
|
||||
TM_JAN = 1
|
||||
TM_FEB = 2
|
||||
TM_MAR = 3
|
||||
TM_APR = 4
|
||||
TM_MAY = 5
|
||||
TM_JUN = 6
|
||||
TM_JUL = 7
|
||||
TM_AUG = 8
|
||||
TM_SEP = 9
|
||||
TM_OCT =10
|
||||
TM_NOV =11
|
||||
TM_DEC =12
|
||||
|
||||
cdef cppclass TMwdayText:
|
||||
string message(int)
|
||||
string asString(int)
|
||||
int enumIs(string)
|
||||
int asEnum(string)
|
||||
show()
|
||||
|
||||
cdef cppclass TMmonthpText:
|
||||
string message(int)
|
||||
string asString(int)
|
||||
int enumIs(string)
|
||||
int asEnum(string)
|
||||
show()
|
||||
|
||||
cdef extern from "cafeDataType.h":
|
||||
ctypedef enum CAFE_DATATYPE:
|
||||
CAFE_TYPENOTCONN =-1
|
||||
@@ -321,7 +383,9 @@ cdef extern from "cafeDataType.h":
|
||||
cdef cppclass CAFEDataTypeCode:
|
||||
pass
|
||||
string message(int)
|
||||
string asString(int)
|
||||
int enumIs(string)
|
||||
int asEnum(string)
|
||||
show()
|
||||
|
||||
cdef extern from "cafeEnum.h":
|
||||
@@ -446,21 +510,15 @@ cdef extern from "channelRegalia.h":
|
||||
string getConnectionStateAsString()
|
||||
string getCafeConnectionStateAsString()
|
||||
|
||||
cdef extern from "handleHelper.h":
|
||||
ctypedef struct etsDate:
|
||||
int year
|
||||
int mon
|
||||
int day
|
||||
int hour
|
||||
int min
|
||||
int sec
|
||||
unsigned long nsec
|
||||
cdef cppclass ChannelDataStore:
|
||||
string description
|
||||
ChannelRegalia info
|
||||
PVDataHolder pvd
|
||||
PVCtrlHolder pvc
|
||||
pass
|
||||
|
||||
ctypedef struct etsNorm:
|
||||
unsigned int secPastEpoch
|
||||
unsigned int nsec
|
||||
pass
|
||||
|
||||
cdef extern from "handleHelper.h":
|
||||
|
||||
|
||||
cdef cppclass HandleHelper:
|
||||
etsDate _etsDate
|
||||
@@ -470,6 +528,7 @@ cdef extern from "handleHelper.h":
|
||||
|
||||
int checkConsistency(unsigned int)
|
||||
|
||||
vector[string] getEnumStrings(unsigned int)
|
||||
string getStringFromEnum(unsigned int, unsigned short)
|
||||
short getEnumFromString(unsigned int, string)
|
||||
|
||||
@@ -485,7 +544,16 @@ cdef extern from "handleHelper.h":
|
||||
chtype getDbrDataTypeCB(unsigned int)
|
||||
DBR_TYPE getCafeDbrTypeCB(unsigned int)
|
||||
|
||||
int getDescription(unsigned int, string &)
|
||||
int getUnits (unsigned int, string &)
|
||||
int getPrecision (unsigned int, short &)
|
||||
|
||||
|
||||
int getChannelDevice (unsigned int, string &)
|
||||
int getChannelAttribute(unsigned int, string &)
|
||||
|
||||
int getStatus (unsigned int)
|
||||
bint hasAlarmStatusSeverity(unsigned int)
|
||||
int getAlarmStatusSeverity(unsigned int, short[2])
|
||||
int [] getTimeStamp(unsigned int, epicsTimeStamp &ts)
|
||||
|
||||
@@ -510,11 +578,15 @@ cdef extern from "handleHelper.h":
|
||||
unsigned int getNmonitor (unsigned int)
|
||||
vector[unsigned int] getMonitorIDs(unsigned int)
|
||||
|
||||
int getDataTypeNative (unsigned int, long)
|
||||
int getDataTypeRequest(unsigned int, long)
|
||||
int getDataTypeNative (unsigned int, long &)
|
||||
int getDataTypeRequest(unsigned int, long &)
|
||||
|
||||
etsNorm getEpicsTimeStampAsUInt32(unsigned int)
|
||||
etsDate getEpicsTimeStampAsDate(unsigned int)
|
||||
etsDate epicsTimeStampToDate(epicsTimeStamp)
|
||||
etsDate etsNormToDate(etsNorm)
|
||||
etsDate unixTimeToDate(etsNorm)
|
||||
string etsDateAsString(etsNorm)
|
||||
|
||||
int printHandlesV(vector[unsigned int])
|
||||
|
||||
@@ -675,6 +747,10 @@ cdef extern from "statusCodes.h":
|
||||
cdef int ICAFE_STATUS_CA_OP = 800
|
||||
cdef int ICAFE_STATUS_ERROR = 1000
|
||||
cdef int ICAFE_FILE_ERROR = 1100
|
||||
cdef int ICAFE_SERVICE_ERROR =1200;
|
||||
cdef int ICAFE_BITSHUFFLE_ERROR =1300;
|
||||
cdef int ICAFE_BSREAD_BASE = 1500;
|
||||
cdef int ICAFE_ERRNO_BASE = 5000;
|
||||
cdef int ICAFE_SUCCESS = ECA_NORMAL
|
||||
cdef int ICAFE_NORMAL = ECA_NORMAL
|
||||
|
||||
@@ -749,7 +825,62 @@ cdef extern from "statusCodes.h":
|
||||
ECAFE_PVGROUP_GROUPHANDLE_MISMATCH
|
||||
ECAFE_TIMEOUT_SET_AND_MATCH
|
||||
ECAFE_HANDLE_MISMATCH_SET_AND_MATCH
|
||||
|
||||
ECAFE_INCONSISTENT_CONTAINER_CORRECTED
|
||||
|
||||
ctypedef enum CAFE_SERVICE_ERROR:
|
||||
ECAFE_BPM_DATA_IS_INVALID=1200
|
||||
|
||||
ctypedef enum CAFE_BITSHUFFLE_ERROR:
|
||||
ECAFE_BITSHUFF_DECOMPRESS=1300
|
||||
ECAFE_BITSHUFF_ALLOCMEM
|
||||
ECAFE_BITSHUFF_REALLOCMEM
|
||||
ECAFE_BITSHUFF_BADCOUNT
|
||||
|
||||
ctypedef enum CAFE_BSREAD_ERROR:
|
||||
ECAFE_BSREAD_MULTIPART_MESS_NODATA=1500
|
||||
ECAFE_BSREAD_PARSEFAIL_MAINHEADER
|
||||
ECAFE_BSREAD_PARSEFAIL_DATAHEADER
|
||||
ECAFE_BSREAD_ZMQSTREAM_NULL
|
||||
|
||||
ctypedef enum CAFE_ERRNO_ERROR:
|
||||
ERRNO_EINTR=5004
|
||||
ERRNO_EAGAIN=5011
|
||||
ERRNO_EFAULT=5014
|
||||
ERRNO_EINVAL=5022
|
||||
ERRNO_ENOTSOCK=5088
|
||||
ERRNO_EPROTONOSUPPORT=5093
|
||||
|
||||
ctypedef enum EPICS_GLOBAL_ALARM_SEVERITY:
|
||||
SEV_NO_ALARM=0
|
||||
SEV_MINOR
|
||||
SEV_MAJOR
|
||||
SEV_INVALID
|
||||
|
||||
ctypedef enum EPICS_GLOBAL_ALARM_CONDITION:
|
||||
STAT_NO_ALARM=0
|
||||
STAT_READ
|
||||
STAT_WRITE
|
||||
STAT_HIHI
|
||||
STAT_HIGH
|
||||
STAT_LOLO
|
||||
STAT_LOW
|
||||
STAT_STATE
|
||||
STAT_COS
|
||||
STAT_COMM
|
||||
STAT_TIMEOUT
|
||||
STAT_HWLIMIT
|
||||
STAT_CALC
|
||||
STAT_SCAN
|
||||
STAT_LINK
|
||||
STAT_SOFT
|
||||
STAT_BAD_SUB
|
||||
STAT_UDF
|
||||
STAT_DISABLE
|
||||
STAT_SIMM
|
||||
STAT_READ_ACCESS
|
||||
STAT_WRITE_ACCESS
|
||||
|
||||
|
||||
cdef cppclass CAFEStatusSeverity:
|
||||
CAFEStatusSeverity()
|
||||
string message (int)
|
||||
@@ -759,28 +890,35 @@ cdef extern from "statusCodes.h":
|
||||
string message (int)
|
||||
|
||||
cdef cppclass CAFEStatusCode:
|
||||
CAFEStatusCode()
|
||||
CAFEStatusCode()
|
||||
void getStates(vector[int], vector[string])
|
||||
string message (int)
|
||||
string msgIDAsString(int)
|
||||
int enumIs(string)
|
||||
bint isTimeout(int)
|
||||
void printAll()
|
||||
|
||||
cdef cppclass CAFEStatus:
|
||||
CAFEStatus()
|
||||
string severity(int)
|
||||
string asString(int)
|
||||
string msgID(int)
|
||||
string code(int)
|
||||
string info(int)
|
||||
string message(int)
|
||||
bint isTimeout(int)
|
||||
void report(int)
|
||||
|
||||
|
||||
|
||||
|
||||
cdef extern from "PVDataHolder.h":
|
||||
|
||||
cdef cppclass PVDataHolder:
|
||||
etsDate _etsDate
|
||||
etsNorm _etsNorm
|
||||
|
||||
PVDataHolder()
|
||||
PVDataHolder(unsigned int)
|
||||
PVDataHolder() except +
|
||||
PVDataHolder(unsigned int) except +
|
||||
#shared_ptr [CAFE_DATATYPE_UNION []] val;
|
||||
#shared_ptr[double []] getDouble()
|
||||
#shared_ptr[float []] getFloat()
|
||||
@@ -814,6 +952,7 @@ cdef extern from "PVDataHolder.h":
|
||||
string getWFAsString()
|
||||
string concatToString()
|
||||
|
||||
unsigned long long getPulseID()
|
||||
|
||||
unsigned int getUserNo()
|
||||
|
||||
@@ -835,10 +974,16 @@ cdef extern from "PVDataHolder.h":
|
||||
|
||||
int getAlarmStatus()
|
||||
int getAlarmSeverity()
|
||||
string getAlarmStatusAsString()
|
||||
string getAlarmSeverityAsString()
|
||||
int getStatus()
|
||||
string getStatusAsString()
|
||||
|
||||
etsNorm getEpicsTimeStampAsUInt32()
|
||||
etsDate getEpicsTimeStampAsDate()
|
||||
etsDate getUnixTimeAsDate(etsNorm)
|
||||
string getEpicsTimeStampAsString()
|
||||
string getBSTimeStampAsString()
|
||||
|
||||
unsigned int getDataType()
|
||||
char * getPV()
|
||||
@@ -850,8 +995,8 @@ cdef extern from "PVCtrlHolder.h":
|
||||
|
||||
cdef cppclass PVCtrlHolder:
|
||||
|
||||
PVCtrlHolder()
|
||||
PVCtrlHolder(unsigned int)
|
||||
PVCtrlHolder() except +
|
||||
PVCtrlHolder(unsigned int) except +
|
||||
|
||||
short getPrecision()
|
||||
const char * getUnits()
|
||||
@@ -959,7 +1104,12 @@ cdef extern from "cafe.h":
|
||||
int closeChannelKeepHandle(unsigned int) nogil
|
||||
int closeChannelsKeepHandles(vector[unsigned int]) nogil
|
||||
vector[unsigned int] closeDisconnectedChannelsFromWithinGroupV(unsigned int) nogil
|
||||
|
||||
|
||||
int supplementHandles()
|
||||
int supplementHandlesV(vector[unsigned int])
|
||||
int supplementHandle(unsigned int)
|
||||
|
||||
|
||||
bint allChannelsConnected()
|
||||
bint isChannelConnected(unsigned int)
|
||||
int printDisconnectedHandles()
|
||||
@@ -984,6 +1134,7 @@ cdef extern from "cafe.h":
|
||||
|
||||
void loadSFGroups(string)
|
||||
|
||||
int getChannelDataStore(unsigned int, ChannelDataStore) nogil
|
||||
int getChannelInfo(unsigned int, ChannelRegalia)
|
||||
|
||||
CAFEStatus getCafeStatus()
|
||||
@@ -1039,6 +1190,12 @@ cdef extern from "cafe.h":
|
||||
int waitForBundledEvents(vector[unsigned int], vector[int]) nogil
|
||||
int waitForGetEvent(unsigned int) nogil
|
||||
|
||||
#bs read
|
||||
int monitorPulseID()
|
||||
int monitorStopPulseID()
|
||||
int setPulseIDBufferSize(unsigned int, unsigned short)
|
||||
int setPulseIDBufferSizeAll(unsigned short)
|
||||
|
||||
int monitorStart(unsigned int, MonitorPolicy &) nogil
|
||||
int monitorStopAll() nogil
|
||||
int monitorStop(unsigned int) nogil
|
||||
@@ -1111,10 +1268,7 @@ cdef extern from "cafe.h":
|
||||
|
||||
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 setNelemToOne(const unsigned int)
|
||||
int setNelemToPrevious(const unsigned int, const unsigned int)
|
||||
@@ -1122,5 +1276,5 @@ cdef extern from "cafe.h":
|
||||
int setNelemToRetrieveFromCacheToPrevious(const unsigned int, const unsigned int)
|
||||
int getNelemToRetrieveFromCache(const unsigned int)
|
||||
int terminate() nogil
|
||||
|
||||
|
||||
pass
|
||||
|
||||
BIN
PyCafe.pyd
BIN
PyCafe.pyd
Binary file not shown.
493
PyCafe.pyx
493
PyCafe.pyx
@@ -1,4 +1,4 @@
|
||||
#distutils: language = c++
|
||||
#dtutils: language = c++
|
||||
# file: PyCafe.pyx
|
||||
|
||||
cimport PyCafe as ccafe
|
||||
@@ -21,6 +21,7 @@ import os
|
||||
import cython
|
||||
import inspect
|
||||
import sys
|
||||
import numbers
|
||||
|
||||
#from libcpp.string cimport string
|
||||
|
||||
@@ -31,6 +32,8 @@ include "PyCafeDefs.pxi"
|
||||
|
||||
cdef dict monDictGlobal={}
|
||||
|
||||
#DEF HAVE_BSREAD=1
|
||||
|
||||
##################################################################################
|
||||
cdef class CyCafe:
|
||||
|
||||
@@ -63,14 +66,19 @@ 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
|
||||
|
||||
|
||||
def __cinit__(self):
|
||||
self._c_cafe = new ccafe.CAFE()
|
||||
if self._c_cafe is NULL:
|
||||
raise MemoryError()
|
||||
|
||||
|
||||
|
||||
self.cs =self._c_cafe.getCafeStatus()
|
||||
##self.css=self._c_cafe_getCafeStatusSeverity()
|
||||
@@ -110,6 +118,9 @@ cdef class CyCafe:
|
||||
#def getMonDict(self):
|
||||
# return self.monDict
|
||||
|
||||
|
||||
|
||||
|
||||
##################################################################################
|
||||
def open(self, pv):
|
||||
cdef str _METHOD_="open(pv)"
|
||||
@@ -157,21 +168,21 @@ cdef class CyCafe:
|
||||
raise Exception(_cyCafeException)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, e.what()))
|
||||
|
||||
#print ("******************** HANDLE *******", handle);
|
||||
|
||||
#A notch to allow for possible race condition
|
||||
if (self.isConnected(handle)==False):
|
||||
time.sleep(0.02)
|
||||
return handle
|
||||
|
||||
##################################################################################
|
||||
def openNoWait(self):
|
||||
#self._c_cafe.channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT)
|
||||
#self._c_cafe.channelOpenPolicy.setFlushSendBufferKind(WITH_POLL)
|
||||
#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.setFlushSendBufferKind(WITH_POLL)
|
||||
#self._c_cafe.channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT)
|
||||
with nogil:
|
||||
self._c_cafe.openPrepare()
|
||||
@@ -301,7 +312,7 @@ cdef class CyCafe:
|
||||
#self._c_cafe.channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_NOW)
|
||||
#self._c_cafe.channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO)
|
||||
with nogil:
|
||||
self._c_cafe.openMonitorNowAndWait(timeout)
|
||||
self._c_cafe.openMonitorNowAndWait(timeout)
|
||||
return
|
||||
|
||||
##################################################################################
|
||||
@@ -577,17 +588,83 @@ cdef class CyCafe:
|
||||
return gList
|
||||
##################################################################################
|
||||
|
||||
def getDataTypeNative(self, handlePV):
|
||||
cdef str _METHOD_="getDataTypeNative(handlePV)"
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(handlePV)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
|
||||
cdef long ndt=-1
|
||||
|
||||
self.hh.getDataTypeNative(handle, ndt)
|
||||
return ndt
|
||||
|
||||
def getDataTypeRequest(self,handlePV):
|
||||
cdef str _METHOD_="getDataTypeRequest(handlePV)"
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(handlePV)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
|
||||
cdef long rdt=-1
|
||||
self.hh.getDataTypeRequest(handle, rdt)
|
||||
return rdt
|
||||
|
||||
def getMonitorIDInCallback(self, handle):
|
||||
def getMonitorIDInCallback(self, handlePV):
|
||||
cdef str _METHOD_="getMonitorIDInCallback(handlePV)"
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(handlePV)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
return self.hh.getUsrArgsAsUInt(handle)
|
||||
|
||||
def getDataTypeInCallback(self, handle):
|
||||
def getDataTypeInCallback(self, handlePV):
|
||||
cdef str _METHOD_="getDataTypeInCallback(handlePV)"
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(handlePV)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
return <long>self.hh.getDataTypeCB(handle)
|
||||
|
||||
def getDbrDataTypeInCallback(self, handle):
|
||||
def getDbrDataTypeInCallback(self, handlePV):
|
||||
cdef str _METHOD_="getDbrDataTypeInCallback(handlePV)"
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(handlePV)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
return <long>self.hh.getDbrDataTypeCB(handle)
|
||||
|
||||
def getDbrBaseInCallback(self, handle):
|
||||
def getDbrBaseInCallback(self, handlePV):
|
||||
cdef str _METHOD_="getDbrBaseInCallback(handlePV)"
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(handlePV)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
return <unsigned int>self.hh.getCafeDbrTypeCB(handle)
|
||||
|
||||
##################################################################################
|
||||
@@ -733,17 +810,55 @@ cdef class CyCafe:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
return <bint>self._c_cafe.isChannelConnected(handle)
|
||||
|
||||
|
||||
|
||||
##################################################################################
|
||||
def supplementHandles(self):
|
||||
return self._c_cafe.supplementHandles()
|
||||
##################################################################################
|
||||
|
||||
def supplementHandle(self, handlePV):
|
||||
cdef str _METHOD_="supplementHandle"
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(handlePV)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
return self._c_cafe.supplementHandle(handle)
|
||||
|
||||
|
||||
##################################################################################
|
||||
def supplementHandlesV(self, handleList):
|
||||
cdef str _METHOD_="supplementHandlesV"
|
||||
if isinstance(handleList, (str,int,long)):
|
||||
hl=[]
|
||||
hl.append(handleList)
|
||||
handleList=[]
|
||||
handleList=hl
|
||||
if isinstance(handleList[0], (str)):
|
||||
handleList=self.checkForHandleList(handleList)
|
||||
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, else <type 'str'> if PVs"))
|
||||
return self._c_cafe.supplementHandlesV(handleList)
|
||||
|
||||
##################################################################################
|
||||
def printDisconnected(self):
|
||||
return self._c_cafe.printDisconnectedHandles()
|
||||
self._c_cafe.printDisconnectedHandles()
|
||||
return
|
||||
|
||||
def printDisconnectedHandles(self):
|
||||
return self._c_cafe.printDisconnectedHandles()
|
||||
self._c_cafe.printDisconnectedHandles()
|
||||
return
|
||||
|
||||
##################################################################################
|
||||
def printHandles(self):
|
||||
return self._c_cafe.printHandles()
|
||||
self._c_cafe.printHandles()
|
||||
return
|
||||
|
||||
##################################################################################
|
||||
def printHandle(self, handlePV):
|
||||
@@ -756,7 +871,8 @@ cdef class CyCafe:
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
return self._c_cafe.printHandle(handle)
|
||||
self._c_cafe.printHandle(handle)
|
||||
return
|
||||
##################################################################################
|
||||
|
||||
##################################################################################
|
||||
@@ -772,7 +888,8 @@ cdef class CyCafe:
|
||||
cdef vector[unsigned int] v
|
||||
for i in range(0, len(handleList)):
|
||||
v.push_back(handleList[i])
|
||||
return self.hh.printHandlesV(v)
|
||||
self.hh.printHandlesV(v)
|
||||
return
|
||||
##################################################################################
|
||||
|
||||
##################################################################################
|
||||
@@ -837,6 +954,115 @@ cdef class CyCafe:
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
return self.hh.getStatus(handle)
|
||||
|
||||
##################################################################################
|
||||
def getChannelDevice(self, handlePV):
|
||||
cdef str _METHOD_="getChannelDevice"
|
||||
cdef string valString=str("")
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(pv=handlePV, force=False)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
if handle == 0:
|
||||
valString=str("")
|
||||
if isinstance(handlePV, (str)) == 1:
|
||||
delSplit=handlePV.split(":")
|
||||
if (len(delSplit) > 1):
|
||||
valString=str(delSplit[0])
|
||||
else:
|
||||
statusLocal=self.hh.getChannelDevice(handle, valString)
|
||||
return valString
|
||||
|
||||
##################################################################################
|
||||
def getChannelAttribute(self, handlePV):
|
||||
cdef str _METHOD_="getChannelAttribute"
|
||||
cdef string valString=str("")
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(pv=handlePV, force=False)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
if handle == 0:
|
||||
valString=str("")
|
||||
if isinstance(handlePV, (str)) == 1:
|
||||
delSplit=handlePV.split(":")
|
||||
if (len(delSplit) > 1):
|
||||
valString=str(delSplit[0])
|
||||
else:
|
||||
statusLocal=self.hh.getChannelAttribute(handle, valString)
|
||||
return valString
|
||||
|
||||
##################################################################################
|
||||
def getDescription(self, handlePV):
|
||||
cdef str _METHOD_="getDescription"
|
||||
cdef string valString
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(handlePV)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
|
||||
statusLocal=self.hh.getDescription(handle, valString)
|
||||
return valString
|
||||
|
||||
|
||||
##################################################################################
|
||||
def getUnits(self, handlePV):
|
||||
cdef str _METHOD_="getUnits"
|
||||
cdef string valString
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(handlePV)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
|
||||
statusLocal=self.hh.getUnits(handle, valString)
|
||||
|
||||
return valString
|
||||
|
||||
|
||||
##################################################################################
|
||||
def getPrecision(self, handlePV):
|
||||
cdef str _METHOD_="getPrecision"
|
||||
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(handlePV)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
cdef short precision=0
|
||||
statusLocal=self.hh.getPrecision(handle, precision)
|
||||
return precision
|
||||
|
||||
##################################################################################
|
||||
def hasAlarmStatusSeverity(self,handlePV):
|
||||
cdef str _METHOD_="hasAlarmStatusSeverity"
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(handlePV)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
|
||||
return self.hh.hasAlarmStatusSeverity(handle)
|
||||
|
||||
##################################################################################
|
||||
def getAlarmStatusSeverity(self,handlePV):
|
||||
cdef str _METHOD_="getAlarmStatusSeverity"
|
||||
@@ -920,7 +1146,6 @@ cdef class CyCafe:
|
||||
cpdef checkForHandleList(self, list pvList, bint force=True):
|
||||
|
||||
cdef unsigned int nToOpen=0
|
||||
|
||||
handleList=[]
|
||||
cdef unsigned int _handle=0
|
||||
for i in range(0, len(pvList)):
|
||||
@@ -934,7 +1159,7 @@ cdef class CyCafe:
|
||||
else:
|
||||
handleList.append(_handle)
|
||||
if nToOpen > 0:
|
||||
self.openNowAndWait(2.0+nToOpen*0.001)
|
||||
self.openNowAndWait(2.0+nToOpen*0.01)
|
||||
return handleList
|
||||
##################################################################################
|
||||
|
||||
@@ -966,6 +1191,71 @@ cdef class CyCafe:
|
||||
return self._c_cafe.getHandleFromPV(name)
|
||||
##################################################################################
|
||||
|
||||
|
||||
def getChannelDataStore(self, handlePV):
|
||||
cdef str _METHOD_="getChannelDataStore"
|
||||
cdef unsigned int handle=0
|
||||
cdef str pv=""
|
||||
if isinstance(handlePV, (int,long)):
|
||||
handle=handlePV
|
||||
pv = self._c_cafe.getPVFromHandle(handle)
|
||||
elif isinstance(handlePV, (str)):
|
||||
handle=self.checkForHandle(handlePV, force=True)
|
||||
pv=handlePV
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
|
||||
if handle == 0:
|
||||
if PYCAFE_PRINT_LEVEL>=PYCAFE_PRINT_LOW:
|
||||
self._c_cafe.printStatusMessage(ECAFE_INVALID_HANDLE)
|
||||
raise Exception("EXCEPTION RAISED in PyCafe def getChannelDataStore")
|
||||
|
||||
cdef ChannelDataStore cds
|
||||
cdef int status=ICAFE_NORMAL
|
||||
|
||||
#with nogil:
|
||||
# status=self._c_cafe.getChannelDataStore(handle,cds)
|
||||
#cdef PVDataHolder pvd
|
||||
#pvd.setNelem(self.hh.getNelemToRetrieveFromCache(handle))
|
||||
#status=self._c_cafe.getCache(handle, pvd)
|
||||
|
||||
#cdef PVCtrlHolder pvc
|
||||
#pvc.setNelem(self.hh.getNelemToRetrieveFromCtrlCache(handle))
|
||||
#status=self._c_cafe.getCtrlCache(handle, pvc)
|
||||
|
||||
pvds=self.getPVCache(handle)
|
||||
pvcs=self.getCtrlCache(handle)
|
||||
infos=self.getChannelInfo(handle)
|
||||
|
||||
'''
|
||||
#remove all after "."
|
||||
found=pv.find(".")
|
||||
if found != -1:
|
||||
pv=pv.substring(0,found)
|
||||
|
||||
pv=pv +".DESC"
|
||||
|
||||
cdef unsigned int handleDesc=0
|
||||
cdef str desc=""
|
||||
self.openPrepare()
|
||||
handleDesc=self.open(pv)
|
||||
self.openNowAndWait(6.0)
|
||||
print('handle',handleDesc, 'pv = ', pv)
|
||||
desc=self.get(handleDesc,'str')
|
||||
print('desc', desc)
|
||||
'''
|
||||
'''
|
||||
if status !=ICAFE_NORMAL:
|
||||
if status != ICAFE_CS_CLOSED:
|
||||
if PYCAFE_PRINT_LEVEL>=PYCAFE_PRINT_LOW:
|
||||
self._c_cafe.printStatusMessage(status)
|
||||
raise Exception("EXCEPTION RAISED in PyCafe def getChannelDataStore. Status = %d" %status)
|
||||
'''
|
||||
|
||||
#return cds.description, channelRegaliaToStruct(cds.info), PVDataHolderToStruct(cds.pvd), PVCtrlHolderToStruct(cds.pvc)
|
||||
return infos, pvds, pvcs
|
||||
|
||||
##################################################################################
|
||||
def getChannelInfo(self, handlePV):
|
||||
cdef str _METHOD_="getChannelInfo"
|
||||
@@ -1042,7 +1332,20 @@ cdef class CyCafe:
|
||||
##################################################################################
|
||||
|
||||
|
||||
##################################################################################
|
||||
|
||||
def getEnumStrings(self, handlePV):
|
||||
cdef str _METHOD_="getEnumStrings"
|
||||
cdef unsigned int handle=0
|
||||
if isinstance(handlePV, (int,long)) == 1:
|
||||
handle=handlePV
|
||||
elif isinstance(handlePV, (str)) == 1:
|
||||
handle=self.checkForHandle(handlePV)
|
||||
else:
|
||||
raise Exception("{} {} {}".format(self.exString, _METHOD_, \
|
||||
"First input argument should be <type 'int'> if handle, else <type 'str'> if PV"))
|
||||
return self.hh.getEnumStrings(handle)
|
||||
|
||||
|
||||
##################################################################################
|
||||
|
||||
@@ -2234,7 +2537,8 @@ cdef class CyCafe:
|
||||
else:
|
||||
with nogil:
|
||||
status=self._c_cafe.getPVArray(v, pvd)
|
||||
|
||||
|
||||
|
||||
if status !=ICAFE_NORMAL:
|
||||
if PYCAFE_PRINT_LEVEL>=PYCAFE_PRINT_LOW:
|
||||
self._c_cafe.printStatusMessage(status)
|
||||
@@ -2249,7 +2553,9 @@ cdef class CyCafe:
|
||||
|
||||
cdef unsigned int dtn
|
||||
cdef unsigned int dtcheck
|
||||
|
||||
|
||||
cdef CAFEDataTypeCode cdt
|
||||
|
||||
pvdList=[]
|
||||
cpdef pvdata p1
|
||||
|
||||
@@ -2281,7 +2587,7 @@ cdef class CyCafe:
|
||||
else:
|
||||
localList.append(0) #no data
|
||||
|
||||
else:
|
||||
else:
|
||||
localListInner=[]
|
||||
if dtcheck==CAFE_STRING:
|
||||
for j in range(0, pvd[i].getNelem()):
|
||||
@@ -2313,15 +2619,18 @@ cdef class CyCafe:
|
||||
localListInner.append(0) #no data
|
||||
localList.append(localListInner)
|
||||
|
||||
p1 = pvdata()
|
||||
p1.value=localList
|
||||
p1 = pvdata()
|
||||
p1.value =localList
|
||||
p1.status=pvd[i].getStatus()
|
||||
p1.nelem=pvd[i].getNelem()
|
||||
p1.alarmStatus=pvd[i].getAlarmStatus()
|
||||
p1.nelem =pvd[i].getNelem()
|
||||
p1.alarmStatus =pvd[i].getAlarmStatus()
|
||||
p1.alarmSeverity=pvd[i].getAlarmSeverity()
|
||||
|
||||
p1.alarmStatusAsString =pvd[i].getAlarmStatusAsString()
|
||||
p1.alarmSeverityAsString=pvd[i].getAlarmSeverityAsString()
|
||||
p1.dataType=pvd[i].getDataType()
|
||||
p1.dataTypeAsString=cdt.message(pvd.getDataType())
|
||||
pvd._etsNorm=pvd[i].getEpicsTimeStampAsUInt32()
|
||||
|
||||
|
||||
ll=[]
|
||||
ll.append((pvd[i]._etsNorm).secPastEpoch)
|
||||
ll.append((pvd[i]._etsNorm).nsec)
|
||||
@@ -2388,7 +2697,8 @@ cdef class CyCafe:
|
||||
for i in range(0, len(handleList)):
|
||||
v.push_back(handleList[i]) #do this copy to avoid compiler warning messages
|
||||
|
||||
return self._c_cafe.printStatusIfError(v, statusList)
|
||||
self._c_cafe.printStatusIfError(v, statusList)
|
||||
return
|
||||
|
||||
##################################################################################
|
||||
|
||||
@@ -2507,18 +2817,18 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
##################################################################################
|
||||
def getScalarArray(self, handleList, str dt='native', bint cacheFlag=False):
|
||||
##################################################################################
|
||||
cdef str _METHOD_="getScalarArray(handleList, str dt='native')"
|
||||
cdef str _METHOD_="getScalarArray(handleList, str dt, bint cacheFlag)"
|
||||
|
||||
#cdef float [::1] mvFloat #C-contiguous
|
||||
|
||||
if not isinstance(handleList, (list)):
|
||||
raise Exception ("EXCEPTION RAISED IN PyCafe def getScalarList. \n\
|
||||
raise Exception ("EXCEPTION RAISED IN PyCafe def getScalarArray. \n\
|
||||
First input argument, should be <type 'list'> of handles or PVs")
|
||||
|
||||
if isinstance(handleList[0], (str)):
|
||||
handleList=self.checkForHandleList(handleList)
|
||||
elif not isinstance(handleList[0], (int, long)):
|
||||
raise Exception ("EXCEPTION RAISED IN PyCafe def getScalarList. \n\
|
||||
raise Exception ("EXCEPTION RAISED IN PyCafe def getScalarArray. \n\
|
||||
First input argument, should be a 'list' of <type 'int'> if handles or <type 'str'> if PVs")
|
||||
|
||||
nelemPrevious= []
|
||||
@@ -2569,7 +2879,7 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
statusBundle=self._c_cafe.waitForBundledEvents(v, vRB)
|
||||
if (statusBundle!=ICAFE_NORMAL):
|
||||
if PYCAFE_PRINT_LEVEL>=PYCAFE_PRINT_LOW:
|
||||
print ("Error in def getScalarList: ")
|
||||
print ("Error in def getScalarArray: ")
|
||||
self._c_cafe.printStatusMessage(statusBundle)
|
||||
|
||||
cdef unsigned int dtcheck=CAFE_NOT_REQUESTED #native type not yet know
|
||||
@@ -2690,7 +3000,7 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
for i in range(0, len(handleList)):
|
||||
statusList.append(pvd[i].getStatus())
|
||||
if pvd[i].getStatus() != ICAFE_NORMAL:
|
||||
print ("Error in Element ", i, " from ", len(handleList), " in PyCafe def getScalarList")
|
||||
print ("Error in Element ", i, " from ", len(handleList), " in PyCafe def getScalarArray")
|
||||
print ("Handle= ", handleList[i], " PV=", self.hh.getPVFromHandle(handleList[i]))
|
||||
print ("with error status=", pvd[i].getStatus())
|
||||
self._c_cafe.printStatusMessage(pvd[i].getStatus())
|
||||
@@ -2742,7 +3052,7 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
else:
|
||||
localList.append(0)
|
||||
if PYCAFE_PRINT_LEVEL>=PYCAFE_PRINT_HIGH:
|
||||
print ("def getScalarList:")
|
||||
print ("def getScalarArray:")
|
||||
print ("Entering 0 for element", i, "as channel is not connected!")
|
||||
|
||||
#print (" vstatus = ", vStatus[i] , " pvd[i].status ", pvd[i].getStatus() )
|
||||
@@ -2754,7 +3064,7 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
return localList, status, vStatus # use vstatus instead of statusList (as cache is NoWait)
|
||||
|
||||
##################################################################################
|
||||
#END: def getScalarList(self, handleList, dt):
|
||||
#END: def getScalarArray(self, handleList, dt, cacheFlag):
|
||||
##################################################################################
|
||||
|
||||
|
||||
@@ -2790,7 +3100,7 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
##################################################################################
|
||||
def getScalarList(self, handleList, str dt='native', bint cacheFlag=False):
|
||||
##################################################################################
|
||||
cdef str _METHOD_="getScalarList(handleList, str dt='native')"
|
||||
cdef str _METHOD_="getScalarList(handleList, str dt, bint cacheFlag)"
|
||||
|
||||
#cdef float [::1] mvFloat #C-contiguous
|
||||
|
||||
@@ -2806,7 +3116,7 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
|
||||
nelemPrevious= []
|
||||
|
||||
for i in range(0, len(handleList)):
|
||||
for i in range(0, len(handleList)):
|
||||
nelemPrevious.append(self._c_cafe.setNelemToOne(handleList[i]))
|
||||
|
||||
#c=self.hh.getNelemClient(handleList[i])
|
||||
@@ -2835,6 +3145,9 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
with nogil:
|
||||
status=self._c_cafe.getV(v, vStatus)
|
||||
|
||||
#for i in range(0, len(vStatus)):
|
||||
# print (vStatus[i])
|
||||
#print("====")
|
||||
#Check for error code 704: ICAFE_WAITING_FOR_PREV_CALLBACK
|
||||
#as this may mean we have a double handle instance.
|
||||
#This is not a problem as such but if this is the case let's
|
||||
@@ -2851,11 +3164,11 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
vStatus[i]=vStatus[j]
|
||||
|
||||
#ca_poll() Not required as above will flush!
|
||||
|
||||
#Wait for bundle
|
||||
|
||||
with nogil:
|
||||
statusBundle=self._c_cafe.waitForBundledEvents(v, vRB)
|
||||
|
||||
if (statusBundle!=ICAFE_NORMAL):
|
||||
if PYCAFE_PRINT_LEVEL>=PYCAFE_PRINT_LOW:
|
||||
print ("Error in def getScalarList: ")
|
||||
@@ -2945,9 +3258,9 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
cdef PVDataHolder * pvd = self._c_cafe.getPVData(v)
|
||||
|
||||
|
||||
#for i in range (0, len(handleList)):
|
||||
# print pvd[i].getPVName(), pvd[i].getAsString(), " [",i,"]"
|
||||
# print ""
|
||||
#for i in range (0, len(handleList)):
|
||||
# print pvd[i].getPVName(), pvd[i].getAsString(), " [",i,"]"
|
||||
# print ""
|
||||
|
||||
#print ("-----------------------------------------------------------------")
|
||||
|
||||
@@ -2958,11 +3271,12 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
#print "sizeoverall", len(handleList) * sizeof(PVDataHolder)*10000
|
||||
|
||||
#Required to allocate memory for shared pointer
|
||||
for i in range(0, len(handleList)):
|
||||
for i in range(0, len(handleList)):
|
||||
pvd[i].setNelem(1)
|
||||
|
||||
|
||||
statusNoWait=self._c_cafe.getCachePVArrayNoWait(v, pvd)
|
||||
|
||||
|
||||
|
||||
for i in range(0, len(handleList)):
|
||||
self._c_cafe.setNelemToPrevious(handleList[i],nelemPrevious[i])
|
||||
@@ -2970,8 +3284,9 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
statusList=[]
|
||||
statusFlag=True
|
||||
statusLocal=ICAFE_NORMAL
|
||||
if (cacheFlag==True):
|
||||
|
||||
|
||||
#if cacheFlag==True:
|
||||
if True: #For all cases Added Oct 2018
|
||||
#if status !=ICAFE_NORMAL:
|
||||
# if PYCAFE_PRINT_LEVEL>=PYCAFE_PRINT_LOW:
|
||||
# self._c_cafe.printStatusMessage(status)
|
||||
@@ -2987,7 +3302,6 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
statusLocal =pvd[i].getStatus()
|
||||
statusFlag=False
|
||||
|
||||
|
||||
#
|
||||
#else:
|
||||
# statusList.append(status)
|
||||
@@ -3039,8 +3353,9 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
#free(pvd)
|
||||
if (cacheFlag==True):
|
||||
return localList, statusLocal, statusList
|
||||
|
||||
return localList, status, vStatus # use vstatus instead of statusList (as cache is NoWait)
|
||||
|
||||
return localList, statusNoWait, vStatus # use vstatus instead of statusList (as cache is NoWait)
|
||||
#return localList, status, vStatus # use vstatus instead of statusList (as cache is NoWait)
|
||||
|
||||
##################################################################################
|
||||
#END: def getScalarList(self, handleList, dt):
|
||||
@@ -3081,8 +3396,7 @@ First input argument, should be a 'list' of <type 'int'> if handles or <type 'st
|
||||
|
||||
for i in range(0, len(handleList)):
|
||||
v.push_back(handleList[i]) #do this copy to avoid compiler warning messages
|
||||
|
||||
|
||||
|
||||
if (nelemLocal==1):
|
||||
nelemLocal=self.hh.getNelemNative(handleList[i])
|
||||
if nelemLocal > 1:
|
||||
@@ -3995,7 +4309,7 @@ First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"
|
||||
##################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
##################################################################################
|
||||
def getCtrlCache(self, handlePV, str dt='native'):
|
||||
##################################################################################
|
||||
@@ -4150,8 +4464,8 @@ First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"
|
||||
print ("Assuming DBR_TIME")
|
||||
dbr=DBR_TIME
|
||||
|
||||
global py_cb
|
||||
|
||||
global py_cb
|
||||
|
||||
cdef vector[MonitorPolicy] mpV
|
||||
cdef unsigned int mpid
|
||||
|
||||
@@ -4171,15 +4485,34 @@ First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"
|
||||
mpid=mp[i].getMonitorID()
|
||||
|
||||
if cb:
|
||||
sig=inspect.signature(cb)
|
||||
a=inspect.getargspec(cb)
|
||||
monDictGlobal[mpid]=cb
|
||||
|
||||
if (len(a[0])==1):
|
||||
|
||||
#print ('============')
|
||||
#print ('SIGNATURE:')
|
||||
#print (str(sig))
|
||||
#for param in sig.parameters.values():
|
||||
# print('Parameter:', param)
|
||||
#print ('len1', len(sig.parameters.values()))
|
||||
#print ('len2', len(sig.parameters))
|
||||
#a=inspect.getargspec(cb)
|
||||
#print ('a',a)
|
||||
#print ('l',len(a[0]))
|
||||
#print ('============')
|
||||
|
||||
monDictGlobal[mpid]=cb
|
||||
|
||||
|
||||
if(len(sig.parameters)==1):
|
||||
#if (len(a[0])==1):
|
||||
mp[i].setUserArgs(<void*> mpid)
|
||||
mp[i].setPyHandler()
|
||||
else:
|
||||
#print("setPyHandlerData")
|
||||
py_cb=cb
|
||||
mp[i].setPyHandlerData()
|
||||
|
||||
#print("setPyHandlerData//")
|
||||
mpV.push_back(mp[i])
|
||||
|
||||
|
||||
@@ -4253,13 +4586,27 @@ No of group members doe not match the length of callback object list")
|
||||
mpid=mp[i].getMonitorID()
|
||||
|
||||
if cb[i]:
|
||||
a=inspect.getargspec(cb[i])
|
||||
monDictGlobal[mpid]=cb[i]
|
||||
sig=inspect.signature(cb[i])
|
||||
#a=inspect.getargspec(cb[i])
|
||||
|
||||
if (len(a[0])==1):
|
||||
#print ('============')
|
||||
#print ('SIGNATURE:')
|
||||
#print (str(sig))
|
||||
#for param in sig.parameters.values():
|
||||
# print('Parameter:', param)
|
||||
#print ('len1', len(sig.parameters.values()))
|
||||
#print ('len2', len(sig.parameters))
|
||||
#a=inspect.getargspec(cb[i])
|
||||
#print ('a',a)
|
||||
#print ('l',len(a[0]))
|
||||
#print ('============')
|
||||
monDictGlobal[mpid]=cb[i]
|
||||
if(len(sig.parameters)==1):
|
||||
#if (len(a[0])==1):
|
||||
mp[i].setUserArgs(<void*> mpid)
|
||||
mp[i].setPyHandler()
|
||||
else:
|
||||
py_cb=cb[i]
|
||||
mp[i].setPyHandlerData()
|
||||
|
||||
mpV.push_back(mp[i])
|
||||
@@ -4960,9 +5307,20 @@ No of group members doe not match the length of callback object list")
|
||||
#print (monDictGlobal)
|
||||
|
||||
if cb:
|
||||
sig=inspect.signature(cb)
|
||||
'''
|
||||
print ('SIGNATURE:')
|
||||
print (str(sig))
|
||||
for param in sig.parameters.values():
|
||||
print('Parameter:', param)
|
||||
print ('len1', len(sig.parameters.values()))
|
||||
print ('len2', len(sig.parameters))
|
||||
a=inspect.getargspec(cb)
|
||||
#print (a)
|
||||
if(len(a[0])==1):
|
||||
print ('a',a)
|
||||
print ('l',len(a[0]))
|
||||
'''
|
||||
if (len(sig.parameters)==1):
|
||||
#if(len(a[0])==1):
|
||||
##py_cb_handle=cb
|
||||
#self.monidList.append(mpid)
|
||||
#self.moncbList.append(cb)
|
||||
@@ -4980,6 +5338,7 @@ No of group members doe not match the length of callback object list")
|
||||
#print (<long>mp.getUserArgs())
|
||||
else:
|
||||
py_cb=cb
|
||||
mp.setUserArgs(<void *> mpid)
|
||||
mp.setPyHandlerData()
|
||||
#else:
|
||||
# mp.setHandler(callbackHandlerMonitor_wrapper)
|
||||
@@ -6174,8 +6533,10 @@ First input argument, should be <type 'int'> if handle, else <type 'str'> if PV"
|
||||
##################################################################################
|
||||
|
||||
|
||||
|
||||
###################################################################################
|
||||
##################################################################################
|
||||
#END: cdef CAFE###################################################################
|
||||
##################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
PyCafeDefs_api.pxi
|
||||
1513
PyCafeDefs.pxi
Normal file
1513
PyCafeDefs.pxi
Normal file
File diff suppressed because it is too large
Load Diff
1336
PyCafeDefs_api.pxi
1336
PyCafeDefs_api.pxi
File diff suppressed because it is too large
Load Diff
@@ -1,848 +0,0 @@
|
||||
|
||||
def show():
|
||||
print "cafe=PyCafe.CyCafe()"
|
||||
print "cyca=PyCafe.CyCa()"
|
||||
print "cafe.init()"
|
||||
print "cafe.openNoWait()"
|
||||
print "<handle/handleList>=cafe.open(<pv/pvList>)"
|
||||
print "cafe.openNowAndWait(timeout)"
|
||||
print "cafe.openNow()"
|
||||
print "cafe.close(handlePV=<handle/pv>)"
|
||||
print "cafe.closeChannels()"
|
||||
print "cafe.allConnected()"
|
||||
print "cafe.isConnected(handlePV=<handle/pv>)"
|
||||
print "cafe.printDisconnected()"
|
||||
print "cafe.printHandles()"
|
||||
print "cafe.printHandle(handlePV=<handle/pv>)"
|
||||
|
||||
print "cafe.getStatus(handlePV=<handle/pv>)"
|
||||
print "cafe.getAlarmStatusSeverity(handlePV=<handle/pv>)"
|
||||
print "cafe.getTimeStamp(handlePV=<handle/pv>)"
|
||||
print "cafe.getTimeStampDate(handlePV=<handle/pv>)"
|
||||
print "cafe.checkForHandle(<pv>)"
|
||||
print "cafe.checkForHandleList(<pvList>)"
|
||||
print "cafe.checkForGroupHandle(<groupName>)"
|
||||
print "cafe.getPVNameFromHandle(int)"
|
||||
print "cafe.getHandleFromPVName(str)"
|
||||
print "cafe.getChannelInfo(handlePV=<handle/pv>)"
|
||||
print "cafe.setDbrBase(handlePV=<handle/pv>, unsigned int) #dbrBase.DBR_XXX"
|
||||
print "cafe.getDbrBase(handlePV=<handle/pv>)"
|
||||
|
||||
print "cafe.getNonBlocking(handlePV=<handle/pv>)" #followed by getCache
|
||||
print "cafe.get(handlePV=<handle/pv>)" # return in native type
|
||||
print "cafe.get(handlePV=<handle/pv>, dt='native' (default) else <'int','float','str'>)"
|
||||
print "cafe.getInt(handlePV=<handle/pv>)"
|
||||
print "cafe.getFloathandlePV=<handle/pv>)"
|
||||
print "cafe.getStr(handlePV=<handle/pv>)"
|
||||
|
||||
print "cafe.getList(handlePV=<handle/pv>)" # return List in native type
|
||||
print "cafe.getList(handlePV=<handle/pv>, dt='native' (default) else <'int','float','str'>)"
|
||||
print "cafe.getIntList(handlePV=<handle/pv>)"
|
||||
print "cafe.getFloatList(handlePV=<handle/pv>)"
|
||||
print "cafe.getStrList(handlePV=<handle/pv>)"
|
||||
|
||||
# returns Memoryview in native type, except for when dt='str' which returns a List
|
||||
# returns np.array if asnumpy=True
|
||||
print "cafe.getArray(handlePV=<handle/pv>)"
|
||||
print "cafe.getArray(handlePV=<handle/pv>, dt=<'int','float','str','native'(default)>)"
|
||||
print "cafe.getIntArray(handlePV=<handle/pv>,asnumpy=<True,False(default)>)"
|
||||
print "cafe.getFloatArray(handlePV=<handle/pv>,asnumpy=<True,False(default)>)"
|
||||
|
||||
|
||||
print "cafe.getPV(handlePV=<handle/pv>)" # return PVData in native type
|
||||
print "cafe.getPV(handlePV=<handle/pv>, dt='native' (default) else <'int','float','str'>)"
|
||||
print "cafe.getPVInt(handlePV=<handle/pv>)"
|
||||
print "cafe.getPVFloat(handlePV=<handle/pv>)"
|
||||
print "cafe.getPVStr(handlePV=<handle/pv>)"
|
||||
|
||||
print "cafe.getPVList(handleList=<handleList/pvList>)" # return Array of PVData in native type
|
||||
print "cafe.getPVList(handleList=<handleList/pvList>, dt='native' (default) else <'int','float','str'>)"
|
||||
print "cafe.getPVIntList(handleList=<handleList/pvList>)"
|
||||
print "cafe.getPVFloatList(handleList=<handleList/pvList>)"
|
||||
print "cafe.getPVStrList(handleList=<handleList/pvList>)"
|
||||
|
||||
print "cafe.getScalarList(handleList=<handleList/pvList>)" # return List in native type
|
||||
print "cafe.getScalarList(handleList=<handleList/pvList>, dt='native' (default) else <'int','float','str'>)"
|
||||
print "cafe.getIntScalarList(handleList=<handleList/pvList>)"
|
||||
print "cafe.getFloatScalarList(handleList=<handleList/pvList>)"
|
||||
print "cafe.getStrScalarList(handleList=<handleList/pvList>)"
|
||||
|
||||
print "cafe.getPVCache(handlePV=<handle/pv>)" # return PVData in native type
|
||||
print "cafe.getPVCache(handlePV=<handle/pv>, dt='native' (default) else <'int','float','str'>)"
|
||||
print "cafe.getPVIntCache(handlePV=<handle/pv>)"
|
||||
print "cafe.getPVFloatCache(handlePV=<handle/pv>)"
|
||||
print "cafe.getPVStrCache(handlePV=<handle/pv>)"
|
||||
|
||||
|
||||
# returns Memoryview in native type, except for when dt='str' which returns a List
|
||||
# returns np.array if asnumpy=True
|
||||
print "cafe.getArrayCache(handlePV=<handle/pv>)"
|
||||
print "cafe.getArrayCache(handlePV=<handle/pv>, dt=<'int','float','str','native'(default)>)"
|
||||
print "cafe.getIntArrayCache(handlePV=<handle/pv>,asnumpy=<True,False(default)>)"
|
||||
print "cafe.getFloatArrayCache(handlePV=<handle/pv>,asnumpy=<True,False(default)>)"
|
||||
|
||||
print "cafe.getCtrl(handlePV=<handle/pv>)"
|
||||
print "cafe.getCtrl(handlePV=<handle/pv>, dt='native' (default) else <'int','float','str'>)"
|
||||
print "cafe.getCtrlCache(handlePV=<handle/pv>)"
|
||||
print "cafe.getCtrlCache(handlePV=<handle/pv>, dt='native' (default) else <'int','float','str'>)"
|
||||
|
||||
print "mpid=cafe.monitorStart(handlePV=<handle/pv>), cb=None, dbr=None, mask=DBE_VALUE|DBE_LOG|DBE_ALARM)"
|
||||
print "cafe.monitorStop(handlePV=<handle/pv>, mpID=None)"
|
||||
print "cafe.monitorStopAll(handlePV=<handle/pv>)"
|
||||
|
||||
print "cafe.getNoMonitors(handlePV=<handle/pv>)"
|
||||
|
||||
print "cafe.set(handlePV=<handle/pv>, valSet)"
|
||||
print "cafe.setScalarList(handleList=<handleList/pvList>, valList)"
|
||||
print "cafe.setAndMatch(handlePVSet=<handle/pv>, valSet=<int,float,str>, handlePVMatch=<handle/pv>, \
|
||||
tolerance=<int,float,str> , timeout=<float>, printFlag=<bint>)"
|
||||
#Synchronous groups
|
||||
print "handleList[]=cafe.defineGroup(gname, pvList)"
|
||||
print "list[]=cafe.PVGroupValuesToList(pvgroup)"
|
||||
print "vectorList,status,statusList = cafe.getGroup(self, ghandleName, dt='native')"
|
||||
print "pvdataList[],status = cafe.getPVGroup(self, ghandleName, dt='native')"
|
||||
print "cafe.setGroup(ghandleName, vectorList)"
|
||||
|
||||
return
|
||||
|
||||
|
||||
cdef int PYCAFE_PRINT_HIGH=9
|
||||
cdef int PYCAFE_PRINT_MED=5
|
||||
cdef int PYCAFE_PRINT_LOW=1
|
||||
|
||||
cdef int PYCAFE_PRINT_LEVEL=PYCAFE_PRINT_MED
|
||||
|
||||
ctypedef shared_ptr[vector [double]] vdouble_ptr
|
||||
ctypedef shared_ptr[vector [float]] vfloat_ptr
|
||||
|
||||
cdef object py_cb = None
|
||||
cdef object py_cb_handle = None
|
||||
cdef object py_cb_ctrl = None
|
||||
|
||||
|
||||
'''
|
||||
def py_cb(pvdata pv1, unsigned int handle, str pvname):
|
||||
print "PV:", pvname, " Handle:", handle
|
||||
pv1.showMax(10)
|
||||
return
|
||||
|
||||
def py_cb_handle(unsigned int handle):
|
||||
print " Handle:", handle
|
||||
return
|
||||
|
||||
#Add control callback!
|
||||
|
||||
def py_cb_ctrl(pvctrl c1, unsigned int handle, str pvname):
|
||||
print "PV:", pvname, " Handle:", handle
|
||||
c1.showMax(10)
|
||||
return
|
||||
'''
|
||||
|
||||
#***********api***************
|
||||
|
||||
cdef public void py_cb_wrapper(PVDataHolder pvd, unsigned int handle, string pvname) with gil:
|
||||
cdef pvdata pv1 = PVDataHolderToStruct(pvd)
|
||||
py_cb(pv1, handle, pvname)
|
||||
with nogil:
|
||||
return
|
||||
|
||||
cdef public void py_cb_ctrl_wrapper(PVCtrlHolder pvc, unsigned int handle, string pvname) with gil:
|
||||
cdef pvctrl c1 = PVCtrlHolderToStruct(pvc)
|
||||
py_cb_ctrl(c1, handle, pvname)
|
||||
with nogil:
|
||||
return
|
||||
|
||||
cdef public void py_cb_handle_wrapper(unsigned int handle) with gil:
|
||||
|
||||
py_cb_handle(handle)
|
||||
|
||||
with nogil:
|
||||
return
|
||||
|
||||
|
||||
cdef public void py_cb_handle_monid_wrapper(unsigned int handle, unsigned long monid) with gil:
|
||||
|
||||
|
||||
cbobjt=monDictGlobal[monid]
|
||||
|
||||
cbobjt(handle)
|
||||
|
||||
with nogil:
|
||||
return
|
||||
|
||||
|
||||
#***********api***************
|
||||
'''
|
||||
cdef object callbackHandlerMonitor = None
|
||||
|
||||
|
||||
cdef void callbackHandlerMonitor_wrapper(event_handler_args args) with gil:
|
||||
handle=<unsigned long> args.usr
|
||||
py_cb_handle(handle)
|
||||
with nogil:
|
||||
return
|
||||
'''
|
||||
#Correct memory management a la KWSmith p.190
|
||||
cdef class _finalizer:
|
||||
cdef void *_data
|
||||
def __dealloc__(self):
|
||||
if self._data is not NULL:
|
||||
free(self._data)
|
||||
return
|
||||
|
||||
cdef void set_base(cnp.ndarray arr, void * carr):
|
||||
cdef _finalizer fin = _finalizer()
|
||||
fin._data = <void *> carr
|
||||
cnp.set_array_base(arr, fin)
|
||||
return
|
||||
|
||||
cdef class CyCa:
|
||||
cpdef readonly unsigned int CY_DBE_VALUE
|
||||
cpdef readonly unsigned int CY_DBE_LOG
|
||||
cpdef readonly unsigned int CY_DBE_ARCHIVE
|
||||
cpdef readonly unsigned int CY_DBE_ALARM
|
||||
cpdef readonly unsigned int CY_DBE_PROPERTY
|
||||
cpdef readonly unsigned int CY_DBR_PRIMITIVE
|
||||
cpdef readonly unsigned int CY_DBR_PLAIN
|
||||
cpdef readonly unsigned int CY_DBR_STS
|
||||
cpdef readonly unsigned int CY_DBR_TIME
|
||||
cpdef readonly unsigned int CY_DBR_GR
|
||||
cpdef readonly unsigned int CY_DBR_CTRL
|
||||
cpdef readonly unsigned int CY_DBR_PUT
|
||||
cpdef readonly unsigned int CY_DBR_STSACK
|
||||
cpdef readonly unsigned int CY_DBR_CLASS
|
||||
cpdef readonly unsigned int CY_DBR_NONE
|
||||
cpdef readonly unsigned int CY_DBR_STRING #returns a NULL terminated string
|
||||
cpdef readonly unsigned int CY_DBR_SHORT #returns an unsigned short
|
||||
cpdef readonly unsigned int CY_DBR_INT #returns an unsigned short
|
||||
cpdef readonly unsigned int CY_DBR_FLOAT #returns an IEEE floating point value
|
||||
cpdef readonly unsigned int CY_DBR_ENUM #returns an unsigned short which is the enum item
|
||||
cpdef readonly unsigned int CY_DBR_CHAR #returns an unsigned char
|
||||
cpdef readonly unsigned int CY_DBR_LONG #returns an unsigned long
|
||||
cpdef readonly unsigned int CY_DBR_DOUBLE #returns a double precision floating point number
|
||||
cpdef readonly unsigned int CY_DBR_STS_STRING #returns a string status structure (dbr_sts_string)
|
||||
cpdef readonly unsigned int CY_DBR_STS_SHORT #returns a short status structure (dbr_sts_short)
|
||||
cpdef readonly unsigned int CY_DBR_STS_INT #returns a short status structure (dbr_sts_int)
|
||||
cpdef readonly unsigned int CY_DBR_STS_FLOAT #returns a float status structure (dbr_sts_float)
|
||||
cpdef readonly unsigned int CY_DBR_STS_ENUM #returns an enum status structure (dbr_sts_enum)
|
||||
cpdef readonly unsigned int CY_DBR_STS_CHAR #returns a char status structure (dbr_sts_char)
|
||||
cpdef readonly unsigned int CY_DBR_STS_LONG #returns a long status structure (dbr_sts_long)
|
||||
cpdef readonly unsigned int CY_DBR_STS_DOUBLE #returns a double status structure (dbr_sts_double)
|
||||
cpdef readonly unsigned int CY_DBR_TIME_STRING #returns a string time structure (dbr_time_string)
|
||||
cpdef readonly unsigned int CY_DBR_TIME_SHORT #returns a short time structure (dbr_time_short)
|
||||
cpdef readonly unsigned int CY_DBR_TIME_INT #returns a short time structure (dbr_time_short)
|
||||
cpdef readonly unsigned int CY_DBR_TIME_FLOAT #returns a float time structure (dbr_time_float)
|
||||
cpdef readonly unsigned int CY_DBR_TIME_ENUM #returns an enum time structure (dbr_time_enum)
|
||||
cpdef readonly unsigned int CY_DBR_TIME_CHAR #returns a char time structure (dbr_time_char)
|
||||
cpdef readonly unsigned int CY_DBR_TIME_LONG #returns a long time structure (dbr_time_long)
|
||||
cpdef readonly unsigned int CY_DBR_TIME_DOUBLE #returns a double time structure (dbr_time_double)
|
||||
cpdef readonly unsigned int CY_DBR_GR_STRING #returns a graphic string structure (dbr_gr_string)
|
||||
cpdef readonly unsigned int CY_DBR_GR_SHORT #returns a graphic short structure (dbr_gr_short)
|
||||
cpdef readonly unsigned int CY_DBR_GR_INT #returns a graphic short structure (dbr_gr_int)
|
||||
cpdef readonly unsigned int CY_DBR_GR_FLOAT #returns a graphic float structure (dbr_gr_float)
|
||||
cpdef readonly unsigned int CY_DBR_GR_ENUM #returns a graphic enum structure (dbr_gr_enum)
|
||||
cpdef readonly unsigned int CY_DBR_GR_CHAR #returns a graphic char structure (dbr_gr_char)
|
||||
cpdef readonly unsigned int CY_DBR_GR_LONG #returns a graphic long structure (dbr_gr_long)
|
||||
cpdef readonly unsigned int CY_DBR_GR_DOUBLE #returns a graphic double structure (dbr_gr_double)
|
||||
cpdef readonly unsigned int CY_DBR_CTRL_STRING #returns a control string structure (dbr_ctrl_int)
|
||||
cpdef readonly unsigned int CY_DBR_CTRL_SHORT #returns a control short structure (dbr_ctrl_short)
|
||||
cpdef readonly unsigned int CY_DBR_CTRL_INT #returns a control short structure (dbr_ctrl_int)
|
||||
cpdef readonly unsigned int CY_DBR_CTRL_FLOAT #returns a control float structure (dbr_ctrl_float)
|
||||
cpdef readonly unsigned int CY_DBR_CTRL_ENUM #returns a control enum structure (dbr_ctrl_enum)
|
||||
cpdef readonly unsigned int CY_DBR_CTRL_CHAR #returns a control char structure (dbr_ctrl_char)
|
||||
cpdef readonly unsigned int CY_DBR_CTRL_LONG #returns a control long structure (dbr_ctrl_long)
|
||||
cpdef readonly unsigned int CY_DBR_CTRL_DOUBLE #returns a control double structure (dbr_ctrl_double)
|
||||
|
||||
def __cinit__(self):
|
||||
self.CY_DBE_VALUE =DBE_VALUE
|
||||
self.CY_DBE_LOG =DBE_LOG
|
||||
self.CY_DBE_ARCHIVE =DBE_ARCHIVE
|
||||
self.CY_DBE_ALARM =DBE_ALARM
|
||||
self.CY_DBE_PROPERTY =DBE_PROPERTY
|
||||
self.CY_DBR_PRIMITIVE =DBR_PRIMITIVE
|
||||
self.CY_DBR_PLAIN =DBR_PLAIN
|
||||
self.CY_DBR_STS =DBR_STS
|
||||
self.CY_DBR_TIME =DBR_TIME
|
||||
self.CY_DBR_GR =DBR_GR
|
||||
self.CY_DBR_CTRL =DBR_CTRL
|
||||
self.CY_DBR_PUT =DBR_PUT # DBR_PUT_ACKT and DBR_PUT_ACKS Write only - used from global alarm acknowledge.
|
||||
self.CY_DBR_STSACK =DBR_STSACK # is DBR_STSACK_STRING
|
||||
self.CY_DBR_CLASS =DBR_CLASS # is DBR_CLASS_NAME,
|
||||
self.CY_DBR_NONE =DBR_NONE
|
||||
self.CY_DBR_STRING =DBR_STRING
|
||||
self.CY_DBR_SHORT =DBR_SHORT #returns an unsigned short
|
||||
self.CY_DBR_INT =DBR_INT #returns an unsigned short
|
||||
self.CY_DBR_FLOAT =DBR_FLOAT #returns an IEEE floating point value
|
||||
self.CY_DBR_ENUM =DBR_ENUM #returns an unsigned short which is the enum item
|
||||
self.CY_DBR_CHAR =DBR_CHAR #returns an unsigned char
|
||||
self.CY_DBR_LONG =DBR_LONG #returns an unsigned long
|
||||
self.CY_DBR_DOUBLE =DBR_DOUBLE #returns a double precision floating point number
|
||||
self.CY_DBR_STS_STRING=DBR_STS_STRING #returns a string status structure (dbr_sts_string)
|
||||
self.CY_DBR_STS_SHORT =DBR_STS_SHORT #returns a short status structure (dbr_sts_short)
|
||||
self.CY_DBR_STS_INT =DBR_STS_INT #returns a short status structure (dbr_sts_int)
|
||||
self.CY_DBR_STS_FLOAT =DBR_STS_FLOAT #returns a float status structure (dbr_sts_float)
|
||||
self.CY_DBR_STS_ENUM =DBR_STS_ENUM #returns an enum status structure (dbr_sts_enum)
|
||||
self.CY_DBR_STS_CHAR =DBR_STS_CHAR #returns a char status structure (dbr_sts_char)
|
||||
self.CY_DBR_STS_LONG =DBR_STS_LONG #returns a long status structure (dbr_sts_long)
|
||||
self.CY_DBR_STS_DOUBLE=DBR_STS_DOUBLE #returns a double status structure (dbr_sts_double)
|
||||
self.CY_DBR_TIME_STRING=DBR_TIME_STRING #returns a string time structure (dbr_time_string)
|
||||
self.CY_DBR_TIME_SHORT =DBR_TIME_SHORT #returns a short time structure (dbr_time_short)
|
||||
self.CY_DBR_TIME_INT =DBR_TIME_INT #returns a short time structure (dbr_time_short)
|
||||
self.CY_DBR_TIME_FLOAT =DBR_TIME_FLOAT #returns a float time structure (dbr_time_float)
|
||||
self.CY_DBR_TIME_ENUM =DBR_TIME_ENUM #returns an enum time structure (dbr_time_enum)
|
||||
self.CY_DBR_TIME_CHAR =DBR_TIME_CHAR #returns a char time structure (dbr_time_char)
|
||||
self.CY_DBR_TIME_LONG =DBR_TIME_LONG #returns a long time structure (dbr_time_long)
|
||||
self.CY_DBR_TIME_DOUBLE=DBR_TIME_DOUBLE #returns a double time structure (dbr_time_double)
|
||||
self.CY_DBR_GR_STRING =DBR_GR_STRING #returns a graphic string structure (dbr_gr_string)
|
||||
self.CY_DBR_GR_SHORT =DBR_GR_SHORT #returns a graphic short structure (dbr_gr_short)
|
||||
self.CY_DBR_GR_INT =DBR_GR_INT #returns a graphic short structure (dbr_gr_int)
|
||||
self.CY_DBR_GR_FLOAT =DBR_GR_FLOAT #returns a graphic float structure (dbr_gr_float)
|
||||
self.CY_DBR_GR_ENUM =DBR_GR_ENUM #returns a graphic enum structure (dbr_gr_enum)
|
||||
self.CY_DBR_GR_CHAR =DBR_GR_CHAR #returns a graphic char structure (dbr_gr_char)
|
||||
self.CY_DBR_GR_LONG =DBR_GR_LONG #returns a graphic long structure (dbr_gr_long)
|
||||
self.CY_DBR_GR_DOUBLE =DBR_GR_DOUBLE #returns a graphic double structure (dbr_gr_double)
|
||||
self.CY_DBR_CTRL_STRING=DBR_CTRL_STRING #returns a control string structure (dbr_ctrl_int)
|
||||
self.CY_DBR_CTRL_SHORT =DBR_CTRL_SHORT #returns a control short structure (dbr_ctrl_short)
|
||||
self.CY_DBR_CTRL_INT =DBR_CTRL_INT #returns a control short structure (dbr_ctrl_int)
|
||||
self.CY_DBR_CTRL_FLOAT =DBR_CTRL_FLOAT #returns a control float structure (dbr_ctrl_float)
|
||||
self.CY_DBR_CTRL_ENUM =DBR_CTRL_ENUM #returns a control enum structure (dbr_ctrl_enum)
|
||||
self.CY_DBR_CTRL_CHAR =DBR_CTRL_CHAR #returns a control char structure (dbr_ctrl_char)
|
||||
self.CY_DBR_CTRL_LONG =DBR_CTRL_LONG #returns a control long structure (dbr_ctrl_long)
|
||||
self.CY_DBR_CTRL_DOUBLE=DBR_CTRL_DOUBLE #returns a control double structure (dbr_ctrl_double)
|
||||
return
|
||||
|
||||
|
||||
|
||||
cdef class channelInfo:
|
||||
cdef readonly long channelID
|
||||
cdef readonly bint connectFlag
|
||||
cdef readonly string hostName
|
||||
cdef readonly unsigned int nelem #native
|
||||
cdef readonly int dataType; #native
|
||||
cdef readonly unsigned short accessRead; #0 or 1
|
||||
cdef readonly unsigned short accessWrite; #0 or 1
|
||||
cdef readonly string className; #dbr_class_name_t
|
||||
cdef readonly int connectionState; #as given by CA_OP_
|
||||
cdef readonly int cafeConnectionState; #as given by cafe_cs_state
|
||||
cdef readonly string connectionStateAsString; #as given by CA_OP_
|
||||
cdef readonly string cafeConnectionStateAsString; #as given by cafe_cs_state
|
||||
cdef CAFEDataTypeCode cdt
|
||||
cdef CAFEStatusCode csc
|
||||
cdef CAOPCodes caop
|
||||
|
||||
def __cinit__(self):
|
||||
self.channelID=0
|
||||
self.connectFlag=False
|
||||
self.hostName=''
|
||||
self.nelem=0
|
||||
self.dataType=ICAFE_TYPENOTCONN
|
||||
self.accessRead=0
|
||||
self.accessWrite=0
|
||||
self.className=''
|
||||
self.connectionState=ICAFE_CA_OP_CONN_DOWN
|
||||
self.cafeConnectionState=ICAFE_CS_NEVER_CONN
|
||||
self.connectionStateAsString='ICAFE_CA_OP_CONN_DOWN'
|
||||
self.cafeConnectionStateAsString='ICAFE_CS_NEVER_CONN'
|
||||
|
||||
def show(self):
|
||||
print ("channelID = %x" % self.channelID)
|
||||
print ("connectFlag = %d" % self.connectFlag)
|
||||
print ("hostName = %s" % self.hostName)
|
||||
print ("nelem = %d" % self.nelem)
|
||||
print ("dataType = %s (%d)" % (self.cdt.message(self.dataType), self.dataType))
|
||||
print ("accessRead = %d" % self.accessRead)
|
||||
print ("accessWrite = %d" % self.accessWrite)
|
||||
print ("className = %s" % self.className)
|
||||
#print ("connectionState = %s (%d)" % (self.connectionStateAsString, self.connectionState))
|
||||
#print ("cafeConnectionState = %s (%d)" % (self.cafeConnectionStateAsString,self.cafeConnectionState))
|
||||
print ("connectionState = %s (%d)" % (self.caop.message(self.connectionState),self.connectionState))
|
||||
print ("cafeConnectionState = %s (%d)" % (self.csc.message(self.cafeConnectionState),self.cafeConnectionState))
|
||||
return
|
||||
|
||||
|
||||
|
||||
##################################################################################
|
||||
cdef class _epicsTimeStampAsDate:
|
||||
cdef epicsTime *_time
|
||||
cdef local_tm_nano_sec local
|
||||
cdef list etsDate
|
||||
def __cinit__(self, epicsTimeStamp ts):
|
||||
self._time = new epicsTime(ts)
|
||||
self.local = <local_tm_nano_sec &> (self._time)
|
||||
|
||||
print "ts====== ", ts.secPastEpoch, ts.nsec
|
||||
|
||||
print "year=== ", ( ( (&(&self.local).ansi_tm).tm_year) + 1900)
|
||||
|
||||
self.etsDate=[]
|
||||
self.etsDate.append( (self.local.ansi_tm.tm_year + 1900))
|
||||
self.etsDate.append( (self.local.ansi_tm.tm_mon + 1))
|
||||
self.etsDate.append( self.local.ansi_tm.tm_mday)
|
||||
self.etsDate.append( self.local.ansi_tm.tm_hour)
|
||||
self.etsDate.append( self.local.ansi_tm.tm_min)
|
||||
self.etsDate.append( self.local.ansi_tm.tm_sec)
|
||||
self.etsDate.append( <unsigned int> ts.nsec)
|
||||
self.etsDate.append( self.local.nSec)
|
||||
def get(self):
|
||||
return self.etsDate
|
||||
|
||||
|
||||
##################################################################################
|
||||
|
||||
##################################################################################
|
||||
cdef class pvctrl:
|
||||
cdef readonly unsigned int nelem
|
||||
cdef readonly int alarmStatus
|
||||
cdef readonly int alarmSeverity
|
||||
cdef readonly unsigned short precision
|
||||
cdef readonly string units
|
||||
cdef readonly unsigned short noEnumStrings
|
||||
cdef readonly list enumStrings
|
||||
cdef readonly upperDisplayLimit
|
||||
cdef readonly lowerDisplayLimit
|
||||
cdef readonly upperAlarmLimit
|
||||
cdef readonly upperWarningLimit
|
||||
cdef readonly lowerWarningLimit
|
||||
cdef readonly lowerAlarmLimit
|
||||
cdef readonly upperControlLimit
|
||||
cdef readonly lowerControlLimit
|
||||
cdef readonly list value
|
||||
cdef readonly int status
|
||||
|
||||
def __cinit__(self):
|
||||
self.nelem= 1
|
||||
self.alarmStatus=-1
|
||||
self.alarmSeverity=-1
|
||||
self.precision=0
|
||||
self.units=""
|
||||
self.noEnumStrings=0
|
||||
self.enumStrings=[]
|
||||
self.upperDisplayLimit=0
|
||||
self.lowerDisplayLimit=0
|
||||
self.upperAlarmLimit=0
|
||||
self.lowerAlarmLimit=0
|
||||
self.upperControlLimit=0
|
||||
self.lowerControlLimit=0
|
||||
self.value=[]
|
||||
self.status=1
|
||||
|
||||
|
||||
def show(self):
|
||||
self.showPrint(self.nelem)
|
||||
return
|
||||
|
||||
def showMax(self, nelem):
|
||||
if nelem > self.nelem:
|
||||
#print "----------------------"
|
||||
#print "Note: Max. Nelem =", self.nelem
|
||||
#print "----------------------"
|
||||
nelem=self.nelem
|
||||
self.showPrint(nelem)
|
||||
return
|
||||
|
||||
cdef showPrint(self, nelem):
|
||||
cdef unsigned int i
|
||||
#is self.value[0] a list
|
||||
if nelem==1:
|
||||
if isinstance (self.value[0], list):
|
||||
print "value =", self.value[0][0],
|
||||
else:
|
||||
print "value =", self.value[0],
|
||||
else:
|
||||
print "values =",
|
||||
if isinstance (self.value[0], list):
|
||||
for i in range(0, nelem):
|
||||
print self.value[0][i],"[%d]" %i,
|
||||
else:
|
||||
for i in range(0, nelem):
|
||||
print self.value[i],"[%d]" %i,
|
||||
print ""
|
||||
print ("status = %d" % self.status)
|
||||
print ("alarmStatus = %d" % self.alarmStatus)
|
||||
print ("alarmSeverity = %d" % self.alarmSeverity)
|
||||
print ("precision = %d" % self.precision)
|
||||
print ("units = %s" % self.units)
|
||||
print ("noEnumStrings = %d" % self.noEnumStrings)
|
||||
|
||||
if self.noEnumStrings > 0:
|
||||
print "enumStrings =",
|
||||
for i in range(0, self.noEnumStrings):
|
||||
print self.enumStrings[i],"[%s]" %i,
|
||||
print ""
|
||||
|
||||
print ("upperDisplayLimit = %f" % self.upperDisplayLimit)
|
||||
print ("lowerDisplayLimit = %f" % self.lowerDisplayLimit)
|
||||
print ("upperAlarmLimit = %f" % self.upperAlarmLimit)
|
||||
print ("lowerAlarmLimit = %f" % self.lowerAlarmLimit)
|
||||
print ("upperWarningLimit = %f" % self.upperWarningLimit)
|
||||
print ("lowerWarningLimit = %f" % self.lowerWarningLimit)
|
||||
print ("upperControlLimit = %f" % self.upperControlLimit)
|
||||
print ("lowerControlLimit = %f" % self.lowerControlLimit)
|
||||
|
||||
return
|
||||
##################################################################################
|
||||
|
||||
|
||||
##################################################################################
|
||||
cdef class pvdata:
|
||||
cdef readonly unsigned int nelem
|
||||
cdef readonly int alarmStatus
|
||||
cdef readonly int alarmSeverity
|
||||
cdef readonly list ts
|
||||
cdef readonly list tsDate
|
||||
cdef readonly list value
|
||||
cdef readonly int status
|
||||
|
||||
|
||||
def __cinit__(self):
|
||||
self.nelem= 1
|
||||
|
||||
self.alarmStatus=-1
|
||||
self.alarmSeverity=-1
|
||||
self.ts=[]
|
||||
self.tsDate=[]
|
||||
self.value=[]
|
||||
self.status=1
|
||||
|
||||
|
||||
def show(self):
|
||||
self.showPrint(self.nelem)
|
||||
return
|
||||
|
||||
def showMax(self, nelem):
|
||||
if nelem > self.nelem:
|
||||
#print "----------------------"
|
||||
#print "Note: Max. Nelem =", self.nelem
|
||||
#print "----------------------"
|
||||
nelem=self.nelem
|
||||
self.showPrint(nelem)
|
||||
return
|
||||
|
||||
cdef showPrint(self, nelem):
|
||||
cdef unsigned int i
|
||||
#is self.value[0] a list
|
||||
|
||||
if nelem==1:
|
||||
if isinstance (self.value[0], list):
|
||||
print "value =", self.value[0][0],
|
||||
else:
|
||||
print "value =", self.value[0],
|
||||
else:
|
||||
print "values =",
|
||||
if isinstance (self.value[0], list):
|
||||
for i in range(0, nelem):
|
||||
print self.value[0][i],"[%d]" %i,
|
||||
else:
|
||||
for i in range(0, nelem):
|
||||
print self.value[i],"[%d]" %i,
|
||||
print ""
|
||||
print ("status = %d" % self.status)
|
||||
#if self.alarmStatus != -1:
|
||||
print ("alarmStatus = %d" % self.alarmStatus)
|
||||
print ("alarmSeverity = %d" % self.alarmSeverity)
|
||||
#if self.ts[0] != 0:
|
||||
print "ts =", self.ts[0], self.ts[1]
|
||||
print "tsDate =", self.tsDate[0], self.tsDate[1], \
|
||||
self.tsDate[2], self.tsDate[3],\
|
||||
self.tsDate[4], self.tsDate[5], self.tsDate[6]
|
||||
return
|
||||
|
||||
##################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
##################################################################################
|
||||
cdef class pvgroup:
|
||||
cdef readonly list pvdata
|
||||
cdef readonly unsigned int npv
|
||||
cdef readonly string name
|
||||
cdef readonly int groupStatus
|
||||
cdef readonly unsigned int groupHandle
|
||||
|
||||
def __cinit__(self):
|
||||
self.groupStatus=ICAFE_NORMAL
|
||||
return
|
||||
|
||||
def show(self):
|
||||
self.showPrint(npv=self.npv, grouplist=None)
|
||||
return
|
||||
|
||||
def showWithPV(self,glist):
|
||||
if len(glist) != self.npv:
|
||||
print "ERROR: GROUP MEMBER MISMATCH!!"
|
||||
print glist, "has", len(glist), "members while group has", self.npv,"!!"
|
||||
return
|
||||
self.showPrint(self.npv, grouplist=glist)
|
||||
return
|
||||
|
||||
|
||||
def showMax(self, _npv):
|
||||
if _npv > self.npv:
|
||||
#print "----------------------"
|
||||
#print "Note: Max. Npv =", self.npv
|
||||
#print "----------------------"
|
||||
_npv=self.npv
|
||||
self.showPrint(npv=_npv, grouplist=None)
|
||||
return
|
||||
|
||||
cdef showPrint(self, npv, grouplist):
|
||||
print "GROUP NAME = ", self.name
|
||||
print "GROUP HANDLE = ", self.groupHandle
|
||||
print "GROUP STATUS = ", self.groupStatus
|
||||
cdef unsigned int i,j
|
||||
#if nelem==1:
|
||||
# print "value =", self.value[0],
|
||||
#else:
|
||||
|
||||
|
||||
for i in range(0, npv):
|
||||
print "Member: ", i, "---------------------------------"
|
||||
if grouplist:
|
||||
print "PV =", grouplist[i]
|
||||
|
||||
print "values =",
|
||||
for j in range(0, len(self.pvdata[i].value)):
|
||||
print self.pvdata[i].value[j],"[%d]" %j,
|
||||
print ""
|
||||
print ("status = %d" % self.pvdata[i].status)
|
||||
print ("alarmStatus = %d" % self.pvdata[i].alarmStatus)
|
||||
print ("alarmSeverity = %d" % self.pvdata[i].alarmSeverity)
|
||||
print "ts =", self.pvdata[i].ts[0], self.pvdata[i].tsDate[1]
|
||||
print "tsDate =", self.pvdata[i].tsDate[0], self.pvdata[i].tsDate[1], \
|
||||
self.pvdata[i].tsDate[2], self.pvdata[i].tsDate[3],\
|
||||
self.pvdata[i].tsDate[4], self.pvdata[i].tsDate[5], self.pvdata[i].tsDate[6]
|
||||
print "--------------------------------------------"
|
||||
return
|
||||
|
||||
|
||||
'''
|
||||
cdef showPrintWithPVName(self, npv, pvlist):
|
||||
print "GROUP NAME = ", self.name
|
||||
print "GROUP HANDLE = ", self.groupHandle
|
||||
print "GROUP STATUS = ", self.groupStatus
|
||||
cdef unsigned int i,j
|
||||
|
||||
for i in range(0, npv):
|
||||
print "pv =", pvlist[i]
|
||||
for j in range(0, len(self.pvdata[i].value)):
|
||||
print self.pvdata[i].value[j],"[%d]" %j,
|
||||
print ""
|
||||
print ("status = %d" % self.pvdata[i].status)
|
||||
print ("alarmStatus = %d" % self.pvdata[i].alarmStatus)
|
||||
print ("alarmSeverity = %d" % self.pvdata[i].alarmSeverity)
|
||||
print "ts =", self.pvdata[i].ts[0], self.pvdata[i].tsDate[1]
|
||||
print "tsDate =", self.pvdata[i].tsDate[0], self.pvdata[i].tsDate[1], \
|
||||
self.pvdata[i].tsDate[2], self.pvdata[i].tsDate[3],\
|
||||
self.pvdata[i].tsDate[4], self.pvdata[i].tsDate[5], self.pvdata[i].tsDate[6]
|
||||
return
|
||||
'''
|
||||
##################################################################################
|
||||
|
||||
|
||||
|
||||
##################################################################################
|
||||
cdef getMatchedDataType(dt, dtn):
|
||||
#dt: input from user
|
||||
#dtn: native type
|
||||
#dtcheck: matching data type for pvd convert method
|
||||
|
||||
cdef unsigned int dtcheck=dtn;
|
||||
|
||||
if dt in ['int','long','short','uint','ulong','ushort','int32','int64','uint32','uint64']:
|
||||
dtcheck=CAFE_LONG
|
||||
elif dt=='double':
|
||||
dtcheck=CAFE_DOUBLE
|
||||
elif dt=='float':
|
||||
dtcheck=CAFE_DOUBLE
|
||||
elif dt in ['string','str']:
|
||||
dtcheck=CAFE_STRING
|
||||
elif dt in ['native','']:
|
||||
dtcheck=dtn #need a line here
|
||||
else:
|
||||
print "Valid input parameters for data type are: 'int', 'float', 'str', or 'native'"
|
||||
print "Data to be presented in native data type"
|
||||
|
||||
return dtcheck
|
||||
##################################################################################
|
||||
|
||||
|
||||
|
||||
#################################################################################
|
||||
|
||||
#cdef pvdata p1 = pvdata()
|
||||
#cdef pvctrl c1 = pvctrl()
|
||||
|
||||
|
||||
#################################################################################
|
||||
|
||||
cdef pvdata PVDataHolderToStruct(PVDataHolder pvd, dt=None):
|
||||
|
||||
#global p1
|
||||
cdef pvdata p1 = pvdata()
|
||||
|
||||
cdef unsigned int dtn = pvd.getDataType();
|
||||
cdef unsigned int dtcheck=dtn
|
||||
cdef localList=[]
|
||||
|
||||
if dt:
|
||||
dtcheck=getMatchedDataType(dt, dtn)
|
||||
|
||||
if dtcheck==CAFE_STRING:
|
||||
for i in range(0, pvd.getNelem()):
|
||||
localList.append(pvd.getAsString(i))
|
||||
elif dtcheck==CAFE_SHORT:
|
||||
for i in range(0, pvd.getNelem()):
|
||||
localList.append(pvd.getAsLong(i)) #getAsShort(i)
|
||||
elif dtcheck==CAFE_FLOAT:
|
||||
for i in range(0, pvd.getNelem()):
|
||||
localList.append(pvd.getAsDouble(i)) #getAsFloat(i)
|
||||
elif dtcheck==CAFE_ENUM:
|
||||
#if enum, string taken as native
|
||||
#if self._c_cafe.isEnum(handle)==1:
|
||||
for i in range(0, pvd.getNelem()):
|
||||
localList.append(pvd.getAsString(i))
|
||||
#else:
|
||||
# for i in range(0, pvd.getNelem()):
|
||||
# localList.append(pvd.getAsLong(i)) #getAsUShort(i)
|
||||
elif dtcheck==CAFE_CHAR:
|
||||
for i in range(0, pvd.getNelem()):
|
||||
localList.append(pvd.getAsLong(i)) # <unsigned char> pvd.getAsChar(i)
|
||||
elif dtcheck==CAFE_LONG:
|
||||
for i in range(0, pvd.getNelem()):
|
||||
localList.append(pvd.getAsLong(i))
|
||||
elif dtcheck==CAFE_DOUBLE:
|
||||
for i in range(0, pvd.getNelem()):
|
||||
localList.append(pvd.getAsDouble(i))
|
||||
else:
|
||||
localList.append(0)
|
||||
#print "This line in PyCafe def getDataHolderToStruct should never appear!"
|
||||
#print "No Data! Error. Is channel connected?"
|
||||
|
||||
p1.value=localList
|
||||
p1.status=pvd.getStatus()
|
||||
p1.nelem=pvd.getNelem()
|
||||
p1.alarmStatus=pvd.getAlarmStatus()
|
||||
p1.alarmSeverity=pvd.getAlarmSeverity()
|
||||
|
||||
pvd._etsNorm=pvd.getEpicsTimeStampAsUInt32()
|
||||
|
||||
cpdef ll=[]
|
||||
ll.append((pvd._etsNorm).secPastEpoch)
|
||||
ll.append((pvd._etsNorm).nsec)
|
||||
p1.ts=ll
|
||||
|
||||
pvd._etsDate=pvd.getEpicsTimeStampAsDate()
|
||||
|
||||
cpdef ld=[]
|
||||
ld.append( (pvd._etsDate).year )
|
||||
ld.append( (pvd._etsDate).mon )
|
||||
ld.append( (pvd._etsDate).day )
|
||||
ld.append( (pvd._etsDate).hour )
|
||||
ld.append( (pvd._etsDate).min )
|
||||
ld.append( (pvd._etsDate).sec )
|
||||
ld.append( (pvd._etsDate).nsec )
|
||||
p1.tsDate=ld
|
||||
|
||||
return p1
|
||||
##################################################################################
|
||||
|
||||
|
||||
|
||||
#################################################################################
|
||||
|
||||
cdef pvctrl PVCtrlHolderToStruct(PVCtrlHolder pvc, dt=None):
|
||||
|
||||
#global c1
|
||||
cdef pvctrl c1 = pvctrl()
|
||||
|
||||
cdef unsigned int dtn = pvc.getDataType();
|
||||
|
||||
cdef unsigned int dtcheck=dtn
|
||||
|
||||
cdef localList=[]
|
||||
|
||||
if dt:
|
||||
dtcheck=getMatchedDataType(dt, dtn)
|
||||
|
||||
if dtcheck==CAFE_STRING:
|
||||
for i in range(0, pvc.getNelem()):
|
||||
localList.append(pvc.getAsString(i))
|
||||
elif dtcheck==CAFE_SHORT:
|
||||
for i in range(0, pvc.getNelem()):
|
||||
localList.append(pvc.getAsLong(i)) #getAsShort(i)
|
||||
elif dtcheck==CAFE_FLOAT:
|
||||
for i in range(0, pvc.getNelem()):
|
||||
localList.append(pvc.getAsDouble(i)) #getAsFloat(i)
|
||||
elif dtcheck==CAFE_ENUM:
|
||||
#if enum, string taken as native
|
||||
#if self._c_cafe.isEnum(handle)==1:
|
||||
for i in range(0, pvc.getNelem()):
|
||||
localList.append(pvc.getAsString(i))
|
||||
#else:
|
||||
# for i in range(0, pvd.getNelem()):
|
||||
# localList.append(pvd.getAsLong(i)) #getAsUShort(i)
|
||||
elif dtcheck==CAFE_CHAR:
|
||||
for i in range(0, pvc.getNelem()):
|
||||
localList.append(pvc.getAsLong(i)) # <unsigned char> pvd.getAsChar(i)
|
||||
elif dtcheck==CAFE_LONG:
|
||||
for i in range(0, pvc.getNelem()):
|
||||
localList.append(pvc.getAsLong(i))
|
||||
elif dtcheck==CAFE_DOUBLE:
|
||||
for i in range(0, pvc.getNelem()):
|
||||
localList.append(pvc.getAsDouble(i))
|
||||
else:
|
||||
localList.append(0)
|
||||
#print "This line in PyCafe def getDataHolderToStruct should never appear!"
|
||||
#print "No Data! Error. Is channel connected?"
|
||||
c1.value=localList
|
||||
c1.status=pvc.getStatus()
|
||||
c1.nelem=pvc.getNelem()
|
||||
c1.alarmStatus=pvc.getAlarmStatus()
|
||||
c1.alarmSeverity=pvc.getAlarmSeverity()
|
||||
|
||||
c1.precision=pvc.getPrecision()
|
||||
c1.noEnumStrings=pvc.getNoEnumStrings()
|
||||
|
||||
enumList=[]
|
||||
for i in range(0, pvc.getNoEnumStrings()):
|
||||
enumList.append(pvc.getEnumStrings()[i])
|
||||
|
||||
c1.enumStrings=enumList
|
||||
|
||||
c1.units=pvc.getUnitsAsString()
|
||||
|
||||
c1.upperDisplayLimit=pvc.getUpperDispLimit_AsDouble()
|
||||
c1.lowerDisplayLimit=pvc.getLowerDispLimit_AsDouble()
|
||||
c1.upperAlarmLimit =pvc.getUpperAlarmLimit_AsDouble()
|
||||
c1.upperWarningLimit=pvc.getUpperWarningLimit_AsDouble()
|
||||
c1.lowerWarningLimit=pvc.getLowerWarningLimit_AsDouble()
|
||||
c1.lowerAlarmLimit =pvc.getLowerAlarmLimit_AsDouble()
|
||||
c1.upperControlLimit=pvc.getUpperCtrlLimit_AsDouble()
|
||||
c1.lowerControlLimit=pvc.getLowerCtrlLimit_AsDouble()
|
||||
|
||||
return c1
|
||||
##################################################################################
|
||||
|
||||
|
||||
#################################################################################
|
||||
|
||||
cdef channelInfo channelRegaliaToStruct(ChannelRegalia cr):
|
||||
|
||||
cdef channelInfo ci = channelInfo()
|
||||
|
||||
ci.channelID = (<long> cr.getChannelID())
|
||||
ci.connectFlag=cr.getConnectFlag()
|
||||
ci.hostName =cr.getHostNameAsString()
|
||||
ci.dataType =cr.getDataType()
|
||||
ci.className =cr.getClassNameAsString()
|
||||
ci.accessRead =cr.getAccessRead()
|
||||
ci.accessWrite=cr.getAccessWrite()
|
||||
ci.nelem =cr.getNelem()
|
||||
ci.connectionState =cr.getConnectionState()
|
||||
ci.cafeConnectionState=cr.getCafeConnectionState()
|
||||
ci.connectionStateAsString =cr.getConnectionStateAsString()
|
||||
ci.cafeConnectionStateAsString =cr.getCafeConnectionStateAsString()
|
||||
return ci
|
||||
#################################################################################
|
||||
|
||||
144
examples.py
144
examples.py
@@ -53,9 +53,7 @@ PVWF3='ARIDI-BPM-01SE:WF-INT-2'
|
||||
PVWF4='ARIDI-BPM-01SB:WF-INT-2'
|
||||
|
||||
PVS='ARIDI-BPM-01SB:SET-ENABLE.DESC'
|
||||
|
||||
PV_JOKE='PV-DOES-NOT:EXIST'
|
||||
|
||||
PV_REAL='SAR-CMON-MAG4531:VOLTAGE-5'
|
||||
|
||||
pvlist1 =[PV1,PV2,PV3,PV4]
|
||||
@@ -93,7 +91,9 @@ def py_callback(handle):
|
||||
|
||||
#get PVData
|
||||
p1=cafe.getPVCache(handle)
|
||||
print ("--------")
|
||||
p1.showMax(10) #if waveform print only first 10 elements
|
||||
print ("--------")
|
||||
#alternatively:
|
||||
print ("Value =", p1.value[0])
|
||||
print ("status = %d" % p1.status)
|
||||
@@ -127,6 +127,57 @@ def py_callback(handle):
|
||||
return
|
||||
##############################################################
|
||||
|
||||
|
||||
#################################################################
|
||||
# A user supplied callback function to be (optionally) used in (8) Monitors.
|
||||
# This is a variant to the above; it returns a PVData object, handle, and pv name.
|
||||
#################################################################
|
||||
def py_callback_pvdata(p1, handle, pv):
|
||||
#operations permitted from within handle are getCache, set and close
|
||||
#open, get and monitorStart are not permitted
|
||||
try:
|
||||
print ("")
|
||||
print ("START: MONITOR CALLBACK HANDLER INVOKED FOR HANDLE:", handle)
|
||||
#Usual action is to get the updated value
|
||||
print ("isConnected?", cafe.isConnected(handle));
|
||||
print ("Channel=", pv)
|
||||
print ("Value =", p1.value[0]) #native format
|
||||
print ("Value =", cafe.getCache(handle, dt='str')) #else dt='int', dt='float'
|
||||
#print ("DbrDataType =", cafe.getDbrDataTypeInCallback(handle) )
|
||||
#print ("DataType =", cafe.getDataTypeInCallback(handle) )
|
||||
#print ("DbrBase =", cafe.getDbrBaseInCallback(handle) )
|
||||
print ("----------")
|
||||
p1.showMax(10) #if waveform print only first 10 elements
|
||||
print ("----------")
|
||||
#alternatively:
|
||||
print ("Value =", p1.value[0])
|
||||
print ("status = %d" % p1.status)
|
||||
print ("alarmStatus = %d" % p1.alarmStatus)
|
||||
print ("alarmSeverity = %d" % p1.alarmSeverity)
|
||||
print ("ts =", p1.ts[0], p1.ts[1])
|
||||
print ("tsDate =", p1.tsDate[0], p1.tsDate[1], \
|
||||
p1.tsDate[2], p1.tsDate[3],\
|
||||
p1.tsDate[4], p1.tsDate[5], p1.tsDate[6] )
|
||||
|
||||
except Exception as inst:
|
||||
print ("ERROR IN CALLBACK HANDLER:")
|
||||
if isinstance(inst.args[0],PyCafe.CyCafeException):
|
||||
cafeEx=inst.args[0]
|
||||
cafeEx.show()
|
||||
#or
|
||||
cafeEx.reveal()
|
||||
#or
|
||||
print (cafeEx.pv,"(handle=", cafeEx.handle,")")
|
||||
print (cafeEx.errorCode,":", cafeEx.errorText,cafeEx.errorInfo)
|
||||
else:
|
||||
print (inst)
|
||||
|
||||
print ("END: MONITOR CALLBACK HANDLER COMPLETED FOR HANDLE:", handle)
|
||||
print ("")
|
||||
return
|
||||
##############################################################
|
||||
|
||||
|
||||
#################################################################
|
||||
# A user supplied callback function for put operations (optional)
|
||||
#################################################################
|
||||
@@ -179,7 +230,7 @@ except Exception as inst:
|
||||
|
||||
print(inst.args)
|
||||
|
||||
cafe.openNowAndWait(0.5) #wait 500ms for channels to connect
|
||||
cafe.openNowAndWait(0.5) #timeout for channels to connect
|
||||
|
||||
end=time.time()
|
||||
print(end-start)
|
||||
@@ -401,7 +452,7 @@ except Exception as inst:
|
||||
#(3) Waveforms and Arrays
|
||||
##############################################################
|
||||
try:
|
||||
NWF=5
|
||||
NWF=5000
|
||||
print ('setting no of elements for wf to ', cafe.setNelem(PVWF1,4084))
|
||||
#time.sleep(5)
|
||||
|
||||
@@ -557,7 +608,7 @@ except Exception as inst:
|
||||
#(4) Multiple scalar operations
|
||||
##############################################################
|
||||
#Now work with multiple scalars - far far more efficient to get multiple data-sets with one call
|
||||
#If a channel is not connected (or other error) then it is reported in the statusList!
|
||||
#If a channel is not connected (or other error) then it is reported in the !
|
||||
#These methods do not throw exceptions
|
||||
|
||||
valueList,status,statusList=cafe.getScalarList(hlist1,'str') #hlist1 or pvlist1
|
||||
@@ -637,7 +688,21 @@ print("--------------------------------------------------------")
|
||||
val,s,sl=cafe.getCompoundList(hlistAll,dt='native')
|
||||
|
||||
print(val)
|
||||
print(s)
|
||||
print(sl)
|
||||
|
||||
print("--------------------------------------------------------")
|
||||
print("valueList from cafe.getPVList(hlistAll,dt='native') for comparison to above")
|
||||
print("A WF is returned as a List within the List ")
|
||||
print("--------------------------------------------------------")
|
||||
pvl,s=cafe.getPVList(hlistAll,dt='native')
|
||||
for i in range (0, len(pvl)):
|
||||
print(hlistAll[i], " " , cafe.getPVNameFromHandle(hlistAll[i]))
|
||||
pvl[i].show()
|
||||
print(" ")
|
||||
print(s)
|
||||
print("--------------------------------------------------------")
|
||||
|
||||
#print one of the waveforms in above val List
|
||||
'''
|
||||
if PY3:
|
||||
@@ -677,6 +742,7 @@ print("--------------------------------------------------------")
|
||||
##############################################################
|
||||
|
||||
|
||||
|
||||
##############################################################
|
||||
#(6) Synchronous group operations and like
|
||||
##############################################################
|
||||
@@ -803,7 +869,7 @@ cafe.withExceptions(False);
|
||||
cafe.openMonitorPrepare();
|
||||
|
||||
#user supplied callback
|
||||
m0 =cafe.monitorStart(hlist1[0], cb=py_callback, dbr=cyca.CY_DBR_PLAIN, mask=cyca.CY_DBE_VALUE|cyca.CY_DBE_ALARM)
|
||||
m0 =cafe.monitorStart(hlist1[0], cb=py_callback_pvdata, dbr=cyca.CY_DBR_PLAIN, mask=cyca.CY_DBE_VALUE|cyca.CY_DBE_ALARM)
|
||||
print(m0)
|
||||
#default input parameters fro dbr and mask
|
||||
m1 =cafe.monitorStart(hlist1[0], cb=py_callback )
|
||||
@@ -821,7 +887,7 @@ cafe.openMonitorNowAndWait(1.0);
|
||||
val=-2.0
|
||||
|
||||
#watch the callbacks being invoked
|
||||
for i in range (0,10):
|
||||
for i in range (0,5):
|
||||
cafe.set(hlist1[0], val+i)
|
||||
#cafe.set(hlist1[1], val+i+0.373)
|
||||
time.sleep(2.0)
|
||||
@@ -831,7 +897,9 @@ for i in range (0,10):
|
||||
#print (" ")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print ('getNoMonitors ' , cafe.getNoMonitors(hlist1[0]));
|
||||
cafe.close(hlist1[0])
|
||||
time.sleep(2);
|
||||
@@ -843,8 +911,8 @@ time.sleep(2);
|
||||
#cafe.setGetCacheWaitPolicy(hlist[0], cyca.GET_CACHE_WAIT)
|
||||
#cafe.setGetCacheWaitPolicy(hlist[1], cyca.GET_CACHE_WAIT)
|
||||
|
||||
cafe.terminate();
|
||||
exit(1);
|
||||
#cafe.terminate();
|
||||
#exit(1);
|
||||
|
||||
|
||||
##############################################################
|
||||
@@ -921,18 +989,36 @@ print (ll)
|
||||
print ("----------------------------////")
|
||||
|
||||
try:
|
||||
cafe.openGroupPrepare()
|
||||
|
||||
gHandle=cafe.groupOpen(ll[0])
|
||||
|
||||
if (len(ll) >0):
|
||||
gHandle2=cafe.groupOpen(ll[1])
|
||||
|
||||
gl=[]
|
||||
gl.append(gHandle)
|
||||
if (len(ll) >0):
|
||||
gl.append(gHandle2)
|
||||
cafe.openGroupNowAndWaitForInputGroups(3.0, [ll[0], gHandle2]) # maximum timeout
|
||||
|
||||
cafe.closeDisconnectedChannelsWithinGroup([ll[0], gHandle2])
|
||||
#cafe.closeChannelKeepHandle(pvlist1)
|
||||
|
||||
pvg=cafe.getPVGroup(gHandle)
|
||||
#or
|
||||
pvg=cafe.getPVGroup(ll[0])
|
||||
print ("--------------------------------/")
|
||||
pvg.showWithPV(cafe.groupMemberList(ll[0])) #'gBRPM'
|
||||
print ("--------------------------------/")
|
||||
pvg=cafe.getPVGroup(ll[1])
|
||||
|
||||
pvg.showWithPV(cafe.groupMemberList(ll[1])) #'gAll'
|
||||
|
||||
|
||||
#cafe.terminate()
|
||||
#exit(0)
|
||||
|
||||
#Start a Collective monitor on all group memebers with the same user supplied cb function
|
||||
cbf=[]
|
||||
for i in range (0, len(ll[0])):
|
||||
cbf.append(py_callback)
|
||||
cbf.append(py_callback_pvdata)
|
||||
s,sV=cafe.groupMonitorStartWithCBList(gHandle,cbf)
|
||||
#or
|
||||
#s,sV=cafe.groupMonitorStartWithCBList(ll[0],cbf)
|
||||
@@ -1072,6 +1158,34 @@ print ("END cafe.setAndMatch----------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#int gameSetAndMatch(handlePVArraytoSet, valueArrayToSet, handlePVActiontoSet, valueActionToSet, handlePVArraytoReadback, tolerance, timeout, printFlag)
|
||||
print (" ")
|
||||
print ("START cafe.gameSetAndMatch------------------------------------------------------")
|
||||
try:
|
||||
s,sL=cafe.setScalarList(mSetHandleList, valInput)
|
||||
s,sL=cafe.setScalarList(mReadHandleList, [3.501,3.599])
|
||||
s=cafe.gameSetAndMatch(mSetHandleList,valInput,mReadHandleList[0],"1",mReadHandleList,0.002,20.0,True)
|
||||
print ("Status of set and match method: ", cafe.getStatusCodeAsText(s))
|
||||
|
||||
except Exception as inst:
|
||||
if isinstance(inst.args[0],PyCafe.CyCafeException):
|
||||
cafeEx=inst.args[0]
|
||||
cafeEx.show()
|
||||
#or
|
||||
cafeEx.reveal()
|
||||
#or
|
||||
print (cafeEx.pv,"(handle=", cafeEx.handle,")")
|
||||
print (cafeEx.errorCode,":", cafeEx.errorText,cafeEx.errorInfo)
|
||||
else:
|
||||
print (inst)
|
||||
|
||||
|
||||
|
||||
|
||||
print ("END cafe.gameSetAndMatch------------------------------------------------------")
|
||||
|
||||
|
||||
|
||||
##############################################################
|
||||
|
||||
|
||||
|
||||
@@ -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.5.0-final-1/lib
|
||||
export PYTHONPATH=.:/opt/gfa/cafe/python/python-3.5/pycafe-1.8.0/lib
|
||||
export LD_LIBRARY_PATH=./
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
##### CHANGE AS APPROPRIATE #################
|
||||
#Cython Version to install
|
||||
CYCAFE_VERSION=pycafe-1.5.0-final-1
|
||||
CYCAFE_VERSION=pycafe-1.8.0
|
||||
|
||||
#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.5.0-final-1/include',
|
||||
'/opt/gfa/cafe/python/python-3.5/pycafe-1.8.0/include',
|
||||
'.', get_include()],
|
||||
library_dirs=[ '/usr/local/epics/base/lib/SL6-x86_64',
|
||||
'/opt/gfa/cafe/python/python-3.5/pycafe-1.5.0-final-1/lib',
|
||||
'/opt/gfa/cafe/python/python-3.5/pycafe-1.8.0/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.5.0-final-1/lib',
|
||||
'/opt/gfa/cafe/python/python-3.5/pycafe-1.8.0/lib',
|
||||
'/opt/gfa/python-3.5/latest/lib'
|
||||
],
|
||||
libraries=['ca','Com','dl','cafe'])
|
||||
|
||||
Reference in New Issue
Block a user