From 8ae0659478dc8eec3b4e727182141167b314106e Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Fri, 11 Sep 2020 15:09:44 +0200 Subject: [PATCH 1/5] docs --- docs/CMakeLists.txt | 9 ++++ docs/gen_server_doc.py.in | 43 +++++++++++++++ docs/src/index.rst | 5 ++ docs/src/servers.rst | 52 +++++++++++++++++++ .../slsDetectorServer_defs.h | 2 +- .../slsDetectorServer_defs.h | 2 +- .../slsDetectorServer_defs.h | 4 +- 7 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 docs/gen_server_doc.py.in create mode 100644 docs/src/servers.rst diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 10b2d4ee1..eba7e0e21 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -38,6 +38,7 @@ set(SPHINX_SOURCE_FILES src/pydetector.rst src/pyenums.rst src/pyexamples.rst + src/servers.rst src/receiver.rst src/result.rst src/type_traits.rst @@ -57,6 +58,11 @@ configure_file( "${SPHINX_BUILD}/conf.py" @ONLY) +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/gen_server_doc.py.in" + "${SPHINX_BUILD}/gen_server_doc.py" + @ONLY) + add_custom_target(docs gendoc COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} @@ -74,3 +80,6 @@ add_custom_target(rst ${SPHINX_BUILD}/src ${SPHINX_BUILD}/html COMMENT "Generating documentation with Sphinx") + +add_custom_target(hej + python gen_server_doc.py) \ No newline at end of file diff --git a/docs/gen_server_doc.py.in b/docs/gen_server_doc.py.in new file mode 100644 index 000000000..f4d99f05a --- /dev/null +++ b/docs/gen_server_doc.py.in @@ -0,0 +1,43 @@ +import os +import re +from pathlib import Path + +# @CMAKE_CURRENT_BINARY_DIR@ + +src = Path('@CMAKE_SOURCE_DIR@')/'slsDetectorServers/' + +detectors = ['Mythen3', 'Gotthard2', 'Eiger', 'Jungfrau', 'Moench', 'Gotthard'] + + +for det in detectors: + with open(src/f'{det.lower()}DetectorServer/slsDetectorServer_defs.h') as f: + lines = f.read().replace('\\\n', '') + lines = lines.splitlines(keepends = True) + + lines = [l.strip('#define').strip(' ') for l in lines if l.startswith('#define')] + output = [] + signals = [] + fields = ['Name,', 'Value', 'Comment'] + excluded = ['DAC_NAMES', 'DEFAULT_DAC_VALS', 'CLK_NAMES', 'ONCHIP_DAC_NAMES'] + header = f'{fields[0]:35}{fields[1]:35}\n' + output.append(header) + signals.append(header) + for line in lines: + name, *parts = line.split() + arg = ' '.join(parts) + value, *comments = arg.split('//') + value = value.strip('() ') + # value = value.replace(', ', ' ') + value = value.replace('\"', '') + if name not in excluded: + name += ',' + if name.startswith('SIGNAL_'): + signals.append(f'{name:35}{value}\n') + else: + output.append(f'{name:35}\"{value}\"\n') + + + rstpath = Path('@CMAKE_SOURCE_DIR@')/'docs/src/' + with open(f'src/{det.lower()}.csv', 'w') as f: + f.writelines(output) + diff --git a/docs/src/index.rst b/docs/src/index.rst index 369281f42..5ece80817 100644 --- a/docs/src/index.rst +++ b/docs/src/index.rst @@ -50,6 +50,11 @@ Welcome to slsDetectorPackage's documentation! type_traits ToString +.. toctree:: + :caption: Servers + + servers + .. Indices and tables .. ================== diff --git a/docs/src/servers.rst b/docs/src/servers.rst new file mode 100644 index 000000000..91f6a024e --- /dev/null +++ b/docs/src/servers.rst @@ -0,0 +1,52 @@ +Detector Servers +============================================== + +Some general intro + +Mythen3 +------------- + +.. csv-table:: Default values + :file: mythen3.csv + :widths: 35, 35 + :header-rows: 1 + +Gotthard2 +------------- + +.. csv-table:: Default values + :file: gotthard2.csv + :widths: 35, 35 + :header-rows: 1 + +Moench +------------- + +.. csv-table:: Default values + :file: moech.csv + :widths: 35, 35 + :header-rows: 1 + +Eiger +------------- + +.. csv-table:: Default values + :file: eiger.csv + :widths: 35, 35 + :header-rows: 1 + +Jungfrau +------------- + +.. csv-table:: Default values + :file: jungfrau.csv + :widths: 35, 35 + :header-rows: 1 + +Gotthard +------------- + +.. csv-table:: Default values + :file: gotthard.csv + :widths: 35, 35 + :header-rows: 1 \ No newline at end of file diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h index 9fdaf0506..213475dbd 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h @@ -130,7 +130,7 @@ enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE }; #define DAC_MAX_STEPS (4096) #define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS \ - (0x1FFFFFFF) /** 29 bit register for max subframe exposure value */ +(0x1FFFFFFF) // 29 bit register for max subframe exposure value #define SLAVE_HIGH_VOLTAGE_READ_VAL (-999) #define HIGH_VOLTAGE_TOLERANCE (5) diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthardDetectorServer/slsDetectorServer_defs.h index bc01d327d..399194b48 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorServer_defs.h @@ -41,7 +41,7 @@ enum CLKINDEX { ADC_CLK, NUM_CLOCKS }; #define DYNAMIC_RANGE (16) #define NUM_BITS_PER_PIXEL (DYNAMIC_RANGE / 8) #define DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL) -#define CLK_FREQ (32007729) /* Hz */ +#define CLK_FREQ (32007729) // Hz #define MAX_EXT_SIGNALS (1) /** Firmware Definitions */ diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h index f286c05b9..6763f8867 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h @@ -69,8 +69,8 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS }; #define DYNAMIC_RANGE (16) #define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8) #define DATA_BYTES (NCHIP * NCHAN * NUM_BYTES_PER_PIXEL) -#define CLK_RUN (40) /* MHz */ -#define CLK_SYNC (20) /* MHz */ +#define CLK_RUN (40) // MHz +#define CLK_SYNC (20) // MHz #define ADC_CLK_INDEX (1) #define DBIT_CLK_INDEX (0) From 884da7197e5021c9bffe82346092156d206a2db2 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Fri, 11 Sep 2020 15:13:26 +0200 Subject: [PATCH 2/5] fixed command --- docs/CMakeLists.txt | 4 +--- docs/src/servers.rst | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index eba7e0e21..6d885f4ca 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -65,6 +65,7 @@ configure_file( add_custom_target(docs gendoc + python gen_server_doc.py COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} COMMAND ${SPHINX_EXECUTABLE} -a -b html -Dbreathe_projects.slsDetectorPackage=${CMAKE_CURRENT_BINARY_DIR}/xml @@ -80,6 +81,3 @@ add_custom_target(rst ${SPHINX_BUILD}/src ${SPHINX_BUILD}/html COMMENT "Generating documentation with Sphinx") - -add_custom_target(hej - python gen_server_doc.py) \ No newline at end of file diff --git a/docs/src/servers.rst b/docs/src/servers.rst index 91f6a024e..aeae6ce2b 100644 --- a/docs/src/servers.rst +++ b/docs/src/servers.rst @@ -1,4 +1,4 @@ -Detector Servers +Default values ============================================== Some general intro From aa10c4665f3dbcd5d659205ad2ff16ccb7b9661e Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Fri, 11 Sep 2020 15:25:23 +0200 Subject: [PATCH 3/5] added ctb --- docs/CMakeLists.txt | 2 ++ docs/gen_server_doc.py.in | 2 +- docs/src/servers.rst | 8 ++++++++ .../ctbDetectorServer/slsDetectorServer_defs.h | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 6d885f4ca..d8e63a448 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -81,3 +81,5 @@ add_custom_target(rst ${SPHINX_BUILD}/src ${SPHINX_BUILD}/html COMMENT "Generating documentation with Sphinx") + +add_custom_target(server_rst python gen_server_doc.py) \ No newline at end of file diff --git a/docs/gen_server_doc.py.in b/docs/gen_server_doc.py.in index f4d99f05a..b99c3e0ad 100644 --- a/docs/gen_server_doc.py.in +++ b/docs/gen_server_doc.py.in @@ -6,7 +6,7 @@ from pathlib import Path src = Path('@CMAKE_SOURCE_DIR@')/'slsDetectorServers/' -detectors = ['Mythen3', 'Gotthard2', 'Eiger', 'Jungfrau', 'Moench', 'Gotthard'] +detectors = ['Mythen3', 'Gotthard2', 'Eiger', 'Jungfrau', 'Moench', 'Gotthard', 'Ctb'] for det in detectors: diff --git a/docs/src/servers.rst b/docs/src/servers.rst index aeae6ce2b..34edc8de0 100644 --- a/docs/src/servers.rst +++ b/docs/src/servers.rst @@ -27,6 +27,14 @@ Moench :widths: 35, 35 :header-rows: 1 +Ctb +------------- + +.. csv-table:: Default values + :file: ctb.csv + :widths: 35, 35 + :header-rows: 1 + Eiger ------------- diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h index a6f39cd5c..f5b681efc 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h @@ -95,7 +95,7 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS }; #define NDAC_ONLY (NDAC - NPWR) #define DYNAMIC_RANGE (16) #define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8) -#define CLK_FREQ (156.25) /* MHz */ +#define CLK_FREQ (156.25) // MHz #define I2C_POWER_VIO_DEVICE_ID (0x40) #define I2C_POWER_VA_DEVICE_ID (0x41) #define I2C_POWER_VB_DEVICE_ID (0x42) From e10ebe33d7bbf8537583940174c661904f1b461b Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Fri, 11 Sep 2020 17:25:27 +0200 Subject: [PATCH 4/5] fixed cmake command --- docs/CMakeLists.txt | 6 ++++-- docs/gen_server_doc.py.in | 18 ++++++++++++++---- docs/src/servers.rst | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index d8e63a448..8209215ef 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -63,9 +63,12 @@ configure_file( "${SPHINX_BUILD}/gen_server_doc.py" @ONLY) + +add_custom_target(server_rst python gen_server_doc.py) + add_custom_target(docs gendoc - python gen_server_doc.py + COMMAND python gen_server_doc.py COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} COMMAND ${SPHINX_EXECUTABLE} -a -b html -Dbreathe_projects.slsDetectorPackage=${CMAKE_CURRENT_BINARY_DIR}/xml @@ -82,4 +85,3 @@ add_custom_target(rst ${SPHINX_BUILD}/html COMMENT "Generating documentation with Sphinx") -add_custom_target(server_rst python gen_server_doc.py) \ No newline at end of file diff --git a/docs/gen_server_doc.py.in b/docs/gen_server_doc.py.in index b99c3e0ad..2a4d154fa 100644 --- a/docs/gen_server_doc.py.in +++ b/docs/gen_server_doc.py.in @@ -2,15 +2,21 @@ import os import re from pathlib import Path + + # @CMAKE_CURRENT_BINARY_DIR@ -src = Path('@CMAKE_SOURCE_DIR@')/'slsDetectorServers/' +print('\n\n\n\n SERVER CSV') -detectors = ['Mythen3', 'Gotthard2', 'Eiger', 'Jungfrau', 'Moench', 'Gotthard', 'Ctb'] +src = Path('@CMAKE_SOURCE_DIR@')/'slsDetectorServers/' +detectors = ['Mythen3', 'Gotthard2', 'Eiger', + 'Jungfrau', 'Moench', 'Gotthard', 'Ctb'] for det in detectors: - with open(src/f'{det.lower()}DetectorServer/slsDetectorServer_defs.h') as f: + in_fname = src/f'{det.lower()}DetectorServer/slsDetectorServer_defs.h' + print(f'Reading: {in_fname}') + with open(in_fname) as f: lines = f.read().replace('\\\n', '') lines = lines.splitlines(keepends = True) @@ -38,6 +44,10 @@ for det in detectors: rstpath = Path('@CMAKE_SOURCE_DIR@')/'docs/src/' - with open(f'src/{det.lower()}.csv', 'w') as f: + + out_fname = Path.cwd()/f'src/{det.lower()}.csv' + print(f'Writing: {out_fname}') + with open(out_fname, 'w') as f: f.writelines(output) +print('END\n\n\n\n') \ No newline at end of file diff --git a/docs/src/servers.rst b/docs/src/servers.rst index 34edc8de0..67a1649c8 100644 --- a/docs/src/servers.rst +++ b/docs/src/servers.rst @@ -23,7 +23,7 @@ Moench ------------- .. csv-table:: Default values - :file: moech.csv + :file: moench.csv :widths: 35, 35 :header-rows: 1 From 2285061623423d2c4173bb5335393fefaf0359f2 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Fri, 11 Sep 2020 17:47:28 +0200 Subject: [PATCH 5/5] column wrap for long attributes --- docs/CMakeLists.txt | 4 ++++ docs/conf.py.in | 6 +++++- docs/static/extra.css | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 docs/static/extra.css diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 8209215ef..b39097084 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -63,6 +63,10 @@ configure_file( "${SPHINX_BUILD}/gen_server_doc.py" @ONLY) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/static/extra.css" + "${SPHINX_BUILD}/static/css/extra.css" + @ONLY) add_custom_target(server_rst python gen_server_doc.py) diff --git a/docs/conf.py.in b/docs/conf.py.in index 3f4289e0c..c5db6e684 100644 --- a/docs/conf.py.in +++ b/docs/conf.py.in @@ -59,4 +59,8 @@ html_theme = "sphinx_rtd_theme" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -#html_static_path = ['_static'] +html_static_path = ['static'] + + +def setup(app): + app.add_stylesheet('css/extra.css') # may also be an URL \ No newline at end of file diff --git a/docs/static/extra.css b/docs/static/extra.css new file mode 100644 index 000000000..62e8dbd68 --- /dev/null +++ b/docs/static/extra.css @@ -0,0 +1,4 @@ +/* override table no-wrap */ +.wy-table-responsive table td, .wy-table-responsive table th { + white-space: normal; +} \ No newline at end of file