mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
M3: polarity, interpolation, pump probe (#421)
* wip, adding m3 functions: polarity, inerpolation, pumpprobe * added interpol, polarity, pump probe, analog pulsing, digital pulsing * tests * binaries in * update release * added python polarity enum * fixed python and minor readability in mythen3.c * binarie sin * added all the m3 funcs also in list.c and enablingall counters for enabling interpolation * binarie sin
This commit is contained in:
@ -1472,6 +1472,36 @@ class Detector {
|
||||
|
||||
Result<int> getGainCaps(Positions pos = {});
|
||||
|
||||
/** [Mythen3] */
|
||||
Result<defs::polarity> getPolarity(Positions pos = {}) const;
|
||||
|
||||
/** [Mythen3] */
|
||||
void setPolarity(defs::polarity value, Positions pos = {});
|
||||
|
||||
/** [Mythen3] */
|
||||
Result<bool> getInterpolation(Positions pos = {}) const;
|
||||
|
||||
/** [Mythen3] Also enables all counters */
|
||||
void setInterpolation(bool value, Positions pos = {});
|
||||
|
||||
/** [Mythen3] */
|
||||
Result<bool> getPumpProbe(Positions pos = {}) const;
|
||||
|
||||
/** [Mythen3] */
|
||||
void setPumpProbe(bool value, Positions pos = {});
|
||||
|
||||
/** [Mythen3] */
|
||||
Result<bool> getAnalogPulsing(Positions pos = {}) const;
|
||||
|
||||
/** [Mythen3] */
|
||||
void setAnalogPulsing(bool value, Positions pos = {});
|
||||
|
||||
/** [Mythen3] */
|
||||
Result<bool> getDigitalPulsing(Positions pos = {}) const;
|
||||
|
||||
/** [Mythen3] */
|
||||
void setDigitalPulsing(bool value, Positions pos = {});
|
||||
|
||||
///@}
|
||||
|
||||
/** @name CTB / Moench Specific */
|
||||
@ -1614,12 +1644,11 @@ class Detector {
|
||||
/** [CTB] Default is enabled. */
|
||||
void setLEDEnable(bool enable, Positions pos = {});
|
||||
|
||||
|
||||
void setDacNames(const std::vector<std::string> names);
|
||||
|
||||
std::vector<std::string> getDacNames() const;
|
||||
|
||||
defs::dacIndex getDacIndex(const std::string& name);
|
||||
defs::dacIndex getDacIndex(const std::string &name);
|
||||
std::string getDacName(defs::dacIndex i);
|
||||
///@}
|
||||
|
||||
|
@ -996,6 +996,11 @@ class CmdProxy {
|
||||
{"gatedelay2", &CmdProxy::GateDelay},
|
||||
{"gatedelay3", &CmdProxy::GateDelay},
|
||||
{"gaincaps", &CmdProxy::GainCaps},
|
||||
{"polarity", &CmdProxy::polarity},
|
||||
{"interpolation", &CmdProxy::interpolation},
|
||||
{"pumpprobe", &CmdProxy::pumpprobe},
|
||||
{"apulse", &CmdProxy::apulse},
|
||||
{"dpulse", &CmdProxy::dpulse},
|
||||
|
||||
/* CTB/ Moench Specific */
|
||||
{"samples", &CmdProxy::Samples},
|
||||
@ -2034,6 +2039,31 @@ class CmdProxy {
|
||||
"[n_gates]\n\t[Mythen3] Number of external gates in gating "
|
||||
"or trigger_gating mode (external gating).");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(polarity, getPolarity, setPolarity,
|
||||
StringTo<defs::polarity>,
|
||||
"[pos|neg]\n\t[Mythen3] Sets negative or positive "
|
||||
"polarity. Default is positive");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(interpolation, getInterpolation, setInterpolation,
|
||||
StringTo<int>,
|
||||
"[0, 1]\n\t[Mythen3] Enables or disables "
|
||||
"interpolation. Default is disabled. Enabling also "
|
||||
"enables all counters. ");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(pumpprobe, getPumpProbe, setPumpProbe, StringTo<int>,
|
||||
"[0, 1]\n\t[Mythen3] Enables or disables pump probe "
|
||||
"mode. Default is disabled");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(apulse, getAnalogPulsing, setAnalogPulsing,
|
||||
StringTo<int>,
|
||||
"[0, 1]\n\t[Mythen3] Enables or disables analog "
|
||||
"pulsing. Default is disabled");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(dpulse, getDigitalPulsing, setDigitalPulsing,
|
||||
StringTo<int>,
|
||||
"[0, 1]\n\t[Mythen3] Enables or disables digital "
|
||||
"pulsing. Default is disabled");
|
||||
|
||||
/* CTB/ Moench Specific */
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
|
@ -5,9 +5,9 @@
|
||||
|
||||
#include "CmdParser.h"
|
||||
#include "CmdProxy.h"
|
||||
#include "CtbConfig.h"
|
||||
#include "DetectorImpl.h"
|
||||
#include "Module.h"
|
||||
#include "CtbConfig.h"
|
||||
#include "sls/Pattern.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include "sls/file_utils.h"
|
||||
@ -1875,6 +1875,46 @@ Result<int> Detector::getGainCaps(Positions pos) {
|
||||
return pimpl->Parallel(&Module::getGainCaps, pos);
|
||||
}
|
||||
|
||||
Result<defs::polarity> Detector::getPolarity(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getPolarity, pos);
|
||||
}
|
||||
|
||||
void Detector::setPolarity(defs::polarity value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setPolarity, pos, value);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getInterpolation(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getInterpolation, pos);
|
||||
}
|
||||
|
||||
void Detector::setInterpolation(bool value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setInterpolation, pos, value);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getPumpProbe(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getPumpProbe, pos);
|
||||
}
|
||||
|
||||
void Detector::setPumpProbe(bool value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setPumpProbe, pos, value);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getAnalogPulsing(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getAnalogPulsing, pos);
|
||||
}
|
||||
|
||||
void Detector::setAnalogPulsing(bool value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setAnalogPulsing, pos, value);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getDigitalPulsing(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDigitalPulsing, pos);
|
||||
}
|
||||
|
||||
void Detector::setDigitalPulsing(bool value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setDigitalPulsing, pos, value);
|
||||
}
|
||||
|
||||
// CTB/ Moench Specific
|
||||
|
||||
Result<int> Detector::getNumberOfAnalogSamples(Positions pos) const {
|
||||
|
@ -2256,11 +2256,52 @@ int Module::getChipStatusRegister() const {
|
||||
}
|
||||
|
||||
void Module::setGainCaps(int caps) {
|
||||
sendToDetector<int>(F_SET_GAIN_CAPS, caps);
|
||||
sendToDetector(F_SET_GAIN_CAPS, caps, nullptr);
|
||||
}
|
||||
|
||||
int Module::getGainCaps() { return sendToDetector<int>(F_GET_GAIN_CAPS); }
|
||||
|
||||
defs::polarity Module::getPolarity() const {
|
||||
return sendToDetector<defs::polarity>(F_GET_POLARITY);
|
||||
}
|
||||
|
||||
void Module::setPolarity(const defs::polarity value) {
|
||||
sendToDetector(F_SET_POLARITY, static_cast<int>(value), nullptr);
|
||||
}
|
||||
|
||||
bool Module::getInterpolation() const {
|
||||
return sendToDetector<int>(F_GET_INTERPOLATION);
|
||||
}
|
||||
|
||||
void Module::setInterpolation(const bool enable) {
|
||||
sendToDetector(F_SET_INTERPOLATION, static_cast<int>(enable), nullptr);
|
||||
setCounterMask(getCounterMask());
|
||||
}
|
||||
|
||||
bool Module::getPumpProbe() const {
|
||||
return sendToDetector<int>(F_GET_PUMP_PROBE);
|
||||
}
|
||||
|
||||
void Module::setPumpProbe(const bool enable) {
|
||||
sendToDetector(F_SET_PUMP_PROBE, static_cast<int>(enable), nullptr);
|
||||
}
|
||||
|
||||
bool Module::getAnalogPulsing() const {
|
||||
return sendToDetector<int>(F_GET_ANALOG_PULSING);
|
||||
}
|
||||
|
||||
void Module::setAnalogPulsing(const bool enable) {
|
||||
sendToDetector(F_SET_ANALOG_PULSING, static_cast<int>(enable), nullptr);
|
||||
}
|
||||
|
||||
bool Module::getDigitalPulsing() const {
|
||||
return sendToDetector<int>(F_GET_DIGITAL_PULSING);
|
||||
}
|
||||
|
||||
void Module::setDigitalPulsing(const bool enable) {
|
||||
sendToDetector(F_SET_DIGITAL_PULSING, static_cast<int>(enable), nullptr);
|
||||
}
|
||||
|
||||
// CTB / Moench Specific
|
||||
int Module::getNumberOfAnalogSamples() const {
|
||||
return sendToDetector<int>(F_GET_NUM_ANALOG_SAMPLES);
|
||||
|
@ -466,6 +466,16 @@ class Module : public virtual slsDetectorDefs {
|
||||
int getChipStatusRegister() const;
|
||||
void setGainCaps(int caps);
|
||||
int getGainCaps();
|
||||
defs::polarity getPolarity() const;
|
||||
void setPolarity(const defs::polarity enable);
|
||||
bool getInterpolation() const;
|
||||
void setInterpolation(const bool enable);
|
||||
bool getPumpProbe() const;
|
||||
void setPumpProbe(const bool enable);
|
||||
bool getAnalogPulsing() const;
|
||||
void setAnalogPulsing(const bool enable);
|
||||
bool getDigitalPulsing() const;
|
||||
void setDigitalPulsing(const bool enable);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
|
@ -462,4 +462,152 @@ TEST_CASE("gatedelay3", "[.cmd]") {
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("gatedelay3", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("polarity", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
if (det.getDetectorType().squash() == defs::MYTHEN3) {
|
||||
auto prev_val = det.getPolarity();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("polarity", {"pos"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "polarity pos\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("polarity", {"neg"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "polarity neg\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("polarity", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "polarity neg\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setPolarity(prev_val[i], {i});
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("polarity", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("interpolation", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
if (det.getDetectorType().squash() == defs::MYTHEN3) {
|
||||
auto prev_val = det.getInterpolation();
|
||||
auto mask = det.getCounterMask();
|
||||
{
|
||||
proxy.Call("counters", {"0", "1"}, -1, PUT);
|
||||
std::ostringstream oss;
|
||||
proxy.Call("interpolation", {"1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "interpolation 1\n");
|
||||
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") ==
|
||||
7);
|
||||
}
|
||||
{
|
||||
proxy.Call("counters", {"0", "1"}, -1, PUT);
|
||||
std::ostringstream oss;
|
||||
proxy.Call("interpolation", {"0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "interpolation 0\n");
|
||||
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") ==
|
||||
3);
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("interpolation", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "interpolation 0\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setCounterMask(mask[i], {i});
|
||||
det.setInterpolation(prev_val[i], {i});
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("interpolation", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("pumpprobe", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
if (det.getDetectorType().squash() == defs::MYTHEN3) {
|
||||
auto prev_val = det.getPumpProbe();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("pumpprobe", {"1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "pumpprobe 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("pumpprobe", {"0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "pumpprobe 0\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("pumpprobe", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "pumpprobe 0\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setPumpProbe(prev_val[i], {i});
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("pumpprobe", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("apulse", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
if (det.getDetectorType().squash() == defs::MYTHEN3) {
|
||||
auto prev_val = det.getAnalogPulsing();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("apulse", {"1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "apulse 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("apulse", {"0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "apulse 0\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("apulse", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "apulse 0\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setAnalogPulsing(prev_val[i], {i});
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("apulse", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("dpulse", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
if (det.getDetectorType().squash() == defs::MYTHEN3) {
|
||||
auto prev_val = det.getDigitalPulsing();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("dpulse", {"1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "dpulse 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("dpulse", {"0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "dpulse 0\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("dpulse", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "dpulse 0\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDigitalPulsing(prev_val[i], {i});
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("dpulse", {}, -1, GET));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user