gotthard2: timingsource and currentsource features, (timing source external yet to be implemented in fpga to test (#80)

This commit is contained in:
Dhanya Thattil
2020-02-28 12:45:02 +01:00
committed by GitHub
parent 2e2e91b219
commit 11e7737a2f
17 changed files with 334 additions and 3 deletions

View File

@ -931,6 +931,18 @@ class Detector {
/** [Gotthard2] BURST_OFF, BURST_INTERNAL (default), BURST_EXTERNAL */
void setBurstMode(defs::burstMode value, Positions pos = {});
/** [Gotthard2] */
Result<bool> getCurrentSource(Positions pos = {}) const;
/** default disabled */
void setCurrentSource(bool value, Positions pos = {});
/** [Gotthard2] */
Result<defs::timingSourceType> getTimingSource(Positions pos = {}) const;
/** [Gotthard2] Options: TIMING_INTERNAL, TIMING_EXTERNAL */
void setTimingSource(defs::timingSourceType value, Positions pos = {});
/**************************************************
* *
* Mythen3 Specific *

View File

@ -790,6 +790,8 @@ class CmdProxy {
{"vetophoton", &CmdProxy::VetoPhoton},
{"vetoref", &CmdProxy::VetoReference},
{"burstmode", &CmdProxy::BurstMode},
{"currentsource", &CmdProxy::currentsource},
{"timingsource", &CmdProxy::timingsource},
/* Mythen3 Specific */
{"counters", &CmdProxy::Counters},
@ -1564,6 +1566,12 @@ 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(currentsource, getCurrentSource, setCurrentSource, std::stoi,
"[0, 1]\n\t[Gotthard2] Enable or disable current source. Default is disabled.");
INTEGER_COMMAND(timingsource, getTimingSource, setTimingSource, sls::StringTo<slsDetectorDefs::timingSourceType>,
"[internal|external]\n\t[Gotthard2] Timing source. Internal is crystal and external is system timing. Default is internal.");
/* Mythen3 Specific */
/* CTB Specific */

View File

@ -1204,6 +1204,22 @@ void Detector::setBurstMode(defs::burstMode value, Positions pos) {
pimpl->Parallel(&slsDetector::setBurstMode, pos, value);
}
Result<bool> Detector::getCurrentSource(Positions pos) const {
return pimpl->Parallel(&slsDetector::getCurrentSource, pos);
}
void Detector::setCurrentSource(bool value, Positions pos) {
pimpl->Parallel(&slsDetector::setCurrentSource, pos, value);
}
Result<defs::timingSourceType> Detector::getTimingSource(Positions pos) const {
return pimpl->Parallel(&slsDetector::getTimingSource, pos);
}
void Detector::setTimingSource(defs::timingSourceType value, Positions pos) {
pimpl->Parallel(&slsDetector::setTimingSource, pos, value);
}
// Mythen3 Specific
Result<uint32_t> Detector::getCounterMask(Positions pos) const {

View File

@ -2546,6 +2546,32 @@ void slsDetector::setBurstMode(slsDetectorDefs::burstMode value) {
shm()->burstMode = value;
}
bool slsDetector::getCurrentSource() {
int retval = -1;
sendToDetector(F_GET_CURRENT_SOURCE, nullptr, retval);
FILE_LOG(logDEBUG1) << "Current source enable:" << retval;
return static_cast<bool>(retval);
}
void slsDetector::setCurrentSource(bool value) {
int arg = static_cast<int>(value);
FILE_LOG(logDEBUG1) << "Setting current source enable to " << arg;
sendToDetector(F_SET_CURRENT_SOURCE, arg, nullptr);
}
slsDetectorDefs::timingSourceType slsDetector::getTimingSource() {
int retval = -1;
sendToDetector(F_GET_TIMING_SOURCE, nullptr, retval);
FILE_LOG(logDEBUG1) << "Timing source:" << retval;
return static_cast<slsDetectorDefs::timingSourceType>(retval);
}
void slsDetector::setTimingSource(slsDetectorDefs::timingSourceType value) {
int arg = static_cast<int>(value);
FILE_LOG(logDEBUG1) << "Setting timing source to " << arg;
sendToDetector(F_SET_TIMING_SOURCE, arg, nullptr);
}
int slsDetector::setCounterBit(int cb) {
int retval = -1;
FILE_LOG(logDEBUG1) << "Sending counter bit " << cb;

View File

@ -1152,6 +1152,18 @@ class slsDetector : public virtual slsDetectorDefs {
/** [Gotthard2] BURST_OFF, BURST_INTERNAL (default), BURST_EXTERNAL */
void setBurstMode(burstMode value);
/** [Gotthard2] */
bool getCurrentSource();
/** default disabled */
void setCurrentSource(bool value);
/** [Gotthard2] */
slsDetectorDefs::timingSourceType getTimingSource();
/** [Gotthard2] Options: TIMING_INTERNAL, TIMING_EXTERNAL */
void setTimingSource(slsDetectorDefs::timingSourceType value);
/**
* Set/get counter bit in detector (Gotthard)

View File

@ -282,3 +282,62 @@ TEST_CASE("burstperiod", "[.cmd]") {
}
TEST_CASE("currentsource", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
auto prev_val = det.getCurrentSource();
{
std::ostringstream oss;
proxy.Call("currentsource", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "currentsource 1\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "currentsource 0\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {}, -1, GET, oss);
REQUIRE(oss.str() == "currentsource 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setCurrentSource(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("currentsource", {}, -1, GET));
}
}
TEST_CASE("timingsource", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
auto prev_val = det.getTimingSource();
/* { until its activated in fpga
std::ostringstream oss;
proxy.Call("timingsource", {"external"}, -1, PUT, oss);
REQUIRE(oss.str() == "timingsource external\n");
}*/
{
std::ostringstream oss;
proxy.Call("timingsource", {"internal"}, -1, PUT, oss);
REQUIRE(oss.str() == "timingsource internal\n");
}
{
std::ostringstream oss;
proxy.Call("timingsource", {}, -1, GET, oss);
REQUIRE(oss.str() == "timingsource internal\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setTimingSource(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("timingsource", {}, -1, GET));
}
}