gotthard2: vetoref, burstmode

This commit is contained in:
2019-11-15 18:59:27 +01:00
parent a62d6a2fb8
commit 6a27207875
15 changed files with 486 additions and 11 deletions

View File

@ -778,6 +778,8 @@ class CmdProxy {
/* Gotthard2 Specific */
{"inj_ch", &CmdProxy::InjectChannel},
{"vetophoton", &CmdProxy::VetoPhoton},
{"vetoref", &CmdProxy::VetoReference},
{"burstmode", &CmdProxy::burstmode},
/* CTB Specific */
{"samples", &CmdProxy::Samples},
@ -927,7 +929,8 @@ class CmdProxy {
std::string ClearROI(int action);
/* Gotthard2 Specific */
std::string InjectChannel(int action);
std::string VetoPhoton(int action);
std::string VetoPhoton(int action);
std::string VetoReference(int action);
/* CTB Specific */
std::string Samples(int action);
std::string Dbitphase(int action);
@ -1509,6 +1512,9 @@ class CmdProxy {
"[0, 1]\n\t[Gotthard] 1 adds channel intensity with precalculated values when taking an acquisition. Default is 0.");
/* Gotthard2 Specific */
INTEGER_COMMAND(burstmode, getBurstMode, setBurstMode, std::stoi,
"[0, 1]\n\t[Gotthard2] 1 sets to burst mode. 0 sets to continuous mode. Default is burst mode.");
/* CTB Specific */
INTEGER_COMMAND(asamples, getNumberOfAnalogSamples, setNumberOfAnalogSamples, std::stoi,

View File

@ -891,7 +891,16 @@ class Detector {
Result<std::vector<int>> getVetoPhoton(const int chipIndex, Positions pos = {});
/** [Gotthard2] energy in keV */
void setVetoPhoton(const int chipIndex, const int numPhotons, const int energy, const std::string& fname, Positions pos = {});
void setVetoPhoton(const int chipIndex, const int numPhotons, const int energy, const std::string& fname, Positions pos = {});
/** [Gotthard2] */
void setVetoReference(const int gainIndex, const int value, Positions pos = {});
/** [Gotthard2] burst mode or continuous mode */
void setBurstMode(bool enable, Positions pos = {});
/** [Gotthard2] */
Result<bool> getBurstMode(Positions pos = {});
/**************************************************
* *

View File

@ -1116,6 +1116,15 @@ class slsDetector : public virtual slsDetectorDefs {
/** [Gotthard2] energy in keV */
void setVetoPhoton(const int chipIndex, const int numPhotons, const int energy, const std::string& fname);
void setVetoReference(const int gainIndex, const int value);
/** [Gotthard2] burst mode or continuous mode */
void setBurstMode(bool enable);
/** [Gotthard2] */
bool getBurstMode();
/**
* Set/get counter bit in detector (Gotthard)
* @param i is -1 to get, 0 to reset and any other value to set the counter

View File

@ -1066,6 +1066,25 @@ std::string CmdProxy::VetoPhoton(int action) {
return os.str();
}
std::string CmdProxy::VetoReference(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[gain index] [12 bit value in hex] \n\t[Gotthard2] Set veto reference for all 128 channels for all chips." << '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("cannot get vetoref. Did you mean vetophoton?");
} else if (action == defs::PUT_ACTION) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
det->setVetoReference(std::stoi(args[0]), stoiHex(args[1]), {det_id});
os << sls::ToString(args) << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/* CTB Specific */
std::string CmdProxy::Samples(int action) {

View File

@ -1104,6 +1104,18 @@ void Detector::setVetoPhoton(const int chipIndex, const int numPhotons, const in
pimpl->Parallel(&slsDetector::setVetoPhoton, pos, chipIndex, numPhotons, energy, fname);
}
void Detector::setVetoReference(const int gainIndex, const int value, Positions pos) {
pimpl->Parallel(&slsDetector::setVetoReference, pos, gainIndex, value);
}
void Detector::setBurstMode(bool enable, Positions pos) {
pimpl->Parallel(&slsDetector::setBurstMode, pos, enable);
}
Result<bool> Detector::getBurstMode(Positions pos) {
return pimpl->Parallel(&slsDetector::getBurstMode, pos);
}
// CTB Specific
Result<int> Detector::getNumberOfAnalogSamples(Positions pos) const {

View File

@ -2475,6 +2475,25 @@ void slsDetector::setVetoPhoton(const int chipIndex, const int numPhotons, const
}
}
void slsDetector::setVetoReference(const int gainIndex, const int value) {
int args[]{gainIndex, value};
FILE_LOG(logDEBUG1) << "Setting veto reference [gainIndex: " << gainIndex << ", value: 0x" << std::hex << value << std::dec << ']';
sendToDetector(F_SET_VETO_REFERENCE, args, nullptr);
}
bool slsDetector::getBurstMode() {
int retval = -1;
sendToDetector(F_GET_BURST_MODE, nullptr, retval);
FILE_LOG(logDEBUG1) << "Burst mode:" << retval;
return static_cast<bool>(retval);
}
void slsDetector::setBurstMode(bool enable) {
int arg = static_cast<int>(enable);
FILE_LOG(logDEBUG1) << "Setting burst mode to " << arg;
sendToDetector(F_SET_BURST_MODE, arg, nullptr);
}
int slsDetector::setCounterBit(int cb) {
int retval = -1;
FILE_LOG(logDEBUG1) << "Sending counter bit " << cb;

View File

@ -9,6 +9,27 @@
auto GET = slsDetectorDefs::GET_ACTION;
auto PUT = slsDetectorDefs::PUT_ACTION;
TEST_CASE("burstmode", "[.cmd][.gotthard2]") {
if (test::type == slsDetectorDefs::GOTTHARD2) {
REQUIRE_NOTHROW(multiSlsDetectorClient("burstmode 0", PUT));
REQUIRE_NOTHROW(multiSlsDetectorClient("burstmode 1", PUT));
REQUIRE_NOTHROW(multiSlsDetectorClient("burstmode", GET));
} else {
REQUIRE_THROWS(multiSlsDetectorClient("burstmod", GET));
}
}
TEST_CASE("vetoref", "[.cmd][.gotthard2]") {
if (test::type == slsDetectorDefs::GOTTHARD2) {
REQUIRE_THROWS(multiSlsDetectorClient("vetoref 3 0x3ff", PUT)); // invalid chip index
REQUIRE_THROWS(multiSlsDetectorClient("vetoref 0 0xFFFF", PUT)); // invalid value
REQUIRE_NOTHROW(multiSlsDetectorClient("vetoref 1 0x010", PUT));
REQUIRE_THROWS(multiSlsDetectorClient("vetoref", GET));
} else {
REQUIRE_THROWS(multiSlsDetectorClient("vetoref 3 0x0", PUT));
}
}
TEST_CASE("vetophoton", "[.cmd][.gotthard2]") {
if (test::type == slsDetectorDefs::GOTTHARD2) {
REQUIRE_THROWS(multiSlsDetectorClient("vetophoton 12 1 39950 examples/gotthard2_veto_photon.txt", PUT)); // invalid chip index