This commit is contained in:
maliakal_d 2021-08-10 17:26:26 +02:00
parent c716a87935
commit fce35e35a1
17 changed files with 486 additions and 78 deletions

View File

@ -65,6 +65,7 @@ This document describes the differences between 5.2.0 and 5.1.0 releases.
getAutoCompDisable->getAutoComparatorDisable
filter->filterResistor
setBottom->setFlipRows
currentsource expects currentsrcparameters structure instread of bool
3. Firmware Requirements
========================

View File

@ -106,8 +106,8 @@
#define CONFIG_V11_STATUS_STRG_CLL_OFST (12)
#define CONFIG_V11_STATUS_STRG_CLL_MSK (0x0000000F << CONFIG_V11_STATUS_STRG_CLL_OFST)
// CSM mode = high current (100%), low current (16%)
#define CONFIG_V11_STATUS_CRRNT_SRC_MODE_OFST (19)
#define CONFIG_V11_STATUS_CRRNT_SRC_MODE_MSK (0x00000001 << CONFIG_V11_STATUS_CRRNT_SRC_MODE_OFST)
#define CONFIG_V11_STATUS_CRRNT_SRC_LOW_OFST (19)
#define CONFIG_V11_STATUS_CRRNT_SRC_LOW_MSK (0x00000001 << CONFIG_V11_STATUS_CRRNT_SRC_LOW_OFST)
#define CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_OFST (21)
#define CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_MSK (0x00000001 << CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_OFST)
#define CONFIG_V11_STATUS_AUTO_MODE_OVRRD_OFST (23)
@ -247,8 +247,8 @@
#define CONFIG_V11_STRG_CLL_OFST (12)
#define CONFIG_V11_STRG_CLL_MSK (0x0000000F << CONFIG_V11_STRG_CLL_OFST)
// CSM mode = high current (100%), low current (16%)
#define CONFIG_V11_CRRNT_SRC_MODE_OFST (19)
#define CONFIG_V11_CRRNT_SRC_MODE_MSK (0x00000001 << CONFIG_V11_CRRNT_SRC_MODE_OFST)
#define CONFIG_V11_CRRNT_SRC_LOW_OFST (19)
#define CONFIG_V11_CRRNT_SRC_LOW_MSK (0x00000001 << CONFIG_V11_CRRNT_SRC_LOW_OFST)
#define CONFIG_V11_FLTR_RSSTR_SMLR_OFST (21)
#define CONFIG_V11_FLTR_RSSTR_SMLR_MSK (0x00000001 << CONFIG_V11_FLTR_RSSTR_SMLR_OFST)
#define CONFIG_V11_AUTO_MODE_OVRRD_OFST (23)

View File

