4 Commits

Author SHA1 Message Date
603eda7531 rm --cached ... 2018-12-20 10:44:04 +01:00
a3690b06e4 new release 2018-12-14 15:55:57 +01:00
8e1a1595e0 open methods refined 2017-11-22 14:16:25 +01:00
bc87ffe6ea Connection time optimized 2017-11-14 09:26:02 +01:00
10 changed files with 2541 additions and 2463 deletions

View File

@@ -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,53 +890,26 @@ 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 "cafeService.h":
cdef cppclass DBPMData:
double getValue()
epicsTimeStamp getEpicsTimeStamp()
int getStatus()
cdef cppclass DBPMKeeper:
DBPMKeeper()
#DBPMKeeper(vector[string], vector[unsigned int], multimap[float, string])
DBPMKeeper(vector[string], vector[unsigned int], vector[string], vector[float])
vector[unsigned int] getHandle()
vector[string] getPV()
vector[string] getDevice()
vector[double] getS()
vector[DBPMData] getX()
vector[DBPMData] getY()
vector[DBPMData] getQ()
vector[DBPMData] getEnergy()
vector[double] getOffsetX()
vector[double] getOffsetY()
bint getIsAllXOK()
bint getIsAllYOK()
bint getIsAllQOK()
bint getIsAllEnergyOK()
bint getIsAllOK ()
bint setBS(bint)
bint resetBS()
void closeBS()
int getStatus()
'''
cdef extern from "PVDataHolder.h":
@@ -813,8 +917,8 @@ cdef extern from "PVDataHolder.h":
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()
@@ -848,6 +952,7 @@ cdef extern from "PVDataHolder.h":
string getWFAsString()
string concatToString()
unsigned long long getPulseID()
unsigned int getUserNo()
@@ -869,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()
@@ -884,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()
@@ -970,11 +1081,36 @@ cdef extern from "cafe.h":
int init()
int open(char *, unsigned int &) except +
int openV(vector[string], vector[unsigned int] &) except +
void openNoWait() nogil
void openPrepare() nogil
void openGroupPrepare() nogil
void openNow() nogil
void openNowAndWait(double) nogil
void openGroupNowAndWait(double) nogil
void openGroupNowAndWaitForInput(double, vector[unsigned int]) nogil
void groupOpenNowAndWait(double, vector[unsigned int]) nogil
void openMonitorPrepare() nogil
void openMonitorNow() nogil
void openMonitorNowAndWait(double) nogil
int closeHandlesV(vector[unsigned int]) nogil
int close(unsigned int) nogil
int closeChannels() nogil
bint allChannelsConnected()
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()
int printHandle(unsigned int)
@@ -998,6 +1134,7 @@ cdef extern from "cafe.h":
void loadSFGroups(string)
int getChannelDataStore(unsigned int, ChannelDataStore) nogil
int getChannelInfo(unsigned int, ChannelRegalia)
CAFEStatus getCafeStatus()
@@ -1053,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
@@ -1121,15 +1264,11 @@ cdef extern from "cafe.h":
int setAndMatch(const unsigned int, double, const unsigned int, double tolerance, double timeout, bint printFlag) nogil
int setAndMatchMany(vector[unsigned int], vector[double], vector[unsigned int], double tolerance, double timeout, bint printFlag) nogil
int gameSetAndMatch(vector[unsigned int], vector[double], vector[unsigned int], vector[string], vector[unsigned int], double tolerance, double timeout, bint printFlag) nogil
int match(double, const unsigned int, double tolerance, double timeout, bint printFlag) nogil
int matchMany(vector[double], vector[unsigned int], double tolerance, double timeout, bint printFlag) nogil
#int readDBPMOffsets(DBPMKeeper)
#int getDBPM(DBPMKeeper &) nogil
#int prepareDBPM(vector[string] &, vector[unsigned int] &, vector[string] &, vector[float] &) nogil
int setNelemToOne(const unsigned int)
int setNelemToPrevious(const unsigned int, const unsigned int)
@@ -1137,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

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@
PyCafeDefs_api.pxi

1513
PyCafeDefs.pxi Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -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
#################################################################################

View File

@@ -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------------------------------------------------------")
##############################################################

View File

@@ -1,4 +1,4 @@
source /opt/gfa/python 3.5
python setup3.5_release.py build_ext -i
export PYTHONPATH=.:/opt/gfa/cafe/python/python-3.5/pycafe-1.3.0-final-2/lib
export PYTHONPATH=.:/opt/gfa/cafe/python/python-3.5/pycafe-1.8.0/lib
export LD_LIBRARY_PATH=./

View File

@@ -5,7 +5,7 @@
##### CHANGE AS APPROPRIATE #################
#Cython Version to install
CYCAFE_VERSION=pycafe-1.3.0-final-2
CYCAFE_VERSION=pycafe-1.8.0
#CAFE project base
#CAFE_BASE=${EPICS_EXTENSIONS}/CAFE

View File

@@ -13,14 +13,14 @@ setup(
'/usr/local/epics/base/include/os/Linux',
'/opt/gfa/cafe/boost/boost_1_61_0/include',
'/opt/gfa/cafe/boost/boost_1_61_0/include/boost',
'/opt/gfa/cafe/python/python-3.5/pycafe-1.3.0-final-2/include',
'/opt/gfa/cafe/python/python-3.5/pycafe-1.8.0/include',
'.', get_include()],
library_dirs=[ '/usr/local/epics/base/lib/SL6-x86_64',
'/opt/gfa/cafe/python/python-3.5/pycafe-1.3.0-final-2/lib',
'/opt/gfa/cafe/python/python-3.5/pycafe-1.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.3.0-final-2/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'])