From c43fe9b10e6d5f5878fdcc1973f8049b6780b0a1 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Fri, 14 Dec 2012 12:55:34 +0000 Subject: [PATCH] included svninfo header file which gets populated when exportSoftware from newMythenSoftware is executed git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@384 951219d9-93cf-4727-9268-0efd64621fa3 --- slsDetectorSoftware/Makefile | 3 +- .../slsDetector/slsDetector.cpp | 12 +- slsDetectorSoftware/svnInfo.h | 120 ++++++++++++++++++ 3 files changed, 125 insertions(+), 10 deletions(-) create mode 100644 slsDetectorSoftware/svnInfo.h diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index 03ed9656d..722b63a56 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -1,7 +1,7 @@ CFLAGS= -DC_ONLY -fPIC #FLAGS+= #-DVERBOSE -DVERYVERBOSE -DFLAGS= -DDACS_INT +DFLAGS= -DDACS_INT -DTHIS_PATH='"$(shell pwd)"' #ASM=$(shell echo "/lib/modules/`uname -r`/build/include") @@ -28,7 +28,6 @@ DOCDIR ?= docs - all: package $(SRC_CLNT) echo "compiling all" diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 987d7927e..849f39f31 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -8,6 +8,8 @@ #include #include #include +#include "svnInfo.h" + int slsDetector::initSharedMemory(detectorType type, int id) { @@ -1572,13 +1574,9 @@ slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunication int64_t slsDetector::getId( idMode mode, int imod){ - int64_t retval=-1; int fnum=F_GET_ID; int ret=FAIL; - int64_t rev=0; - int rev1; - char mess[100]; #ifdef VERBOSE @@ -1590,10 +1588,8 @@ int64_t slsDetector::getId( idMode mode, int imod){ #endif if (mode==THIS_SOFTWARE_VERSION) { ret=OK; - sscanf(THIS_REVISION,"$Rev : %x",&rev1); - rev=((int64_t)rev1); - - retval=(thisSoftwareVersion<<32) | rev; + svnInfo* s = new svnInfo(THIS_PATH); + retval=(thisSoftwareVersion<<32) | (s->getRevision()); } else { if (thisDetector->onlineFlag==ONLINE_FLAG) { if (controlSocket) { diff --git a/slsDetectorSoftware/svnInfo.h b/slsDetectorSoftware/svnInfo.h new file mode 100644 index 000000000..c98ee7312 --- /dev/null +++ b/slsDetectorSoftware/svnInfo.h @@ -0,0 +1,120 @@ +#ifndef SVN_INFO_H +#define SVN_INFO_H + +#include +#include +#include +#include +using namespace std; + +/** + * + * @short reads svnInfo.txt and populates this class members + */ + +class svnInfo{ +public: + /** Constructor : populates the class members from svnInfo.txt*/ + svnInfo(string const path){ + revision=0; + char fName[100]; + strcpy(fName,path.c_str()); + strcat(fName,"/svnInfo.txt"); + //read from file and populate class + string sLine,sArgName; + ifstream inFile; + inFile.open(fName, ifstream::in); + if(inFile.is_open()) + { + while(inFile.good()) + { + getline(inFile,sLine); + istringstream sstr(sLine); + + if(sstr.good()){ + sstr>>sArgName; + + if(sArgName=="Path:"){ + if(sstr.good()) + sstr>>Path; + } + else if(sArgName=="URL:"){ + if(sstr.good()) + sstr>>URL; + } + else if(sArgName=="Repository"){ + + if(sstr.good()){ + sstr>>sArgName; + + if(sArgName=="Root:"){ + if(sstr.good()) + sstr>>repositoryRoot; + } + else{ + if(sstr.good()) + sstr>>repositoryUUID; + } + } + } + else if(sArgName=="Revision:"){ + if(sstr.good()){ + int rev=0; + sstr>>sArgName; + sscanf(sArgName.c_str(),"%x",&rev); + revision = ((int64_t)rev); + } + } + else if(sArgName=="NodeKind:"){ + if(sstr.good()) + sstr>>nodeKind; + } + else if(sArgName=="Schedule:"){ + if(sstr.good()) + sstr>>schedule; + } + else if(sArgName=="Last"){ + if(sstr.good()){ + if(sstr.good()){ + sstr>>sArgName; + + if(sArgName=="Author:"){ + if(sstr.good()) + sstr>>lastChangedAuthor; + } + else if(sArgName=="Rev:"){ + if(sstr.good()) + sstr>>lastChangedRev; + } + else if(sArgName=="Date:"){ + if(sstr.good()) + sstr>>lastChangedDate; + } + } + } + } + } + } + inFile.close(); + }else + cout << "ERROR: Could not open svn Info file: svnInfo.txt" << endl; + }; + + /** Returns revision */ + int64_t getRevision(){return revision;}; + +private: + string Path; + string URL; + string repositoryRoot; + string repositoryUUID; + int64_t revision; + string nodeKind; + string schedule; + string lastChangedAuthor; + string lastChangedRev; + string lastChangedDate; +}; + + +#endif