Merge branch 'my3regs' into developer

This commit is contained in:
Erik Frojdh
2021-04-26 08:39:46 +02:00
34 changed files with 970 additions and 349 deletions

View File

@ -55,6 +55,12 @@ void CmdParser::Parse(const std::string &s) {
command_ = arguments_[0];
arguments_.erase(begin(arguments_));
}
//allow comma sep
for (auto& arg : arguments_){
if (arg.back() == ',')
arg.pop_back();
}
DecodeIdAndPosition(command_.c_str());
}

View File

@ -1981,6 +1981,43 @@ std::string CmdProxy::GateDelay(int action) {
return os.str();
}
std::string CmdProxy::GainCaps(int action){
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[cap1, cap2, ...]\n\t[Mythen3] gain, options: C10pre, C15sh, C30sh, C50sh, C225ACsh, C15pre"
<< '\n';
} else if (action == defs::GET_ACTION) {
if (!args.empty())
WrongNumberOfParameters(0);
auto tmp = det->getGainCaps();
sls::Result<defs::M3_GainCaps> csr;
for (auto val : tmp){
if (val)
csr.push_back(static_cast<defs::M3_GainCaps>(val));
}
os << OutString(csr) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() < 1) {
WrongNumberOfParameters(1);
}
int caps = 0;
for (const auto& arg:args){
if (arg != "0")
caps |= sls::StringTo<defs::M3_GainCaps>(arg);
}
det->setGainCaps(caps);
os << OutString(args) << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/* CTB / Moench Specific */
std::string CmdProxy::Samples(int action) {

View File

@ -571,19 +571,6 @@ class CmdProxy {
return ToString(value, unit);
}
// inline unsigned int stoiHex(const std::string& s) {
// unsigned long lresult = stoul(s, nullptr, 16);
// unsigned int result = lresult;
// if (result != lresult) {
// throw std::out_of_range("cannot convert to unsigned int");
// }
// return result;
// }
// inline unsigned long int stoulHex(const std::string& s) {
// unsigned long result = stoul(s, nullptr, 16);
// return result;
// }
using FunctionMap = std::map<std::string, std::string (CmdProxy::*)(int)>;
using StringMap = std::map<std::string, std::string>;
@ -970,6 +957,7 @@ class CmdProxy {
{"gatedelay1", &CmdProxy::GateDelay},
{"gatedelay2", &CmdProxy::GateDelay},
{"gatedelay3", &CmdProxy::GateDelay},
{"gaincaps", &CmdProxy::GainCaps},
/* CTB/ Moench Specific */
{"samples", &CmdProxy::Samples},
@ -1137,6 +1125,7 @@ class CmdProxy {
/* Mythen3 Specific */
std::string Counters(int action);
std::string GateDelay(int action);
std::string GainCaps(int action);
/* CTB/ Moench Specific */
std::string Samples(int action);
/* CTB Specific */

View File

@ -1615,6 +1615,18 @@ Result<bool> Detector::getMaster(Positions pos) const{
return pimpl->Parallel(&Module::isMaster, pos);
}
Result<int> Detector::getChipStatusRegister(Positions pos) const{
return pimpl->Parallel(&Module::getChipStatusRegister, pos);
}
void Detector::setGainCaps(int caps, Positions pos){
return pimpl->Parallel(&Module::setGainCaps, pos, caps);
}
Result<int> Detector::getGainCaps(Positions pos){
return pimpl->Parallel(&Module::getGainCaps, pos);
}
// CTB/ Moench Specific

View File

@ -1998,6 +1998,18 @@ bool Module::isMaster() const{
return sendToDetector<int>(F_GET_MASTER);
}
int Module::getChipStatusRegister() const{
return sendToDetector<int>(F_GET_CSR);
}
void Module::setGainCaps(int caps){
sendToDetector<int>(F_SET_GAIN_CAPS, caps);
}
int Module::getGainCaps(){
return sendToDetector<int>(F_GET_GAIN_CAPS);
}
// CTB / Moench Specific
int Module::getNumberOfAnalogSamples() const {
return sendToDetector<int>(F_GET_NUM_ANALOG_SAMPLES);
@ -3195,6 +3207,9 @@ sls_detector_module Module::readSettingsFile(const std::string &fname,
throw RuntimeError("Could not open settings file: " + fname);
}
auto file_size = getFileSize(infile);
// eiger
if (shm()->myDetectorType == EIGER) {
infile.read(reinterpret_cast<char *>(myMod.dacs),
@ -3220,6 +3235,16 @@ 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);
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.dacs),
sizeof(int) * (myMod.ndac));
for (int i = 0; i < myMod.ndac; ++i) {

View File

@ -426,6 +426,9 @@ class Module : public virtual slsDetectorDefs {
void setGateDelay(int gateIndex, int64_t value);
std::array<time::ns, 3> getGateDelayForAllGates() const;
bool isMaster() const;
int getChipStatusRegister() const;
void setGainCaps(int caps);
int getGainCaps();
/**************************************************
* *