mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-05 20:30:03 +02:00
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:
parent
a25b74c9ab
commit
f0217ce9b1
@ -31,86 +31,6 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</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">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -152,8 +72,126 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<zorder>horizontalLayoutWidget_2</zorder>
|
||||
<zorder>checkBox_3</zorder>
|
||||
</widget>
|
||||
<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>
|
||||
<resources/>
|
||||
|
@ -327,7 +327,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
|
||||
if (!fName.isEmpty()){
|
||||
if(myDet->retrieveDetectorSetup(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL)
|
||||
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){
|
||||
@ -342,7 +342,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
|
||||
if (!fName.isEmpty()){
|
||||
if(myDet->dumpDetectorSetup(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL)
|
||||
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){
|
||||
@ -362,7 +362,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
|
||||
if (!fName.isEmpty()){
|
||||
if(myDet->readConfigurationFile(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL)
|
||||
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){
|
||||
@ -377,14 +377,14 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
|
||||
if (!fName.isEmpty()){
|
||||
if(myDet->writeConfigurationFile(string(fName.toAscii().constData()))!=slsDetectorDefs::FAIL)
|
||||
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){
|
||||
#ifdef VERBOSE
|
||||
cout << "Loading Trimbits" << endl;
|
||||
#endif
|
||||
QString fName = QString(myDet->getFilePath().c_str());
|
||||
QString fName = QString(myDet->getSettingsDir());
|
||||
fName = QFileDialog::getOpenFileName(this,
|
||||
tr("Load Detector Trimbits"),fName,
|
||||
tr("Trimbit files (*.trim *.sn*)"));
|
||||
@ -392,14 +392,14 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
|
||||
if (!fName.isEmpty()){
|
||||
if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
|
||||
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){
|
||||
#ifdef VERBOSE
|
||||
cout << "Saving Trimbits" << endl;
|
||||
#endif
|
||||
QString fName = QString(myDet->getFilePath().c_str());
|
||||
QString fName = QString(myDet->getSettingsDir());
|
||||
fName = QFileDialog::getSaveFileName(this,
|
||||
tr("Save Current Detector Trimbits"),fName,
|
||||
tr("Trimbit files (*.trim *.sn*) "));
|
||||
@ -407,87 +407,38 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
|
||||
if (!fName.isEmpty()){
|
||||
if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
|
||||
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){
|
||||
#ifdef VERBOSE
|
||||
cout << "Loading Calibration Data" << endl;
|
||||
#endif
|
||||
QString fName = QString(myDet->getFilePath().c_str());
|
||||
QString fName = QString(myDet->getCalDir());
|
||||
fName = QFileDialog::getOpenFileName(this,
|
||||
tr("Load Detector Calibration Data"),fName,
|
||||
tr("Calibration files (*.cal *.sn*)"));
|
||||
// Gets called when cancelled as well
|
||||
if (!fName.isEmpty()){
|
||||
int nMod = myDet->setNumberOfModules();
|
||||
slsDetector *detector;
|
||||
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){
|
||||
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");
|
||||
if(myDet->loadCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
|
||||
qDefs::InfoMessage("The Calibration Data have been loaded successfully.","Main");
|
||||
else qDefs::WarningMessage(string("Could not load the Calibration data from file:\n")+ fName.toAscii().constData(),"Main");
|
||||
}
|
||||
}
|
||||
else if(action==actionSaveCalibration){
|
||||
#ifdef VERBOSE
|
||||
cout << "Saving Calibration Data" << endl;
|
||||
#endif
|
||||
QString fName = QString(myDet->getFilePath().c_str());
|
||||
QString fName = QString(myDet->getCalDir());
|
||||
fName = QFileDialog::getSaveFileName(this,
|
||||
tr("Save Current Detector Calibration Data"),fName,
|
||||
tr("Calibration files (*.cal *.sn*) "));
|
||||
// Gets called when cancelled as well
|
||||
if (!fName.isEmpty()){
|
||||
int nMod = myDet->setNumberOfModules();
|
||||
cout<<"nmode:"<<nMod<<endl;
|
||||
slsDetector *detector;
|
||||
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");
|
||||
if(myDet->saveCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
|
||||
qDefs::InfoMessage("The Calibration Data have been saved successfully.","Main");
|
||||
else qDefs::WarningMessage(string("Could not save the Calibration data to file:\n")+fName.toAscii().constData(),"Main");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user