This commit is contained in:
maliakal_d 2020-09-23 12:32:51 +02:00
parent a4bdffd0b9
commit bd4299fd15
5 changed files with 97 additions and 40 deletions

View File

@ -221,6 +221,13 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def rx_threads(self): def rx_threads(self):
"""
Get thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1].
Note
-----
If no streamer yet or there is no second interface, it gives 0 in its place.
:setter: Not Implemented
"""
return self.getRxThreadIds() return self.getRxThreadIds()
@property @property
@ -1276,11 +1283,18 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def scanerrmsg(self): def scanerrmsg(self):
"""Gets Scan error message if scan ended in error for non blocking acquisitions."""
return self.getScanErrorMessage() return self.getScanErrorMessage()
@property @property
@element @element
def rx_zmqstartfnum(self): def rx_zmqstartfnum(self):
"""
The starting frame index to stream out.
Note
----
0 by default, which streams the first frame in an acquisition, and then depending on the rx zmq frequency/ timer.
"""
return self.getRxZmqStartingFrame() return self.getRxZmqStartingFrame()
@rx_zmqstartfnum.setter @rx_zmqstartfnum.setter
@ -1307,6 +1321,22 @@ class Detector(CppDetectorApi):
@property @property
def slowadc(self): def slowadc(self):
"""
[Ctb] Slow ADC channel in uV of all channels or specific ones from 0-7.
Example
-------
>>> d.slowadc
0: 0 uV
1: 0 uV
2: 0 uV
3: 0 uV
4: 0 uV
5: 0 uV
6: 0 uV
7: 0 uV
>>> d.slowadc[3]
0
"""
return SlowAdcProxy(self) return SlowAdcProxy(self)
@property @property
@ -1340,6 +1370,7 @@ class Detector(CppDetectorApi):
@property @property
def settingslist(self): def settingslist(self):
"""List of settings implemented for this detector."""
return self.getSettingsList() return self.getSettingsList()
@property @property
@ -1489,18 +1520,20 @@ class Detector(CppDetectorApi):
@property @property
def rx_jsonpara(self): def rx_jsonpara(self):
""" """
Get the receiver additional json parameter. In case the parameter is different between Set the receiver additional json parameter.
the modules a list of strings will be returned. On setting the value is automatically Note
converted to a string. ----
Use only if to be processed by an intermediate user process listening to receiver zmq packets, such as Moench \n
If not found, the pair is appended. Empty value deletes parameter. Max 20 characters for each key/value.\n
On setting the value is automatically, it is converted to a string.
Example Example
----------- -----------
>>> d.rx_jsonpara['emin'] >>> d.rx_jsonpara['emin']
'4500' '4500'
>>> d.rx_jsonpara['emin'] = 5000 >>> d.rx_jsonpara['emin'] = 5000
>>> d.rx_jsonpara
emax: 30
emin: 5000
""" """
return JsonProxy(self) return JsonProxy(self)
@ -1508,6 +1541,21 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def rx_jsonaddheader(self): def rx_jsonaddheader(self):
"""
Additional json header to be streamed out from receiver via zmq.
Note
-----
Default is empty. Max 20 characters for each key/value\n
Use only if to be processed by an intermediate user process listening to receiver zmq packets, such as Moench \n
Empty value deletes header.
Example
-------
>>> d.rx_jsonaddheader
{}
>>> d.rx_jsonaddheader = {"key1": "value1", "key2":"value2"}
>>> d.rx_jsonaddheader
{'emax': '30', 'emin': '50'}
"""
return self.getAdditionalJsonHeader() return self.getAdditionalJsonHeader()
@rx_jsonaddheader.setter @rx_jsonaddheader.setter
@ -2213,6 +2261,10 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def samples(self): def samples(self):
"""
[CTB] Number of samples (both analog and digitial) expected. \n
[Moench] Number of samples (analog only)
"""
return self.getNumberOfAnalogSamples() return self.getNumberOfAnalogSamples()
@samples.setter @samples.setter

View File

@ -51,12 +51,12 @@ class SlowAdcProxy:
def __repr__(self): def __repr__(self):
rstr = '' rstr = ''
for i in range(7): for i in range(8):
r = element_if_equal(self.__getitem__(i)) r = element_if_equal(self.__getitem__(i))
if isinstance(r, list): if isinstance(r, list):
rstr += ' '.join(f'{item} mV' for item in r) rstr += ' '.join(f'{item} uV' for item in r)
else: else:
rstr += f'{i}: {r} mV\n' rstr += f'{i}: {r} uV\n'
return rstr.strip('\n') return rstr.strip('\n')

