mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-16 23:07:13 +02:00
mythen3: set trimbits (not settings, threshold yet), set all trimbits
This commit is contained in:
@ -563,6 +563,8 @@ class CmdProxy {
|
||||
{"type", &CmdProxy::type},
|
||||
{"detsize", &CmdProxy::DetectorSize},
|
||||
{"settings", &CmdProxy::settings},
|
||||
{"trimbits", &CmdProxy::trimbits},
|
||||
{"trimval", &CmdProxy::trimval},
|
||||
|
||||
/* acquisition parameters */
|
||||
{"acquire", &CmdProxy::acquire},
|
||||
@ -751,13 +753,11 @@ class CmdProxy {
|
||||
{"threshold", &CmdProxy::Threshold},
|
||||
{"thresholdnotb", &CmdProxy::ThresholdNoTb},
|
||||
{"settingspath", &CmdProxy::settingspath},
|
||||
{"trimbits", &CmdProxy::trimbits},
|
||||
{"gappixels", &CmdProxy::GapPixels},
|
||||
{"parallel", &CmdProxy::parallel},
|
||||
{"overflow", &CmdProxy::overflow},
|
||||
{"storeinram", &CmdProxy::storeinram},
|
||||
{"flippeddatax", &CmdProxy::flippeddatax},
|
||||
{"trimval", &CmdProxy::trimval},
|
||||
{"trimen", &CmdProxy::TrimEnergies},
|
||||
{"ratecorr", &CmdProxy::RateCorrection},
|
||||
{"readnlines", &CmdProxy::readnlines},
|
||||
@ -1032,6 +1032,15 @@ class CmdProxy {
|
||||
"g2_lc_hg | g2_lc_lg | g4_hg | g4_lg]"
|
||||
"\n\t[Eiger] Use threshold or thresholdnotb.");
|
||||
|
||||
EXECUTE_SET_COMMAND_NOID_1ARG(
|
||||
trimbits, loadTrimbits,
|
||||
"[fname]\n\t[Eiger][Mythen3] Loads the trimbit file to detector. If no "
|
||||
"extension specified, serial number of each module is attached.");
|
||||
|
||||
INTEGER_COMMAND(trimval, getAllTrimbits, setAllTrimbits, StringTo<int>,
|
||||
"[n_trimval]\n\t[Eiger][Mythen3] All trimbits set to this "
|
||||
"value. Returns -1 if all trimbits are different values.");
|
||||
|
||||
/* acquisition parameters */
|
||||
|
||||
INTEGER_COMMAND_NOID(
|
||||
@ -1740,11 +1749,6 @@ class CmdProxy {
|
||||
settingspath, getSettingsPath, setSettingsPath,
|
||||
"[path]\n\t[Eiger] Directory where settings files are loaded from/to.");
|
||||
|
||||
EXECUTE_SET_COMMAND_NOID_1ARG(
|
||||
trimbits, loadTrimbits,
|
||||
"[fname]\n\t[Eiger] Loads the trimbit file to detector. If no "
|
||||
"extension specified, serial number of each module is attached.");
|
||||
|
||||
INTEGER_COMMAND(parallel, getParallelMode, setParallelMode, StringTo<int>,
|
||||
"[0, 1]\n\t[Eiger] Enable or disable parallel mode.");
|
||||
|
||||
@ -1762,10 +1766,6 @@ class CmdProxy {
|
||||
"is top. Used to let Receivers and Gui know to flip the bottom image "
|
||||
"over the x axis. Files are not written without the flip however.");
|
||||
|
||||
INTEGER_COMMAND(trimval, getAllTrimbits, setAllTrimbits, StringTo<int>,
|
||||
"[n_trimval]\n\t[Eiger] All trimbits set to this value. A "
|
||||
"get returns -1 if all trimbits are different values.");
|
||||
|
||||
INTEGER_COMMAND(
|
||||
readnlines, getPartialReadout, setPartialReadout, StringTo<int>,
|
||||
"[1 - 256]\n\t[Eiger] Number of rows to readout per half module "
|
||||
|
@ -149,6 +149,18 @@ void Detector::setSettings(const defs::detectorSettings value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setSettings, pos, value);
|
||||
}
|
||||
|
||||
void Detector::loadTrimbits(const std::string &fname, Positions pos) {
|
||||
pimpl->Parallel(&Module::loadSettingsFile, pos, fname);
|
||||
}
|
||||
|
||||
Result<int> Detector::getAllTrimbits(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getAllTrimbits, pos);
|
||||
}
|
||||
|
||||
void Detector::setAllTrimbits(int value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setAllTrimbits, pos, value);
|
||||
}
|
||||
|
||||
// Callback
|
||||
|
||||
void Detector::registerAcquisitionFinishedCallback(void (*func)(double, int,
|
||||
@ -942,10 +954,6 @@ void Detector::setSettingsPath(const std::string &value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setSettingsDir, pos, value);
|
||||
}
|
||||
|
||||
void Detector::loadTrimbits(const std::string &fname, Positions pos) {
|
||||
pimpl->Parallel(&Module::loadSettingsFile, pos, fname);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getParallelMode(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getParallelMode, pos);
|
||||
}
|
||||
@ -978,14 +986,6 @@ void Detector::setBottom(bool value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setFlippedDataX, pos, value);
|
||||
}
|
||||
|
||||
Result<int> Detector::getAllTrimbits(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::setAllTrimbits, pos, -1);
|
||||
}
|
||||
|
||||
void Detector::setAllTrimbits(int value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setAllTrimbits, pos, value);
|
||||
}
|
||||
|
||||
Result<std::vector<int>> Detector::getTrimEnergies(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getTrimEn, pos);
|
||||
}
|
||||
|
@ -110,19 +110,20 @@ int64_t Module::getFirmwareVersion() {
|
||||
int64_t Module::getDetectorServerVersion() {
|
||||
int64_t retval = -1;
|
||||
sendToDetector(F_GET_SERVER_VERSION, nullptr, retval);
|
||||
LOG(logDEBUG1) << "firmware version: 0x" << std::hex << retval << std::dec;
|
||||
LOG(logDEBUG1) << "detector server version: 0x" << std::hex << retval
|
||||
<< std::dec;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t Module::getSerialNumber() {
|
||||
int64_t retval = -1;
|
||||
sendToDetector(F_GET_SERIAL_NUMBER, nullptr, retval);
|
||||
LOG(logDEBUG1) << "firmware version: 0x" << std::hex << retval << std::dec;
|
||||
LOG(logDEBUG1) << "serial number: 0x" << std::hex << retval << std::dec;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t Module::getReceiverSoftwareVersion() const {
|
||||
LOG(logDEBUG1) << "Getting receiver software version";
|
||||
LOG(logDEBUG1) << "Getting receiver version";
|
||||
int64_t retval = -1;
|
||||
if (shm()->useReceiverFlag) {
|
||||
sendToReceiver(F_GET_RECEIVER_VERSION, nullptr, retval);
|
||||
@ -450,7 +451,7 @@ int Module::sendModule(sls_detector_module *myMod, sls::ClientSocket &client) {
|
||||
ts += n;
|
||||
LOG(level) << "dacs sent. " << n << " bytes";
|
||||
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->myDetectorType == EIGER || shm()->myDetectorType == MYTHEN3) {
|
||||
n = client.Send(myMod->chanregs, sizeof(int) * (myMod->nchan));
|
||||
ts += n;
|
||||
LOG(level) << "channels sent. " << n << " bytes";
|
||||
@ -472,7 +473,7 @@ int Module::receiveModule(sls_detector_module *myMod,
|
||||
|
||||
ts += client.Receive(myMod->dacs, sizeof(int) * (myMod->ndac));
|
||||
LOG(logDEBUG1) << "received dacs of size " << ts;
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->myDetectorType == EIGER || shm()->myDetectorType == MYTHEN3) {
|
||||
ts += client.Receive(myMod->chanregs, sizeof(int) * (myMod->nchan));
|
||||
LOG(logDEBUG1) << " nchan= " << myMod->nchan
|
||||
<< " nchip= " << myMod->nchip
|
||||
@ -907,7 +908,7 @@ void Module::loadSettingsFile(const std::string &fname) {
|
||||
ostfn << fname;
|
||||
|
||||
// find specific file if it has detid in file name (.snxxx)
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->myDetectorType == EIGER || shm()->myDetectorType == MYTHEN3) {
|
||||
if (fname.find(".sn") == std::string::npos &&
|
||||
fname.find(".trim") == std::string::npos &&
|
||||
fname.find(".settings") == std::string::npos) {
|
||||
@ -2509,14 +2510,20 @@ void Module::setFlippedDataX(bool value) {
|
||||
sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, arg, retval);
|
||||
}
|
||||
|
||||
int Module::setAllTrimbits(int val) {
|
||||
int Module::getAllTrimbits() {
|
||||
int retval = -1;
|
||||
LOG(logDEBUG1) << "Setting all trimbits to " << val;
|
||||
int val = -1;
|
||||
sendToDetector(F_SET_ALL_TRIMBITS, val, retval);
|
||||
LOG(logDEBUG1) << "All trimbit value: " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void Module::setAllTrimbits(int val) {
|
||||
int retval = -1;
|
||||
LOG(logDEBUG1) << "Setting all trimbits to " << val;
|
||||
sendToDetector(F_SET_ALL_TRIMBITS, val, retval);
|
||||
}
|
||||
|
||||
int Module::setTrimEn(const std::vector<int> &energies) {
|
||||
if (shm()->myDetectorType != EIGER) {
|
||||
throw RuntimeError("setTrimEn not implemented for this detector.");
|
||||
@ -2766,7 +2773,6 @@ int Module::setAutoComparatorDisableMode(int ival) {
|
||||
void Module::setModule(sls_detector_module &module, int tb) {
|
||||
int fnum = F_SET_MODULE;
|
||||
int ret = FAIL;
|
||||
int retval = -1;
|
||||
LOG(logDEBUG1) << "Setting module with tb:" << tb;
|
||||
// to exclude trimbits
|
||||
if (tb == 0) {
|
||||
@ -2783,8 +2789,6 @@ void Module::setModule(sls_detector_module &module, int tb) {
|
||||
throw RuntimeError("Detector " + std::to_string(detId) +
|
||||
" returned error: " + mess);
|
||||
}
|
||||
client.Receive(&retval, sizeof(retval));
|
||||
LOG(logDEBUG1) << "Set Module returned: " << retval;
|
||||
}
|
||||
|
||||
sls_detector_module Module::getModule() {
|
||||
@ -3554,7 +3558,7 @@ sls_detector_module Module::readSettingsFile(const std::string &fname, int tb) {
|
||||
auto names = getSettingsFileDacNames();
|
||||
// open file
|
||||
std::ifstream infile;
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->myDetectorType == EIGER || shm()->myDetectorType == MYTHEN3) {
|
||||
infile.open(fname.c_str(), std::ifstream::binary);
|
||||
} else {
|
||||
infile.open(fname.c_str(), std::ios_base::in);
|
||||
@ -3600,6 +3604,29 @@ sls_detector_module Module::readSettingsFile(const std::string &fname, int tb) {
|
||||
LOG(logDEBUG1) << "tau:" << myMod.tau;
|
||||
}
|
||||
|
||||
// mythen3 (dacs, trimbits)
|
||||
else if (shm()->myDetectorType == MYTHEN3) {
|
||||
bool allread = false;
|
||||
infile.read(reinterpret_cast<char *>(myMod.dacs),
|
||||
sizeof(int) * (myMod.ndac));
|
||||
if (infile.good()) {
|
||||
infile.read(reinterpret_cast<char *>(myMod.chanregs),
|
||||
sizeof(int) * (myMod.nchan));
|
||||
if (infile) {
|
||||
allread = true;
|
||||
}
|
||||
}
|
||||
if (!allread) {
|
||||
infile.close();
|
||||
throw RuntimeError("readSettingsFile: Could not load all values "
|
||||
"for settings for " +
|
||||
fname);
|
||||
}
|
||||
for (int i = 0; i < myMod.ndac; ++i) {
|
||||
LOG(logDEBUG1) << "dac " << i << ":" << myMod.dacs[i];
|
||||
}
|
||||
}
|
||||
|
||||
// gotthard, jungfrau
|
||||
else {
|
||||
size_t idac = 0;
|
||||
@ -3694,6 +3721,8 @@ std::vector<std::string> Module::getSettingsFileDacNames() {
|
||||
"VDAC6", "VDAC7", "VDAC8", "VDAC9", "VDAC10", "VDAC11",
|
||||
"VDAC12", "VDAC13", "VDAC14", "VDAC15"};
|
||||
break;
|
||||
case MYTHEN3:
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError(
|
||||
"Unknown detector type - unknown format for settings file");
|
||||
|
@ -318,11 +318,6 @@ class Module : public virtual slsDetectorDefs {
|
||||
*/
|
||||
std::string setSettingsDir(const std::string &dir);
|
||||
|
||||
/**
|
||||
* Loads the modules settings/trimbits reading from a specific file
|
||||
* file name extension is automatically generated.
|
||||
* @param fname specific settings/trimbits file
|
||||
*/
|
||||
void loadSettingsFile(const std::string &fname);
|
||||
|
||||
/**
|
||||
@ -1127,12 +1122,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
*/
|
||||
void setFlippedDataX(bool value);
|
||||
|
||||
/**
|
||||
* Sets all the trimbits to a particular value (Eiger)
|
||||
* @param val trimbit value
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int setAllTrimbits(int val);
|
||||
int getAllTrimbits();
|
||||
void setAllTrimbits(int val);
|
||||
|
||||
/**
|
||||
* Sets the number of trim energies and their value (Eiger)
|
||||
|
Reference in New Issue
Block a user