This commit is contained in:
maliakal_d 2020-09-21 11:23:46 +02:00
parent d65030f5ca
commit 569c014d3c
7 changed files with 91 additions and 40 deletions

View File

@ -1264,6 +1264,11 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def adcinvert(self): def adcinvert(self):
"""[Ctb][Moench][Jungfrau] ADC Inversion Mask.
Note
-----
[Jungfrau][Moench] Inversions on top of the default mask.
"""
return self.getADCInvert() return self.getADCInvert()
@adcinvert.setter @adcinvert.setter
@ -1831,6 +1836,7 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def bursts(self): def bursts(self):
"""[Gotthard2] Number of bursts per aquire. Only in auto timing mode and burst mode."""
return self.getNumberOfBursts() return self.getNumberOfBursts()
@bursts.setter @bursts.setter
@ -1878,6 +1884,7 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def cdsgain(self): def cdsgain(self):
"""[Gotthard2] Enable or disable CDS gain. Default is disabled. """
return self.getCDSGain() return self.getCDSGain()
@cdsgain.setter @cdsgain.setter
@ -1888,6 +1895,11 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def burstmode(self): def burstmode(self):
"""[Gotthard2] Burst mode of detector. Enum: burstMode
Note
----
BURST_INTERNAL (default), BURST_EXTERNAL, CONTINUOUS_INTERNAL, CONTINUOUS_EXTERNAL
"""
return self.getBurstMode() return self.getBurstMode()
@burstmode.setter @burstmode.setter
@ -1896,6 +1908,22 @@ class Detector(CppDetectorApi):
@property @property
def burstperiod(self): def burstperiod(self):
"""
[Gotthard2] Period between 2 bursts. Only in burst mode and auto timing mode.
Note
-----
:getter: always returns in seconds. To get in datetime.delta, use getBurstPeriod
Example
-----------
>>> d.burstperiod = 1.05
>>> d.burstperiod = datetime.timedelta(minutes = 3, seconds = 1.23)
>>> d.burstperiod
181.23
>>> d.getBurstPeriod()
[datetime.timedelta(seconds=181, microseconds=230000)]
"""
return ut.reduce_time(self.getBurstPeriod()) return ut.reduce_time(self.getBurstPeriod())
@burstperiod.setter @burstperiod.setter
@ -2031,6 +2059,7 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def adcenable(self): def adcenable(self):
"""[Ctb][Moench] ADC Enable Mask for 1Gb. Enable for each 32 ADC channel."""
return self.getADCEnableMask() return self.getADCEnableMask()
@adcenable.setter @adcenable.setter
@ -2040,6 +2069,10 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def adcenable10g(self): def adcenable10g(self):
"""[Ctb][Moench] ADC Enable Mask for 10Gb mode for each 32 ADC channel.
Note
-----
If any of a consecutive 4 bits are enabled, the complete 4 bits are enabled."""
return self.getTenGigaADCEnableMask() return self.getTenGigaADCEnableMask()
@adcenable10g.setter @adcenable10g.setter

View File

