mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
temp_threshold, temp_control, temp_event done
This commit is contained in:
@ -2606,6 +2606,135 @@ dacs_t slsDetector::getADC(dacIndex index, int imod){
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
int slsDetector::setThresholdTemperature(int val, int imod) {
|
||||
|
||||
int retval = -1;
|
||||
int fnum = F_THRESHOLD_TEMP;
|
||||
int ret = FAIL;
|
||||
char mess[MAX_STR_LENGTH] = "";
|
||||
|
||||
int arg[2];
|
||||
arg[0]=val;
|
||||
arg[1]=imod;
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< std::endl;
|
||||
std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " << imod << std::endl;
|
||||
#endif
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectStop() == OK){
|
||||
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
stopSocket->SendDataOnly(arg,sizeof(arg));
|
||||
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret!=FAIL) {
|
||||
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Threshold Temperature returned "<< retval << std::endl;
|
||||
#endif
|
||||
} else {
|
||||
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL));
|
||||
}
|
||||
disconnectStop();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsDetector::setTemperatureControl(int val, int imod) {
|
||||
|
||||
int retval = -1;
|
||||
int fnum = F_TEMP_CONTROL;
|
||||
int ret = FAIL;
|
||||
char mess[MAX_STR_LENGTH] = "";
|
||||
|
||||
int arg[2];
|
||||
arg[0]=val;
|
||||
arg[1]=imod;
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< std::endl;
|
||||
std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " << imod << std::endl;
|
||||
#endif
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectStop() == OK){
|
||||
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
stopSocket->SendDataOnly(arg,sizeof(arg));
|
||||
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret!=FAIL) {
|
||||
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Threshold Temperature returned "<< retval << std::endl;
|
||||
#endif
|
||||
} else {
|
||||
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL));
|
||||
}
|
||||
disconnectStop();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int slsDetector::setTemperatureEvent(int val, int imod) {
|
||||
|
||||
int retval = -1;
|
||||
int fnum = F_TEMP_EVENT;
|
||||
int ret = FAIL;
|
||||
char mess[MAX_STR_LENGTH] = "";
|
||||
|
||||
int arg[2];
|
||||
arg[0]=val;
|
||||
arg[1]=imod;
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< std::endl;
|
||||
std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " << imod << std::endl;
|
||||
#endif
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectStop() == OK){
|
||||
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
stopSocket->SendDataOnly(arg,sizeof(arg));
|
||||
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret!=FAIL) {
|
||||
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Threshold Temperature returned "<< retval << std::endl;
|
||||
#endif
|
||||
} else {
|
||||
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL));
|
||||
}
|
||||
disconnectStop();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
configure single channel
|
||||
enum channelRegisterBit {
|
||||
|
@ -916,7 +916,31 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
\returns current ADC value (temperature for eiger and jungfrau in millidegrees)
|
||||
*/
|
||||
dacs_t getADC(dacIndex index, int imod=0);
|
||||
|
||||
/**
|
||||
set/gets threshold temperature (Jungfrau only)
|
||||
\param val value in millidegrees, -1 gets
|
||||
\param imod module number, -1 is all
|
||||
\returns threshold temperature in millidegrees
|
||||
*/
|
||||
int setThresholdTemperature(int val=-1, int imod=-1);
|
||||
|
||||
/**
|
||||
enables/disables temperature control (Jungfrau only)
|
||||
\param val value, -1 gets
|
||||
\param imod module number, -1 is all
|
||||
\returns temperature control enable
|
||||
*/
|
||||
int setTemperatureControl(int val=-1, int imod=-1);
|
||||
|
||||
/**
|
||||
Resets/ gets over-temperature event (Jungfrau only)
|
||||
\param val value, -1 gets
|
||||
\param imod module number, -1 is all
|
||||
\returns over-temperature event
|
||||
*/
|
||||
int setTemperatureEvent(int val=-1, int imod=-1);
|
||||
|
||||
/**
|
||||
configure channel
|
||||
\param reg channel register
|
||||
|
@ -958,6 +958,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
- \ref settingssett "Settings and Threshold": commands to configure settings and threshold of detector
|
||||
- \ref settingsdacs "DACs": commands to configure DACs of detector
|
||||
- \ref settingsadcs "ADCs": commands to readout ADCs of detector
|
||||
- \ref settingstmp "Temp Control": commands to monitor and handle temperature overshoot (only JUNGFRAU)
|
||||
*/
|
||||
|
||||
/* trim/cal directories */
|
||||
@ -1562,6 +1563,33 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
|
||||
|
||||
|
||||
/* temperature control */
|
||||
/*! \page settings
|
||||
\section settingsadcs Temp Control
|
||||
commands to monitor and handle temperature overshoot (only JUNGFRAU)
|
||||
*/
|
||||
|
||||
/*! \page settings
|
||||
- <b>temp_threshold</b> Sets/gets the threshold temperature. JUNGFRAU ONLY. \c Returns \c (double"°C")
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName="temp_threshold"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTempControl;
|
||||
++i;
|
||||
|
||||
/*! \page settings
|
||||
- <b>temp_control</b> Enables/Disables the temperature control. 1 enables, 0 disables. JUNGFRAU ONLY. \c Returns \c int
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName="temp_control"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTempControl;
|
||||
++i;
|
||||
|
||||
/*! \page settings
|
||||
- <b>temp_event</b> Resets/gets over-temperative event. Put only with option 0 to clear event. Gets 1 if temperature went over threshold and control is enabled, else 0. /Disables the temperature control. JUNGFRAU ONLY. \c Returns \c int
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName="temp_event"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTempControl;
|
||||
++i;
|
||||
|
||||
|
||||
/* file name */
|
||||
|
||||
@ -5287,6 +5315,80 @@ string slsDetectorCommand::helpADC(int narg, char *args[], int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string slsDetectorCommand::cmdTempControl(int narg, char *args[], int action) {
|
||||
char answer[1000]="";
|
||||
int val = -1;
|
||||
|
||||
if (action==HELP_ACTION)
|
||||
return helpTempControl(narg, args, action);
|
||||
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
|
||||
if (cmd == "temp_threshold") {
|
||||
if (action==PUT_ACTION) {
|
||||
double fval=0.0;
|
||||
if (!sscanf(args[1],"%lf", &fval))
|
||||
return string("cannot scan temp control value ")+string(args[1]);
|
||||
val = fval * 1000;
|
||||
myDet->setThresholdTemperature(val);
|
||||
}
|
||||
val = myDet->setThresholdTemperature();
|
||||
if (val == -1)
|
||||
sprintf(answer,"%d",val);
|
||||
else
|
||||
sprintf(answer,"%.2f°C", (double)val/1000.000);
|
||||
}
|
||||
|
||||
else if (cmd == "temp_control") {
|
||||
if (action==PUT_ACTION) {
|
||||
if (!sscanf(args[1],"%d", &val))
|
||||
return string("cannot scan temp control value ")+string(args[1]);
|
||||
if ((val!=0) && (val!=1))
|
||||
return string ("temp_control option must be 0 or 1");
|
||||
myDet->setTemperatureControl(val);
|
||||
}
|
||||
sprintf(answer,"%d", myDet->setTemperatureControl());
|
||||
}
|
||||
|
||||
else if (cmd == "temp_event") {
|
||||
if (action==PUT_ACTION) {
|
||||
if (!sscanf(args[1],"%d", &val))
|
||||
return string("cannot scan temp control value ")+string(args[1]);
|
||||
if (val!=0)
|
||||
return string ("temp_event option must be 0 to clear event");
|
||||
myDet->setTemperatureEvent(val);
|
||||
}
|
||||
sprintf(answer,"%d", myDet->setTemperatureEvent());
|
||||
}
|
||||
|
||||
else
|
||||
return string ("cannot scan command " + cmd);
|
||||
|
||||
return string(answer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
string slsDetectorCommand::helpTempControl(int narg, char *args[], int action) {
|
||||
ostringstream os;
|
||||
if (action==PUT_ACTION || action==HELP_ACTION) {
|
||||
os << "temp_threshold t \t sets the threshold temperature. Jungfrau only" << std::endl;
|
||||
os << "temp_control t \t Enables/Disables the temperature control. 1 enables, 0 disables. JUNGFRAU ONLY" << std::endl;
|
||||
os << "temp_event t \t Resets over-temperative event. Put only with option 0 to clear event. JUNGFRAU ONLY." << std::endl;
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION) {
|
||||
os << "temp_threshold \t gets the threshold temperature. Jungfrau only." << std::endl;
|
||||
os << "temp_control \t gets temperature control enable. 1 enabled, 0 disabled. JUNGFRAU ONLY" << std::endl;
|
||||
os << "temp_event \t gets over-temperative event. Gets 1 if temperature went over threshold and control is enabled, else 0. /Disables the temperature control. JUNGFRAU ONLY." << std::endl;
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
string slsDetectorCommand::cmdTiming(int narg, char *args[], int action){
|
||||
#ifdef VERBOSE
|
||||
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
|
||||
|
@ -82,6 +82,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
static string helpImage(int narg, char *args[], int action);
|
||||
static string helpCounter(int narg, char *args[], int action);
|
||||
static string helpADC(int narg, char *args[], int action);
|
||||
static string helpTempControl(int narg, char *args[], int action);
|
||||
static string helpEnablefwrite(int narg, char *args[], int action);
|
||||
static string helpOverwrite(int narg, char *args[], int action);
|
||||
static string helpReceiver(int narg, char *args[], int action);
|
||||
@ -155,6 +156,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
string cmdImage(int narg, char *args[], int action);
|
||||
string cmdCounter(int narg, char *args[], int action);
|
||||
string cmdADC(int narg, char *args[], int action);
|
||||
string cmdTempControl(int narg, char *args[], int action);
|
||||
string cmdEnablefwrite(int narg, char *args[], int action);
|
||||
string cmdOverwrite(int narg, char *args[], int action);
|
||||
string cmdReceiver(int narg, char *args[], int action);
|
||||
|
@ -618,6 +618,30 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
*/
|
||||
virtual dacs_t getADC(dacIndex index, int imod=-1)=0;
|
||||
|
||||
/**
|
||||
set/gets threshold temperature (Jungfrau only)
|
||||
\param val value in millidegrees, -1 gets
|
||||
\param imod module number, -1 is all
|
||||
\returns threshold temperature in millidegrees
|
||||
*/
|
||||
virtual int setThresholdTemperature(int val=-1, int imod=-1)=0;
|
||||
|
||||
/**
|
||||
enables/disables temperature control (Jungfrau only)
|
||||
\param val value, -1 gets
|
||||
\param imod module number, -1 is all
|
||||
\returns temperature control enable
|
||||
*/
|
||||
virtual int setTemperatureControl(int val=-1, int imod=-1)=0;
|
||||
|
||||
/**
|
||||
Resets/ gets over-temperature event (Jungfrau only)
|
||||
\param val value, -1 gets
|
||||
\param imod module number, -1 is all
|
||||
\returns over-temperature event
|
||||
*/
|
||||
virtual int setTemperatureEvent(int val=-1, int imod=-1)=0;
|
||||
|
||||
/**
|
||||
get the maximum size of the detector
|
||||
\param d dimension
|
||||
|
Reference in New Issue
Block a user