loading and saving trimbits and calibration file works now

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@46 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2012-09-03 09:25:09 +00:00
parent a25b74c9ab
commit f0217ce9b1
2 changed files with 137 additions and 148 deletions

View File

@ -31,86 +31,6 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>25</x>
<y>200</y>
<width>726</width>
<height>58</height>
</rect>
</property>
<property name="title">
<string>Trimming Method</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>711</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>15</number>
</property>
<item>
<widget class="QRadioButton" name="radioButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>None</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Adjust to Fix Count Level</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Equalize to Median</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Optimize Settings</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -152,8 +72,126 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<zorder>horizontalLayoutWidget_2</zorder> </widget>
<zorder>checkBox_3</zorder> <widget class="QGroupBox" name="groupBox_4">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>20</x>
<y>150</y>
<width>731</width>
<height>156</height>
</rect>
</property>
<property name="title">
<string>Trimming</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="flat">
<bool>false</bool>
</property>
<widget class="QWidget" name="gridLayoutWidget_6">
<property name="geometry">
<rect>
<x>15</x>
<y>20</y>
<width>701</width>
<height>126</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="1">
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>45</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Trimming Method:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Adjust to Fix Count Level</string>
</property>
</item>
<item>
<property name="text">
<string>Equalize to Median</string>
</property>
</item>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_18">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>75</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="4">
<widget class="QCheckBox" name="chkSaveAll">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Optimize Settings</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</widget> </widget>
<resources/> <resources/>

View File

