added command line option

This commit is contained in:
Erik Frojdh 2021-04-01 10:06:37 +02:00
parent 779a2a0199
commit 0299d315d5
6 changed files with 80 additions and 13 deletions

View File

@ -19,6 +19,7 @@ This document describes the differences between X and Y releases.
1. New Features
===============
Setting Mythen3 gain from command line
4. Firmware Requirements
========================

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,37 @@ 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->getChipStatusRegister();
sls::Result<defs::M3_GainCaps> csr;
for (auto val : tmp)
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)
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

@ -36,6 +36,7 @@ std::string ToString(const defs::dacIndex s);
std::string ToString(const std::vector<defs::dacIndex> &vec);
std::string ToString(const defs::burstMode s);
std::string ToString(const defs::timingSourceType s);
std::string ToString(const defs::M3_GainCaps s);
std::string ToString(const slsDetectorDefs::xy &coord);
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord);
@ -297,6 +298,7 @@ template <> defs::readoutMode StringTo(const std::string &s);
template <> defs::dacIndex StringTo(const std::string &s);
template <> defs::burstMode StringTo(const std::string &s);
template <> defs::timingSourceType StringTo(const std::string &s);
template <> defs::M3_GainCaps StringTo(const std::string &s);
template <> uint32_t StringTo(const std::string &s);
template <> uint64_t StringTo(const std::string &s);

View File

@ -859,6 +859,44 @@ template <> defs::timingSourceType StringTo(const std::string &s) {
throw sls::RuntimeError("Unknown timing source type " + s);
}
template <> defs::M3_GainCaps StringTo(const std::string &s){
if (s == "C10pre")
return defs::M3_C10pre;
if (s == "C15sh")
return defs::M3_C15sh;
if (s == "C30sh")
return defs::M3_C30sh;
if (s == "C50sh")
return defs::M3_C50sh;
if (s == "C225ACsh")
return defs::M3_C225ACsh;
if (s == "C15pre")
return defs::M3_C15pre;
throw sls::RuntimeError("Unknown gain cap " + s);
}
std::string ToString(defs::M3_GainCaps s){
std::ostringstream os;
if (s & defs::M3_C10pre)
os << "C10pre, ";
if (s & defs::M3_C15sh)
os << "C15sh, ";
if (s & defs::M3_C30sh)
os << "C30sh, ";
if (s & defs::M3_C50sh)
os << "C50sh, ";
if (s & defs::M3_C225ACsh)
os << "C225ACsh, ";
if (s & defs::M3_C15pre)
os << "C15pre, ";
auto rs = os.str();
rs.erase(rs.end()-2);
return rs;
}
template <> uint32_t StringTo(const std::string &s) {
int base = s.find("0x") != std::string::npos ? 16 : 10;
return std::stoul(s, nullptr, base);