ran tests and fixed

This commit is contained in:
maliakal_d 2020-10-08 15:44:15 +02:00
parent b9a459faa1
commit a838830090
8 changed files with 153 additions and 210 deletions

View File

@ -110,23 +110,23 @@ TEST_CASE("adcvpp", "[.cmd][.new]") {
{
std::ostringstream oss;
proxy.Call("adcvpp", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcvpp 1\n");
REQUIRE(oss.str() == "dac adcvpp 1\n");
}
{
std::ostringstream oss;
proxy.Call("adcvpp", {"1140", "mv"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcvpp 1140 mv\n");
REQUIRE(oss.str() == "dac adcvpp 1140 mV\n");
}
{
std::ostringstream oss;
proxy.Call("adcvpp", {"mv"}, -1, GET, oss);
REQUIRE(oss.str() == "adcvpp 1140 mv\n");
REQUIRE(oss.str() == "dac adcvpp 1140 mV\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setDAC(defs::ADC_VPP, prev_val[i], false, {i});
}
} else {
REQUIRE_THROWS(proxy.Call("adcvpp", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("dac adcvpp", {}, -1, GET));
}
}
@ -777,7 +777,7 @@ TEST_CASE("adc", "[.cmd][.new]") {
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
for (int i = 0; i <= 8; ++i) {
for (int i = 0; i <= 7; ++i) {
REQUIRE_NOTHROW(proxy.Call("adc", {std::to_string(i)}, -1, GET));
REQUIRE_THROWS(proxy.Call("adc", {"0"}, -1, PUT));
}

View File

@ -160,12 +160,12 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmd][.dacs][.new]") {
{
std::ostringstream oss;
proxy.Call("vthreshold", {"1234"}, -1, PUT, oss);
REQUIRE(oss.str() == "vthreshold 1234\n");
REQUIRE(oss.str() == "dac vthreshold 1234\n");
}
{
std::ostringstream oss;
proxy.Call("vthreshold", {}, -1, GET, oss);
REQUIRE(oss.str() == "vthreshold 1234\n");
REQUIRE(oss.str() == "dac vthreshold 1234\n");
}
// Reset dacs after test
@ -231,44 +231,6 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmd][.dacs][.new]") {
/* acquisition */
TEST_CASE("trigger", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_THROWS(proxy.Call("trigger", {}, -1, GET));
auto det_type = det.getDetectorType().squash();
if (det_type != defs::EIGER) {
REQUIRE_THROWS(proxy.Call("trigger", {}, -1, PUT));
} else {
auto prev_timing =
det.getTimingMode().tsquash("inconsistent timing mode in test");
auto prev_frames =
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
auto prev_exptime =
det.getExptime().tsquash("inconsistent exptime in test");
auto prev_period =
det.getPeriod().tsquash("inconsistent period in test");
det.setTimingMode(defs::TRIGGER_EXPOSURE);
det.setNumberOfFrames(1);
det.setExptime(std::chrono::milliseconds(1));
det.setPeriod(std::chrono::milliseconds(1));
auto startingfnum = det.getStartingFrameNumber().tsquash(
"inconsistent frame nr in test");
det.startDetector();
{
std::ostringstream oss;
proxy.Call("trigger", {}, -1, PUT, oss);
REQUIRE(oss.str() == "trigger successful\n");
}
std::this_thread::sleep_for(std::chrono::seconds(2));
auto currentfnum = det.getStartingFrameNumber().tsquash(
"inconsistent frame nr in test");
REQUIRE(startingfnum + 1 == currentfnum);
det.stopDetector();
det.setTimingMode(prev_timing);
det.setNumberOfFrames(prev_frames);
}
}
/* Network Configuration (Detector<->Receiver) */
TEST_CASE("txndelay_left", "[.cmd][.new]") {
@ -431,36 +393,6 @@ TEST_CASE("settingspath", "[.cmd][.new]") {
}
}
TEST_CASE("parallel", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_val = det.getParallelMode();
{
std::ostringstream oss;
proxy.Call("parallel", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "parallel 1\n");
}
{
std::ostringstream oss;
proxy.Call("parallel", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "parallel 0\n");
}
{
std::ostringstream oss;
proxy.Call("parallel", {}, -1, GET, oss);
REQUIRE(oss.str() == "parallel 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setParallelMode(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("parallel", {}, -1, GET));
}
}
TEST_CASE("overflow", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);

View File

@ -28,9 +28,9 @@ void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) {
// other detectors
else {
proxy.Call(dacname, {dacstr}, -1, PUT, oss_set);
REQUIRE(oss_set.str() == dacname + " " + dacstr + "\n");
REQUIRE(oss_set.str() == "dac " + dacname + " " + dacstr + "\n");
proxy.Call(dacname, {}, -1, GET, oss_get);
REQUIRE(oss_get.str() == dacname + " " + dacstr + "\n");
REQUIRE(oss_get.str() == "dac " + dacname + " " + dacstr + "\n");
}
// Reset all dacs to previous value
for (int i = 0; i != det.size(); ++i) {

View File

@ -106,121 +106,3 @@ TEST_CASE("Setting and reading back MOENCH dacs", "[.cmd][.dacs][.new]") {
REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET));
}
}
/* Moench */
TEST_CASE("emin", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MOENCH) {
{
std::ostringstream oss;
proxy.Call("emin", {"100"}, -1, PUT, oss);
REQUIRE(oss.str() == "emin 100\n");
}
{
std::ostringstream oss;
proxy.Call("emin", {"200"}, -1, PUT, oss);
REQUIRE(oss.str() == "emin 200\n");
}
{
std::ostringstream oss;
proxy.Call("emin", {}, -1, GET, oss);
REQUIRE(oss.str() == "emin 200\n");
}
} else {
REQUIRE_THROWS(proxy.Call("emin", {}, -1, GET));
}
}
TEST_CASE("emax", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MOENCH) {
{
std::ostringstream oss;
proxy.Call("emax", {"100"}, -1, PUT, oss);
REQUIRE(oss.str() == "emax 100\n");
}
{
std::ostringstream oss;
proxy.Call("emax", {"200"}, -1, PUT, oss);
REQUIRE(oss.str() == "emax 200\n");
}
{
std::ostringstream oss;
proxy.Call("emax", {}, -1, GET, oss);
REQUIRE(oss.str() == "emax 200\n");
}
} else {
REQUIRE_THROWS(proxy.Call("emax", {}, -1, GET));
}
}
TEST_CASE("framemode", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MOENCH) {
{
std::ostringstream oss;
proxy.Call("framemode", {"pedestal"}, -1, PUT, oss);
REQUIRE(oss.str() == "framemode pedestal\n");
}
{
std::ostringstream oss;
proxy.Call("framemode", {"newpedestal"}, -1, PUT, oss);
REQUIRE(oss.str() == "framemode newpedestal\n");
}
{
std::ostringstream oss;
proxy.Call("framemode", {"flatfield"}, -1, PUT, oss);
REQUIRE(oss.str() == "framemode flatfield\n");
}
{
std::ostringstream oss;
proxy.Call("framemode", {"newflatfield"}, -1, PUT, oss);
REQUIRE(oss.str() == "framemode newflatfield\n");
}
{
std::ostringstream oss;
proxy.Call("framemode", {}, -1, GET, oss);
REQUIRE(oss.str() == "framemode newflatfield\n");
}
REQUIRE_THROWS(proxy.Call("framemode", {"counting"}, -1, PUT));
} else {
REQUIRE_THROWS(proxy.Call("framemode", {}, -1, GET));
}
}
TEST_CASE("detectormode", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MOENCH) {
{
std::ostringstream oss;
proxy.Call("detectormode", {"counting"}, -1, PUT, oss);
REQUIRE(oss.str() == "detectormode counting\n");
}
{
std::ostringstream oss;
proxy.Call("detectormode", {"interpolating"}, -1, PUT, oss);
REQUIRE(oss.str() == "detectormode interpolating\n");
}
{
std::ostringstream oss;
proxy.Call("detectormode", {"analog"}, -1, PUT, oss);
REQUIRE(oss.str() == "detectormode analog\n");
}
std::ostringstream oss;
proxy.Call("detectormode", {}, -1, GET, oss);
REQUIRE(oss.str() == "detectormode analog\n");
REQUIRE_THROWS(proxy.Call("detectormode", {"pedestal"}, -1, PUT));
} else {
REQUIRE_THROWS(proxy.Call("detectormode", {}, -1, GET));
}
}

