This commit is contained in:
maliakal_d 2019-06-11 16:36:02 +02:00
parent 3c1df02414
commit b922b79232
3 changed files with 33 additions and 29 deletions

View File

@ -4,6 +4,7 @@ class qDetectorMain;
class multiSlsDetector; class multiSlsDetector;
class ServerSocket; class ServerSocket;
class ServerInterface;
#include <vector> #include <vector>
@ -18,14 +19,14 @@ class qServer : public QWidget, public virtual slsDetectorDefs {
private: private:
void FunctionTable(); void FunctionTable();
int DecodeFunction(ServerSocket *sock); void DecodeFunction(ServerSocket *sock);
void ShutDownSockets(); void ShutDownSockets();
void ServerThread(ServerSocket* sock); void ServerThread(ServerSocket* sock);
int GetStatus(ServerSocket* sock); void GetStatus(ServerSocket* sock);
int StartAcquisition(ServerSocket* sock); void StartAcquisition(ServerSocket* sock);
int StopsAcquisition(ServerSocket* sock); void StopsAcquisition(ServerSocket* sock);
int Acquire(ServerSocket* sock); void Acquire(ServerSocket* sock);
int ExitServer(ServerSocket* sock); void ExitServer(ServerSocket* sock);
/** function list */ /** function list */
typedef int (qServer::*some_func_t)(ServerSocket*); typedef int (qServer::*some_func_t)(ServerSocket*);

View File

@ -1,10 +1,11 @@
#pragma once #pragma once
class multiSlsDetector; class multiSlsDetector;
#include "sls_detector_defs.h"
#include <QDoubleSpinBox>
class QGroupBox; class QGroupBox;
class QLabel; class QLabel;
class QDoubleSpinBox;
class MyDoubleSpinBox; class MyDoubleSpinBox;
class QLineEdit; class QLineEdit;
class QComboBox; class QComboBox;
@ -12,6 +13,7 @@ class QSpinBox;
class QGridLayout; class QGridLayout;
class QString; class QString;
class QPalette; class QPalette;
class QGridLayout;
#include <string> #include <string>
#include <vector> #include <vector>
@ -90,6 +92,7 @@ private:
QSpinBox *spinHV; QSpinBox *spinHV;
QGridLayout *dacLayout; QGridLayout *dacLayout;
QComboBox *comboDetector; QComboBox *comboDetector;
QGridLayout *layout;
static const int HV_MIN = 60; static const int HV_MIN = 60;
static const int HV_MAX = 200; static const int HV_MAX = 200;

View File

@ -107,7 +107,7 @@ void qTabDeveloper::SetupWidgetWindow() {
QScrollArea* scroll = new QScrollArea; QScrollArea* scroll = new QScrollArea;
scroll->setWidget(this); scroll->setWidget(this);
scroll->setWidgetResizable(true); scroll->setWidgetResizable(true);
QGridLayout *layout = new QGridLayout(scroll); layout = new QGridLayout(scroll);
layout->setContentsMargins(20, 10, 10, 5); layout->setContentsMargins(20, 10, 10, 5);
setLayout(layout); setLayout(layout);
@ -235,21 +235,20 @@ void qTabDeveloper::CreateHVWidget() {
comboHV->addItem("150"); comboHV->addItem("150");
comboHV->addItem("180"); comboHV->addItem("180");
comboHV->addItem("200"); comboHV->addItem("200");
tipHV = "<nobr>Set high voltage to 0, 90, 110, 120, 150 or 200V.</nobr>"; comboHV->setToolTip("<nobr>Set high voltage to 0, 90, 110, 120, 150 or 200V.</nobr>");
comboHV->setToolTip(tipHV); lblHV->setToolTip(comboHV->toolTip());
dacLayout->addWidget(comboHV, (int)(numDACWidgets / 2), 2); dacLayout->addWidget(comboHV, (int)(numDACWidgets / 2), 2);
} }
// jungfrau, moench (range of values) // jungfrau, moench (range of values)
else { else {
spinHV = new QSpinBox(boxDacs); spinHV = new QSpinBox(boxDacs);
spinDacs[i]->setMinimum(-1); spinDacs[numDACWidgets]->setMinimum(-1);
spinDacs[i]->setMaximum(HV_MAX); spinDacs[numDACWidgets]->setMaximum(HV_MAX);
tipHV = "<nobr>Set high voltage to 0 or 60 - 200V</nobr>"; spinHV->setToolTip("<nobr>Set high voltage to 0 or 60 - 200V</nobr>");
spinHV->setToolTip(tipHV); lblHV->setToolTip(spinHV->toolTip());
dacLayout->addWidget(spinHV, (int)(numDACWidgets / 2), 2); dacLayout->addWidget(spinHV, (int)(numDACWidgets / 2), 2);
} }
lblHV->setToolTip(tipHV);
} }
void qTabDeveloper::GetDac(int id) { void qTabDeveloper::GetDac(int id) {
@ -283,7 +282,7 @@ void qTabDeveloper::SetDac(int id) {
FILE_LOG(logINFO) << "Setting dac:" << dacNames[id] << " : " << val; FILE_LOG(logINFO) << "Setting dac:" << dacNames[id] << " : " << val;
try { try {
myDet->setDAC(val, etSLSIndex(id), 0, comboDetector->currentIndex() - 1); myDet->setDAC(val, getSLSIndex(id), 0, comboDetector->currentIndex() - 1);
} catch (const sls::NonCriticalError &e) { } catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not set dac.", e.what(), "qTabDeveloper::SetDac"); qDefs::ExceptionMessage("Could not set dac.", e.what(), "qTabDeveloper::SetDac");
} }
@ -294,16 +293,17 @@ void qTabDeveloper::SetDac(int id) {
void qTabDeveloper::GetAdcs() { void qTabDeveloper::GetAdcs() {
FILE_LOG(logDEBUG) << "Getting ADCs"; FILE_LOG(logDEBUG) << "Getting ADCs";
auto moduleId = comboDetector->currentIndex() - 1;
for (int i = 0; i < numADCWidgets; ++i) { for (int i = 0; i < numADCWidgets; ++i) {
try { try {
auto retval = myDet->getADC(getSLSIndex(id + numDACWidgets), comboDetector->currentIndex() - 1); auto retval = myDet->getADC(getSLSIndex(i + numDACWidgets), moduleId);
if (value == -1 && moduleId == -1) { if (retval == -1 && moduleId == -1) {
spinAdcs[i]->setText(QString("Different values")); spinAdcs[i]->setText(QString("Different values"));
} else { } else {
if (detType == slsDetectorDefs::EIGER || detType == slsDetectorDefs::JUNGFRAU) { if (detType == slsDetectorDefs::EIGER || detType == slsDetectorDefs::JUNGFRAU) {
value /= 1000.00; retval /= 1000.00;
} }
spinAdcs[i]->setText(QString::number(value, 'f', 2) + 0x00b0 + QString("C")); spinAdcs[i]->setText(QString::number(retval, 'f', 2) + 0x00b0 + QString("C"));
} }
} catch (const sls::NonCriticalError &e) { } catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not get adcs.", e.what(), "qTabDeveloper::GetAdcs"); qDefs::ExceptionMessage("Could not get adcs.", e.what(), "qTabDeveloper::GetAdcs");
@ -327,15 +327,15 @@ void qTabDeveloper::GetHighVoltage() {
// dac units // dac units
auto retval = myDet->setDAC(-1, slsDetectorDefs::HIGH_VOLTAGE, 0, comboDetector->currentIndex() - 1); auto retval = myDet->setDAC(-1, slsDetectorDefs::HIGH_VOLTAGE, 0, comboDetector->currentIndex() - 1);
if (spinHV != nullptr) { if (spinHV != nullptr) {
if (retval != 0 && retval != -1 && retval < HV_MIN && ret > HV_MAX) { if (retval != 0 && retval != -1 && retval < HV_MIN && retval > HV_MAX) {
qDefs::Message(qDefs::WARNING, std::string("Unknown High Voltage: ") + std::to_string(retval), "qTabDeveloper::GetHighVoltage"); qDefs::Message(qDefs::WARNING, std::string("Unknown High Voltage: ") + std::to_string(retval), "qTabDeveloper::GetHighVoltage");
} else{ } else{
spinHV->setValue(ret); spinHV->setValue(retval);
} }
} else { } else {
switch (ret) { switch (retval) {
case -1: case -1:
qDefs::Message(qDefs::WARNING, "Different values for high voltage."); qDefs::Message(qDefs::WARNING, "Different values for high voltage.", "qTabDeveloper::GetHighVoltage");
break; break;
case 0: case 0:
comboHV->setCurrentIndex(HV_0); comboHV->setCurrentIndex(HV_0);
@ -381,7 +381,7 @@ void qTabDeveloper::SetHighVoltage() {
FILE_LOG(logINFO) << "Setting high voltage:" << val; FILE_LOG(logINFO) << "Setting high voltage:" << val;
try { try {
myDet->setDAC(val, slsDetectorDefs::HIGH_VOLTAGE, 0, comboFileFormat->currentIndex() - 1); myDet->setDAC(val, slsDetectorDefs::HIGH_VOLTAGE, 0, comboDetector->currentIndex() - 1);
} catch (const sls::NonCriticalError &e) { } catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not set high voltage.", e.what(), "qTabDeveloper::SetHighVoltage"); qDefs::ExceptionMessage("Could not set high voltage.", e.what(), "qTabDeveloper::SetHighVoltage");
GetHighVoltage(); GetHighVoltage();
@ -441,7 +441,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
case 22: case 22:
return slsDetectorDefs::TEMPERATURE_FPGA; return slsDetectorDefs::TEMPERATURE_FPGA;
default: default:
throw sls:NonCriticalError(std::string(Unknown dac/adc index) + std::to_string(index)); throw sls::NonCriticalError(std::string("Unknown dac/adc index") + std::to_string(index));
} }
break; break;
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
@ -467,7 +467,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
case 9: case 9:
return slsDetectorDefs::TEMPERATURE_FPGA; return slsDetectorDefs::TEMPERATURE_FPGA;
default: default:
throw sls:NonCriticalError(std::string(Unknown dac/adc index) + std::to_string(index)); throw sls::NonCriticalError(std::string("Unknown dac/adc index") + std::to_string(index));
} }
break; break;
@ -478,7 +478,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
if (index == numDACWidgets) { if (index == numDACWidgets) {
return slsDetectorDefs::TEMPERATURE_ADC; return slsDetectorDefs::TEMPERATURE_ADC;
} else { } else {
throw sls:NonCriticalError(std::string(Unknown dac/adc index) + std::to_string(index)); throw sls::NonCriticalError(std::string("Unknown dac/adc index") + std::to_string(index));
} }
break; break;
@ -486,7 +486,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
if (index >= 0 && index < numDACWidgets) { if (index >= 0 && index < numDACWidgets) {
return (slsDetectorDefs::dacIndex)index; return (slsDetectorDefs::dacIndex)index;
} else { } else {
throw sls:NonCriticalError(std::string(Unknown dac/adc index) + std::to_string(index)); throw sls::NonCriticalError(std::string("Unknown dac/adc index") + std::to_string(index));
} }
break; break;