temp_threshold, temp_control, temp_event done

This commit is contained in:
Dhanya Maliakal 2018-01-11 15:37:24 +01:00
parent a87687199f
commit 2d6e4c95a2
15 changed files with 725 additions and 6 deletions

View File

@ -88,7 +88,7 @@ using namespace std;
#define RECEIVER_SUBF_TIME_NOT_SET 0x0000000100000000ULL #define RECEIVER_SUBF_TIME_NOT_SET 0x0000000100000000ULL
#define RECEIVER_SILENT_MODE_NOT_SET 0x0000000200000000ULL #define RECEIVER_SILENT_MODE_NOT_SET 0x0000000200000000ULL
#define RESTREAM_STOP_FROM_RECEIVER 0x0000000400000000ULL #define RESTREAM_STOP_FROM_RECEIVER 0x0000000400000000ULL
#define TEMPERATURE_CONTROL 0x0000000800000000ULL
// 0x0000000FFFFFFFFFULL // 0x0000000FFFFFFFFFULL
/** @short class returning all error messages for error mask */ /** @short class returning all error messages for error mask */
@ -277,7 +277,8 @@ public:
if(slsErrorMask&RESTREAM_STOP_FROM_RECEIVER) if(slsErrorMask&RESTREAM_STOP_FROM_RECEIVER)
retval.append("Could not restream stop from receiver.\n"); retval.append("Could not restream stop from receiver.\n");
if(slsErrorMask&TEMPERATURE_CONTROL)
retval.append("Could not set/get threshold temperature, temp control or temp event.\n");

View File

