new release

This commit is contained in:
2018-12-14 15:55:17 +01:00
parent e31fed82be
commit f351a0d5bb
5 changed files with 226 additions and 51 deletions

3
.gitignore vendored
View File

@@ -1,5 +1,8 @@
*~
*.bak
*.*-
SL6-x86_64
windows-x64
felix-cache
readme.txt
makefile_rel*

View File

@@ -38,7 +38,7 @@
% To run this test script, first create 5 soft channels of the given class.
% pv(1:2) are scalar numerics, pv(3) is a wf, pv(4) is a mbbo record (enum),
% pv(5) is a dbr_string_t, pv(6) does not exist
pv={'ARIDI-BPM-01LE:X-AVG','ARIDI-BPM-01LE:Y-AVG','ARIDI-BPM-01LE:WF-INT-2','ARIDI-BPM-01LE:SET-ENABLE','ARIDI-BPM-01LE:SET-ENABLE.DESC','PV-JOKE'};
pv={'ARIDI-BPM-01LE:X-AVG','ARIDI-BPM-01LE:Y-AVG','ARIDI-BPM-01LE:WF-INT-2','caget','ARIDI-BPM-01LE:SET-ENABLE.DESC','PV-JOKE'};
%
% MATLAB's Run and Advance utility will run each of these 17 sections at the user's prompt.
@@ -162,7 +162,7 @@ pvtable
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%(2) Simple single channel operations (and the PVData Object)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
@@ -1029,7 +1029,7 @@ setValue=0.4;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (17) Gracefully terminate CAFE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
@@ -1044,7 +1044,7 @@ mocha ('close');
%
%END (17) Gracefully terminate CAFE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@@ -6,7 +6,7 @@ namespace NS_MOCHA {
using boost::multi_index_container;
using namespace boost::multi_index;
using namespace std;
const unsigned short METHOD_NAME_MAX_SIZE=80;
const unsigned short PVNAME_MAX_SIZE=80;
@@ -172,7 +172,7 @@ enum mochaIndex {SHOW=1, OPEN, OPEN_ARRAY, OPEN_WAIT, GET_OPEN_WAIT_TIME,
GET_WF_AS_STRING, GET_WF_AS_STRING_CACHE,
GET_GROUP, GET_GROUP_CACHE, GET_GROUP_EXTENDED, GET_GROUP_EXTENDED_CACHE,
GET_STRUCT, GET_STRUCT_CACHE, GET_STRUCT_EXTENDED, GET_STRUCT_EXTENDED_CACHE,
GET_CTRL_STRUCT, GET_CTRL_CACHE, GET_ME_STRUCT, GET_CHANNEL_INFO,
GET_ENUM_STRINGS, GET_CTRL_STRUCT, GET_CTRL_CACHE, GET_ME_STRUCT, GET_CHANNEL_INFO,
FETCH_INDEX_OF_GROUP_MEMBER, FETCH_INDEX_OF_COLLECTION_MEMBER,
GET_STATUS=200, GET_STATUS_TEXT, GET_STATUS_INFO, IS_STATUS_TIMEOUT,
GET_ALARM, GET_ALARM_AS_STRING,
@@ -296,6 +296,8 @@ void msInsert() {
ms.insert(mochaccino(GET_GROUP_EXTENDED, "getstructgroup"));
ms.insert(mochaccino(GET_GROUP_EXTENDED_CACHE, "getstructgroupcache"));
ms.insert(mochaccino(GET_ENUM_STRINGS, "getenumstrings"));
ms.insert(mochaccino(GET_CTRL_STRUCT, "getctrl"));
ms.insert(mochaccino(GET_CTRL_CACHE, "getctrlcache"));
@@ -322,8 +324,8 @@ void msInsert() {
ms.insert(mochaccino(GET_TIMESTAMP, "gettimestamp"));
ms.insert(mochaccino(GET_EPICS_TIMESTAMP, "getepicstimestamp"));
ms.insert(mochaccino(GET_EPICS_TIMESTAMP, "getets"));
ms.insert(mochaccino(GET_PULSEID_FROM_TIMESTAMP, "getpulseidfromts"));
ms.insert(mochaccino(GET_PULSEID_FROM_TIMESTAMP_GROUP,"getgrouppulseidfromts"));
//ms.insert(mochaccino(GET_PULSEID_FROM_TIMESTAMP, "getpulseidfromts"));
//ms.insert(mochaccino(GET_PULSEID_FROM_TIMESTAMP_GROUP,"getgrouppulseidfromts"));
ms.insert(mochaccino(GET_READ_ACCESS, "getreadaccess"));
ms.insert(mochaccino(GET_WRITE_ACCESS, "getwriteaccess"));
@@ -421,27 +423,27 @@ void mdtInsert() {
}
void printStatus(int status ) {
string s = cafe.getCafeStatus().csi.message(status);
string c = cafe.getCafeStatus().csc.message(status);
std::string s = cafe.getCafeStatus().csi.message(status);
std::string c = cafe.getCafeStatus().csc.message(status);
mexPrintf("%s\n",c.c_str());
mexPrintf("%s\n",s.c_str());
}
string prepareExceptionID(int status ) {
string exID="CAFE_"; exID.append(cafe.getCafeStatus().severity(status));
std::string prepareExceptionID(int status ) {
std::string exID="CAFE_"; exID.append(cafe.getCafeStatus().severity(status));
exID.append(":"); exID.append(cafe.getCafeStatus().msgID(status));
return exID;
}
string prepareExceptionText(unsigned int handle, int status ) {
string exText="PV=";
std::string prepareExceptionText(unsigned int handle, int status ) {
std::string exText="PV=";
exText.append(cafe.getPVFromHandle(handle));
exText.append(" Handle=");
exText.append(static_cast<ostringstream*>( &(ostringstream() << handle) )->str());
exText.append(static_cast<std::ostringstream*>( &(std::ostringstream() << handle) )->str());
exText.append(" statusCode=");
exText.append(static_cast<ostringstream*>( &(ostringstream() << status) )->str());
exText.append(static_cast<std::ostringstream*>( &(std::ostringstream() << status) )->str());
exText.append(" statusText="); exText.append(cafe.getCafeStatus().msgID(status));
exText.append(" statusInfo="); exText.append(cafe.getCafeStatus().info(status));
return exText;
@@ -449,8 +451,7 @@ string prepareExceptionText(unsigned int handle, int status ) {
void fillMEStruct(string sME) {
void fillMEStruct(std::string sME) {
fout1 = mxCreateNumericMatrix(1,1,mxUINT32_CLASS,mxREAL);
ulongArray = (uint32_T *) mxGetData (fout1);
@@ -467,17 +468,16 @@ void fillMEStruct(string sME) {
std::size_t found = sME.find("PV=");
if (found != string::npos) {
if (found != std::string::npos) {
str2 = sME.substr(found+3);
found = str2.find(" ");
str = str2.substr(0,found);
mexPrintf("PV %s\n", str.c_str());
mxSetCell (fout0, 0, mxCreateString( str.c_str()));
}
found= sME.find("Handle=");
if (found!= string::npos) {
if (found!= std::string::npos) {
str2 = sME.substr(found+7);
found = str2.find(" ");
str = str2.substr(0,found);
@@ -486,7 +486,7 @@ void fillMEStruct(string sME) {
}
found= sME.find("statusCode=");
if (found!= string::npos) {
if (found!= std::string::npos) {
str2 = sME.substr(found+11);
found = str2.find(" ");
@@ -494,10 +494,9 @@ void fillMEStruct(string sME) {
//mexPrintf("status %d\n", std::atoi(str.c_str()));
longStatus[0]= std::atoi(str.c_str());
}
found= sME.find("statusText=");
if (found!= string::npos) {
if (found!= std::string::npos) {
str2 = sME.substr(found+11);
found = str2.find(" ");
str = str2.substr(0,found);
@@ -506,14 +505,13 @@ void fillMEStruct(string sME) {
}
found= sME.find("statusInfo=");
if (found!= string::npos) {
if (found!= std::string::npos) {
str2 = sME.substr(found+11);
//mexPrintf("statusInfo %s\n", str2.c_str());
mxSetCell (fout4, 0, mxCreateString(str2.c_str()));
}
return;
}
@@ -542,6 +540,7 @@ bool isValidClass(const mxArray * inputClass) {
return true;
}
unsigned int getMdtIndexFromCafeDataType(CAFE_DATATYPE cdt){
unsigned int mdtIndex;
@@ -978,10 +977,10 @@ void cellToPVString(const mxArray * thisCell){
vector<unsigned int> openArray(vector<string> vstr) {
std::vector<unsigned int> openArray(std::vector<std::string> vstr) {
vector<uint32_T> vuint32;
std::vector<uint32_T> vuint32;
vuint32.reserve(vstr.size());
std::fill(vuint32.begin(), vuint32.end(), 0);

View File

@@ -59,9 +59,7 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
if ( mxGetString(mData, mess, messLength) == 1) {
mexPrintf ("mxGetString has failed; input is not of mxChar type\n");
}
mexPrintf ("mocha does not support string/mxSTRING_CLASS as input\n");
mexPrintf ("Please use char/mxCHAR_CLASS as data type for input\n");
return;
@@ -82,16 +80,12 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
}
char messOriginal[METHOD_NAME_MAX_SIZE+1];
strcpy(messOriginal,mess);
//mexPrintf("message mess:%s\n", mess);
//mexPrintf("message orig:%s\n", messOriginal);
//remove leadingTrailing Blanks
const char * _mess=mess;
cafe.getHandleHelper().removeLeadingAndTrailingSpaces(_mess,mess);
@@ -150,9 +144,9 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
if (strcmp(mess,"monitorflushevent")==0 ) {
mexPrintf("The CAFEteria is now open due to an outstanding monitorFlushEvent action (probably from a timer) \n");
}
else {
mexPrintf("The CAFEteria is now open \n");
}
// else {
//mexPrintf("The CAFEteria is now open \n");
// }
}
@@ -453,7 +447,7 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
break;
case MOCHA_VERSION:
plhs[0]=mxCreateString((char *) "mocha-1.5.0-final-1 : November 2017");
plhs[0]=mxCreateString((char *) "mocha-1.8.0 : 14 December 2018");
break;
case SHOW:
@@ -921,7 +915,6 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
}
}
vector<uint32_T> vuint32=NS_MOCHA::openArray(vstr);
@@ -1384,14 +1377,62 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
}
case GET_ENUM_STRINGS:
{
if (mxIsChar(prhs[1])) {
nh=1;
}
else{
nh=mxGetNumberOfElements (prhs[1]);
}
if (nh >1) {
mexPrintf("Method limited to one handle/pv only. Reporting on first given");
}
handle=checkForHandle(prhs[1]);
if(handle==0) {
mexPrintf("Handle does not exist!\n");
return;}
chtype rdt;
status=cafe.getHandleHelper().getDataTypeRequest(handle, rdt);
if (status!=ICAFE_NORMAL) {
mexPrintf("Error for handle input= %d \n", (uint32_T) handle );
NS_MOCHA::printStatus(status);
plhs[0] = mxCreateCellMatrix(1,1);
mxSetCell (plhs[0], 0, mxCreateString((const char *) "" ) );
return;
}
vector<std::string> enumStrings= cafe.getHandleHelper().getEnumStrings(handle);
unsigned int noEnumStrings=enumStrings.size();
if (noEnumStrings==0){
status=cafe.getHandleHelper().getStatus(handle);
if (status!=ICAFE_NORMAL) {
NS_MOCHA::printStatus(status);
}
plhs[0] = mxCreateCellMatrix(1,1);
mxSetCell (plhs[0], 0, mxCreateString((const char *) "" ) );
}
else {
plhs[0] = mxCreateCellMatrix(1,noEnumStrings);
for (mwSignedIndex i=0; i <noEnumStrings; ++i)
mxSetCell (plhs[0], i, mxCreateString((const char *) enumStrings[i].c_str()));
}
break;
}
case GET_CTRL_STRUCT:
{
if (nrhs<2) {
mexPrintf("Invalid Number of argument %d. Input: message, handle/pv, matlab type (optional)\n", nrhs);
return;
}
if (mxIsChar(prhs[1])) {
nh=1;
}
@@ -1453,8 +1494,6 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
string s = cafe.getPVFromHandle(handle);
fout17 =mxCreateString( s.c_str() );
nelem=cafe.getHandleHelper().getNelemRequestCtrl(handle);
// mexPrintf("nelemRequested %d", nelem);
@@ -2990,7 +3029,7 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
break;
}
/*
case GET_PULSEID_FROM_TIMESTAMP:
{
if (nrhs<2) {
@@ -3073,7 +3112,7 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
break;
}
*/
case SET_GROUP:
{
if (nrhs<3) {

View File

@@ -1 +0,0 @@
makefile_rel_1.5

135
makefile Normal file
View File

@@ -0,0 +1,135 @@
#
# Jan Chrin
# New Version: June 2016
#
# makefile to build mocha mex file
# printenv | grep MATLAB to reveal your MATLAB Directory
#
# e.g. on sf-lc we have
# MATLAB=/afs/psi.ch/sys/linux/opt/matlab/2015a.x86_64
#
# local executables are built in ./${EPICS_HOST_ARCH}/$(MVER)
# where the MATLAB version is grepped from $(MATLAB)
MATLAB_ROOT=${MATLAB}
MATLAB_VERSION=$(notdir $(MATLAB_ROOT))
##### CHANGE AS APPROPRIATE #################
#Mocha Version to install
MOCHA_VERSION=mocha-noqt-1.8.0-gcc-6.3.0
#CAFE version to link to
CAFE_VERSION=cafe-noqt-1.8.0-gcc-6.3.0
EPICS_BASE=${EPICS}/base
#CAFE project base
CAFE_BASE=/opt/gfa/cafe
CAFE_MOCHA_BASE=${CAFE_BASE}/mocha
CAFE_CPP_BASE=$(CAFE_BASE)/cpp/$(CAFE_VERSION)
BOOST_BASE=${CAFE_BASE}/boost/boost_1_61_0/include
INSTALL_MOCHA_LIBDIR= $(CAFE_MOCHA_BASE)/$(MOCHA_VERSION)/lib/$(MATLAB_VERSION)
#############################################
#First deteremine if we are on a 32/64 bit machine
#as mex file extensions are named differently
pattern64=x86_64
pattern32=i386
PWD=$(shell pwd)
#hardware platform
HW=$(shell uname -i)
ifeq ($(pattern64),$(findstring $(pattern64), $(HW)))
MEXE=mexa64
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa64
else
ifeq ($(pattern32),$(findstring $(pattern32), $(HW)))
MEXE=mexglx
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa86
endif
endif
INSTALL_PATH?=$(INSTALL_MOCHA_LIBDIR)
OBJ_DIR= ${EPICS_HOST_ARCH}/$(MATLAB_VERSION)
INCLUDEPATH_MOCHA += -I$(MATLAB_ROOT)/extern/include \
-I$(CAFE_CPP_BASE)/include -I./ \
-I$(EPICS_BASE)/include -I$(EPICS_BASE)/include/os/Linux
INCLUDEPATH_MACHINETTA += $(INCLUDEPATH_MOCHA) -I$(BOOST_BASE) -I$(BOOST_BASE)/boost
LIB_DIR += \
-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} \
-Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} \
-L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB)
#-lboost_system -lboost_thread-mt
LIBS += -ldl -lca -lCom -lmx -lmex -lmat
LIB_INSTALL = $(LIB_DIR) -L$(INSTALL_PATH) -Wl,-rpath,$(INSTALL_PATH)
LIB_LOCAL = $(LIB_DIR)
CPP_OBJS=../cpp/src/libs/cafe/$(CAFE_VERSION_M)
#CAFE_OBJS_DIR = $(CPP_OBJS)/cafe.o $(CPP_OBJS)/cafeCache.o $(CPP_OBJS)/cafeGroup.o $(CPP_OBJS)/cafeVectors.o \
# $(CPP_OBJS)/cafeXML.o $(CPP_OBJS)/callbackHandlerCreate.o $(CPP_OBJS)/callbackHandlerMonitor.o \
# $(CPP_OBJS)/conduitGroup.o $(CPP_OBJS)/conduit.o \
# $(CPP_OBJS)/connectCallbacks.o $(CPP_OBJS)/connectGroup.o \
# $(CPP_OBJS)/connect.o $(CPP_OBJS)/exceptionsHelper.o $(CPP_OBJS)/granules.o $(CPP_OBJS)/handleHelper.o \
# $(CPP_OBJS)/helper.o \
# $(CPP_OBJS)/loadCollectionXMLParser.o $(CPP_OBJS)/loadGroupXMLParser.o $(CPP_OBJS)/methodCallbacks.o \
# $(CPP_OBJS)/policyHelper.o \
# $(CPP_OBJS)/restorePVGroupXMLParser.o $(CPP_OBJS)/transpose.o
CAFE_OBJS_DIR = $(CAFE_BASE)/cpp/$(CAFE_VERSION)/lib/libcafe.a
# MATLAB Versions 2014 onwards, use
# LDFLAGS='$(LIB_LOCAL) $(LIBS) instead of $(LIB_LOCAL) $(LIBS)
# LDFLAGS='$(LIB_LOCAL) $(LIBS) instead of $(LIB_INSTALL) $(LIBS)
$(OBJ_DIR)/mocha.$(MEXE): mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o
mex -largeArrayDims CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) -outdir $(OBJ_DIR) -output mocha.$(MEXE) \
$(INCLUDEPATH_MOCHA) \
LDFLAGS='$(LIB_LOCAL) $(LIBS)'
#$(OBJ_DIR)/libmacchinetta.so: $(OBJ_DIR)/macchinettaSwitch.o
# g++ -shared -Wl,-soname,libmacchinetta.so \
# $(OBJ_DIR)/macchinettaSwitch.o -o $(OBJ_DIR)/libmacchinetta.so
$(OBJ_DIR)/macchinettaSwitch.o: macchinettaSwitch.cpp macchinettaHelper.h \
macchinetta.h containerMochaccino.h
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread' \
-c macchinettaSwitch.cpp $(INCLUDEPATH_MACHINETTA) -outdir $(OBJ_DIR)
install: $(OBJ_DIR)/mocha.$(MEXE)
mkdir -p $(INSTALL_PATH)
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) -outdir $(INSTALL_PATH) -output mocha.$(MEXE) \
$(INCLUDEPATH_MOCHA) \
LDFLAGS='$(LIB_INSTALL) $(LIBS)'
cp example.m $(INSTALL_PATH)
cp scripts/monitorAction.m $(INSTALL_PATH)
cp scripts/pvtable.m $(INSTALL_PATH)
cp scripts/test.xml $(INSTALL_PATH)
install_lib: $(OBJ_DIR)/libmacchinetta.so
mkdir -p $(INSTALL_PATH)
cp $(OBJ_DIR)/libmacchinetta.so $(INSTALL_PATH)
clean:
rm -f $(OBJ_DIR)/*.o $(OBJ_DIR)/*.so $(OBJ_DIR)/*.$(MEXE)