@ -479,6 +479,7 @@ void setupDetector() {
setFilterResistor(DEFAULT_FILTER_RESISTOR);
setFilterCell(DEFAULT_FILTER_CELL);
}
disableCurrentSource();
}
int resetToDefaultDacs(int hardReset) {
@ -2084,6 +2085,90 @@ void setFilterCell(int iCell) {
LOG(logINFO, ("Setting Filter Cell to %d [Reg:0x%x]\n", iCell, bus_r(addr)));
}
void disableCurrentSource() {
LOG(logINFO, ("Disabling Current Source\n"));
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_ENBL_MSK);
}
void enableCurrentSource(int fix, uint64_t select, int normal) {
if (chipVersion == 11) {
LOG(logINFO, ("Enabling current source [fix:%d, select:%lld]\n", fix,
(long long int)select));
} else {
LOG(logINFO,
("Enabling current source [fix:%d, select:0x%llx, normal:%d]\n",
fix, (long long int)select, normal));
}
disableCurrentSource();
LOG(logINFO, ("\tSetting current source parameters\n"));
// fix
if (fix) {
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_CRRNT_SRC_CLMN_FIX_MSK);
} else {
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_CLMN_FIX_MSK);
}
if (chipVersion == 10) {
// select
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_CLMN_SLCT_MSK);
bus_w(DAQ_REG,
bus_r(DAQ_REG) | ((select << DAQ_CRRNT_SRC_CLMN_SLCT_OFST) &
DAQ_CRRNT_SRC_CLMN_SLCT_MSK));
} else {
// select
set64BitReg(select, CRRNT_SRC_COL_LSB_REG, CRRNT_SRC_COL_MSB_REG);
// normal
if (normal) {
bus_w(CONFIG_V11_REG,
bus_r(CONFIG_V11_REG) & ~CONFIG_V11_CRRNT_SRC_LOW_MSK);
} else {
bus_w(CONFIG_V11_REG,
bus_r(CONFIG_V11_REG) | CONFIG_V11_CRRNT_SRC_LOW_MSK);
}
}
// validating before enabling current source
if (getFixCurrentSource() != fix || getSelectCurrentSource() != select) {
LOG(logERROR,
("Could not set fix or select parameters for current source.\n"))
return;
}
// not validating normal because the status register might not update during
// acquisition
// enabling current source
LOG(logINFO, ("Enabling Current Source\n"));
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_CRRNT_SRC_ENBL_MSK);
}
int getCurrentSource() {
return ((bus_r(DAQ_REG) & DAQ_CRRNT_SRC_ENBL_MSK) >>
DAQ_CRRNT_SRC_ENBL_OFST);
}
int getFixCurrentSource() {
return ((bus_r(DAQ_REG) & DAQ_CRRNT_SRC_CLMN_FIX_MSK) >>
DAQ_CRRNT_SRC_CLMN_FIX_OFST);
}
int getNormalCurrentSource() {
if (getChipVersion() == 11) {
int low = ((bus_r(CONFIG_V11_STATUS_REG) &
CONFIG_V11_STATUS_CRRNT_SRC_LOW_MSK) >>
CONFIG_V11_STATUS_CRRNT_SRC_LOW_OFST);
return (low == 0 ? 1 : 0);
}
return -1;
}
uint64_t getSelectCurrentSource() {
if (chipVersion == 10) {
return ((bus_r(DAQ_REG) & DAQ_CRRNT_SRC_CLMN_SLCT_MSK) >>
DAQ_CRRNT_SRC_CLMN_SLCT_OFST);
} else {
return get64BitReg(CRRNT_SRC_COL_LSB_REG, CRRNT_SRC_COL_MSB_REG);
}
}
int getTenGigaFlowControl() {
return ((bus_r(CONFIG_REG) & CONFIG_ETHRNT_FLW_CNTRL_MSK) >>
CONFIG_ETHRNT_FLW_CNTRL_OFST);

View File

@ -123,6 +123,7 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
#define MAX_STORAGE_CELL_DLY_NS_VAL (ASIC_CTRL_EXPSRE_TMR_MAX_VAL)
#define ACQ_TIME_MIN_CLOCK (2)
#define ASIC_FILTER_MAX_RES_VALUE (1)
#define MAX_SELECT_CHIP10_VAL (63)
#define MAX_PHASE_SHIFTS (240)
#define BIT16_MASK (0xFFFF)

View File

@ -466,6 +466,12 @@ int setFilterResistor(int value);
int getFilterResistor();
int getFilterCell();
void setFilterCell(int iCell);
void disableCurrentSource();
void enableCurrentSource(int fix, uint64_t select, int normal);
int getCurrentSource();
int getFixCurrentSource();
int getNormalCurrentSource();
uint64_t getSelectCurrentSource();
// eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter
#elif EIGERD

View File

@ -6753,21 +6753,94 @@ int set_burst_period(int file_des) {
int set_current_source(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
uint64_t select = 0;
int args[3] = {-1, -1, -1};
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
LOG(logINFO, ("Setting current source enable: %u\n", arg));
if (receiveData(file_des, &select, sizeof(select), INT64) < 0)
return printSocketReadError();
int enable = args[0];
int fix = args[1];
int normal = args[2];
LOG(logDEBUG1, ("Setting current source [enable:%d, fix:%d, select:%lld, normal :%d]\n", enable, fix, (long long int)select, normal));
#ifndef GOTTHARD2D
#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
setCurrentSource(arg);
if (enable != 0 && enable != 1) {
ret = FAIL;
strcpy(mess,
"Could not enable/disable current source. Enable can be 0 or 1 only.\n");
LOG(logERROR, (mess));
}
// disable
else if (enable == 0 && (fix != -1 || normal != -1)) {
ret = FAIL;
strcpy(mess,
"Could not disable current source. Requires no parameters.\n");
LOG(logERROR, (mess));
}
// enable
else if (enable == 1) {
#ifdef GOTTHARD2D
// no parameters allowed
if (fix != -1 || normal != -1) {
ret = FAIL;
strcpy(mess,
"Could not enable current source. Fix and normal are invalid parameters for this detector.\n");
LOG(logERROR, (mess));
}
#else
int chipVersion = getChipVersion();
if (chipVersion == 11) {
// require both
if ((fix != 0 && fix != -1) || (normal != 0 && normal != 1)) {
ret = FAIL;
strcpy(mess,
"Could not enable current source. Invalid value for parameters (fix or normal). Options: 0 or 1.\n");
LOG(logERROR, (mess));
}
}
// chipv1.0
else {
// require only fix
if (fix != 0 && fix != -1) {
ret = FAIL;
strcpy(mess,
"Could not enable current source. Invalid value for parameter (fix). Options: 0 or 1.\n");
LOG(logERROR, (mess));
} else if (normal != -1) {
ret = FAIL;
strcpy(mess,
"Could not enable current source. Invalid parmaeter (normal). Require only fix and select for chipv1.0.\n");
LOG(logERROR, (mess));
}
// select can only be 0-63
else if (select > MAX_SELECT_CHIP10_VAL) {
ret = FAIL;
strcpy(mess,
"Could not enable current source. Invalid value for parameter (select). Options: 0-63.\n");
LOG(logERROR, (mess));
}
}
#endif
}
#ifdef JUNGFRAUD
if (enable == 0) {
disableCurrentSource();
} else {
enableCurrentSource(fix, select, normal);
}
#else
setCurrentSource(enable);
#endif
int retval = getCurrentSource();
LOG(logDEBUG1, ("current source enable retval: %u\n", retval));
validate(&ret, mess, arg, retval, "set current source enable", DEC);
validate(&ret, mess, enable, retval, "set current source enable", DEC);
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
@ -6776,18 +6849,30 @@ int set_current_source(int file_des) {
int get_current_source(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
int retvals[3] = {-1, -1, -1};
uint64_t retval_select = 0;
LOG(logDEBUG1, ("Getting current source enable\n"));
LOG(logDEBUG1, ("Getting current source\n"));
#ifndef GOTTHARD2D
#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
functionNotImplemented();
#else
// get only
retval = getCurrentSource();
LOG(logDEBUG1, ("current source enable retval: %u\n", retval));
retvals[0] = getCurrentSource();
LOG(logDEBUG1, ("current source enable retval: %u\n", retvals[0]));
#ifdef JUNGFRAUD
retvals[1] = getFixCurrentSource();
retvals[2] = getNormalCurrentSource();
retval_select = getSelectCurrentSource();
LOG(logDEBUG1, ("current source parameters retval: [fix:%d, normal:%d, select:%lld]\n", retvals[1], retvals[2], retval_select));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
#endif
Server_SendResult(file_des, INT32, NULL, 0);
if (ret != FAIL) {
sendData(file_des, retvals, sizeof(retvals), INT32);
sendData(file_des, &retval_select, sizeof(retval_select), INT64);
}
return ret;
}
int set_timing_source(int file_des) {

View File

@ -488,6 +488,14 @@ class Detector {
* 0.\n[Jungfrau] Options: [0|1]. Default is 1.*/
void setFilterResistor(int value, Positions pos = {});
/** [Gotthard2][Jungfrau] */
Result<defs::currentSrcParameters>
getCurrentSource(Positions pos = {}) const;
/** [Gotthard2][Jungfrau] Please refer documentation on currentSrcParameters
* (sls_detector_defs.h) on the structure and its members */
void setCurrentSource(defs::currentSrcParameters par, Positions pos = {});
///@{
/** @name Acquisition */
@ -1300,12 +1308,6 @@ class Detector {
/** default disabled */
void setCDSGain(bool value, Positions pos = {});
/** [Gotthard2] */
Result<bool> getCurrentSource(Positions pos = {}) const;
/** default disabled */
void setCurrentSource(bool value, Positions pos = {});
/** [Gotthard2] */
Result<defs::timingSourceType> getTimingSource(Positions pos = {}) const;

View File

@ -959,6 +959,69 @@ std::string CmdProxy::ExternalSignal(int action) {
return os.str();
}
std::string CmdProxy::CurrentSource(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[0|1]\n\t[Gotthard2] Enable or disable current source. Default "
"is disabled.\n[0|1] [fix|nofix] [select source] "
"[normal|low]\n\t[Jungfrau] Disable or enable current source "
"with some parameters. The select source is 0-63 for chipv1.0 "
"and a 64 bit mask for chipv1.1. To disable, one needs only one "
"argument '0'."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() != 0) {
WrongNumberOfParameters(0);
}
auto t = det->getCurrentSource(std::vector<int>{det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() == 1) {
det->setCurrentsource(
defs::currentSrcParameters(StringTo<bool>(args[0])));
} else if (args.size() >= 3) {
// scan fix
bool fix = false;
if (args[1] == "fix") {
fix = true;
} else if (args[1] == "nofix") {
fix = false;
} else {
throw sls::RuntimeError("Invalid argument: " + args[1] +
". Did you mean fix or nofix?");
}
if (args.size() == 3) {
det->setCurrentsource(defs::currentSrcParameters(
StringTo<bool>(args[0]), fix, StringTo<int64_t>(args[2])));
} else if (args.size() == 4) {
bool normalCurrent = false;
if (args[3] == "normal") {
normalCurrent = true;
} else if (args[3] == "low") {
normalCurrent = false;
} else {
throw sls::RuntimeError("Invalid argument: " + args[3] +
". Did you mean normal or low?");
}
det->setCurrentsource(defs::currentSrcParameters(
StringTo<bool>(args[0]), fix, StringTo<int64_t>(args[2]),
normalCurrent));
} else {
throw sls::RuntimeError(
"Invalid number of parareters for this command.");
}
} else {
throw sls::RuntimeError(
"Invalid number of parareters for this command.");
}
os << ToString(args) << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/** temperature */
std::string CmdProxy::TemperatureValues(int action) {
std::ostringstream os;

View File

@ -803,6 +803,7 @@ class CmdProxy {
{"extsig", &CmdProxy::ExternalSignal},
{"parallel", &CmdProxy::parallel},
{"filterresistor", &CmdProxy::filterresistor},
{"currentsource", &CmdProxy::CurrentSource},
/** temperature */
{"templist", &CmdProxy::templist},
@ -951,7 +952,6 @@ class CmdProxy {
{"vetofile", &CmdProxy::VetoFile},
{"burstmode", &CmdProxy::BurstMode},
{"cdsgain", &CmdProxy::cdsgain},
{"currentsource", &CmdProxy::currentsource},
{"timingsource", &CmdProxy::timingsource},
{"veto", &CmdProxy::veto},
{"vetostream", &CmdProxy::VetoStreaming},
@ -1097,6 +1097,7 @@ class CmdProxy {
std::string MaxClockPhaseShift(int action);
std::string ClockDivider(int action);
std::string ExternalSignal(int action);
std::string CurrentSource(int action);
/** temperature */
std::string TemperatureValues(int action);
/* dacs */
@ -1921,11 +1922,6 @@ class CmdProxy {
"[0, 1]\n\t[Gotthard2] Enable or disable CDS gain. Default "
"is disabled.");
INTEGER_COMMAND_VEC_ID(
currentsource, getCurrentSource, setCurrentSource, StringTo<int>,
"[0, 1]\n\t[Gotthard2] Enable or disable current source. "
"Default is disabled.");
INTEGER_COMMAND_VEC_ID(
timingsource, getTimingSource, setTimingSource,
sls::StringTo<slsDetectorDefs::timingSourceType>,

View File

@ -707,6 +707,14 @@ void Detector::setFilterResistor(int value, Positions pos) {
pimpl->Parallel(&Module::setFilterResistor, pos, value);
}
Result<defs::currentSrcParameters>
Detector::getCurrentSource(Positions pos) const {
return pimpl->Parallel(&Module::getCurrentSource, pos);
}
void Detector::setCurrentSource(defs::currentSrcParameters par, Positions pos) {
pimpl->Parallel(&Module::setCurrentSource, pos, par);
}
// Acquisition
void Detector::acquire() { pimpl->acquire(); }
@ -1620,14 +1628,6 @@ void Detector::setCDSGain(bool value, Positions pos) {
pimpl->Parallel(&Module::setCDSGain, pos, value);
}
Result<bool> Detector::getCurrentSource(Positions pos) const {
return pimpl->Parallel(&Module::getCurrentSource, pos);
}
void Detector::setCurrentSource(bool value, Positions pos) {
pimpl->Parallel(&Module::setCurrentSource, pos, value);
}
Result<defs::timingSourceType> Detector::getTimingSource(Positions pos) const {
return pimpl->Parallel(&Module::getTimingSource, pos);
}

View File

@ -712,6 +712,14 @@ void Module::setFilterResistor(int value) {
sendToDetector(F_SET_FILTER_RESISTOR, value, nullptr);
}
defs::currentSrcParameters Module::getCurrentSource() const {
return sendToDetector<defs::currentSrcParameters>(F_GET_CURRENT_SOURCE);
}
void Module::setCurrentSource(defs::currentSrcParameters par) {
sendToDetector(F_SET_CURRENT_SOURCE, par, nullptr);
}
// Acquisition
void Module::startReceiver() {
@ -1914,14 +1922,6 @@ void Module::setCDSGain(bool value) {
sendToDetector(F_SET_CDS_GAIN, static_cast<int>(value), nullptr);
}
bool Module::getCurrentSource() const {
return sendToDetector<int>(F_GET_CURRENT_SOURCE);
}
void Module::setCurrentSource(bool value) {
sendToDetector(F_SET_CURRENT_SOURCE, static_cast<int>(value), nullptr);
}
slsDetectorDefs::timingSourceType Module::getTimingSource() const {
return sendToDetector<timingSourceType>(F_GET_TIMING_SOURCE);
}

View File

@ -172,7 +172,8 @@ class Module : public virtual slsDetectorDefs {
void setParallelMode(const bool enable);
int getFilterResistor() const;
void setFilterResistor(int value);
defs::currentSrcParameters getCurrentSource() const;
void setCurrentSource(defs::currentSrcParameters par);
/**************************************************
* *
* Acquisition *
@ -412,8 +413,6 @@ class Module : public virtual slsDetectorDefs {
void setBurstMode(burstMode value);
bool getCDSGain() const;
void setCDSGain(bool value);
bool getCurrentSource() const;
void setCurrentSource(bool value);
slsDetectorDefs::timingSourceType getTimingSource() const;
void setTimingSource(slsDetectorDefs::timingSourceType value);
bool getVeto() const;

View File

@ -519,36 +519,6 @@ TEST_CASE("cdsgain", "[.cmd]") {
}
}
TEST_CASE("currentsource", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
auto prev_val = det.getCurrentSource();
{
std::ostringstream oss;
proxy.Call("currentsource", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "currentsource 1\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "currentsource 0\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {}, -1, GET, oss);
REQUIRE(oss.str() == "currentsource 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setCurrentSource(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("currentsource", {}, -1, GET));
}
}
TEST_CASE("timingsource", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);

View File

@ -1423,6 +1423,134 @@ TEST_CASE("filterresistor", "[.cmd]") {
}
}
TEST_CASE("currentsource", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2 || detType == defs::Jungfrau) {
auto prev_val = det.getCurrentSource();
if (det_type == defs::GOTTHARD2) {
{
std::ostringstream oss;
proxy.Call("currentsource", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "currentsource 1\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "currentsource 0\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {}, -1, GET, oss);
REQUIRE(oss.str() == "currentsource 0\n");
}
REQUIRE_THROWS(
proxy.Call("currentsource", {"1", "fix", "42"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("currentsource",
{"1", "fix", "42", "normal"}, -1, PUT));
}
// jungfrau
else {
auto chipVersion = det.getChipVersion().tsquash(
"inconsistent chip versions to test");
if (chipVersion == 10) {
REQUIRE_THROWS(proxy.Call("currentsource", {"1"}, -1, PUT));
REQUIRE_THROWS(
proxy.Call("currentsource", {"1", "fix"}, -1, PUT));
REQUIRE_THROWS(
proxy.Call("currentsource", {"1", "fix", 64}, -1, PUT));
REQUIRE_THROWS(
proxy.Call("currentsource", {"1", "dfg", 64}, -1, PUT));
REQUIRE_THROWS(proxy.Call("currentsource",
{"1", "fix", 63, "normal"}, -1, PUT));
{
std::ostringstream oss;
proxy.Call("currentsource", {"1", "fix", "63"}, -1, PUT,
oss);
REQUIRE(oss.str() == "currentsource [1, fix, 63]\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "currentsource 0\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {}, -1, GET, oss);
REQUIRE(oss.str() == "currentsource [disabled]\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {"1", "nofix", "63"}, -1, PUT,
oss);
REQUIRE(oss.str() == "currentsource [1, nofix, 63]\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {}, -1, GET, oss);
REQUIRE(oss.str() ==
"currentsource [enabled, nofix, 63]\n");
}
}
// chipv1.1
else {
REQUIRE_THROWS(proxy.Call("currentsource", {"1"}, -1, PUT));
REQUIRE_THROWS(
proxy.Call("currentsource", {"1", "fix"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("currentsource",
{"1", "ffgdfgix", 65}, -1, PUT));
REQUIRE_THROWS(proxy.Call(
"currentsource", {"1", "fix", 65, "normaldgf"}, -1, PUT));
{
std::ostringstream oss;
proxy.Call("currentsource", {"1", "fix", "65", "normal"},
-1, PUT, oss);
REQUIRE(oss.str() ==
"currentsource [1, fix, 65, normal]\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "currentsource 0\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {}, -1, GET, oss);
REQUIRE(oss.str() == "currentsource [disabled]\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {"1", "nofix", "65", "normal"},
-1, PUT, oss);
REQUIRE(oss.str() ==
"currentsource [1, nofix, 65, normal]\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {}, -1, GET, oss);
REQUIRE(oss.str() ==
"currentsource [enabled, nofix, 65, normal]\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {"1", "nofix", "65", "low"}, -1,
PUT, oss);
REQUIRE(oss.str() == "currentsource [1, nofix, 65, low]\n");
}
}
}
for (int i = 0; i != det.size(); ++i) {
det.setCurrentSource(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("currentsource", {}, -1, GET));
}
}
/** temperature */
TEST_CASE("templist", "[.cmd]") {

View File

@ -52,7 +52,12 @@ std::ostream &operator<<(std::ostream &os,
std::string ToString(const slsDetectorDefs::scanParameters &r);
std::ostream &operator<<(std::ostream &os,
const slsDetectorDefs::scanParameters &r);
std::string ToString(const slsDetectorDefs::currentSrcParameters &r);
std::ostream &operator<<(std::ostream &os,
const slsDetectorDefs::currentSrcParameters &r);
const std::string &ToString(const std::string &s);
/** Convert std::chrono::duration with specified output unit */
template <typename T, typename Rep = double>
typename std::enable_if<is_duration<T>::value, std::string>::type

View File

@ -456,6 +456,39 @@ typedef struct {
}
} __attribute__((packed));
struct currentSrcParameters {
int enable;
int fix;
int normal;
uint64_t select;
/** [Gotthard2][Jungfrau] disable */
currentSrcParameters() : enable(0), fix(-1), normal(-1), select(0) {}
/** [Gotthard2] enable */
currentSrcParameters(bool ena)
: enable(static_cast<int>(ena)), fix(-1), normal(-1), select(0) {}
/** [Jungfrau](chipv1.0) enable current src with fix or no fix,
* selectColumn is 0 to 63 columns only */
currentSrcParameters(bool fixCurrent, uint64_t selectColumn)
: enable(1), fix(static_cast<int>(fixCurrent)), normal(-1),
select(selectColumn) {}
/** [Jungfrau](chipv1.1) enable current src, fixCurrent[fix|no fix],
* selectColumn is a mask of 63 bits (muliple columns can be selected
* simultaneously, normalCurrent [normal|low] */
currentSrcParameters(bool fixCurrent, uint64_t selectColumn,
bool normalCurrent)
: enable(1), fix(static_cast<int>(fixCurrent)),
normal(static_cast<int>(normalCurrent)), select(selectColumn) {}
bool operator==(const currentSrcParameters &other) const {
return ((enable == other.enable) && (fix == other.fix) &&
(normal == other.normal) && (select == other.select));
}
} __attribute__((packed));
/**
* structure to udpate receiver
*/

View File

@ -114,6 +114,40 @@ std::ostream &operator<<(std::ostream &os,
return os << ToString(r);
}
std::string ToString(const slsDetectorDefs::currentSrcParameters &r) {
std::ostringstream oss;
if (r.fix < -1 || r.fix > 1 || r.normal < -1 || r.normal > 1) {
throw sls::RuntimeError(
"Invalid current source parameters. Cannot print.");
}
oss << '[';
if (r.enable) {
oss << "enabled" << std::endl;
// [jungfrau]
if (r.fix != -1) {
oss << (r.fix == 1 ? "fix" : "nofix") << std::endl;
}
// [jungfrau chip v1.1]
if (r.normal != -1) {
oss << (r.normal == 1 ? "normal" : "low") << std::endl;
oss << "select: " << ToStringHex(r.select, 16) << std::endl;
}
// [jungfrau chip v1.0]
else {
oss << "select: " << r.select << std::endl;
}
} else {
oss << "disabled";
}
oss << ']';
return oss.str();
}
std::ostream &operator<<(std::ostream &os,
const slsDetectorDefs::currentSrcParameters &r) {
return os << ToString(r);
}
std::string ToString(const defs::runStatus s) {
switch (s) {
case defs::ERROR: