diff --git a/.gitignore b/.gitignore index bf668b9..951fca0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ *~ *.bak +*.*- SL6-x86_64 windows-x64 felix-cache +readme.txt +makefile_rel* diff --git a/exampleNew.m b/exampleNew.m index 1b5cb33..c2f09c3 100644 --- a/exampleNew.m +++ b/exampleNew.m @@ -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 -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/macchinettaHelper.h b/macchinettaHelper.h index 712349c..2d33520 100644 --- a/macchinettaHelper.h +++ b/macchinettaHelper.h @@ -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() << handle) )->str()); + exText.append(static_cast( &(std::ostringstream() << handle) )->str()); exText.append(" statusCode="); - exText.append(static_cast( &(ostringstream() << status) )->str()); + exText.append(static_cast( &(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 openArray(vector vstr) { +std::vector openArray(std::vector vstr) { - vector vuint32; + std::vector vuint32; vuint32.reserve(vstr.size()); std::fill(vuint32.begin(), vuint32.end(), 0); diff --git a/macchinettaSwitch.cpp b/macchinettaSwitch.cpp index 39932c8..798c773 100644 --- a/macchinettaSwitch.cpp +++ b/macchinettaSwitch.cpp @@ -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 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 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