@ -327,7 +327,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
if (!fName.isEmpty()){ if (!fName.isEmpty()){
if(myDet->retrieveDetectorSetup(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL) if(myDet->retrieveDetectorSetup(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL)
qDefs::InfoMessage("The Setup Parameters have been loaded successfully.","Main"); qDefs::InfoMessage("The Setup Parameters have been loaded successfully.","Main");
else qDefs::WarningMessage("The Loading of Setup Parameters has failed.","Main"); else qDefs::WarningMessage(string("Could not load the Setup Parameters from file:\n")+fName.toAscii().constData(),"Main");
} }
} }
else if(action==actionSaveSetup){ else if(action==actionSaveSetup){
@ -342,7 +342,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
if (!fName.isEmpty()){ if (!fName.isEmpty()){
if(myDet->dumpDetectorSetup(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL) if(myDet->dumpDetectorSetup(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL)
qDefs::InfoMessage("The Setup Parameters have been saved successfully.","Main"); qDefs::InfoMessage("The Setup Parameters have been saved successfully.","Main");
else qDefs::WarningMessage("The Saving of Setup Parameters has failed.","Main"); else qDefs::WarningMessage(string("Could not save the Setup Parameters from file:\n")+fName.toAscii().constData(),"Main");
} }
} }
else if(action==actionMeasurementWizard){ else if(action==actionMeasurementWizard){
@ -362,7 +362,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
if (!fName.isEmpty()){ if (!fName.isEmpty()){
if(myDet->readConfigurationFile(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL) if(myDet->readConfigurationFile(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL)
qDefs::InfoMessage("The Configuration Parameters have been configured successfully.","Main"); qDefs::InfoMessage("The Configuration Parameters have been configured successfully.","Main");
else qDefs::WarningMessage("The Loading of Configuration Parameters has failed.","Main"); else qDefs::WarningMessage(string("Could not load the Configuration Parameters from file:\n")+fName.toAscii().constData(),"Main");
} }
} }
else if(action==actionSaveConfiguration){ else if(action==actionSaveConfiguration){
@ -377,14 +377,14 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
if (!fName.isEmpty()){ if (!fName.isEmpty()){
if(myDet->writeConfigurationFile(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL) if(myDet->writeConfigurationFile(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL)
qDefs::InfoMessage("The Configuration Parameters have been saved successfully.","Main"); qDefs::InfoMessage("The Configuration Parameters have been saved successfully.","Main");
else qDefs::WarningMessage("The Saving of Configuration Parameters has failed.","Main"); else qDefs::WarningMessage(string("Could not save the Configuration Parameters from file:\n")+fName.toAscii().constData(),"Main");
} }
} }
else if(action==actionLoadTrimbits){ else if(action==actionLoadTrimbits){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Loading Trimbits" << endl; cout << "Loading Trimbits" << endl;
#endif #endif
QString fName = QString(myDet->getFilePath().c_str()); QString fName = QString(myDet->getSettingsDir());
fName = QFileDialog::getOpenFileName(this, fName = QFileDialog::getOpenFileName(this,
tr("Load Detector Trimbits"),fName, tr("Load Detector Trimbits"),fName,
tr("Trimbit files (*.trim *.sn*)")); tr("Trimbit files (*.trim *.sn*)"));
@ -392,14 +392,14 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
if (!fName.isEmpty()){ if (!fName.isEmpty()){
if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
qDefs::InfoMessage("The Trimbits have been loaded successfully.","Main"); qDefs::InfoMessage("The Trimbits have been loaded successfully.","Main");
else qDefs::WarningMessage("The Loading of Trimbits has failed.","Main"); else qDefs::WarningMessage(string("Could not load the Trimbits from file:\n")+fName.toAscii().constData(),"Main");
} }
} }
else if(action==actionSaveTrimbits){ else if(action==actionSaveTrimbits){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Saving Trimbits" << endl; cout << "Saving Trimbits" << endl;
#endif #endif
QString fName = QString(myDet->getFilePath().c_str()); QString fName = QString(myDet->getSettingsDir());
fName = QFileDialog::getSaveFileName(this, fName = QFileDialog::getSaveFileName(this,
tr("Save Current Detector Trimbits"),fName, tr("Save Current Detector Trimbits"),fName,
tr("Trimbit files (*.trim *.sn*) ")); tr("Trimbit files (*.trim *.sn*) "));
@ -407,87 +407,38 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
if (!fName.isEmpty()){ if (!fName.isEmpty()){
if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
qDefs::InfoMessage("The Trimbits have been saved successfully.","Main"); qDefs::InfoMessage("The Trimbits have been saved successfully.","Main");
else qDefs::WarningMessage("The Saving of Trimbits has failed.","Main"); else qDefs::WarningMessage(string("Could not save the Trimbits to file:\n")+fName.toAscii().constData(),"Main");
} }
} }
else if(action==actionLoadCalibration){ else if(action==actionLoadCalibration){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Loading Calibration Data" << endl; cout << "Loading Calibration Data" << endl;
#endif #endif
QString fName = QString(myDet->getFilePath().c_str()); QString fName = QString(myDet->getCalDir());
fName = QFileDialog::getOpenFileName(this, fName = QFileDialog::getOpenFileName(this,
tr("Load Detector Calibration Data"),fName, tr("Load Detector Calibration Data"),fName,
tr("Calibration files (*.cal *.sn*)")); tr("Calibration files (*.cal *.sn*)"));
// Gets called when cancelled as well // Gets called when cancelled as well
if (!fName.isEmpty()){ if (!fName.isEmpty()){
int nMod = myDet->setNumberOfModules(); if(myDet->loadCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
slsDetector *detector; qDefs::InfoMessage("The Calibration Data have been loaded successfully.","Main");
slsDetectorDefs::sls_detector_module *myMod=NULL; else qDefs::WarningMessage(string("Could not load the Calibration data from file:\n")+ fName.toAscii().constData(),"Main");
string sFname= fName.toAscii().constData();
double gain,offset;
for(int i=0;i<nMod;i++){
string fn = sFname;
detector = myDet->getSlsDetector(i);
if(detector){
if (sFname.find(".cal")==string::npos) {
if (sFname.find(".sn")==string::npos && sFname.find(".cal")) {
ostringstream ostfn;
ostfn << sFname << ".sn" << setfill('0') << setw(3) << hex << myDet->getId(slsDetectorDefs::MODULE_SERIAL_NUMBER, i);
fn=ostfn.str();
}}
if(detector->readCalibrationFile(fn,gain,offset)==-1)
qDefs::WarningMessage(string("Could not open Calibration File.\n")+ fn,"Main");
else{
if(myMod = detector->getModule(i)){
myMod->gain = gain;
myMod->offset = offset;
detector->setModule(*myMod);
detector->deleteModule(myMod);
}
}
}
detector = NULL;
}
//if(energyConversion::readCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
// qDefs::InfoMessage("The Calibration Data have been loaded successfully.","Main");
//else qDefs::WarningMessage("The Loading of Calibration Data has failed.","Main");
} }
} }
else if(action==actionSaveCalibration){ else if(action==actionSaveCalibration){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Saving Calibration Data" << endl; cout << "Saving Calibration Data" << endl;
#endif #endif
QString fName = QString(myDet->getFilePath().c_str()); QString fName = QString(myDet->getCalDir());
fName = QFileDialog::getSaveFileName(this, fName = QFileDialog::getSaveFileName(this,
tr("Save Current Detector Calibration Data"),fName, tr("Save Current Detector Calibration Data"),fName,
tr("Calibration files (*.cal *.sn*) ")); tr("Calibration files (*.cal *.sn*) "));
// Gets called when cancelled as well // Gets called when cancelled as well
if (!fName.isEmpty()){ if (!fName.isEmpty()){
int nMod = myDet->setNumberOfModules(); if(myDet->saveCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
cout<<"nmode:"<<nMod<<endl; qDefs::InfoMessage("The Calibration Data have been saved successfully.","Main");
slsDetector *detector; else qDefs::WarningMessage(string("Could not save the Calibration data to file:\n")+fName.toAscii().constData(),"Main");
slsDetectorDefs::sls_detector_module *myMod=NULL;
string sFname= fName.toAscii().constData();
double gain,offset;
for(int i=0;i<nMod;i++){
string fn = sFname;
detector = myDet->getSlsDetector(i);
if(detector){
ostringstream ostfn;
ostfn << sFname << ".sn" << setfill('0') << setw(3) << hex << myDet->getId(slsDetectorDefs::MODULE_SERIAL_NUMBER, i);
fn=ostfn.str();
if(myMod = detector->getModule(i)){
if(detector->writeCalibrationFile(fn,myMod->gain,myMod->offset)==-1)
qDefs::WarningMessage(string("Could not open Calibration File.\n")+ fn,"Main");
detector->deleteModule(myMod);
}
}
detector = NULL;
}
//if(energyConversion::writeCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
// qDefs::InfoMessage("The Calibration Data have been saved successfully.","Main");
//else qDefs::WarningMessage("The Saving of Calibration Data has failed.","Main");
} }
} }