mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
read/write of config/parameter file rewritten so that parameter file can take in slsdetector level commands
This commit is contained in:
@ -2407,254 +2407,126 @@ int slsDetector::updateDetector() {
|
||||
|
||||
|
||||
int slsDetector::readConfigurationFile(string const fname) {
|
||||
|
||||
|
||||
|
||||
string ans;
|
||||
string str;
|
||||
ifstream infile;
|
||||
//char *args[1000];
|
||||
|
||||
string sargname, sargval;
|
||||
#ifdef VERBOSE
|
||||
int iline=0;
|
||||
std::cout<< "config file name "<< fname << std::endl;
|
||||
#endif
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
#ifdef VERBOSE
|
||||
iline=readConfigurationFile(infile);
|
||||
#else
|
||||
readConfigurationFile(infile);
|
||||
#endif
|
||||
infile.close();
|
||||
} else {
|
||||
std::cout<< "Error opening configuration file " << fname <<
|
||||
" for reading" << std::endl;
|
||||
setErrorMask((getErrorMask())|(CONFIG_FILE));
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Read configuration file of " << iline << " lines" << std::endl;
|
||||
#endif
|
||||
return OK;
|
||||
|
||||
std::cout << "Cannot read config file from slsDetector level" << std::endl;
|
||||
setErrorMask((getErrorMask())|(CONFIG_FILE));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::readConfigurationFile(ifstream &infile) {
|
||||
|
||||
|
||||
|
||||
|
||||
slsDetectorCommand *cmd=new slsDetectorCommand(this);
|
||||
|
||||
string ans;
|
||||
string str;
|
||||
int iargval;
|
||||
int interrupt=0;
|
||||
char *args[100];
|
||||
char myargs[1000][1000];
|
||||
|
||||
string sargname, sargval;
|
||||
int iline=0;
|
||||
while (infile.good() and interrupt==0) {
|
||||
sargname="none";
|
||||
sargval="0";
|
||||
getline(infile,str);
|
||||
++iline;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< str << std::endl;
|
||||
#endif
|
||||
if (str.find('#')!=string::npos) {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Line is a comment " << std::endl;
|
||||
std::cout<< str << std::endl;
|
||||
#endif
|
||||
continue;
|
||||
} else if (str.length()<2) {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Empty line " << std::endl;
|
||||
#endif
|
||||
continue;
|
||||
} else {
|
||||
istringstream ssstr(str);
|
||||
iargval=0;
|
||||
while (ssstr.good()) {
|
||||
ssstr >> sargname;
|
||||
//if (ssstr.good()) {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< iargval << " " << sargname << std::endl;
|
||||
#endif
|
||||
strcpy(myargs[iargval],sargname.c_str());
|
||||
args[iargval]=myargs[iargval];
|
||||
++iargval;
|
||||
//}
|
||||
}
|
||||
ans=cmd->executeLine(iargval,args,PUT_ACTION);
|
||||
#ifdef VERBOSE
|
||||
std::cout<< ans << std::endl;
|
||||
#endif
|
||||
}
|
||||
++iline;
|
||||
}
|
||||
delete cmd;
|
||||
return OK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int slsDetector::writeConfigurationFile(string const fname) {
|
||||
|
||||
ofstream outfile;
|
||||
#ifdef VERBOSE
|
||||
int ret;
|
||||
#endif
|
||||
outfile.open(fname.c_str(),ios_base::out);
|
||||
if (outfile.is_open()) {
|
||||
#ifdef VERBOSE
|
||||
ret=writeConfigurationFile(outfile);
|
||||
#else
|
||||
writeConfigurationFile(outfile);
|
||||
#endif
|
||||
outfile.close();
|
||||
}
|
||||
else {
|
||||
std::cout<< "Error opening configuration file " << fname <<
|
||||
" for writing" << std::endl;
|
||||
setErrorMask((getErrorMask())|(CONFIG_FILE));
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "wrote " <<ret << " lines to configuration file " << std::endl;
|
||||
#endif
|
||||
return OK;
|
||||
|
||||
|
||||
std::cout << "Cannot write config file from slsDetector level" << std::endl;
|
||||
setErrorMask((getErrorMask())|(CONFIG_FILE));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::writeConfigurationFile(ofstream &outfile, int id) {
|
||||
;
|
||||
slsDetectorCommand *cmd=new slsDetectorCommand(this);
|
||||
detectorType type = thisDetector->myDetectorType;
|
||||
string names[100];
|
||||
int nvar=0;
|
||||
|
||||
std::vector <std::string> commands;
|
||||
// common config
|
||||
names[nvar++] = "hostname";
|
||||
names[nvar++] = "port";
|
||||
names[nvar++] = "stopport";
|
||||
names[nvar++] = "settingsdir";
|
||||
names[nvar++] = "caldir";
|
||||
names[nvar++] = "ffdir";
|
||||
names[nvar++] = "outdir";
|
||||
names[nvar++] = "angdir";
|
||||
names[nvar++] = "moveflag";
|
||||
names[nvar++] = "lock";
|
||||
commands.push_back("port");
|
||||
commands.push_back("stopport");
|
||||
commands.push_back("settingsdir");
|
||||
commands.push_back("caldir");
|
||||
commands.push_back("ffdir");
|
||||
commands.push_back("outdir");
|
||||
commands.push_back("angdir");
|
||||
commands.push_back("moveflag");
|
||||
commands.push_back("lock");
|
||||
|
||||
// receiver config
|
||||
if (type != MYTHEN) {
|
||||
names[nvar++] = "detectormac";
|
||||
names[nvar++] = "detectorip";
|
||||
names[nvar++] = "zmqport";
|
||||
names[nvar++] = "rx_zmqport";
|
||||
names[nvar++] = "zmqip";
|
||||
names[nvar++] = "rx_zmqip";
|
||||
names[nvar++] = "rx_tcpport";
|
||||
names[nvar++] = "rx_udpport";
|
||||
names[nvar++] = "rx_udpport2";
|
||||
names[nvar++] = "rx_udpip";
|
||||
names[nvar++] = "rx_hostname";
|
||||
names[nvar++] = "r_readfreq";
|
||||
if (thisDetector->myDetectorType != MYTHEN) {
|
||||
commands.push_back("detectormac");
|
||||
commands.push_back("detectorip");
|
||||
commands.push_back("zmqport");
|
||||
commands.push_back("rx_zmqport");
|
||||
commands.push_back("zmqip");
|
||||
commands.push_back("rx_zmqip");
|
||||
commands.push_back("rx_tcpport");
|
||||
commands.push_back("rx_udpport");
|
||||
commands.push_back("rx_udpport2");
|
||||
commands.push_back("rx_udpip");
|
||||
commands.push_back("rx_hostname");
|
||||
commands.push_back("r_readfreq");
|
||||
}
|
||||
|
||||
// detector specific config
|
||||
switch (type) {
|
||||
switch (thisDetector->myDetectorType) {
|
||||
case MYTHEN:
|
||||
names[nvar++] = "nmod";
|
||||
names[nvar++] = "waitstates";
|
||||
names[nvar++] = "setlength";
|
||||
names[nvar++] = "clkdivider";
|
||||
names[nvar++] = "extsig";
|
||||
commands.push_back("waitstates");
|
||||
commands.push_back("setlength");
|
||||
commands.push_back("clkdivider");
|
||||
commands.push_back("extsig");
|
||||
break;
|
||||
case GOTTHARD:
|
||||
case PROPIX:
|
||||
names[nvar++] = "extsig";
|
||||
names[nvar++] = "vhighvoltage";
|
||||
break;
|
||||
break;
|
||||
case MOENCH:
|
||||
names[nvar++] = "extsig";
|
||||
names[nvar++] = "vhighvoltage";
|
||||
commands.push_back("vhighvoltage");
|
||||
break;
|
||||
case EIGER:
|
||||
names[nvar++] = "vhighvoltage";
|
||||
names[nvar++] = "trimen";
|
||||
names[nvar++] = "iodelay";
|
||||
names[nvar++] = "tengiga";
|
||||
commands.push_back("vhighvoltage");
|
||||
commands.push_back("trimen");
|
||||
commands.push_back("iodelay");
|
||||
commands.push_back("tengiga");
|
||||
break;
|
||||
case JUNGFRAU:
|
||||
names[nvar++] = "powerchip";
|
||||
names[nvar++] = "vhighvoltage";
|
||||
break;
|
||||
case JUNGFRAUCTB:
|
||||
names[nvar++] = "powerchip";
|
||||
names[nvar++] = "vhighvoltage";
|
||||
commands.push_back("powerchip");
|
||||
commands.push_back("vhighvoltage");
|
||||
break;
|
||||
default:
|
||||
std::cout << "detector type " <<
|
||||
getDetectorType(thisDetector->myDetectorType) << " not implemented in "
|
||||
"writing config file" << std::endl;
|
||||
nvar = 0;
|
||||
break;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int nsig=4;
|
||||
int iv=0;
|
||||
char *args[100];
|
||||
char myargs[100][1000];
|
||||
|
||||
for (int ia=0; ia<100; ++ia) {
|
||||
args[ia]=myargs[ia];
|
||||
}
|
||||
|
||||
|
||||
for (iv=0; iv<nvar; ++iv) {
|
||||
cout << iv << " " << names[iv] << endl;
|
||||
if (names[iv]=="extsig") {
|
||||
for (int is=0; is<nsig; ++is) {
|
||||
sprintf(args[0],"%s:%d",names[iv].c_str(),is);
|
||||
|
||||
if (id>=0)
|
||||
slsDetectorCommand *cmd = new slsDetectorCommand(this);
|
||||
char* args[2];
|
||||
args[0] = new char[MAX_STR_LENGTH];
|
||||
for (unsigned int i = 0; i < commands.size(); ++i) {
|
||||
if (commands[i] == "extsig") {
|
||||
for (int is = 0; is < 4; ++is) {
|
||||
if (id >= 0) {
|
||||
outfile << id << ":";
|
||||
|
||||
outfile << args[0] << " " << cmd->executeLine(1,args,GET_ACTION)
|
||||
<< std::endl;
|
||||
}
|
||||
memset(args[0], 0, MAX_STR_LENGTH);
|
||||
sprintf(args[0],"extsig:%d", is);
|
||||
outfile << args[0] << " " << cmd->executeLine(1, args, GET_ACTION) << std::endl;
|
||||
}
|
||||
} else {
|
||||
strcpy(args[0],names[iv].c_str());
|
||||
if (id>=0)
|
||||
if (id >= 0) {
|
||||
outfile << id << ":";
|
||||
outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION)
|
||||
<< std::endl;
|
||||
}
|
||||
memset(args[0], 0, MAX_STR_LENGTH);
|
||||
strcpy(args[0], commands[i].c_str());
|
||||
outfile << commands[i] << " " << cmd->executeLine(1, args, GET_ACTION) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
delete cmd;
|
||||
delete args[0];
|
||||
delete cmd;
|
||||
|
||||
if (getErrorMask()) {
|
||||
int c = 0;
|
||||
cprintf(RED, "\n----------------\n Error Messages\n----------------\n%s\n",
|
||||
getErrorMessage(c).c_str());
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int slsDetector::retrieveDetectorSetup(std::string const fname, int level) {
|
||||
std::cout << "Cannot read parameter file from slsDetector level" << std::endl;
|
||||
setErrorMask((getErrorMask())|(CONFIG_FILE));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int slsDetector::dumpDetectorSetup(std::string const fname, int level) {
|
||||
std::cout << "Cannot write parameter file from slsDetector level" << std::endl;
|
||||
setErrorMask((getErrorMask())|(CONFIG_FILE));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
string slsDetector::getSettingsFile() {
|
||||
|
@ -852,20 +852,11 @@ public:
|
||||
int updateDetector();
|
||||
|
||||
/**
|
||||
* Load configuration from a configuration File
|
||||
* calls readConfigurationFile and gives it the stream
|
||||
* @param fname configuration file name
|
||||
* @return OK or FAIL
|
||||
* should not be called at this level
|
||||
* @return FAIL
|
||||
*/
|
||||
int readConfigurationFile(std::string const fname);
|
||||
|
||||
/**
|
||||
* Load configuration from a stream
|
||||
* @param infile stream
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int readConfigurationFile(std::ifstream &infile);
|
||||
|
||||
/**
|
||||
* Write current configuration to a file
|
||||
* calls writeConfigurationFile giving it a stream to write to
|
||||
@ -882,6 +873,26 @@ public:
|
||||
*/
|
||||
int writeConfigurationFile(std::ofstream &outfile, int id=-1);
|
||||
|
||||
/**
|
||||
* Loads the detector setup from file
|
||||
* @param fname file to read from
|
||||
* @param level if 2 reads also reads trimbits, angular
|
||||
* conversion coefficients etc. from files with default
|
||||
* extensions as generated by dumpDetectorSetup
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int retrieveDetectorSetup(std::string const fname, int level=0);
|
||||
|
||||
/**
|
||||
* Saves the detector setup to file
|
||||
* @param fname file to write to
|
||||
* @param level if 2 reads also trimbits, flat field, angular
|
||||
* correction etc. and writes them to files with automatically
|
||||
* added extension
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int dumpDetectorSetup(std::string const fname, int level=0);
|
||||
|
||||
/**
|
||||
* Returns the trimfile or settings file name (Useless??)
|
||||
* @returns the trimfile or settings file name
|
||||
|
@ -540,10 +540,8 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
||||
*/
|
||||
virtual int readConfigurationFile(std::string const fname)=0;
|
||||
|
||||
virtual int dumpDetectorSetup(std::string const fname, int level)=0;
|
||||
int dumpDetectorSetup(std::string const fname){return dumpDetectorSetup(fname,0);};
|
||||
virtual int retrieveDetectorSetup(std::string const fname, int level)=0;
|
||||
int retrieveDetectorSetup(std::string const fname){return retrieveDetectorSetup(fname,0);};
|
||||
virtual int dumpDetectorSetup(std::string const fname, int level = 0)=0;
|
||||
virtual int retrieveDetectorSetup(std::string const fname, int level = 0)=0;
|
||||
/**
|
||||
@short
|
||||
\returns the default output file index
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <sys/shm.h>
|
||||
#include <time.h> //clock()
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
using namespace std;
|
||||
|
||||
slsDetectorUtils::slsDetectorUtils() {
|
||||
@ -638,316 +639,5 @@ void slsDetectorUtils::setCurrentProgress(int i){
|
||||
}
|
||||
|
||||
|
||||
int slsDetectorUtils::retrieveDetectorSetup(string const fname1, int level){
|
||||
|
||||
|
||||
|
||||
slsDetectorCommand *cmd;
|
||||
|
||||
|
||||
// char ext[100];
|
||||
int skip=0;
|
||||
string fname;
|
||||
string str;
|
||||
ifstream infile;
|
||||
int iargval;
|
||||
int interrupt=0;
|
||||
char *args[10];
|
||||
|
||||
char myargs[10][1000];
|
||||
|
||||
//args[0]=myargs[0];
|
||||
//args[1]=myargs[1];
|
||||
|
||||
string sargname, sargval;
|
||||
int iline=0;
|
||||
|
||||
if (level==2) {
|
||||
// fname=fname1+string(".config");
|
||||
// readConfigurationFile(fname);
|
||||
#ifdef VERBOSE
|
||||
cout << "config file read" << endl;
|
||||
#endif
|
||||
fname=fname1+string(".det");
|
||||
} else
|
||||
fname=fname1;
|
||||
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
cmd=new slsDetectorCommand(this);
|
||||
while (infile.good() and interrupt==0) {
|
||||
sargname="none";
|
||||
sargval="0";
|
||||
getline(infile,str);
|
||||
iline++;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< str << std::endl;
|
||||
#endif
|
||||
if (str.find('#')!=string::npos) {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Line is a comment " << std::endl;
|
||||
std::cout<< str << std::endl;
|
||||
#endif
|
||||
continue;
|
||||
} else {
|
||||
istringstream ssstr(str);
|
||||
iargval=0;
|
||||
while (ssstr.good()) {
|
||||
ssstr >> sargname;
|
||||
// if (ssstr.good()) {
|
||||
strcpy(myargs[iargval],sargname.c_str());
|
||||
args[iargval]=myargs[iargval];
|
||||
#ifdef VERBOSE
|
||||
std::cout<< args[iargval] << std::endl;
|
||||
#endif
|
||||
iargval++;
|
||||
// }
|
||||
skip=0;
|
||||
}
|
||||
|
||||
if (level!=2) {
|
||||
if (string(args[0])==string("flatfield"))
|
||||
skip=1;
|
||||
else if (string(args[0])==string("badchannels"))
|
||||
skip=1;
|
||||
else if (string(args[0])==string("trimbits"))
|
||||
skip=1;
|
||||
}
|
||||
if (skip==0)
|
||||
cmd->executeLine(iargval,args,PUT_ACTION);
|
||||
}
|
||||
iline++;
|
||||
}
|
||||
delete cmd;
|
||||
infile.close();
|
||||
|
||||
} else {
|
||||
std::cout<< "Error opening " << fname << " for reading" << std::endl;
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Read " << iline << " lines" << std::endl;
|
||||
#endif
|
||||
|
||||
if (getErrorMask())
|
||||
return FAIL;
|
||||
|
||||
return OK;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
||||
|
||||
slsDetectorCommand *cmd;
|
||||
detectorType type = getDetectorsType();
|
||||
string names[100];
|
||||
int nvar=0;
|
||||
|
||||
// common config
|
||||
names[nvar++]="fname";
|
||||
names[nvar++]="index";
|
||||
names[nvar++]="enablefwrite";
|
||||
names[nvar++]="overwrite";
|
||||
names[nvar++]="dr";
|
||||
names[nvar++]="settings";
|
||||
names[nvar++]="exptime";
|
||||
names[nvar++]="period";
|
||||
names[nvar++]="frames";
|
||||
names[nvar++]="cycles";
|
||||
names[nvar++]="measurements";
|
||||
names[nvar++]="timing";
|
||||
names[nvar++]="flatfield";
|
||||
names[nvar++]="badchannels";
|
||||
|
||||
switch (type) {
|
||||
case EIGER:
|
||||
names[nvar++]="flags";
|
||||
names[nvar++]="clkdivider";
|
||||
names[nvar++]="threshold";
|
||||
names[nvar++]="ratecorr";
|
||||
names[nvar++]="trimbits";
|
||||
break;
|
||||
case GOTTHARD:
|
||||
case PROPIX:
|
||||
names[nvar++]="flags";
|
||||
names[nvar++]="delay";
|
||||
names[nvar++]="gates";
|
||||
names[nvar++]="ratecorr";
|
||||
break;
|
||||
case JUNGFRAU:
|
||||
names[nvar++]="flags";
|
||||
names[nvar++]="delay";
|
||||
names[nvar++]="gates";
|
||||
names[nvar++]="ratecorr";
|
||||
names[nvar++]="clkdivider";
|
||||
break;
|
||||
case MYTHEN:
|
||||
names[nvar++]="flags";
|
||||
names[nvar++]="threshold";
|
||||
names[nvar++]="delay";
|
||||
names[nvar++]="gates";
|
||||
names[nvar++]="probes";
|
||||
names[nvar++]="fineoff";
|
||||
names[nvar++]="ratecorr";
|
||||
names[nvar++]="trimbits";
|
||||
break;
|
||||
case JUNGFRAUCTB:
|
||||
names[nvar++]="dac:0";
|
||||
names[nvar++]="dac:1";
|
||||
names[nvar++]="dac:2";
|
||||
names[nvar++]="dac:3";
|
||||
names[nvar++]="dac:4";
|
||||
names[nvar++]="dac:5";
|
||||
names[nvar++]="dac:6";
|
||||
names[nvar++]="dac:7";
|
||||
names[nvar++]="dac:8";
|
||||
names[nvar++]="dac:9";
|
||||
names[nvar++]="dac:10";
|
||||
names[nvar++]="dac:11";
|
||||
names[nvar++]="dac:12";
|
||||
names[nvar++]="dac:13";
|
||||
names[nvar++]="dac:14";
|
||||
names[nvar++]="dac:15";
|
||||
names[nvar++]="adcvpp";
|
||||
|
||||
|
||||
|
||||
names[nvar++]="adcclk";
|
||||
names[nvar++]="clkdivider";
|
||||
names[nvar++]="adcphase";
|
||||
names[nvar++]="adcpipeline";
|
||||
names[nvar++]="adcinvert"; //
|
||||
names[nvar++]="adcdisable";
|
||||
names[nvar++]="patioctrl";
|
||||
names[nvar++]="patclkctrl";
|
||||
names[nvar++]="patlimits";
|
||||
names[nvar++]="patloop0";
|
||||
names[nvar++]="patnloop0";
|
||||
names[nvar++]="patwait0";
|
||||
names[nvar++]="patwaittime0";
|
||||
names[nvar++]="patloop1";
|
||||
names[nvar++]="patnloop1";
|
||||
names[nvar++]="patwait1";
|
||||
names[nvar++]="patwaittime1";
|
||||
names[nvar++]="patloop2";
|
||||
names[nvar++]="patnloop2";
|
||||
names[nvar++]="patwait2";
|
||||
names[nvar++]="patwaittime2";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
names[nvar++]="startscript";
|
||||
names[nvar++]="startscriptpar";
|
||||
names[nvar++]="stopscript";
|
||||
names[nvar++]="stopscriptpar";
|
||||
names[nvar++]="scriptbefore";
|
||||
names[nvar++]="scriptbeforepar";
|
||||
names[nvar++]="scriptafter";
|
||||
names[nvar++]="scriptafterpar";
|
||||
names[nvar++]="scan0script";
|
||||
names[nvar++]="scan0par";
|
||||
names[nvar++]="scan0prec";
|
||||
names[nvar++]="scan0steps";
|
||||
names[nvar++]="scan1script";
|
||||
names[nvar++]="scan1par";
|
||||
names[nvar++]="scan1prec";
|
||||
names[nvar++]="scan1steps";
|
||||
|
||||
|
||||
int iv=0;
|
||||
string fname1;
|
||||
|
||||
|
||||
|
||||
ofstream outfile;
|
||||
char *args[4];
|
||||
for (int ia=0; ia<4; ia++) {
|
||||
args[ia]=new char[1000];
|
||||
}
|
||||
|
||||
|
||||
int nargs;
|
||||
if (level==2)
|
||||
nargs=2;
|
||||
else
|
||||
nargs=1;
|
||||
|
||||
|
||||
if (level==2) {
|
||||
fname1=fname+string(".config");
|
||||
writeConfigurationFile(fname1);
|
||||
fname1=fname+string(".det");
|
||||
} else
|
||||
fname1=fname;
|
||||
|
||||
|
||||
|
||||
outfile.open(fname1.c_str(),ios_base::out);
|
||||
if (outfile.is_open()) {
|
||||
cmd=new slsDetectorCommand(this);
|
||||
for (iv=0; iv<nvar-3; iv++) {
|
||||
strcpy(args[0],names[iv].c_str());
|
||||
outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl;
|
||||
}
|
||||
|
||||
|
||||
strcpy(args[0],names[iv].c_str());
|
||||
if (level==2) {
|
||||
fname1=fname+string(".ff");
|
||||
strcpy(args[1],fname1.c_str());
|
||||
}
|
||||
outfile << names[iv] << " " << cmd->executeLine(nargs,args,GET_ACTION) << std::endl;
|
||||
iv++;
|
||||
|
||||
strcpy(args[0],names[iv].c_str());
|
||||
if (level==2) {
|
||||
fname1=fname+string(".bad");
|
||||
strcpy(args[1],fname1.c_str());
|
||||
}
|
||||
outfile << names[iv] << " " << cmd->executeLine(nargs,args,GET_ACTION) << std::endl;
|
||||
iv++;
|
||||
|
||||
|
||||
|
||||
if (level==2) {
|
||||
strcpy(args[0],names[iv].c_str());
|
||||
size_t c=fname.rfind('/');
|
||||
if (c<string::npos) {
|
||||
fname1=fname.substr(0,c+1)+string("trim_")+fname.substr(c+1);
|
||||
} else {
|
||||
fname1=string("trim_")+fname;
|
||||
}
|
||||
strcpy(args[1],fname1.c_str());
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "writing to file " << fname1 << std::endl;
|
||||
#endif
|
||||
outfile << names[iv] << " " << cmd->executeLine(nargs,args,GET_ACTION) << std::endl;
|
||||
iv++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
delete cmd;
|
||||
|
||||
outfile.close();
|
||||
}
|
||||
else {
|
||||
std::cout<< "Error opening parameters file " << fname1 << " for writing" << std::endl;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "wrote " <<iv << " lines to "<< fname1 << std::endl;
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -709,25 +709,6 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
void registerProgressCallback(int( *func)(double,void*), void *pArg){progress_call=func; pProgressCallArg=pArg;};
|
||||
|
||||
|
||||
/**
|
||||
Saves the detector setup to file
|
||||
\param fname file to write to
|
||||
\param level if 2 reads also trimbits, flat field, angular correction etc. and writes them to files with automatically added extension
|
||||
\returns OK or FAIL
|
||||
|
||||
*/
|
||||
int dumpDetectorSetup(std::string const fname, int level=0);
|
||||
|
||||
|
||||
/**
|
||||
Loads the detector setup from file
|
||||
\param fname file to read from
|
||||
\param level if 2 reads also reads trimbits, angular conversion coefficients etc. from files with default extensions as generated by dumpDetectorSetup
|
||||
\returns OK or FAIL
|
||||
|
||||
*/
|
||||
int retrieveDetectorSetup(std::string const fname, int level=0);
|
||||
|
||||
static int dummyAcquisitionFinished(double prog,int status,void* p){cout <<"Acquisition finished callback! " << prog << " " << status << endl; return 0;}
|
||||
static int dummyMeasurementFinished(int im,int findex,void* p){cout <<"Measurement finished callback! " << im << " " << findex << endl; return 0;}
|
||||
|
||||
|
Reference in New Issue
Block a user