View File

@ -53,12 +53,12 @@ TEST_CASE("Setting and reading back MYTHEN3 dacs", "[.cmd][.dacs][.new]") {
{
std::ostringstream oss;
proxy.Call("vthreshold", {"1234"}, -1, PUT, oss);
REQUIRE(oss.str() == "vthreshold 1234\n");
REQUIRE(oss.str() == "dac vthreshold 1234\n");
}
{
std::ostringstream oss;
proxy.Call("vthreshold", {}, -1, GET, oss);
REQUIRE(oss.str() == "vthreshold 1234\n");
REQUIRE(oss.str() == "dac vthreshold 1234\n");
}
// Reset dacs after test

View File

@ -706,6 +706,34 @@ TEST_CASE("rx_zmqip", "[.cmd][.rx][.new]") {
}
}
TEST_CASE("rx_zmqhwm", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto prev_val =
det.getRxZmqHwm().tsquash("Inconsistent values for rx_zmqhwm to test");
{
std::ostringstream oss;
proxy.Call("rx_zmqhwm", {"50"}, -1, PUT, oss);
REQUIRE(oss.str() == "rx_zmqhwm 50\n");
}
{
std::ostringstream oss;
proxy.Call("rx_zmqhwm", {}, -1, GET, oss);
REQUIRE(oss.str() == "rx_zmqhwm 50\n");
}
{
std::ostringstream oss;
proxy.Call("rx_zmqhwm", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "rx_zmqhwm 0\n");
}
{
std::ostringstream oss;
proxy.Call("rx_zmqhwm", {"-1"}, -1, PUT, oss);
REQUIRE(oss.str() == "rx_zmqhwm -1\n");
}
det.setRxZmqHwm(prev_val);
}
/* CTB Specific */
TEST_CASE("rx_dbitlist", "[.cmd][.rx][.new]") {

View File

@ -1051,6 +1051,36 @@ TEST_CASE("extsig", "[.cmd][.new]") {
}
}
TEST_CASE("parallel", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::MYTHEN3) {
auto prev_val = det.getParallelMode();
{
std::ostringstream oss;
proxy.Call("parallel", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "parallel 1\n");
}
{
std::ostringstream oss;
proxy.Call("parallel", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "parallel 0\n");
}
{
std::ostringstream oss;
proxy.Call("parallel", {}, -1, GET, oss);
REQUIRE(oss.str() == "parallel 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setParallelMode(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("parallel", {}, -1, GET));
}
}
/** temperature */
TEST_CASE("templist", "[.cmd][.new]") {
@ -1116,6 +1146,46 @@ TEST_CASE("dacvalues", "[.cmd][.new]") {
/* acquisition */
TEST_CASE("trigger", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_THROWS(proxy.Call("trigger", {}, -1, GET));
auto det_type = det.getDetectorType().squash();
if (det_type != defs::EIGER && det_type != defs::MYTHEN3) {
REQUIRE_THROWS(proxy.Call("trigger", {}, -1, PUT));
} else if (det_type == defs::MYTHEN3) {
REQUIRE_NOTHROW(proxy.Call("trigger", {}, -1, PUT));
} else if (det_type == defs::EIGER) {
auto prev_timing =
det.getTimingMode().tsquash("inconsistent timing mode in test");
auto prev_frames =
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
auto prev_exptime =
det.getExptime().tsquash("inconsistent exptime in test");
auto prev_period =
det.getPeriod().tsquash("inconsistent period in test");
det.setTimingMode(defs::TRIGGER_EXPOSURE);
det.setNumberOfFrames(1);
det.setExptime(std::chrono::milliseconds(1));
det.setPeriod(std::chrono::milliseconds(1));
auto startingfnum = det.getStartingFrameNumber().tsquash(
"inconsistent frame nr in test");
det.startDetector();
{
std::ostringstream oss;
proxy.Call("trigger", {}, -1, PUT, oss);
REQUIRE(oss.str() == "trigger successful\n");
}
std::this_thread::sleep_for(std::chrono::seconds(2));
auto currentfnum = det.getStartingFrameNumber().tsquash(
"inconsistent frame nr in test");
REQUIRE(startingfnum + 1 == currentfnum);
det.stopDetector();
det.setTimingMode(prev_timing);
det.setNumberOfFrames(prev_frames);
}
}
TEST_CASE("clearbusy", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
@ -1757,6 +1827,33 @@ TEST_CASE("zmqip", "[.cmd][.new]") {
}
}
TEST_CASE("zmqhwm", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto prev_val = det.getClientZmqHwm();
{
std::ostringstream oss;
proxy.Call("zmqhwm", {"50"}, -1, PUT, oss);
REQUIRE(oss.str() == "zmqhwm 50\n");
}
{
std::ostringstream oss;
proxy.Call("zmqhwm", {}, -1, GET, oss);
REQUIRE(oss.str() == "zmqhwm 50\n");
}
{
std::ostringstream oss;
proxy.Call("zmqhwm", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "zmqhwm 0\n");
}
{
std::ostringstream oss;
proxy.Call("zmqhwm", {"-1"}, -1, PUT, oss);
REQUIRE(oss.str() == "zmqhwm -1\n");
}
det.setClientZmqHwm(prev_val);
}
/* Advanced */
TEST_CASE("programfpga", "[.cmd][.new]") {

View File

@ -485,6 +485,8 @@ std::string ToString(const defs::dacIndex s) {
return std::string("vipre_cds");
case defs::IBIAS_SFP:
return std::string("ibias_sfp");
case defs::ADC_VPP:
return std::string("adcvpp");
case defs::TRIMBIT_SCAN:
return std::string("trimbit_scan");
case defs::HIGH_VOLTAGE:
@ -696,31 +698,31 @@ template <> defs::dacIndex StringTo(const std::string &s) {
return defs::DAC_3;
if (s == "dac 4" || s == "4")
return defs::DAC_4;
if (s == "dac 5"|| s == "5")
if (s == "dac 5" || s == "5")
return defs::DAC_5;
if (s == "dac 6"|| s == "6")
if (s == "dac 6" || s == "6")
return defs::DAC_6;
if (s == "dac 7"|| s == "7")
if (s == "dac 7" || s == "7")
return defs::DAC_7;
if (s == "dac 8"|| s == "8")
if (s == "dac 8" || s == "8")
return defs::DAC_8;
if (s == "dac 9"|| s == "9")
if (s == "dac 9" || s == "9")
return defs::DAC_9;
if (s == "dac 10"|| s == "10")
if (s == "dac 10" || s == "10")
return defs::DAC_10;
if (s == "dac 11"|| s == "11")
if (s == "dac 11" || s == "11")
return defs::DAC_11;
if (s == "dac 12"|| s == "12")
if (s == "dac 12" || s == "12")
return defs::DAC_12;
if (s == "dac 13"|| s == "13")
if (s == "dac 13" || s == "13")
return defs::DAC_13;
if (s == "dac 14"|| s == "14")
if (s == "dac 14" || s == "14")
return defs::DAC_14;
if (s == "dac 15"|| s == "15")
if (s == "dac 15" || s == "15")
return defs::DAC_15;
if (s == "dac 16"|| s == "16")
if (s == "dac 16" || s == "16")
return defs::DAC_16;
if (s == "dac 17"|| s == "17")
if (s == "dac 17" || s == "17")
return defs::DAC_17;
if (s == "vsvp")
return defs::VSVP;
@ -844,6 +846,8 @@ template <> defs::dacIndex StringTo(const std::string &s) {
return defs::VIPRE_CDS;
if (s == "ibias_sfp")
return defs::IBIAS_SFP;
if (s == "adcvpp")
return defs::ADC_VPP;
if (s == "trimbit_scan")
return defs::TRIMBIT_SCAN;
if (s == "highvoltage")