View File

@ -483,13 +483,15 @@ class Detector {
Result<defs::scanParameters> getScan(Positions pos = {}) const; Result<defs::scanParameters> getScan(Positions pos = {}) const;
/** enables/ disables scans for dac, trimbits [Eiger/ Mythen3] /** enables/ disables scans for dac and trimbits \n
* TRIMBIT_SCAN. Enabling scan sets number of frames to number of steps in * Enabling scan sets number of frames to number of steps in
* receiver. Disabling scan sets number of frames to 1 */ * receiver. \n To cancel scan configuration, set dac to '0', which also
* sets number of frames to 1 \n [Eiger/ Mythen3] Trimbits using
* TRIMBIT_SCAN*/
void setScan(const defs::scanParameters t); void setScan(const defs::scanParameters t);
/** gets scan error message in case of error during scan in case of non /** Gets Scan error message if scan ended in error for non blocking
* blocking acquisition (startDetector, not acquire) */ * acquisitions.*/
Result<std::string> getScanErrorMessage(Positions pos = {}) const; Result<std::string> getScanErrorMessage(Positions pos = {}) const;
///@{ ///@{
@ -517,7 +519,7 @@ class Detector {
Result<int> getSelectedUDPInterface(Positions pos = {}) const; Result<int> getSelectedUDPInterface(Positions pos = {}) const;
/** /**
* [Jungfrau: * [Jungfrau]
* Effective only when number of interfaces is 1. * Effective only when number of interfaces is 1.
* Options: 0 (outer, default), 1(inner)] //TODO: enum? * Options: 0 (outer, default), 1(inner)] //TODO: enum?
*/ */
@ -728,6 +730,9 @@ class Detector {
/** Client IP Address that last communicated with the receiver */ /** Client IP Address that last communicated with the receiver */
Result<sls::IpAddr> getRxLastClientIP(Positions pos = {}) const; Result<sls::IpAddr> getRxLastClientIP(Positions pos = {}) const;
/** Get thread ids from the receiver in order of [parent, tcp, listener 0,
* processor 0, streamer 0, listener 1, processor 1, streamer 1]. If no
* streamer yet or there is no second interface, it gives 0 in its place. */
Result<std::array<pid_t, NUM_RX_THREAD_IDS>> Result<std::array<pid_t, NUM_RX_THREAD_IDS>>
getRxThreadIds(Positions pos = {}) const; getRxThreadIds(Positions pos = {}) const;
///@{ ///@{
@ -1408,7 +1413,8 @@ class Detector {
* (instead of executing line by line)*/ * (instead of executing line by line)*/
void setPattern(const std::string &fname, Positions pos = {}); void setPattern(const std::string &fname, Positions pos = {});
/** [CTB][Moench][Mythen3] */ /** [CTB][Moench][Mythen3] [Ctb][Moench][Mythen3] Saves pattern to file
* (ascii). \n [Ctb][Moench] Also executes pattern.*/
void savePattern(const std::string &fname); void savePattern(const std::string &fname);
/** [CTB][Moench] */ /** [CTB][Moench] */
@ -1487,8 +1493,10 @@ class Detector {
Result<std::map<std::string, std::string>> Result<std::map<std::string, std::string>>
getAdditionalJsonHeader(Positions pos = {}) const; getAdditionalJsonHeader(Positions pos = {}) const;
/** [Moench] If empty, reset additional json header. Max 20 characters for /** [Moench] If empty, reset additional json header. Default is empty. Max
* each key/value */ * 20 characters for each key/value. Empty value deletes header. Use only if
* to be processed by an intermediate user process listening to receiver zmq
* packets such as in Moench */
void setAdditionalJsonHeader( void setAdditionalJsonHeader(
const std::map<std::string, std::string> &jsonHeader, const std::map<std::string, std::string> &jsonHeader,
Positions pos = {}); Positions pos = {});
@ -1498,9 +1506,9 @@ class Detector {
Positions pos = {}) const; Positions pos = {}) const;
/** /**
* [Moench] * [Moench]
* Sets the value for additional json header parameters if found, * Sets the value for additional json header parameters. If not found,
* else appends the parameter key and value * the pair is appended. Empty value deletes parameter. Max 20 characters
* If empty, deletes parameter. Max 20 characters for each key/value * for each key/value.
*/ */
void setAdditionalJsonParameter(const std::string &key, void setAdditionalJsonParameter(const std::string &key,
const std::string &value, const std::string &value,
@ -1630,7 +1638,7 @@ class Detector {
/** lock detector to one client IP. default is unlocked */ /** lock detector to one client IP. default is unlocked */
void setDetectorLock(bool lock, Positions pos = {}); void setDetectorLock(bool lock, Positions pos = {});
/** Get last client IP saved on detector server */ /** Client IP Address that last communicated with the detector */
Result<sls::IpAddr> getLastClientIP(Positions pos = {}) const; Result<sls::IpAddr> getLastClientIP(Positions pos = {}) const;
/** Execute a command on the detector server console */ /** Execute a command on the detector server console */

View File

@ -1037,14 +1037,12 @@ std::string CmdProxy::Scan(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[dac_name|0|trimbit_scan] [start_val] [stop_val] " os << "[dac_name|0|trimbit_scan] [start_val] [stop_val] "
"[step_size] [dac settling time ns|us|ms|s]\n\tConfigures to " "[step_size] [dac settling time ns|us|ms|s]\n\tEnables/ disables "
"scan dac and sets number of frames to number of steps. Must " "scans for dac and trimbits \n\tEnabling scan sets number of "
"acquire after this. \n\tTo cancel the scan configuration " "frames to number of steps in receiver. \n\tTo cancel scan "
"set dac to '0' without further arguments, which also sets " "configuration, set dac to '0', which also sets number of frames "
"number " "to 1. \n\t[Eiger][Mythen3] Use trimbit_scan as dac name for a "
"of frames back to 1." "trimbit scan."
"\n\t[Eiger][Mythen3] Use trimbit_scan as dac name for a trimbit "
"scan."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (args.size() != 0) { if (args.size() != 0) {
@ -1990,7 +1988,7 @@ std::string CmdProxy::SlowAdc(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[n_channel (0-7 for channel]\n\t[Ctb] Slow " os << "[n_channel (0-7 for channel]\n\t[Ctb] Slow "
"ADC channel in mV" "ADC channel in uV"
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (args.size() != 1) { if (args.size() != 1) {
@ -2355,9 +2353,8 @@ std::string CmdProxy::AdditionalJsonHeader(int action) {
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[key1] [value1] [key2] [value2]...[keyn] [valuen]" os << "[key1] [value1] [key2] [value2]...[keyn] [valuen]"
"\n\tAdditional json header to be streamed out from receiver via " "\n\tAdditional json header to be streamed out from receiver via "
"zmq. " "zmq. Default is empty. Max 20 characters for each key/value. "
"Default is empty. Use only if to be processed by an " "Use only if to be processed by an intermediate user process "
"intermediate user process "
"listening to receiver zmq packets. Empty value deletes header. " "listening to receiver zmq packets. Empty value deletes header. "
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
@ -2391,8 +2388,8 @@ std::string CmdProxy::JsonParameter(int action) {
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[key1] [value1]\n\tAdditional json header parameter streamed " os << "[key1] [value1]\n\tAdditional json header parameter streamed "
"out from receiver. If not found in header, the pair is " "out from receiver. If not found in header, the pair is "
"appended. " "appended. An empty values deletes parameter. Max 20 characters "
"An empty values deletes parameter." "for each key/value."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (args.size() != 1) { if (args.size() != 1) {

View File

@ -1877,7 +1877,7 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
rx_lock, getRxLock, setRxLock, StringTo<int>, rx_lock, getRxLock, setRxLock, StringTo<int>,
"[0, 1]\n\tLock receiver to one client IP, 1 locks, 0 " "[0, 1]\n\tLock receiver to one client IP, 1 locks, 0 "
"unlocks. Default is unlocked. 1: locks"); "unlocks. Default is unlocked.");
GET_COMMAND( GET_COMMAND(
rx_lastclient, getRxLastClientIP, rx_lastclient, getRxLastClientIP,
@ -2282,8 +2282,8 @@ class CmdProxy {
EXECUTE_SET_COMMAND_NOID_1ARG( EXECUTE_SET_COMMAND_NOID_1ARG(
savepattern, savePattern, savepattern, savePattern,
"[fname]\n\t[Ctb][Moench][Mythen3] Saves pattern to file (ascii). Also " "[fname]\n\t[Ctb][Moench][Mythen3] Saves pattern to file (ascii). "
"executes pattern."); "\n\t[Ctb][Moench] Also executes pattern.");
INTEGER_COMMAND_HEX_WIDTH16(patioctrl, getPatternIOControl, INTEGER_COMMAND_HEX_WIDTH16(patioctrl, getPatternIOControl,
setPatternIOControl, StringTo<uint64_t>, setPatternIOControl, StringTo<uint64_t>,