mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
filter and cds gain, burst and continuous value to asic changed, bug fix to scanning function addresses in server_funcs.c
This commit is contained in:
@ -56,6 +56,8 @@ int64_t numTriggersReg = 1;
|
|||||||
int64_t delayReg = 0;
|
int64_t delayReg = 0;
|
||||||
int64_t numBurstsReg = 1;
|
int64_t numBurstsReg = 1;
|
||||||
int64_t burstPeriodReg = 0;
|
int64_t burstPeriodReg = 0;
|
||||||
|
int filter = 0;
|
||||||
|
int cdsGain = 0;
|
||||||
int detPos[2] = {};
|
int detPos[2] = {};
|
||||||
|
|
||||||
int isInitCheckDone() { return initCheckDone; }
|
int isInitCheckDone() { return initCheckDone; }
|
||||||
@ -369,6 +371,8 @@ void setupDetector() {
|
|||||||
delayReg = 0;
|
delayReg = 0;
|
||||||
numBurstsReg = 1;
|
numBurstsReg = 1;
|
||||||
burstPeriodReg = 0;
|
burstPeriodReg = 0;
|
||||||
|
filter = 0;
|
||||||
|
cdsGain = 0;
|
||||||
for (int i = 0; i < NUM_CLOCKS; ++i) {
|
for (int i = 0; i < NUM_CLOCKS; ++i) {
|
||||||
clkPhase[i] = 0;
|
clkPhase[i] = 0;
|
||||||
}
|
}
|
||||||
@ -450,6 +454,8 @@ void setupDetector() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setBurstMode(DEFAULT_BURST_MODE);
|
setBurstMode(DEFAULT_BURST_MODE);
|
||||||
|
setFilter(DEFAULT_FILTER);
|
||||||
|
setCDSGain(DEFAILT_CDS_GAIN);
|
||||||
setSettings(DEFAULT_SETTINGS);
|
setSettings(DEFAULT_SETTINGS);
|
||||||
|
|
||||||
// Initialization of acquistion parameters
|
// Initialization of acquistion parameters
|
||||||
@ -2088,9 +2094,19 @@ int setBurstMode(enum burstMode burst) {
|
|||||||
}
|
}
|
||||||
LOG(logINFO, ("\tDone Updating registers\n"))
|
LOG(logINFO, ("\tDone Updating registers\n"))
|
||||||
|
|
||||||
|
return configureASICGlobalSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
int configureASICGlobalSettings() {
|
||||||
LOG(logINFO, ("\tSetting %s Mode in Chip\n",
|
LOG(logINFO, ("\tSetting %s Mode in Chip\n",
|
||||||
burstMode == BURST_OFF ? "Continuous" : "Burst"));
|
burstMode == BURST_OFF ? "Continuous" : "Burst"));
|
||||||
int value = burstMode ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE;
|
int modeValue =
|
||||||
|
burstMode ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE;
|
||||||
|
int value = ((modeValue << ASIC_GLOBAL_MODE_OFST) & ASIC_GLOBAL_MODE_MSK) |
|
||||||
|
((filter << ASIC_FILTER_OFST) & ASIC_FILTER_MSK) |
|
||||||
|
((cdsGain << ASIC_CDS_GAIN_OFST) & ASIC_CDS_GAIN_MSK);
|
||||||
|
LOG(logINFO, ("\tsetting value:0x%x (mode:%d, filter:%d, cdsgain:%d)\n",
|
||||||
|
value, modeValue, filter, cdsGain));
|
||||||
|
|
||||||
const int padding = 6; // due to address (4) to make it byte aligned
|
const int padding = 6; // due to address (4) to make it byte aligned
|
||||||
const int lenTotalBits = padding + ASIC_GLOBAL_SETT_MAX_BITS +
|
const int lenTotalBits = padding + ASIC_GLOBAL_SETT_MAX_BITS +
|
||||||
@ -2151,6 +2167,30 @@ enum burstMode getBurstMode() {
|
|||||||
return burstMode;
|
return burstMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setCDSGain(int enable) {
|
||||||
|
if (enable >= 0) {
|
||||||
|
cdsGain = (enable == 0 ? 0 : 1);
|
||||||
|
LOG(logINFO,
|
||||||
|
("%s CDS Gain\n", (cdsGain == 0 ? "Disabling" : "Enabling")));
|
||||||
|
return configureASICGlobalSettings();
|
||||||
|
}
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getCDSGain() { return cdsGain; }
|
||||||
|
|
||||||
|
int setFilter(int value) {
|
||||||
|
if (value < 0 || value > ASIC_FILTER_MAX_VALUE) {
|
||||||
|
LOG(logERROR, ("Invalid filter value %d\n", value));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
filter = value;
|
||||||
|
LOG(logINFO, ("Setting Filter to %d\n", filter));
|
||||||
|
return configureASICGlobalSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
int getFilter() { return filter; }
|
||||||
|
|
||||||
void setCurrentSource(int value) {
|
void setCurrentSource(int value) {
|
||||||
uint32_t addr = ASIC_CONFIG_REG;
|
uint32_t addr = ASIC_CONFIG_REG;
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
/** Default Parameters */
|
/** Default Parameters */
|
||||||
#define DEFAULT_BURST_MODE (BURST_INTERNAL)
|
#define DEFAULT_BURST_MODE (BURST_INTERNAL)
|
||||||
|
#define DEFAULT_FILTER (0)
|
||||||
|
#define DEFAILT_CDS_GAIN (0)
|
||||||
#define DEFAULT_NUM_FRAMES (1)
|
#define DEFAULT_NUM_FRAMES (1)
|
||||||
#define DEFAULT_NUM_CYCLES (1)
|
#define DEFAULT_NUM_CYCLES (1)
|
||||||
#define DEFAULT_NUM_BURSTS (1)
|
#define DEFAULT_NUM_BURSTS (1)
|
||||||
@ -135,7 +137,14 @@ enum PLLINDEX { READOUT_PLL, SYSTEM_PLL };
|
|||||||
#define ASIC_ADC_MAX_VAL (0x7F)
|
#define ASIC_ADC_MAX_VAL (0x7F)
|
||||||
#define ASIC_GLOBAL_SETT_MAX_BITS (6)
|
#define ASIC_GLOBAL_SETT_MAX_BITS (6)
|
||||||
#define ASIC_GLOBAL_BURST_VALUE (0x0)
|
#define ASIC_GLOBAL_BURST_VALUE (0x0)
|
||||||
#define ASIC_GLOBAL_CONT_VALUE (0x1E)
|
#define ASIC_GLOBAL_CONT_VALUE (0x6)
|
||||||
|
#define ASIC_GLOBAL_MODE_OFST (0)
|
||||||
|
#define ASIC_GLOBAL_MODE_MSK (0x7 << ASIC_GLOBAL_MODE_OFST)
|
||||||
|
#define ASIC_FILTER_OFST (3)
|
||||||
|
#define ASIC_FILTER_MSK (0x3 << ASIC_FILTER_OFST)
|
||||||
|
#define ASIC_FILTER_MAX_VALUE (3)
|
||||||
|
#define ASIC_CDS_GAIN_OFST (5)
|
||||||
|
#define ASIC_CDS_GAIN_MSK (0x1 << ASIC_CDS_GAIN_OFST)
|
||||||
|
|
||||||
/* Struct Definitions */
|
/* Struct Definitions */
|
||||||
typedef struct udp_header_struct {
|
typedef struct udp_header_struct {
|
||||||
|
@ -509,7 +509,12 @@ int configureSingleADCDriver(int chipIndex);
|
|||||||
int configureADC();
|
int configureADC();
|
||||||
int setBurstModeinFPGA(enum burstMode value);
|
int setBurstModeinFPGA(enum burstMode value);
|
||||||
int setBurstMode(enum burstMode burst);
|
int setBurstMode(enum burstMode burst);
|
||||||
|
int configureASICGlobalSettings();
|
||||||
enum burstMode getBurstMode();
|
enum burstMode getBurstMode();
|
||||||
|
int setCDSGain(int enable);
|
||||||
|
int getCDSGain();
|
||||||
|
int setFilter(int value);
|
||||||
|
int getFilter();
|
||||||
void setCurrentSource(int value);
|
void setCurrentSource(int value);
|
||||||
int getCurrentSource();
|
int getCurrentSource();
|
||||||
void setTimingSource(enum timingSourceType value);
|
void setTimingSource(enum timingSourceType value);
|
||||||
|
@ -228,4 +228,8 @@ int set_veto(int);
|
|||||||
int set_pattern(int);
|
int set_pattern(int);
|
||||||
int get_scan(int);
|
int get_scan(int);
|
||||||
int set_scan(int);
|
int set_scan(int);
|
||||||
int get_scan_error_message(int);
|
int get_scan_error_message(int);
|
||||||
|
int get_cds_gain(int);
|
||||||
|
int set_cds_gain(int);
|
||||||
|
int get_filter(int);
|
||||||
|
int set_filter(int);
|
||||||
|
@ -343,9 +343,13 @@ void function_table() {
|
|||||||
flist[F_GET_VETO] = &get_veto;
|
flist[F_GET_VETO] = &get_veto;
|
||||||
flist[F_SET_VETO] = &set_veto;
|
flist[F_SET_VETO] = &set_veto;
|
||||||
flist[F_SET_PATTERN] = &set_pattern;
|
flist[F_SET_PATTERN] = &set_pattern;
|
||||||
flist[F_GET_SCAN] = get_scan;
|
flist[F_GET_SCAN] = &get_scan;
|
||||||
flist[F_SET_SCAN] = set_scan;
|
flist[F_SET_SCAN] = &set_scan;
|
||||||
flist[F_GET_SCAN_ERROR_MESSAGE] = get_scan_error_message;
|
flist[F_GET_SCAN_ERROR_MESSAGE] = &get_scan_error_message;
|
||||||
|
flist[F_GET_CDS_GAIN] = &get_cds_gain;
|
||||||
|
flist[F_SET_CDS_GAIN] = &set_cds_gain;
|
||||||
|
flist[F_GET_FILTER] = &get_filter;
|
||||||
|
flist[F_SET_FILTER] = &set_filter;
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||||
@ -637,8 +641,7 @@ int get_server_version(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int64_t retval = -1;
|
int64_t retval = -1;
|
||||||
retval = getServerVersion();
|
retval = getServerVersion();
|
||||||
LOG(logDEBUG1,
|
LOG(logDEBUG1, ("server version retval: 0x%llx\n", (long long int)retval));
|
||||||
("server version retval: 0x%llx\n", (long long int)retval));
|
|
||||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,8 +650,7 @@ int get_serial_number(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int64_t retval = -1;
|
int64_t retval = -1;
|
||||||
retval = getDetectorNumber();
|
retval = getDetectorNumber();
|
||||||
LOG(logDEBUG1,
|
LOG(logDEBUG1, ("detector number retval: 0x%llx\n", (long long int)retval));
|
||||||
("detector number retval: 0x%llx\n", (long long int)retval));
|
|
||||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7645,4 +7647,102 @@ int get_scan_error_message(int file_des) {
|
|||||||
LOG(logDEBUG1, ("scan retval err message: [%s]\n", retvals));
|
LOG(logDEBUG1, ("scan retval err message: [%s]\n", retvals));
|
||||||
|
|
||||||
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
|
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_cds_gain(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
|
LOG(logDEBUG1, ("Getting cds gain enable\n"));
|
||||||
|
|
||||||
|
#ifndef GOTTHARD2D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// get only
|
||||||
|
retval = getCDSGain();
|
||||||
|
LOG(logDEBUG1, ("cds gain enable retval: %u\n", retval));
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
|
}
|
||||||
|
|
||||||
|
int set_cds_gain(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int arg = 0;
|
||||||
|
|
||||||
|
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
LOG(logINFO, ("Setting cds gain enable: %u\n", arg));
|
||||||
|
|
||||||
|
#ifndef GOTTHARD2D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// only set
|
||||||
|
if (Server_VerifyLock() == OK) {
|
||||||
|
if (arg != 0 && arg != 1) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess,
|
||||||
|
"Could not set CDS gain. Invalid value %d. "
|
||||||
|
"Options [0-1]\n",
|
||||||
|
arg);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
setCDSGain(arg);
|
||||||
|
int retval = getCDSGain();
|
||||||
|
LOG(logDEBUG1, ("cds gain enable retval: %u\n", retval));
|
||||||
|
validate(arg, retval, "set cds gain enable", DEC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_filter(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
|
LOG(logDEBUG1, ("Getting filter\n"));
|
||||||
|
|
||||||
|
#ifndef GOTTHARD2D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// get only
|
||||||
|
retval = getFilter();
|
||||||
|
LOG(logDEBUG1, ("filter retval: %u\n", retval));
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
|
}
|
||||||
|
|
||||||
|
int set_filter(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int arg = 0;
|
||||||
|
|
||||||
|
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
LOG(logINFO, ("Setting filter: %u\n", arg));
|
||||||
|
|
||||||
|
#ifndef GOTTHARD2D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// only set
|
||||||
|
if (Server_VerifyLock() == OK) {
|
||||||
|
if (arg < 0 || arg > ASIC_FILTER_MAX_VALUE) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess,
|
||||||
|
"Could not set filter. Invalid filter %d. "
|
||||||
|
"Options [0-%d]\n",
|
||||||
|
arg, ASIC_FILTER_MAX_VALUE);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
setFilter(arg);
|
||||||
|
int retval = getFilter();
|
||||||
|
LOG(logDEBUG1, ("filter retval: %u\n", retval));
|
||||||
|
validate(arg, retval, "set filter", DEC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
}
|
||||||
|
@ -989,6 +989,18 @@ class Detector {
|
|||||||
/** [Gotthard2] BURST_OFF, BURST_INTERNAL (default), BURST_EXTERNAL */
|
/** [Gotthard2] BURST_OFF, BURST_INTERNAL (default), BURST_EXTERNAL */
|
||||||
void setBurstMode(defs::burstMode value, Positions pos = {});
|
void setBurstMode(defs::burstMode value, Positions pos = {});
|
||||||
|
|
||||||
|
/** [Gotthard2] */
|
||||||
|
Result<bool> getCDSGain(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/** default disabled */
|
||||||
|
void setCDSGain(bool value, Positions pos = {});
|
||||||
|
|
||||||
|
/** [Gotthard2] */
|
||||||
|
Result<int> getFilter(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/** default 0 */
|
||||||
|
void setFilter(int value, Positions pos = {});
|
||||||
|
|
||||||
/** [Gotthard2] */
|
/** [Gotthard2] */
|
||||||
Result<bool> getCurrentSource(Positions pos = {}) const;
|
Result<bool> getCurrentSource(Positions pos = {}) const;
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@
|
|||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
auto t = det->GETFCN(DAC_INDEX, mv, {det_id}); \
|
auto t = det->GETFCN(DAC_INDEX, mv, {det_id}); \
|
||||||
os << OutString(t) << (!args.empty() ? " mv\n" : "\n"); \
|
os << OutString(t) << (!args.empty() ? " mv\n" : "\n"); \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
bool mv = false; \
|
bool mv = false; \
|
||||||
if (args.size() == 2) { \
|
if (args.size() == 2) { \
|
||||||
@ -835,6 +835,8 @@ class CmdProxy {
|
|||||||
{"vetophoton", &CmdProxy::VetoPhoton},
|
{"vetophoton", &CmdProxy::VetoPhoton},
|
||||||
{"vetoref", &CmdProxy::VetoReference},
|
{"vetoref", &CmdProxy::VetoReference},
|
||||||
{"burstmode", &CmdProxy::BurstMode},
|
{"burstmode", &CmdProxy::BurstMode},
|
||||||
|
{"cdsgain", &CmdProxy::cdsgain},
|
||||||
|
{"filter", &CmdProxy::filter},
|
||||||
{"currentsource", &CmdProxy::currentsource},
|
{"currentsource", &CmdProxy::currentsource},
|
||||||
{"timingsource", &CmdProxy::timingsource},
|
{"timingsource", &CmdProxy::timingsource},
|
||||||
{"veto", &CmdProxy::veto},
|
{"veto", &CmdProxy::veto},
|
||||||
@ -1119,10 +1121,6 @@ class CmdProxy {
|
|||||||
"ns|us|ms|s]\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb]["
|
"ns|us|ms|s]\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb]["
|
||||||
"Moench] Delay after trigger");
|
"Moench] Delay after trigger");
|
||||||
|
|
||||||
TIME_COMMAND(burstperiod, getBurstPeriod, setBurstPeriod,
|
|
||||||
"[duration] [(optional unit) ns|us|ms|s]\n\t[Gotthard2] Burst "
|
|
||||||
"period. Only in burst mode and auto timing mode.");
|
|
||||||
|
|
||||||
GET_COMMAND(framesl, getNumberOfFramesLeft,
|
GET_COMMAND(framesl, getNumberOfFramesLeft,
|
||||||
"\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] "
|
"\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] "
|
||||||
"Number of frames left in acquisition."
|
"Number of frames left in acquisition."
|
||||||
@ -1906,6 +1904,18 @@ class CmdProxy {
|
|||||||
"timing mode and burst mode. Use timing command to set timing mode and "
|
"timing mode and burst mode. Use timing command to set timing mode and "
|
||||||
"burstmode command to set burst mode.");
|
"burstmode command to set burst mode.");
|
||||||
|
|
||||||
|
TIME_COMMAND(burstperiod, getBurstPeriod, setBurstPeriod,
|
||||||
|
"[duration] [(optional unit) ns|us|ms|s]\n\t[Gotthard2] Burst "
|
||||||
|
"period. Only in burst mode and auto timing mode.");
|
||||||
|
|
||||||
|
INTEGER_COMMAND(cdsgain, getCDSGain, setCDSGain, StringTo<bool>,
|
||||||
|
"[0, 1]\n\t[Gotthard2] Enable or disable CDS gain. Default "
|
||||||
|
"is disabled.");
|
||||||
|
|
||||||
|
INTEGER_COMMAND(
|
||||||
|
filter, getFilter, setFilter, StringTo<int>,
|
||||||
|
"[0|1|2|3]\n\t[Gotthard2] Set filter resistor. Default is 0.");
|
||||||
|
|
||||||
INTEGER_COMMAND(currentsource, getCurrentSource, setCurrentSource,
|
INTEGER_COMMAND(currentsource, getCurrentSource, setCurrentSource,
|
||||||
StringTo<int>,
|
StringTo<int>,
|
||||||
"[0, 1]\n\t[Gotthard2] Enable or disable current source. "
|
"[0, 1]\n\t[Gotthard2] Enable or disable current source. "
|
||||||
|
@ -1305,6 +1305,22 @@ void Detector::setBurstMode(defs::burstMode value, Positions pos) {
|
|||||||
pimpl->Parallel(&Module::setBurstMode, pos, value);
|
pimpl->Parallel(&Module::setBurstMode, pos, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result<bool> Detector::getCDSGain(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&Module::getCDSGain, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setCDSGain(bool value, Positions pos) {
|
||||||
|
pimpl->Parallel(&Module::setCDSGain, pos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<int> Detector::getFilter(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&Module::getFilter, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setFilter(int value, Positions pos) {
|
||||||
|
pimpl->Parallel(&Module::setFilter, pos, value);
|
||||||
|
}
|
||||||
|
|
||||||
Result<bool> Detector::getCurrentSource(Positions pos) const {
|
Result<bool> Detector::getCurrentSource(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getCurrentSource, pos);
|
return pimpl->Parallel(&Module::getCurrentSource, pos);
|
||||||
}
|
}
|
||||||
|
@ -1534,6 +1534,18 @@ void Module::setBurstMode(slsDetectorDefs::burstMode value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Module::getCDSGain() { return sendToDetector<int>(F_GET_CDS_GAIN); }
|
||||||
|
|
||||||
|
void Module::setCDSGain(bool value) {
|
||||||
|
sendToDetector(F_SET_CDS_GAIN, static_cast<int>(value), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Module::getFilter() { return sendToDetector<int>(F_GET_FILTER); }
|
||||||
|
|
||||||
|
void Module::setFilter(int value) {
|
||||||
|
sendToDetector(F_SET_FILTER, value, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
bool Module::getCurrentSource() {
|
bool Module::getCurrentSource() {
|
||||||
return sendToDetector<int>(F_GET_CURRENT_SOURCE);
|
return sendToDetector<int>(F_GET_CURRENT_SOURCE);
|
||||||
}
|
}
|
||||||
|
@ -375,6 +375,10 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setVetoReference(const int gainIndex, const int value);
|
void setVetoReference(const int gainIndex, const int value);
|
||||||
burstMode getBurstMode();
|
burstMode getBurstMode();
|
||||||
void setBurstMode(burstMode value);
|
void setBurstMode(burstMode value);
|
||||||
|
bool getCDSGain();
|
||||||
|
void setCDSGain(bool value);
|
||||||
|
int getFilter();
|
||||||
|
void setFilter(int value);
|
||||||
bool getCurrentSource();
|
bool getCurrentSource();
|
||||||
void setCurrentSource(bool value);
|
void setCurrentSource(bool value);
|
||||||
slsDetectorDefs::timingSourceType getTimingSource();
|
slsDetectorDefs::timingSourceType getTimingSource();
|
||||||
|
@ -374,6 +374,66 @@ TEST_CASE("burstmode", "[.cmd][.new]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("cdsgain", "[.cmd][.new]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
|
||||||
|
if (det_type == defs::GOTTHARD2) {
|
||||||
|
auto prev_val = det.getCDSGain();
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("cdsgain", {"1"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "cdsgain 1\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("cdsgain", {"0"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "cdsgain 0\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("cdsgain", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "cdsgain 0\n");
|
||||||
|
}
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
det.setCDSGain(prev_val[i], {i});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REQUIRE_THROWS(proxy.Call("cdsgain", {}, -1, GET));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("filter", "[.cmd][.new]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
|
||||||
|
if (det_type == defs::GOTTHARD2) {
|
||||||
|
auto prev_val = det.getFilter();
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("filter", {"1"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "filter 1\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("filter", {"0"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "filter 0\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("filter", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "filter 0\n");
|
||||||
|
}
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
det.setFilter(prev_val[i], {i});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REQUIRE_THROWS(proxy.Call("filter", {}, -1, GET));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("currentsource", "[.cmd][.new]") {
|
TEST_CASE("currentsource", "[.cmd][.new]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
|
@ -290,6 +290,7 @@ template <> defs::timingSourceType StringTo(const std::string &s);
|
|||||||
template <> uint32_t StringTo(const std::string &s);
|
template <> uint32_t StringTo(const std::string &s);
|
||||||
template <> uint64_t StringTo(const std::string &s);
|
template <> uint64_t StringTo(const std::string &s);
|
||||||
template <> int StringTo(const std::string &s);
|
template <> int StringTo(const std::string &s);
|
||||||
|
template <> bool StringTo(const std::string &s);
|
||||||
template <> int64_t StringTo(const std::string &s);
|
template <> int64_t StringTo(const std::string &s);
|
||||||
|
|
||||||
/** For types with a .str() method use this for conversion */
|
/** For types with a .str() method use this for conversion */
|
||||||
|
@ -203,6 +203,10 @@ enum detFuncs {
|
|||||||
F_GET_SCAN,
|
F_GET_SCAN,
|
||||||
F_SET_SCAN,
|
F_SET_SCAN,
|
||||||
F_GET_SCAN_ERROR_MESSAGE,
|
F_GET_SCAN_ERROR_MESSAGE,
|
||||||
|
F_GET_CDS_GAIN,
|
||||||
|
F_SET_CDS_GAIN,
|
||||||
|
F_GET_FILTER,
|
||||||
|
F_SET_FILTER,
|
||||||
|
|
||||||
NUM_DET_FUNCTIONS,
|
NUM_DET_FUNCTIONS,
|
||||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||||
@ -504,7 +508,10 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
|||||||
case F_GET_SCAN: return "F_GET_SCAN";
|
case F_GET_SCAN: return "F_GET_SCAN";
|
||||||
case F_SET_SCAN: return "F_SET_SCAN";
|
case F_SET_SCAN: return "F_SET_SCAN";
|
||||||
case F_GET_SCAN_ERROR_MESSAGE: return "F_GET_SCAN_ERROR_MESSAGE";
|
case F_GET_SCAN_ERROR_MESSAGE: return "F_GET_SCAN_ERROR_MESSAGE";
|
||||||
|
case F_GET_CDS_GAIN: return "F_GET_CDS_GAIN";
|
||||||
|
case F_SET_CDS_GAIN: return "F_SET_CDS_GAIN";
|
||||||
|
case F_GET_FILTER: return "F_GET_FILTER";
|
||||||
|
case F_SET_FILTER: return "F_SET_FILTER";
|
||||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||||
|
|
||||||
|
@ -891,6 +891,18 @@ template <> int StringTo(const std::string &s) {
|
|||||||
return std::stoi(s, nullptr, base);
|
return std::stoi(s, nullptr, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <> bool StringTo(const std::string &s) {
|
||||||
|
int i = std::stoi(s, nullptr, 10);
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
return false;
|
||||||
|
case 1:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
throw sls::RuntimeError("Unknown boolean. Expecting be 0 or 1.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <> int64_t StringTo(const std::string &s) {
|
template <> int64_t StringTo(const std::string &s) {
|
||||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||||
return std::stol(s, nullptr, base);
|
return std::stol(s, nullptr, base);
|
||||||
|
Reference in New Issue
Block a user