mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
gotthard2: on chip dacs
This commit is contained in:
@ -188,7 +188,7 @@
|
||||
return os.str(); \
|
||||
}
|
||||
|
||||
/** int with index, */
|
||||
/** int with index */
|
||||
#define INTEGER_IND_COMMAND(CMDNAME, GETFCN, SETFCN, CONV, INDEX, HLPSTR) \
|
||||
std::string CMDNAME(const int action) { \
|
||||
std::ostringstream os; \
|
||||
@ -214,6 +214,32 @@
|
||||
return os.str(); \
|
||||
}
|
||||
|
||||
/** int with user index */
|
||||
#define INTEGER_USER_IND_COMMAND(CMDNAME, GETFCN, SETFCN, CONV, INDEX, HLPSTR) \
|
||||
std::string CMDNAME(const int action) { \
|
||||
std::ostringstream os; \
|
||||
os << cmd << ' '; \
|
||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||
os << HLPSTR << '\n'; \
|
||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||
if (args.size() != 1) { \
|
||||
WrongNumberOfParameters(1); \
|
||||
} \
|
||||
auto t = det->GETFCN(INDEX, std::stoi(args[0]), {det_id}); \
|
||||
os << args [0] << ' ' << OutStringHex(t) << '\n'; \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (args.size() != 2) { \
|
||||
WrongNumberOfParameters(2); \
|
||||
} \
|
||||
auto val = CONV(args[1]); \
|
||||
det->SETFCN(INDEX, std::stoi(args[0]), val, {det_id}); \
|
||||
os << args[0] << ' ' << args[1] << '\n'; \
|
||||
} else { \
|
||||
throw sls::RuntimeError("Unknown action"); \
|
||||
} \
|
||||
return os.str(); \
|
||||
}
|
||||
|
||||
|
||||
/** dac */
|
||||
#define DAC_COMMAND(CMDNAME, GETFCN, SETFCN, DAC_INDEX, HLPSTR) \
|
||||
@ -634,7 +660,14 @@ class CmdProxy {
|
||||
{"dac", &CmdProxy::Dac},
|
||||
{"daclist", &CmdProxy::DacList},
|
||||
{"dacvalues", &CmdProxy::DacValues},
|
||||
|
||||
|
||||
/* on chip dacs */
|
||||
{"vchip_comp_fe", &CmdProxy::vchip_comp_fe},
|
||||
{"vchip_opa_1st", &CmdProxy::vchip_opa_1st},
|
||||
{"vchip_opa_fd", &CmdProxy::vchip_opa_fd},
|
||||
{"vchip_comp_adc", &CmdProxy::vchip_comp_adc},
|
||||
{"vchip_ref_comp_fe", &CmdProxy::vchip_ref_comp_fe},
|
||||
{"vchip_cs", &CmdProxy::vchip_cs},
|
||||
|
||||
/* acquisition */
|
||||
{"clearbusy", &CmdProxy::clearbusy},
|
||||
@ -866,6 +899,7 @@ class CmdProxy {
|
||||
std::string DacList(int action);
|
||||
std::string DacValues(int action);
|
||||
std::vector<std::string> DacCommands();
|
||||
std::string OnChipDac(int action);
|
||||
/* acquisition */
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
/* Receiver Config */
|
||||
@ -1195,6 +1229,27 @@ class CmdProxy {
|
||||
"[dac or mv value][(optional unit) mv] \n\t[Jungfrau] Dac for ??"); //TODO
|
||||
|
||||
|
||||
/* on chip dacs */
|
||||
INTEGER_USER_IND_COMMAND(vchip_comp_fe, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_COMP_FE,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for comparator current of analogue front end.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_opa_1st, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_OPA_1ST,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for opa current for driving the other DACs in chip.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_opa_fd, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_OPA_FD,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac current for CDS opa stage.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_comp_adc, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_COMP_ADC,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for comparator current of ADC.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_ref_comp_fe, getOnChipDAC, setOnChipDAC, stoiHex, defs::VREF_COMP_FE,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for reference voltage of the comparator of analogue front end.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_cs, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_CS,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for current injection into preamplifier.");
|
||||
|
||||
|
||||
|
||||
/* acquisition */
|
||||
|
||||
EXECUTE_SET_COMMAND_NOID(clearbusy, clearAcquiringFlag,
|
||||
|
@ -235,6 +235,12 @@ class Detector {
|
||||
|
||||
void setDAC(defs::dacIndex index, int value, bool mV, Positions pos = {});
|
||||
|
||||
/* [Gotthard2] */
|
||||
Result<int> getOnChipDAC(defs::dacIndex index, int chipIndex, Positions pos = {}) const;
|
||||
|
||||
/* [Gotthard2] */
|
||||
void setOnChipDAC(defs::dacIndex index, int chipIndex, int value, Positions pos = {});
|
||||
|
||||
Result<defs::timingMode> getTimingMode(Positions pos = {}) const;
|
||||
|
||||
/**
|
||||
|
@ -632,6 +632,12 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
*/
|
||||
int setDAC(int val, dacIndex index, int mV);
|
||||
|
||||
/* [Gotthard2] */
|
||||
int getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex);
|
||||
|
||||
/* [Gotthard2] */
|
||||
void setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex, int value);
|
||||
|
||||
/**
|
||||
* Get adc value
|
||||
* @param index adc(DAC) index
|
||||
|
@ -285,6 +285,14 @@ void Detector::setDAC(defs::dacIndex index, int value, bool mV, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setDAC, pos, value, index, mV);
|
||||
}
|
||||
|
||||
Result<int> Detector::getOnChipDAC(defs::dacIndex index, int chipIndex, Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getOnChipDAC, pos, index, chipIndex);
|
||||
}
|
||||
|
||||
void Detector::setOnChipDAC(defs::dacIndex index, int chipIndex, int value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setOnChipDAC, pos, index, chipIndex, value);
|
||||
}
|
||||
|
||||
Result<defs::timingMode> Detector::getTimingMode(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setTimingMode, pos,
|
||||
defs::GET_TIMING_MODE);
|
||||
|
@ -1510,6 +1510,20 @@ int slsDetector::setDAC(int val, dacIndex index, int mV) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
int slsDetector::getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex) {
|
||||
int args[]{static_cast<int>(index), chipIndex};
|
||||
int retval = -1;
|
||||
sendToDetector(F_GET_ON_CHIP_DAC, args, retval);
|
||||
FILE_LOG(logDEBUG1) << "On chip DAC " << index << " (chip index:" << chipIndex << "): " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex, int value) {
|
||||
int args[]{static_cast<int>(index), chipIndex, value};
|
||||
FILE_LOG(logDEBUG1) << "Setting On chip DAC " << index << " (chip index:" << chipIndex << ") to " << value;
|
||||
sendToDetector(F_SET_ON_CHIP_DAC, args, nullptr);
|
||||
}
|
||||
|
||||
int slsDetector::getADC(dacIndex index) {
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting ADC " << index;
|
||||
|
@ -9,6 +9,110 @@
|
||||
auto GET = slsDetectorDefs::GET_ACTION;
|
||||
auto PUT = slsDetectorDefs::PUT_ACTION;
|
||||
|
||||
TEST_CASE("vchip", "[.cmd]") {
|
||||
int prev_val = 0;
|
||||
|
||||
if (test::type == slsDetectorDefs::GOTTHARD2) {
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_comp_fe", GET)); // needs a chip index
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_comp_fe -1 0x400", GET)); // max val is 0x3ff
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_fe -1", GET, nullptr, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("vchip_comp_fe -1 "));
|
||||
prev_val = stoul(s, 0, 16);
|
||||
}
|
||||
{
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_fe -1 0x137", PUT));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_fe -1", GET, nullptr, oss));
|
||||
REQUIRE(oss.str() == "vchip_comp_fe -1 0x137\n");
|
||||
}
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_fe -1 " + sls::ToStringHex(prev_val), PUT));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_opa_1st", GET)); // needs a chip index
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_1st -1", GET, nullptr, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("vchip_opa_1st -1 "));
|
||||
prev_val = stoul(s, 0, 16);
|
||||
}
|
||||
{
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_1st -1 0x137", PUT));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_1st -1", GET, nullptr, oss));
|
||||
REQUIRE(oss.str() == "vchip_opa_1st -1 0x137\n");
|
||||
}
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_1st -1 " + sls::ToStringHex(prev_val), PUT));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_opa_fd", GET)); // needs a chip index
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_fd -1", GET, nullptr, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("vchip_opa_fd -1 "));
|
||||
prev_val = stoul(s, 0, 16);
|
||||
}
|
||||
{
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_fd -1 0x137", PUT));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_fd -1", GET, nullptr, oss));
|
||||
REQUIRE(oss.str() == "vchip_opa_fd -1 0x137\n");
|
||||
}
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_fd -1 " + sls::ToStringHex(prev_val), PUT));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_comp_adc", GET)); // needs a chip index
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_adc -1", GET, nullptr, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("vchip_comp_adc -1 "));
|
||||
prev_val = stoul(s, 0, 16);
|
||||
}
|
||||
{
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_adc -1 0x137", PUT));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_adc -1", GET, nullptr, oss));
|
||||
REQUIRE(oss.str() == "vchip_comp_adc -1 0x137\n");
|
||||
}
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_adc -1 " + sls::ToStringHex(prev_val), PUT));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_ref_comp_fe", GET)); // needs a chip index
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_ref_comp_fe -1", GET, nullptr, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("vchip_ref_comp_fe -1 "));
|
||||
prev_val = stoul(s, 0, 16);
|
||||
}
|
||||
{
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_ref_comp_fe -1 0x137", PUT));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_ref_comp_fe -1", GET, nullptr, oss));
|
||||
REQUIRE(oss.str() == "vchip_ref_comp_fe -1 0x137\n");
|
||||
}
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_ref_comp_fe -1 " + sls::ToStringHex(prev_val), PUT));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_cs", GET)); // needs a chip index
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_cs -1", GET, nullptr, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("vchip_cs -1 "));
|
||||
prev_val = stoul(s, 0, 16);
|
||||
}
|
||||
{
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_cs -1 0x137", PUT));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_cs -1", GET, nullptr, oss));
|
||||
REQUIRE(oss.str() == "vchip_cs -1 0x137\n");
|
||||
}
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_cs -1 " + sls::ToStringHex(prev_val), PUT));
|
||||
} else {
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_comp_fe", GET));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_opa_1st", GET));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_opa_fd", GET));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_comp_adc", GET));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_ref_comp_fe", GET));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_cs", GET));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TEST_CASE("dacs", "[.cmd]") {
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("daclist", GET));
|
||||
|
Reference in New Issue
Block a user