From 8e79e5077fff09c9771e36c8a9a2fa78d5810fcc Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Mon, 20 Feb 2012 13:57:52 +0000 Subject: [PATCH] modified configuremac function, moved digital test bit to digital test function git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@126 951219d9-93cf-4727-9268-0efd64621fa3 --- .../slsDetector/slsDetector.cpp | 9 +-- slsDetectorSoftware/slsDetector/slsDetector.h | 3 +- .../slsDetector/slsDetectorCommand.cpp | 81 ++++++++++++------- .../slsDetector/slsDetectorCommand.h | 2 +- 4 files changed, 58 insertions(+), 37 deletions(-) diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index bbdcc25e7..de653bf31 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -1571,21 +1571,19 @@ int slsDetector::digitalTest( digitalTestMode mode, int imod){ int retval; int fnum=F_DIGITAL_TEST; int ret=FAIL; - char mess[100]; #ifdef VERBOSE std::cout<< std::endl; std::cout<< "Getting id of "<< mode << std::endl; #endif + if (thisDetector->onlineFlag==ONLINE_FLAG) { - - if (controlSocket) { if (controlSocket->Connect()>=0) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&mode,sizeof(mode)); - if (mode==CHIP_TEST) + if ((mode==CHIP_TEST)|| (mode==DIGITAL_BIT_TEST)) controlSocket->SendDataOnly(&imod,sizeof(imod)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) @@ -4356,7 +4354,7 @@ char* slsDetector::setServerMAC(string serverMAC){ }; -int slsDetector::configureMAC(int ival){ +int slsDetector::configureMAC(){ int retval,i; int ret=FAIL; int fnum=F_CONFIGURE_MAC; @@ -4414,7 +4412,6 @@ int slsDetector::configureMAC(int ival){ if (controlSocket->Connect()>=0) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->SendDataOnly(&ival,sizeof(ival)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 8fb64ecbb..284fa5c28 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -336,9 +336,8 @@ typedef struct sharedSlsDetector { /** configures mac for gotthard readout - \param ival temporarily used to set/reset the digital test bit */ - int configureMAC(int ival); + int configureMAC(); /** Purely virtual function diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 7fac72256..356949d3e 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -346,6 +346,10 @@ slsDetectorCommand::slsDetectorCommand() { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest; i++; + descrToFuncMap[i].m_pFuncName="digibittest"; // + descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest; + i++; + descrToFuncMap[i].m_pFuncName="reg_rw"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRegister; i++; @@ -2222,12 +2226,19 @@ string slsDetectorCommand::cmdConfigureMac(int narg, char *args[], int action) { int ival; int ret; char ans[1000]; - if (action==PUT_ACTION) { - if (sscanf(args[1],"%d",&ival)) - ret=configureMAC(ival); - else - return string("Could not scan digital test bit ")+string(args[1]); + + if (action==PUT_ACTION){ + if (sscanf(args[1],"%d",&ival)) + if(ival==1){ + setOnline(ONLINE_FLAG); + ret=configureMAC(); + } + else + return string("Not yet implemented with arguments other than 1"); } + else + return string("Cannot get ")+cmd; + sprintf(ans,"%d",ret); return ans; } @@ -2235,13 +2246,12 @@ string slsDetectorCommand::cmdConfigureMac(int narg, char *args[], int action) { string slsDetectorCommand::helpConfigureMac(int narg, char *args[], int action) { ostringstream os; - if (action==PUT_ACTION || action==HELP_ACTION) { - os << "configuremac i \n configures the MAC of the detector and sets/resets (1/0) the digital test bit"<< std::endl; + if (action==PUT_ACTION || action==HELP_ACTION) + os << "configuremac i \n configures the MAC of the detector. i=1 for configure; i=0 for unconfigure(not implemented yet)"<< std::endl; + if (action==GET_ACTION || action==HELP_ACTION) + os << "configuremac " << "Cannot get " << std::endl; - } return os.str(); - - } @@ -2497,31 +2507,46 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) { char answer[1000]; - - if (action==PUT_ACTION) - return string("cannot set"); - - if (action==HELP_ACTION) - return helpSN(narg, args, action); - + return helpSN(narg, args, action); + setOnline(ONLINE_FLAG); if (cmd=="bustest"){ - sprintf(answer,"%x",digitalTest(DETECTOR_BUS_TEST)); - return string(answer); + if (action==PUT_ACTION) + return string("cannot set ")+cmd; + sprintf(answer,"%x",digitalTest(DETECTOR_BUS_TEST)); + return string(answer); } - if (cmd=="digitest") { - int ival=-1; - if (sscanf(args[0],"digitest:%d",&ival)) { - sprintf(answer,"%x",digitalTest(CHIP_TEST, ival)); - return string(answer); - } else - return string("undefined module number"); - } - + if (cmd=="digitest") { + if (action==PUT_ACTION) + return string("cannot set ")+cmd; + int ival=-1; + if (sscanf(args[0],"digitest:%d",&ival)) { + sprintf(answer,"%x",digitalTest(CHIP_TEST, ival)); + return string(answer); + } else + return string("undefined module number"); + } + + if (cmd=="digibittest") { + if (action==GET_ACTION) + return string("cannot get ")+cmd; + int ival=-1; + if (sscanf(args[1],"%d",&ival)) { + if((ival==0)||(ival==1)){ + sprintf(answer,"%x",digitalTest(DIGITAL_BIT_TEST,ival)); + return string(answer); + } + else + return string("Use only 0 or 1 to set/clear digital test bit\n"); + } else + return string("undefined value"); + } + + return string("unknown digital test mode ")+cmd; } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h index 1e8af344e..c9f0d322b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h @@ -299,7 +299,7 @@ class slsDetectorCommand; virtual int setPort(portType t, int i=-1)=0; virtual int lockServer(int i=-1)=0; virtual string getLastClientIP()=0; - virtual int configureMAC(int)=0; + virtual int configureMAC()=0; virtual int setNumberOfModules(int i=-1, dimension d=X)=0; virtual int getMaxNumberOfModules(dimension d=X)=0; virtual int setDynamicRange(int i=-1)=0;