@ -112,6 +112,10 @@ enum detFuncs{
F_ACTIVATE, /** < activate */ F_ACTIVATE, /** < activate */
F_PREPARE_ACQUISITION, /** < prepare acquisition */ F_PREPARE_ACQUISITION, /** < prepare acquisition */
F_CLEANUP_ACQUISITION, /** < clean up after acquisition */ F_CLEANUP_ACQUISITION, /** < clean up after acquisition */
F_THRESHOLD_TEMP, /** < set threshold temperature */
F_TEMP_CONTROL, /** < set temperature control */
F_TEMP_EVENT, /** < set temperature event */
/* Always append functions hereafter!!! */ /* Always append functions hereafter!!! */
/* Always append functions before!!! */ /* Always append functions before!!! */

View File

@ -312,7 +312,7 @@
#define TEMP_CTRL_REG (0x5F << 11) #define TEMP_CTRL_REG (0x5F << 11)
#define TEMP_CTRL_PROTCT_THRSHLD_OFST (0) #define TEMP_CTRL_PROTCT_THRSHLD_OFST (0)
#define TEMP_CTRL_PROTCT_THRSHLD_MSK (0x000007FF << TEMP_CTRL_PRTCT_THRSHLD_OFST) #define TEMP_CTRL_PROTCT_THRSHLD_MSK (0x000007FF << TEMP_CTRL_PROTCT_THRSHLD_OFST)
#define TEMP_CTRL_PROTCT_ENABLE_OFST (16) #define TEMP_CTRL_PROTCT_ENABLE_OFST (16)
#define TEMP_CTRL_PROTCT_ENABLE_MSK (0x00000001 << TEMP_CTRL_PROTCT_ENABLE_OFST) #define TEMP_CTRL_PROTCT_ENABLE_MSK (0x00000001 << TEMP_CTRL_PROTCT_ENABLE_OFST)
#define TEMP_CTRL_OVR_TMP_EVNT_OFST (31) #define TEMP_CTRL_OVR_TMP_EVNT_OFST (31)

View File

@ -1146,13 +1146,67 @@ void configurePll() {
int setThresholdTemperature(int val) {
if (val >= 0) {
printf("\nThreshold Temperature: %d\n", val);
val *= (10.0/625.0);
#ifdef VERBOSE
printf("Converted Threshold Temperature: %d\n", val);
#endif
bus_w(TEMP_CTRL_REG, bus_r(TEMP_CTRL_REG) | (((val << TEMP_CTRL_PROTCT_THRSHLD_OFST) & TEMP_CTRL_PROTCT_THRSHLD_MSK)));
#ifdef VERBOSE
printf("Converted Threshold Temperature set to %d\n", ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_THRSHLD_MSK) >> TEMP_CTRL_PROTCT_THRSHLD_OFST));
#endif
}
uint32_t temp = ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_THRSHLD_MSK) >> TEMP_CTRL_PROTCT_THRSHLD_OFST);
// conversion
temp *= (625.0/10.0);
printf("Threshold Temperature %f °C\n",(double)temp/1000.00);
return temp;
}
int setTemperatureControl(int val) {
if (val >= 0) {
// binary value
if (val > 0 ) val = 1;
printf("\nTemperature control: %d\n", val);
bus_w(TEMP_CTRL_REG, bus_r(TEMP_CTRL_REG) | (((val << TEMP_CTRL_PROTCT_ENABLE_OFST) & TEMP_CTRL_PROTCT_ENABLE_MSK)));
#ifdef VERBOSE
printf("Temperature control set to %d\n", ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_ENABLE_MSK) >> TEMP_CTRL_PROTCT_ENABLE_OFST));
#endif
}
return ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_ENABLE_MSK) >> TEMP_CTRL_PROTCT_ENABLE_OFST);
}
int setTemperatureEvent(int val) {
if (val >= 0) {
// set bit to clear it
val = 1;
printf("\nTemperature Event: %d\n", val);
bus_w(TEMP_CTRL_REG, bus_r(TEMP_CTRL_REG) | (((val << TEMP_CTRL_OVR_TMP_EVNT_OFST) & TEMP_CTRL_OVR_TMP_EVNT_MSK)));
#ifdef VERBOSE
printf("Temperature Event set to %d\n", ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_OVR_TMP_EVNT_MSK) >> TEMP_CTRL_OVR_TMP_EVNT_OFST));
#endif
}
return ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_OVR_TMP_EVNT_MSK) >> TEMP_CTRL_OVR_TMP_EVNT_OFST);
}
int setNetworkParameter(enum NETWORKINDEX mode, int value) { int setNetworkParameter(enum NETWORKINDEX mode, int value) {
if (mode != TXN_FRAME) if (mode != TXN_FRAME)
return -1; return -1;
if (value >= 0) { if (value >= 0) {
printf("\nSetting transmission delay: %d\n", value); printf("\nSetting transmission delay: %d\n", value);
bus_w(CONFIG_REG, ((value << CONFIG_TDMA_TIMESLOT_OFST) & CONFIG_TDMA_TIMESLOT_MSK)); bus_w(CONFIG_REG, bus_r(CONFIG_REG) | (((value << CONFIG_TDMA_TIMESLOT_OFST) & CONFIG_TDMA_TIMESLOT_MSK)));
#ifdef VERBOSE #ifdef VERBOSE
printf("Transmission delay set to %d\n", ((bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK) >> CONFIG_TDMA_TIMESLOT_OFST)); printf("Transmission delay set to %d\n", ((bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK) >> CONFIG_TDMA_TIMESLOT_OFST));
#endif #endif

View File

@ -91,6 +91,7 @@ enum NETWORKINDEX { TXN_FRAME };
#define FIX_PATT_VAL (0xACDC2014) #define FIX_PATT_VAL (0xACDC2014)
#define ADC_PORT_INVERT_VAL (0x453b2a9c) #define ADC_PORT_INVERT_VAL (0x453b2a9c)
#define MAX_TIMESLOT_VAL (0x1F) #define MAX_TIMESLOT_VAL (0x1F)
#define MAX_THRESHOLD_TEMP_VAL (127999) //millidegrees
#define SAMPLE_ADC_HALF_SPEED (SAMPLE_DECMT_FACTOR_2_VAL + SAMPLE_DGTL_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x1000 */ #define SAMPLE_ADC_HALF_SPEED (SAMPLE_DECMT_FACTOR_2_VAL + SAMPLE_DGTL_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x1000 */

View File

@ -3331,6 +3331,173 @@ dacs_t multiSlsDetector::getADC(dacIndex idac, int imod) {
return ret; return ret;
} }
int multiSlsDetector::setThresholdTemperature(int val, int imod) {
int ret = -100;
// single
{
int id=-1, im=-1;
if (decodeNMod(imod, id, im)>=0) {
if(detectors[id]){
ret = detectors[id]->setThresholdTemperature(val, im);
if(detectors[id]->getErrorMask())
setErrorMask(getErrorMask()|(1<<id));
return ret;
}
return -1;
}
}
// multi
if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl;
return -1;
}
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
int* iret[posmax-posmin];
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
iret[idet]= new dacs_t(-1);
Task* task = new Task(new func2_t<int,int,int>(&slsDetector::setThresholdTemperature,
detectors[idet], val, imod, iret[idet]));
threadpool->add_task(task);
}
}
threadpool->startExecuting();
threadpool->wait_for_tasks_to_complete();
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
if(iret[idet] != NULL){
if (ret==-100)
ret=*iret[idet];
else if (ret!=*iret[idet])
ret=-1;
delete iret[idet];
}else ret=-1;
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
}
}
return ret;
}
int multiSlsDetector::setTemperatureControl(int val, int imod) {
int ret = -100;
// single
{
int id=-1, im=-1;
if (decodeNMod(imod, id, im)>=0) {
if(detectors[id]){
ret = detectors[id]->setTemperatureControl(val, im);
if(detectors[id]->getErrorMask())
setErrorMask(getErrorMask()|(1<<id));
return ret;
}
return -1;
}
}
// multi
if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl;
return -1;
}
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
int* iret[posmax-posmin];
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
iret[idet]= new dacs_t(-1);
Task* task = new Task(new func2_t<int,int,int>(&slsDetector::setTemperatureControl,
detectors[idet], val, imod, iret[idet]));
threadpool->add_task(task);
}
}
threadpool->startExecuting();
threadpool->wait_for_tasks_to_complete();
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
if(iret[idet] != NULL){
if (ret==-100)
ret=*iret[idet];
else if (ret!=*iret[idet])
ret=-1;
delete iret[idet];
}else ret=-1;
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
}
}
return ret;
}
int multiSlsDetector::setTemperatureEvent(int val, int imod) {
int ret = -100;
// single
{
int id=-1, im=-1;
if (decodeNMod(imod, id, im)>=0) {
if(detectors[id]){
ret = detectors[id]->setTemperatureEvent(val, im);
if(detectors[id]->getErrorMask())
setErrorMask(getErrorMask()|(1<<id));
return ret;
}
return -1;
}
}
// multi
if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl;
return -1;
}
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
int* iret[posmax-posmin];
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
iret[idet]= new dacs_t(-1);
Task* task = new Task(new func2_t<int,int,int>(&slsDetector::setTemperatureEvent,
detectors[idet], val, imod, iret[idet]));
threadpool->add_task(task);
}
}
threadpool->startExecuting();
threadpool->wait_for_tasks_to_complete();
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
if(iret[idet] != NULL){
if (ret==-100)
ret=*iret[idet];
else if (ret!=*iret[idet])
ret=-1;
delete iret[idet];
}else ret=-1;
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
}
}
return ret;
}
int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) { int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) {
int ret, ret1=-100; int ret, ret1=-100;
int id=-1, im=-1; int id=-1, im=-1;

View File

@ -948,6 +948,31 @@ class multiSlsDetector : public slsDetectorUtils {
\returns current DAC value (temperature for eiger and jungfrau in millidegrees) \returns current DAC value (temperature for eiger and jungfrau in millidegrees)
*/ */
dacs_t getADC(dacIndex index, int imod=-1); dacs_t getADC(dacIndex index, int imod=-1);
/**
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 configure channel
\param reg channel register \param reg channel register

View File

@ -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 configure single channel
enum channelRegisterBit { enum channelRegisterBit {

View File

@ -917,6 +917,30 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/ */
dacs_t getADC(dacIndex index, int imod=0); 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 configure channel
\param reg channel register \param reg channel register

View File

@ -958,6 +958,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
- \ref settingssett "Settings and Threshold": commands to configure settings and threshold of detector - \ref settingssett "Settings and Threshold": commands to configure settings and threshold of detector
- \ref settingsdacs "DACs": commands to configure DACs of detector - \ref settingsdacs "DACs": commands to configure DACs of detector
- \ref settingsadcs "ADCs": commands to readout ADCs 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 */ /* 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 */ /* file name */
@ -5287,6 +5315,80 @@ string slsDetectorCommand::helpADC(int narg, char *args[], int action) {
return os.str(); 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){ string slsDetectorCommand::cmdTiming(int narg, char *args[], int action){
#ifdef VERBOSE #ifdef VERBOSE
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");

View File

@ -82,6 +82,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
static string helpImage(int narg, char *args[], int action); static string helpImage(int narg, char *args[], int action);
static string helpCounter(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 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 helpEnablefwrite(int narg, char *args[], int action);
static string helpOverwrite(int narg, char *args[], int action); static string helpOverwrite(int narg, char *args[], int action);
static string helpReceiver(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 cmdImage(int narg, char *args[], int action);
string cmdCounter(int narg, char *args[], int action); string cmdCounter(int narg, char *args[], int action);
string cmdADC(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 cmdEnablefwrite(int narg, char *args[], int action);
string cmdOverwrite(int narg, char *args[], int action); string cmdOverwrite(int narg, char *args[], int action);
string cmdReceiver(int narg, char *args[], int action); string cmdReceiver(int narg, char *args[], int action);

View File

@ -618,6 +618,30 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/ */
virtual dacs_t getADC(dacIndex index, int imod=-1)=0; 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 get the maximum size of the detector
\param d dimension \param d dimension

View File

@ -169,6 +169,9 @@ int calibratePedestal(int frames);
void resetPLL(); void resetPLL();
u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val); u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val);
void configurePll(); void configurePll();
int setThresholdTemperature(int val);
int setTemperatureControl(int val);
int setTemperatureEvent(int val);
extern void eraseFlash(); // programfpga.h extern void eraseFlash(); // programfpga.h
extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h
extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h

View File

@ -181,6 +181,10 @@ const char* getFunctionName(enum detFuncs func) {
case F_ACTIVATE: return "F_ACTIVATE"; case F_ACTIVATE: return "F_ACTIVATE";
case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION"; case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION";
case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION"; case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION";
case F_THRESHOLD_TEMP: return "F_THRESHOLD_TEMP";
case F_TEMP_CONTROL: return "F_TEMP_CONTROL";
case F_TEMP_EVENT: return "F_TEMP_EVENT";
default: return "Unknown Function"; default: return "Unknown Function";
} }
} }
@ -259,6 +263,9 @@ void function_table() {
flist[F_ACTIVATE] = &set_activate; flist[F_ACTIVATE] = &set_activate;
flist[F_PREPARE_ACQUISITION] = &prepare_acquisition; flist[F_PREPARE_ACQUISITION] = &prepare_acquisition;
flist[F_CLEANUP_ACQUISITION] = &cleanup_acquisition; flist[F_CLEANUP_ACQUISITION] = &cleanup_acquisition;
flist[F_THRESHOLD_TEMP] = &threshold_temp;
flist[F_TEMP_CONTROL] = &temp_control;
flist[F_TEMP_EVENT] = &temp_event;
// check // check
if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) { if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) {
@ -4454,7 +4461,7 @@ int set_network_parameter(int file_des) {
#ifdef JUNGFRAUD #ifdef JUNGFRAUD
if (value > MAX_TIMESLOT_VAL) { if (value > MAX_TIMESLOT_VAL) {
ret=FAIL; ret=FAIL;
sprintf(mess,"Transmission delay %d should be in range: 0 - 31\n", value); sprintf(mess,"Transmission delay %d should be in range: 0 - %d\n", value, MAX_TIMESLOT_VAL);
cprintf(RED, "Warning: %s", mess); cprintf(RED, "Warning: %s", mess);
} }
#endif #endif
@ -4902,3 +4909,177 @@ int cleanup_acquisition(int file_des) {
} }
int threshold_temp(int file_des) {
int ret=OK,ret1=OK;
int n=0;
int arg[2]={-1,-1};
int val=-1;
int retval=-1;
sprintf(mess,"could not set/get threshold temperature\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Threshold Temp) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
// receive arguments
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
val=arg[0];
//ignoring imod
if (val > MAX_THRESHOLD_TEMP_VAL) {
ret=FAIL;
sprintf(mess,"Threshold Temp %d should be in range: 0 - %d\n", val, MAX_THRESHOLD_TEMP_VAL);
cprintf(RED, "Warning: %s", mess);
}
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
#ifdef VERBOSE
printf("Setting Threshold Temperature to %d\n", val);
#endif
retval=setThresholdTemperature(val);
}
#endif
#ifdef VERBOSE
printf("Threshold temperature is %d\n", retval);
#endif
if (ret==OK && differentClients && val >= 0)
ret=FORCE_UPDATE;
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret!=FAIL) {
n += sendData(file_des,&retval,sizeof(retval),INT32);
} else {
n += sendData(file_des,mess,sizeof(mess),OTHER);
}
// return ok / fail
return ret;
}
int temp_control(int file_des) {
int ret=OK,ret1=OK;
int n=0;
int arg[2]={-1,-1};
int val=-1;
int retval=-1;
sprintf(mess,"could not set/get temperature control\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Temperature control) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
// receive arguments
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
val=arg[0];
//ignoring imod
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
#ifdef VERBOSE
printf("Setting Temperature control to %d\n", val);
#endif
retval=setTemperatureControl(val);
}
#endif
#ifdef VERBOSE
printf("Temperature control is %d\n", retval);
#endif
if (ret==OK && differentClients && val >= 0)
ret=FORCE_UPDATE;
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret!=FAIL) {
n += sendData(file_des,&retval,sizeof(retval),INT32);
} else {
n += sendData(file_des,mess,sizeof(mess),OTHER);
}
// return ok / fail
return ret;
}
int temp_event(int file_des) {
int ret=OK,ret1=OK;
int n=0;
int arg[2]={-1,-1};
int val=-1;
int retval=-1;
sprintf(mess,"could not set/get temperature event\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Temperature Event) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
// receive arguments
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
val=arg[0];
//ignoring imod
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
#ifdef VERBOSE
printf("Setting Temperature Event to %d\n", val);
#endif
retval=setTemperatureEvent(val);
}
#endif
#ifdef VERBOSE
printf("Temperature Event is %d\n", retval);
#endif
if (ret==OK && differentClients && val >= 0)
ret=FORCE_UPDATE;
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret!=FAIL) {
n += sendData(file_des,&retval,sizeof(retval),INT32);
} else {
n += sendData(file_des,mess,sizeof(mess),OTHER);
}
// return ok / fail
return ret;
}

View File

@ -88,6 +88,8 @@ int power_chip(int);
int set_activate(int); int set_activate(int);
int prepare_acquisition(int); int prepare_acquisition(int);
int cleanup_acquisition(int); int cleanup_acquisition(int);
int threshold_temp(int);
int temp_control(int);
int temp_event(int);
#endif #endif