mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-17 09:29:55 +01:00
added trimval function, but sending trimbits from char to int bug
This commit is contained in:
@@ -5719,6 +5719,41 @@ int slsDetector::saveSettingsFile(string fname, int imod) {
|
||||
|
||||
|
||||
|
||||
int slsDetector::setAllTrimbits(int val, int imod){
|
||||
int fnum=F_SET_ALL_TRIMBITS;
|
||||
int retval;
|
||||
char mess[100];
|
||||
int ret=OK;
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Setting all trimbits to "<< val << std::endl;
|
||||
#endif
|
||||
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectControl() == OK){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
controlSocket->SendDataOnly(&val,sizeof(val));
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==FAIL) {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(ALLTIMBITS_NOT_SET));
|
||||
} else {
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
}
|
||||
controlSocket->Disconnect();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "All trimbits were set to "<< retval << std::endl;
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int slsDetector::loadCalibrationFile(string fname, int imod) {
|
||||
|
||||
@@ -510,6 +510,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
int saveSettingsFile(string fname, int imod=-1);
|
||||
|
||||
/** sets all the trimbits to a particular value
|
||||
\param val trimbit value
|
||||
\param imod module number, -1 means all modules
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
int setAllTrimbits(int val, int imod=-1);
|
||||
|
||||
|
||||
/** loads the modules calibration data reading from a file
|
||||
\param fname file name . If not specified, extension is automatically generated!
|
||||
|
||||
@@ -497,6 +497,9 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="trimval"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="pedestal"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
|
||||
@@ -2912,6 +2915,15 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
|
||||
myDet->saveSettingsFile(sval, -1);
|
||||
return string("done");
|
||||
|
||||
} else if (cmd=="trimval") {
|
||||
if (action==PUT_ACTION){
|
||||
if (sscanf(args[1],"%d",&val))
|
||||
myDet->setAllTrimbits(val);
|
||||
else
|
||||
return string("invalid trimbit value ")+cmd;
|
||||
}
|
||||
sprintf(ans,"%d",myDet->setAllTrimbits(-1));
|
||||
return ans;
|
||||
} else if (cmd=="pedestal") {
|
||||
if (action==GET_ACTION)
|
||||
return string("cannot get");
|
||||
@@ -2935,6 +2947,7 @@ string slsDetectorCommand::helpSettings(int narg, char *args[], int action) {
|
||||
os << "threshold eV\n sets the detector threshold in eV"<< std::endl;
|
||||
os << "trimbits fname\n loads the trimfile fname to the detector. If no extension is specified, the serial number of each module will be attached."<< std::endl;
|
||||
os << "trim:mode fname\n trims the detector according to mode (can be noise, beam, improve, fix) and saves the resulting trimbits to file fname."<< std::endl;
|
||||
os << "trimval i \n sets all the trimbits to i" << std::endl;
|
||||
os << "pedestal i \n starts acquisition for i frames, calculates pedestal and writes back to fpga."<< std::endl;
|
||||
|
||||
}
|
||||
@@ -2942,6 +2955,7 @@ string slsDetectorCommand::helpSettings(int narg, char *args[], int action) {
|
||||
os << "settings \n gets the settings of the detector"<< std::endl;
|
||||
os << "threshold V\n gets the detector threshold"<< std::endl;
|
||||
os << "trimbits [fname]\n returns the trimfile loaded on the detector. If fname is specified the trimbits are saved to file. If no extension is specified, the serial number of each module will be attached."<< std::endl;
|
||||
os << "trimval \n returns the value all trimbits are set to. If they are different, returns -1." << std::endl;
|
||||
}
|
||||
return os.str();
|
||||
|
||||
|
||||
@@ -490,6 +490,14 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
*/
|
||||
virtual int saveSettingsFile(string fname, int imod=-1)=0;
|
||||
|
||||
/** sets all the trimbits to a particular value
|
||||
\param val trimbit value
|
||||
\param imod module number, -1 means all modules
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
virtual int setAllTrimbits(int val, int imod=-1)=0;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user