mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00
Merge pull request #286 from slsdetectorgroup/j14filtercell
Jungfrau features: 14. Filter cell
This commit is contained in:
commit
c716a87935
@ -2254,6 +2254,21 @@ class Detector(CppDetectorApi):
|
||||
def filterresistor(self, value):
|
||||
ut.set_using_dict(self.setFilterResistor, value)
|
||||
|
||||
@property
|
||||
@element
|
||||
def filtercell(self):
|
||||
"""
|
||||
[Jungfrau] Set filter capacitor.
|
||||
Note
|
||||
----
|
||||
[Jungfrau] Options: 0-12. Default: 0. Advanced user command.
|
||||
"""
|
||||
return self.getFilterCell()
|
||||
|
||||
@filtercell.setter
|
||||
def filtercell(self, value):
|
||||
ut.set_using_dict(self.setFilterCell, value)
|
||||
|
||||
@property
|
||||
def maxclkphaseshift(self):
|
||||
"""
|
||||
|
@ -1104,6 +1104,14 @@ void init_det(py::module &m) {
|
||||
(void (Detector::*)(int, sls::Positions)) &
|
||||
Detector::setFilterResistor,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getFilterCell",
|
||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getFilterCell,
|
||||
py::arg() = Positions{})
|
||||
.def("setFilterCell",
|
||||
(void (Detector::*)(int, sls::Positions)) &
|
||||
Detector::setFilterCell,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getCurrentSource",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getCurrentSource,
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -475,7 +475,10 @@ void setupDetector() {
|
||||
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
|
||||
setTemperatureEvent(0);
|
||||
setFlipRows(DEFAULT_FLIP_ROWS);
|
||||
if (getChipVersion() == 11) {
|
||||
setFilterResistor(DEFAULT_FILTER_RESISTOR);
|
||||
setFilterCell(DEFAULT_FILTER_CELL);
|
||||
}
|
||||
}
|
||||
|
||||
int resetToDefaultDacs(int hardReset) {
|
||||
@ -2055,6 +2058,32 @@ int setFilterResistor(int value) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int getFilterCell() {
|
||||
#ifdef VIRTUAL
|
||||
uint32_t addr = CONFIG_V11_REG;
|
||||
#else
|
||||
uint32_t addr = CONFIG_V11_STATUS_REG;
|
||||
#endif
|
||||
uint32_t value = (bus_r(addr) & CONFIG_V11_FLTR_CLL_MSK) >> CONFIG_V11_FLTR_CLL_OFST;
|
||||
// count number of bits = which icell
|
||||
return (__builtin_popcount(value));
|
||||
}
|
||||
|
||||
void setFilterCell(int iCell) {
|
||||
uint32_t value = 0;
|
||||
// sets the corresponding cell and the cells before it
|
||||
if (iCell != 0) {
|
||||
value = iCell;
|
||||
if (value > 1) {
|
||||
value += (value - 1);
|
||||
}
|
||||
}
|
||||
uint32_t addr = CONFIG_V11_REG;
|
||||
bus_w(addr, bus_r(addr) &~ CONFIG_V11_FLTR_CLL_MSK);
|
||||
bus_w(addr, bus_r(addr) | ((value << CONFIG_V11_FLTR_CLL_OFST) & CONFIG_V11_FLTR_CLL_MSK));
|
||||
LOG(logINFO, ("Setting Filter Cell to %d [Reg:0x%x]\n", iCell, bus_r(addr)));
|
||||
}
|
||||
|
||||
int getTenGigaFlowControl() {
|
||||
return ((bus_r(CONFIG_REG) & CONFIG_ETHRNT_FLW_CNTRL_MSK) >>
|
||||
CONFIG_ETHRNT_FLW_CNTRL_OFST);
|
||||
|
@ -107,11 +107,13 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
|
||||
#define DEFAULT_STRG_CLL_DLY (0)
|
||||
#define DEFAULT_FLIP_ROWS (0)
|
||||
#define DEFAULT_FILTER_RESISTOR (1) // higher resistor
|
||||
#define DEFAULT_FILTER_CELL (0)
|
||||
|
||||
#define HIGHVOLTAGE_MIN (60)
|
||||
#define HIGHVOLTAGE_MAX (200)
|
||||
#define DAC_MIN_MV (0)
|
||||
#define DAC_MAX_MV (2500)
|
||||
#define MAX_FILTER_CELL_VAL (12)
|
||||
|
||||
/* Defines in the Firmware */
|
||||
#define MAX_TIMESLOT_VAL (0x1F)
|
||||
|
Binary file not shown.
Binary file not shown.
@ -2573,6 +2573,7 @@ int setChipStatusRegister(int csr) {
|
||||
}
|
||||
|
||||
int setGainCaps(int caps) {
|
||||
LOG(logINFO, ("Setting gain caps to: %u\n", caps));
|
||||
// Update only gain caps, leave the rest of the CSR unchanged
|
||||
int csr = getChipStatusRegister();
|
||||
csr &= ~GAIN_MASK;
|
||||
|
@ -464,6 +464,8 @@ int getFlipRows();
|
||||
void setFlipRows(int arg);
|
||||
int setFilterResistor(int value);
|
||||
int getFilterResistor();
|
||||
int getFilterCell();
|
||||
void setFilterCell(int iCell);
|
||||
|
||||
// eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter
|
||||
#elif EIGERD
|
||||
|
@ -263,3 +263,5 @@ int get_comp_disable_time(int);
|
||||
int set_comp_disable_time(int);
|
||||
int get_flip_rows(int);
|
||||
int set_flip_rows(int);
|
||||
int get_filter_cell(int);
|
||||
int set_filter_cell(int);
|
@ -388,6 +388,8 @@ void function_table() {
|
||||
flist[F_SET_COMP_DISABLE_TIME] = &set_comp_disable_time;
|
||||
flist[F_GET_FLIP_ROWS] = &get_flip_rows;
|
||||
flist[F_SET_FLIP_ROWS] = &set_flip_rows;
|
||||
flist[F_GET_FILTER_CELL] = &get_filter_cell;
|
||||
flist[F_SET_FILTER_CELL] = &set_filter_cell;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
@ -8243,7 +8245,7 @@ int set_gain_caps(int file_des) {
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting gain caps to: %u\n", arg));
|
||||
LOG(logDEBUG1, ("Setting gain caps to: %u\n", arg));
|
||||
|
||||
int retval = -1;
|
||||
|
||||
@ -8389,7 +8391,7 @@ int set_veto_stream(int file_des) {
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting vetostream: %u\n", (int)arg));
|
||||
LOG(logDEBUG1, ("Setting vetostream: %u\n", (int)arg));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
@ -8450,7 +8452,7 @@ int set_veto_algorithm(int file_des) {
|
||||
|
||||
enum vetoAlgorithm alg = args[0];
|
||||
enum streamingInterface interface = args[1];
|
||||
LOG(logINFO, ("Setting vetoalgorithm (interface: %d): %u\n", (int)interface,
|
||||
LOG(logDEBUG1, ("Setting vetoalgorithm (interface: %d): %u\n", (int)interface,
|
||||
(int)alg));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
@ -8614,7 +8616,7 @@ int set_gain_mode(int file_des) {
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
enum gainMode gainmode = arg;
|
||||
LOG(logINFO, ("Setting gain mode %d\n", (int)gainmode));
|
||||
LOG(logDEBUG1, ("Setting gain mode %d\n", (int)gainmode));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
@ -8730,7 +8732,7 @@ int set_flip_rows(int file_des) {
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting flip rows: %u\n", (int)arg));
|
||||
LOG(logDEBUG1, ("Setting flip rows: %u\n", (int)arg));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
@ -8766,3 +8768,58 @@ int set_flip_rows(int file_des) {
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
int get_filter_cell(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
|
||||
LOG(logDEBUG1, ("Getting filter cell\n"));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = getFilterCell();
|
||||
LOG(logDEBUG1, ("filter cell retval: %u\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_filter_cell(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = -1;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Setting filter cell: %u\n", (int)arg));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
|
||||
if (arg < 0 || arg > MAX_FILTER_CELL_VAL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set filter cell. Invalid argument %d. Options: 0 - %d\n",
|
||||
arg, MAX_FILTER_CELL_VAL);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
// only for chipv1.1
|
||||
else if (getChipVersion() == 10) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not set filter cell. Only available for "
|
||||
"chip version 1.1\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
setFilterCell(arg);
|
||||
// no validation as it might take time to update status register if acquiring
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
@ -1199,6 +1199,13 @@ class Detector {
|
||||
*/
|
||||
void setGainMode(const defs::gainMode mode, Positions pos = {});
|
||||
|
||||
/** [Jungfrau] Advanced */
|
||||
Result<int> getFilterCell(Positions pos = {}) const;
|
||||
|
||||
/** [Jungfrau] Advanced Options[0-12]
|
||||
*/
|
||||
void setFilterCell(int cell, Positions pos = {});
|
||||
|
||||
///@{
|
||||
|
||||
/** @name Gotthard Specific */
|
||||
|
@ -934,6 +934,7 @@ class CmdProxy {
|
||||
{"storagecell_start", &CmdProxy::storagecell_start},
|
||||
{"storagecell_delay", &CmdProxy::storagecell_delay},
|
||||
{"gainmode", &CmdProxy::gainmode},
|
||||
{"filtercell", &CmdProxy::filtercell},
|
||||
|
||||
/* Gotthard Specific */
|
||||
{"roi", &CmdProxy::ROI},
|
||||
@ -1888,8 +1889,11 @@ class CmdProxy {
|
||||
sls::StringTo<slsDetectorDefs::gainMode>,
|
||||
"[dynamicgain|forceswitchg1|forceswitchg2|fixg1|fixg2|fixg0]\n\t["
|
||||
"Jungfrau] Gain mode.\n\tCAUTION: Do not use fixg0 without caution, "
|
||||
"you can "
|
||||
"damage the detector!!!");
|
||||
"you can damage the detector!!!");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
filtercell, getFilterCell, setFilterCell, sls::StringTo<int>,
|
||||
"[0-12]\n\t[Jungfrau] Set Filter Cell. Advanced user Command");
|
||||
|
||||
/* Gotthard Specific */
|
||||
TIME_GET_COMMAND(exptimel, getExptimeLeft,
|
||||
|
@ -1521,6 +1521,14 @@ void Detector::setGainMode(const defs::gainMode mode, Positions pos) {
|
||||
pimpl->Parallel(&Module::setGainMode, pos, mode);
|
||||
}
|
||||
|
||||
Result<int> Detector::getFilterCell(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getFilterCell, pos);
|
||||
}
|
||||
|
||||
void Detector::setFilterCell(int cell, Positions pos) {
|
||||
pimpl->Parallel(&Module::setFilterCell, pos, cell);
|
||||
}
|
||||
|
||||
// Gotthard Specific
|
||||
|
||||
Result<defs::ROI> Detector::getROI(Positions pos) const {
|
||||
|
@ -1632,6 +1632,14 @@ void Module::setGainMode(const slsDetectorDefs::gainMode mode) {
|
||||
sendToDetector(F_SET_GAIN_MODE, mode, nullptr);
|
||||
}
|
||||
|
||||
int Module::getFilterCell() const {
|
||||
return sendToDetector<int>(F_GET_FILTER_CELL);
|
||||
}
|
||||
|
||||
void Module::setFilterCell(int value) {
|
||||
sendToDetector(F_SET_FILTER_CELL, value, nullptr);
|
||||
}
|
||||
|
||||
// Gotthard Specific
|
||||
|
||||
slsDetectorDefs::ROI Module::getROI() const {
|
||||
|
@ -375,6 +375,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setStorageCellDelay(int64_t value);
|
||||
gainMode getGainMode() const;
|
||||
void setGainMode(const gainMode mode);
|
||||
int getFilterCell() const;
|
||||
void setFilterCell(int value);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
|
@ -488,3 +488,48 @@ TEST_CASE("gainmode", "[.cmd]") {
|
||||
REQUIRE_THROWS(proxy.Call("gainmode", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("filtercell", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::JUNGFRAU) {
|
||||
// chip version 1.1
|
||||
if (det.getChipVersion().squash() * 10 == 11) {
|
||||
auto prev_val = det.getFilterCell();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("filtercell", {"1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "filtercell 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("filtercell", {"12"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "filtercell 12\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("filtercell", {"0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "filtercell 0\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("filtercell", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "filtercell 0\n");
|
||||
}
|
||||
REQUIRE_THROWS(proxy.Call("filtercell", {"13"}, -1, PUT));
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setFilterCell(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
// chip version 1.0
|
||||
else {
|
||||
// cannot set/get filter cell
|
||||
REQUIRE_THROWS(proxy.Call("filtercell", {"1"}, -1, PUT));
|
||||
REQUIRE_THROWS(proxy.Call("filtercell", {}, -1, GET));
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("filtercell", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("filtercell", {"0"}, -1, PUT));
|
||||
}
|
||||
}
|
||||
|
@ -239,6 +239,8 @@ enum detFuncs {
|
||||
F_SET_COMP_DISABLE_TIME,
|
||||
F_GET_FLIP_ROWS,
|
||||
F_SET_FLIP_ROWS,
|
||||
F_GET_FILTER_CELL,
|
||||
F_SET_FILTER_CELL,
|
||||
|
||||
NUM_DET_FUNCTIONS,
|
||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||
@ -585,6 +587,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_SET_COMP_DISABLE_TIME: return "F_SET_COMP_DISABLE_TIME";
|
||||
case F_GET_FLIP_ROWS: return "F_GET_FLIP_ROWS";
|
||||
case F_SET_FLIP_ROWS: return "F_SET_FLIP_ROWS";
|
||||
case F_GET_FILTER_CELL: return "F_GET_FILTER_CELL";
|
||||
case F_SET_FILTER_CELL: return "F_SET_FILTER_CELL";
|
||||
|
||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||
|
Loading…
x
Reference in New Issue
Block a user