diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.c b/slsDetectorServers/eigerDetectorServer/FebControl.c index fa38438b7..413e56a32 100644 --- a/slsDetectorServers/eigerDetectorServer/FebControl.c +++ b/slsDetectorServers/eigerDetectorServer/FebControl.c @@ -998,14 +998,24 @@ int Feb_Control_StartAcquisition() { int Feb_Control_StopAcquisition() { if (Feb_Control_activated) { - // stop acquisition and also sends last frame + // sends last + unsigned int orig_value = 0; + if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(), + DAQ_REG_CTRL, &orig_value)) { + LOG(logERROR, ("Could not read DAQ_REG_CHIP_CMDS to send software " + "trigger\n")); + return 0; + } if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(), - DAQ_REG_CTRL, DAQ_CTRL_STOP, 0, 0)) { + DAQ_REG_CTRL, + orig_value | DAQ_CTRL_STOP, 0, 0)) { LOG(logERROR, ("Could not send last frames.\n")); return 0; } + // stop acquisition + return Feb_Control_Reset(); } - return Feb_Control_Reset(); + return 1; } int Feb_Control_SoftwareTrigger() { diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 31ab0d22b..2acc30749 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -698,7 +698,7 @@ void Detector::startDetectorReadout() { void Detector::stopDetector(Positions pos) { auto detector_type = getDetectorType().squash(); - /*if (detector_type == defs::EIGER && size() > 1) { + if (detector_type == defs::EIGER && size() > 1) { auto is_master = getMaster(); int masterPosition = -1; std::vector slaves; @@ -716,9 +716,9 @@ void Detector::stopDetector(Positions pos) { if (masterPosition != -1) { pimpl->Parallel(&Module::stopAcquisition, {masterPosition}); } - } else {*/ - pimpl->Parallel(&Module::stopAcquisition, pos); - //} + } else { + pimpl->Parallel(&Module::stopAcquisition, pos); + } } Result Detector::getDetectorStatus(Positions pos) const { diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index bb43ad31a..713229fea 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -352,37 +352,39 @@ void Module::setAllThresholdEnergy(std::array e_eV, std::copy(e_eV.begin(), e_eV.end(), myMod.eV); LOG(logDEBUG) << "ev:" << ToString(myMod.eV); - //check for trimbits that are out of range + // check for trimbits that are out of range bool out_of_range = false; - for(int i = 0; i!=myMod.nchan; ++i){ - if (myMod.chanregs[i]<0){ + for (int i = 0; i != myMod.nchan; ++i) { + if (myMod.chanregs[i] < 0) { myMod.chanregs[i] = 0; out_of_range = true; - }else if(myMod.chanregs[i]>63){ - myMod.chanregs[i]=63; + } else if (myMod.chanregs[i] > 63) { + myMod.chanregs[i] = 63; out_of_range = true; } } - if (out_of_range){ - LOG(logWARNING) << "Some trimbits were out of range after interpolation, these have been replaced with 0 or 63."; + if (out_of_range) { + LOG(logWARNING) + << "Some trimbits were out of range after interpolation, these " + "have been replaced with 0 or 63."; } - //check dacs + // check dacs out_of_range = false; - for (auto dac : {M_VTRIM,M_VTH1,M_VTH2, M_VTH3}){ - if (myMod.dacs[dac] < 600){ + for (auto dac : {M_VTRIM, M_VTH1, M_VTH2, M_VTH3}) { + if (myMod.dacs[dac] < 600) { myMod.dacs[dac] = 600; out_of_range = true; - }else if(myMod.dacs[dac] > 2400){ + } else if (myMod.dacs[dac] > 2400) { myMod.dacs[dac] = 2400; out_of_range = true; } } - if (out_of_range){ - LOG(logWARNING) << "Some dacs were out of range after interpolation, these have been replaced with 600 or 2400."; + if (out_of_range) { + LOG(logWARNING) << "Some dacs were out of range after interpolation, " + "these have been replaced with 600 or 2400."; } - setModule(myMod, trimbits); if (getSettings() != isettings) { throw RuntimeError("setThresholdEnergyAndSettings: Could not set " @@ -412,7 +414,8 @@ void Module::loadSettingsFile(const std::string &fname) { if (shm()->myDetectorType == MYTHEN3) { serialNumberWidth = 4; } - if ((fname.find(".sn") == std::string::npos) && (fname.find(".trim") == std::string::npos)) { + if ((fname.find(".sn") == std::string::npos) && + (fname.find(".trim") == std::string::npos)) { ostfn << ".sn" << std::setfill('0') << std::setw(serialNumberWidth) << std::dec << getSerialNumber(); } @@ -1994,21 +1997,17 @@ std::array Module::getGateDelayForAllGates() const { return sendToDetector>(F_GET_GATE_DELAY_ALL_GATES); } -bool Module::isMaster() const{ - return sendToDetector(F_GET_MASTER); -} +bool Module::isMaster() const { return sendToDetectorStop(F_GET_MASTER); } -int Module::getChipStatusRegister() const{ +int Module::getChipStatusRegister() const { return sendToDetector(F_GET_CSR); } -void Module::setGainCaps(int caps){ +void Module::setGainCaps(int caps) { sendToDetector(F_SET_GAIN_CAPS, caps); } -int Module::getGainCaps(){ - return sendToDetector(F_GET_GAIN_CAPS); -} +int Module::getGainCaps() { return sendToDetector(F_GET_GAIN_CAPS); } // CTB / Moench Specific int Module::getNumberOfAnalogSamples() const { @@ -3209,7 +3208,6 @@ sls_detector_module Module::readSettingsFile(const std::string &fname, auto file_size = getFileSize(infile); - // eiger if (shm()->myDetectorType == EIGER) { infile.read(reinterpret_cast(myMod.dacs), @@ -3235,16 +3233,15 @@ sls_detector_module Module::readSettingsFile(const std::string &fname, // mythen3 (dacs, trimbits) else if (shm()->myDetectorType == MYTHEN3) { - int expected_size = - sizeof(int) * myMod.ndac + sizeof(int) * myMod.nchan + sizeof(myMod.reg); + int expected_size = sizeof(int) * myMod.ndac + + sizeof(int) * myMod.nchan + sizeof(myMod.reg); if (file_size != expected_size) { throw RuntimeError("The size of the settings file: " + fname + " differs from the expected size, " + std::to_string(file_size) + " instead of " + std::to_string(expected_size) + " bytes"); } - infile.read(reinterpret_cast(&myMod.reg), - sizeof(myMod.reg)); + infile.read(reinterpret_cast(&myMod.reg), sizeof(myMod.reg)); infile.read(reinterpret_cast(myMod.dacs), sizeof(int) * (myMod.ndac)); for (int i = 0; i < myMod.ndac; ++i) {