This commit is contained in:
2021-06-22 20:50:50 +02:00
parent 1a88cbd266
commit 755738a42e
15 changed files with 378 additions and 49 deletions

View File

@ -1555,6 +1555,49 @@ std::string CmdProxy::Quad(int action) {
return os.str();
}
std::string CmdProxy::DataStream(int action) {
std::ostringstream os;
os << cmd << ' ';
bool left = true;
if (action == defs::HELP_ACTION) {
os << "[0, 1] [left|right]\n\t[Eiger] Enables or disables data "
"streaming from left or/and right side of detector. 1 (enabled) "
"by default."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
// TODO, enum for "left and right?"
if (args[0] == "left") {
left = true;
} else if (args[0] == "right") {
left = false;
} else {
throw sls::RuntimeError("Unknown data argument " + args[0]);
}
auto t = det->getDataStream(left, std::vector<int>{det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
if (args[1] == "left") {
left = true;
} else if (args[1] == "right") {
left = false;
} else {
throw sls::RuntimeError("Unknown data argument " + args[1]);
}
det->setDataStream(left, StringTo<bool>(args[0]),
std::vector<int>{det_id});
os << args.front() << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/* Jungfrau Specific */
std::string CmdProxy::TemperatureEvent(int action) {

View File

@ -571,7 +571,6 @@ class CmdProxy {
return ToString(value, unit);
}
using FunctionMap = std::map<std::string, std::string (CmdProxy::*)(int)>;
using StringMap = std::map<std::string, std::string>;
@ -915,6 +914,7 @@ class CmdProxy {
{"pulsenmove", &CmdProxy::PulsePixelAndMove},
{"pulsechip", &CmdProxy::PulseChip},
{"quad", &CmdProxy::Quad},
{"datastream", &CmdProxy::DataStream},
/* Jungfrau Specific */
{"temp_threshold", &CmdProxy::temp_threshold},
@ -1109,6 +1109,7 @@ class CmdProxy {
std::string PulsePixelAndMove(int action);
std::string PulseChip(int action);
std::string Quad(int action);
std::string DataStream(int action);
/* Jungfrau Specific */
std::string TemperatureEvent(int action);
/* Gotthard Specific */
@ -1445,8 +1446,8 @@ class CmdProxy {
"and automatically returns to idle at the end of readout.");
EXECUTE_SET_COMMAND(stop, stopDetector,
"\n\tAbort detector acquisition. Status changes "
"to IDLE or STOPPED. Goes to stop server.");
"\n\tAbort detector acquisition. Status changes "
"to IDLE or STOPPED. Goes to stop server.");
GET_COMMAND(rx_framescaught, getFramesCaught,
"\n\tNumber of frames caught by receiver.");

View File

@ -675,11 +675,11 @@ void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); }
void Detector::startDetector() {
auto detector_type = getDetectorType().squash();
if (detector_type == defs::MYTHEN3 && size() > 1){
if (detector_type == defs::MYTHEN3 && size() > 1) {
auto is_master = getMaster();
std::vector<int> master;
std::vector<int> slaves;
for(int i=0; i<size(); ++i){
for (int i = 0; i < size(); ++i) {
if (is_master[i])
master.push_back(i);
else
@ -687,17 +687,18 @@ void Detector::startDetector() {
}
pimpl->Parallel(&Module::startAcquisition, slaves);
pimpl->Parallel(&Module::startAcquisition, master);
}else{
} else {
pimpl->Parallel(&Module::startAcquisition, {});
}
}
void Detector::startDetectorReadout() {
pimpl->Parallel(&Module::startReadout, {});
}
void Detector::stopDetector(Positions pos) { pimpl->Parallel(&Module::stopAcquisition, pos); }
void Detector::stopDetector(Positions pos) {
pimpl->Parallel(&Module::stopAcquisition, pos);
}
Result<defs::runStatus> Detector::getDetectorStatus(Positions pos) const {
return pimpl->Parallel(&Module::getRunStatus, pos);
@ -733,8 +734,10 @@ Result<defs::scanParameters> Detector::getScan(Positions pos) const {
}
void Detector::setScan(const defs::scanParameters t) {
if(getDetectorType().squash() == defs::MYTHEN3 && size()>1 && t.enable != 0){
throw DetectorError("Scan is only allowed for single module Mythen 3 because of synchronization");
if (getDetectorType().squash() == defs::MYTHEN3 && size() > 1 &&
t.enable != 0) {
throw DetectorError("Scan is only allowed for single module Mythen 3 "
"because of synchronization");
}
pimpl->Parallel(&Module::setScan, {}, t);
}
@ -1366,6 +1369,15 @@ void Detector::setQuad(const bool enable) {
pimpl->Parallel(&Module::setQuad, {}, enable);
}
Result<bool> Detector::getDataStream(const bool left, Positions pos) const {
return pimpl->Parallel(&Module::getDataStream, pos, left);
}
void Detector::setDataStream(const bool enable, const bool left,
Positions pos) {
pimpl->Parallel(&Module::setDataStream, pos, enable, left);
}
// Jungfrau Specific
Result<int> Detector::getThresholdTemperature(Positions pos) const {
@ -1611,23 +1623,22 @@ Detector::getGateDelayForAllGates(Positions pos) const {
return pimpl->Parallel(&Module::getGateDelayForAllGates, pos);
}
Result<bool> Detector::getMaster(Positions pos) const{
Result<bool> Detector::getMaster(Positions pos) const {
return pimpl->Parallel(&Module::isMaster, pos);
}
Result<int> Detector::getChipStatusRegister(Positions pos) const{
Result<int> Detector::getChipStatusRegister(Positions pos) const {
return pimpl->Parallel(&Module::getChipStatusRegister, pos);
}
void Detector::setGainCaps(int caps, Positions pos){
void Detector::setGainCaps(int caps, Positions pos) {
return pimpl->Parallel(&Module::setGainCaps, pos, caps);
}
Result<int> Detector::getGainCaps(Positions pos){
Result<int> Detector::getGainCaps(Positions pos) {
return pimpl->Parallel(&Module::getGainCaps, pos);
}
// CTB/ Moench Specific
Result<int> Detector::getNumberOfAnalogSamples(Positions pos) const {

View File

@ -352,37 +352,39 @@ void Module::setAllThresholdEnergy(std::array<int, 3> 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();
}
@ -1504,6 +1507,15 @@ void Module::setQuad(const bool enable) {
}
}
bool Module::getDataStream(const bool left) const {
return sendToDetector<int>(F_GET_DATASTREAM, static_cast<int>(left));
}
void Module::setDataStream(const bool enable, const bool left) {
int args[]{static_cast<int>(enable), static_cast<int>(left)};
sendToDetector(F_GET_DATASTREAM, args, nullptr);
}
// Jungfrau Specific
int Module::getThresholdTemperature() const {
@ -1994,21 +2006,17 @@ std::array<time::ns, 3> Module::getGateDelayForAllGates() const {
return sendToDetector<std::array<time::ns, 3>>(F_GET_GATE_DELAY_ALL_GATES);
}
bool Module::isMaster() const{
return sendToDetector<int>(F_GET_MASTER);
}
bool Module::isMaster() const { return sendToDetector<int>(F_GET_MASTER); }
int Module::getChipStatusRegister() const{
int Module::getChipStatusRegister() const {
return sendToDetector<int>(F_GET_CSR);
}
void Module::setGainCaps(int caps){
void Module::setGainCaps(int caps) {
sendToDetector<int>(F_SET_GAIN_CAPS, caps);
}
int Module::getGainCaps(){
return sendToDetector<int>(F_GET_GAIN_CAPS);
}
int Module::getGainCaps() { return sendToDetector<int>(F_GET_GAIN_CAPS); }
// CTB / Moench Specific
int Module::getNumberOfAnalogSamples() const {
@ -3209,7 +3217,6 @@ sls_detector_module Module::readSettingsFile(const std::string &fname,
auto file_size = getFileSize(infile);
// eiger
if (shm()->myDetectorType == EIGER) {
infile.read(reinterpret_cast<char *>(myMod.dacs),
@ -3235,16 +3242,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<char *>(&myMod.reg),
sizeof(myMod.reg));
infile.read(reinterpret_cast<char *>(&myMod.reg), sizeof(myMod.reg));
infile.read(reinterpret_cast<char *>(myMod.dacs),
sizeof(int) * (myMod.ndac));
for (int i = 0; i < myMod.ndac; ++i) {

View File

@ -343,6 +343,8 @@ class Module : public virtual slsDetectorDefs {
void pulseChip(int n_pulses = 0);
bool getQuad() const;
void setQuad(const bool enable);
bool getDataStream(const bool left) const;
void setDataStream(const bool enable, const bool left);
/**************************************************
* *