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:
Dhanya Thattil 2022-04-08 15:18:01 +02:00 committed by GitHub
parent 27c7fd9a97
commit 52882cba20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 901 additions and 142 deletions

View File

@ -59,8 +59,10 @@ This document describes the differences between v7.0.0 and v6.x.x
- gotthard 25 um image reconstructed in gui and virtual hdf5 (firmware updated for slave to reverse channels)
- master binary file in json format now
- fixed bug introduced in 6.0.0: hdf5 files created 1 file per frame after the initial file which had maxframesperfile
- m3 polarity, interpolation (enables all counters when enabled), pump probe, analog pulsing, digital pulsing
- updatedetectorserver - removes old server current binary pointing to for blackfin
- removing copydetectorserver using tftp
>>>>>>> developer
- registerCallBackRawDataReady and registerCallBackRawDataModifyReady now gives a sls_receiver_header* instead of a char*, and uint32_t to size_t
- registerCallBackStartAcquisition gave incorrect imagesize (+120 bytes). corrected.
- registerCallBackStartAcquisition parameter is a const string reference

View File

@ -3498,10 +3498,60 @@ class Detector(CppDetectorApi):
def readout(self):
"""
Mythen3] Starts detector readout. Status changes to TRANSMITTING and automatically returns to idle at the end of readout.
[Mythen3] Starts detector readout. Status changes to TRANSMITTING and automatically returns to idle at the end of readout.
"""
self.startDetectorReadout()
@property
@element
def polarity(self):
"""[Mythen3] Set positive or negative polarity. Enum: polarity"""
return self.getPolarity()
@polarity.setter
def polarity(self, value):
ut.set_using_dict(self.setPolarity, value)
@property
@element
def interpolation(self):
"""[Mythen3] Enable or disable interpolation. Enabling also enables all counters """
return self.getInterpolation()
@interpolation.setter
def interpolation(self, value):
ut.set_using_dict(self.setInterpolation, value)
@property
@element
def pumpprobe(self):
"""[Mythen3] Enable or disable pump probe mode. """
return self.getPumpProbe()
@pumpprobe.setter
def pumpprobe(self, value):
ut.set_using_dict(self.setPumpProbe, value)
@property
@element
def apulse(self):
"""[Mythen3] Enable or disable analog pulsing. """
return self.getAnalogPulsing()
@apulse.setter
def apulse(self, value):
ut.set_using_dict(self.setAnalogPulsing, value)
@property
@element
def dpulse(self):
"""[Mythen3] Enable or disable digital pulsing. """
return self.getDigitalPulsing()
@dpulse.setter
def dpulse(self, value):
ut.set_using_dict(self.setDigitalPulsing, value)
"""
---------------------------<<<Debug>>>---------------------------

View File

@ -1290,6 +1290,46 @@ void init_det(py::module &m) {
.def("getGainCaps",
(Result<int>(Detector::*)(sls::Positions)) & Detector::getGainCaps,
py::arg() = Positions{})
.def("getPolarity",
(Result<defs::polarity>(Detector::*)(sls::Positions) const) &
Detector::getPolarity,
py::arg() = Positions{})
.def("setPolarity",
(void (Detector::*)(defs::polarity, sls::Positions)) &
Detector::setPolarity,
py::arg(), py::arg() = Positions{})
.def("getInterpolation",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getInterpolation,
py::arg() = Positions{})
.def("setInterpolation",
(void (Detector::*)(bool, sls::Positions)) &
Detector::setInterpolation,
py::arg(), py::arg() = Positions{})
.def("getPumpProbe",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getPumpProbe,
py::arg() = Positions{})
.def("setPumpProbe",
(void (Detector::*)(bool, sls::Positions)) &
Detector::setPumpProbe,
py::arg(), py::arg() = Positions{})
.def("getAnalogPulsing",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getAnalogPulsing,
py::arg() = Positions{})
.def("setAnalogPulsing",
(void (Detector::*)(bool, sls::Positions)) &
Detector::setAnalogPulsing,
py::arg(), py::arg() = Positions{})
.def("getDigitalPulsing",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getDigitalPulsing,
py::arg() = Positions{})
.def("setDigitalPulsing",
(void (Detector::*)(bool, sls::Positions)) &
Detector::setDigitalPulsing,
py::arg(), py::arg() = Positions{})
.def("getNumberOfAnalogSamples",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getNumberOfAnalogSamples,

View File

@ -315,4 +315,9 @@ void init_enums(py::module &m) {
.value("FIX_G2", slsDetectorDefs::gainMode::FIX_G2)
.value("FIX_G0", slsDetectorDefs::gainMode::FIX_G0)
.export_values();
py::enum_<slsDetectorDefs::polarity>(Defs, "polarity")
.value("POSITIVE", slsDetectorDefs::polarity::POSITIVE)
.value("NEGATIVE", slsDetectorDefs::polarity::NEGATIVE)
.export_values();
}

View File

@ -10,20 +10,6 @@
#include <string.h>
/*
// Common C/C++ structure to handle pattern data
typedef struct __attribute__((packed)) {
uint64_t word[MAX_PATTERN_LENGTH];
uint64_t ioctrl;
uint32_t limits[2];
// loop0 start, loop0 stop .. loop2 start, loop2 stop
uint32_t loop[6];
uint32_t nloop[3];
uint32_t wait[3];
uint64_t waittime[3];
} patternParameters;
*/
int chipStatusRegister = 0;
int setBit(int ibit, int patword) { return patword |= (1 << ibit); }
@ -32,44 +18,6 @@ int clearBit(int ibit, int patword) { return patword &= ~(1 << ibit); }
int getChipStatusRegister() { return chipStatusRegister; }
int gainCapsToCsr(int caps) {
// Translates bit representation
int csr = 0;
if (!(caps & M3_C10pre))
csr |= 1 << _CSR_C10pre;
if (caps & M3_C15sh)
csr |= 1 << CSR_C15sh;
if (caps & M3_C30sh)
csr |= 1 << CSR_C30sh;
if (caps & M3_C50sh)
csr |= 1 << CSR_C50sh;
if (caps & M3_C225ACsh)
csr |= 1 << CSR_C225ACsh;
if (!(caps & M3_C15pre))
csr |= 1 << _CSR_C15pre;
return csr;
}
int csrToGainCaps(int csr) {
// Translates bit representation
int caps = 0;
if (!(csr & (1 << _CSR_C10pre)))
caps |= M3_C10pre;
if (csr & (1 << CSR_C15sh))
caps |= M3_C15sh;
if (csr & (1 << CSR_C30sh))
caps |= M3_C30sh;
if (csr & (1 << CSR_C50sh))
caps |= M3_C50sh;
if (csr & (1 << CSR_C225ACsh))
caps |= M3_C225ACsh;
if (!(csr & (1 << _CSR_C15pre)))
caps |= M3_C15pre;
return caps;
}
patternParameters *setChipStatusRegisterPattern(int csr) {
int iaddr = 0;
int nbits = 18;
@ -149,54 +97,116 @@ patternParameters *setChipStatusRegisterPattern(int csr) {
return pat;
}
patternParameters *setInterpolation(int mask) {
int csr;
if (mask)
csr = chipStatusRegister | (1 << CSR_interp);
else
csr = chipStatusRegister & ~(1 << CSR_interp);
int getGainCaps() {
int csr = chipStatusRegister;
// Translates bit representation
int caps = 0;
if (!(csr & (1 << _CSR_C10pre)))
caps |= M3_C10pre;
if (csr & (1 << CSR_C15sh))
caps |= M3_C15sh;
if (csr & (1 << CSR_C30sh))
caps |= M3_C30sh;
if (csr & (1 << CSR_C50sh))
caps |= M3_C50sh;
if (csr & (1 << CSR_C225ACsh))
caps |= M3_C225ACsh;
if (!(csr & (1 << _CSR_C15pre)))
caps |= M3_C15pre;
return setChipStatusRegisterPattern(csr);
return caps;
}
patternParameters *setPumpProbe(int mask) {
int csr;
if (mask)
csr = chipStatusRegister | (1 << CSR_pumprobe);
else
csr = chipStatusRegister & ~(1 << CSR_pumprobe);
int M3SetGainCaps(int caps) {
int csr = chipStatusRegister & ~GAIN_MASK;
return setChipStatusRegisterPattern(csr);
// Translates bit representation
if (!(caps & M3_C10pre))
csr |= 1 << _CSR_C10pre;
if (caps & M3_C15sh)
csr |= 1 << CSR_C15sh;
if (caps & M3_C30sh)
csr |= 1 << CSR_C30sh;
if (caps & M3_C50sh)
csr |= 1 << CSR_C50sh;
if (caps & M3_C225ACsh)
csr |= 1 << CSR_C225ACsh;
if (!(caps & M3_C15pre))
csr |= 1 << _CSR_C15pre;
return csr;
}
patternParameters *setDigitalPulsing(int mask) {
int csr;
if (mask)
csr = chipStatusRegister | (1 << CSR_dpulse);
else
csr = chipStatusRegister & ~(1 << CSR_dpulse);
return setChipStatusRegisterPattern(csr);
int getInterpolation() {
return ((chipStatusRegister & CSR_interp_MSK) >> CSR_interp);
}
patternParameters *setAnalogPulsing(int mask) {
int csr;
if (mask)
csr = chipStatusRegister | (1 << CSR_apulse);
int M3SetInterpolation(int enable) {
int csr = 0;
if (enable)
csr = chipStatusRegister | CSR_interp_MSK;
else
csr = chipStatusRegister & ~(1 << CSR_apulse);
return setChipStatusRegisterPattern(csr);
csr = chipStatusRegister & ~CSR_interp_MSK;
return csr;
}
patternParameters *setNegativePolarity(int mask) {
int csr;
if (mask)
csr = chipStatusRegister | (1 << CSR_invpol);
int getPumpProbe() {
return ((chipStatusRegister & CSR_pumprobe_MSK) >> CSR_pumprobe);
}
int M3SetPumpProbe(int enable) {
LOG(logINFO, ("%s Pump Probe\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = 0;
if (enable)
csr = chipStatusRegister | CSR_pumprobe_MSK;
else
csr = chipStatusRegister & ~(1 << CSR_invpol);
csr = chipStatusRegister & ~CSR_pumprobe_MSK;
return csr;
}
return setChipStatusRegisterPattern(csr);
int getDigitalPulsing() {
return ((chipStatusRegister & CSR_dpulse_MSK) >> CSR_dpulse);
}
int M3SetDigitalPulsing(int enable) {
LOG(logINFO,
("%s Digital Pulsing\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = 0;
if (enable)
csr = chipStatusRegister | CSR_dpulse_MSK;
else
csr = chipStatusRegister & ~CSR_dpulse_MSK;
return csr;
}
int getAnalogPulsing() {
return ((chipStatusRegister & CSR_apulse_MSK) >> CSR_apulse);
}
int M3SetAnalogPulsing(int enable) {
LOG(logINFO,
("%s Analog Pulsing\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = 0;
if (enable)
csr = chipStatusRegister | CSR_apulse_MSK;
else
csr = chipStatusRegister & ~CSR_apulse_MSK;
return csr;
}
int getNegativePolarity() {
return ((chipStatusRegister & CSR_invpol_MSK) >> CSR_invpol);
}
int M3SetNegativePolarity(int enable) {
LOG(logINFO,
("%s Negative Polarity\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = 0;
if (enable)
csr = chipStatusRegister | CSR_invpol_MSK;
else
csr = chipStatusRegister & ~CSR_invpol_MSK;
return csr;
}
patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits) {

View File

@ -49,6 +49,12 @@
// shaper)
#define _CSR_C15pre 14 // negative polarity
#define CSR_invpol_MSK (0x1 << CSR_invpol)
#define CSR_dpulse_MSK (0x1 << CSR_dpulse)
#define CSR_interp_MSK (0x1 << CSR_interp)
#define CSR_pumprobe_MSK (0x1 << CSR_pumprobe)
#define CSR_apulse_MSK (0x1 << CSR_apulse)
#define CSR_default (1 << _CSR_C10pre) | (1 << CSR_C30sh)
#define GAIN_MASK \
@ -58,15 +64,20 @@
int setBit(int ibit, int patword);
int clearBit(int ibit, int patword);
int getChipStatusRegister();
int gainCapsToCsr(int caps);
int csrToGainCaps(int csr);
patternParameters *setChipStatusRegisterPattern(int csr);
patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits);
patternParameters *setInterpolation(int mask);
patternParameters *setPumpProbe(int mask);
patternParameters *setDigitalPulsing(int mask);
patternParameters *setAnalogPulsing(int mask);
patternParameters *setNegativePolarity(int mask);
int getGainCaps();
int M3SetGainCaps(int caps);
int getInterpolation();
int M3SetInterpolation(int enable);
int getPumpProbe();
int M3SetPumpProbe(int enable);
int getDigitalPulsing();
int M3SetDigitalPulsing(int enable);
int getAnalogPulsing();
int M3SetAnalogPulsing(int enable);
int getNegativePolarity();
int M3SetNegativePolarity(int enable);
#endif

View File

@ -1689,6 +1689,55 @@ void setInitialExtSignals() {
DOUTIF_RISING_LNGTH_PORT_1_MSK));
}
int setGainCaps(int caps) {
LOG(logINFO, ("Setting gain caps to: %u\n", caps));
int csr = M3SetGainCaps(caps);
return setChipStatusRegister(csr);
}
int setInterpolation(int enable) {
LOG(logINFO,
("%s Interpolation\n", enable == 0 ? "Disabling" : "Enabling"));
if (enable) {
setCounterMask(MAX_COUNTER_MSK);
if (getCounterMask() != MAX_COUNTER_MSK) {
LOG(logERROR,
("Could not set interpolation. Could not enable all counters"));
return FAIL;
}
LOG(logINFO, ("\tEnabled all counters\n"));
}
int csr = M3SetInterpolation(enable);
return setChipStatusRegister(csr);
}
int setPumpProbe(int enable) {
LOG(logINFO, ("%s Pump Probe\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = M3SetPumpProbe(enable);
return setChipStatusRegister(csr);
}
int setDigitalPulsing(int enable) {
LOG(logINFO,
("%s Digital Pulsing\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = M3SetDigitalPulsing(enable);
return setChipStatusRegister(csr);
}
int setAnalogPulsing(int enable) {
LOG(logINFO,
("%s Analog Pulsing\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = M3SetAnalogPulsing(enable);
return setChipStatusRegister(csr);
}
int setNegativePolarity(int enable) {
LOG(logINFO,
("%s Negative Polarity\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = M3SetNegativePolarity(enable);
return setChipStatusRegister(csr);
}
void setExtSignal(int signalIndex, enum externalSignalFlag mode) {
LOG(logDEBUG1, ("Setting signal flag[%d] to %d\n", signalIndex, mode));
@ -2623,21 +2672,3 @@ int setChipStatusRegister(int csr) {
return iret;
}
int setGainCaps(int caps) {
LOG(logINFO, ("Setting gain caps to: %u\n", caps));
// Update only gain caps, leave the rest of the CSR unchanged
int csr = getChipStatusRegister();
csr &= ~GAIN_MASK;
caps = gainCapsToCsr(caps);
// caps &= GAIN_MASK;
csr |= caps;
return setChipStatusRegister(csr);
}
int getGainCaps() {
int csr = getChipStatusRegister();
int caps = csrToGainCaps(csr);
return caps;
}

View File

@ -376,7 +376,7 @@ int setHighVoltage(int val);
// parameters - timing, extsig
#ifdef EIGERD
int setMaster(enum MASTERINDEX m);
int setTop(enum TOPINDEX t);
int setTop(enum TOPINDEX t);
int isTop(int *retval);
#endif
#if defined(MYTHEN3D) || defined(EIGERD) || defined(GOTTHARDD) || \
@ -391,9 +391,13 @@ void setTiming(enum timingMode arg);
enum timingMode getTiming();
#ifdef MYTHEN3D
void setInitialExtSignals();
int setGainCaps(int caps);
int getGainCaps();
int setChipStatusRegister(int csr);
int setGainCaps(int caps);
int setInterpolation(int enable);
int setPumpProbe(int enable);
int setDigitalPulsing(int enable);
int setAnalogPulsing(int enable);
int setNegativePolarity(int enable);
int setDACS(int *dacs);
#endif
#if defined(GOTTHARDD) || defined(MYTHEN3D)

View File

@ -292,4 +292,14 @@ void receive_program_default(int file_des, enum PROGRAM_INDEX index,
int get_update_mode(int);
int set_update_mode(int);
int get_top(int);
int set_top(int);
int set_top(int);
int get_polarity(int);
int set_polarity(int);
int get_interpolation(int);
int set_interpolation(int);
int get_pump_probe(int);
int set_pump_probe(int);
int get_analog_pulsing(int);
int set_analog_pulsing(int);
int get_digital_pulsing(int);
int set_digital_pulsing(int);

View File

@ -470,6 +470,16 @@ void function_table() {
flist[F_SET_MASTER] = &set_master;
flist[F_GET_TOP] = &get_top;
flist[F_SET_TOP] = &set_top;
flist[F_GET_POLARITY] = &get_polarity;
flist[F_SET_POLARITY] = &set_polarity;
flist[F_GET_INTERPOLATION] = &get_interpolation;
flist[F_SET_INTERPOLATION] = &set_interpolation;
flist[F_GET_PUMP_PROBE] = &get_pump_probe;
flist[F_SET_PUMP_PROBE] = &set_pump_probe;
flist[F_GET_ANALOG_PULSING] = &get_analog_pulsing;
flist[F_SET_ANALOG_PULSING] = &set_analog_pulsing;
flist[F_GET_DIGITAL_PULSING] = &get_digital_pulsing;
flist[F_SET_DIGITAL_PULSING] = &set_digital_pulsing;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -8236,33 +8246,35 @@ int set_gain_caps(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting gain caps to: %u\n", arg));
int retval = -1;
#ifndef MYTHEN3D
functionNotImplemented();
#else
if (Server_VerifyLock() == OK) {
setGainCaps(arg);
retval = getChipStatusRegister(); // TODO! fix
LOG(logDEBUG1, ("gain caps retval: %u\n", retval));
ret = setGainCaps(arg);
if (ret == FAIL) {
strcpy(mess, "Could not set gain caps.\n");
LOG(logERROR, (mess));
} else {
int retval = getGainCaps();
validate(&ret, mess, (int)arg, (int)retval, "set gain caps", DEC);
LOG(logDEBUG1, ("gain caps retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_gain_caps(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logINFO, ("Getting gain caps\n"));
LOG(logDEBUG1, ("Getting gain caps\n"));
#ifndef MYTHEN3D
functionNotImplemented();
#else
if (Server_VerifyLock() == OK) {
retval = getGainCaps();
LOG(logDEBUG1, ("Gain caps: %u\n", retval));
}
retval = getGainCaps();
LOG(logDEBUG1, ("Gain caps: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
@ -9772,4 +9784,246 @@ int set_top(int file_des) {
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_polarity(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum polarity retval = POSITIVE;
LOG(logDEBUG1, ("Getting negativepolarity\n"));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// get only
retval = getNegativePolarity() ? NEGATIVE : POSITIVE;
LOG(logDEBUG1, ("negative polarity retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_polarity(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum polarity arg = POSITIVE;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logDEBUG1, ("Setting negative polarity: %u\n", (int)arg));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
switch (arg) {
case POSITIVE:
ret = setNegativePolarity(0);
break;
case NEGATIVE:
ret = setNegativePolarity(1);
break;
default:
modeNotImplemented("Polarity index", (int)arg);
break;
}
if (ret == FAIL) {
sprintf(mess, "Could not set polarity\n");
LOG(logERROR, (mess));
} else {
enum polarity retval = getNegativePolarity() ? NEGATIVE : POSITIVE;
validate(&ret, mess, (int)arg, (int)retval, "set polarity", DEC);
LOG(logDEBUG1, ("negative polarity retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_interpolation(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logDEBUG1, ("Getting interpolation\n"));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// get only
retval = getInterpolation();
LOG(logDEBUG1, ("interpolation retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_interpolation(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logINFO, ("Setting interpolation: %u\n", arg));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
ret = setInterpolation(arg);
if (ret == FAIL) {
if (arg)
sprintf(mess, "Could not set interpolation or enable all "
"counters for it.\n");
else
sprintf(mess, "Could not set interpolation\n");
LOG(logERROR, (mess));
} else {
int retval = getInterpolation();
validate(&ret, mess, (int)arg, (int)retval, "set interpolation",
DEC);
LOG(logDEBUG1, ("interpolation retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_pump_probe(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logDEBUG1, ("Getting pump probe\n"));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// get only
retval = getPumpProbe();
LOG(logDEBUG1, ("pump probe retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_pump_probe(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logINFO, ("Setting pump probe: %u\n", arg));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
ret = setPumpProbe(arg);
if (ret == FAIL) {
sprintf(mess, "Could not set pump probe\n");
LOG(logERROR, (mess));
} else {
int retval = getPumpProbe();
validate(&ret, mess, (int)arg, (int)retval, "set pump probe", DEC);
LOG(logDEBUG1, ("pump probe retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_analog_pulsing(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logDEBUG1, ("Getting analog pulsing\n"));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// get only
retval = getAnalogPulsing();
LOG(logDEBUG1, ("analog pulsing retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_analog_pulsing(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logINFO, ("Setting analog pulsing: %u\n", arg));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
ret = setAnalogPulsing(arg);
if (ret == FAIL) {
sprintf(mess, "Could not set analog pulsing\n");
LOG(logERROR, (mess));
} else {
int retval = getAnalogPulsing();
validate(&ret, mess, (int)arg, (int)retval, "set analog pulsing",
DEC);
LOG(logDEBUG1, ("analog pulsing retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_digital_pulsing(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logDEBUG1, ("Getting digital pulsing\n"));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// get only
retval = getDigitalPulsing();
LOG(logDEBUG1, ("digital pulsing retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_digital_pulsing(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logINFO, ("Setting digital pulsing: %u\n", arg));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
ret = setDigitalPulsing(arg);
if (ret == FAIL) {
sprintf(mess, "Could not set digital pulsing\n");
LOG(logERROR, (mess));
} else {
int retval = getDigitalPulsing();
validate(&ret, mess, (int)arg, (int)retval, "set digital pulsing",
DEC);
LOG(logDEBUG1, ("digital pulsing retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}

View File

@ -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);
///@}

View File

@ -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(

View File

@ -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 {

View File

@ -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);

View File

@ -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);
/**************************************************
* *

View File

@ -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));
}
}

View File

@ -43,6 +43,7 @@ std::string ToString(const defs::portPosition s);
std::string ToString(const defs::streamingInterface s);
std::string ToString(const defs::vetoAlgorithm s);
std::string ToString(const defs::gainMode s);
std::string ToString(const defs::polarity s);
std::string ToString(const slsDetectorDefs::xy &coord);
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord);
@ -313,6 +314,7 @@ template <> defs::portPosition StringTo(const std::string &s);
template <> defs::streamingInterface StringTo(const std::string &s);
template <> defs::vetoAlgorithm StringTo(const std::string &s);
template <> defs::gainMode StringTo(const std::string &s);
template <> defs::polarity StringTo(const std::string &s);
template <> uint32_t StringTo(const std::string &s);
template <> uint64_t StringTo(const std::string &s);

View File

@ -438,6 +438,8 @@ enum streamingInterface {
FIX_G0
};
enum polarity { POSITIVE, NEGATIVE };
#ifdef __cplusplus
/** scan structure */

View File

@ -260,9 +260,19 @@ enum detFuncs {
F_SET_MASTER,
F_GET_TOP,
F_SET_TOP,
F_GET_POLARITY,
F_SET_POLARITY,
F_GET_INTERPOLATION,
F_SET_INTERPOLATION,
F_GET_PUMP_PROBE,
F_SET_PUMP_PROBE,
F_GET_ANALOG_PULSING,
F_SET_ANALOG_PULSING,
F_GET_DIGITAL_PULSING,
F_SET_DIGITAL_PULSING,
NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
RECEIVER_ENUM_START = 512, /**< detector function should not exceed this
(detector server should not compile anyway) */
F_EXEC_RECEIVER_COMMAND,
@ -623,6 +633,16 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_MASTER: return "F_SET_MASTER";
case F_GET_TOP: return "F_GET_TOP";
case F_SET_TOP: return "F_SET_TOP";
case F_GET_POLARITY: return "F_GET_POLARITY";
case F_SET_POLARITY: return "F_SET_POLARITY";
case F_GET_INTERPOLATION: return "F_GET_INTERPOLATION";
case F_SET_INTERPOLATION: return "F_SET_INTERPOLATION";
case F_GET_PUMP_PROBE: return "F_GET_PUMP_PROBE";
case F_SET_PUMP_PROBE: return "F_SET_PUMP_PROBE";
case F_GET_ANALOG_PULSING: return "F_GET_ANALOG_PULSING";
case F_SET_ANALOG_PULSING: return "F_SET_ANALOG_PULSING";
case F_GET_DIGITAL_PULSING: return "F_GET_DIGITAL_PULSING";
case F_SET_DIGITAL_PULSING: return "F_SET_DIGITAL_PULSING";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

@ -2,13 +2,14 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */
#define GITBRANCH "developer"
#define APILIB 0x220405
#define APIRECEIVER 0x220405
#define APILIB 0x220408
#define APIRECEIVER 0x220408
#define APIGUI 0x220328
#define APICTB 0x220405
#define APIGOTTHARD 0x220405
#define APIGOTTHARD2 0x220405
#define APIJUNGFRAU 0x220405
#define APIMYTHEN3 0x220405
#define APIMOENCH 0x220405
#define APIEIGER 0x220405
#define APICTB 0x220408
#define APIGOTTHARD 0x220408
#define APIGOTTHARD2 0x220408
#define APIJUNGFRAU 0x220408
#define APIMYTHEN3 0x220408
#define APIMOENCH 0x220408
#define APIEIGER 0x220408

View File

@ -642,6 +642,17 @@ std::string ToString(const defs::gainMode s) {
}
}
std::string ToString(const defs::polarity s) {
switch (s) {
case defs::POSITIVE:
return std::string("pos");
case defs::NEGATIVE:
return std::string("neg");
default:
return std::string("Unknown");
}
}
const std::string &ToString(const std::string &s) { return s; }
template <> defs::detectorType StringTo(const std::string &s) {
@ -1055,6 +1066,14 @@ template <> defs::gainMode StringTo(const std::string &s) {
throw sls::RuntimeError("Unknown gain mode " + s);
}
template <> defs::polarity StringTo(const std::string &s) {
if (s == "pos")
return defs::POSITIVE;
if (s == "neg")
return defs::NEGATIVE;
throw sls::RuntimeError("Unknown polarity mode " + s);
}
template <> uint32_t StringTo(const std::string &s) {
int base = s.find("0x") != std::string::npos ? 16 : 10;
return std::stoul(s, nullptr, base);