mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 05:17:13 +02:00
fixed mismatch between slsDetectorCommand and slsDetectorUsers when setting the timing mode
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@684 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -1912,19 +1912,22 @@ int slsDetector::readRegister(int addr){
|
|||||||
std::cout<< "Reading register "<< hex<<addr << std::endl;
|
std::cout<< "Reading register "<< hex<<addr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (connectControl() == OK){
|
// if (connectControl() == OK){
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
if (stopSocket) {
|
||||||
controlSocket->SendDataOnly(&arg,sizeof(arg));
|
if (stopSocket->Connect()>=0) {
|
||||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
|
stopSocket->SendDataOnly(&arg,sizeof(arg));
|
||||||
|
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=FAIL)
|
if (ret!=FAIL)
|
||||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
else {
|
else {
|
||||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||||
}
|
}
|
||||||
controlSocket->Disconnect();
|
stopSocket->Disconnect();
|
||||||
if (ret==FORCE_UPDATE)
|
// if (ret==FORCE_UPDATE)
|
||||||
updateDetector();
|
// updateDetector();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
#include "slsDetectorUsers.h"
|
||||||
#include "error_defs.h"
|
#include "error_defs.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -392,8 +393,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
|||||||
\returns current external communication mode
|
\returns current external communication mode
|
||||||
*/
|
*/
|
||||||
virtual externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE)=0;
|
virtual externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE)=0;
|
||||||
int setTimingMode(int i=-1){return (int)setExternalCommunicationMode((externalCommunicationMode)i);};
|
int setTimingMode(int i=-1){return slsDetectorUsers::getTimingMode( externalCommunicationType( setExternalCommunicationMode(externalCommunicationType( slsDetectorUsers::getTimingMode(i) ) ) ) );};
|
||||||
|
|
||||||
|
|
||||||
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS)=0;
|
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS)=0;
|
||||||
int setThresholdEnergy(int e_eV){return setThresholdEnergy(e_eV,-1);};
|
int setThresholdEnergy(int e_eV){return setThresholdEnergy(e_eV,-1);};
|
||||||
|
@ -455,6 +455,27 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRegister;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRegister;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="setbit"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRegister;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="clearbit"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRegister;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="getbit"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRegister;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* settings, threshold */
|
/* settings, threshold */
|
||||||
|
|
||||||
descrToFuncMap[i].m_pFuncName="settings"; //
|
descrToFuncMap[i].m_pFuncName="settings"; //
|
||||||
@ -3029,38 +3050,105 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) {
|
|||||||
if (action==HELP_ACTION)
|
if (action==HELP_ACTION)
|
||||||
return helpRegister(narg, args, action);
|
return helpRegister(narg, args, action);
|
||||||
|
|
||||||
int addr, val;
|
int addr, val,n;
|
||||||
char answer[1000];
|
char answer[1000];
|
||||||
|
|
||||||
myDet->setOnline(ONLINE_FLAG);
|
myDet->setOnline(ONLINE_FLAG);
|
||||||
|
|
||||||
|
|
||||||
|
// "reg" //
|
||||||
|
|
||||||
|
// "setbit" //
|
||||||
|
|
||||||
|
// "clearbit" //
|
||||||
|
|
||||||
|
// "getbit" //
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (action==PUT_ACTION) {
|
if (action==PUT_ACTION) {
|
||||||
if(narg<3)
|
if (cmd=="getbit")
|
||||||
return string("wrong usage: should specify both address and value (hexadecimal fomat) ");
|
return string("Cannot put");
|
||||||
|
|
||||||
|
if(narg<3) {
|
||||||
|
if (cmd=="reg")
|
||||||
|
return string("wrong usage: should specify both address and value (hexadecimal fomat) ");
|
||||||
|
else
|
||||||
|
return string("wrong usage: should specify both address (hexadecimal fomat) and bit number");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (sscanf(args[1],"%x",&addr))
|
if (sscanf(args[1],"%x",&addr))
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
return string("Could not scan address (hexadecimal fomat) ")+string(args[1]);
|
return string("Could not scan address (hexadecimal fomat) ")+string(args[1]);
|
||||||
|
|
||||||
|
|
||||||
if (sscanf(args[2],"%x",&val))
|
if (cmd=="reg") {
|
||||||
;
|
if (sscanf(args[2],"%x",&val))
|
||||||
else
|
;
|
||||||
return string("Could not scan value (hexadecimal fomat) ")+string(args[2]);
|
else
|
||||||
|
return string("Could not scan value (hexadecimal fomat) ")+string(args[2]);
|
||||||
|
sprintf(answer,"%x",myDet->writeRegister(addr,val));
|
||||||
sprintf(answer,"%x",myDet->writeRegister(addr,val));
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
if (narg<2)
|
|
||||||
return string("wrong usage: should specify address (hexadecimal fomat) ");
|
|
||||||
if (sscanf(args[1],"%x",&addr))
|
|
||||||
;
|
|
||||||
else
|
|
||||||
return string("Could not scan address (hexadecimal fomat) ")+string(args[1]);
|
|
||||||
|
|
||||||
|
|
||||||
sprintf(answer,"%x",myDet->readRegister(addr));
|
|
||||||
|
|
||||||
|
if (sscanf(args[2],"%d",&n))
|
||||||
|
;
|
||||||
|
else
|
||||||
|
return string("Could not scan bit number ")+string(args[2]);
|
||||||
|
|
||||||
|
if (n<0 || n>31)
|
||||||
|
return string("Bit number out of range")+string(args[2]);
|
||||||
|
|
||||||
|
if (cmd=="setbit")
|
||||||
|
sprintf(answer,"%x",myDet->writeRegister(addr,myDet->readRegister(addr)| 1<<n));
|
||||||
|
if (cmd=="clearbit")
|
||||||
|
sprintf(answer,"%x",myDet->writeRegister(addr,myDet->readRegister(addr) & ~(1<<n)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (cmd=="setbit")
|
||||||
|
return string("Cannot get");
|
||||||
|
if (cmd=="clearbit")
|
||||||
|
return string("Cannot get");
|
||||||
|
|
||||||
|
if (cmd=="reg") {
|
||||||
|
if (narg<2)
|
||||||
|
return string("wrong usage: should specify address (hexadecimal fomat) ");
|
||||||
|
if (sscanf(args[1],"%x",&addr))
|
||||||
|
;
|
||||||
|
else
|
||||||
|
return string("Could not scan address (hexadecimal fomat) ")+string(args[1]);
|
||||||
|
|
||||||
|
|
||||||
|
sprintf(answer,"%x",myDet->readRegister(addr));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd=="getbit") {
|
||||||
|
|
||||||
|
if(narg<3)
|
||||||
|
return string("wrong usage: should specify both address (hexadecimal fomat) and bit number");
|
||||||
|
|
||||||
|
|
||||||
|
if (sscanf(args[1],"%x",&addr))
|
||||||
|
;
|
||||||
|
else
|
||||||
|
return string("Could not scan address (hexadecimal fomat) ")+string(args[1]);
|
||||||
|
|
||||||
|
if (sscanf(args[2],"%d",&n))
|
||||||
|
;
|
||||||
|
else
|
||||||
|
return string("Could not scan bit number ")+string(args[2]);
|
||||||
|
|
||||||
|
if (n<0 || n>31)
|
||||||
|
return string("Bit number out of range")+string(args[2]);
|
||||||
|
|
||||||
|
|
||||||
|
sprintf(answer,"%d",(myDet->readRegister(addr) >> n) & 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(answer);
|
return string(answer);
|
||||||
@ -3404,9 +3492,9 @@ string slsDetectorCommand::helpTiming(int narg, char *args[], int action){
|
|||||||
|
|
||||||
ostringstream os;
|
ostringstream os;
|
||||||
if (action==GET_ACTION || action==HELP_ACTION)
|
if (action==GET_ACTION || action==HELP_ACTION)
|
||||||
os << string("sync \t gets the synchronization mode of the structure\n");
|
os << string("timing \t gets the timing mode of the detector (auto, trigger, ro_trigger, gating, triggered_gating)\n");
|
||||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
if (action==PUT_ACTION || action==HELP_ACTION)
|
||||||
os << string("sync mode \t sets synchronization mode of the structure. Cane be none, gating, trigger, complementary \n");
|
os << string("timing mode \t sets synchronization mode of the detector. Can be auto, trigger, ro_trigger, gating, triggered_gating \n");
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +178,8 @@ double slsDetectorUsers::setDelayAfterTrigger(double t, bool inseconds){
|
|||||||
return ((1E-9) * (double)myDetector->setDelayAfterTrigger(tms));
|
return ((1E-9) * (double)myDetector->setDelayAfterTrigger(tms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int64_t slsDetectorUsers::setNumberOfGates(int64_t t){
|
int64_t slsDetectorUsers::setNumberOfGates(int64_t t){
|
||||||
return myDetector->setNumberOfGates(t);
|
return myDetector->setNumberOfGates(t);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user