From bd4299fd15bb0c6e0982400017948a4bb808a091 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 23 Sep 2020 12:32:51 +0200 Subject: [PATCH] Wip, doc --- python/slsdet/detector.py | 66 +++++++++++++++++++++++--- python/slsdet/proxy.py | 6 +-- slsDetectorSoftware/include/Detector.h | 34 ++++++++----- slsDetectorSoftware/src/CmdProxy.cpp | 25 +++++----- slsDetectorSoftware/src/CmdProxy.h | 6 +-- 5 files changed, 97 insertions(+), 40 deletions(-) diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index b8b53d1f3..4f5c6bff2 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -221,6 +221,13 @@ class Detector(CppDetectorApi): @property @element 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() @property @@ -1276,11 +1283,18 @@ class Detector(CppDetectorApi): @property @element def scanerrmsg(self): + """Gets Scan error message if scan ended in error for non blocking acquisitions.""" return self.getScanErrorMessage() @property @element 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() @rx_zmqstartfnum.setter @@ -1307,6 +1321,22 @@ class Detector(CppDetectorApi): @property 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) @property @@ -1340,6 +1370,7 @@ class Detector(CppDetectorApi): @property def settingslist(self): + """List of settings implemented for this detector.""" return self.getSettingsList() @property @@ -1489,18 +1520,20 @@ class Detector(CppDetectorApi): @property def rx_jsonpara(self): """ - Get the receiver additional json parameter. In case the parameter is different between - the modules a list of strings will be returned. On setting the value is automatically - converted to a string. - + Set the receiver additional json parameter. + Note + ---- + 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 ----------- - >>> d.rx_jsonpara['emin'] '4500' - >>> d.rx_jsonpara['emin'] = 5000 - + >>> d.rx_jsonpara + emax: 30 + emin: 5000 """ return JsonProxy(self) @@ -1508,6 +1541,21 @@ class Detector(CppDetectorApi): @property @element 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() @rx_jsonaddheader.setter @@ -2213,6 +2261,10 @@ class Detector(CppDetectorApi): @property @element def samples(self): + """ + [CTB] Number of samples (both analog and digitial) expected. \n + [Moench] Number of samples (analog only) + """ return self.getNumberOfAnalogSamples() @samples.setter diff --git a/python/slsdet/proxy.py b/python/slsdet/proxy.py index aa2383b3c..0cc498ba6 100644 --- a/python/slsdet/proxy.py +++ b/python/slsdet/proxy.py @@ -51,12 +51,12 @@ class SlowAdcProxy: def __repr__(self): rstr = '' - for i in range(7): + for i in range(8): r = element_if_equal(self.__getitem__(i)) if isinstance(r, list): - rstr += ' '.join(f'{item} mV' for item in r) + rstr += ' '.join(f'{item} uV' for item in r) else: - rstr += f'{i}: {r} mV\n' + rstr += f'{i}: {r} uV\n' return rstr.strip('\n') diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index b3737a8ed..ae55d3143 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -483,13 +483,15 @@ class Detector { Result getScan(Positions pos = {}) const; - /** enables/ disables scans for dac, trimbits [Eiger/ Mythen3] - * TRIMBIT_SCAN. Enabling scan sets number of frames to number of steps in - * receiver. Disabling scan sets number of frames to 1 */ + /** enables/ disables scans for dac and trimbits \n + * Enabling scan sets number of frames to number of steps in + * 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); - /** gets scan error message in case of error during scan in case of non - * blocking acquisition (startDetector, not acquire) */ + /** Gets Scan error message if scan ended in error for non blocking + * acquisitions.*/ Result getScanErrorMessage(Positions pos = {}) const; ///@{ @@ -517,7 +519,7 @@ class Detector { Result getSelectedUDPInterface(Positions pos = {}) const; /** - * [Jungfrau: + * [Jungfrau] * Effective only when number of interfaces is 1. * Options: 0 (outer, default), 1(inner)] //TODO: enum? */ @@ -728,6 +730,9 @@ class Detector { /** Client IP Address that last communicated with the receiver */ Result 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> getRxThreadIds(Positions pos = {}) const; ///@{ @@ -1408,7 +1413,8 @@ class Detector { * (instead of executing line by line)*/ 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); /** [CTB][Moench] */ @@ -1487,8 +1493,10 @@ class Detector { Result> getAdditionalJsonHeader(Positions pos = {}) const; - /** [Moench] If empty, reset additional json header. Max 20 characters for - * each key/value */ + /** [Moench] If empty, reset additional json header. Default is empty. Max + * 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( const std::map &jsonHeader, Positions pos = {}); @@ -1498,9 +1506,9 @@ class Detector { Positions pos = {}) const; /** * [Moench] - * Sets the value for additional json header parameters if found, - * else appends the parameter key and value - * If empty, deletes parameter. Max 20 characters for each key/value + * Sets the value for additional json header parameters. If not found, + * the pair is appended. Empty value deletes parameter. Max 20 characters + * for each key/value. */ void setAdditionalJsonParameter(const std::string &key, const std::string &value, @@ -1630,7 +1638,7 @@ class Detector { /** lock detector to one client IP. default is unlocked */ void setDetectorLock(bool lock, Positions pos = {}); - /** Get last client IP saved on detector server */ + /** Client IP Address that last communicated with the detector */ Result getLastClientIP(Positions pos = {}) const; /** Execute a command on the detector server console */ diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index b9dacf157..4361d120f 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1037,14 +1037,12 @@ std::string CmdProxy::Scan(int action) { os << cmd << ' '; if (action == defs::HELP_ACTION) { os << "[dac_name|0|trimbit_scan] [start_val] [stop_val] " - "[step_size] [dac settling time ns|us|ms|s]\n\tConfigures to " - "scan dac and sets number of frames to number of steps. Must " - "acquire after this. \n\tTo cancel the scan configuration " - "set dac to '0' without further arguments, which also sets " - "number " - "of frames back to 1." - "\n\t[Eiger][Mythen3] Use trimbit_scan as dac name for a trimbit " - "scan." + "[step_size] [dac settling time ns|us|ms|s]\n\tEnables/ disables " + "scans for dac and trimbits \n\tEnabling scan sets number of " + "frames to number of steps in receiver. \n\tTo cancel scan " + "configuration, set dac to '0', which also sets number of frames " + "to 1. \n\t[Eiger][Mythen3] Use trimbit_scan as dac name for a " + "trimbit scan." << '\n'; } else if (action == defs::GET_ACTION) { if (args.size() != 0) { @@ -1990,7 +1988,7 @@ std::string CmdProxy::SlowAdc(int action) { os << cmd << ' '; if (action == defs::HELP_ACTION) { os << "[n_channel (0-7 for channel]\n\t[Ctb] Slow " - "ADC channel in mV" + "ADC channel in uV" << '\n'; } else if (action == defs::GET_ACTION) { if (args.size() != 1) { @@ -2355,9 +2353,8 @@ std::string CmdProxy::AdditionalJsonHeader(int action) { if (action == defs::HELP_ACTION) { os << "[key1] [value1] [key2] [value2]...[keyn] [valuen]" "\n\tAdditional json header to be streamed out from receiver via " - "zmq. " - "Default is empty. Use only if to be processed by an " - "intermediate user process " + "zmq. Default is empty. Max 20 characters for each key/value. " + "Use only if to be processed by an intermediate user process " "listening to receiver zmq packets. Empty value deletes header. " << '\n'; } else if (action == defs::GET_ACTION) { @@ -2391,8 +2388,8 @@ std::string CmdProxy::JsonParameter(int action) { if (action == defs::HELP_ACTION) { os << "[key1] [value1]\n\tAdditional json header parameter streamed " "out from receiver. If not found in header, the pair is " - "appended. " - "An empty values deletes parameter." + "appended. An empty values deletes parameter. Max 20 characters " + "for each key/value." << '\n'; } else if (action == defs::GET_ACTION) { if (args.size() != 1) { diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index f7e809c68..6d45a6e77 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1877,7 +1877,7 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( rx_lock, getRxLock, setRxLock, StringTo, "[0, 1]\n\tLock receiver to one client IP, 1 locks, 0 " - "unlocks. Default is unlocked. 1: locks"); + "unlocks. Default is unlocked."); GET_COMMAND( rx_lastclient, getRxLastClientIP, @@ -2282,8 +2282,8 @@ class CmdProxy { EXECUTE_SET_COMMAND_NOID_1ARG( savepattern, savePattern, - "[fname]\n\t[Ctb][Moench][Mythen3] Saves pattern to file (ascii). Also " - "executes pattern."); + "[fname]\n\t[Ctb][Moench][Mythen3] Saves pattern to file (ascii). " + "\n\t[Ctb][Moench] Also executes pattern."); INTEGER_COMMAND_HEX_WIDTH16(patioctrl, getPatternIOControl, setPatternIOControl, StringTo,