deactivate for eiger

This commit is contained in:
Dhanya Maliakal
2016-08-02 10:32:37 +02:00
parent ffaf62176f
commit c0db1a89a8
17 changed files with 306 additions and 4 deletions

View File

@ -1257,6 +1257,48 @@ string slsDetector::checkOnline() {
int slsDetector::activate(int const enable){
int fnum = F_ACTIVATE;
int retval = -1;
int arg = enable;
char mess[1000]="";
int ret = OK;
#ifdef VERBOSE
if(!enable)
std::cout<< "Deactivating Detector" << std::endl;
else if(enable == -1)
std::cout<< "Getting Detector activate mode" << std::endl;
else
std::cout<< "Activating Detector" << 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 (ret==FAIL) {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE));
} else {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
}
disconnectControl();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
#ifdef VERBOSE
if(retval)
std::cout << "Detector Activated" << std::endl;
else
std::cout << "Detector Deactivated" << std::endl;
#endif
return retval;
}
/*
configure the socket communication and check that the server exists
enum communicationProtocol{

View File

@ -318,6 +318,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
string checkOnline();
/** @short activates the detector (detector specific)
\param enable can be: -1 returns wether the detector is in active (1) or inactive (0) state
\returns 0 (inactive) or 1 (active)
*/
int activate(int const enable=GET_ONLINE_FLAG);
/** returns if the detector already existed
\returns 1 if the detector structure has already be initlialized, 0 otherwise */
int exists() {return thisDetector->alreadyExisting;};

View File

@ -394,6 +394,14 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
\returns 0 (offline) or 1 (online)
*/
virtual int setOnline(int const online=-1)=0;
/** @short activates the detector (detector specific)
\param enable can be: -1 returns wether the detector is in active (1) or inactive (0) state
\returns 0 (inactive) or 1 (active)
*/
virtual int activate(int const enable=GET_ONLINE_FLAG)=0;
/**
@short set detector settings
\param isettings settings index (-1 gets)

View File

@ -207,6 +207,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
i++;
descrToFuncMap[i].m_pFuncName="activate"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
i++;
descrToFuncMap[i].m_pFuncName="enablefwrite"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdEnablefwrite;
i++;
@ -2885,6 +2889,17 @@ string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) {
else
strcat(ans," :Not online");
}
else if(cmd=="activate"){
myDet->setOnline(ONLINE_FLAG);
if (action==PUT_ACTION) {
if (!sscanf(args[1],"%d",&ival))
return string("Could not scan activate mode ")+string(args[1]);
/* if(dynamic_cast<slsDetector*>(myDet) != NULL)
return string("Can only set it from the multiDetector mode");*/
myDet->activate(ival);
}
sprintf(ans,"%d",myDet->activate());
}
else if(cmd=="r_online"){
if (action==PUT_ACTION) {
if (sscanf(args[1],"%d",&ival))