@ -432,8 +432,8 @@ class Detector {
*/ */
void acquire(); void acquire();
/** If acquisition aborted, use this to clear before starting next /** If acquisition aborted during blocking acquire, use this to clear
* acquisition */ * acquiring flag in shared memory before starting next acquisition */
void clearAcquiringFlag(); void clearAcquiringFlag();
/** Non Blocking: Start receiver listener and create data file if file write /** Non Blocking: Start receiver listener and create data file if file write
@ -956,13 +956,14 @@ class Detector {
/** [Eiger] */ /** [Eiger] */
Result<bool> getActive(Positions pos = {}) const; Result<bool> getActive(Positions pos = {}) const;
/** [Eiger] */ /** [Eiger] activated by default at hostname command. Deactivated does not
* send data or communicated with FEB or BEB */
void setActive(const bool active, Positions pos = {}); void setActive(const bool active, Positions pos = {});
/** [Eiger] */ /** [Eiger] */
Result<bool> getRxPadDeactivatedMode(Positions pos = {}) const; Result<bool> getRxPadDeactivatedMode(Positions pos = {}) const;
/** [Eiger] Pad deactivated modules in receiver */ /** [Eiger] Pad deactivated modules in receiver. Enabled by default */
void setRxPadDeactivatedMode(bool pad, Positions pos = {}); void setRxPadDeactivatedMode(bool pad, Positions pos = {});
/** [Eiger] Advanced */ /** [Eiger] Advanced */
@ -1035,7 +1036,7 @@ class Detector {
* automatically after 93.75% of exposure time (only for longer than * automatically after 93.75% of exposure time (only for longer than
* 100us).\n * 100us).\n
* Default is false or this mode disabled(comparator enabled throughout). * Default is false or this mode disabled(comparator enabled throughout).
* true enables " "mode. 0 disables mode. * true enables mode. 0 disables mode.
*/ */
void setAutoCompDisable(bool value, Positions pos = {}); void setAutoCompDisable(bool value, Positions pos = {});
@ -1082,7 +1083,8 @@ class Detector {
*/ */
void setROI(defs::ROI value, int module_id); void setROI(defs::ROI value, int module_id);
/** [Gotthard] Clear ROI */ /** [Gotthard] Clear ROI to all channels enabled. Default is all channels
* enabled. */
void clearROI(Positions pos = {}); void clearROI(Positions pos = {});
/** [Gotthard] */ /** [Gotthard] */
@ -1106,7 +1108,8 @@ class Detector {
/** [Gotthard2] only in burst mode and auto timing mode */ /** [Gotthard2] only in burst mode and auto timing mode */
Result<ns> getBurstPeriod(Positions pos = {}) const; Result<ns> getBurstPeriod(Positions pos = {}) const;
/** [Gotthard2] only in burst mode and auto timing mode */ /** [Gotthard2] Period between 2 bursts. Only in burst mode and auto timing
* mode */
void setBurstPeriod(ns value, Positions pos = {}); void setBurstPeriod(ns value, Positions pos = {});
/** [Gotthard2] offset channel, increment channel */ /** [Gotthard2] offset channel, increment channel */
@ -1285,7 +1288,8 @@ class Detector {
/** [CTB][Moench] */ /** [CTB][Moench] */
Result<uint32_t> getTenGigaADCEnableMask(Positions pos = {}) const; Result<uint32_t> getTenGigaADCEnableMask(Positions pos = {}) const;
/** [CTB][Moench] */ /** [CTB][Moench] If any of a consecutive 4 bits are enabled, the "
"complete 4 bits are enabled */
void setTenGigaADCEnableMask(uint32_t mask, Positions pos = {}); void setTenGigaADCEnableMask(uint32_t mask, Positions pos = {});
///@{ ///@{
@ -1545,12 +1549,16 @@ class Detector {
/** Advanced user Function! */ /** Advanced user Function! */
void clearBit(uint32_t addr, int bitnr, Positions pos = {}); void clearBit(uint32_t addr, int bitnr, Positions pos = {});
/** Advanced user Function! */
Result<int> getBit(uint32_t addr, int bitnr, Positions pos = {});
/** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Advanced user /** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Advanced user
* Function! */ * Function! */
void executeFirmwareTest(Positions pos = {}); void executeFirmwareTest(Positions pos = {});
/** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Advanced user /** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Advanced user
* Function! */ * Function! Writes different values in a R/W register and confirms the
* writes to check bus */
void executeBusTest(Positions pos = {}); void executeBusTest(Positions pos = {});
/** [Gotthard][Jungfrau][CTB][Moench] Advanced user Function! not possible /** [Gotthard][Jungfrau][CTB][Moench] Advanced user Function! not possible
@ -1567,7 +1575,8 @@ class Detector {
/** [CTB][Moench][Jungfrau] Advanced user Function! */ /** [CTB][Moench][Jungfrau] Advanced user Function! */
Result<uint32_t> getADCInvert(Positions pos = {}) const; Result<uint32_t> getADCInvert(Positions pos = {}) const;
/** [CTB][Moench][Jungfrau] Advanced user Function! */ /** [CTB][Moench][Jungfrau] Advanced user Function! \n
[Jungfrau] Inversions on top of default mask */
void setADCInvert(uint32_t value, Positions pos = {}); void setADCInvert(uint32_t value, Positions pos = {});
///@{ ///@{

View File

@ -1584,7 +1584,7 @@ std::string CmdProxy::ClearROI(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "\n\t[Gotthard] Resets Region of interest in detector. All " os << "\n\t[Gotthard] Resets Region of interest in detector. All "
"channels enabled. Default is all channels." "channels enabled. Default is all channels enabled."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get"); throw sls::RuntimeError("Cannot get");
@ -2554,16 +2554,13 @@ std::string CmdProxy::BitOperations(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
if (cmd == "setbit") { if (cmd == "setbit") {
os << "[address] [value\n\t[Moench] Minimum energy threshold (soft " os << "[reg address in hex] [bit index]\n\tSets bit in address."
"setting) for processor."
<< '\n'; << '\n';
} else if (cmd == "clearbit") { } else if (cmd == "clearbit") {
os << "[n_value]\n\t[Moench] Maximum energy threshold (soft " os << "[reg address in hex] [bit index]\n\tClears bit in address."
"setting) for processor."
<< '\n'; << '\n';
} else if (cmd == "getbit") { } else if (cmd == "getbit") {
os << "[n_value]\n\t[Moench] Maximum energy threshold (soft " os << "[reg address in hex] [bit index]\n\tGets bit in address."
"setting) for processor."
<< '\n'; << '\n';
} else { } else {
throw sls::RuntimeError( throw sls::RuntimeError(
@ -2587,12 +2584,8 @@ std::string CmdProxy::BitOperations(int action) {
if (cmd == "setbit" || cmd == "clearbit") { if (cmd == "setbit" || cmd == "clearbit") {
throw sls::RuntimeError("Cannot get"); throw sls::RuntimeError("Cannot get");
} }
auto t = det->readRegister(addr, std::vector<int>{det_id}); auto t = det->getBit(addr, bitnr, std::vector<int>{det_id});
Result<int> result(t.size()); os << OutString(t) << '\n';
for (unsigned int i = 0; i < t.size(); ++i) {
result[i] = ((t[i] >> bitnr) & 0x1);
}
os << OutString(result) << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
if (cmd == "getbit") { if (cmd == "getbit") {
throw sls::RuntimeError("Cannot put"); throw sls::RuntimeError("Cannot put");

View File

@ -1589,7 +1589,8 @@ class CmdProxy {
DAC_COMMAND( DAC_COMMAND(
adcvpp, getDAC, setDAC, defs::ADC_VPP, adcvpp, getDAC, setDAC, defs::ADC_VPP,
"[dac or mV value][(optional unit) mV] \n\t[Ctb][Moench] Vpp of " "[dac or mV value][(optional unit) mV] \n\t[Ctb][Moench] Vpp of "
"ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> 2V."); "ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> 2V. "
"\n\tAdvanced User function! ");
DAC_COMMAND(vb_ds, getDAC, setDAC, defs::VB_DS, DAC_COMMAND(vb_ds, getDAC, setDAC, defs::VB_DS,
"[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for " "[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for "
@ -1669,9 +1670,10 @@ class CmdProxy {
/* acquisition */ /* acquisition */
EXECUTE_SET_COMMAND_NOID(clearbusy, clearAcquiringFlag, EXECUTE_SET_COMMAND_NOID(
"\n\tClears Acquiring Flag for unexpected acquire " clearbusy, clearAcquiringFlag,
"command terminations."); "\n\tIf acquisition aborted during acquire command, use this to clear "
"acquiring flag in shared memory before starting next acquisition");
EXECUTE_SET_COMMAND_NOID( EXECUTE_SET_COMMAND_NOID(
rx_start, startReceiver, rx_start, startReceiver,
@ -2107,9 +2109,10 @@ class CmdProxy {
"timing mode and burst mode. Use timing command to set timing mode and " "timing mode and burst mode. Use timing command to set timing mode and "
"burstmode command to set burst mode."); "burstmode command to set burst mode.");
TIME_COMMAND(burstperiod, getBurstPeriod, setBurstPeriod, TIME_COMMAND(
"[duration] [(optional unit) ns|us|ms|s]\n\t[Gotthard2] Burst " burstperiod, getBurstPeriod, setBurstPeriod,
"period. Only in burst mode and auto timing mode."); "[duration] [(optional unit) ns|us|ms|s]\n\t[Gotthard2] "
"Period between 2 bursts. Only in burst mode and auto timing mode.");
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
cdsgain, getCDSGain, setCDSGain, StringTo<bool>, cdsgain, getCDSGain, setCDSGain, StringTo<bool>,
@ -2171,13 +2174,13 @@ class CmdProxy {
INTEGER_COMMAND_HEX(adcenable, getADCEnableMask, setADCEnableMask, INTEGER_COMMAND_HEX(adcenable, getADCEnableMask, setADCEnableMask,
StringTo<uint32_t>, StringTo<uint32_t>,
"[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 1Gb " "[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 1Gb "
"Mode for each 32 ADC channel."); "Enable for each 32 ADC channel.");
INTEGER_COMMAND_HEX( INTEGER_COMMAND_HEX(
adcenable10g, getTenGigaADCEnableMask, setTenGigaADCEnableMask, adcenable10g, getTenGigaADCEnableMask, setTenGigaADCEnableMask,
StringTo<uint32_t>, StringTo<uint32_t>,
"[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 10Gb mode for each 32 " "[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 10Gb mode for each 32 "
"ADC channel. However, if any of consecutive 4 bits are enabled, the " "ADC channel. However, if any of a consecutive 4 bits are enabled, the "
"complete 4 bits are enabled."); "complete 4 bits are enabled.");
/* CTB Specific */ /* CTB Specific */
@ -2321,7 +2324,8 @@ class CmdProxy {
EXECUTE_SET_COMMAND( EXECUTE_SET_COMMAND(
bustest, executeBusTest, bustest, executeBusTest,
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Bus test, " "\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Bus test, "
"ie. keeps writing and reading back different values in R/W register."); "ie. Writes different values in a R/W register and confirms the "
"writes to check bus.\n\tAdvanced User function!");
INTEGER_COMMAND_HEX( INTEGER_COMMAND_HEX(
adcinvert, getADCInvert, setADCInvert, StringTo<uint32_t>, adcinvert, getADCInvert, setADCInvert, StringTo<uint32_t>,

View File

@ -384,7 +384,6 @@ Result<int> Detector::getClockFrequency(int clkIndex, Positions pos) {
return pimpl->Parallel(&Module::getClockFrequency, pos, clkIndex); return pimpl->Parallel(&Module::getClockFrequency, pos, clkIndex);
} }
Result<int> Detector::getClockPhase(int clkIndex, Positions pos) { Result<int> Detector::getClockPhase(int clkIndex, Positions pos) {
return pimpl->Parallel(&Module::getClockPhase, pos, clkIndex, false); return pimpl->Parallel(&Module::getClockPhase, pos, clkIndex, false);
} }
@ -1883,6 +1882,10 @@ void Detector::clearBit(uint32_t addr, int bitnr, Positions pos) {
pimpl->Parallel(&Module::clearBit, pos, addr, bitnr); pimpl->Parallel(&Module::clearBit, pos, addr, bitnr);
} }
Result<int> Detector::getBit(uint32_t addr, int bitnr, Positions pos) {
return pimpl->Parallel(&Module::getBit, pos, addr, bitnr);
}
void Detector::executeFirmwareTest(Positions pos) { void Detector::executeFirmwareTest(Positions pos) {
pimpl->Parallel(&Module::executeFirmwareTest, pos); pimpl->Parallel(&Module::executeFirmwareTest, pos);
} }

View File

@ -2199,21 +2199,29 @@ uint32_t Module::writeRegister(uint32_t addr, uint32_t val) {
return sendToDetectorStop<uint32_t>(F_WRITE_REGISTER, args); return sendToDetectorStop<uint32_t>(F_WRITE_REGISTER, args);
} }
uint32_t Module::setBit(uint32_t addr, int n) { void Module::setBit(uint32_t addr, int n) {
if (n < 0 || n > 31) { if (n < 0 || n > 31) {
throw RuntimeError("Bit number " + std::to_string(n) + " out of Range"); throw RuntimeError("Bit number " + std::to_string(n) + " out of Range");
} else { } else {
uint32_t val = readRegister(addr); uint32_t val = readRegister(addr);
return writeRegister(addr, val | 1 << n); writeRegister(addr, val | 1 << n);
} }
} }
uint32_t Module::clearBit(uint32_t addr, int n) { void Module::clearBit(uint32_t addr, int n) {
if (n < 0 || n > 31) { if (n < 0 || n > 31) {
throw RuntimeError("Bit number " + std::to_string(n) + " out of Range"); throw RuntimeError("Bit number " + std::to_string(n) + " out of Range");
} else { } else {
uint32_t val = readRegister(addr); uint32_t val = readRegister(addr);
return writeRegister(addr, val & ~(1 << n)); writeRegister(addr, val & ~(1 << n));
}
}
int Module::getBit(uint32_t addr, int n) {
if (n < 0 || n > 31) {
throw RuntimeError("Bit number " + std::to_string(n) + " out of Range");
} else {
return ((readRegister(addr) >> n) & 0x1);
} }
} }

View File

@ -497,8 +497,9 @@ class Module : public virtual slsDetectorDefs {
void rebootController(); void rebootController();
uint32_t readRegister(uint32_t addr) const; uint32_t readRegister(uint32_t addr) const;
uint32_t writeRegister(uint32_t addr, uint32_t val); uint32_t writeRegister(uint32_t addr, uint32_t val);
uint32_t setBit(uint32_t addr, int n); void setBit(uint32_t addr, int n);
uint32_t clearBit(uint32_t addr, int n); void clearBit(uint32_t addr, int n);
int getBit(uint32_t addr, int n);
void executeFirmwareTest(); void executeFirmwareTest();
void executeBusTest(); void executeBusTest();
void writeAdcRegister(uint32_t addr, uint32_t val); void writeAdcRegister(uint32_t addr, uint32_t val);