veotalg for g2

This commit is contained in:
2021-07-20 14:57:31 +02:00
parent af16ad4040
commit e02493d4e4
11 changed files with 152 additions and 48 deletions

View File

@ -1825,7 +1825,19 @@ std::string CmdProxy::VetoStreaming(int action) {
if (args.empty()) {
WrongNumberOfParameters(1);
}
defs::ethernetInterface interface = GetVetoInterface(true);
defs::ethernetInterface interface = defs::ethernetInterface::NONE;
for (const auto &arg : args) {
if (arg == "none") {
if (args.size() > 1) {
throw sls::RuntimeError(
std::string(
"cannot have other arguments with 'none'. args: ") +
ToString(args));
}
break;
}
interface = interface | (StringTo<defs::ethernetInterface>(arg));
}
det->setVetoStream(interface, std::vector<int>{det_id});
os << ToString(interface) << '\n';
} else {
@ -1834,48 +1846,36 @@ std::string CmdProxy::VetoStreaming(int action) {
return os.str();
}
defs::ethernetInterface CmdProxy::GetVetoInterface(bool isNoneAllowed) {
defs::ethernetInterface interface = defs::ethernetInterface::NONE;
for (const auto &arg : args) {
if (arg == "none") {
if (!isNoneAllowed) {
throw sls::RuntimeError("Must specifiy an interface");
} else {
if (args.size() > 1) {
throw sls::RuntimeError(
std::string(
"cannot have other arguments with 'none'. args: ") +
ToString(args));
}
}
break;
}
interface = interface | (StringTo<defs::ethernetInterface>(arg));
}
return interface;
}
std::string CmdProxy::VetoAlgorithm(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[default] [3gbe|10gbe|...]\n\t[Gotthard2] Set the veto "
os << "[default] [3gbe|10gbe]\n\t[Gotthard2] Set the veto "
"algorithm."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() < 1) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
defs::ethernetInterface interface = GetVetoInterface(false);
defs::ethernetInterface interface =
StringTo<defs::ethernetInterface>(args[0]);
if (interface == defs::ethernetInterface::NONE) {
throw sls::RuntimeError(
"Must specify an interface to set algorithm");
}
auto t = det->getVetoAlgorithm(interface, std::vector<int>{det_id});
os << OutString(t) << ' ' << ToString(interface) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() < 2) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
defs::vetoAlgorithm alg = StringTo<defs::vetoAlgorithm>(args[0]);
args.erase(args.begin());
defs::ethernetInterface interface = GetVetoInterface(false);
defs::ethernetInterface interface =
StringTo<defs::ethernetInterface>(args[1]);
if (interface == defs::ethernetInterface::NONE) {
throw sls::RuntimeError(
"Must specify an interface to set algorithm");
}
det->setVetoAlgorithm(alg, interface, std::vector<int>{det_id});
os << ToString(alg) << ' ' << ToString(interface) << '\n';
} else {

View File

@ -1135,7 +1135,6 @@ class CmdProxy {
std::string VetoFile(int action);
std::string BurstMode(int action);
std::string VetoStreaming(int action);
defs::ethernetInterface GetVetoInterface(bool isNoneAllowed);
std::string VetoAlgorithm(int action);
std::string ConfigureADC(int action);
std::string BadChannels(int action);

View File

@ -1878,15 +1878,17 @@ void Module::setVetoStream(const bool value) {
sendToDetector(F_SET_VETO_STREAM, static_cast<int>(value), nullptr);
}
slsDetectorDefs::vetoAlgorithm
Module::getVetoAlgorithm(const slsDetectorDefs::ethernetInterface) const {
return alg_;
slsDetectorDefs::vetoAlgorithm Module::getVetoAlgorithm(
const slsDetectorDefs::ethernetInterface interface) const {
return sendToDetector<vetoAlgorithm>(F_GET_VETO_ALGORITHM,
static_cast<int>(interface));
}
void Module::setVetoAlgorithm(
const slsDetectorDefs::vetoAlgorithm alg,
const slsDetectorDefs::ethernetInterface interface) {
alg_ = alg;
int args[]{static_cast<int>(alg), static_cast<int>(interface)};
sendToDetector(F_SET_VETO_ALGORITHM, args, nullptr);
}
int Module::getADCConfiguration(const int chipIndex, const int adcIndex) const {

View File

@ -409,7 +409,7 @@ class Module : public virtual slsDetectorDefs {
bool getVetoStream() const;
void setVetoStream(const bool value);
slsDetectorDefs::vetoAlgorithm
getVetoAlgorithm(const slsDetectorDefs::ethernetInterface) const;
getVetoAlgorithm(const slsDetectorDefs::ethernetInterface interface) const;
void setVetoAlgorithm(const slsDetectorDefs::vetoAlgorithm alg,
const slsDetectorDefs::ethernetInterface interface);
int getADCConfiguration(const int chipIndex, const int adcIndex) const;
@ -725,7 +725,6 @@ class Module : public virtual slsDetectorDefs {
const int moduleId;
mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0};
slsDetectorDefs::vetoAlgorithm alg_{slsDetectorDefs::DEFAULT_ALGORITHM};
};
} // namespace sls