mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 16:20:03 +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:
parent
1ac2c6d09b
commit
1673da0854
@ -1912,19 +1912,22 @@ int slsDetector::readRegister(int addr){
|
||||
std::cout<< "Reading register "<< hex<<addr << std::endl;
|
||||
#endif
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectControl() == OK){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
controlSocket->SendDataOnly(&arg,sizeof(arg));
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
// if (connectControl() == OK){
|
||||
if (stopSocket) {
|
||||
if (stopSocket->Connect()>=0) {
|
||||
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
stopSocket->SendDataOnly(&arg,sizeof(arg));
|
||||
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret!=FAIL)
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
else {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
}
|
||||
controlSocket->Disconnect();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
stopSocket->Disconnect();
|
||||
// if (ret==FORCE_UPDATE)
|
||||
// updateDetector();
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
|
@ -48,6 +48,7 @@
|
||||
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
#include "slsDetectorUsers.h"
|
||||
#include "error_defs.h"
|
||||
|
||||
#include <string>
|
||||
@ -392,8 +393,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
||||
\returns current external communication mode
|
||||
*/
|
||||
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;
|
||||
int setThresholdEnergy(int e_eV){return setThresholdEnergy(e_eV,-1);};
|
||||
|
@ -455,6 +455,27 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRegister;
|
||||
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 */
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="settings"; //
|
||||
@ -3029,38 +3050,105 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) {
|
||||
if (action==HELP_ACTION)
|
||||
return helpRegister(narg, args, action);
|
||||
|
||||
int addr, val;
|
||||
int addr, val,n;
|
||||
char answer[1000];
|
||||
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
|
||||
|
||||
// "reg" //
|
||||
|
||||
// "setbit" //
|
||||
|
||||
// "clearbit" //
|
||||
|
||||
// "getbit" //
|
||||
|
||||
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
if(narg<3)
|
||||
return string("wrong usage: should specify both address and value (hexadecimal fomat) ");
|
||||
if (cmd=="getbit")
|
||||
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))
|
||||
;
|
||||
else
|
||||
return string("Could not scan address (hexadecimal fomat) ")+string(args[1]);
|
||||
|
||||
if (sscanf(args[2],"%x",&val))
|
||||
;
|
||||
else
|
||||
return string("Could not scan value (hexadecimal fomat) ")+string(args[2]);
|
||||
|
||||
if (cmd=="reg") {
|
||||
if (sscanf(args[2],"%x",&val))
|
||||
;
|
||||
else
|
||||
return string("Could not scan value (hexadecimal fomat) ")+string(args[2]);
|
||||
sprintf(answer,"%x",myDet->writeRegister(addr,val));
|
||||
} else {
|
||||
|
||||
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)));
|
||||
|
||||
}
|
||||
|
||||
sprintf(answer,"%x",myDet->writeRegister(addr,val));
|
||||
|
||||
} 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]);
|
||||
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));
|
||||
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);
|
||||
@ -3404,9 +3492,9 @@ string slsDetectorCommand::helpTiming(int narg, char *args[], int action){
|
||||
|
||||
ostringstream os;
|
||||
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)
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -178,6 +178,8 @@ double slsDetectorUsers::setDelayAfterTrigger(double t, bool inseconds){
|
||||
return ((1E-9) * (double)myDetector->setDelayAfterTrigger(tms));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int64_t slsDetectorUsers::setNumberOfGates(int64_t t){
|
||||
return myDetector->setNumberOfGates(t);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user