mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00
WIP
This commit is contained in:
parent
1084e5361b
commit
badff47663
@ -312,7 +312,7 @@ void qDetectorMain::EnableModes(QAction *action) {
|
||||
enable = actionDebug->isChecked();
|
||||
tabs->setTabEnabled(DEBUGGING, enable);
|
||||
FILE_LOG(logINFO) << "Debug Mode: "
|
||||
<< slsDetectorDefs::stringEnable(enable);
|
||||
<< sls::ToString(enable);
|
||||
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ void qDetectorMain::EnableModes(QAction *action) {
|
||||
tabs->setTabEnabled(ADVANCED, enable);
|
||||
actionLoadTrimbits->setVisible(enable && detType == slsDetectorDefs::EIGER);
|
||||
FILE_LOG(logINFO) << "Expert Mode: "
|
||||
<< slsDetectorDefs::stringEnable(enable);
|
||||
<< sls::ToString(enable);
|
||||
}
|
||||
|
||||
// Set DockableMode
|
||||
@ -336,7 +336,7 @@ void qDetectorMain::EnableModes(QAction *action) {
|
||||
dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
}
|
||||
FILE_LOG(logINFO) << "Dockable Mode: "
|
||||
<< slsDetectorDefs::stringEnable(enable);
|
||||
<< sls::ToString(enable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1220,13 +1220,13 @@ uint64_t slsDetector::getStartingFrameNumber() {
|
||||
int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
||||
int64_t args[]{static_cast<int64_t>(index), t};
|
||||
int64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Setting " << getTimerType(index) << " to " << t
|
||||
FILE_LOG(logDEBUG1) << "Setting " << sls::ToString(index) << " to " << t
|
||||
<< " ns/value";
|
||||
|
||||
// send to detector
|
||||
int64_t oldtimer = shm()->timerValue[index];
|
||||
sendToDetector(F_SET_TIMER, args, retval);
|
||||
FILE_LOG(logDEBUG1) << getTimerType(index) << ": " << retval;
|
||||
FILE_LOG(logDEBUG1) << sls::ToString(index) << ": " << retval;
|
||||
shm()->timerValue[index] = retval;
|
||||
// update #nchan, as it depends on #samples, adcmask,
|
||||
if (index == ANALOG_SAMPLES || index == DIGITAL_SAMPLES) {
|
||||
@ -1283,7 +1283,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
||||
<< (((index == FRAME_NUMBER) || (index == TRIGGER_NUMBER) ||
|
||||
(index == STORAGE_CELL_NUMBER))
|
||||
? "(#Frames) * (#triggers) * (#storage cells)"
|
||||
: getTimerType(index))
|
||||
: sls::ToString(index))
|
||||
<< " to receiver: " << args[1];
|
||||
|
||||
sendToReceiver(F_SET_RECEIVER_TIMER, args, retval);
|
||||
@ -1294,9 +1294,9 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
||||
|
||||
int64_t slsDetector::getTimeLeft(timerIndex index) const {
|
||||
int64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting " << getTimerType(index) << " left";
|
||||
FILE_LOG(logDEBUG1) << "Getting " << sls::ToString(index) << " left";
|
||||
sendToDetectorStop(F_GET_TIME_LEFT, index, retval);
|
||||
FILE_LOG(logDEBUG1) << getTimerType(index) << " left: " << retval;
|
||||
FILE_LOG(logDEBUG1) << sls::ToString(index) << " left: " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -646,21 +646,21 @@ void slsReceiverImplementation::setFileWriteEnable(const bool b) {
|
||||
}
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO) << "File Write Enable: " << stringEnable(fileWriteEnable);
|
||||
FILE_LOG(logINFO) << "File Write Enable: " << sls::ToString(fileWriteEnable);
|
||||
}
|
||||
|
||||
void slsReceiverImplementation::setMasterFileWriteEnable(const bool b) {
|
||||
masterFileWriteEnable = b;
|
||||
|
||||
FILE_LOG(logINFO) << "Master File Write Enable: "
|
||||
<< stringEnable(masterFileWriteEnable);
|
||||
<< sls::ToString(masterFileWriteEnable);
|
||||
}
|
||||
|
||||
void slsReceiverImplementation::setOverwriteEnable(const bool b) {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
|
||||
overwriteEnable = b;
|
||||
FILE_LOG(logINFO) << "Overwrite Enable: " << stringEnable(overwriteEnable);
|
||||
FILE_LOG(logINFO) << "Overwrite Enable: " << sls::ToString(overwriteEnable);
|
||||
}
|
||||
|
||||
/***connection parameters***/
|
||||
@ -1057,7 +1057,7 @@ int slsReceiverImplementation::setTenGigaEnable(const bool b) {
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO) << "Ten Giga: " << stringEnable(tengigaEnable);
|
||||
FILE_LOG(logINFO) << "Ten Giga: " << sls::ToString(tengigaEnable);
|
||||
FILE_LOG(logINFO) << "Packets per Frame: "
|
||||
<< (generalData->packetsPerFrame);
|
||||
return OK;
|
||||
@ -1077,7 +1077,7 @@ int slsReceiverImplementation::setFifoDepth(const uint32_t i) {
|
||||
bool slsReceiverImplementation::setActivate(bool enable) {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
activated = enable;
|
||||
FILE_LOG(logINFO) << "Activation: " << stringEnable(activated);
|
||||
FILE_LOG(logINFO) << "Activation: " << sls::ToString(activated);
|
||||
return activated;
|
||||
}
|
||||
|
||||
@ -1085,7 +1085,7 @@ bool slsReceiverImplementation::setDeactivatedPadding(bool enable) {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
deactivatedPaddingEnable = enable;
|
||||
FILE_LOG(logINFO) << "Deactivated Padding Enable: "
|
||||
<< stringEnable(deactivatedPaddingEnable);
|
||||
<< sls::ToString(deactivatedPaddingEnable);
|
||||
return deactivatedPaddingEnable;
|
||||
}
|
||||
|
||||
|
@ -531,7 +531,8 @@ int slsReceiverTCPIPInterface::set_roi(Interface &socket) {
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
||||
auto index = socket.Receive<int64_t>();
|
||||
auto ind = socket.Receive<int64_t>();
|
||||
slsDetectorDefs::timerIndex index = static_cast<slsDetectorDefs::timerIndex>(ind);
|
||||
auto value = socket.Receive<int64_t>();
|
||||
if (value >= 0) {
|
||||
FILE_LOG(logDEBUG1)
|
||||
@ -571,7 +572,7 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
||||
impl()->setNumberofDigitalSamples(value);
|
||||
break;
|
||||
default:
|
||||
modeNotImplemented("Timer index", static_cast<int>(value));
|
||||
modeNotImplemented("Timer index", static_cast<int>(index));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -597,14 +598,14 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
||||
break;
|
||||
case ANALOG_SAMPLES:
|
||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
||||
throw RuntimeError("This timer mode (" + std::to_string(index) +
|
||||
throw RuntimeError("This timer mode (" + sls::ToString(index) +
|
||||
") does not exist for this receiver type");
|
||||
}
|
||||
retval = impl()->getNumberofAnalogSamples();
|
||||
break;
|
||||
case DIGITAL_SAMPLES:
|
||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
||||
throw RuntimeError("This timer mode (" + std::to_string(index) +
|
||||
throw RuntimeError("This timer mode (" + sls::ToString(index) +
|
||||
") does not exist for this receiver type");
|
||||
}
|
||||
retval = impl()->getNumberofDigitalSamples();
|
||||
@ -614,7 +615,7 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
||||
break;
|
||||
}
|
||||
validate(value, retval, "set timer", DEC);
|
||||
FILE_LOG(logDEBUG1) << slsDetectorDefs::getTimerType((timerIndex)(index))
|
||||
FILE_LOG(logDEBUG1) << sls::ToString((index))
|
||||
<< ":" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
@ -23,7 +23,14 @@ namespace sls {
|
||||
|
||||
using defs = slsDetectorDefs;
|
||||
|
||||
inline std::string ToString(const defs::runStatus s){
|
||||
inline std::string ToString(const bool b) {
|
||||
if (b) {
|
||||
return std::string("enabled");
|
||||
}
|
||||
return std::string("disabled");
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::runStatus s) {
|
||||
switch (s) {
|
||||
case defs::ERROR:
|
||||
return std::string("error");
|
||||
@ -42,7 +49,7 @@ inline std::string ToString(const defs::runStatus s){
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::detectorType s){
|
||||
inline std::string ToString(const defs::detectorType s) {
|
||||
switch (s) {
|
||||
case defs::EIGER:
|
||||
return std::string("Eiger");
|
||||
@ -63,7 +70,7 @@ inline std::string ToString(const defs::detectorType s){
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::detectorSettings s){
|
||||
inline std::string ToString(const defs::detectorSettings s) {
|
||||
switch (s) {
|
||||
case defs::STANDARD:
|
||||
return std::string("standard");
|
||||
@ -100,7 +107,7 @@ inline std::string ToString(const defs::detectorSettings s){
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::speedLevel s){
|
||||
inline std::string ToString(const defs::speedLevel s) {
|
||||
switch (s) {
|
||||
case defs::FULL_SPEED:
|
||||
return std::string("full_speed");
|
||||
@ -113,7 +120,7 @@ inline std::string ToString(const defs::speedLevel s){
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::timingMode s){
|
||||
inline std::string ToString(const defs::timingMode s) {
|
||||
switch (s) {
|
||||
case defs::AUTO_TIMING:
|
||||
return std::string("auto");
|
||||
@ -128,7 +135,7 @@ inline std::string ToString(const defs::timingMode s){
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::frameDiscardPolicy s){
|
||||
inline std::string ToString(const defs::frameDiscardPolicy s) {
|
||||
switch (s) {
|
||||
case defs::NO_DISCARD:
|
||||
return std::string("nodiscard");
|
||||
@ -141,7 +148,7 @@ inline std::string ToString(const defs::frameDiscardPolicy s){
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::fileFormat s){
|
||||
inline std::string ToString(const defs::fileFormat s) {
|
||||
switch (s) {
|
||||
case defs::HDF5:
|
||||
return std::string("hdf5");
|
||||
@ -152,7 +159,7 @@ inline std::string ToString(const defs::fileFormat s){
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::externalSignalFlag s){
|
||||
inline std::string ToString(const defs::externalSignalFlag s) {
|
||||
switch (s) {
|
||||
case defs::TRIGGER_IN_RISING_EDGE:
|
||||
return std::string("trigger_in_rising_edge");
|
||||
@ -176,7 +183,7 @@ inline std::string ToString(const defs::readoutMode s){
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::frameModeType s){
|
||||
inline std::string ToString(const defs::frameModeType s) {
|
||||
switch (s) {
|
||||
case defs::PEDESTAL:
|
||||
return std::string("pedestal");
|
||||
@ -191,7 +198,7 @@ inline std::string ToString(const defs::frameModeType s){
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::detectorModeType s){
|
||||
inline std::string ToString(const defs::detectorModeType s) {
|
||||
switch (s) {
|
||||
case defs::COUNTING:
|
||||
return std::string("counting");
|
||||
@ -204,9 +211,47 @@ inline std::string ToString(const defs::detectorModeType s){
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string ToString(const defs::timerIndex t) {
|
||||
switch (t) {
|
||||
case defs::FRAME_NUMBER:
|
||||
return std::string("frame_number");
|
||||
case defs::ACQUISITION_TIME:
|
||||
return std::string("acquisition_time");
|
||||
case defs::FRAME_PERIOD:
|
||||
return std::string("frame_period");
|
||||
case defs::DELAY_AFTER_TRIGGER:
|
||||
return std::string("delay_after_trigger");
|
||||
case defs::TRIGGER_NUMBER:
|
||||
return std::string("triggers_number");
|
||||
case defs::ACTUAL_TIME:
|
||||
return std::string("actual_time");
|
||||
case defs::MEASUREMENT_TIME:
|
||||
return std::string("measurement_time");
|
||||
case defs::PROGRESS:
|
||||
return std::string("progress");
|
||||
case defs::FRAMES_FROM_START:
|
||||
return std::string("frames_from_start");
|
||||
case defs::FRAMES_FROM_START_PG:
|
||||
return std::string("frames_from_start_pg");
|
||||
case defs::ANALOG_SAMPLES:
|
||||
return std::string("analog_samples");
|
||||
case defs::DIGITAL_SAMPLES:
|
||||
return std::string("digital_samples");
|
||||
case defs::SUBFRAME_ACQUISITION_TIME:
|
||||
return std::string("subframe_acquisition_time");
|
||||
case defs::SUBFRAME_DEADTIME:
|
||||
return std::string("subframe_deadtime");
|
||||
case defs::STORAGE_CELL_NUMBER:
|
||||
return std::string("storage_cell_number");
|
||||
default:
|
||||
return std::string("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// in case we already have a string
|
||||
// causes a copy but might be needed in generic code
|
||||
inline std::string ToString(const std::string& s){
|
||||
inline std::string ToString(const std::string& s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -388,7 +433,7 @@ template <typename T> T StringTo(const std::string& t) {
|
||||
}
|
||||
|
||||
template <>
|
||||
inline defs::detectorType StringTo(const std::string& s){
|
||||
inline defs::detectorType StringTo(const std::string& s) {
|
||||
if (s == "Eiger")
|
||||
return defs::EIGER;
|
||||
if (s == "Gotthard")
|
||||
@ -407,7 +452,7 @@ inline defs::detectorType StringTo(const std::string& s){
|
||||
}
|
||||
|
||||
template <>
|
||||
inline defs::detectorSettings StringTo(const std::string& s){
|
||||
inline defs::detectorSettings StringTo(const std::string& s) {
|
||||
if (s == "standard")
|
||||
return defs::STANDARD;
|
||||
if (s == "fast")
|
||||
@ -525,6 +570,31 @@ inline defs::detectorModeType StringTo(const std::string& s) {
|
||||
throw sls::RuntimeError("Unknown detector mode " + s);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline defs::dacIndex StringTo(const std::string& s) {
|
||||
if (s == "vcmp_ll")
|
||||
return defs::E_Vcmp_ll;
|
||||
if (s == "vcmp_lr")
|
||||
return defs::E_Vcmp_lr;
|
||||
if (s == "vcmp_rl")
|
||||
return defs::E_Vcmp_rl;
|
||||
if (s == "vcmp_rr")
|
||||
return defs::E_Vcmp_rr;
|
||||
if (s == "vthreshold")
|
||||
return defs::THRESHOLD;
|
||||
if (s == "vrf")
|
||||
return defs::E_Vrf;
|
||||
if (s == "vrs")
|
||||
return defs::E_Vrs;
|
||||
if (s == "vtr")
|
||||
return defs::E_Vtr;
|
||||
if (s == "vcall")
|
||||
return defs::E_cal;
|
||||
if (s == "vcp")
|
||||
return defs::E_Vcp;
|
||||
throw sls::RuntimeError("Unknown dac Index " + s);
|
||||
}
|
||||
|
||||
/** For types with a .str() method use this for conversion */
|
||||
template <typename T>
|
||||
typename std::enable_if<has_str<T>::value, std::string>::type
|
||||
|
@ -560,104 +560,6 @@ format
|
||||
ANALOG /** < analog */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
/** returns string from enabled/disabled
|
||||
\param b true or false
|
||||
\returns string enabled, disabled
|
||||
*/
|
||||
static std::string stringEnable(bool b) {
|
||||
if (b)
|
||||
return std::string("enabled");
|
||||
else
|
||||
return std::string("disabled");
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/** returns std::string from timer index
|
||||
\param s can be FRAME_NUMBER,ACQUISITION_TIME,FRAME_PERIOD,
|
||||
DELAY_AFTER_TRIGGER, TRIGGER_NUMBER,
|
||||
ACTUAL_TIME,MEASUREMENT_TIME,
|
||||
PROGRESS,FRAMES_FROM_START,FRAMES_FROM_START_PG,ANALOG_SAMPLES,DIGITAL_SAMPLES,SUBFRAME_ACQUISITION_TIME,STORAGE_CELL_NUMBER,
|
||||
SUBFRAME_DEADTIME \returns std::string
|
||||
frame_number,acquisition_time,frame_period,
|
||||
delay_after_trigger, triggers_number,
|
||||
actual_time,measurement_time,
|
||||
progress,frames_from_start,frames_from_start_pg,analog_samples, digital_samples,subframe_acquisition_time,storage_cell_number,
|
||||
SUBFRAME_DEADTIME
|
||||
*/
|
||||
static std::string getTimerType(timerIndex t) {
|
||||
switch (t) {
|
||||
case FRAME_NUMBER:
|
||||
return std::string("frame_number");
|
||||
case ACQUISITION_TIME:
|
||||
return std::string("acquisition_time");
|
||||
case FRAME_PERIOD:
|
||||
return std::string("frame_period");
|
||||
case DELAY_AFTER_TRIGGER:
|
||||
return std::string("delay_after_trigger");
|
||||
case TRIGGER_NUMBER:
|
||||
return std::string("triggers_number");
|
||||
case ACTUAL_TIME:
|
||||
return std::string("actual_time");
|
||||
case MEASUREMENT_TIME:
|
||||
return std::string("measurement_time");
|
||||
case PROGRESS:
|
||||
return std::string("progress");
|
||||
case FRAMES_FROM_START:
|
||||
return std::string("frames_from_start");
|
||||
case FRAMES_FROM_START_PG:
|
||||
return std::string("frames_from_start_pg");
|
||||
case ANALOG_SAMPLES:
|
||||
return std::string("analog_samples");
|
||||
case DIGITAL_SAMPLES:
|
||||
return std::string("digital_samples");
|
||||
case SUBFRAME_ACQUISITION_TIME:
|
||||
return std::string("subframe_acquisition_time");
|
||||
case SUBFRAME_DEADTIME:
|
||||
return std::string("subframe_deadtime");
|
||||
case STORAGE_CELL_NUMBER:
|
||||
return std::string("storage_cell_number");
|
||||
default:
|
||||
return std::string("unknown");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@short returns dac index from std::string
|
||||
\param s can be vcmp_ll, vcmp_lr, vcmp_rl, vcmp_rr, vthreshold, vrf, vrs,
|
||||
vtr, vcall, vcp \returns E_Vcmp_ll, E_Vcmp_lr, E_Vcmp_rl, E_Vcmp_rr,
|
||||
THRESHOLD, E_Vrf, E_Vrs, E_Vtr, E_cal, E_Vcp , -1 when unknown mode
|
||||
*/
|
||||
static int getDACIndex(std::string s) {
|
||||
if (s == "vcmp_ll")
|
||||
return E_Vcmp_ll;
|
||||
if (s == "vcmp_lr")
|
||||
return E_Vcmp_lr;
|
||||
if (s == "vcmp_rl")
|
||||
return E_Vcmp_rl;
|
||||
if (s == "vcmp_rr")
|
||||
return E_Vcmp_rr;
|
||||
if (s == "vthreshold")
|
||||
return THRESHOLD;
|
||||
if (s == "vrf")
|
||||
return E_Vrf;
|
||||
if (s == "vrs")
|
||||
return E_Vrs;
|
||||
if (s == "vtr")
|
||||
return E_Vtr;
|
||||
if (s == "vcall")
|
||||
return E_cal;
|
||||
if (s == "vcp")
|
||||
return E_Vcp;
|
||||
return -1;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
protected:
|
||||
|
Loading…
x
Reference in New Issue
Block a user