mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-14 08:22:12 +02:00
added auto comp disable feature
This commit is contained in:
parent
c520f10409
commit
5d04067973
@ -50,9 +50,9 @@ using namespace std;
|
||||
#define PREPARE_ACQUISITION 0x0000100000000000ULL
|
||||
#define CLEANUP_ACQUISITION 0x0000080000000000ULL
|
||||
#define REGISER_WRITE_READ 0x0000040000000000ULL
|
||||
// 0xFFFFFFF000000000ULL
|
||||
// 0xFFFFFF0000000000ULL
|
||||
|
||||
// 0x0000000FFFFFFFFFULL
|
||||
// 0x000000FFFFFFFFFFULL
|
||||
#define COULDNOT_SET_NETWORK_PARAMETER 0x0000000000000001ULL
|
||||
#define COULDNOT_SET_ROI 0x0000000000000002ULL
|
||||
#define RECEIVER_READ_FREQUENCY 0x0000000000000004ULL
|
||||
@ -89,7 +89,8 @@ using namespace std;
|
||||
#define RECEIVER_SILENT_MODE_NOT_SET 0x0000000200000000ULL
|
||||
#define RESTREAM_STOP_FROM_RECEIVER 0x0000000400000000ULL
|
||||
#define TEMPERATURE_CONTROL 0x0000000800000000ULL
|
||||
// 0x0000000FFFFFFFFFULL
|
||||
#define AUTO_COMP_DISABLE 0x0000001000000000ULL
|
||||
// 0x000000FFFFFFFFFFULL
|
||||
|
||||
/** @short class returning all error messages for error mask */
|
||||
class errorDefs {
|
||||
@ -280,7 +281,8 @@ public:
|
||||
if(slsErrorMask&TEMPERATURE_CONTROL)
|
||||
retval.append("Could not set/get threshold temperature, temp control or temp event.\n");
|
||||
|
||||
|
||||
if(slsErrorMask&AUTO_COMP_DISABLE)
|
||||
retval.append("Could not set/get auto comparator disable\n");
|
||||
|
||||
//------------------------------------------------------ length of message
|
||||
|
||||
|
@ -116,6 +116,8 @@ enum detFuncs{
|
||||
F_THRESHOLD_TEMP, /** < set threshold temperature */
|
||||
F_TEMP_CONTROL, /** < set temperature control */
|
||||
F_TEMP_EVENT, /** < set temperature event */
|
||||
|
||||
F_AUTO_COMP_DISABLE, /** < auto comp disable mode */
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
/* Always append functions before!!! */
|
||||
|
@ -291,7 +291,7 @@
|
||||
#define VREF_COMP_MOD_REG (0x5C << 11)
|
||||
|
||||
#define VREF_COMP_MOD_OFST (0)
|
||||
#define VREF_COMP_MOD_MSK (0x00000FFF << VREF_COMP_OFST)
|
||||
#define VREF_COMP_MOD_MSK (0x00000FFF << VREF_COMP_MOD_OFST)
|
||||
#define VREF_COMP_MOD_ENABLE_OFST (31)
|
||||
#define VREF_COMP_MOD_ENABLE_MSK (0x00000FFF << VREF_COMP_MOD_ENABLE_OFST)
|
||||
|
||||
|
Binary file not shown.
BIN
slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.1.1
Executable file
BIN
slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.1.1
Executable file
Binary file not shown.
@ -395,6 +395,24 @@ int powerChip (int on){
|
||||
//return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_STATUS_MSK) >> CHIP_POWER_STATUS_OFST);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int autoCompDisable(int on) {
|
||||
if(on != -1){
|
||||
if(on){
|
||||
cprintf(BLUE, "\n*** Auto comp disable mode: enabling ***\n");
|
||||
bus_w(VREF_COMP_MOD_REG, bus_r(VREF_COMP_MOD_REG) | VREF_COMP_MOD_ENABLE_MSK);
|
||||
}
|
||||
else{
|
||||
cprintf(BLUE, "\n*** Auto comp disable mode: disabling *** \n");
|
||||
bus_w(VREF_COMP_MOD_REG, bus_r(VREF_COMP_MOD_REG) & ~VREF_COMP_MOD_ENABLE_MSK);
|
||||
}
|
||||
}
|
||||
|
||||
return (bus_r(VREF_COMP_MOD_REG) & VREF_COMP_MOD_ENABLE_MSK);
|
||||
}
|
||||
|
||||
|
||||
void cleanFifos() {
|
||||
printf("\nClearing Acquisition Fifos\n");
|
||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_ACQ_FIFO_CLR_MSK);
|
||||
@ -879,6 +897,11 @@ void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){
|
||||
DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST);
|
||||
|
||||
dacValues[ind] = dacval;
|
||||
|
||||
if (ind == VREF_COMP) {
|
||||
bus_w (VREF_COMP_MOD_REG, (bus_r(VREF_COMP_MOD_REG) &~ (VREF_COMP_MOD_MSK)) // reset
|
||||
| ((val << VREF_COMP_MOD_OFST) & VREF_COMP_MOD_MSK)); // or it with value
|
||||
}
|
||||
}
|
||||
|
||||
printf("Getting DAC %d : ",ind);
|
||||
|
@ -4595,6 +4595,22 @@ int multiSlsDetector::powerChip(int ival){
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::setAutoComparatorDisableMode(int ival) {
|
||||
int ret=OK, ret1=OK;
|
||||
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
|
||||
if (detectors[i]) {
|
||||
ret=detectors[i]->setAutoComparatorDisableMode(ival);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (ret==FAIL)
|
||||
ret1=FAIL;
|
||||
}
|
||||
}
|
||||
return ret1;
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::loadSettingsFile(string fname, int imod) {
|
||||
int ret=OK;
|
||||
|
||||
|
@ -527,6 +527,12 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
*/
|
||||
int powerChip(int ival= -1);
|
||||
|
||||
/** automatic comparator disable for Jungfrau only
|
||||
\param ival on is 1, off is 0, -1 to get
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
int setAutoComparatorDisableMode(int ival= -1);
|
||||
|
||||
/** loads the modules settings/trimbits reading from a file - file name extension is automatically generated! */
|
||||
int loadSettingsFile(string fname, int nmod=-1);
|
||||
|
||||
|
@ -7513,6 +7513,43 @@ int slsDetector::powerChip(int ival){
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::setAutoComparatorDisableMode(int ival){
|
||||
int ret=FAIL;
|
||||
int fnum=F_AUTO_COMP_DISABLE;
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
int retval=-1;
|
||||
|
||||
if(thisDetector->myDetectorType != JUNGFRAU){
|
||||
std::cout << "Not implemented for this detector" << std::endl;
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Enabling/disabling Auto comp disable mode " << endl;
|
||||
#endif
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectControl() == OK){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
controlSocket->SendDataOnly(&ival,sizeof(ival));
|
||||
//check opening error
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==FAIL) {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(AUTO_COMP_DISABLE));
|
||||
}else
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
disconnectControl();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::loadSettingsFile(string fname, int imod) {
|
||||
|
||||
sls_detector_module *myMod=NULL;
|
||||
|
@ -551,6 +551,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
int powerChip(int ival= -1);
|
||||
|
||||
/** automatic comparator disable for Jungfrau only
|
||||
\param ival on is 1, off is 0, -1 to get
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
int setAutoComparatorDisableMode(int ival= -1);
|
||||
|
||||
|
||||
/** loads the modules settings/trimbits reading from a file
|
||||
\param fname file name . If not specified, extension is automatically generated!
|
||||
|
@ -234,7 +234,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
|
||||
|
||||
|
||||
|
||||
/*! \page config Configuration commands
|
||||
Commands to configure the detector. these commands are often left to the configuration file.
|
||||
- \ref configstructure "Data Structure": commands to configure detector data structure
|
||||
@ -461,6 +460,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
|
||||
++i;
|
||||
|
||||
/*! \page config
|
||||
- <b>auto_comp_disable i </b> this mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). 1 enables mode, 0 disables mode. By default, mode is disabled (comparator is enabled throughout). (JUNGFRAU only). \c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName="auto_comp_disable"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
|
||||
++i;
|
||||
|
||||
/*! \page config
|
||||
- <b>pulse [n] [x] [y]</b> pulses pixel at coordinates (x,y) n number of times. Used in EIGER only. Only put! \c Returns \c ("successful", "unsuccessful")
|
||||
*/
|
||||
@ -5854,7 +5860,9 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
|
||||
}
|
||||
sprintf(ans,"%d",myDet->powerChip());
|
||||
return string(ans);
|
||||
} else if (cmd=="led") {
|
||||
}
|
||||
|
||||
else if (cmd=="led") {
|
||||
char ans[100];
|
||||
int val=0;
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
@ -5868,6 +5876,19 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
|
||||
sprintf(ans,"%d",~(myDet->readRegister(0x4d))&1);
|
||||
return string(ans);
|
||||
}
|
||||
|
||||
else if (cmd=="auto_comp_disable") {
|
||||
char ans[100];
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
if (action==PUT_ACTION){
|
||||
int ival = -1;
|
||||
if (!sscanf(args[1],"%d",&ival))
|
||||
return string("could not scan auto_comp_control parameter " + string(args[1]));
|
||||
myDet->setAutoComparatorDisableMode(ival);
|
||||
}
|
||||
sprintf(ans,"%d",myDet->setAutoComparatorDisableMode());
|
||||
return string(ans);
|
||||
}
|
||||
else
|
||||
return string("unknown command ")+cmd;
|
||||
|
||||
@ -5887,6 +5908,7 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
|
||||
|
||||
os << "led s \t sets led status (0 off, 1 on)" << std::endl;
|
||||
os << "powerchip i \t powers on or off the chip. i = 1 for on, i = 0 for off" << std::endl;
|
||||
os << "auto_comp_disable i \t this mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). 1 enables mode, 0 disables mode. By default, mode is disabled (comparator is enabled throughout). (JUNGFRAU only). " << std::endl;
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION) {
|
||||
|
||||
@ -5896,6 +5918,7 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
|
||||
os << "led \t returns led status (0 off, 1 on)" << std::endl;
|
||||
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl;
|
||||
os << "powerchip \t gets if the chip has been powered on or off" << std::endl;
|
||||
os << "auto_comp_disable \t gets if the automatic comparator diable mode is enabled/disabled" << std::endl;
|
||||
|
||||
}
|
||||
return os.str();
|
||||
|
@ -582,6 +582,12 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
*/
|
||||
virtual int powerChip(int ival= -1)=0;
|
||||
|
||||
/** automatic comparator disable for Jungfrau only
|
||||
\param ival on is 1, off is 0, -1 to get
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
virtual int setAutoComparatorDisableMode(int ival= -1)=0;
|
||||
|
||||
/** saves the modules settings/trimbits writing to a file
|
||||
\param fname file name . Axtension is automatically generated!
|
||||
\param imod module number, -1 means all modules
|
||||
|
@ -69,6 +69,7 @@ uint32_t readRegister(uint32_t offset);
|
||||
// firmware functions (resets)
|
||||
#ifdef JUNGFRAUD
|
||||
int powerChip (int on);
|
||||
int autoCompDisable(int on);
|
||||
void cleanFifos();
|
||||
void resetCore();
|
||||
void resetPeripheral();
|
||||
|
@ -184,6 +184,7 @@ const char* getFunctionName(enum detFuncs func) {
|
||||
case F_THRESHOLD_TEMP: return "F_THRESHOLD_TEMP";
|
||||
case F_TEMP_CONTROL: return "F_TEMP_CONTROL";
|
||||
case F_TEMP_EVENT: return "F_TEMP_EVENT";
|
||||
case F_AUTO_COMP_DISABLE: return "F_AUTO_COMP_DISABLE";
|
||||
|
||||
default: return "Unknown Function";
|
||||
}
|
||||
@ -266,6 +267,7 @@ void function_table() {
|
||||
flist[F_THRESHOLD_TEMP] = &threshold_temp;
|
||||
flist[F_TEMP_CONTROL] = &temp_control;
|
||||
flist[F_TEMP_EVENT] = &temp_event;
|
||||
flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) {
|
||||
@ -4734,7 +4736,7 @@ int power_chip(int file_des) {
|
||||
} else {
|
||||
ret=FAIL;
|
||||
if(setTemperatureEvent(-1) == 1)
|
||||
sprintf(mess,"Powering chip failed due to over-temperature event. Clear event & power chip again.\n", arg, retval);
|
||||
sprintf(mess,"Powering chip failed due to over-temperature event. Clear event & power chip again. Wrote %d, read %d \n", arg, retval);
|
||||
else
|
||||
sprintf(mess,"Powering chip failed, wrote %d but read %d\n", arg, retval);
|
||||
cprintf(RED, "Warning: %s", mess);
|
||||
@ -5086,3 +5088,70 @@ int temp_event(int file_des) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int auto_comp_disable(int file_des) {
|
||||
int ret=OK,ret1=OK;
|
||||
int n=0;
|
||||
int retval=-1;
|
||||
sprintf(mess,"auto comp disable failed\n");
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
//to receive any arguments
|
||||
while (n > 0)
|
||||
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Function (Auto Comp Disable) is not implemented for this detector\n");
|
||||
cprintf(RED, "%s", mess);
|
||||
#else
|
||||
|
||||
// receive arguments
|
||||
int arg=-1;
|
||||
n = receiveData(file_des,&arg,sizeof(arg),INT32);
|
||||
if (n < 0) return printSocketReadError();
|
||||
|
||||
// execute action
|
||||
if (differentClients && lockStatus && arg!=-1) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
cprintf(RED, "Warning: %s", mess);
|
||||
}
|
||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||
else {
|
||||
#ifdef VERBOSE
|
||||
printf("Auto Comp Disable to %d\n", arg);
|
||||
#endif
|
||||
retval=autoCompDisable(arg);
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Auto comp disable set to: %d\n",retval);
|
||||
#endif
|
||||
if (retval==arg || arg<0) {
|
||||
ret=OK;
|
||||
} else {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Atuo Comp Disable failed, wrote %d but read %d\n", arg, retval);
|
||||
cprintf(RED, "Warning: %s", mess);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (ret==OK && differentClients)
|
||||
ret=FORCE_UPDATE;
|
||||
#endif
|
||||
|
||||
// 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,mess,sizeof(mess),OTHER);
|
||||
} else
|
||||
n += sendData(file_des,&retval,sizeof(retval),INT32);
|
||||
|
||||
// return ok / fail
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -91,5 +91,6 @@ int cleanup_acquisition(int);
|
||||
int threshold_temp(int);
|
||||
int temp_control(int);
|
||||
int temp_event(int);
|
||||
int auto_comp_disable(int);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user