mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 13:27:14 +02:00
Compare commits
290 Commits
Author | SHA1 | Date | |
---|---|---|---|
1b41e39ad1 | |||
64fea22c2b | |||
9beaed7813 | |||
0aeb7e4417 | |||
4880f87791 | |||
97f0c1fe46 | |||
a86fd00e59 | |||
24894667b7 | |||
4b414bfddb | |||
15d357d9ab | |||
f95de054f9 | |||
0aef8113dd | |||
9785a41048 | |||
417e1a88a5 | |||
9c0dd0385d | |||
5ab64efe3e | |||
8f77e4d4fe | |||
41c5b75b10 | |||
bfe53c6693 | |||
f7997dd09a | |||
c64e87a2b6 | |||
5eeb8e29c1 | |||
09697fa325 | |||
90b4daef39 | |||
2082f1eee7 | |||
d3a636b563 | |||
50b9b6ca39 | |||
e86b57cdfc | |||
14e11e8b5b | |||
beafe86554 | |||
af3dc1e7f4 | |||
573177203b | |||
a3ca9ebce5 | |||
8174fc9691 | |||
d6eac6da71 | |||
56c7ae4852 | |||
9b9b09ceaf | |||
cfebaee2a5 | |||
4613c54f57 | |||
51f9d6f011 | |||
58ac7ac280 | |||
82edfa75d3 | |||
35ed926047 | |||
4023ed0775 | |||
b6ef3bc39e | |||
2035666792 | |||
1ff4d806e7 | |||
3861379653 | |||
91140bbb71 | |||
a5632fcbea | |||
d44329117d | |||
4a454aa698 | |||
0e43072db8 | |||
6c67025ea8 | |||
e5ee27dbfa | |||
601249cc71 | |||
ff60b8c379 | |||
37ce3d6f59 | |||
bf26533fd8 | |||
7106273521 | |||
1484d038de | |||
dad3dc3e46 | |||
d003a6d8e0 | |||
72bec5d62e | |||
88c39ba702 | |||
fb0090c79e | |||
adc68cd519 | |||
1566eef247 | |||
9834b07b47 | |||
e7cd90db78 | |||
45414149fe | |||
48759f440e | |||
77d13f0794 | |||
b367b7e431 | |||
f0b2a6f6f9 | |||
dd1690d7a1 | |||
1873cc9310 | |||
565858b6c6 | |||
7383b13f16 | |||
d5ce03918c | |||
c9dfa408db | |||
36a9bafbde | |||
15643c2320 | |||
71489b7106 | |||
7394833710 | |||
9c50a3ee1e | |||
fd79d59f4e | |||
c628ae2192 | |||
a56be25500 | |||
f761046bfc | |||
1a859b83db | |||
70bfc875a6 | |||
c0755308a4 | |||
ab5509e10c | |||
d74661a375 | |||
054e733cd5 | |||
fe4db54eb6 | |||
5be503c1bd | |||
004cb26646 | |||
58cdb5bd20 | |||
e18c191247 | |||
1a338346d5 | |||
d3d98db7e9 | |||
3f9ec695db | |||
6f50707cfb | |||
a5f26252b8 | |||
d032f43f11 | |||
0d53f83a2f | |||
a7dcfe4b31 | |||
b9a346a396 | |||
225e5490d2 | |||
95d89522d8 | |||
6fcb880538 | |||
a4f47a5945 | |||
65b8c9c5c1 | |||
0a7fd0a51a | |||
6834294437 | |||
afee45790f | |||
f0c789dc91 | |||
a0f250a487 | |||
fb25a01db5 | |||
312f3f473d | |||
da4dd0df7e | |||
5871086cd6 | |||
4c6be26846 | |||
74acbb15f5 | |||
d65825e9ef | |||
e757e25fa1 | |||
6a0fe823b3 | |||
5912aae53e | |||
8833ccf5cc | |||
14ec4cf1da | |||
ea4aaf743f | |||
61f290441e | |||
80fc7eb220 | |||
73a9c42f62 | |||
72c992bc74 | |||
f4e05f7a01 | |||
cb4f733350 | |||
a5022ff0ee | |||
cab2b335dc | |||
b442b17415 | |||
37e7471dc4 | |||
3b8c612103 | |||
08c0c59a28 | |||
7e01095684 | |||
77c558a7be | |||
378fc301b8 | |||
87d6e16090 | |||
2ef021041c | |||
574127b5ac | |||
500442fd6b | |||
b67c6dea08 | |||
c9215a6d9b | |||
1bdf83e101 | |||
1bd813d620 | |||
943a85cbd5 | |||
fc24558314 | |||
d23722a4b7 | |||
bc46d0f6ab | |||
532f76ed4f | |||
21db57dd89 | |||
dc5db905d4 | |||
48a684b95f | |||
276dc52196 | |||
e942678139 | |||
72a028eaf3 | |||
907257891d | |||
0a79ae523b | |||
90496bcee8 | |||
ed2894dafd | |||
a74c9498e2 | |||
403989e2f8 | |||
7e8d11098a | |||
f9c9a53c8c | |||
90b1b97ffa | |||
50003cbc08 | |||
a799c4d2e2 | |||
700f532b5a | |||
a098bc4674 | |||
13bbd54a21 | |||
d84e9652d3 | |||
1ce39c48c7 | |||
9ddff523cd | |||
f7618fbb93 | |||
8501e1fb1f | |||
6faa4c821f | |||
da291d535e | |||
adcde9fd49 | |||
dde99a16b3 | |||
b200a2efc1 | |||
fe281bd1b1 | |||
878eab9fc3 | |||
4259d49b63 | |||
4dac9f2193 | |||
cb8e4365e3 | |||
0251aa9e63 | |||
7c047cab4a | |||
572332f870 | |||
d90bf6c7df | |||
5c8c3ae3f3 | |||
18136fed9d | |||
fc42720208 | |||
e6505650cb | |||
ba6fdb9695 | |||
8361f2bb96 | |||
4ee4d66977 | |||
e14f6981a0 | |||
8158ef876c | |||
ebb6f53b21 | |||
e172df79f3 | |||
55bf73f3b7 | |||
c62ce0ce6b | |||
3a3628c475 | |||
9ba907f9f7 | |||
3f7c9529dd | |||
c7af9c9f3e | |||
0b17318f10 | |||
1f907b911e | |||
c5b621b684 | |||
946e6aa817 | |||
3682644e15 | |||
a6aaa2c3c6 | |||
ac64afe747 | |||
d19f6a3d0d | |||
eb025b54ef | |||
d77b353481 | |||
3bf6be41b4 | |||
7466c0bc8f | |||
713639d001 | |||
3cc4d25eb9 | |||
0d905923dd | |||
e747a5811f | |||
22b3229d94 | |||
7729e47685 | |||
f31fa92516 | |||
d106109f6c | |||
39b1f5bbf2 | |||
7ab3b25f87 | |||
0f6f20a720 | |||
1340408c2d | |||
7b7c4a2b86 | |||
8fc45676b9 | |||
53fe5f5116 | |||
50f2165c55 | |||
056f650b92 | |||
3d54a4aa26 | |||
3a89c2a61e | |||
570a567a8c | |||
9874f596f6 | |||
984a59a9d7 | |||
e02b11fd1e | |||
68beba732e | |||
104bc6f619 | |||
66cf1825ea | |||
d8e497dbb3 | |||
60502cfa8f | |||
b089dc90cd | |||
4caf10c12b | |||
32cbb11bb6 | |||
339cb925c7 | |||
f8a29c3000 | |||
d431443dda | |||
ae0a54a774 | |||
ae33622da2 | |||
c4a453fdbd | |||
672c0f4a07 | |||
05af370883 | |||
a6022b7cec | |||
72316fa2ce | |||
65523dcc94 | |||
df40665c5e | |||
8472cca81f | |||
110e57ff6c | |||
fdd6031add | |||
e7c65f44cb | |||
0063cc8eb2 | |||
27e6fc3c73 | |||
83e0eb8b01 | |||
7f8b5ac6c0 | |||
340abec016 | |||
a8b37e3932 | |||
0883c73e88 | |||
ef7e9d73a5 | |||
a8bdc1495c | |||
1c54dea9c7 | |||
cee286b6ad | |||
da8e0060d3 | |||
85da65ca15 | |||
4fe067363a |
10
.clang-tidy
10
.clang-tidy
@ -1,16 +1,24 @@
|
||||
---
|
||||
Checks: '*,
|
||||
-altera-*,
|
||||
-android-cloexec-fopen,
|
||||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||
-fuchsia*,
|
||||
-readability-else-after-return,
|
||||
-readability-avoid-const-params-in-decls,
|
||||
-readability-identifier-length,
|
||||
-cppcoreguidelines-pro-bounds-constant-array-index,
|
||||
-cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
-llvm-header-guard,
|
||||
-modernize-use-nodiscard,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
-readability-static-accessed-through-instance,
|
||||
-readability-braces-around-statements,
|
||||
-readability-isolate-declaration,
|
||||
-readability-implicit-bool-conversion,
|
||||
-readability-identifier-length,
|
||||
-readability-identifier-naming,
|
||||
-hicpp-signed-bitwise,
|
||||
-hicpp-no-array-decay,
|
||||
-hicpp-braces-around-statements,
|
||||
@ -18,8 +26,6 @@ Checks: '*,
|
||||
-google-readability-todo,
|
||||
-google-readability-braces-around-statements,
|
||||
-modernize-use-trailing-return-type,
|
||||
-readability-isolate-declaration,
|
||||
-readability-implicit-bool-conversion,
|
||||
-llvmlibc-*'
|
||||
|
||||
HeaderFilterRegex: \.h
|
||||
|
38
.github/workflows/cmake.yml
vendored
Normal file
38
.github/workflows/cmake.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
name: CMake
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Debug
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
|
||||
# You can convert this to a matrix build if you need cross-platform coverage.
|
||||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
||||
runs-on: ubuntu-latest
|
||||
name: Configure and build using cmake
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev
|
||||
version: 1.0
|
||||
|
||||
- name: Configure CMake
|
||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSLS_USE_TESTS=ON -DSLS_USE_HDF5=ON -DSLS_USE_GUI=ON -DSLS_USE_MOENCH=ON -DSLS_USE_PYTHON=ON
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
run: cmake --build ${{github.workspace}}/build -j2 --config ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{github.workspace}}/build
|
||||
# Execute tests defined by the CMake configuration.
|
||||
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
||||
run: ctest -C ${{env.BUILD_TYPE}} -j1
|
||||
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,7 +9,7 @@ bin/
|
||||
*.o
|
||||
*.so
|
||||
.*
|
||||
build
|
||||
build/
|
||||
RELEASE.txt
|
||||
Testing/
|
||||
|
||||
|
1
CMakeFiles/cmake.check_cache
Normal file
1
CMakeFiles/cmake.check_cache
Normal file
@ -0,0 +1 @@
|
||||
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
|
111
CMakeLists.txt
111
CMakeLists.txt
@ -1,15 +1,70 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(slsDetectorPackage)
|
||||
set(PROJECT_VERSION 7.0.0)
|
||||
|
||||
# Read VERSION file into project version
|
||||
set(VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/VERSION")
|
||||
file(READ "${VERSION_FILE}" VERSION_CONTENT)
|
||||
string(STRIP "${VERSION_CONTENT}" PROJECT_VERSION_STRING)
|
||||
set(PROJECT_VERSION ${PROJECT_VERSION_STRING})
|
||||
|
||||
# Pass it to the compiler
|
||||
add_compile_definitions(SLS_DET_VERSION="${PROJECT_VERSION}")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
|
||||
if (${CMAKE_VERSION} VERSION_GREATER "3.24")
|
||||
cmake_policy(SET CMP0135 NEW) #Fetch content download timestamp
|
||||
endif()
|
||||
include(cmake/project_version.cmake)
|
||||
include(cmake/SlsAddFlag.cmake)
|
||||
include(cmake/SlsFindZeroMQ.cmake)
|
||||
|
||||
|
||||
|
||||
# Using FetchContent to get libzmq
|
||||
include(FetchContent)
|
||||
option(SLS_FETCH_ZMQ_FROM_GITHUB "Fetch zmq from github" OFF)
|
||||
option(SLS_FETCH_PYBIND11_FROM_GITHUB "Fetch pybind11 from github" OFF)
|
||||
|
||||
if(SLS_FETCH_ZMQ_FROM_GITHUB)
|
||||
# Opt in to pull down a zmq version from github instead of
|
||||
# using the bundled verison
|
||||
FetchContent_Declare(
|
||||
libzmq
|
||||
GIT_REPOSITORY https://github.com/zeromq/libzmq.git
|
||||
GIT_TAG v4.3.4
|
||||
)
|
||||
else()
|
||||
# Standard behaviour use libzmq included in this repo (libs/libzmq)
|
||||
FetchContent_Declare(
|
||||
libzmq
|
||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq-4.3.4.tar.gz
|
||||
URL_HASH MD5=cc20b769ac10afa352e5ed2769bb23b3
|
||||
)
|
||||
endif()
|
||||
|
||||
# Disable unwanted options from libzmq
|
||||
set(BUILD_TESTS OFF CACHE BOOL "Switch off libzmq test build")
|
||||
set(BUILD_SHARED OFF CACHE BOOL "Switch off libzmq shared libs")
|
||||
set(WITH_PERF_TOOL OFF CACHE BOOL "")
|
||||
set(ENABLE_CPACK OFF CACHE BOOL "")
|
||||
set(ENABLE_CLANG OFF CACHE BOOL "")
|
||||
set(ENABLE_CURVE OFF CACHE BOOL "")
|
||||
set(ENABLE_DRAFTS OFF CACHE BOOL "")
|
||||
|
||||
# Using GetProperties and Populate to be able to exclude zmq
|
||||
# from install (not possible with FetchContent_MakeAvailable(libzmq))
|
||||
FetchContent_GetProperties(libzmq)
|
||||
if(NOT libzmq_POPULATED)
|
||||
FetchContent_Populate(libzmq)
|
||||
add_subdirectory(${libzmq_SOURCE_DIR} ${libzmq_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# If conda build, always set lib dir to 'lib'
|
||||
@ -55,6 +110,7 @@ option(SLS_BUILD_EXAMPLES "examples" OFF)
|
||||
option(SLS_TUNE_LOCAL "tune to local machine" OFF)
|
||||
option(SLS_DEVEL_HEADERS "install headers for devel" OFF)
|
||||
option(SLS_USE_MOENCH "compile zmq and post processing for Moench" OFF)
|
||||
option(SLS_USE_JUNGFRAU "compile post processing for Jungfrau" OFF)
|
||||
|
||||
#Convenience option to switch off defaults when building Moench binaries only
|
||||
option(SLS_BUILD_ONLY_MOENCH "compile only Moench" OFF)
|
||||
@ -68,6 +124,18 @@ if(SLS_BUILD_ONLY_MOENCH)
|
||||
set(SLS_USE_MOENCH ON CACHE BOOL "Enable" FORCE)
|
||||
endif()
|
||||
|
||||
#Convenience option to switch off defaults when building Jungfrau binaries only
|
||||
option(SLS_BUILD_ONLY_JUNGFRAU "compile only Jungfrau" OFF)
|
||||
if(SLS_BUILD_ONLY_JUNGFRAU)
|
||||
message(STATUS "Build JUNGFRAU binaries only!")
|
||||
set(SLS_BUILD_SHARED_LIBRARIES OFF CACHE BOOL "Disabled for JUNGFRAU_ONLY" FORCE)
|
||||
set(SLS_USE_TEXTCLIENT OFF CACHE BOOL "Disabled for JUNGFRAU_ONLY" FORCE)
|
||||
set(SLS_USE_DETECTOR OFF CACHE BOOL "Disabled for JUNGFRAU_ONLY" FORCE)
|
||||
set(SLS_USE_RECEIVER OFF CACHE BOOL "Disabled for JUNGFRAU_ONLY" FORCE)
|
||||
set(SLS_USE_RECEIVER_BINARIES OFF CACHE BOOL "Disabled for JUNGFRAU_ONLY" FORCE)
|
||||
set(SLS_USE_JUNGFRAU ON CACHE BOOL "Enable" FORCE)
|
||||
endif()
|
||||
|
||||
|
||||
option(SLS_EXT_BUILD "external build of part of the project" OFF)
|
||||
if(SLS_EXT_BUILD)
|
||||
@ -88,7 +156,6 @@ set(SLS_INTERNAL_QWT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/qwt-6.1.5)
|
||||
set(ClangFormat_EXCLUDE_PATTERNS "build/"
|
||||
"libs/"
|
||||
"slsDetectorCalibration/"
|
||||
"ctbGui/"
|
||||
"manual/"
|
||||
"python/"
|
||||
"sample/"
|
||||
@ -172,6 +239,8 @@ if (NOT TARGET slsProjectCSettings)
|
||||
-Wredundant-decls
|
||||
-Wdouble-promotion
|
||||
-Werror=return-type
|
||||
-Wno-format-overflow
|
||||
-Wno-format-truncation
|
||||
)
|
||||
sls_disable_c_warning("-Wstringop-truncation")
|
||||
endif()
|
||||
@ -184,6 +253,7 @@ if(SLS_USE_SANITIZER)
|
||||
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
|
||||
endif()
|
||||
|
||||
|
||||
if(SLS_TUNE_LOCAL)
|
||||
target_compile_options(slsProjectOptions INTERFACE -mtune=native -march=native)
|
||||
endif()
|
||||
@ -202,10 +272,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_INSTALL_RPATH $ORIGIN)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
|
||||
|
||||
custom_find_zmq()
|
||||
|
||||
|
||||
if (SLS_USE_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
@ -238,13 +304,29 @@ if (SLS_USE_INTEGRATION_TESTS)
|
||||
endif (SLS_USE_INTEGRATION_TESTS)
|
||||
|
||||
if (SLS_USE_PYTHON)
|
||||
find_package (Python 3.6 COMPONENTS Interpreter Development)
|
||||
add_subdirectory(libs/pybind ${CMAKE_BINARY_DIR}/bin/)
|
||||
find_package (Python 3.8 COMPONENTS Interpreter Development)
|
||||
if(SLS_FETCH_PYBIND11_FROM_GITHUB)
|
||||
FetchContent_Declare(
|
||||
pybind11
|
||||
GIT_REPOSITORY https://github.com/pybind/pybind11
|
||||
GIT_TAG v2.13.6
|
||||
)
|
||||
|
||||
else()
|
||||
# https://github.com/pybind/pybind11/releases
|
||||
FetchContent_Declare(
|
||||
pybind11
|
||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/libs/pybind11/v2.13.6.tar.gz
|
||||
URL_HASH MD5=a04dead9c83edae6d84e2e343da7feeb
|
||||
)
|
||||
endif()
|
||||
FetchContent_MakeAvailable(pybind11)
|
||||
|
||||
add_subdirectory(python)
|
||||
endif(SLS_USE_PYTHON)
|
||||
|
||||
if (SLS_USE_CTBGUI)
|
||||
add_subdirectory(ctbGui)
|
||||
add_subdirectory(pyctbgui)
|
||||
endif(SLS_USE_CTBGUI)
|
||||
|
||||
configure_file( .clang-tidy
|
||||
@ -264,8 +346,13 @@ if(SLS_USE_MOENCH)
|
||||
add_subdirectory(slsDetectorCalibration/moenchExecutables)
|
||||
endif(SLS_USE_MOENCH)
|
||||
|
||||
if(SLS_USE_JUNGFRAU)
|
||||
add_subdirectory(slsDetectorCalibration/tiffio)
|
||||
add_subdirectory(slsDetectorCalibration/jungfrauExecutables)
|
||||
endif(SLS_USE_JUNGFRAU)
|
||||
|
||||
if(SLS_MASTER_PROJECT)
|
||||
set(CMAKE_INSTALL_DIR "share/cmake/${PROJECT_NAME}")
|
||||
set(PROJECT_LIBRARIES slsSupportShared slsDetectorShared slsReceiverShared)
|
||||
include(cmake/package_config.cmake)
|
||||
endif()
|
||||
endif()
|
319
README.md
319
README.md
@ -1,102 +1,281 @@
|
||||
### Note
|
||||
## Dependencies
|
||||
Before building from source make sure that you have the [software wiki](https://slsdetectorgroup.github.io/devdoc/dependencies.html) installed. If installing using conda, conda will manage the dependencies. Avoid also installing packages with pip.
|
||||
|
||||
Please do not update to any xxxx.xx.xx.dev0 tags. They are not releases, but tags for internal usage.
|
||||
Use only releases with tags such as x.x.x or x.x.x-rcx.
|
||||
## Documentaion
|
||||
Detailed documentation including installation can be found in the [software wiki](https://slsdetectorgroup.github.io/devdoc/index.html).
|
||||
|
||||
### Documentation
|
||||
##### 5.0.0 - Latest Release
|
||||
Detailed documentation on the latest release can be found in the [software wiki](https://slsdetectorgroup.github.io/devdoc/index.html) and on the [official site](https://www.psi.ch/en/detectors/software).
|
||||
Different releases can be found on the [official site](https://www.psi.ch/en/lxn/software-releases).
|
||||
|
||||
##### Older Releases
|
||||
Documentation is found in the package.
|
||||
Firmware compatiblity can be found in [firmware page](https://github.com/slsdetectorgroup/slsDetectorFirmware)
|
||||
|
||||
## Installation
|
||||
|
||||
### 1. Install binaries using conda
|
||||
Conda is not only useful to manage python environments but can also
|
||||
be used as a user space package manager. Dates in the tag (for eg. 2020.07.23.dev0)
|
||||
are from the developer branch. Please use released tags for stability.
|
||||
|
||||
We have three different packages available:
|
||||
* **slsdetlib** shared libraries and command line utilities
|
||||
* **slsdetgui** GUI
|
||||
* **slsdet** Python bindings
|
||||
|
||||
### Binaries
|
||||
Binaries for the slsDetectorPackage are available through conda.
|
||||
```
|
||||
#Add conda channels
|
||||
#Add channels for dependencies and our library
|
||||
conda config --add channels conda-forge
|
||||
conda config --add channels slsdetectorgroup
|
||||
conda config --set channel_priority strict
|
||||
|
||||
conda install slsdetlib #only shared lib and command line
|
||||
conda install slsdet #python bindings (includes slsdetlib)
|
||||
conda install slsdetgui #gui (includes qt4)
|
||||
|
||||
#Install specific version
|
||||
conda install slsdet=2020.03.02.dev0 #developer version from 3 March 2020
|
||||
#create and activate an environment with our library
|
||||
#replace 6.1.1 with the required tag
|
||||
conda create -n myenv slsdetlib=6.1.1
|
||||
conda activate myenv
|
||||
|
||||
#ready to use
|
||||
sls_detector_get exptime
|
||||
etc ...
|
||||
```
|
||||
|
||||
### Source code
|
||||
One can also obtain the source code from this repository and compile.
|
||||
```
|
||||
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git
|
||||
# List available versions
|
||||
# lib and binaries
|
||||
conda search slsdetlib
|
||||
# python
|
||||
conda search slsdet
|
||||
# gui
|
||||
conda search slsdetgui
|
||||
```
|
||||
|
||||
## 2. Build from source
|
||||
|
||||
### 2.1 Download Source Code from github
|
||||
```
|
||||
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git --branch 7.0.0
|
||||
```
|
||||
|
||||
> **Note:** For v6.x.x of slsDetectorPackage and older, refer [pybind11 notes on cloning](#Pybind-and-Zeromq).
|
||||
|
||||
|
||||
### 2.2 Build from source
|
||||
|
||||
|
||||
### Build using CMake
|
||||
|
||||
```
|
||||
#### Dependencies
|
||||
# outside slsDetecorPackage folder
|
||||
mkdir build && cd build
|
||||
|
||||
Refer [this page](https://slsdetectorgroup.github.io/devdoc/dependencies.html) for dependencies.
|
||||
# configure & generate Makefiles using cmake
|
||||
# by listing all your options (alternately use ccmake described below)
|
||||
# cmake3 for some systems
|
||||
cmake ../slsDetectorPackage -DCMAKE_INSTALL_PREFIX=/your/install/path
|
||||
|
||||
# compiled to the build/bin directory
|
||||
make -j12 #or whatever number of cores you are using to build
|
||||
|
||||
#### Compilation
|
||||
|
||||
Compiling can be done in two ways. Either with the convenience script
|
||||
cmk.sh or directly with cmake for more control.
|
||||
|
||||
**1. Compile using script cmk.sh**<br>
|
||||
|
||||
These are mainly aimed at those not familiar with using ccmake and cmake.
|
||||
# install headers and libs in /your/install/path directory
|
||||
make install
|
||||
```
|
||||
The binaries are generated in slsDetectorPackage/build/bin directory.
|
||||
|
||||
Usage: ./cmk.sh [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [m] [n] [-h] [z] [-d <HDF5 directory>] [-l Install directory] [-k <CMake command>] [-j <Number of threads>]
|
||||
-[no option]: only make
|
||||
-c: Clean
|
||||
-b: Builds/Rebuilds CMake files normal mode
|
||||
-p: Builds/Rebuilds Python API
|
||||
-h: Builds/Rebuilds Cmake files with HDF5 package
|
||||
-d: HDF5 Custom Directory
|
||||
-k: CMake command
|
||||
-l: Install directory
|
||||
-t: Build/Rebuilds only text client
|
||||
-r: Build/Rebuilds only receiver
|
||||
-g: Build/Rebuilds only gui
|
||||
-s: Simulator
|
||||
-u: Chip Test Gui
|
||||
-j: Number of threads to compile through
|
||||
-e: Debug mode
|
||||
-i: Builds tests
|
||||
-m: Manuals
|
||||
-n: Manuals without compiling doxygen (only rst)
|
||||
-z: Moench zmq processor
|
||||
Instead of the cmake command, one can use ccmake to get a list of options to configure and generate Makefiles at ease.
|
||||
|
||||
|
||||
# get all options
|
||||
./cmk.sh -?
|
||||
|
||||
# new build and compile in parallel:
|
||||
./cmk.sh -bj5
|
||||
```
|
||||
# ccmake3 for some systems
|
||||
ccmake ..
|
||||
|
||||
**2. Compile without script**<br>
|
||||
Use cmake to create out-of-source builds, by creating a build folder parallel to source directory. This would create a debug build with address sanitizers.
|
||||
```
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ cmake ../slsDetectorPackage -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_SANITIZER=ON
|
||||
$ make -j12 #or whatever number of threads wanted
|
||||
# choose the options
|
||||
# first press [c] - configure (unil you see [g])
|
||||
# then press [g] - generate
|
||||
```
|
||||
|
||||
To install binaries using CMake
|
||||
|Example cmake options|Comment|
|
||||
|---|---|
|
||||
| -DSLS_USE_PYTHON=ON | Python |
|
||||
| -DPython_FIND_VIRTUALENV=ONLY | Python from only the conda env |
|
||||
| -DSLS_USE_GUI=ON | GUI |
|
||||
| -DSLS_USE_HDF5=ON | HDF5 |
|
||||
| -DSLS_USE_SIMULATOR=ON | Simulator |
|
||||
|
||||
> **Note:** For v7.x.x of slsDetectorPackage and older, refer [zeromq notes for cmake option to hint library location](#Pybind-and-Zeromq).
|
||||
|
||||
### Build using in-built cmk.sh script
|
||||
|
||||
```
|
||||
git clone --recursive https://github.com/slsdetectorgroup/slsDetectorPackage.git
|
||||
mkdir build && cd build
|
||||
cmake ../slsDetectorPackage -DCMAKE_INSTALL_PREFIX=/your/install/path
|
||||
make -j12 #or whatever number of cores you are using to build
|
||||
make install
|
||||
The binaries are generated in slsDetectorPackage/build/bin directory.
|
||||
|
||||
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-h] [-i]
|
||||
[-j <Number of threads>] [-k <CMake command>] [-l <Install directory>]
|
||||
[-m] [-n] [-p] [-r] [-s] [-t] [-u] [-z]
|
||||
-[no option]: only make
|
||||
-b: Builds/Rebuilds CMake files normal mode
|
||||
-c: Clean
|
||||
-d: HDF5 Custom Directory
|
||||
-e: Debug mode
|
||||
-g: Build/Rebuilds gui
|
||||
-h: Builds/Rebuilds Cmake files with HDF5 package
|
||||
-i: Builds tests
|
||||
-j: Number of threads to compile through
|
||||
-k: CMake command
|
||||
-l: Install directory
|
||||
-m: Manuals
|
||||
-n: Manuals without compiling doxygen (only rst)
|
||||
-p: Builds/Rebuilds Python API
|
||||
-r: Build/Rebuilds only receiver
|
||||
-s: Simulator
|
||||
-t: Build/Rebuilds only text client
|
||||
-u: Chip Test Gui
|
||||
-z: Moench zmq processor
|
||||
|
||||
|
||||
# display all options
|
||||
./cmk.sh -?
|
||||
|
||||
# new build and compile in parallel (recommended basic option):
|
||||
./cmk.sh -cbj5
|
||||
|
||||
# new build, python and compile in parallel:
|
||||
./cmk.sh -cbpj5
|
||||
|
||||
#For rebuilding only certain sections
|
||||
./cmk.sh -tg #only text client and gui
|
||||
./cmk.sh -r #only receiver
|
||||
```
|
||||
|
||||
> **Note:** For v7.x.x of slsDetectorPackage and older, refer [zeromq notes for cmk script option to hint library location](#Pybind-and-Zeromq).
|
||||
|
||||
### Build on old distributions
|
||||
|
||||
If your linux distribution doesn't come with a C++11 compiler (gcc>4.8) then
|
||||
it's possible to install a newer gcc using conda and build the slsDetectorPackage
|
||||
using this compiler
|
||||
|
||||
```
|
||||
#Create an environment with the dependencies
|
||||
conda create -n myenv gxx_linux-64 cmake zmq
|
||||
conda activate myenv
|
||||
|
||||
# outside slsDetecorPackage folder
|
||||
mkdir build && cd build
|
||||
cmake ../slsDetectorPackage -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
|
||||
make -j12
|
||||
```
|
||||
|
||||
> **Note:** For v7.x.x of slsDetectorPackage and older, refer [zeromq notes for dependencies for conda](#Pybind-and-Zeromq).
|
||||
|
||||
|
||||
### Build slsDetectorGui (Qt5)
|
||||
|
||||
1. Using pre-built binary on conda
|
||||
```
|
||||
conda create -n myenv slsdetgui=7.0.0
|
||||
conda activate myenv
|
||||
```
|
||||
|
||||
2. Using system installation on RHEL7
|
||||
```
|
||||
yum install qt5-qtbase-devel.x86_64
|
||||
yum install qt5-qtsvg-devel.x86_64
|
||||
```
|
||||
|
||||
3. Using system installation on RHEL8
|
||||
```
|
||||
yum install qt5-qtbase-devel.x86_64
|
||||
yum install qt5-qtsvg-devel.x86_64
|
||||
yum install expat-devel.x86_64
|
||||
```
|
||||
|
||||
4. Using conda
|
||||
```
|
||||
#Add channels for dependencies and our library
|
||||
conda config --add channels conda-forge
|
||||
conda config --add channels slsdetectorgroup
|
||||
conda config --set channel_priority strict
|
||||
|
||||
# create environment to compile
|
||||
# on rhel7
|
||||
conda create -n slsgui zeromq gxx_linux-64 gxx_linux-64 mesa-libgl-devel-cos6-x86_64 qt
|
||||
# on fedora or newer systems
|
||||
conda create -n slsgui zeromq qt
|
||||
|
||||
# when using conda compilers, would also need libgl, but no need for it on fedora unless maybe using it with ROOT
|
||||
|
||||
# activate environment
|
||||
conda activate slsgui
|
||||
|
||||
# compile with cmake outside slsDetecorPackage folder
|
||||
mkdir build && cd build
|
||||
cmake ../slsDetectorPackage -DSLS_USE_GUI=ON
|
||||
make -j12
|
||||
|
||||
# or compile with cmk.sh
|
||||
cd slsDetectorPackage
|
||||
./cmk.sh -cbgj9
|
||||
```
|
||||
|
||||
> **Note:** For v7.x.x of slsDetectorPackage and older, refer [zeromq notes for dependencies for conda](#Pybind-and-Zeromq).
|
||||
|
||||
### Build documentation from package
|
||||
The documentation for the slsDetectorPackage is build using a combination
|
||||
of Doxygen, Sphinx and Breathe. The easiest way to install the dependencies
|
||||
is to use conda
|
||||
|
||||
```
|
||||
conda create -n myenv python=3.12 sphinx sphinx_rtd_theme breathe doxygen numpy
|
||||
```
|
||||
|
||||
```
|
||||
# using cmake or ccmake to enable DSLS_BUILD_DOCS
|
||||
# outside slsDetecorPackage folder
|
||||
mkdir build && cd build
|
||||
cmake ../slsDetectorPackage -DSLS_BUILD_DOCS=ON
|
||||
|
||||
make docs # generate API docs and build Sphinx RST
|
||||
make rst # rst only, saves time in case the API did not change
|
||||
```
|
||||
|
||||
|
||||
### Support
|
||||
|
||||
## Pybind and Zeromq
|
||||
|
||||
### Pybind11 for Python
|
||||
**v8.0.0+**:
|
||||
pybind11 is built
|
||||
* by default from tar file in repo (libs/pybind/v2.1x.0.tar.gz)
|
||||
* or use advanced option SLS_FETCH_PYBIND11_FROM_GITHUB [link].
|
||||
* v9.0.0+: pybind11 (v2.13.6)
|
||||
* v8.x.x : pybind11 (v2.11.0)
|
||||
|
||||
**v7.x.x**:
|
||||
pybind11 packaged into ‘libs/pybind’. No longer a submodule. No need for “recursive” or “submodule update”.
|
||||
|
||||
**Older versions**:
|
||||
pybind11 is a submodule. Must be cloned using “recursive” and updated when switching between versions using the following commands.
|
||||
|
||||
```
|
||||
# Note: Only for v6.x.x versions and older
|
||||
|
||||
# clone using recursive to get pybind11 submodule
|
||||
git clone --recursive https://github.com/slsdetectorgroup/slsDetectorPackage.git
|
||||
|
||||
# update submodule when switching between releases
|
||||
cd slsDetectorPackage
|
||||
git submodule update --init
|
||||
```
|
||||
|
||||
### Zeromq
|
||||
**v8.0.0+**:
|
||||
zeromq (v4.3.4) is built
|
||||
* by default from tar file in repo (libs/libzmq/libzmq-4.3.4.tar.gz)
|
||||
* or use advanced option SLS_FETCH_ZMQ_FROM_GITHUB [link].
|
||||
|
||||
**v7.x.x and older**:
|
||||
zeromq-devel must be installed and one can hint its location using
|
||||
* cmake option:’-DZeroMQ_HINT=/usr/lib64’ or
|
||||
* option ‘-q’ in cmk.sh script: : ./cmk.sh -cbj5 -q /usr/lib64
|
||||
* ‘zeromq’ dependency added when installing using conda
|
||||
|
||||
|
||||
## Support
|
||||
dhanya.thattil@psi.ch
|
||||
erik.frojdh@psi.ch
|
981
RELEASE.txt
981
RELEASE.txt
File diff suppressed because it is too large
Load Diff
1
bash_autocomplete.sh
Symbolic link
1
bash_autocomplete.sh
Symbolic link
@ -0,0 +1 @@
|
||||
slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh
|
@ -1,38 +0,0 @@
|
||||
function(custom_find_zmq)
|
||||
set(ZeroMQ_HINT "" CACHE STRING "Hint where ZeroMQ could be found")
|
||||
#Adapted from: https://github.com/zeromq/cppzmq/
|
||||
if (NOT TARGET libzmq)
|
||||
if(ZeroMQ_HINT)
|
||||
message(STATUS "Looking for ZeroMQ in: ${ZeroMQ_HINT}")
|
||||
find_package(ZeroMQ 4
|
||||
NO_DEFAULT_PATH
|
||||
HINTS ${ZeroMQ_HINT}
|
||||
)
|
||||
else()
|
||||
find_package(ZeroMQ 4 QUIET)
|
||||
endif()
|
||||
|
||||
# libzmq autotools install: fallback to pkg-config
|
||||
if(ZeroMQ_FOUND)
|
||||
message(STATUS "Found libzmq using find_package")
|
||||
else()
|
||||
message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)")
|
||||
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/libzmq-pkg-config)
|
||||
find_package(ZeroMQ 4 REQUIRED)
|
||||
endif()
|
||||
|
||||
# TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work
|
||||
if(NOT ZeroMQ_FOUND)
|
||||
message(FATAL_ERROR "ZeroMQ was not found, neither as a CMake package nor via pkg-config")
|
||||
endif()
|
||||
|
||||
if (ZeroMQ_FOUND AND NOT TARGET libzmq)
|
||||
message(FATAL_ERROR "ZeroMQ version not supported!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
get_target_property(VAR libzmq IMPORTED_LOCATION)
|
||||
message(STATUS "Using libzmq: ${VAR}")
|
||||
|
||||
|
||||
endfunction()
|
@ -1,36 +0,0 @@
|
||||
#From: https://github.com/zeromq/cppzmq/
|
||||
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(PC_LIBZMQ QUIET libzmq)
|
||||
|
||||
set(ZeroMQ_VERSION ${PC_LIBZMQ_VERSION})
|
||||
|
||||
find_path(ZeroMQ_INCLUDE_DIR zmq.h
|
||||
PATHS ${ZeroMQ_DIR}/include
|
||||
${PC_LIBZMQ_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
find_library(ZeroMQ_LIBRARY
|
||||
NAMES zmq
|
||||
PATHS ${ZeroMQ_DIR}/lib
|
||||
${PC_LIBZMQ_LIBDIR}
|
||||
${PC_LIBZMQ_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY)
|
||||
set(ZeroMQ_FOUND ON)
|
||||
message(STATUS "Found libzmq using PkgConfig")
|
||||
endif()
|
||||
|
||||
set ( ZeroMQ_LIBRARIES ${ZeroMQ_LIBRARY} )
|
||||
set ( ZeroMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR} )
|
||||
|
||||
if (NOT TARGET libzmq)
|
||||
add_library(libzmq UNKNOWN IMPORTED)
|
||||
set_target_properties(libzmq PROPERTIES
|
||||
IMPORTED_LOCATION ${ZeroMQ_LIBRARIES}
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${ZeroMQ_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
include ( FindPackageHandleStandardArgs )
|
||||
find_package_handle_standard_args ( ZeroMQ DEFAULT_MSG ZeroMQ_LIBRARIES ZeroMQ_INCLUDE_DIRS )
|
@ -25,11 +25,6 @@ install(FILES
|
||||
DESTINATION ${CMAKE_INSTALL_DIR}
|
||||
)
|
||||
|
||||
install(FILES
|
||||
"${CMAKE_SOURCE_DIR}/cmake/libzmq-pkg-config/FindZeroMQ.cmake"
|
||||
COMPONENT devel
|
||||
DESTINATION ${CMAKE_INSTALL_DIR}/libzmq-pkg-config
|
||||
)
|
||||
|
||||
if (PROJECT_LIBRARIES OR PROJECT_STATIC_LIBRARIES)
|
||||
install(
|
||||
|
@ -13,17 +13,6 @@ include(CMakeFindDependencyMacro)
|
||||
set(SLS_USE_HDF5 "@SLS_USE_HDF5@")
|
||||
|
||||
|
||||
find_package(ZeroMQ 4 QUIET)
|
||||
# libzmq autotools install: fallback to pkg-config
|
||||
if(NOT ZeroMQ_FOUND)
|
||||
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config)
|
||||
find_package(ZeroMQ 4 REQUIRED)
|
||||
endif()
|
||||
|
||||
if(NOT ZeroMQ_FOUND)
|
||||
message(FATAL_ERROR "ZeroMQ was NOT found!")
|
||||
endif()
|
||||
|
||||
find_dependency(Threads)
|
||||
|
||||
# Add optional dependencies here
|
||||
|
17
cmk.sh
17
cmk.sh
@ -18,7 +18,6 @@ CTBGUI=0
|
||||
MANUALS=0
|
||||
MANUALS_ONLY_RST=0
|
||||
MOENCHZMQ=0
|
||||
ZMQ_HINT_DIR=""
|
||||
|
||||
|
||||
CLEAN=0
|
||||
@ -27,13 +26,13 @@ CMAKE_PRE=""
|
||||
CMAKE_POST=""
|
||||
|
||||
usage() { echo -e "
|
||||
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [e] [g] [-h] [i] [-j <Number of threads>] [-k <CMake command>] [-l <Install directory>] [m] [n] [-p] [-q <Zmq hint directory>] [r] [s] [t] [u] [z]
|
||||
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-h] [-i] [-j <Number of threads>] [-k <CMake command>] [-l <Install directory>] [-m] [-n] [-p] [-r] [-s] [-t] [-u] [-z]
|
||||
-[no option]: only make
|
||||
-b: Builds/Rebuilds CMake files normal mode
|
||||
-c: Clean
|
||||
-d: HDF5 Custom Directory
|
||||
-e: Debug mode
|
||||
-g: Build/Rebuilds only gui
|
||||
-g: Build/Rebuilds gui
|
||||
-h: Builds/Rebuilds Cmake files with HDF5 package
|
||||
-i: Builds tests
|
||||
-j: Number of threads to compile through
|
||||
@ -42,7 +41,6 @@ Usage: $0 [-b] [-c] [-d <HDF5 directory>] [e] [g] [-h] [i] [-j <Number of thread
|
||||
-m: Manuals
|
||||
-n: Manuals without compiling doxygen (only rst)
|
||||
-p: Builds/Rebuilds Python API
|
||||
-q: Zmq hint directory
|
||||
-r: Build/Rebuilds only receiver
|
||||
-s: Simulator
|
||||
-t: Build/Rebuilds only text client
|
||||
@ -140,10 +138,6 @@ while getopts ":bcd:eghij:k:l:mnpq:rstuz" opt ; do
|
||||
PYTHON=1
|
||||
REBUILD=1
|
||||
;;
|
||||
q)
|
||||
echo "Zmq hint directory: $OPTARG"
|
||||
ZMQ_HINT_DIR=$OPTARG
|
||||
;;
|
||||
r)
|
||||
echo "Compiling Options: Receiver"
|
||||
RECEIVER=1
|
||||
@ -260,13 +254,6 @@ if [ $TESTS -eq 1 ]; then
|
||||
echo "Tests Option enabled"
|
||||
fi
|
||||
|
||||
#zmq hint dir
|
||||
if [ -n "$ZMQ_HINT_DIR" ]; then
|
||||
CMAKE_POST+=" -DZeroMQ_HINT="$ZMQ_HINT_DIR
|
||||
CMAKE_POST+=" -DZeroMQ_DIR="
|
||||
# echo "Enabling Zmq Hint Directory: $ZMQ_HINT_DIR"
|
||||
fi
|
||||
|
||||
#hdf5 rebuild
|
||||
if [ $HDF5 -eq 1 ]; then
|
||||
# CMAKE_PRE+="HDF5_ROOT="$HDF5DIR
|
||||
|
@ -1,8 +1,12 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
mkdir build
|
||||
mkdir install
|
||||
if [ ! -d "build" ]; then
|
||||
mkdir build
|
||||
fi
|
||||
if [ ! -d "install" ]; then
|
||||
mkdir install
|
||||
fi
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
|
@ -2,5 +2,10 @@
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
echo "|<-------- starting python build"
|
||||
|
||||
cd python
|
||||
${PYTHON} setup.py install
|
||||
|
||||
# copy VERSION into slsdet for installation
|
||||
cp ../VERSION slsdet/VERSION
|
||||
|
||||
${PYTHON} setup.py install
|
@ -2,7 +2,7 @@ python:
|
||||
- 3.8
|
||||
- 3.9
|
||||
- 3.10
|
||||
- 3.11
|
||||
|
||||
numpy:
|
||||
- 1.17
|
||||
- 3.11
|
||||
- 3.12
|
||||
- 3.13
|
||||
|
@ -1,15 +1,15 @@
|
||||
|
||||
package:
|
||||
name: sls_detector_software
|
||||
version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
|
||||
|
||||
source:
|
||||
- path: ..
|
||||
path: ..
|
||||
|
||||
build:
|
||||
number: 0
|
||||
binary_relocation: True
|
||||
rpaths:
|
||||
rpaths:
|
||||
- lib/
|
||||
|
||||
requirements:
|
||||
@ -18,7 +18,6 @@ requirements:
|
||||
- {{compiler('cxx')}}
|
||||
- cmake
|
||||
- qt 5.*
|
||||
- zeromq
|
||||
- xorg-libx11
|
||||
- xorg-libice
|
||||
- xorg-libxext
|
||||
@ -37,7 +36,6 @@ requirements:
|
||||
host:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
- xorg-libx11
|
||||
- xorg-libice
|
||||
- xorg-libxext
|
||||
@ -48,7 +46,6 @@ requirements:
|
||||
- expat
|
||||
|
||||
run:
|
||||
- zeromq
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
|
||||
@ -63,18 +60,12 @@ outputs:
|
||||
- {{compiler('cxx')}}
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
|
||||
host:
|
||||
- zeromq
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
|
||||
- name: slsdet
|
||||
|
||||
script: build_pylib.sh
|
||||
|
||||
requirements:
|
||||
@ -84,10 +75,13 @@ outputs:
|
||||
- {{compiler('cxx')}}
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- setuptools
|
||||
- pybind11=2.13
|
||||
|
||||
host:
|
||||
- python
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- setuptools
|
||||
- pybind11=2.13
|
||||
|
||||
|
||||
run:
|
||||
@ -97,11 +91,11 @@ outputs:
|
||||
- numpy
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
|
||||
test:
|
||||
imports:
|
||||
- slsdet
|
||||
|
||||
|
||||
- name: slsdetgui
|
||||
script: copy_gui.sh
|
||||
requirements:
|
@ -1,90 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
|
||||
find_package(ROOT CONFIG REQUIRED COMPONENTS Core Gui)
|
||||
find_package(TIFF REQUIRED)
|
||||
|
||||
target_include_directories(ROOT::Core INTERFACE "${ROOT_INCLUDE_DIRS}")
|
||||
add_library(ROOT::Flags_CXX IMPORTED INTERFACE)
|
||||
separate_arguments(ROOT_CXX_FLAGS)
|
||||
target_compile_options(ROOT::Flags_CXX INTERFACE ${ROOT_CXX_FLAGS})
|
||||
separate_arguments(ROOT_DEFINITIONS)
|
||||
target_compile_definitions(ROOT::Flags_CXX INTERFACE ${ROOT_DEFINITIONS})
|
||||
|
||||
# This fixes a bug in the linker flags
|
||||
string(REPLACE "-L " "-L" ROOT_EXE_LINKER_FLAGS "${ROOT_EXE_LINKER_FLAGS}")
|
||||
separate_arguments(ROOT_EXE_LINKER_FLAGS)
|
||||
|
||||
# Stuck into using old property method due to separate -L and -l arguments
|
||||
# (A full path to -l is better!)
|
||||
set_property(TARGET ROOT::Flags_CXX PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES ${ROOT_EXE_LINKER_FLAGS})
|
||||
set_property(TARGET ROOT::Core PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${ROOT_INCLUDE_DIRS}")
|
||||
|
||||
|
||||
add_executable(ctbGui
|
||||
ctbGui.cpp
|
||||
ctbMain.cpp
|
||||
ctbDacs.cpp
|
||||
ctbPowers.cpp
|
||||
ctbSlowAdcs.cpp
|
||||
ctbSignals.cpp
|
||||
ctbAdcs.cpp
|
||||
ctbPattern.cpp
|
||||
ctbAcquisition.cpp
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffio/src/tiffIO.cpp
|
||||
)
|
||||
|
||||
|
||||
#TODO! Replace with target
|
||||
target_include_directories(ctbGui PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/dataStructures
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/interpolations
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffio/include/
|
||||
)
|
||||
|
||||
# Headders needed for ROOT dictionary generation
|
||||
set( HEADERS
|
||||
ctbDefs.h
|
||||
ctbMain.h
|
||||
ctbDacs.h
|
||||
ctbPattern.h
|
||||
ctbSignals.h
|
||||
ctbAdcs.h
|
||||
ctbAcquisition.h
|
||||
ctbPowers.h
|
||||
ctbSlowAdcs.h
|
||||
)
|
||||
|
||||
#set(ROOT_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# ROOT dictionary generation
|
||||
root_generate_dictionary(ctbDict ${HEADERS} LINKDEF ctbLinkDef.h)
|
||||
add_library(ctbRootLib SHARED ctbDict.cxx)
|
||||
target_include_directories(ctbRootLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(ctbRootLib PUBLIC
|
||||
ROOT::Core
|
||||
slsDetectorShared
|
||||
${ROOT_LIBRARIES}
|
||||
${ROOT_EXE_LINKER_FLAGS}
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
ctbRootLib PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
target_link_libraries(ctbGui PUBLIC
|
||||
slsDetectorShared
|
||||
ctbRootLib
|
||||
${TIFF_LIBRARIES}
|
||||
)
|
||||
|
||||
set_target_properties(ctbGui PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
|
||||
)
|
||||
|
@ -1,46 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
|
||||
INCS=ctbMain.h ctbDacs.h ctbPattern.h ctbSignals.h ctbAdcs.h ctbAcquisition.h ctbPowers.h ctbSlowAdcs.h
|
||||
SRC= $(INCS:.h=.cpp) ctbDict.cpp
|
||||
LINKDEF=ctbLinkDef.h
|
||||
ZMQLIB=../slsReceiverSoftware/include
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
|
||||
INCDIR=-I../slsReceiverSoftware/include/ -I../slsDetectorSoftware/include/ -I../slsSupportLib/include/ -I../slsDetectorCalibration -I../slsDetectorCalibration/dataStructures -I$(CBFLIBDIR)/include -I../slsDetectorCalibration/interpolations
|
||||
LDFLAG=-L../build/bin -lSlsDetector -lSlsSupport -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/ -std=c++11
|
||||
#
|
||||
MAIN=ctbGui.cpp
|
||||
|
||||
DESTDIR?=../build/bin
|
||||
|
||||
|
||||
OBJS = $(SRC:.cpp=.o) $(MAIN:.cpp=.o)
|
||||
|
||||
all: $(DESTDIR)/ctbGui
|
||||
|
||||
|
||||
doc:
|
||||
cd manual && make DESTDIR=$(DESTDIR)
|
||||
|
||||
htmldoc:
|
||||
cd manual && make html DESTDIR=$(DESTDIR)
|
||||
|
||||
ctbDict.cpp: $(INCS) $(LINKDEF)
|
||||
rootcint -f ctbDict.cpp -c $(INCS) $(LINKDEF)
|
||||
|
||||
%.o : %.cpp
|
||||
echo $@
|
||||
g++ -DMYROOT `root-config --cflags --glibs` -lMinuit -DCTB $(LDFLAG) -o $@ -c $< $(INCDIR)
|
||||
#$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -lpthread #$(FLAGS)
|
||||
|
||||
|
||||
|
||||
$(DESTDIR)/ctbGui: $(OBJS) $(LINKDEF)
|
||||
g++ -DMYROOT `root-config --cflags --glibs` -lMinuit -DCTB $(LDFLAG) -o ctbGui $(INCDIR) $(OBJS) ../slsDetectorCalibration/tiffIO.cpp
|
||||
mv ctbGui $(DESTDIR)
|
||||
|
||||
clean:
|
||||
rm -f $(DESTDIR)/ctbGui *.o ctbDict.* $(OBJS)
|
||||
|
@ -1,48 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
|
||||
INCS=ctbMain.h ctbDacs.h ctbPattern.h ctbSignals.h ctbAdcs.h ctbAcquisition.h ctbPowers.h ctbSlowAdcs.h
|
||||
SRC= $(INCS:.h=.cpp) ctbDict.cpp
|
||||
LINKDEF=ctbLinkDef.h
|
||||
#ctbActions.h
|
||||
ZMQLIB=../slsReceiverSoftware/include
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
|
||||
INCDIR=-I../slsReceiverSoftware/include/ -I../slsDetectorSoftware/include/ -I../slsSupportLib/include/ -I../slsDetectorCalibration -I../slsDetectorCalibration/dataStructures -I$(CBFLIBDIR)/include -I../slsDetectorCalibration/interpolations
|
||||
|
||||
LDFLAG=-L../build/bin -lSlsDetector -lSlsSupport -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/ -std=c++11
|
||||
#
|
||||
MAIN=ctbGui.cpp
|
||||
|
||||
DESTDIR?=../build/bin
|
||||
|
||||
|
||||
OBJS = $(SRC:.cpp=.o) $(MAIN:.cpp=.o)
|
||||
|
||||
all: $(DESTDIR)/ctbGui
|
||||
|
||||
|
||||
doc:
|
||||
cd manual && make DESTDIR=$(DESTDIR)
|
||||
|
||||
htmldoc:
|
||||
cd manual && make html DESTDIR=$(DESTDIR)
|
||||
|
||||
ctbDict.cpp: $(INCS) $(LINKDEF)
|
||||
rootcling -f ctbDict.cpp -c $(INCS) $(LINKDEF)
|
||||
|
||||
%.o : %.cpp
|
||||
echo $@
|
||||
g++ -DMYROOT `source root-config --cflags --glibs` -lMinuit -DCTB $(LDFLAG) -o $@ -c $< $(INCDIR)
|
||||
#$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -lpthread #$(FLAGS)
|
||||
|
||||
|
||||
|
||||
$(DESTDIR)/ctbGui: $(OBJS) $(LINKDEF)
|
||||
g++ -DMYROOT `source root-config --cflags --glibs` -lMinuit -DCTB $(LDFLAG) -o ctbGui $(INCDIR) $(OBJS) ../slsDetectorCalibration/tiffIO.cpp
|
||||
mv ctbGui $(DESTDIR)
|
||||
|
||||
clean:
|
||||
rm -f $(DESTDIR)/ctbGui *.o ctbDict.* $(OBJS)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,248 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef CTBACQUISITION_H
|
||||
#define CTBACQUISITION_H
|
||||
#include <TGFrame.h>
|
||||
|
||||
#include "ctbAdcs.h"
|
||||
#include "ctbSignals.h"
|
||||
#include "ctbPattern.h"
|
||||
class TGTextEntry;
|
||||
class TGLabel;
|
||||
class TGNumberEntry;
|
||||
class TGCheckButton;
|
||||
class TThread;
|
||||
class TGraph;
|
||||
class TMultiGraph;
|
||||
class THStack;
|
||||
class TGButtonGroup;
|
||||
class TGRadioButton;
|
||||
class TGComboBox;
|
||||
class TTimer;
|
||||
class TCanvas;
|
||||
class TH2F;
|
||||
class TH1F;
|
||||
class TGLabel;
|
||||
class TGTextButton;
|
||||
|
||||
namespace sls
|
||||
{
|
||||
class Detector;
|
||||
class detectorData;
|
||||
};
|
||||
|
||||
template <class dataType> class slsDetectorData;
|
||||
|
||||
class singlePhotonDetector;
|
||||
//class singlePhotonDetector;
|
||||
class commonModeSubtraction;
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
using namespace std;
|
||||
|
||||
class ctbAcquisition : public TGGroupFrame {
|
||||
|
||||
|
||||
enum {DESERIALIZER, MOENCH04, MOENCH02, MOENCH03, IMAGE32B, IMAGE16B, ADCSAR2, MYTHEN301, MYTHEN302};
|
||||
|
||||
|
||||
private:
|
||||
TGTextEntry *eOutdir;
|
||||
TGTextEntry *eFname;
|
||||
TGNumberEntry *eFindex;
|
||||
TGCheckButton *cFileSave;
|
||||
|
||||
|
||||
TGNumberEntry *eSerOff;
|
||||
TGNumberEntry *eDynRange;
|
||||
TGNumberEntry *eNumCount;
|
||||
|
||||
|
||||
TGNumberEntry *ePixX;
|
||||
TGNumberEntry *ePixY;
|
||||
|
||||
TGNumberEntry *eFitADC;
|
||||
TGNumberEntry *eBitPlot;
|
||||
TGNumberEntry *eMinRaw;
|
||||
TGNumberEntry *eMaxRaw;
|
||||
TGNumberEntry *eMinPedSub;
|
||||
TGNumberEntry *eMaxPedSub;
|
||||
TGCheckButton *cMinMaxRaw;
|
||||
TGCheckButton *cMinMaxPedSub;
|
||||
|
||||
|
||||
|
||||
|
||||
TGNumberEntry *eMeasurements;
|
||||
|
||||
|
||||
|
||||
TGTextButton *bStatus;
|
||||
// TGTextButton
|
||||
TGCheckButton *cCompile;
|
||||
TGTextButton *cLoad;
|
||||
// TGCheckButton *cRun;
|
||||
|
||||
TThread *acqThread;
|
||||
|
||||
|
||||
THStack *adcStack;
|
||||
THStack *bitStack;
|
||||
THStack *countsStack;
|
||||
|
||||
|
||||
TH1F *adcHisto[NADCS];
|
||||
TH1F *countsHisto[NADCS];
|
||||
|
||||
TH1F *bitHisto[NSIGNALS];
|
||||
float bitOffset[NSIGNALS];
|
||||
|
||||
// int enableFlag[NADCS+4];
|
||||
int roMode;
|
||||
|
||||
int dBitOffset;
|
||||
|
||||
|
||||
|
||||
TH1F *adcFit;
|
||||
TH1F *bitPlot;
|
||||
TH1F *countsFit;
|
||||
|
||||
|
||||
|
||||
TH2F *h2DMapAn; // for 2D detectors
|
||||
TH2F *h2DMapDig; // for 2D detectors
|
||||
TH1F *h1DMap; //for 1D detectors
|
||||
|
||||
// TH2F *h2Scan; // for 2D detectors
|
||||
// TMultiGraph *mgAdcs;
|
||||
// TH1I *plotAdc[NADCS];
|
||||
|
||||
|
||||
sls::Detector* myDet;
|
||||
|
||||
int plotFlag[NADCS];
|
||||
int bitPlotFlag[NSIGNALS];
|
||||
|
||||
int ip;
|
||||
// int nChannels;
|
||||
// int chanEnable;
|
||||
//int nADCs;
|
||||
|
||||
std::vector <int> dbitlist;
|
||||
std::vector <int> adclist;
|
||||
|
||||
TGButtonGroup *bgPlot;// = new TGVButtonGroup(main_frame);
|
||||
TGRadioButton *rbPlotOff;
|
||||
TGRadioButton *rbWaveform;
|
||||
TGRadioButton *rbDistribution;
|
||||
TGRadioButton *rb2D;
|
||||
// TGRadioButton *rbScan;
|
||||
TGComboBox *cbDetType;
|
||||
TGCheckButton *cbGetPedestal;
|
||||
TGCheckButton *cbSubtractPedestal;
|
||||
TGCheckButton *cbCommonMode;
|
||||
TGTextButton *bResetPedestal;
|
||||
|
||||
TGLabel *lClickX;
|
||||
TGLabel *lClickY;
|
||||
TGLabel *lClickValue;
|
||||
|
||||
|
||||
TCanvas *myCanvas;
|
||||
TTimer *plotTimer;
|
||||
|
||||
char patternFile[10000];
|
||||
char patternCompiler[10000];
|
||||
|
||||
int globalPlot;
|
||||
int adcPlot;
|
||||
int dbitPlot;
|
||||
int tenG;
|
||||
|
||||
int nAnalogSamples, nDigitalSamples;
|
||||
// int iScanStep;
|
||||
|
||||
slsDetectorData<uint16_t> *dataStructure;
|
||||
singlePhotonDetector *photonFinder;
|
||||
//singlePhotonDetector *photonFinder;
|
||||
commonModeSubtraction *commonMode;
|
||||
int cmSub;
|
||||
|
||||
int stop;
|
||||
|
||||
uint64_t dBitMask;
|
||||
|
||||
int deserializer;
|
||||
|
||||
public:
|
||||
ctbAcquisition(TGVerticalFrame*, sls::Detector*);
|
||||
void setOutdir();
|
||||
void setFname();
|
||||
void setMeasurements();
|
||||
void setFsave(Bool_t);
|
||||
void changePlot(Int_t);
|
||||
void changeDetector(Int_t);
|
||||
void changePlot();
|
||||
void changeDetector();
|
||||
void setFindex();
|
||||
void Draw();
|
||||
void setCanvas(TCanvas*);
|
||||
|
||||
void toggleAcquisition();
|
||||
void loadPattern();
|
||||
static void* ThreadHandle(void *arg);
|
||||
void update();
|
||||
void acquisitionFinished();
|
||||
// string getParameters();
|
||||
|
||||
void setGraph (int i ,int en, Pixel_t col);
|
||||
void setBitGraph (int i ,int en, Pixel_t col);
|
||||
void startAcquisition();
|
||||
static void progressCallback(double,void*);
|
||||
static void dataCallback(sls::detectorData*, long unsigned int, unsigned int, void*);
|
||||
int StopFlag;
|
||||
|
||||
int plotData(sls::detectorData*, int);
|
||||
|
||||
void setPatternFile(const char* t);
|
||||
|
||||
void setPatternCompiler(const char* t);
|
||||
|
||||
void setAnalogSamples(int);
|
||||
void setDigitalSamples(int);
|
||||
|
||||
void setADCEnable(Int_t);
|
||||
void setDbitEnable(Int_t);
|
||||
void setReadoutMode(int);
|
||||
void updateChans();
|
||||
|
||||
void resetPedestal();
|
||||
|
||||
void ToggleCommonMode(Bool_t);
|
||||
void TogglePedSub(Bool_t);
|
||||
void ChangeHistoLimitsPedSub(Long_t );
|
||||
void ChangeHistoLimitsRaw(Long_t);
|
||||
void ChangeHistoLimitsPedSub( );
|
||||
void ChangeHistoLimitsRaw();
|
||||
void ChangeHistoLimitsPedSub(Bool_t );
|
||||
void ChangeHistoLimitsRaw(Bool_t);
|
||||
|
||||
|
||||
void ChangeSerialOffset();
|
||||
void ChangeSerialOffset(Long_t);
|
||||
void ChangeNumberOfChannels();
|
||||
void ChangeNumberOfChannels(Long_t);
|
||||
void ChangeDynamicRange();
|
||||
void ChangeDynamicRange(Long_t);
|
||||
void ChangeImagePixels();
|
||||
void ChangeImagePixels(Long_t);
|
||||
|
||||
void canvasClicked();
|
||||
void FitADC();
|
||||
void plotBit();
|
||||
ClassDef(ctbAcquisition,0)
|
||||
};
|
||||
|
||||
#endif
|
@ -1,616 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include <TApplication.h>
|
||||
#include <TGClient.h>
|
||||
#include <TCanvas.h>
|
||||
#include <TF1.h>
|
||||
#include <TRandom.h>
|
||||
#include <TGButton.h>
|
||||
#include <TRootEmbeddedCanvas.h>
|
||||
#include <TGButtonGroup.h>
|
||||
#include <TGNumberEntry.h>
|
||||
#include <TGLabel.h>
|
||||
#include <TList.h>
|
||||
#include <TGFileDialog.h>
|
||||
#include <TGComboBox.h>
|
||||
#include <TH2F.h>
|
||||
#include <TColor.h>
|
||||
#include <TH1F.h>
|
||||
#include <TGraphErrors.h>
|
||||
#include <TGColorSelect.h>
|
||||
#include <THStack.h>
|
||||
#include <TGTab.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "ctbAdcs.h"
|
||||
#include "ctbDefs.h"
|
||||
#include "sls/Detector.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
ctbAdc::ctbAdc(TGVerticalFrame *page, int i, sls::Detector *det)
|
||||
: TGHorizontalFrame(page, 800,800), id(i), myDet(det) {
|
||||
|
||||
TGHorizontalFrame *hframe=this;
|
||||
char tit[100];
|
||||
|
||||
page->AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
hframe->MapWindow();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sprintf(tit, "ADC%d", id);
|
||||
|
||||
sAdcLabel= new TGLabel(hframe, tit);
|
||||
hframe->AddFrame(sAdcLabel,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
|
||||
sAdcLabel->MapWindow();
|
||||
sAdcLabel->SetTextJustify(kTextLeft);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sAdcInvert= new TGCheckButton(hframe, "Inv");
|
||||
hframe->AddFrame( sAdcInvert,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
|
||||
sAdcInvert->MapWindow();
|
||||
sAdcInvert->Connect("Toggled(Bool_t)","ctbAdc",this,"ToggledInvert(Bool_t)");
|
||||
|
||||
|
||||
sAdcEnable= new TGCheckButton(hframe, "En");
|
||||
hframe->AddFrame( sAdcEnable,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
|
||||
sAdcEnable->MapWindow();
|
||||
// sAdcEnable->SetOn(kTRUE);
|
||||
// sAdcEnable->SetEnabled(kFALSE);
|
||||
sAdcEnable->Connect("Toggled(Bool_t)","ctbAdc",this,"ToggledEnable(Bool_t)");
|
||||
|
||||
|
||||
|
||||
sAdcPlot= new TGCheckButton(hframe, "Plot");
|
||||
hframe->AddFrame( sAdcPlot,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
|
||||
sAdcPlot->MapWindow();
|
||||
|
||||
|
||||
sAdcPlot->Connect("Toggled(Bool_t)","ctbAdc",this,"ToggledPlot(Bool_t)");
|
||||
|
||||
|
||||
|
||||
fColorSel = new TGColorSelect(hframe, id+1, 0);
|
||||
|
||||
fColorSel->Connect("ColorSelected(Pixel_t)","ctbAdc",this,"ColorChanged(Pixel_t)");
|
||||
hframe->AddFrame(fColorSel, new TGLayoutHints(kLHintsTop |
|
||||
kLHintsLeft, 2, 0, 2, 2));
|
||||
|
||||
|
||||
fColorSel->SetColor(TColor::Number2Pixel(id+1));
|
||||
// sprintf(tit,"adc%d",id);
|
||||
// gADC=new TGraph();
|
||||
// gADC->SetName(tit);
|
||||
// gADC->SetLineColor(id+1);
|
||||
// gADC->SetMarkerColor(id+1);
|
||||
|
||||
|
||||
|
||||
};
|
||||
Pixel_t ctbAdc::getColor(){
|
||||
return fColorSel->GetColor();
|
||||
}
|
||||
Bool_t ctbAdc::getEnabled(){
|
||||
return getPlot();
|
||||
}
|
||||
Bool_t ctbAdc::getPlot(){
|
||||
return sAdcPlot->IsOn();
|
||||
}
|
||||
Bool_t ctbAdc::getInverted(){
|
||||
return sAdcInvert->IsOn();
|
||||
}
|
||||
|
||||
Bool_t ctbAdc::getEnable(){
|
||||
return sAdcEnable->IsOn();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctbAdc::setInverted(Bool_t b){
|
||||
// cout << id << "set enabled " << b << endl;
|
||||
if (b)
|
||||
sAdcInvert->SetOn(kTRUE,kTRUE);
|
||||
else
|
||||
sAdcInvert->SetOn(kFALSE,kTRUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ctbAdc::setEnable(Bool_t b){
|
||||
// cout << id << "set enabled " << b << endl;
|
||||
if (b)
|
||||
sAdcEnable->SetOn(kTRUE,kFALSE);
|
||||
else
|
||||
sAdcEnable->SetOn(kFALSE,kFALSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ctbAdc::setAdcAlias(char *tit, int plot, int color) {
|
||||
if (tit)
|
||||
sAdcLabel->SetText(tit);
|
||||
if (plot>0)
|
||||
sAdcPlot->SetOn(kTRUE,kTRUE);
|
||||
else if (plot==0)
|
||||
sAdcPlot->SetOn(kFALSE,kTRUE);
|
||||
if (color>=0)
|
||||
fColorSel->SetColor(color);
|
||||
fColorSel->SetEnabled(sAdcPlot->IsOn());
|
||||
}
|
||||
|
||||
|
||||
string ctbAdc::getAdcAlias() {
|
||||
|
||||
char line[1000];
|
||||
sprintf(line,"ADC%d %s %d %lx\n",id,sAdcLabel->GetText()->Data(),sAdcPlot->IsOn(),fColorSel->GetColor());
|
||||
return string(line);
|
||||
}
|
||||
|
||||
void ctbAdc::update() {
|
||||
|
||||
|
||||
//Emit("ToggledAdcEnable(Int_t)", id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ctbAdc::ToggledPlot(Bool_t b){
|
||||
|
||||
// Long_t mask=b<<id;
|
||||
// ToggledAdcPlot(mask);
|
||||
cout << "Colsel " << id << " enable " << b << endl;
|
||||
if (b)
|
||||
fColorSel->SetEnabled(kTRUE);
|
||||
else
|
||||
fColorSel->SetEnabled(kFALSE);
|
||||
|
||||
// fColorSel->SetEnabled(sAdcPlot->IsOn());
|
||||
Emit("ToggledAdcPlot(Int_t)", id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctbAdc::ToggledInvert(Bool_t b){
|
||||
|
||||
|
||||
// fColorSel->SetEnabled(sAdcPlot->IsOn());
|
||||
Emit("ToggledAdcInvert(Int_t)", id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctbAdc::ToggledEnable(Bool_t b){
|
||||
|
||||
|
||||
fColorSel->SetEnabled(sAdcPlot->IsOn());
|
||||
Emit("ToggledAdcEnable(Int_t)", id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ctbAdc::ColorChanged(Pixel_t) {
|
||||
|
||||
Emit("ToggledAdcPlot(Int_t)", id);
|
||||
|
||||
}
|
||||
|
||||
void ctbAdc::ToggledAdcPlot(Int_t b){
|
||||
|
||||
|
||||
Emit("ToggledAdcPlot(Int_t)", id);
|
||||
|
||||
}
|
||||
|
||||
void ctbAdc::ToggledAdcInvert(Int_t b){
|
||||
|
||||
|
||||
Emit("ToggledAdcInvert(Int_t)", id);
|
||||
|
||||
}
|
||||
|
||||
void ctbAdc::ToggledAdcEnable(Int_t b){
|
||||
|
||||
|
||||
Emit("ToggledAdcEnable(Int_t)", id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ctbAdc::setEnabled(Bool_t b){
|
||||
// cout << id << "set enabled " << b << endl;
|
||||
if (b)
|
||||
sAdcPlot->SetOn(kTRUE,kFALSE);
|
||||
else
|
||||
sAdcPlot->SetOn(kFALSE,kFALSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctbAdc::setPlot(Bool_t b){
|
||||
// cout << id << "set enabled " << b << endl;
|
||||
if (b)
|
||||
sAdcPlot->SetOn(kTRUE,kTRUE);
|
||||
else
|
||||
sAdcPlot->SetOn(kFALSE,kTRUE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ctbAdcs::ctbAdcs(TGVerticalFrame *page, sls::Detector *det)
|
||||
: TGGroupFrame(page,"Adcs",kVerticalFrame), myDet(det) {
|
||||
|
||||
|
||||
SetTitlePos(TGGroupFrame::kLeft);
|
||||
page->AddFrame(this,new TGLayoutHints( kLHintsTop | kLHintsExpandX , 10,10,10,10));
|
||||
MapWindow();
|
||||
|
||||
|
||||
|
||||
TGHorizontalFrame* hframe=new TGHorizontalFrame(this, 800,800);
|
||||
AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
hframe->MapWindow();
|
||||
|
||||
|
||||
|
||||
|
||||
int idac=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TGHorizontalFrame* hhframe=new TGHorizontalFrame(this, 800,800);
|
||||
AddFrame(hhframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
hhframe->MapWindow();
|
||||
|
||||
TGVerticalFrame *vframe;
|
||||
|
||||
|
||||
|
||||
|
||||
for (idac=0; idac<NADCS; idac++) {
|
||||
if (idac%16==0) {
|
||||
|
||||
|
||||
vframe=new TGVerticalFrame(hhframe, 400,800);
|
||||
hhframe->AddFrame(vframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
vframe->MapWindow();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
sAdc[idac]=new ctbAdc(vframe,idac,myDet);
|
||||
|
||||
|
||||
sAdc[idac]->Connect("ToggledAdcPlot(Int_t)","ctbAdcs",this,"ToggledAdcPlot(Int_t)");
|
||||
sAdc[idac]->Connect("ToggledAdcInvert(Int_t)","ctbAdcs",this,"ToggledAdcInvert(Int_t)");
|
||||
sAdc[idac]->Connect("ToggledAdcEnable(Int_t)","ctbAdcs",this,"ToggledAdcEnable(Int_t)");
|
||||
|
||||
}
|
||||
|
||||
hframe=new TGHorizontalFrame(this, 800,800);
|
||||
AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
hframe->MapWindow();
|
||||
|
||||
|
||||
bCheckHalf[0]=new TGTextButton(hframe, "All 0-15");
|
||||
hframe->AddFrame(bCheckHalf[0],new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5));
|
||||
bCheckHalf[0]->MapWindow();
|
||||
bCheckHalf[0]->Connect("Clicked()","ctbAdcs",this,"CheckHalf0()");
|
||||
|
||||
|
||||
bRemoveHalf[0]=new TGTextButton(hframe, "None 0-15");
|
||||
hframe->AddFrame(bRemoveHalf[0],new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 5, 5, 5, 5));
|
||||
bRemoveHalf[0]->MapWindow();
|
||||
bRemoveHalf[0]->Connect("Clicked()","ctbAdcs",this,"RemoveHalf0()");
|
||||
|
||||
|
||||
bCheckHalf[1]=new TGTextButton(hframe, "All 16-23");
|
||||
hframe->AddFrame(bCheckHalf[1],new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5));
|
||||
bCheckHalf[1]->MapWindow();
|
||||
bCheckHalf[1]->Connect("Clicked()","ctbAdcs",this,"CheckHalf1()");
|
||||
// bCheckAll->Connect("Clicked()","ctbAdcs",this,"CheckAll()");
|
||||
|
||||
|
||||
bRemoveHalf[1]=new TGTextButton(hframe, "None 16-23");
|
||||
hframe->AddFrame(bRemoveHalf[1],new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 5, 5, 5, 5));
|
||||
bRemoveHalf[1]->MapWindow();
|
||||
bRemoveHalf[1]->Connect("Clicked()","ctbAdcs",this,"RemoveHalf1()");
|
||||
// bRemoveAll->Connect("Clicked()","ctbAdcs",this,"RemoveAll()");
|
||||
|
||||
|
||||
|
||||
|
||||
hframe=new TGHorizontalFrame(this, 800,800);
|
||||
AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
hframe->MapWindow();
|
||||
|
||||
|
||||
bCheckAll=new TGTextButton(hframe, "All");
|
||||
hframe->AddFrame(bCheckAll,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5));
|
||||
bCheckAll->MapWindow();
|
||||
bCheckAll->Connect("Clicked()","ctbAdcs",this,"CheckAll()");
|
||||
|
||||
|
||||
bRemoveAll=new TGTextButton(hframe, "None");
|
||||
hframe->AddFrame(bRemoveAll,new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 5, 5, 5, 5));
|
||||
bRemoveAll->MapWindow();
|
||||
bRemoveAll->Connect("Clicked()","ctbAdcs",this,"RemoveAll()");
|
||||
|
||||
|
||||
|
||||
hframe=new TGHorizontalFrame(this, 800,50);
|
||||
AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
hframe->MapWindow();
|
||||
|
||||
|
||||
TGLabel *label= new TGLabel(hframe, "Inversion mask: ");
|
||||
hframe->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
|
||||
label->MapWindow();
|
||||
label->SetTextJustify(kTextLeft);
|
||||
|
||||
|
||||
eInversionMask = new TGNumberEntry(hframe, 0, 16,999, TGNumberFormat::kNESHex,
|
||||
TGNumberFormat::kNEANonNegative,
|
||||
TGNumberFormat::kNELNoLimits);
|
||||
|
||||
hframe->AddFrame(eInversionMask,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
|
||||
eInversionMask->MapWindow();
|
||||
eInversionMask->Resize(150,30);
|
||||
eInversionMask->SetState(kFALSE);
|
||||
|
||||
|
||||
hframe=new TGHorizontalFrame(this, 800,50);
|
||||
AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
hframe->MapWindow();
|
||||
|
||||
|
||||
label= new TGLabel(hframe, "Enable mask: ");
|
||||
hframe->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
|
||||
label->MapWindow();
|
||||
label->SetTextJustify(kTextLeft);
|
||||
|
||||
|
||||
eEnableMask = new TGNumberEntry(hframe, 0, 16,999, TGNumberFormat::kNESHex,
|
||||
TGNumberFormat::kNEANonNegative,
|
||||
TGNumberFormat::kNELNoLimits);
|
||||
|
||||
hframe->AddFrame(eEnableMask,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
|
||||
eEnableMask->MapWindow();
|
||||
eEnableMask->Resize(150,30);
|
||||
eEnableMask->SetState(kFALSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int ctbAdcs::setEnable(int reg) {
|
||||
|
||||
try {
|
||||
if (reg > -1) {
|
||||
myDet->setADCEnableMask(reg);
|
||||
}
|
||||
auto retval = myDet->getADCEnableMask().tsquash("Different values");
|
||||
eEnableMask->SetHexNumber(retval);
|
||||
return retval;
|
||||
} CATCH_DISPLAY ("Could not set/get adc enablemask.", "ctbAdcs::setEnable")
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ctbAdcs::setInvert(int reg) {
|
||||
|
||||
try {
|
||||
if (reg > -1) {
|
||||
myDet->setADCInvert(reg);
|
||||
}
|
||||
auto retval = myDet->getADCInvert().tsquash("Different values");
|
||||
eInversionMask->SetHexNumber(retval);
|
||||
return retval;
|
||||
} CATCH_DISPLAY ("Could not set/get adc enablemask.", "ctbAdcs::setEnable")
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctbAdcs::update() {
|
||||
Int_t invreg;
|
||||
Int_t disreg;
|
||||
|
||||
disreg=setEnable();
|
||||
invreg=setInvert();
|
||||
|
||||
for (int is=0; is<NADCS; is++) {
|
||||
sAdc[is]->setAdcAlias(NULL,-1,-1);
|
||||
if (invreg & (1<<is) )
|
||||
sAdc[is]->setInverted(kTRUE);
|
||||
else
|
||||
sAdc[is]->setInverted(kFALSE);
|
||||
|
||||
if (disreg & (1<<is) )
|
||||
sAdc[is]->setEnable(kTRUE);
|
||||
else
|
||||
sAdc[is]->setEnable(kFALSE);
|
||||
}
|
||||
|
||||
Emit("AdcEnable(Int_t)", disreg);
|
||||
|
||||
}
|
||||
string ctbAdcs::getAdcParameters() {
|
||||
ostringstream line;
|
||||
line << "reg "<< hex << setInvert() << "# ADC invert reg" << dec << endl;
|
||||
line << "reg "<< hex << setEnable() << " # ADC enable reg"<< dec << endl;
|
||||
return line.str();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ctbAdcs::CheckAll() {
|
||||
for (int is=0; is<NADCS; is++){
|
||||
sAdc[is]->setPlot(kTRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ctbAdcs::RemoveAll() {
|
||||
for (int is=0; is<NADCS; is++) {
|
||||
sAdc[is]->setPlot(kFALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctbAdcs::CheckHalf0() {
|
||||
for (int is=0; is<NADCS/2; is++) {
|
||||
sAdc[is]->setPlot(kTRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ctbAdcs::RemoveHalf0() {
|
||||
for (int is=0; is<NADCS/2; is++){
|
||||
sAdc[is]->setPlot(kFALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void ctbAdcs::CheckHalf1() {
|
||||
for (int is=NADCS/2; is<NADCS; is++){
|
||||
sAdc[is]->setPlot(kTRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ctbAdcs::RemoveHalf1() {
|
||||
for (int is=NADCS/2; is<NADCS; is++){
|
||||
sAdc[is]->setPlot(kFALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ctbAdcs::setAdcAlias(string line) {
|
||||
|
||||
int is=-1, plot=0, color=-1;
|
||||
char tit[100];
|
||||
int narg=sscanf(line.c_str(),"ADC%d %s %d %x",&is,tit,&plot, &color);
|
||||
if (narg<2)
|
||||
return -1;
|
||||
if (narg!=3)
|
||||
color=-1;
|
||||
if (is>=0 && is<NADCS) {
|
||||
sAdc[is]->setAdcAlias(tit,plot,color);
|
||||
}
|
||||
return is;
|
||||
|
||||
}
|
||||
|
||||
string ctbAdcs::getAdcAlias() {
|
||||
|
||||
ostringstream line;
|
||||
|
||||
for (int is=0; is<NADCS; is++)
|
||||
line << sAdc[is]->getAdcAlias();
|
||||
|
||||
return line.str();
|
||||
}
|
||||
|
||||
|
||||
void ctbAdcs::ToggledAdcPlot(Int_t b){
|
||||
|
||||
|
||||
Emit("ToggledAdcPlot(Int_t)", b);
|
||||
|
||||
}
|
||||
|
||||
void ctbAdcs::AdcEnable(Int_t b){
|
||||
Emit("AdcEnable(Int_t)", b);
|
||||
}
|
||||
|
||||
|
||||
void ctbAdcs::ToggledAdcEnable(Int_t b){
|
||||
|
||||
Int_t oreg=setEnable();
|
||||
Int_t m=1<<b;
|
||||
|
||||
if (sAdc[b]->getEnable())
|
||||
oreg|=m;
|
||||
else
|
||||
oreg&=~m;
|
||||
|
||||
setEnable(oreg);
|
||||
|
||||
Emit("AdcEnable(Int_t)", oreg);
|
||||
}
|
||||
|
||||
|
||||
void ctbAdcs::ToggledAdcInvert(Int_t b){
|
||||
|
||||
Int_t oreg=setInvert();
|
||||
Int_t m=1<<b;
|
||||
|
||||
|
||||
if (sAdc[b]->getInverted())
|
||||
oreg|=m;
|
||||
else
|
||||
oreg&=~m;
|
||||
|
||||
setInvert(oreg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Pixel_t ctbAdcs::getColor(int i){
|
||||
if (i>=0 && i<NADCS)
|
||||
return sAdc[i]->getColor();
|
||||
return static_cast<Pixel_t>(-1);
|
||||
}
|
||||
|
||||
Bool_t ctbAdcs::getEnabled(int i){
|
||||
if (i>=0 && i<NADCS)
|
||||
return sAdc[i]->getEnabled();
|
||||
return static_cast<Bool_t>(-1);
|
||||
}
|
||||
|
||||
Bool_t ctbAdcs::getEnable(int i){
|
||||
if (i>=0 && i<NADCS)
|
||||
return sAdc[i]->getEnable();
|
||||
return static_cast<Bool_t>(-1);
|
||||
}
|
||||
|
||||
Bool_t ctbAdcs::getPlot(int i){
|
||||
if (i>=0 && i<NADCS)
|
||||
return sAdc[i]->getPlot();
|
||||
return static_cast<Bool_t>(-1);
|
||||
}
|
157
ctbGui/ctbAdcs.h
157
ctbGui/ctbAdcs.h
@ -1,157 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
|
||||
|
||||
#ifndef CTBADCS_H
|
||||
#define CTBADCS_H
|
||||
#include <TGFrame.h>
|
||||
|
||||
|
||||
#define NADCS 32
|
||||
|
||||
class TRootEmbeddedCanvas;
|
||||
class TGButtonGroup;
|
||||
class TGVerticalFrame;
|
||||
class TGHorizontalFrame;
|
||||
class TGTextEntry;
|
||||
class TGLabel;
|
||||
class TGNumberEntry;
|
||||
class TH2F;
|
||||
class TGComboBox;
|
||||
class TGCheckButton;
|
||||
class TGColorSelect;
|
||||
class TColor;
|
||||
|
||||
class THStack;
|
||||
class TGraphErrors;
|
||||
class TGTextButton;
|
||||
class TGTab;
|
||||
|
||||
class TGraph;
|
||||
|
||||
namespace sls
|
||||
{
|
||||
class Detector;
|
||||
};
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
class ctbAdc : public TGHorizontalFrame {
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
TGLabel *sAdcLabel;
|
||||
TGCheckButton *sAdcEnable;
|
||||
TGCheckButton *sAdcPlot;
|
||||
TGCheckButton *sAdcInvert;
|
||||
|
||||
TGColorSelect *fColorSel;
|
||||
|
||||
// TGraph *gADC;
|
||||
|
||||
int id;
|
||||
sls::Detector *myDet;
|
||||
|
||||
public:
|
||||
ctbAdc(TGVerticalFrame *page, int i, sls::Detector *det);
|
||||
|
||||
|
||||
void setAdcAlias(char *tit, int plot, int color);
|
||||
string getAdcAlias();
|
||||
void ToggledAdcPlot(Int_t b);
|
||||
void ToggledAdcEnable(Int_t b);
|
||||
void ToggledAdcInvert(Int_t b);
|
||||
|
||||
|
||||
void ToggledPlot(Bool_t b);
|
||||
void ToggledEnable(Bool_t b);
|
||||
void ToggledInvert(Bool_t b);
|
||||
void ColorChanged(Pixel_t);
|
||||
void setEnabled(Bool_t b);
|
||||
Bool_t getEnabled();
|
||||
// TGraph *getGraph();
|
||||
void update();
|
||||
|
||||
Pixel_t getColor();
|
||||
|
||||
Bool_t getEnable();
|
||||
void setEnable(Bool_t);
|
||||
void setPlot(Bool_t);
|
||||
Bool_t getInverted();
|
||||
Bool_t getPlot();
|
||||
void setInverted(Bool_t);
|
||||
|
||||
ClassDef(ctbAdc,0)
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ctbAdcs : public TGGroupFrame {
|
||||
private:
|
||||
|
||||
ctbAdc *sAdc[NADCS];
|
||||
sls::Detector *myDet;
|
||||
|
||||
|
||||
TGTextButton *bCheckAll;
|
||||
TGTextButton *bRemoveAll;
|
||||
TGTextButton *bCheckHalf[2];
|
||||
TGTextButton *bRemoveHalf[2];
|
||||
TGNumberEntry *eInversionMask;
|
||||
TGNumberEntry *eEnableMask;
|
||||
|
||||
|
||||
/* TGTextButton *bPlotSelected; */
|
||||
/* TGNumberEntry *eMinX; */
|
||||
/* TGNumberEntry *eMaxX; */
|
||||
/* TGNumberEntry *eMinY; */
|
||||
/* TGNumberEntry *eMaxY; */
|
||||
|
||||
|
||||
|
||||
/* TGTextButton *bGetPixel; */
|
||||
/* TGNumberEntry *ePixelX; */
|
||||
/* TGNumberEntry *ePixelY; */
|
||||
/* TGLabel *lPixelValue; */
|
||||
|
||||
public:
|
||||
|
||||
ctbAdcs(TGVerticalFrame *page, sls::Detector *det);
|
||||
int setAdcAlias(string line);
|
||||
string getAdcAlias();
|
||||
string getAdcParameters();
|
||||
void ToggledAdcPlot(Int_t);
|
||||
void ToggledAdcInvert(Int_t);
|
||||
void ToggledAdcEnable(Int_t);
|
||||
void AdcEnable(Int_t b);
|
||||
// TGraph *getGraph(int i);
|
||||
void CheckAll();
|
||||
void RemoveAll();
|
||||
void update();
|
||||
|
||||
int setInvert(int reg=-1);
|
||||
int setEnable(int reg=-1);
|
||||
|
||||
|
||||
Pixel_t getColor(int i);
|
||||
Bool_t getEnabled(int i);
|
||||
Bool_t getPlot(int i);
|
||||
Bool_t getEnable(int i);
|
||||
|
||||
void CheckHalf0();
|
||||
void RemoveHalf0();
|
||||
|
||||
void CheckHalf1();
|
||||
void RemoveHalf1();
|
||||
|
||||
|
||||
ClassDef(ctbAdcs,0)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,235 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <TGTextEntry.h>
|
||||
#include <TGLabel.h>
|
||||
#include <TGNumberEntry.h>
|
||||
#include <TGButton.h>
|
||||
|
||||
#include "ctbDacs.h"
|
||||
#include "ctbDefs.h"
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
ctbDac::ctbDac(TGGroupFrame *page, int idac, sls::Detector *det) : TGHorizontalFrame(page, 800,50) , id(idac), myDet(det) {
|
||||
|
||||
TGHorizontalFrame *hframe=this;
|
||||
|
||||
page->AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
MapWindow();
|
||||
|
||||
char tit[100];
|
||||
|
||||
|
||||
sprintf(tit, "DAC %d:",idac);
|
||||
|
||||
dacsLabel= new TGCheckButton(hframe, tit);// new TGLabel(hframe, tit);
|
||||
dacsLabel->SetOn(kTRUE, kTRUE);
|
||||
|
||||
dacsLabel->Connect("Toggled(Bool_t)","ctbDac",this,"setOn(Bool_t)");
|
||||
|
||||
|
||||
hframe->AddFrame(dacsLabel,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 5, 5, 5, 5));
|
||||
dacsLabel->MapWindow();
|
||||
dacsLabel->SetTextJustify(kTextLeft);
|
||||
|
||||
|
||||
dacsEntry = new TGNumberEntry(hframe, 0, 9,999, TGNumberFormat::kNESInteger,
|
||||
TGNumberFormat::kNEANonNegative,
|
||||
TGNumberFormat::kNELLimitMinMax,
|
||||
0, 65535);
|
||||
|
||||
hframe->AddFrame(dacsEntry,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5));
|
||||
dacsEntry->MapWindow();
|
||||
dacsEntry->Resize(150,30);
|
||||
|
||||
|
||||
dacsUnit= new TGCheckButton(hframe, "mV");
|
||||
// if (idac!=slsDetectorDefs::ADC_VPP) {
|
||||
hframe->AddFrame( dacsUnit,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 5, 5, 5, 5));
|
||||
dacsUnit->MapWindow();
|
||||
if (idac==slsDetectorDefs::ADC_VPP) {
|
||||
dacsUnit->SetEnabled(kFALSE);
|
||||
hframe->HideFrame(dacsUnit);
|
||||
dacsUnit->MapWindow();
|
||||
cout << "hiding!" << endl;
|
||||
}
|
||||
if (idac==slsDetectorDefs::HIGH_VOLTAGE) {
|
||||
dacsUnit->SetText("V");
|
||||
dacsUnit->SetOn(kTRUE,kTRUE);
|
||||
dacsUnit->SetEnabled(kFALSE);
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
|
||||
sprintf(tit, "xxx");
|
||||
dacsValue= new TGLabel(hframe, tit);
|
||||
hframe->AddFrame( dacsValue,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 5, 5, 5, 5));
|
||||
dacsValue->MapWindow();
|
||||
dacsValue->SetTextJustify(kTextLeft);
|
||||
|
||||
TGTextEntry *e=dacsEntry->TGNumberEntry::GetNumberEntry();
|
||||
e->Connect("ReturnPressed()","ctbDac",this,"setValue()");
|
||||
// e->Connect("ValueSet(Long_t)","ctbDac",this,"setValue(Long_t)");
|
||||
dacsEntry->Connect("ValueSet(Long_t)","ctbDac",this,"setValue(Long_t)");
|
||||
// cout << "(((((((((((((((((((((((((((((((" << dacsEntry->GetListOfSignals()->At(0)->IsA() << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ctbDac::setLabel(char *tit, int mv) {
|
||||
if(tit)
|
||||
dacsLabel->SetText(tit);
|
||||
if (mv==1)
|
||||
dacsUnit->SetOn(kTRUE,kTRUE);
|
||||
else if (mv==0)
|
||||
dacsUnit->SetOn(kFALSE,kTRUE);
|
||||
// else if (mv==2) {
|
||||
// ;}
|
||||
// else if (mv==3)
|
||||
// ;
|
||||
return id;
|
||||
|
||||
}
|
||||
|
||||
string ctbDac::getLabel() {
|
||||
ostringstream line;
|
||||
line << dacsLabel->GetText() << " " << dacsUnit->IsOn() << endl;
|
||||
// line << "DAC" << dec << id << " " << dacsUnit->IsOn() << endl;
|
||||
return line.str();
|
||||
|
||||
}
|
||||
|
||||
int ctbDac::getMoenchDacId() {
|
||||
slsDetectorDefs::dacIndex moenchDacIndices[8] = {slsDetectorDefs::VBP_COLBUF, slsDetectorDefs::VIPRE, slsDetectorDefs::VIN_CM, slsDetectorDefs::VB_SDA, slsDetectorDefs::VCASC_SFP, slsDetectorDefs::VOUT_CM, slsDetectorDefs::VIPRE_CDS, slsDetectorDefs::IBIAS_SFP};
|
||||
|
||||
if (id >= 8) {
|
||||
return id;
|
||||
}
|
||||
return static_cast<int>(moenchDacIndices[id]);
|
||||
}
|
||||
|
||||
void ctbDac::setValue(Long_t a) {setValue();}
|
||||
|
||||
void ctbDac::setValue() {
|
||||
cout << "setting dac! "<< id << " value " << dacsEntry->GetIntNumber() << " units " << dacsUnit->IsOn() << endl;
|
||||
|
||||
try {
|
||||
int sid = id;
|
||||
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
|
||||
sid = getMoenchDacId();
|
||||
}
|
||||
myDet->setDAC(static_cast<slsDetectorDefs::dacIndex>(sid), dacsEntry->GetIntNumber(), dacsUnit->IsOn());
|
||||
} CATCH_DISPLAY ("Could not set dac " + to_string(id) + ".", "ctbDac::setValue")
|
||||
|
||||
getValue();
|
||||
}
|
||||
|
||||
void ctbDac::setOn(Bool_t b) {
|
||||
// cout << "setting dac! "<< id << endl;
|
||||
if ( dacsLabel->IsOn()) {
|
||||
setValue();
|
||||
} else {
|
||||
try {
|
||||
int sid = id;
|
||||
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
|
||||
sid = getMoenchDacId();
|
||||
}
|
||||
myDet->setDAC(static_cast<slsDetectorDefs::dacIndex>(sid), -100, false);
|
||||
} CATCH_DISPLAY ("Could not power off dac " + to_string(id) + ".", "ctbDac::setOn")
|
||||
}
|
||||
getValue();
|
||||
}
|
||||
|
||||
int ctbDac::getValue() {
|
||||
try {
|
||||
int sid = id;
|
||||
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
|
||||
sid = getMoenchDacId();
|
||||
}
|
||||
int val = myDet->getDAC(static_cast<slsDetectorDefs::dacIndex>(sid), dacsUnit->IsOn()).tsquash("Different values");
|
||||
cout << "dac " << id << " " << val << endl;
|
||||
dacsValue->SetText(to_string(val).c_str());
|
||||
if (val >= 0) {
|
||||
dacsLabel->SetOn(kTRUE);
|
||||
} else {
|
||||
dacsLabel->SetOn(kFALSE);
|
||||
}
|
||||
return val;
|
||||
} CATCH_DISPLAY ("Could not get dac " + to_string(id) + ".", "ctbDac::getValue")
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ctbDacs::ctbDacs(TGVerticalFrame *page, sls::Detector *det) : TGGroupFrame(page,"DACs",kVerticalFrame) , myDet(det){
|
||||
|
||||
SetTitlePos(TGGroupFrame::kLeft);
|
||||
page->AddFrame(this,new TGLayoutHints( kLHintsTop | kLHintsExpandX , 10,10,10,10));
|
||||
MapWindow();
|
||||
|
||||
// cout << "window mapped " << endl;
|
||||
|
||||
for (int idac=0; idac<NDACS; idac++) {
|
||||
|
||||
dacs[idac]=new ctbDac(this, idac, myDet);
|
||||
|
||||
}
|
||||
dacs[NDACS]=new ctbDac(this, slsDetectorDefs::ADC_VPP, myDet);
|
||||
dacs[NDACS+1]=new ctbDac(this, slsDetectorDefs::HIGH_VOLTAGE, myDet);
|
||||
dacs[NDACS]->setLabel((char*)"ADC Vpp",2);
|
||||
dacs[NDACS+1]->setLabel((char*)"High Voltage",3);
|
||||
}
|
||||
|
||||
|
||||
int ctbDacs::setDacAlias(string line) {
|
||||
int is=-1, mv=0;
|
||||
char tit[100];
|
||||
int narg=sscanf(line.c_str(),"DAC%d %s %d",&is,tit,&mv);
|
||||
if (narg<2)
|
||||
return -1;
|
||||
if (is>=0 && is<NDACS)
|
||||
dacs[is]->setLabel(tit,mv);
|
||||
return is;
|
||||
|
||||
}
|
||||
|
||||
string ctbDacs::getDacAlias() {
|
||||
ostringstream line;
|
||||
|
||||
for (int i=0; i<NDACS; i++)
|
||||
line << dacs[i]->getLabel() << endl;
|
||||
return line.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
string ctbDacs::getDacParameters() {
|
||||
ostringstream line;
|
||||
|
||||
for (int i=0; i<NDACS; i++) {
|
||||
//line << "dacs:" << i << " " << dacs[i]->getValue << endl;
|
||||
line << "dac:" << i << " " << dacs[i]->getValue() << endl;
|
||||
}
|
||||
return line.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctbDacs::update() {
|
||||
for (int idac=0; idac<NDACS+1; idac++) {
|
||||
dacs[idac]->getValue();
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
|
||||
#ifndef CTBDACS_H
|
||||
#define CTBDACS_H
|
||||
#include <TGFrame.h>
|
||||
|
||||
|
||||
#define NDACS 18
|
||||
//#define NDACS 16
|
||||
|
||||
|
||||
class TGTextEntry;
|
||||
class TGLabel;
|
||||
class TGNumberEntry;
|
||||
class TGCheckButton;
|
||||
|
||||
|
||||
namespace sls
|
||||
{
|
||||
class Detector;
|
||||
};
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
|
||||
class ctbDac : public TGHorizontalFrame {
|
||||
|
||||
|
||||
protected:
|
||||
// TGLabel *dacsLabel;
|
||||
TGNumberEntry *dacsEntry;
|
||||
TGCheckButton *dacsUnit;
|
||||
TGCheckButton *dacsLabel;
|
||||
TGLabel *dacsValue;
|
||||
int id;
|
||||
|
||||
sls::Detector* myDet;
|
||||
public:
|
||||
ctbDac(TGGroupFrame*, int , sls::Detector*);
|
||||
void setValue();
|
||||
void setValue(Long_t);
|
||||
int getValue();
|
||||
void setOn(Bool_t);
|
||||
|
||||
int setLabel(char *tit, int mv);
|
||||
string getLabel();
|
||||
int getMoenchDacId();
|
||||
|
||||
|
||||
ClassDef(ctbDac,0)
|
||||
};
|
||||
|
||||
class ctbDacs : public TGGroupFrame {
|
||||
private:
|
||||
|
||||
ctbDac *dacs[NDACS+2];
|
||||
|
||||
sls::Detector* myDet;
|
||||
|
||||
public:
|
||||
ctbDacs(TGVerticalFrame *page, sls::Detector*);
|
||||
|
||||
int setDacAlias(string line);
|
||||
// int setDacAlias(string line);
|
||||
string getDacAlias();
|
||||
string getDacParameters();
|
||||
|
||||
void update();
|
||||
|
||||
ClassDef(ctbDacs,0)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,86 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <chrono>
|
||||
|
||||
//#include "sls/sls_detector_exceptions.h"
|
||||
//#include "sls/ansi.h"
|
||||
#define RED "\x1b[31m"
|
||||
#define RESET "\x1b[0m"
|
||||
#define BOLD "\x1b[1m"
|
||||
#define cprintf(code, format, ...) printf(code format RESET, ##__VA_ARGS__)
|
||||
|
||||
|
||||
#define CATCH_DISPLAY(m, s) catch(...) { ctbDefs::DisplayExceptions(m, s); }
|
||||
#define CATCH_HANDLE(...) catch(...) { ctbDefs::HandleExceptions(__VA_ARGS__); }
|
||||
|
||||
class ctbDefs {
|
||||
public:
|
||||
/**
|
||||
* Empty Constructor
|
||||
*/
|
||||
ctbDefs(){};
|
||||
|
||||
// convert double seconds to chrono ns
|
||||
static std::chrono::nanoseconds ConvertDoubleStoChronoNS(double timeS) {
|
||||
using std::chrono::duration;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::nanoseconds;
|
||||
return duration_cast<nanoseconds>(duration<double>(timeS));
|
||||
}
|
||||
|
||||
// convert chrono ns to doubel s
|
||||
static double ConvertChronoNStoDoubleS(std::chrono::nanoseconds timeNs) {
|
||||
using std::chrono::duration;
|
||||
using std::chrono::duration_cast;
|
||||
return duration_cast<duration<double>>(timeNs).count();
|
||||
}
|
||||
|
||||
static void DisplayExceptions(std::string emsg, std::string src) {
|
||||
try {
|
||||
throw;
|
||||
} /* catch (const sls::SocketError &e) {
|
||||
throw;
|
||||
} catch (const sls::SharedMemoryError &e) {
|
||||
throw;
|
||||
} */catch (const std::exception &e) {
|
||||
ExceptionMessage(emsg, e.what(), src);
|
||||
}
|
||||
};
|
||||
|
||||
template <class CT> struct NonDeduced { using type = CT; };
|
||||
template <class S, typename RT, typename... CT>
|
||||
static void HandleExceptions(const std::string emsg, const std::string src, S* s,
|
||||
RT (S::*somefunc)(CT...),
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
try {
|
||||
throw;
|
||||
} /*catch (const sls::SocketError &e) {
|
||||
throw;
|
||||
} catch (const sls::SharedMemoryError &e) {
|
||||
throw;
|
||||
} */catch (const std::exception &e) {
|
||||
|
||||
ExceptionMessage(emsg, e.what(), src);
|
||||
(s->*somefunc)(Args...);
|
||||
}
|
||||
};
|
||||
|
||||
static void ExceptionMessage(std::string message,
|
||||
std::string exceptionMessage,
|
||||
std::string source) {
|
||||
// because sls_detector_exceptions cannot be included
|
||||
if (exceptionMessage.find("hared memory") != std::string::npos) {
|
||||
throw;
|
||||
}
|
||||
if (exceptionMessage.find("annot connect") != std::string::npos) {
|
||||
throw;
|
||||
}
|
||||
cprintf(RED, "Warning (%s): %s [Caught Exception: %s]\n", source.c_str(), message.c_str(), exceptionMessage.c_str());
|
||||
//return Message(qDefs::WARNING, message + std::string("\nCaught exception:\n") + exceptionMessage, source);
|
||||
};
|
||||
|
||||
};
|
@ -1,159 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include <TApplication.h>
|
||||
#include <TColor.h>
|
||||
|
||||
#include <TStyle.h>
|
||||
#include <TROOT.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
//#include "sls_receiver_defs.h"
|
||||
#include "ctbMain.h"
|
||||
#include "ctbDefs.h"
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
||||
string afname, cfname, pfname;
|
||||
int id=0;
|
||||
|
||||
int af=0, cf=0, pf=0;
|
||||
|
||||
|
||||
cout << " *** " << argc << endl;
|
||||
for (int ia=0; ia<argc; ia++) {
|
||||
if (strcmp(argv[ia],"-alias")==0) {
|
||||
if (ia+1<argc) {
|
||||
afname=argv[ia+1];
|
||||
ia++;
|
||||
af=1;
|
||||
}
|
||||
|
||||
} else if (strcmp(argv[ia],"-config")==0) {
|
||||
if (ia+1<argc) {
|
||||
cfname=argv[ia+1];
|
||||
ia++;
|
||||
cf=1;
|
||||
}
|
||||
|
||||
|
||||
} else if (strcmp(argv[ia],"-par")==0) {
|
||||
if (ia+1<argc) {
|
||||
pfname=argv[ia+1];
|
||||
ia++;
|
||||
pf=1;
|
||||
}
|
||||
|
||||
|
||||
} else if (strcmp(argv[ia],"-id")==0) {
|
||||
if (ia+1<argc) {
|
||||
id=atoi(argv[ia+1]);
|
||||
ia++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cout << " *** " << endl;
|
||||
sls::Detector *myDet = nullptr;
|
||||
try {
|
||||
/****** Create detector ****************/
|
||||
myDet=new sls::Detector(id);
|
||||
cout << "Created multi detector id " << id << endl;
|
||||
|
||||
if (cf) {
|
||||
myDet->loadConfig(cfname);
|
||||
cout << "Config file loaded successfully" << endl;
|
||||
} else {
|
||||
cout << "No config file specified" << endl;
|
||||
}
|
||||
cout << "hostname " << myDet->getHostname() << endl;
|
||||
|
||||
if (pf) {
|
||||
myDet->loadParameters(pfname);
|
||||
cout << "Loaded parameter file successfully" << endl;
|
||||
} else{
|
||||
cout << "No parameter file specified" << endl;
|
||||
}
|
||||
} CATCH_DISPLAY ("Could not create detector/ load config/parameters.", "ctbGui::main")
|
||||
|
||||
/***********Create GUI stuff *******************/
|
||||
TApplication theApp("App",&argc,argv);
|
||||
|
||||
|
||||
gStyle->SetDrawBorder(0);
|
||||
gStyle->SetCanvasColor(kWhite);
|
||||
gStyle->SetCanvasDefH(800);
|
||||
gStyle->SetCanvasDefW(800);
|
||||
gStyle->SetCanvasBorderMode(0);
|
||||
gStyle->SetPadBorderMode(0);
|
||||
gStyle->SetPaintTextFormat("5.2f");
|
||||
gStyle->SetLineWidth(2);
|
||||
gStyle->SetTextSize(1.1);
|
||||
gStyle->SetLabelSize(0.04,"xy");
|
||||
gStyle->SetTitleSize(0.05,"xy");
|
||||
gStyle->SetTitleOffset(1.0,"x");
|
||||
gStyle->SetTitleOffset(1.1,"y");
|
||||
gStyle->SetPadTopMargin(0.15);
|
||||
gStyle->SetPadRightMargin(0.15);
|
||||
gStyle->SetPadBottomMargin(0.15);
|
||||
gStyle->SetPadLeftMargin(0.15);
|
||||
gStyle->SetLegendBorderSize(1);
|
||||
gStyle->SetFrameBorderMode(0);
|
||||
gStyle->SetFrameFillColor(kWhite);
|
||||
// gStyle->SetLegendFillColor(kWhite);
|
||||
gStyle->SetTitleFillColor(kWhite);
|
||||
gStyle->SetFillColor(kWhite);
|
||||
gStyle->SetStatFontSize(0.03);
|
||||
gStyle->SetStatBorderSize(1);
|
||||
gStyle->SetStatFormat("6.4g");
|
||||
gStyle->SetStatX(0.95);
|
||||
gStyle->SetStatY(0.95);
|
||||
gStyle->SetStatW(0.2);
|
||||
gStyle->SetStatH(0.2);
|
||||
gStyle->SetTitleX(0.1);
|
||||
gStyle->SetTitleY(0.95);
|
||||
gStyle->SetTitleBorderSize(0);
|
||||
gStyle->SetTitleFontSize(0.05);
|
||||
gROOT->SetStyle("Default");
|
||||
|
||||
|
||||
TColor::InitializeColors();
|
||||
const Int_t NRGBs = 5;
|
||||
const Int_t NCont = 90;
|
||||
|
||||
Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
|
||||
Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
|
||||
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
|
||||
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
|
||||
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
|
||||
gStyle->SetNumberContours(NCont);
|
||||
|
||||
|
||||
gROOT->ForceStyle();
|
||||
ctbMain *mf=new ctbMain(gClient->GetRoot(), myDet);
|
||||
|
||||
cout << " *** " << argc << endl;
|
||||
for (int ia=0; ia<argc; ia++)
|
||||
cout << argv[ia] << endl;
|
||||
|
||||
|
||||
cout << " *** " << endl;
|
||||
|
||||
if (af)
|
||||
mf->loadAlias(afname);
|
||||
else
|
||||
cout << "no alias specified" << endl;
|
||||
|
||||
theApp.Run();
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma link C++ class ctbMain;
|
||||
#pragma link C++ class ctbDacs;
|
||||
#pragma link C++ class ctbDac;
|
||||
#pragma link C++ class ctbSignals;
|
||||
#pragma link C++ class ctbSignal;
|
||||
#pragma link C++ class ctbAdc;
|
||||
#pragma link C++ class ctbAdcs;
|
||||
#pragma link C++ class ctbLoop;
|
||||
#pragma link C++ class ctbWait;
|
||||
#pragma link C++ class ctbPattern;
|
||||
#pragma link C++ class ctbAcquisition;
|
||||
#pragma link C++ class ctbPower;
|
||||
#pragma link C++ class ctbPowers;
|
||||
#pragma link C++ class ctbSlowAdc;
|
||||
#pragma link C++ class ctbSlowAdcs;
|
@ -1,588 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include <TApplication.h>
|
||||
#include <TGClient.h>
|
||||
#include <TCanvas.h>
|
||||
#include <TF1.h>
|
||||
#include <TRandom.h>
|
||||
#include <TGButton.h>
|
||||
#include <TRootEmbeddedCanvas.h>
|
||||
#include <TGButtonGroup.h>
|
||||
#include <TGNumberEntry.h>
|
||||
#include <TGLabel.h>
|
||||
#include <TList.h>
|
||||
#include <TGFileDialog.h>
|
||||
#include <TGComboBox.h>
|
||||
#include <TH2F.h>
|
||||
#include <TColor.h>
|
||||
#include <TH1F.h>
|
||||
#include <TGraphErrors.h>
|
||||
#include <THStack.h>
|
||||
#include <TGTab.h>
|
||||
#include <TApplication.h>
|
||||
#include <TGCanvas.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <TGMenu.h>
|
||||
#include <TGDockableFrame.h>
|
||||
//#include <TGMenuBar.h>
|
||||
//#include <TGPopupMenu.h>
|
||||
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include "sls/Detector.h"
|
||||
#include "ctbDefs.h"
|
||||
#include "ctbMain.h"
|
||||
#include "ctbDacs.h"
|
||||
#include "ctbSlowAdcs.h"
|
||||
#include "ctbPowers.h"
|
||||
#include "ctbSignals.h"
|
||||
#include "ctbPattern.h"
|
||||
#include "ctbAdcs.h"
|
||||
#include "ctbAcquisition.h"
|
||||
//#include "ctbActions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
ctbMain::ctbMain(const TGWindow *p, sls::Detector *det)
|
||||
: TGMainFrame(p,800,800), pwrs(NULL), senses(NULL) {
|
||||
|
||||
myDet=det;
|
||||
|
||||
Connect("CloseWindow()", "ctbMain", this, "CloseWindow()");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// fMenuDock = new TGDockableFrame(this);
|
||||
// AddFrame(fMenuDock, new TGLayoutHints(kLHintsExpandX, 0, 0, 1, 0));
|
||||
// fMenuDock->SetWindowName("GuiTest Menu");
|
||||
|
||||
fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX);
|
||||
fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
|
||||
fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
|
||||
|
||||
fMenuFile = new TGPopupMenu(gClient->GetRoot());
|
||||
int im=0;
|
||||
|
||||
fMenuFile->AddEntry("Open Alias", im++);
|
||||
fMenuFile->AddEntry("Save Alias", im++);
|
||||
fMenuFile->AddSeparator();
|
||||
fMenuFile->AddEntry("Open Parameters", im++);
|
||||
fMenuFile->AddEntry("Save Parameters", im++);
|
||||
fMenuFile->AddSeparator();
|
||||
fMenuFile->AddEntry("Open Configuration", im++);
|
||||
fMenuFile->AddEntry("Save Configuration", im++);
|
||||
fMenuFile->AddSeparator();
|
||||
fMenuFile->AddEntry("Open Pattern", im++);
|
||||
fMenuFile->AddEntry("Save Pattern", im++);
|
||||
fMenuFile->AddSeparator();
|
||||
fMenuFile->AddEntry("Exit", im++);
|
||||
|
||||
fMenuFile->Connect("Activated(Int_t)", "ctbMain", this,
|
||||
"HandleMenu(Int_t)");
|
||||
|
||||
|
||||
i_dacs=-1;
|
||||
i_pwrs=-1;
|
||||
i_senses=-1;
|
||||
i_sig=-1;
|
||||
i_adcs=-1;
|
||||
i_pat=-1;
|
||||
i_acq=-1;
|
||||
|
||||
int i_page=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TGVerticalFrame *vframe=new TGVerticalFrame(this, 800,1200); //main frame
|
||||
|
||||
|
||||
|
||||
fMenuBar = new TGMenuBar(vframe, 1, 1, kHorizontalFrame);
|
||||
fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout);
|
||||
// fMenuBar->AddPopup("&Test", fMenuTest, fMenuBarItemLayout);
|
||||
// fMenuBar->AddPopup("&View", fMenuView, fMenuBarItemLayout);
|
||||
// fMenuBar->AddPopup("&Help", fMenuHelp, fMenuBarHelpLayout);
|
||||
|
||||
vframe->AddFrame(fMenuBar, fMenuBarLayout);
|
||||
|
||||
TGHorizontalFrame* hpage=new TGHorizontalFrame(vframe, 800,1200); //horizontal frame. Inside there should be the tab and the canvas
|
||||
mtab=new TGTab(hpage, 1500, 1200); //tab!
|
||||
// page=new TGVerticalFrame(mtab, 1500,1200);
|
||||
|
||||
cout << "DACS" << endl;
|
||||
|
||||
TGCompositeFrame *tf = mtab->AddTab("DACs");
|
||||
TGVerticalFrame *page=new TGVerticalFrame(tf, 1500,1200);
|
||||
tf->AddFrame(page, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
|
||||
dacs=new ctbDacs(page, myDet);
|
||||
i_dacs=i_page++;
|
||||
|
||||
|
||||
cout << "power " << endl;
|
||||
tf = mtab->AddTab("Power Supplies");
|
||||
page=new TGVerticalFrame(tf, 1500,1200);
|
||||
tf->AddFrame(page, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
|
||||
pwrs=new ctbPowers(page, myDet);
|
||||
|
||||
i_pwrs=i_page++;
|
||||
|
||||
cout << "sense " << endl;
|
||||
tf = mtab->AddTab("Sense");
|
||||
page=new TGVerticalFrame(tf, 1500,1200);
|
||||
tf->AddFrame(page, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
|
||||
senses=new ctbSlowAdcs(page, myDet);
|
||||
|
||||
i_senses=i_page++;
|
||||
|
||||
|
||||
|
||||
cout << "signals " << endl;
|
||||
tf = mtab->AddTab("Signals");
|
||||
page=new TGVerticalFrame(tf, 1500,1200);
|
||||
tf->AddFrame(page, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
|
||||
sig=new ctbSignals(page, myDet);
|
||||
sig->Connect("ToggledSignalPlot(Int_t)","ctbMain",this,"setSignalPlot(Int_t)");
|
||||
|
||||
i_sig=i_page++;
|
||||
|
||||
cout << "adcs " << endl;
|
||||
tf = mtab->AddTab("ADCs");
|
||||
page=new TGVerticalFrame(tf, 1500,1200);
|
||||
tf->AddFrame(page, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
|
||||
adcs=new ctbAdcs(page, myDet);
|
||||
adcs->Connect("ToggledAdcPlot(Int_t)","ctbMain",this,"setADCPlot(Int_t)");
|
||||
adcs->Connect("AdcEnable(Int_t)","ctbMain",this,"setADCEnable(Int_t)");
|
||||
i_adcs=i_page++;
|
||||
|
||||
|
||||
cout << "pattern" << endl;
|
||||
|
||||
tf = mtab->AddTab("Pattern");
|
||||
page=new TGVerticalFrame(tf, 1500,1200);
|
||||
tf->AddFrame(page, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
|
||||
pat=new ctbPattern(page, myDet);
|
||||
pat->Connect("patternFileChanged(const char*)","ctbMain",this,"setPatternFile(const char*)");
|
||||
pat->Connect("patternCompilerChanged(const char*)","ctbMain",this,"setPatternCompiler(const char*)");
|
||||
pat->Connect("analogSamplesChanged(const int)","ctbMain",this,"setAnalogSamples(int)");
|
||||
pat->Connect("digitalSamplesChanged(const int)","ctbMain",this,"setDigitalSamples(int)");
|
||||
pat->Connect("readoutModeChanged(int)","ctbMain",this,"setReadoutMode(int)");
|
||||
|
||||
i_pat=i_page++;
|
||||
|
||||
cout << "acquisition" << endl;
|
||||
|
||||
tf = mtab->AddTab("Acquisition");
|
||||
page=new TGVerticalFrame(tf, 1500,1200);
|
||||
tf->AddFrame(page, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
|
||||
acq=new ctbAcquisition(page, myDet);
|
||||
|
||||
|
||||
i_acq=i_page++;
|
||||
|
||||
|
||||
// cout << "actions" << endl;
|
||||
// tf = mtab->AddTab("Actions");
|
||||
// page=new TGVerticalFrame(tf, 1500,1200);
|
||||
// tf->AddFrame(page, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
|
||||
// actions=new ctbActions(page, myDet);
|
||||
|
||||
|
||||
// i_actions=i_page++;
|
||||
|
||||
|
||||
|
||||
cout << "tabs finished" << endl;
|
||||
|
||||
hpage->AddFrame(mtab,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
|
||||
|
||||
vframe->AddFrame(hpage,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
|
||||
|
||||
AddFrame(vframe,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
|
||||
vframe->MapWindow();
|
||||
hpage->MapWindow();
|
||||
mtab->MapWindow();
|
||||
page->MapWindow();
|
||||
|
||||
// Sets window name and shows the main frame
|
||||
cout << "dockabel" << endl;
|
||||
TGDockableFrame *fdock=new TGDockableFrame(hpage);
|
||||
hpage->AddFrame(fdock, new TGLayoutHints(kLHintsBottom | kLHintsCenterX | kLHintsExpandX | kLHintsExpandY, 10,10,10,10));
|
||||
fdock->MapWindow();
|
||||
|
||||
cout << "canvas" << endl;
|
||||
// // Creates widgets of the example
|
||||
|
||||
|
||||
fEcanvas = new TRootEmbeddedCanvas ("Ecanvas",fdock,800,800);//hpage,800,800);
|
||||
//fEcanvas = new TRootEmbeddedCanvas ("Ecanvas",this,800,800);//hpage,800,800);
|
||||
// fEcanvas->Resize();
|
||||
// fEcanvas->GetCanvas()->Update();
|
||||
//AddFrame(fEcanvas, new TGLayoutHints(kLHintsBottom | kLHintsCenterX | kLHintsExpandX | kLHintsExpandY, 10,10,10,10));
|
||||
|
||||
// // hpage->
|
||||
fdock->AddFrame(fEcanvas, new TGLayoutHints(kLHintsBottom | kLHintsCenterX | kLHintsExpandX | kLHintsExpandY, 10,10,10,10));
|
||||
|
||||
|
||||
fEcanvas->MapWindow();
|
||||
|
||||
acq->setCanvas(getCanvas());
|
||||
|
||||
|
||||
|
||||
hpage->MapSubwindows();
|
||||
mtab->Connect("Selected(Int_t)","ctbMain",this,"tabSelected(Int_t)");
|
||||
|
||||
|
||||
|
||||
cout << "connect mtab" << endl;
|
||||
|
||||
try{
|
||||
setReadoutMode(pat->getReadoutMode());
|
||||
} CATCH_DISPLAY ("Could not get readout flags", "ctbPattern::getReadoutMode")
|
||||
|
||||
setADCEnable(adcs->setEnable());
|
||||
setAnalogSamples(pat->getAnalogSamples());
|
||||
setDigitalSamples(pat->getDigitalSamples());
|
||||
|
||||
tabSelected(0);
|
||||
|
||||
SetWindowName("CTB Gui");
|
||||
MapSubwindows();
|
||||
Resize(1500,1200);
|
||||
|
||||
MapWindow();
|
||||
}
|
||||
|
||||
void ctbMain::CloseWindow() {
|
||||
gApplication->Terminate();
|
||||
}
|
||||
|
||||
TCanvas* ctbMain::getCanvas() {
|
||||
return fEcanvas->GetCanvas();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctbMain::HandleMenu(Int_t id)
|
||||
{
|
||||
// Handle menu items.
|
||||
|
||||
|
||||
|
||||
|
||||
switch (id) {
|
||||
|
||||
case 0: // fMenuFile->AddEntry("Open Alias", im++);
|
||||
cout << "Open Alias" << endl;
|
||||
{
|
||||
static TString dir(".");
|
||||
TGFileInfo fi;
|
||||
//fi.fFileTypes = filetypes;
|
||||
fi.fIniDir = StrDup(dir);
|
||||
printf("fIniDir = %s\n", fi.fIniDir);
|
||||
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
|
||||
printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
|
||||
// dir = fi.fIniDir;
|
||||
if (fi.fFilename)
|
||||
loadAlias(fi.fFilename);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: // fMenuFile->AddEntry("Save Alias", im++);
|
||||
cout << "Save Alias" << endl;
|
||||
{
|
||||
static TString dir(".");
|
||||
TGFileInfo fi;
|
||||
//fi.fFileTypes = filetypes;
|
||||
fi.fIniDir = StrDup(dir);
|
||||
printf("fIniDir = %s\n", fi.fIniDir);
|
||||
new TGFileDialog(gClient->GetRoot(), this, kFDSave, &fi);
|
||||
printf("Save file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
|
||||
// dir = fi.fIniDir;
|
||||
if (fi.fFilename)
|
||||
saveAlias(fi.fFilename);
|
||||
}
|
||||
break;
|
||||
case 2: //fMenuFile->AddEntry("Open Parameters", im++);
|
||||
cout << "Open Parameters" << endl;
|
||||
{
|
||||
static TString dir(".");
|
||||
TGFileInfo fi;
|
||||
//fi.fFileTypes = filetypes;
|
||||
fi.fIniDir = StrDup(dir);
|
||||
printf("fIniDir = %s\n", fi.fIniDir);
|
||||
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
|
||||
printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
|
||||
// dir = fi.fIniDir;
|
||||
if (fi.fFilename)
|
||||
loadParameters(fi.fFilename);
|
||||
}
|
||||
break;
|
||||
|
||||
case 3: // fMenuFile->AddEntry("Open Configuration", im++);
|
||||
cout << "Open configuration" << endl;
|
||||
{
|
||||
static TString dir(".");
|
||||
TGFileInfo fi;
|
||||
//fi.fFileTypes = filetypes;
|
||||
fi.fIniDir = StrDup(dir);
|
||||
printf("fIniDir = %s\n", fi.fIniDir);
|
||||
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
|
||||
printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
|
||||
// dir = fi.fIniDir;
|
||||
if (fi.fFilename)
|
||||
loadConfiguration(fi.fFilename);
|
||||
}
|
||||
break;
|
||||
|
||||
case 4: //fMenuFile->AddEntry("Open Pattern", im++);
|
||||
cout << "Open pattern" << endl;
|
||||
{
|
||||
static TString dir(".");
|
||||
TGFileInfo fi;
|
||||
//fi.fFileTypes = filetypes;
|
||||
fi.fIniDir = StrDup(dir);
|
||||
printf("fIniDir = %s\n", fi.fIniDir);
|
||||
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
|
||||
printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
|
||||
// dir = fi.fIniDir;
|
||||
if (fi.fFilename)
|
||||
loadParameters(fi.fFilename);
|
||||
}
|
||||
break;
|
||||
|
||||
case 5: //fMenuFile->AddEntry("Save Pattern", im++);
|
||||
cout << "Save pattern" << endl;
|
||||
{
|
||||
static TString dir(".");
|
||||
TGFileInfo fi;
|
||||
//fi.fFileTypes = filetypes;
|
||||
fi.fIniDir = StrDup(dir);
|
||||
printf("fIniDir = %s\n", fi.fIniDir);
|
||||
new TGFileDialog(gClient->GetRoot(), this, kFDSave, &fi);
|
||||
printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
|
||||
// dir = fi.fIniDir;
|
||||
if (fi.fFilename)
|
||||
savePattern(fi.fFilename);
|
||||
}
|
||||
break;
|
||||
|
||||
case 6: // fMenuFile->AddEntry("Exit", im++);
|
||||
CloseWindow();
|
||||
|
||||
default:
|
||||
printf("Menu item %d selected\n", id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ctbMain::setADCPlot(Int_t i) {
|
||||
|
||||
// cout << "ADC " << i << " plot or color toggled" << endl;
|
||||
// acq->setGraph(i,adcs->getGraph(i));
|
||||
acq->setGraph(i,adcs->getEnabled(i),adcs->getColor(i));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int ctbMain::setSignalPlot(Int_t i) {
|
||||
|
||||
// cout << "ADC " << i << " plot or color toggled" << endl;
|
||||
// acq->setGraph(i,adcs->getGraph(i));
|
||||
acq->setBitGraph(i,sig->getPlot(i),sig->getColor(i));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctbMain::loadConfiguration(string fname) {
|
||||
try{
|
||||
myDet->loadConfig(fname);
|
||||
} CATCH_DISPLAY ("Could not load config.", "ctbMain::loadConfiguration")
|
||||
}
|
||||
|
||||
void ctbMain::loadParameters(string fname) {
|
||||
try{
|
||||
myDet->loadParameters(fname);
|
||||
} CATCH_DISPLAY ("Could not load parameters.", "ctbMain::loadParameters")
|
||||
}
|
||||
|
||||
void ctbMain::savePattern(string fname) {
|
||||
try{
|
||||
myDet->savePattern(fname);
|
||||
} CATCH_DISPLAY ("Could not save pattern.", "ctbMain::savePattern")
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ctbMain::loadAlias(string fname) {
|
||||
|
||||
|
||||
string line;
|
||||
char aaaa[1000];
|
||||
int i;
|
||||
ifstream myfile (fname.c_str());
|
||||
if (myfile.is_open())
|
||||
{
|
||||
while ( getline (myfile,line) )
|
||||
{
|
||||
// cout << line ;
|
||||
if (sscanf(line.c_str(),"BIT%d",&i)>0) {
|
||||
//cout << "*******" << line<< endl;
|
||||
sig->setSignalAlias(line);
|
||||
// cout << line ;
|
||||
} else if (sscanf(line.c_str(),"DAC%d",&i)>0) {
|
||||
dacs->setDacAlias(line);
|
||||
// cout << "+++++++++" << line<< endl;
|
||||
} else if (sscanf(line.c_str(),"ADC%d",&i)>0) {
|
||||
adcs->setAdcAlias(line);
|
||||
// cout << "---------" << line<< endl;
|
||||
} // else
|
||||
// cout << "<<<<<<<" << line << endl;
|
||||
else if (sscanf(line.c_str(),"PAT%s",aaaa)>0) {
|
||||
pat->setPatternAlias(line);
|
||||
// cout << "---------" << line<< endl;
|
||||
} else if (sscanf(line.c_str(),"V%s",aaaa)>0) {
|
||||
if (pwrs) pwrs->setPwrAlias(line);
|
||||
// cout << "+++++++++" << line<< endl;
|
||||
} else if (sscanf(line.c_str(),"SENSE%d",&i)>0) {
|
||||
if (senses) senses->setSlowAdcAlias(line);
|
||||
// cout << "+++++++++" << line<< endl;
|
||||
}
|
||||
|
||||
}
|
||||
myfile.close();
|
||||
}
|
||||
|
||||
else cout << "Unable to open file";
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int ctbMain::saveAlias(string fname) {
|
||||
|
||||
|
||||
string line;
|
||||
ofstream myfile (fname.c_str());
|
||||
if (myfile.is_open())
|
||||
{
|
||||
//while ( getline (myfile,line) )
|
||||
// {
|
||||
// cout << line ;
|
||||
//if (sscanf(line.c_str(),"BIT%d",&i)>0) {
|
||||
//cout << "*******" << line<< endl;
|
||||
myfile << sig->getSignalAlias();
|
||||
// cout << line ;
|
||||
// } else if (sscanf(line.c_str(),"DAC%d",&i)>0) {
|
||||
myfile << dacs->getDacAlias();
|
||||
if (pwrs) myfile << pwrs->getPwrAlias();
|
||||
if (senses) myfile << senses->getSlowAdcAlias();
|
||||
// cout << "+++++++++" << line<< endl;
|
||||
// } else if (sscanf(line.c_str(),"ADC%d",&i)>0) {
|
||||
myfile << adcs->getAdcAlias();
|
||||
// cout << "---------" << line<< endl;
|
||||
// } // else
|
||||
// cout << "<<<<<<<" << line << endl;
|
||||
myfile << pat->getPatternAlias();
|
||||
|
||||
//}
|
||||
myfile.close();
|
||||
}
|
||||
|
||||
else cout << "Unable to open file";
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ctbMain::tabSelected(Int_t i) {
|
||||
|
||||
// cout << "Selected tab " << i << endl;
|
||||
// cout << "Current tab is " << mtab->GetCurrent() << endl;
|
||||
|
||||
if (i==i_dacs) dacs->update();
|
||||
else if (i==i_pwrs) pwrs->update();
|
||||
else if (i==i_senses) ;//senses->update();
|
||||
else if (i==i_sig) sig->update();
|
||||
else if (i==i_adcs) adcs->update();
|
||||
else if (i==i_pat) pat->update();
|
||||
else if (i==i_acq) acq->update();
|
||||
else if (i==i_acq) acq->update();
|
||||
// else if (i==i_actions) actions->update();
|
||||
else cout << "Unknown tab " << i << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ctbMain::setPatternFile(const char* t) {
|
||||
acq->setPatternFile(t);
|
||||
|
||||
}
|
||||
|
||||
void ctbMain::setPatternCompiler(const char* t) {
|
||||
acq->setPatternCompiler(t);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ctbMain::setAnalogSamples(const int n) {
|
||||
acq->setAnalogSamples(n);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ctbMain::setDigitalSamples(const int n) {
|
||||
acq->setDigitalSamples(n);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ctbMain::setReadoutMode(int flags) {
|
||||
acq->setReadoutMode(flags);
|
||||
}
|
||||
|
||||
void ctbMain::setADCEnable(Int_t reg){
|
||||
acq->setADCEnable(reg);
|
||||
}
|
130
ctbGui/ctbMain.h
130
ctbGui/ctbMain.h
@ -1,130 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef CTBMAIN_H
|
||||
#define CTBMAIN_H
|
||||
#include <TGFrame.h>
|
||||
|
||||
|
||||
class TRootEmbeddedCanvas;
|
||||
class TGButtonGroup;
|
||||
class TGVerticalFrame;
|
||||
class TGHorizontalFrame;
|
||||
class TGTextEntry;
|
||||
class TGLabel;
|
||||
class TGNumberEntry;
|
||||
class TH2F;
|
||||
class TGComboBox;
|
||||
class TGCheckButton;
|
||||
|
||||
class THStack;
|
||||
class TGraphErrors;
|
||||
class TGTextButton;
|
||||
class TGTab;
|
||||
|
||||
class TGMenuBar;
|
||||
class TGPopupMenu;
|
||||
class TGDockableFrame;
|
||||
class TGLayoutHints;
|
||||
class TGCanvas;
|
||||
class TCanvas;
|
||||
|
||||
class ctbDacs;
|
||||
class ctbSlowAdcs;
|
||||
class ctbPowers;
|
||||
|
||||
|
||||
class ctbSignals;
|
||||
|
||||
namespace sls
|
||||
{
|
||||
class Detector;
|
||||
};
|
||||
|
||||
class ctbPattern;
|
||||
class ctbAdcs;
|
||||
class ctbAcquisition;
|
||||
//class ctbActions;
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
class ctbMain : public TGMainFrame {
|
||||
private:
|
||||
|
||||
|
||||
sls::Detector *myDet;
|
||||
|
||||
|
||||
|
||||
TRootEmbeddedCanvas *fEcanvas;
|
||||
TRootEmbeddedCanvas *fModulecanvas;
|
||||
TGButtonGroup *br;
|
||||
|
||||
TGTab *mtab;
|
||||
|
||||
|
||||
ctbDacs *dacs;
|
||||
int i_dacs;
|
||||
|
||||
ctbPowers *pwrs;
|
||||
int i_pwrs;
|
||||
|
||||
ctbSlowAdcs *senses;
|
||||
int i_senses;
|
||||
|
||||
|
||||
ctbSignals *sig;
|
||||
int i_sig;
|
||||
|
||||
|
||||
ctbAdcs *adcs;
|
||||
int i_adcs;
|
||||
|
||||
|
||||
ctbPattern *pat;
|
||||
int i_pat;
|
||||
|
||||
ctbAcquisition *acq;
|
||||
int i_acq;
|
||||
|
||||
// ctbActions *actions;
|
||||
int i_actions;
|
||||
|
||||
TGDockableFrame *fMenuDock;
|
||||
|
||||
TGMenuBar *fMenuBar;
|
||||
TGPopupMenu *fMenuFile, *fMenuTest, *fMenuView, *fMenuHelp;
|
||||
TGPopupMenu *fCascadeMenu, *fCascade1Menu, *fCascade2Menu;
|
||||
TGPopupMenu *fMenuNew1, *fMenuNew2;
|
||||
TGLayoutHints *fMenuBarLayout, *fMenuBarItemLayout, *fMenuBarHelpLayout;
|
||||
TGCanvas *myCanvas;
|
||||
|
||||
|
||||
public:
|
||||
ctbMain(const TGWindow *p, sls::Detector *det);
|
||||
|
||||
|
||||
int loadAlias(string fname);
|
||||
int saveAlias(string fname);
|
||||
void loadParameters(string fname);
|
||||
void savePattern(string fname);
|
||||
void loadConfiguration(string fname);
|
||||
void tabSelected(Int_t);
|
||||
int setADCPlot(Int_t);
|
||||
int setSignalPlot(Int_t);
|
||||
void CloseWindow();
|
||||
|
||||
void setPatternFile(const char* t);
|
||||
|
||||
void setPatternCompiler(const char* t);
|
||||
void setAnalogSamples(const int);
|
||||
void setDigitalSamples(const int);
|
||||
void setReadoutMode(int);
|
||||
void setADCEnable(Int_t);
|
||||
|
||||
void HandleMenu(Int_t);
|
||||
TCanvas* getCanvas();
|
||||
ClassDef(ctbMain,0)
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,181 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef CTBPATTERN_H
|
||||
#define CTBPATTERN_H
|
||||
#include <TGFrame.h>
|
||||
|
||||
|
||||
#define NLOOPS 3
|
||||
#define NWAITS 3
|
||||
#define NADCS 32
|
||||
#define PATLEN 1024
|
||||
|
||||
class TRootEmbeddedCanvas;
|
||||
class TGButtonGroup;
|
||||
class TGVerticalFrame;
|
||||
class TGHorizontalFrame;
|
||||
class TGTextEntry;
|
||||
class TGLabel;
|
||||
class TGNumberEntry;
|
||||
class TH2F;
|
||||
class TGComboBox;
|
||||
class TGCheckButton;
|
||||
class TGTextEntry;
|
||||
class TGCheckButton;
|
||||
|
||||
class THStack;
|
||||
class TGraphErrors;
|
||||
class energyCalibration;
|
||||
class TGTextButton;
|
||||
class TGTab;
|
||||
|
||||
namespace sls
|
||||
{
|
||||
class Detector;
|
||||
};
|
||||
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
class ctbLoop : public TGHorizontalFrame {
|
||||
|
||||
|
||||
private:
|
||||
|
||||
TGNumberEntry *eLoopStartAddr;
|
||||
TGNumberEntry *eLoopStopAddr;
|
||||
TGNumberEntry *eLoopNumber;
|
||||
|
||||
int id;
|
||||
|
||||
sls::Detector *myDet;
|
||||
|
||||
public:
|
||||
ctbLoop(TGGroupFrame *page, int i,sls::Detector *det);
|
||||
|
||||
void setNLoops();
|
||||
void update();
|
||||
|
||||
ClassDef(ctbLoop,0)
|
||||
};
|
||||
|
||||
class ctbWait : public TGHorizontalFrame {
|
||||
|
||||
|
||||
private:
|
||||
|
||||
TGNumberEntry *eWaitAddr;
|
||||
TGNumberEntry *eWaitTime;
|
||||
|
||||
int id;
|
||||
|
||||
sls::Detector *myDet;
|
||||
|
||||
public:
|
||||
ctbWait(TGGroupFrame *page, int i,sls::Detector *det);
|
||||
|
||||
void setWaitTime();
|
||||
void update();
|
||||
|
||||
ClassDef(ctbWait,0)
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ctbPattern : public TGGroupFrame {
|
||||
private:
|
||||
|
||||
|
||||
TGNumberEntry *eAdcClkFreq;
|
||||
TGNumberEntry *eRunClkFreq;
|
||||
TGNumberEntry *eDBitClkFreq;
|
||||
TGNumberEntry *eAdcClkPhase;
|
||||
TGNumberEntry *eDBitClkPhase;
|
||||
//TGNumberEntry *eRunClkPhase;
|
||||
|
||||
TGNumberEntry *eStartAddr;
|
||||
TGNumberEntry *eStopAddr;
|
||||
TGNumberEntry *eFrames;
|
||||
TGNumberEntry *ePeriod;
|
||||
TGNumberEntry *eTriggers;
|
||||
// TGNumberEntry *eMeasurements;
|
||||
TGNumberEntry *eAdcPipeline;
|
||||
TGNumberEntry *eDBitPipeline;
|
||||
|
||||
ctbLoop *eLoop[NLOOPS];
|
||||
ctbWait *eWait[NWAITS];
|
||||
|
||||
TGTextEntry *patternCompiler;
|
||||
TGTextEntry *patternFile;
|
||||
|
||||
TGTextButton *browseCompiler;
|
||||
TGTextButton *browseFile;
|
||||
|
||||
|
||||
TGNumberEntry *eAnalogSamples;
|
||||
TGNumberEntry *eDigitalSamples;
|
||||
|
||||
TGCheckButton *cbAnalog;
|
||||
TGCheckButton *cbDigital;
|
||||
|
||||
char pat[PATLEN*8];
|
||||
|
||||
sls::Detector *myDet;
|
||||
|
||||
public:
|
||||
|
||||
ctbPattern(TGVerticalFrame *page, sls::Detector *det);
|
||||
|
||||
void update();
|
||||
void setAdcFreq();
|
||||
void setRunFreq();
|
||||
void setDBitFreq();
|
||||
void setAdcPhase();
|
||||
void setDBitPhase();
|
||||
// void setRunPhase();
|
||||
void setAdcPipeline();
|
||||
void setDBitPipeline();
|
||||
void setFrames();
|
||||
void setTriggers();
|
||||
// void setMeasurements();
|
||||
void setPeriod();
|
||||
|
||||
|
||||
void chooseCompiler();
|
||||
void choosePattern();
|
||||
|
||||
string getCompiler();
|
||||
string getPatternFile();
|
||||
|
||||
void setPatternAlias(string);
|
||||
string getPatternAlias();
|
||||
|
||||
|
||||
int getAnalogSamples();
|
||||
void setAnalogSamples();
|
||||
int getDigitalSamples();
|
||||
void setDigitalSamples();
|
||||
void setReadoutMode(Bool_t);
|
||||
int getReadoutMode();
|
||||
|
||||
|
||||
void setFile();
|
||||
void setCompiler();
|
||||
void patternFileChanged(const char*);
|
||||
void patternCompilerChanged(const char*);
|
||||
void analogSamplesChanged(const int t);
|
||||
void digitalSamplesChanged(const int t);
|
||||
void readoutModeChanged(int);
|
||||
|
||||
|
||||
ClassDef(ctbPattern,0)
|
||||
};
|
||||
|
||||
#endif
|
@ -1,225 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include <TGFrame.h>
|
||||
|
||||
|
||||
#include <TGButtonGroup.h>
|
||||
#include <TGNumberEntry.h>
|
||||
#include <TGLabel.h>
|
||||
#include <TList.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "ctbDefs.h"
|
||||
#include "ctbDacs.h"
|
||||
#include "ctbPowers.h"
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
ctbPower::ctbPower(TGGroupFrame* f, int i, sls::Detector* d)
|
||||
: ctbDac(f, i, d)
|
||||
{
|
||||
cout << "****************************************************************power " << i << endl;
|
||||
dacsUnit->SetOn(kTRUE);
|
||||
dacsUnit->SetEnabled(kFALSE);
|
||||
|
||||
switch(i) {
|
||||
case slsDetectorDefs::V_POWER_IO:
|
||||
dacsLabel->SetText("VIO");
|
||||
break;
|
||||
case slsDetectorDefs::V_POWER_A:
|
||||
dacsLabel->SetText("VA");
|
||||
break;
|
||||
case slsDetectorDefs::V_POWER_B:
|
||||
dacsLabel->SetText("VB");
|
||||
break;
|
||||
case slsDetectorDefs::V_POWER_C:
|
||||
dacsLabel->SetText("VC");
|
||||
break;
|
||||
case slsDetectorDefs::V_POWER_D:
|
||||
dacsLabel->SetText("VD");
|
||||
break;
|
||||
case slsDetectorDefs::V_POWER_CHIP:
|
||||
dacsLabel->SetText("VCHIP");
|
||||
dacsLabel->SetEnabled(kFALSE);
|
||||
break;
|
||||
default:
|
||||
dacsLabel->SetText("Bad index");
|
||||
break;
|
||||
};
|
||||
|
||||
|
||||
TGTextEntry *e=dacsEntry->TGNumberEntry::GetNumberEntry();
|
||||
e->Disconnect ("ReturnPressed()");
|
||||
e->Disconnect ("ValueSet(Long_t)");
|
||||
|
||||
e->Connect("ReturnPressed()","ctbPower",this,"setValue()");
|
||||
dacsEntry->Connect("ValueSet(Long_t)","ctbPower",this,"setValue(Long_t)");
|
||||
};
|
||||
|
||||
|
||||
string ctbPower::getLabel() {
|
||||
|
||||
ostringstream line;
|
||||
switch (id) {
|
||||
case slsDetectorDefs::V_POWER_IO:
|
||||
line << "VIO";
|
||||
break;
|
||||
case slsDetectorDefs::V_POWER_A:
|
||||
line << "VA";
|
||||
break;
|
||||
case slsDetectorDefs::V_POWER_B:
|
||||
line << "VB";
|
||||
break;
|
||||
case slsDetectorDefs::V_POWER_C:
|
||||
line << "VC";
|
||||
break;
|
||||
case slsDetectorDefs::V_POWER_D:
|
||||
line << "VD";
|
||||
break;
|
||||
case slsDetectorDefs::V_POWER_CHIP:
|
||||
line << "VCHIP";
|
||||
break;
|
||||
default:
|
||||
line << "VBAD";
|
||||
break;
|
||||
|
||||
}
|
||||
line << " " << dacsLabel->GetText() << endl;
|
||||
return line.str();
|
||||
}
|
||||
|
||||
void ctbPower::setValue(Long_t a) {ctbPower::setValue();}
|
||||
|
||||
void ctbPower::setValue() {
|
||||
cout << "***************************Setting power " << dacsEntry->GetIntNumber() << " " << id << " " << 1 << endl;
|
||||
|
||||
try {
|
||||
myDet->setVoltage(static_cast<slsDetectorDefs::dacIndex>(id), dacsEntry->GetIntNumber());
|
||||
} CATCH_DISPLAY ("Could not set power " + to_string(id) + ".", "ctbPower::setValue")
|
||||
|
||||
getValue();
|
||||
}
|
||||
|
||||
|
||||
int ctbPower::getValue() {
|
||||
try {
|
||||
|
||||
int val = myDet->getVoltage(static_cast<slsDetectorDefs::dacIndex>(id)).tsquash("Different values");
|
||||
cout << "****************************Getting power " << val << " " << id << " " << 1 << endl;
|
||||
|
||||
dacsValue->SetText(to_string(val).c_str());
|
||||
if (val > 0) {
|
||||
if (id != static_cast<int>(slsDetectorDefs::V_POWER_CHIP))
|
||||
dacsLabel->SetOn(kTRUE);
|
||||
} else {
|
||||
dacsLabel->SetOn(kFALSE);
|
||||
}
|
||||
|
||||
return val;
|
||||
|
||||
} CATCH_DISPLAY ("Could not get power " + to_string(id) + ".", "ctbPower::getValue")
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ctbPowers::ctbPowers(TGVerticalFrame* page, sls::Detector* det) : TGGroupFrame(page,"Power Supplies",kVerticalFrame) , myDet(det){
|
||||
|
||||
|
||||
SetTitlePos(TGGroupFrame::kLeft);
|
||||
page->AddFrame(this,new TGLayoutHints( kLHintsTop | kLHintsExpandX , 10,10,10,10));
|
||||
MapWindow();
|
||||
|
||||
// cout << "window mapped " << endl;
|
||||
|
||||
for (int idac=0; idac<NPOWERS; idac++) {
|
||||
dacs[idac]=new ctbPower(this, slsDetectorDefs::V_POWER_A+idac, myDet);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ctbPowers::setPwrAlias(string line) {
|
||||
|
||||
int is=-1;
|
||||
char tit[100];
|
||||
|
||||
if (sscanf(line.c_str(),"VA %s",tit)) {
|
||||
dacs[0]->setLabel(tit,1);
|
||||
is=0;
|
||||
}
|
||||
|
||||
if (sscanf(line.c_str(),"VB %s",tit)) {
|
||||
dacs[1]->setLabel(tit,1);
|
||||
is=1;
|
||||
}
|
||||
|
||||
if (sscanf(line.c_str(),"VC %s",tit)) {
|
||||
dacs[2]->setLabel(tit,1);
|
||||
is=2;
|
||||
}
|
||||
|
||||
if (sscanf(line.c_str(),"VD %s",tit)) {
|
||||
dacs[3]->setLabel(tit,1);
|
||||
is=3;
|
||||
}
|
||||
|
||||
if (sscanf(line.c_str(),"VIO %s",tit)) {
|
||||
dacs[4]->setLabel(tit,1);
|
||||
is=4;
|
||||
}
|
||||
|
||||
if (sscanf(line.c_str(),"VCHIP %s",tit)) {
|
||||
dacs[5]->setLabel(tit,1);
|
||||
is=5;
|
||||
}
|
||||
|
||||
return is;
|
||||
|
||||
}
|
||||
|
||||
string ctbPowers::getPwrAlias() {
|
||||
|
||||
ostringstream line;
|
||||
|
||||
for (int i=0; i<NPOWERS; i++)
|
||||
line << dacs[i]->getLabel() << endl;
|
||||
return line.str();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ctbPowers::getPwrParameters() {
|
||||
|
||||
ostringstream line;
|
||||
line << "v_a" << " " << dacs[0]->getValue() << " mv" << endl;
|
||||
line << "v_b" << " " << dacs[1]->getValue() << " mv" << endl;
|
||||
line << "v_c" << " " << dacs[2]->getValue() << " mv" << endl;
|
||||
line << "v_d" << " " << dacs[3]->getValue() << " mv" << endl;
|
||||
line << "v_io" << " " << dacs[4]->getValue() << " mv" << endl;
|
||||
line << "v_chip" << " " << dacs[5]->getValue() << " mv" << endl;
|
||||
// for (int i=0; i<POWERS; i++) {
|
||||
// //line << "dacs:" << i << " " << dacs[i]->getValue << endl;
|
||||
// line << "dac:" << i << " " << dacs[i]->getValue() << endl;
|
||||
// }
|
||||
return line.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctbPowers::update() {
|
||||
for (int idac=0; idac<NPOWERS; idac++) {
|
||||
dacs[idac]->getValue();
|
||||
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef CTBPOWERS_H
|
||||
#define CTBPOWERS_H
|
||||
|
||||
#include <TGFrame.h>
|
||||
|
||||
#define NPOWERS 6
|
||||
|
||||
|
||||
|
||||
class TGTextEntry;
|
||||
class TGLabel;
|
||||
class TGNumberEntry;
|
||||
class TGCheckButton;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace sls
|
||||
{
|
||||
class Detector;
|
||||
};
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
|
||||
class ctbPower : public ctbDac {
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
ctbPower(TGGroupFrame* f, int i, sls::Detector* d);
|
||||
|
||||
string getLabel();
|
||||
|
||||
int getValue();
|
||||
void setValue();
|
||||
void setValue(Long_t);
|
||||
|
||||
ClassDef(ctbPower,0)
|
||||
};
|
||||
|
||||
|
||||
class ctbPowers : public TGGroupFrame
|
||||
{
|
||||
private:
|
||||
|
||||
ctbPower *dacs[NPOWERS];
|
||||
|
||||
sls::Detector* myDet;
|
||||
|
||||
public:
|
||||
//ctbPowers();
|
||||
ctbPowers(TGVerticalFrame*, sls::Detector*);
|
||||
|
||||
int setPwrAlias(string);
|
||||
string getPwrAlias();
|
||||
string getPwrParameters();
|
||||
|
||||
void update();
|
||||
|
||||
ClassDef(ctbPowers,0)
|
||||
};
|
||||
|
||||
#endif
|
@ -1,543 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include <TApplication.h>
|
||||
#include <TGClient.h>
|
||||
#include <TCanvas.h>
|
||||
#include <TF1.h>
|
||||
#include <TRandom.h>
|
||||
#include <TGButton.h>
|
||||
#include <TRootEmbeddedCanvas.h>
|
||||
#include <TGButtonGroup.h>
|
||||
#include <TGNumberEntry.h>
|
||||
#include <TGLabel.h>
|
||||
#include <TList.h>
|
||||
#include <TGFileDialog.h>
|
||||
#include <TGComboBox.h>
|
||||
#include <TH2F.h>
|
||||
#include <TColor.h>
|
||||
#include <TH1F.h>
|
||||
#include <TGraphErrors.h>
|
||||
#include <THStack.h>
|
||||
#include <TGTab.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <TGButton.h>
|
||||
#include <TRootEmbeddedCanvas.h>
|
||||
#include <TGButtonGroup.h>
|
||||
#include <TGNumberEntry.h>
|
||||
#include <TGLabel.h>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <TColor.h>
|
||||
#include <TGColorSelect.h>
|
||||
|
||||
|
||||
#include "ctbSignals.h"
|
||||
#include "ctbDefs.h"
|
||||
#include "sls/Detector.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
//#define DEFAULTFN "run_0.encal"
|
||||
|
||||
|
||||
ctbSignal::ctbSignal(TGFrame *page, int i, sls::Detector *det)
|
||||
: TGHorizontalFrame(page, 800,50), myDet(det), id(i), hsig(NULL) {
|
||||
|
||||
|
||||
TGHorizontalFrame *hframe=this;
|
||||
char tit[100];
|
||||
|
||||
|
||||
|
||||
sprintf(tit, "BIT%d ",id);
|
||||
|
||||
sLabel= new TGLabel(hframe, tit);
|
||||
hframe->AddFrame( sLabel,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
|
||||
sLabel->MapWindow();
|
||||
sLabel->SetTextJustify(kTextLeft);
|
||||
|
||||
|
||||
|
||||
sOutput= new TGCheckButton(hframe, "Out");
|
||||
hframe->AddFrame( sOutput,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
|
||||
sOutput->MapWindow();
|
||||
|
||||
|
||||
sOutput->Connect("Toggled(Bool_t)","ctbSignal",this,"ToggledOutput(Bool_t)");
|
||||
|
||||
sDbitList= new TGCheckButton(hframe, "DB List");
|
||||
hframe->AddFrame( sDbitList,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
|
||||
sDbitList->MapWindow();
|
||||
|
||||
sDbitList->Connect("Toggled(Bool_t)","ctbSignal",this,"ToggledDbitList(Bool_t)");
|
||||
|
||||
|
||||
sPlot= new TGCheckButton(hframe, "Plot");
|
||||
hframe->AddFrame( sPlot,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
|
||||
sPlot->MapWindow();
|
||||
|
||||
sPlot->Connect("Toggled(Bool_t)","ctbSignal",this,"ToggledPlot(Bool_t)");
|
||||
|
||||
fColorSel = new TGColorSelect(hframe, id+1, 0);
|
||||
fColorSel->Connect("ColorSelected(Pixel_t)","ctbSignal",this,"ColorChanged(Pixel_t)");
|
||||
hframe->AddFrame(fColorSel, new TGLayoutHints(kLHintsTop |
|
||||
kLHintsLeft, 2, 0, 2, 2));
|
||||
|
||||
|
||||
fColorSel->SetColor(TColor::Number2Pixel(id+1));
|
||||
|
||||
|
||||
ToggledOutput(kFALSE);
|
||||
|
||||
|
||||
ToggledPlot(kFALSE);
|
||||
|
||||
// if (id==63) {
|
||||
// sOutput->SetOn(kTRUE);
|
||||
// sOutput->SetEnabled(kFALSE);
|
||||
// }
|
||||
// #ifdef CTB
|
||||
// if (id==62) {
|
||||
// sOutput->SetOn(kTRUE);
|
||||
// sOutput->SetEnabled(kFALSE);
|
||||
// }
|
||||
|
||||
// // if (id>=32 && id<48)
|
||||
// // fixOutput(1);
|
||||
// // else if (id>=48 && id<64)
|
||||
// // fixOutput(0);
|
||||
|
||||
// #endif
|
||||
}
|
||||
int ctbSignal::setSignalAlias(char *tit, int plot, int col) {
|
||||
|
||||
if (tit)
|
||||
sLabel->SetText(tit);
|
||||
|
||||
if (plot>0) {
|
||||
sPlot->SetOn(kTRUE,kTRUE);
|
||||
} else if (plot==0)
|
||||
sPlot->SetOn(kFALSE,kTRUE);
|
||||
|
||||
if (col>=0)
|
||||
fColorSel->SetColor(col);//TColor::Number2Pixel(col+1));
|
||||
|
||||
fColorSel->SetEnabled(sPlot->IsOn());
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
string ctbSignal::getSignalAlias() {
|
||||
|
||||
|
||||
ostringstream oss;
|
||||
oss << "BIT" << dec << id << " " << sLabel->GetText()->Data() << " " << sPlot->IsOn() << hex << " " << fColorSel->GetColor() << endl;
|
||||
return oss.str();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
int ctbSignal::setOutput(Long64_t r) {
|
||||
|
||||
|
||||
// cout << hex << r << dec <<endl;
|
||||
|
||||
Long64_t mask=((Long64_t)1<<id);
|
||||
|
||||
if (r&mask)
|
||||
sOutput->SetOn(kTRUE,kTRUE);
|
||||
else
|
||||
sOutput->SetOn(kFALSE,kTRUE);
|
||||
|
||||
return sOutput->IsOn();
|
||||
|
||||
}
|
||||
|
||||
int ctbSignal::fixOutput(int i) {
|
||||
|
||||
if (i) {
|
||||
sPlot->SetOn(kFALSE);
|
||||
//sClock->SetOn(kFALSE,kTRUE);
|
||||
sOutput->SetOn(kTRUE);
|
||||
// sPlot->SetEnabled(kFALSE);
|
||||
// sClock->SetEnabled(kTRUE);
|
||||
} else {
|
||||
sOutput->SetOn(kFALSE,kTRUE);
|
||||
// sClock->SetOn(kFALSE);
|
||||
// sClock->SetEnabled(kFALSE);
|
||||
sPlot->SetEnabled(kTRUE);
|
||||
}
|
||||
sOutput->SetEnabled(kFALSE);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int ctbSignal::setDbitList(Long64_t r) {
|
||||
|
||||
if (r)
|
||||
sDbitList->SetOn(kTRUE,kFALSE);
|
||||
else
|
||||
sDbitList->SetOn(kFALSE,kFALSE);
|
||||
|
||||
return sDbitList->IsOn();
|
||||
|
||||
}
|
||||
|
||||
int ctbSignal::isDbitList() { return sDbitList->IsOn();}
|
||||
int ctbSignal::isOutput() { return sOutput->IsOn();}
|
||||
int ctbSignal::isPlot() { return sPlot->IsOn();}
|
||||
Pixel_t ctbSignal::getColor(){return fColorSel->GetColor();}
|
||||
|
||||
void ctbSignal::ToggledOutput(Bool_t b) {
|
||||
ToggledSignalOutput(id);
|
||||
if (b) {
|
||||
// sClock->SetEnabled(kTRUE);
|
||||
sPlot->SetOn(kFALSE);
|
||||
// sPlot->SetEnabled(kFALSE);
|
||||
fColorSel->SetEnabled(kFALSE);
|
||||
} else {
|
||||
// sClock->SetEnabled(kFALSE);
|
||||
// sClock->SetOn(kFALSE);
|
||||
sPlot->SetEnabled(kTRUE);
|
||||
if ( sPlot->IsOn())
|
||||
fColorSel->SetEnabled(kFALSE);
|
||||
else
|
||||
fColorSel->SetEnabled(kTRUE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ctbSignal::ToggledDbitList(Bool_t b){
|
||||
Long_t mask=id;
|
||||
ToggledSignalDbitList(mask);
|
||||
}
|
||||
|
||||
|
||||
void ctbSignal::ToggledPlot(Bool_t b){
|
||||
Long_t mask=b<<id;
|
||||
ToggledSignalPlot(mask);
|
||||
fColorSel->SetEnabled(b);
|
||||
}
|
||||
|
||||
void ctbSignal::ColorChanged(Pixel_t p){
|
||||
ToggledSignalPlot(id);
|
||||
}
|
||||
|
||||
|
||||
void ctbSignal::ToggledSignalOutput(Int_t b) {
|
||||
cout << "Toggle signal " << id << " " << b << " " << sOutput->IsOn() <<endl;;
|
||||
Emit("ToggledSignalOutput(Int_t)", id);
|
||||
}
|
||||
|
||||
void ctbSignal::ToggledSignalDbitList(Int_t b){
|
||||
cout << "Toggle dbitlist " << id << " " << b << endl;;
|
||||
Emit("ToggledSignalDbitList(Int_t)", id);
|
||||
}
|
||||
|
||||
void ctbSignal::ToggledSignalPlot(Int_t b){
|
||||
Emit("ToggledSignalPlot(Int_t)", id);
|
||||
}
|
||||
|
||||
|
||||
ctbSignals::ctbSignals(TGVerticalFrame *page, sls::Detector *det)
|
||||
: TGGroupFrame(page,"IO Signals",kVerticalFrame), myDet(det) {
|
||||
|
||||
|
||||
SetTitlePos(TGGroupFrame::kLeft);
|
||||
page->AddFrame(this,new TGLayoutHints( kLHintsTop | kLHintsExpandX , 10,10,10,10));
|
||||
MapWindow();
|
||||
|
||||
|
||||
TGHorizontalFrame *hframe;
|
||||
|
||||
TGHorizontalFrame* hhframe=new TGHorizontalFrame(this, 800,800);
|
||||
AddFrame(hhframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
hhframe->MapWindow();
|
||||
|
||||
TGVerticalFrame *vframe;
|
||||
|
||||
|
||||
|
||||
|
||||
int idac=0;
|
||||
for (idac=0; idac<NSIGNALS; idac++) {
|
||||
if (idac%((NSIGNALS+2)/2)==0) {
|
||||
vframe=new TGVerticalFrame(hhframe, 400,800);
|
||||
hhframe->AddFrame(vframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
vframe->MapWindow();
|
||||
}
|
||||
|
||||
|
||||
signals[idac]=new ctbSignal(vframe,idac,myDet);
|
||||
signals[idac]->Connect("ToggledSignalOutput(Int_t)","ctbSignals",this,"ToggledOutReg(Int_t)");
|
||||
signals[idac]->Connect("ToggledSignalDbitList(Int_t)","ctbSignals",this,"ToggledDbitList(Int_t)");
|
||||
signals[idac]->Connect("ToggledSignalPlot(Int_t)","ctbSignals",this,"ToggledPlot(Int_t)");
|
||||
|
||||
vframe->AddFrame(signals[idac],new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
signals[idac]->MapWindow();
|
||||
|
||||
|
||||
}
|
||||
|
||||
hframe=new TGHorizontalFrame(vframe, 800,50);
|
||||
vframe->AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
hframe->MapWindow();
|
||||
|
||||
|
||||
TGLabel *label= new TGLabel(hframe, "IO Control Register: ");
|
||||
hframe->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
|
||||
label->MapWindow();
|
||||
label->SetTextJustify(kTextLeft);
|
||||
|
||||
|
||||
eIOCntrlRegister = new TGNumberEntry(hframe, 0, 16,999, TGNumberFormat::kNESHex,
|
||||
TGNumberFormat::kNEANonNegative,
|
||||
TGNumberFormat::kNELNoLimits);
|
||||
|
||||
hframe->AddFrame(eIOCntrlRegister,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
|
||||
eIOCntrlRegister->MapWindow();
|
||||
eIOCntrlRegister->Resize(150,30);
|
||||
|
||||
|
||||
|
||||
|
||||
hframe=new TGHorizontalFrame(vframe, 800,50);
|
||||
vframe->AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
hframe->MapWindow();
|
||||
|
||||
|
||||
label= new TGLabel(hframe, "DBit Offset: ");
|
||||
hframe->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
|
||||
label->MapWindow();
|
||||
label->SetTextJustify(kTextLeft);
|
||||
|
||||
|
||||
eDbitOffset = new TGNumberEntry(hframe, 0, 9,999, TGNumberFormat::kNESInteger,
|
||||
TGNumberFormat::kNEANonNegative,
|
||||
TGNumberFormat::kNELNoLimits);
|
||||
|
||||
hframe->AddFrame(eDbitOffset,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
|
||||
eDbitOffset->MapWindow();
|
||||
eDbitOffset->Resize(150,30);
|
||||
|
||||
|
||||
TGTextEntry *e= eDbitOffset->TGNumberEntry::GetNumberEntry();
|
||||
e->Connect("ReturnPressed()","ctbSignals",this,"setDbitOffset()");
|
||||
|
||||
e->Connect("ValueSet(Long_t)","ctbSignals",this,"setDbitOffset(Long_t)");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int ctbSignals::setSignalAlias(string line) {
|
||||
|
||||
int is=-1, plot=0, col=-1;
|
||||
char tit[100];
|
||||
int narg=sscanf(line.c_str(),"BIT%d %s %d %d",&is,tit,&plot,&col);
|
||||
if (narg<2)
|
||||
return -1;
|
||||
if (is>=0 && is<NIOSIGNALS) {
|
||||
signals[is]->setSignalAlias(tit,plot,col);
|
||||
}
|
||||
return is;
|
||||
|
||||
}
|
||||
|
||||
string ctbSignals::getSignalAlias() {
|
||||
|
||||
ostringstream oss;
|
||||
for (int is=0; is<NIOSIGNALS; is++)
|
||||
oss << signals[is]->getSignalAlias() << endl;
|
||||
|
||||
|
||||
return oss.str();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ctbSignals::update() {
|
||||
try {
|
||||
|
||||
Long64_t oreg = static_cast<Long64_t>(myDet->getPatternIOControl().tsquash("Different values"));
|
||||
cout << hex << oreg << dec << endl;
|
||||
|
||||
for (int idac=0; idac<NIOSIGNALS; idac++) {
|
||||
signals[idac]->setOutput(oreg);
|
||||
}
|
||||
|
||||
} CATCH_DISPLAY ("Could not get patternIOcontrol.", "ctbSignals::update")
|
||||
|
||||
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
|
||||
// enable all
|
||||
for (int is=0; is<64; is++) {
|
||||
signals[is]->setDbitList(1);
|
||||
}
|
||||
eDbitOffset->SetNumber(0);
|
||||
}
|
||||
|
||||
// ctb
|
||||
else {
|
||||
try {
|
||||
|
||||
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
|
||||
// enable all
|
||||
if (dbitlist.empty()) {
|
||||
for (int is=0; is<64; is++) {
|
||||
signals[is]->setDbitList(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// disable all
|
||||
for (int is=0; is<64; is++) {
|
||||
signals[is]->setDbitList(0);
|
||||
}
|
||||
// enable selected
|
||||
for (const auto &value : dbitlist) {
|
||||
signals[value]->setDbitList(1);
|
||||
}
|
||||
}
|
||||
|
||||
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbSignals::update")
|
||||
|
||||
try {
|
||||
auto val = myDet->getRxDbitOffset().tsquash("Different values");
|
||||
eDbitOffset->SetNumber(val);
|
||||
} CATCH_DISPLAY ("Could not get receiver dbit offset.", "ctbSignals::update")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string ctbSignals::getSignalParameters() {
|
||||
|
||||
try {
|
||||
|
||||
auto val = myDet->getPatternIOControl().tsquash("Different values");
|
||||
ostringstream line;
|
||||
line << "patioctrl " << hex << val << dec << endl;
|
||||
return line.str();
|
||||
|
||||
} CATCH_DISPLAY ("Could not get patternIOcontrol.", "ctbSignals::getSignalParameters")
|
||||
|
||||
return ("");
|
||||
}
|
||||
|
||||
void ctbSignals::ToggledOutReg(Int_t mask) {
|
||||
try {
|
||||
|
||||
Long64_t oreg = static_cast<Long64_t>(myDet->getPatternIOControl().tsquash("Different values"));
|
||||
Long64_t m=((Long64_t)1)<<mask;
|
||||
cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg;
|
||||
|
||||
if (signals[mask]->isOutput()) {
|
||||
cout << " or " << m ;
|
||||
oreg|=m;
|
||||
} else {
|
||||
cout << " not " << ~m ;
|
||||
oreg&=~m;
|
||||
}
|
||||
cout << " after " << oreg << endl;
|
||||
|
||||
myDet->setPatternIOControl(static_cast<uint64_t>(oreg));
|
||||
oreg = static_cast<Long64_t>(myDet->getPatternIOControl().tsquash("Different values"));
|
||||
cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg << endl;
|
||||
|
||||
eIOCntrlRegister->SetText(to_string(oreg).c_str());
|
||||
|
||||
} CATCH_DISPLAY ("Could not get/set patternIOcontrol.", "ctbSignals::ToggledOutReg")
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctbSignals::ToggledDbitList(Int_t mask){
|
||||
try {
|
||||
|
||||
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
|
||||
|
||||
// anyway all enabled
|
||||
if ((dbitlist.empty()) && (signals[mask]->isDbitList())) {
|
||||
;
|
||||
}
|
||||
// set the dbitlist
|
||||
else {
|
||||
std::vector <int> new_dbitlist;
|
||||
for (int is=0; is<64; is++) {
|
||||
if (signals[is]->isDbitList()){
|
||||
new_dbitlist.push_back(is);
|
||||
cout << is << " " << new_dbitlist.size() - 1 << endl;
|
||||
}
|
||||
}
|
||||
if (new_dbitlist.size() > 64)
|
||||
new_dbitlist.clear();
|
||||
myDet->setRxDbitList(new_dbitlist);
|
||||
// get list again
|
||||
dbitlist = myDet->getRxDbitList().tsquash("Different values");
|
||||
}
|
||||
|
||||
// enable all
|
||||
if (dbitlist.empty()) {
|
||||
for (int is=0; is<64; is++) {
|
||||
signals[is]->setDbitList(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// disable all
|
||||
for (int is=0; is<64; is++) {
|
||||
signals[is]->setDbitList(0);
|
||||
}
|
||||
// enable selected
|
||||
for (const auto &value : dbitlist) {
|
||||
signals[value]->setDbitList(1);
|
||||
}
|
||||
}
|
||||
|
||||
} CATCH_DISPLAY ("Could not get/set receiver dbit list.", "ctbSignals::ToggledDbitList")
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ctbSignals::ToggledPlot(Int_t b) {
|
||||
|
||||
Emit("ToggledSignalPlot(Int_t)", b);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ctbSignals::ToggledSignalPlot(Int_t b) {
|
||||
|
||||
Emit("ToggledSignalPlot(Int_t)", b);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Pixel_t ctbSignals::getColor(int i){
|
||||
if (i>=0 && i<NSIGNALS)
|
||||
return signals[i]->getColor();
|
||||
return static_cast<Pixel_t>(-1);
|
||||
}
|
||||
|
||||
int ctbSignals::getPlot(int i){
|
||||
if (i>=0 && i<NSIGNALS)
|
||||
return signals[i]->isPlot();
|
||||
return -1;
|
||||
};
|
||||
|
||||
void ctbSignals::setDbitOffset(Long_t) {
|
||||
setDbitOffset();
|
||||
}
|
||||
|
||||
void ctbSignals::setDbitOffset(){
|
||||
try {
|
||||
myDet->setRxDbitOffset(eDbitOffset->GetNumber());
|
||||
} CATCH_DISPLAY ("Could not set receiver dbit offset.", "ctbSignals::setDbitOffset")
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef CTBSIGNALS_H
|
||||
#define CTBSIGNALS_H
|
||||
#include <TGFrame.h>
|
||||
|
||||
|
||||
#define NSIGNALS 64
|
||||
|
||||
#define NIOSIGNALS 64 //for moench board was 52
|
||||
|
||||
|
||||
#define ADCLATCH 63
|
||||
#define DIGSIGLATCH 62
|
||||
|
||||
|
||||
|
||||
|
||||
class TGTextEntry;
|
||||
class TGLabel;
|
||||
class TGNumberEntry;
|
||||
class TGCheckButton;
|
||||
class TH1I;
|
||||
class TGTextButton;
|
||||
class TGColorSelect;
|
||||
|
||||
|
||||
|
||||
class TGNumberEntry;
|
||||
namespace sls
|
||||
{
|
||||
class Detector;
|
||||
};
|
||||
class ctbSignal;
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
class ctbSignal : public TGHorizontalFrame {
|
||||
|
||||
// RQ_OBJECT("ctbSignal")
|
||||
|
||||
private:
|
||||
|
||||
TGLabel *sLabel;
|
||||
TGCheckButton *sOutput;
|
||||
TGCheckButton *sDbitList;
|
||||
TGCheckButton *sPlot;
|
||||
TGLabel *sValue;
|
||||
TGNumberEntry *sEntry;
|
||||
TGColorSelect *fColorSel;
|
||||
|
||||
sls::Detector *myDet;
|
||||
Int_t id;
|
||||
|
||||
TH1I *hsig;
|
||||
|
||||
public:
|
||||
|
||||
ctbSignal(TGFrame *page, int i, sls::Detector *det);
|
||||
int setSignalAlias(char *tit, int plot, int col);
|
||||
string getSignalAlias();
|
||||
|
||||
TH1I *getPlot() {return hsig;};
|
||||
int setOutput(Long64_t);
|
||||
int fixOutput(int);
|
||||
int setDbitList(Long64_t);
|
||||
|
||||
void ToggledOutput(Bool_t);
|
||||
void ToggledDbitList(Bool_t);
|
||||
void ToggledPlot(Bool_t);
|
||||
void ColorChanged(Pixel_t);
|
||||
|
||||
int isDbitList();
|
||||
int isOutput();
|
||||
int isPlot();
|
||||
Pixel_t getColor();
|
||||
|
||||
|
||||
void ToggledSignalOutput(Int_t); //*SIGNAL*
|
||||
void ToggledSignalDbitList(Int_t); //*SIGNAL*
|
||||
void ToggledSignalPlot(Int_t); //*SIGNAL*
|
||||
|
||||
|
||||
|
||||
ClassDef(ctbSignal,0)
|
||||
};
|
||||
|
||||
class ctbSignals : public TGGroupFrame {
|
||||
private:
|
||||
|
||||
ctbSignal *signals[NSIGNALS];
|
||||
|
||||
TGNumberEntry *eIOCntrlRegister;
|
||||
TGNumberEntry *eDbitOffset;
|
||||
|
||||
sls::Detector *myDet;
|
||||
|
||||
public:
|
||||
ctbSignals(TGVerticalFrame *page, sls::Detector *det);
|
||||
int setSignalAlias(string line);
|
||||
string getSignalAlias();
|
||||
|
||||
int getPlot(int);
|
||||
Pixel_t getColor(int);
|
||||
|
||||
void update();
|
||||
// void saveParameters();
|
||||
string getSignalParameters();
|
||||
|
||||
//void setDbitList(Int_t);
|
||||
void setDbitOffset(Long_t);
|
||||
void setDbitOffset();
|
||||
|
||||
void ToggledOutReg(Int_t);
|
||||
void ToggledDbitList(Int_t);
|
||||
void ToggledPlot(Int_t);
|
||||
void ToggledSignalPlot(Int_t); //*SIGNAL*
|
||||
|
||||
ClassDef(ctbSignals,0)
|
||||
};
|
||||
|
||||
#endif
|
@ -1,184 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <TGTextEntry.h>
|
||||
#include <TGLabel.h>
|
||||
#include <TGNumberEntry.h>
|
||||
#include <TGButton.h>
|
||||
|
||||
#include "ctbSlowAdcs.h"
|
||||
#include "ctbDefs.h"
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
|
||||
ctbSlowAdc::ctbSlowAdc(TGGroupFrame *page, int idac, sls::Detector *det) : TGHorizontalFrame(page, 800,50) , id(idac), myDet(det) {
|
||||
|
||||
|
||||
TGHorizontalFrame *hframe=this;
|
||||
|
||||
page->AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
|
||||
MapWindow();
|
||||
|
||||
char tit[100];
|
||||
|
||||
|
||||
sprintf(tit, "SENSE %d:",idac-1000);
|
||||
|
||||
dacsLabel= new TGLabel(hframe, tit);// new TGLabel(hframe, tit);
|
||||
|
||||
|
||||
|
||||
hframe->AddFrame(dacsLabel,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 5, 5, 5, 5));
|
||||
dacsLabel->MapWindow();
|
||||
dacsLabel->SetTextJustify(kTextLeft);
|
||||
|
||||
|
||||
|
||||
|
||||
sprintf(tit, "xxx");
|
||||
dacsValue= new TGLabel(hframe, tit);
|
||||
hframe->AddFrame( dacsValue,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 5, 5, 5, 5));
|
||||
dacsValue->MapWindow();
|
||||
dacsValue->SetTextJustify(kTextLeft);
|
||||
|
||||
|
||||
|
||||
TGTextButton *b= new TGTextButton(hframe, "Update");
|
||||
hframe->AddFrame( b,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 5, 5, 5, 5));
|
||||
b->MapWindow();
|
||||
b->SetTextJustify(kTextLeft);
|
||||
|
||||
b->Connect("Clicked()","ctbSlowAdc",this,"getValue()");
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ctbSlowAdc::setLabel(char *tit) {
|
||||
if(tit)
|
||||
dacsLabel->SetText(tit);
|
||||
|
||||
return id;
|
||||
|
||||
}
|
||||
|
||||
string ctbSlowAdc::getLabel() {
|
||||
ostringstream line;
|
||||
line << dacsLabel->GetText() << endl;
|
||||
|
||||
// line << "DAC" << dec << id << " " << dacsUnit->IsOn() << endl;
|
||||
|
||||
return line.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ctbSlowAdc::getValue() {
|
||||
try {
|
||||
std::string s;
|
||||
|
||||
// temp
|
||||
if (id == static_cast<int>(slsDetectorDefs::SLOW_ADC_TEMP)) {
|
||||
|
||||
int val = myDet->getTemperature(static_cast<slsDetectorDefs::dacIndex>(id)).tsquash("Different values");
|
||||
cout << "slow adc temp" << " " << val << endl;
|
||||
|
||||
s = to_string(val) + " " + to_string(0x00b0) + "C";//<2F>C
|
||||
dacsValue->SetText(s.c_str());
|
||||
return val;
|
||||
}
|
||||
|
||||
// mv
|
||||
else {
|
||||
|
||||
int val = myDet->getSlowADC(static_cast<slsDetectorDefs::dacIndex>(id)).tsquash("Different values");
|
||||
cout << "slow adc " << id << " " << val << endl;
|
||||
|
||||
s = to_string(val) + " mV";
|
||||
dacsValue->SetText(s.c_str());
|
||||
return val;
|
||||
}
|
||||
|
||||
} CATCH_DISPLAY ("Could not get slow dac " + to_string(id) + ".", "ctbSlowAdc::getValue")
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ctbSlowAdcs::ctbSlowAdcs(TGVerticalFrame *page, sls::Detector *det) : TGGroupFrame(page,"Sense",kVerticalFrame) , myDet(det){
|
||||
|
||||
SetTitlePos(TGGroupFrame::kLeft);
|
||||
page->AddFrame(this,new TGLayoutHints( kLHintsTop | kLHintsExpandX , 10,10,10,10));
|
||||
MapWindow();
|
||||
|
||||
// cout << "window mapped " << endl;
|
||||
|
||||
|
||||
for (int idac=0; idac<NSLOWADCS + 1; idac++) {
|
||||
|
||||
adcs[idac]=new ctbSlowAdc(this, idac+1000, myDet);
|
||||
|
||||
}
|
||||
adcs[NSLOWADCS]->setLabel((char*)"Temperature");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int ctbSlowAdcs::setSlowAdcAlias(string line) {
|
||||
|
||||
int is=-1, mv=0;
|
||||
char tit[100];
|
||||
int narg=sscanf(line.c_str(),"SENSE%d %s %d",&is,tit,&mv);
|
||||
if (narg<2)
|
||||
return -1;
|
||||
if (is>=0 && is<NSLOWADCS)
|
||||
adcs[is]->setLabel(tit);
|
||||
return is;
|
||||
|
||||
}
|
||||
|
||||
string ctbSlowAdcs::getSlowAdcAlias() {
|
||||
|
||||
ostringstream line;
|
||||
|
||||
for (int i=0; i<NSLOWADCS; i++)
|
||||
line << adcs[i]->getLabel() << endl;
|
||||
return line.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ctbSlowAdcs::getAdcParameters() {
|
||||
|
||||
ostringstream line;
|
||||
|
||||
for (int i=0; i<NSLOWADCS; i++) {
|
||||
//line << "dacs:" << i << " " << dacs[i]->getValue << endl;
|
||||
line << "adc:" << i << " " << adcs[i]->getValue() << endl;
|
||||
}
|
||||
line << "adc:-1" << adcs[NSLOWADCS]->getValue() << endl;
|
||||
return line.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ctbSlowAdcs::update() {
|
||||
for (int idac=0; idac<NSLOWADCS+1; idac++) {
|
||||
adcs[idac]->getValue();
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
|
||||
#ifndef CTBSLOWADCS_H
|
||||
#define CTBSLOWADCS_H
|
||||
#include <TGFrame.h>
|
||||
|
||||
|
||||
//#define NDACS 16
|
||||
#define NSLOWADCS 8
|
||||
|
||||
|
||||
|
||||
|
||||
class TGTextEntry;
|
||||
class TGLabel;
|
||||
class TGNumberEntry;
|
||||
class TGCheckButton;
|
||||
class TGTextButton;
|
||||
|
||||
|
||||
|
||||
namespace sls
|
||||
{
|
||||
class Detector;
|
||||
};
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
class ctbSlowAdc : public TGHorizontalFrame {
|
||||
|
||||
|
||||
protected:
|
||||
// TGLabel *dacsLabel;
|
||||
// TGNumberEntry *dacsEntry;
|
||||
// TGCheckButton *dacsUnit;
|
||||
TGLabel *dacsLabel;
|
||||
TGLabel *dacsValue;
|
||||
int id;
|
||||
|
||||
sls::Detector* myDet;
|
||||
public:
|
||||
ctbSlowAdc(TGGroupFrame*, int , sls::Detector*);
|
||||
int getValue();
|
||||
|
||||
int setLabel(char *tit);
|
||||
string getLabel();
|
||||
|
||||
|
||||
|
||||
ClassDef(ctbSlowAdc,0)
|
||||
};
|
||||
|
||||
|
||||
class ctbSlowAdcs : public TGGroupFrame {
|
||||
private:
|
||||
|
||||
|
||||
|
||||
ctbSlowAdc *adcs[NSLOWADCS+1];
|
||||
|
||||
sls::Detector* myDet;
|
||||
|
||||
public:
|
||||
ctbSlowAdcs(TGVerticalFrame *page, sls::Detector*);
|
||||
|
||||
int setSlowAdcAlias(string line);
|
||||
// int setDacAlias(string line);
|
||||
string getSlowAdcAlias();
|
||||
string getAdcParameters();
|
||||
|
||||
void update();
|
||||
|
||||
ClassDef(ctbSlowAdcs,0)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -58,6 +58,12 @@ set(SPHINX_SOURCE_FILES
|
||||
src/udpheader.rst
|
||||
src/udpconfig.rst
|
||||
src/udpdetspec.rst
|
||||
src/fileformat.rst
|
||||
src/slsreceiverheaderformat.rst
|
||||
src/masterfileattributes.rst
|
||||
src/binaryfileformat.rst
|
||||
src/hdf5fileformat.rst
|
||||
src/zmqjsonheaderformat.rst
|
||||
)
|
||||
|
||||
foreach(filename ${SPHINX_SOURCE_FILES})
|
||||
|
@ -890,7 +890,7 @@ EXCLUDE_SYMLINKS = NO
|
||||
# Note that the wildcards are matched against the file with absolute path, so to
|
||||
# exclude all test directories for example use the pattern */test/*
|
||||
|
||||
EXCLUDE_PATTERNS = */docs/* */tests/* */python/* */manual */slsDetectorServers/* */libs/* */integrationTests *README* */slsDetectorGui/* */ctbGui/* */slsDetectorCalibration/*
|
||||
EXCLUDE_PATTERNS = */docs/* */tests/* */python/* */manual */slsDetectorServers/* */libs/* */integrationTests *README* */slsDetectorGui/* */ctbGui/* */slsDetectorCalibration/* *TobiSchluter*
|
||||
|
||||
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
||||
# (namespaces, classes, functions, etc.) that should be excluded from the
|
||||
|
438
docs/src/binaryfileformat.rst
Normal file
438
docs/src/binaryfileformat.rst
Normal file
@ -0,0 +1,438 @@
|
||||
Binary File Format
|
||||
====================
|
||||
|
||||
This is the default file format that can be configured using command `fformat <commandline.html#term-fformat-binary-hdf5>`_.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sls_detector_put fformat binary
|
||||
|
||||
|
||||
Master File
|
||||
--------------
|
||||
|
||||
* File Name: [fpath]/[fname]_master_[findex].json :ref:`Details here<file name format>`
|
||||
|
||||
* It is in json format and created for every acquisition.
|
||||
|
||||
* It contains :ref:`attributes<master file attributes>` relevant to the acquisition. This can vary with detector type shown in :ref:`master json file examples <json master file examples>` here.
|
||||
|
||||
* It shows the :ref:`**SLS Receiver Header** <sls receiver header format>` format used in data files.
|
||||
|
||||
* Enabled/disabled using command `fmaster <commandline.html#term-fmaster-0-1>`_.
|
||||
|
||||
|
||||
Data File
|
||||
----------
|
||||
|
||||
* File Name: [fpath]/[fname]_dx_fy_[findex].raw :ref:`Details here<file name format>`
|
||||
|
||||
* It store multiple frames sequentially, with total number of frames determined by `rx_framesperfile <commandline.html#term-rx_framesperfile-n_frames>`_ parameter.
|
||||
|
||||
* Each frame includes a :ref:`**sls_receiver_header** <sls receiver header format>` structure, followed by the actual frame data.
|
||||
|
||||
|
||||
|
||||
.. _json master file examples:
|
||||
|
||||
JSON Master File Examples
|
||||
---------------------------------------------------
|
||||
|
||||
Eiger
|
||||
^^^^^
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
{
|
||||
"Version": 7.2,
|
||||
"Timestamp": "Wed Nov 13 15:46:30 2024",
|
||||
"Detector Type": "Eiger",
|
||||
"Timing Mode": "auto",
|
||||
"Geometry": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"Image Size in bytes": 262144,
|
||||
"Pixels": {
|
||||
"x": 512,
|
||||
"y": 256
|
||||
},
|
||||
"Max Frames Per File": 10000,
|
||||
"Frame Discard Policy": "nodiscard",
|
||||
"Frame Padding": 1,
|
||||
"Scan Parameters": "[disabled]",
|
||||
"Total Frames": 1,
|
||||
"Receiver Roi": {
|
||||
"xmin": 4294967295,
|
||||
"xmax": 4294967295,
|
||||
"ymin": 4294967295,
|
||||
"ymax": 4294967295
|
||||
},
|
||||
"Dynamic Range": 16,
|
||||
"Ten Giga": 0,
|
||||
"Exptime": "1s",
|
||||
"Period": "1s",
|
||||
"Threshold Energy": -1,
|
||||
"Sub Exptime": "2.62144ms",
|
||||
"Sub Period": "2.62144ms",
|
||||
"Quad": 0,
|
||||
"Number of rows": 256,
|
||||
"Rate Corrections": "[0]",
|
||||
"Frames in File": 1,
|
||||
"Frame Header Format": {
|
||||
"Frame Number": "8 bytes",
|
||||
"SubFrame Number/ExpLength": "4 bytes",
|
||||
"Packet Number": "4 bytes",
|
||||
"Bunch ID": "8 bytes",
|
||||
"Timestamp": "8 bytes",
|
||||
"Module Id": "2 bytes",
|
||||
"Row": "2 bytes",
|
||||
"Column": "2 bytes",
|
||||
"Reserved": "2 bytes",
|
||||
"Debug": "4 bytes",
|
||||
"Round Robin Number": "2 bytes",
|
||||
"Detector Type": "1 byte",
|
||||
"Header Version": "1 byte",
|
||||
"Packets Caught Mask": "64 bytes"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Jungfrau
|
||||
^^^^^^^^
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
{
|
||||
"Version": 7.2,
|
||||
"Timestamp": "Wed Nov 13 13:03:53 2024",
|
||||
"Detector Type": "Jungfrau",
|
||||
"Timing Mode": "auto",
|
||||
"Geometry": {
|
||||
"x": 1,
|
||||
"y": 1
|
||||
},
|
||||
"Image Size in bytes": 1048576,
|
||||
"Pixels": {
|
||||
"x": 1024,
|
||||
"y": 512
|
||||
},
|
||||
"Max Frames Per File": 10000,
|
||||
"Frame Discard Policy": "nodiscard",
|
||||
"Frame Padding": 1,
|
||||
"Scan Parameters": "[disabled]",
|
||||
"Total Frames": 1000,
|
||||
"Receiver Roi": {
|
||||
"xmin": 4294967295,
|
||||
"xmax": 4294967295,
|
||||
"ymin": 4294967295,
|
||||
"ymax": 4294967295
|
||||
},
|
||||
"Exptime": "10us",
|
||||
"Period": "2ms",
|
||||
"Number of UDP Interfaces": 1,
|
||||
"Number of rows": 512,
|
||||
"Frames in File": 10,
|
||||
"Frame Header Format": {
|
||||
"Frame Number": "8 bytes",
|
||||
"SubFrame Number/ExpLength": "4 bytes",
|
||||
"Packet Number": "4 bytes",
|
||||
"Bunch ID": "8 bytes",
|
||||
"Timestamp": "8 bytes",
|
||||
"Module Id": "2 bytes",
|
||||
"Row": "2 bytes",
|
||||
"Column": "2 bytes",
|
||||
"Reserved": "2 bytes",
|
||||
"Debug": "4 bytes",
|
||||
"Round Robin Number": "2 bytes",
|
||||
"Detector Type": "1 byte",
|
||||
"Header Version": "1 byte",
|
||||
"Packets Caught Mask": "64 bytes"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Gotthard2
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
{
|
||||
"Version": 7.2,
|
||||
"Timestamp": "Wed Nov 13 14:18:17 2024",
|
||||
"Detector Type": "Gotthard2",
|
||||
"Timing Mode": "auto",
|
||||
"Geometry": {
|
||||
"x": 1,
|
||||
"y": 1
|
||||
},
|
||||
"Image Size in bytes": 2560,
|
||||
"Pixels": {
|
||||
"x": 1280,
|
||||
"y": 1
|
||||
},
|
||||
"Max Frames Per File": 20000,
|
||||
"Frame Discard Policy": "nodiscard",
|
||||
"Frame Padding": 1,
|
||||
"Scan Parameters": "[disabled]",
|
||||
"Total Frames": 10,
|
||||
"Receiver Roi": {
|
||||
"xmin": 4294967295,
|
||||
"xmax": 4294967295,
|
||||
"ymin": 4294967295,
|
||||
"ymax": 4294967295
|
||||
},
|
||||
"Exptime": "0ns",
|
||||
"Period": "0ns",
|
||||
"Burst Mode": "burst_internal",
|
||||
"Frames in File": 10,
|
||||
"Frame Header Format": {
|
||||
"Frame Number": "8 bytes",
|
||||
"SubFrame Number/ExpLength": "4 bytes",
|
||||
"Packet Number": "4 bytes",
|
||||
"Bunch ID": "8 bytes",
|
||||
"Timestamp": "8 bytes",
|
||||
"Module Id": "2 bytes",
|
||||
"Row": "2 bytes",
|
||||
"Column": "2 bytes",
|
||||
"Reserved": "2 bytes",
|
||||
"Debug": "4 bytes",
|
||||
"Round Robin Number": "2 bytes",
|
||||
"Detector Type": "1 byte",
|
||||
"Header Version": "1 byte",
|
||||
"Packets Caught Mask": "64 bytes"
|
||||
}
|
||||
}
|
||||
|
||||
Mythen3
|
||||
^^^^^^^
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
{
|
||||
"Version": 7.2,
|
||||
"Timestamp": "Wed Nov 13 14:39:14 2024",
|
||||
"Detector Type": "Mythen3",
|
||||
"Timing Mode": "auto",
|
||||
"Geometry": {
|
||||
"x": 1,
|
||||
"y": 1
|
||||
},
|
||||
"Image Size in bytes": 15360,
|
||||
"Pixels": {
|
||||
"x": 3840,
|
||||
"y": 1
|
||||
},
|
||||
"Max Frames Per File": 10000,
|
||||
"Frame Discard Policy": "nodiscard",
|
||||
"Frame Padding": 1,
|
||||
"Scan Parameters": "[disabled]",
|
||||
"Total Frames": 1,
|
||||
"Receiver Roi": {
|
||||
"xmin": 4294967295,
|
||||
"xmax": 4294967295,
|
||||
"ymin": 4294967295,
|
||||
"ymax": 4294967295
|
||||
},
|
||||
"Dynamic Range": 32,
|
||||
"Ten Giga": 1,
|
||||
"Period": "2ms",
|
||||
"Counter Mask": "0x7",
|
||||
"Exptime1": "0.1s",
|
||||
"Exptime2": "0.1s",
|
||||
"Exptime3": "0.1s",
|
||||
"GateDelay1": "0ns",
|
||||
"GateDelay2": "0ns",
|
||||
"GateDelay3": "0ns",
|
||||
"Gates": 1,
|
||||
"Threshold Energies": "[-1, -1, -1]",
|
||||
"Frames in File": 1,
|
||||
"Frame Header Format": {
|
||||
"Frame Number": "8 bytes",
|
||||
"SubFrame Number/ExpLength": "4 bytes",
|
||||
"Packet Number": "4 bytes",
|
||||
"Bunch ID": "8 bytes",
|
||||
"Timestamp": "8 bytes",
|
||||
"Module Id": "2 bytes",
|
||||
"Row": "2 bytes",
|
||||
"Column": "2 bytes",
|
||||
"Reserved": "2 bytes",
|
||||
"Debug": "4 bytes",
|
||||
"Round Robin Number": "2 bytes",
|
||||
"Detector Type": "1 byte",
|
||||
"Header Version": "1 byte",
|
||||
"Packets Caught Mask": "64 bytes"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Moench
|
||||
^^^^^^
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
{
|
||||
"Version": 7.2,
|
||||
"Timestamp": "Wed Nov 13 14:41:32 2024",
|
||||
"Detector Type": "Moench",
|
||||
"Timing Mode": "auto",
|
||||
"Geometry": {
|
||||
"x": 1,
|
||||
"y": 1
|
||||
},
|
||||
"Image Size in bytes": 320000,
|
||||
"Pixels": {
|
||||
"x": 400,
|
||||
"y": 400
|
||||
},
|
||||
"Max Frames Per File": 100000,
|
||||
"Frame Discard Policy": "discardpartial",
|
||||
"Frame Padding": 1,
|
||||
"Scan Parameters": "[disabled]",
|
||||
"Total Frames": 1,
|
||||
"Receiver Roi": {
|
||||
"xmin": 4294967295,
|
||||
"xmax": 4294967295,
|
||||
"ymin": 4294967295,
|
||||
"ymax": 4294967295
|
||||
},
|
||||
"Exptime": "10us",
|
||||
"Period": "2ms",
|
||||
"Number of UDP Interfaces": 1,
|
||||
"Number of rows": 400,
|
||||
"Frames in File": 1,
|
||||
"Frame Header Format": {
|
||||
"Frame Number": "8 bytes",
|
||||
"SubFrame Number/ExpLength": "4 bytes",
|
||||
"Packet Number": "4 bytes",
|
||||
"Bunch ID": "8 bytes",
|
||||
"Timestamp": "8 bytes",
|
||||
"Module Id": "2 bytes",
|
||||
"Row": "2 bytes",
|
||||
"Column": "2 bytes",
|
||||
"Reserved": "2 bytes",
|
||||
"Debug": "4 bytes",
|
||||
"Round Robin Number": "2 bytes",
|
||||
"Detector Type": "1 byte",
|
||||
"Header Version": "1 byte",
|
||||
"Packets Caught Mask": "64 bytes"
|
||||
}
|
||||
}
|
||||
|
||||
Gotthard I
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
{
|
||||
"Version": 7.2,
|
||||
"Timestamp": "Wed Nov 13 15:16:19 2024",
|
||||
"Detector Type": "Gotthard",
|
||||
"Timing Mode": "auto",
|
||||
"Geometry": {
|
||||
"x": 1,
|
||||
"y": 1
|
||||
},
|
||||
"Image Size in bytes": 2560,
|
||||
"Pixels": {
|
||||
"x": 1280,
|
||||
"y": 1
|
||||
},
|
||||
"Max Frames Per File": 20000,
|
||||
"Frame Discard Policy": "nodiscard",
|
||||
"Frame Padding": 1,
|
||||
"Scan Parameters": "[disabled]",
|
||||
"Total Frames": 1,
|
||||
"Receiver Roi": {
|
||||
"xmin": 4294967295,
|
||||
"xmax": 4294967295,
|
||||
"ymin": 4294967295,
|
||||
"ymax": 4294967295
|
||||
},
|
||||
"Exptime": "1.00001ms",
|
||||
"Period": "1s",
|
||||
"Detector Roi": {
|
||||
"xmin": 4294967295,
|
||||
"xmax": 4294967295
|
||||
},
|
||||
"Frames in File": 1,
|
||||
"Frame Header Format": {
|
||||
"Frame Number": "8 bytes",
|
||||
"SubFrame Number/ExpLength": "4 bytes",
|
||||
"Packet Number": "4 bytes",
|
||||
"Bunch ID": "8 bytes",
|
||||
"Timestamp": "8 bytes",
|
||||
"Module Id": "2 bytes",
|
||||
"Row": "2 bytes",
|
||||
"Column": "2 bytes",
|
||||
"Reserved": "2 bytes",
|
||||
"Debug": "4 bytes",
|
||||
"Round Robin Number": "2 bytes",
|
||||
"Detector Type": "1 byte",
|
||||
"Header Version": "1 byte",
|
||||
"Packets Caught Mask": "64 bytes"
|
||||
}
|
||||
}
|
||||
|
||||
Chip Test Board
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
{
|
||||
"Version": 7.2,
|
||||
"Timestamp": "Wed Nov 13 15:32:59 2024",
|
||||
"Detector Type": "ChipTestBoard",
|
||||
"Timing Mode": "auto",
|
||||
"Geometry": {
|
||||
"x": 1,
|
||||
"y": 1
|
||||
},
|
||||
"Image Size in bytes": 48018,
|
||||
"Pixels": {
|
||||
"x": 3,
|
||||
"y": 1
|
||||
},
|
||||
"Max Frames Per File": 20000,
|
||||
"Frame Discard Policy": "nodiscard",
|
||||
"Frame Padding": 1,
|
||||
"Scan Parameters": "[disabled]",
|
||||
"Total Frames": 1,
|
||||
"Receiver Roi": {
|
||||
"xmin": 4294967295,
|
||||
"xmax": 4294967295,
|
||||
"ymin": 4294967295,
|
||||
"ymax": 4294967295
|
||||
},
|
||||
"Exptime": "0ns",
|
||||
"Period": "0.18s",
|
||||
"Ten Giga": 0,
|
||||
"ADC Mask": "0x2202",
|
||||
"Analog Flag": 1,
|
||||
"Analog Samples": 8003,
|
||||
"Digital Flag": 0,
|
||||
"Digital Samples": 1000,
|
||||
"Dbit Offset": 0,
|
||||
"Dbit Bitset": 0,
|
||||
"Transceiver Mask": "0x3",
|
||||
"Transceiver Flag": 0,
|
||||
"Transceiver Samples": 1,
|
||||
"Frames in File": 1,
|
||||
"Frame Header Format": {
|
||||
"Frame Number": "8 bytes",
|
||||
"SubFrame Number/ExpLength": "4 bytes",
|
||||
"Packet Number": "4 bytes",
|
||||
"Bunch ID": "8 bytes",
|
||||
"Timestamp": "8 bytes",
|
||||
"Module Id": "2 bytes",
|
||||
"Row": "2 bytes",
|
||||
"Column": "2 bytes",
|
||||
"Reserved": "2 bytes",
|
||||
"Debug": "4 bytes",
|
||||
"Round Robin Number": "2 bytes",
|
||||
"Detector Type": "1 byte",
|
||||
"Header Version": "1 byte",
|
||||
"Packets Caught Mask": "64 bytes"
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ Commands can be used either with sls_detector_get or sls_detector_put
|
||||
|
||||
.. code-block::
|
||||
|
||||
sls_detector_get vrf
|
||||
sls_detector_get exptime
|
||||
|
||||
Help
|
||||
--------
|
||||
@ -24,6 +24,16 @@ Help
|
||||
# get help for a particular command
|
||||
sls_detector_get -h fpath
|
||||
sls_detector_help fpath
|
||||
|
||||
# list of deprecated commands
|
||||
list deprecated
|
||||
|
||||
# autocompletion
|
||||
# bash_autocomplete.sh or zsh_autocomplete.sh must be sourced from the
|
||||
# main package folder to enable auto completion of commands and arguments
|
||||
# for the command line on that shell.
|
||||
source bash_autocomplete.sh
|
||||
|
||||
|
||||
|
||||
Commands
|
||||
@ -32,14 +42,14 @@ Commands
|
||||
.. include:: ../commands.rst
|
||||
|
||||
|
||||
Depreciated commands
|
||||
Deprecated commands
|
||||
------------------------
|
||||
|
||||
.. note ::
|
||||
All the dac commands are preceded with the **dac** command. Use command **daclist** to get correct list of dac command arguments for current detector.
|
||||
|
||||
.. csv-table:: Depreciated commands
|
||||
:file: ../depreciated.csv
|
||||
.. csv-table:: Deprecated commands
|
||||
:file: ../deprecated.csv
|
||||
:widths: 35, 35
|
||||
:header-rows: 1
|
||||
|
||||
|
@ -19,7 +19,7 @@ A minimal CMakeLists.txt could look like this:
|
||||
.. code-block:: cmake
|
||||
|
||||
project(myDetectorIntegration)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
add_subdirectory(slsDetectorPackage)
|
||||
|
||||
#Add your executable
|
||||
@ -43,7 +43,7 @@ should be needed, otherwise specify cmake prefix path.
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(myintegration)
|
||||
|
||||
find_package(slsDetectorPackage 5.0 REQUIRED)
|
||||
|
@ -13,24 +13,36 @@ To use the basic building blocks, meaning sls_detector_get/put and
|
||||
the shared libraries these are needed:
|
||||
|
||||
* Linux, preferably recent kernel (currently no cross platform support)
|
||||
* CMake > 3.12
|
||||
* CMake >= 3.14
|
||||
* C++11 compatible compiler. (We test with gcc and clang)
|
||||
* ZeroMQ version 4
|
||||
|
||||
-----------------------
|
||||
Python bindings
|
||||
-----------------------
|
||||
|
||||
* Python >= 3.8
|
||||
* pybind11 2.13.6 (packaged in libs)
|
||||
|
||||
.. note ::
|
||||
|
||||
Refer :ref:`pybind11 notes. <pybind for different slsDetectorPackage versions>`
|
||||
|
||||
-----------------------
|
||||
ZeroMQ
|
||||
-----------------------
|
||||
|
||||
* Zeromq 4.3.4 (packaged in libs)
|
||||
|
||||
.. note ::
|
||||
|
||||
Refer :ref:`zeromq notes. <zeromq for different slsDetectorPackage versions>`
|
||||
|
||||
-----------------------
|
||||
GUI
|
||||
-----------------------
|
||||
|
||||
* Qt 5.9
|
||||
* Qwt 6.1.5 (packaged in libs/)
|
||||
|
||||
-----------------------
|
||||
Python bindings
|
||||
-----------------------
|
||||
|
||||
* Python > 3.6
|
||||
* pybind11 (packaged in libs/)
|
||||
|
||||
* Qwt 6.1.5 (packaged in libs)
|
||||
|
||||
-----------------------
|
||||
Moench executables
|
||||
@ -54,4 +66,6 @@ Packaged in libs/
|
||||
|
||||
* catch2 (unit testing)
|
||||
* rapidjson (streaming from receiver)
|
||||
* pybind11 (python bindings)
|
||||
* pybind11 (python bindings)
|
||||
* qwt (gui plotting)
|
||||
* libzmq (streaming to/from receiver)
|
@ -1,16 +1,19 @@
|
||||
Detector
|
||||
==============================================
|
||||
|
||||
The sls::Detector is the new public API to control
|
||||
The sls::Detector is the public API to control
|
||||
detectors from C++. This API is also used internally
|
||||
for the Python bindings and the command line interface.
|
||||
If a receiver has been configured this is also controlled
|
||||
If a receiver has been configured, this is also controlled
|
||||
through this class.
|
||||
|
||||
Most, if not all, functions are called in parallel
|
||||
and the return value is a thin std::vector wrapper
|
||||
containing results from all modules. (Result<T>)
|
||||
containing results from all modules. (:ref:`Result class<Result Class>`)
|
||||
|
||||
Here are some :ref:`examples <Cplusplus Api Examples>` on how to use the API.
|
||||
|
||||
.. _Cplusplus Api Examples:
|
||||
.. doxygenclass:: sls::Detector
|
||||
:members:
|
||||
:undoc-members:
|
@ -1,3 +1,4 @@
|
||||
.. _Cplusplus Api Examples:
|
||||
|
||||
|
||||
|
||||
@ -53,8 +54,8 @@ then set up the detector.
|
||||
|
||||
jungfrauDetectorServer_virtual
|
||||
|
||||
This launches a virtual Jungfrau detector server. As default is uses port 1952 and 1953
|
||||
for communication over TCP. Most commands go on 1952 and only stop and status on 1953.
|
||||
This launches a virtual Jungfrau detector server. As default it uses port 1952 and 1953
|
||||
for communication over TCP. Most commands go on 1952 and only a few such as stop and status on 1953.
|
||||
|
||||
**Run example to configure**
|
||||
|
||||
@ -90,7 +91,10 @@ std::vector.
|
||||
sls::Result<int> res1{1, 1, 1};
|
||||
std::cout << "res1: " << res1 << '\n';
|
||||
res1.squash();
|
||||
# return -1 if different
|
||||
res1.squash(-1);
|
||||
# throw exception with custom message if different
|
||||
res1.tsquash("Values are different);
|
||||
|
||||
|
||||
|
||||
|
62
docs/src/fileformat.rst
Normal file
62
docs/src/fileformat.rst
Normal file
@ -0,0 +1,62 @@
|
||||
File format
|
||||
================================
|
||||
|
||||
If `fwrite <commandline.html#term-fwrite-0-1>`_ is enabled, the receiver will write data to files.
|
||||
|
||||
Number of Files
|
||||
----------------
|
||||
|
||||
Every acquisition will create a master file and data files.
|
||||
|
||||
An acquisition can have multiple data files for a single frame. The number of files is determined by the number of UDP ports per module and the number of modules.
|
||||
|
||||
* Every modules has its own receiver process. Every receiver process can have 1 or 2 UDP ports.
|
||||
* Each UDP port will create its own file. Therefore, each receiver can write 1 or 2 files.
|
||||
* So, for example a detector with 4 modules with 2 UDP ports each will create a total of 8 files with file names containing UDP port index **'_d0'** to **'_d7'**.
|
||||
|
||||
A new file containing **'_f[file_index]'** in file name is also created when reaching the maximum frames per file. Configured using `rx_framesperfile <commandline.html#term-rx_framesperfile-n_frames>`_.
|
||||
|
||||
.. _file name format:
|
||||
|
||||
Naming
|
||||
-------
|
||||
| Master File Name: [fpath]/[fname]_master_[findex].[ext]
|
||||
|
||||
|
||||
| Data File Name: [fpath]/[fname]_dx_fy_[findex].[ext]
|
||||
|
||||
* fpath: file path set using command `fpath <commandline.html#term-fpath-path>`_. Default: '/'
|
||||
* fname: file name prefix using command `fname <commandline.html#term-fname-name>`_. Default: "run"
|
||||
* findex: acquisition index using command `findex <commandline.html#term-findex-n_value>`_. Automatically incremented for every acquisition with `sls_detector_acquire <commandline.html#term-acquire>`_ (if `fwrite <commandline.html#term-fwrite-0-1>`_ enabled).
|
||||
* x: unique udp port index. New file per UDP port.
|
||||
* y: file index. New file created after reaching max frames per file.
|
||||
* ext: file extension. Default: "raw"(data file) or "json"(master file)
|
||||
|
||||
|
||||
Some file name examples:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# first file
|
||||
path-to-file/run_d0_f0_0.raw
|
||||
|
||||
# first file for second UDP port
|
||||
path-to-file/run_d1_f0_0.raw
|
||||
|
||||
# second file after reaching max frames in first file
|
||||
path-to-file/run_d0_f1_0.raw
|
||||
|
||||
# second acquisition, first file
|
||||
path-to-file/run_d0_f0_1.raw
|
||||
|
||||
|
||||
Formats
|
||||
--------
|
||||
|
||||
There are 2 file formats supported by the receiver:
|
||||
|
||||
* Binary - extension .json (master file) or .raw (data files)
|
||||
* HDF5 - extension .h5
|
||||
|
||||
The default is binary. HDF5 can be enabled by compiling the package with HDF5 option enabled. The file format is set using the command `fformat <commandline.html#term-fformat-binary-hdf5>`_.
|
||||
|
@ -98,7 +98,7 @@ Upgrade
|
||||
|
||||
* 6.1.2 server has a fix for seamless fpga programming
|
||||
|
||||
* We recommend first updating the on-board detector server to 6.1.2 (with client 6.1.x) using command 'updatedetectorserver' or 'copydetectorserver'.
|
||||
* We recommend first updating the on-board detector server to 6.1.2 (with client 6.1.x) using command `updatedetectorserver <commandline.html#term-updatedetectorserver-server_name-with-full-path>`_.
|
||||
|
||||
* Then use command 'programfpga' to only update firmware or use command 'update' to update firmware and server to the latest release.
|
||||
|
||||
@ -116,12 +116,16 @@ Program from console
|
||||
|
||||
# Always ensure that the client and server software are of the same release.
|
||||
|
||||
# copies server from tftp folder of pc, links new server to jungfrauDetectorServer,
|
||||
# copies server, links new server to jungfrauDetectorServer,
|
||||
# removes old server from respawn, sets up new lnked server to respawn
|
||||
# programs fpga,
|
||||
# reboots
|
||||
# programs fpga, reboots
|
||||
|
||||
# older versions: v5.0.0 - 6.0.0 using tftp from tftp folder of pc
|
||||
sls_detector_put update jungfrauDetectorServervxxx pcxxx xx.pof
|
||||
|
||||
# v6.1.1 - present (copies server from the full path provided)
|
||||
sls_detector_put update jungfrauDetectorServervxxx xx.pof
|
||||
|
||||
# Or only program firmware
|
||||
sls_detector_put programfpga xxx.pof
|
||||
|
||||
@ -182,11 +186,16 @@ Program from console
|
||||
|
||||
# Always ensure that the client and server software are of the same release.
|
||||
|
||||
# copies server from tftp folder of pc, links new server to mythen3DetectorServer,
|
||||
# programs fpga,
|
||||
# reboots
|
||||
# copies server, links new server to mythen3DetectorServer,
|
||||
# removes old server from respawn, sets up new lnked server to respawn
|
||||
# programs fpga, reboots
|
||||
|
||||
# older versions: v5.0.0 - 6.0.0 using tftp from tftp folder of pc
|
||||
sls_detector_put update mythen3DetectorServervxxx pcxxx xxx.rbf
|
||||
|
||||
# v6.1.1 - present (copies server from the full path provided)
|
||||
sls_detector_put update mythen3DetectorServervxxx xxx.rbf
|
||||
|
||||
# Or only program firmware
|
||||
sls_detector_put programfpga xxx.rbf
|
||||
|
||||
@ -211,11 +220,16 @@ Program from console
|
||||
|
||||
# Always ensure that the client and server software are of the same release.
|
||||
|
||||
# copies server from tftp folder of pc, links new server to gotthard2DetectorServer,
|
||||
# programs fpga,
|
||||
# reboots
|
||||
# copies server, links new server to gotthard2DetectorServer,
|
||||
# removes old server from respawn, sets up new lnked server to respawn
|
||||
# programs fpga, reboots
|
||||
|
||||
# older versions: v5.0.0 - 6.0.0 using tftp from tftp folder of pc
|
||||
sls_detector_put update gotthard2DetectorServervxxx pcxxx xxx.rbf
|
||||
|
||||
# v6.1.1 - present (copies server from the full path provided)
|
||||
sls_detector_put update gotthard2DetectorServervxxx xxx.rbf
|
||||
|
||||
# Or only program firmware
|
||||
sls_detector_put programfpga xxx.rbf
|
||||
|
||||
@ -243,7 +257,7 @@ Upgrade
|
||||
|
||||
* 6.1.2 server has a fix for seamless fpga programming
|
||||
|
||||
* We recommend first updating the on-board detector server to 6.1.2 (with client 6.1.x) using command 'updatedetectorserver' or 'copydetectorserver'.
|
||||
* We recommend first updating the on-board detector server to 6.1.2 (with client 6.1.x) using command `updatedetectorserver <commandline.html#term-updatedetectorserver-server_name-with-full-path>`_.
|
||||
|
||||
* Then use command 'programfpga' to only update firmware or use command 'update' to update firmware and server to the latest release.
|
||||
|
||||
@ -257,12 +271,16 @@ Program from console
|
||||
|
||||
# Always ensure that the client and server software are of the same release.
|
||||
|
||||
# copies server from tftp folder of pc, links new server to moenchDetectorServer,
|
||||
# copies server, links new server to moenchDetectorServer,
|
||||
# removes old server from respawn, sets up new lnked server to respawn
|
||||
# programs fpga,
|
||||
# reboots
|
||||
# programs fpga, reboots
|
||||
|
||||
# older versions: v5.0.0 - 6.0.0 using tftp from tftp folder of pc
|
||||
sls_detector_put update moenchDetectorServervxxx pcxxx xx.pof
|
||||
|
||||
# v6.1.1 - present (copies server from the full path provided)
|
||||
sls_detector_put update moenchDetectorServervxxx xx.pof
|
||||
|
||||
# Or only program firmware
|
||||
sls_detector_put programfpga xxx.pof
|
||||
|
||||
@ -288,12 +306,16 @@ Program from console
|
||||
|
||||
# Always ensure that the client and server software are of the same release.
|
||||
|
||||
# copies server from tftp folder of pc, links new server to ctbDetectorServer,
|
||||
# copies server, links new server to ctbDetectorServer,
|
||||
# removes old server from respawn, sets up new lnked server to respawn
|
||||
# programs fpga,
|
||||
# reboots
|
||||
# programs fpga, reboots
|
||||
|
||||
# older versions: v5.0.0 - 6.0.0 using tftp from tftp folder of pc
|
||||
sls_detector_put update ctbDetectorServervxxx pcxxx xx.pof
|
||||
|
||||
# v6.1.1 - present (copies server from the full path provided)
|
||||
sls_detector_put update ctbDetectorServervxxx xx.pof
|
||||
|
||||
# Or only program firmware
|
||||
sls_detector_put programfpga xxx.pof
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "CmdProxy.h"
|
||||
#include "Caller.h"
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
@ -37,8 +37,8 @@ int main() {
|
||||
|
||||
std::cout << "Generating command line documentation!\n";
|
||||
|
||||
sls::CmdProxy proxy(nullptr);
|
||||
auto commands = proxy.GetProxyCommands();
|
||||
sls::Caller caller(nullptr);
|
||||
auto commands = caller.getAllCommands();
|
||||
|
||||
std::ofstream fs("commands.rst");
|
||||
fs << ".. glossary::\n";
|
||||
@ -46,7 +46,7 @@ int main() {
|
||||
for (const auto &cmd : commands) {
|
||||
std::ostringstream os;
|
||||
std::cout << cmd << '\n';
|
||||
proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os);
|
||||
caller.call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os);
|
||||
|
||||
auto tmp = os.str().erase(0, cmd.size());
|
||||
auto usage = tmp.substr(0, tmp.find_first_of('\n'));
|
||||
@ -55,9 +55,9 @@ int main() {
|
||||
fs << '\t' << cmd << usage << help << "\n";
|
||||
}
|
||||
|
||||
std::ofstream fs2("depreciated.csv");
|
||||
std::ofstream fs2("deprecated.csv");
|
||||
fs2 << "Old, New\n";
|
||||
auto cmds = proxy.GetDepreciatedCommands();
|
||||
auto cmds = caller.GetDeprecatedCommands();
|
||||
for (auto it : cmds) {
|
||||
fs2 << it.first << ", " << it.second << '\n';
|
||||
}
|
||||
|
89
docs/src/hdf5fileformat.rst
Normal file
89
docs/src/hdf5fileformat.rst
Normal file
@ -0,0 +1,89 @@
|
||||
|
||||
|
||||
HDF5 File Format
|
||||
================================
|
||||
|
||||
Compilation
|
||||
-------------
|
||||
|
||||
#. Compile the package with HDF5 option enabled
|
||||
|
||||
#. Using cmk script: ./cmk.sh -hj9 -d [path of hdf5 dir] (-d is optional and for custom installation folder)
|
||||
|
||||
#. Enable using cmake option **-DSLS_USE_HDF5=ON** and **-DCMAKE_INSTALL_PREFIX=/path/to/custom/hdf/installation** (optional).
|
||||
|
||||
|
||||
Setup
|
||||
-------
|
||||
|
||||
#. Start Receiver process
|
||||
|
||||
#. Load config file
|
||||
|
||||
#. Set file format using command `fformat <commandline.html#term-fformat-binary-hdf5>`_.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sls_detector_put fformat hdf5
|
||||
|
||||
|
||||
Master File
|
||||
-------------
|
||||
|
||||
* File Name: [fpath]/[fname]_master_[findex].h5 :ref:`Details here<file name format>`
|
||||
|
||||
* It contains :ref:`attributes<master file attributes>` relevant to the acquisition. This can vary with detector type.
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
/ # Root level
|
||||
|---> entry # entry group
|
||||
| |---> data # data group
|
||||
| |---> column # dataset of each sls_receiver_header member
|
||||
| |---> data
|
||||
| |---> detector header version
|
||||
| |---> detector specific 1
|
||||
| |---> detector specific 2
|
||||
| |---> detector specific 3
|
||||
| |---> detector specific 4
|
||||
| |---> detector type
|
||||
| |---> exp length or sub exposure time
|
||||
| |---> frame number
|
||||
| |---> mod id
|
||||
| |---> packets caught
|
||||
| |---> packets caught bit mask
|
||||
| |---> row
|
||||
| |---> timestamp
|
||||
| |---> instrument # instrument group
|
||||
| |---> beam # beam group
|
||||
| |---> detector # detector group
|
||||
| |---> Master File Attribute 1 # dataset of each master file attribute
|
||||
| |---> Master File Attribute 2
|
||||
| |---> Master File Attribute 3
|
||||
| |---> Master File Attribute ..
|
||||
| |---> sample # sample group
|
||||
|
||||
|
||||
If more than 1 data file per frame:
|
||||
* The dataset of each :ref:`**SLS Receiver Header** <sls receiver header format>` member is a virtual dataset.
|
||||
* **data** dataset is a virtual dataset.
|
||||
|
||||
|
||||
More details regarding master file attributes can be found :ref:`here<master file attributes>`.
|
||||
|
||||
Data File
|
||||
-----------
|
||||
|
||||
* File Name: [fpath]/[fname]_dx_fy_[findex].h5 :ref:`Details here<file name format>`
|
||||
|
||||
|
||||
Virtual Data File
|
||||
------------------
|
||||
|
||||
* File Name: [fpath]/[fname]_virtual_[findex].h5 :ref:`Details here<file name format>`
|
||||
|
||||
* For multiple modules, a virtual file linking data from all the modules is created. The individual files are expected to be present.
|
||||
|
||||
* It is linked in the master file.
|
||||
|
||||
|
@ -8,11 +8,11 @@ Welcome to slsDetectorPackage's documentation!
|
||||
|
||||
.. note ::
|
||||
|
||||
This is the documentation for the latest development version of slsDetectorPackage
|
||||
For documentation on current and previous releases visit the official page: https://www.psi.ch/en/detectors/documentation
|
||||
This is the documentation for the latest development version of slsDetectorPackage.
|
||||
For further documentation, visit the official page: https://www.psi.ch/en/detectors/documentation
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:maxdepth: 3
|
||||
:caption: Installation:
|
||||
|
||||
installation
|
||||
@ -82,6 +82,22 @@ Welcome to slsDetectorPackage's documentation!
|
||||
receivers
|
||||
slsreceiver
|
||||
|
||||
.. toctree::
|
||||
:caption: Receiver Files
|
||||
:maxdepth: 3
|
||||
|
||||
fileformat
|
||||
slsreceiverheaderformat
|
||||
masterfileattributes
|
||||
binaryfileformat
|
||||
hdf5fileformat
|
||||
|
||||
.. toctree::
|
||||
:caption: Receiver ZMQ Stream
|
||||
:maxdepth: 2
|
||||
|
||||
zmqjsonheaderformat
|
||||
|
||||
.. toctree::
|
||||
:caption: Troubleshooting
|
||||
|
||||
|
@ -1,13 +1,12 @@
|
||||
|
||||
|
||||
.. _Installation:
|
||||
|
||||
.. note ::
|
||||
|
||||
The default branch of our git repository is developer. It contains the
|
||||
latest development version. It is expected to compile and work but
|
||||
features might be added or tweaked. In some cases the API might also change
|
||||
without being communicated. If absolute stability of the API is needed please
|
||||
use one of the release versions.
|
||||
Installation
|
||||
===============
|
||||
|
||||
One can either install pre-built binaries using conda or build from source.
|
||||
|
||||
.. warning ::
|
||||
|
||||
@ -16,14 +15,9 @@
|
||||
manage the dependencies. Avoid also installing packages with pip.
|
||||
|
||||
|
||||
.. _Installation:
|
||||
|
||||
|
||||
Installation
|
||||
===============
|
||||
|
||||
Install binaries using conda
|
||||
-------------------------------
|
||||
----------------------------------
|
||||
|
||||
Conda is not only useful to manage python environments but can also
|
||||
be used as a user space package manager. Dates in the tag (for eg. 2020.07.23.dev0)
|
||||
@ -66,8 +60,7 @@ We have three different packages available:
|
||||
|
||||
|
||||
Build from source
|
||||
-------------------
|
||||
|
||||
----------------------
|
||||
|
||||
1. Download Source Code from github
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -76,23 +69,9 @@ Build from source
|
||||
|
||||
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git --branch 6.1.1
|
||||
|
||||
.. note ::
|
||||
|
||||
| **Pybind for Python**
|
||||
| v7.0.0+:
|
||||
| pybind11 packaged into 'libs/pybind'. No longer a submodule. No need for "recursive" or "submodule update".
|
||||
|
|
||||
| Older versions:
|
||||
| pybind11 is a submodule. Must be cloned using "recursive" and updated when switching between versions using the following commands.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# clone using recursive to get pybind11 submodule
|
||||
git clone --recursive https://github.com/slsdetectorgroup/slsDetectorPackage.git
|
||||
|
||||
# update submodule when switching between releases
|
||||
cd slsDetectorPackage
|
||||
git submodule update --init
|
||||
|
||||
For v6.x.x of slsDetectorPackage and older, refer :ref:`pybind11 notes on cloning. <pybind for different slsDetectorPackage versions>`
|
||||
|
||||
.. _build from source using cmake:
|
||||
|
||||
@ -101,8 +80,10 @@ Build from source
|
||||
2. Build from Source
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
One can either build using cmake or use the in-built cmk.sh script.
|
||||
|
||||
Build using CMake
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
@ -129,39 +110,42 @@ Instead of the cmake command, one can use ccmake to get a list of options to con
|
||||
ccmake ..
|
||||
|
||||
# choose the options
|
||||
# first press [c] - configure
|
||||
# first press [c] - configure (until you see [g])
|
||||
# then press [g] - generate
|
||||
|
||||
|
||||
|
||||
=============================== ===========================================
|
||||
=============================== ===============================
|
||||
Example cmake options Comment
|
||||
=============================== ===========================================
|
||||
=============================== ===============================
|
||||
-DSLS_USE_PYTHON=ON Python
|
||||
-DPython_FIND_VIRTUALENV=ONLY Python from only the conda environment
|
||||
-DZeroMQ_HINT=/usr/lib64 Use system zmq instead
|
||||
-DPython_FIND_VIRTUALENV=ONLY Python from the conda env
|
||||
-DSLS_USE_GUI=ON GUI
|
||||
=============================== ===========================================
|
||||
-DSLS_USE_HDF5=ON HDF5
|
||||
-DSLS_USE_SIMULATOR=ON Simulator
|
||||
=============================== ===============================
|
||||
|
||||
.. note ::
|
||||
|
||||
For v7.x.x of slsDetectorPackage and older, refer :ref:`zeromq notes for cmake option to hint library location. <zeromq for different slsDetectorPackage versions>`
|
||||
|
||||
|
||||
Build using in-built cmk.sh script
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
The binaries are generated in slsDetectorPackage/build/bin directory.
|
||||
|
||||
Usage: ./cmk.sh [-b] [-c] [-d <HDF5 directory>] [e] [g] [-h] [i] [-j <Number of threads>]
|
||||
[-k <CMake command>] [-l <Install directory>] [m] [n] [-p] [-q <Zmq hint directory>]
|
||||
[r] [s] [t] [u] [z]
|
||||
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-h] [-i]
|
||||
[-j <Number of threads>] [-k <CMake command>] [-l <Install directory>]
|
||||
[-m] [-n] [-p] [-r] [-s] [-t] [-u] [-z]
|
||||
-[no option]: only make
|
||||
-b: Builds/Rebuilds CMake files normal mode
|
||||
-c: Clean
|
||||
-d: HDF5 Custom Directory
|
||||
-e: Debug mode
|
||||
-g: Build/Rebuilds only gui
|
||||
-g: Build/Rebuilds gui
|
||||
-h: Builds/Rebuilds Cmake files with HDF5 package
|
||||
-i: Builds tests
|
||||
-j: Number of threads to compile through
|
||||
@ -170,7 +154,6 @@ Build using in-built cmk.sh script
|
||||
-m: Manuals
|
||||
-n: Manuals without compiling doxygen (only rst)
|
||||
-p: Builds/Rebuilds Python API
|
||||
-q: Zmq hint directory
|
||||
-r: Build/Rebuilds only receiver
|
||||
-s: Simulator
|
||||
-t: Build/Rebuilds only text client
|
||||
@ -178,22 +161,26 @@ Build using in-built cmk.sh script
|
||||
-z: Moench zmq processor
|
||||
|
||||
|
||||
# get all options
|
||||
# display all options
|
||||
./cmk.sh -?
|
||||
|
||||
# new build and compile in parallel:
|
||||
./cmk.sh -bj5
|
||||
# new build and compile in parallel (recommended basic option):
|
||||
./cmk.sh -cbj5
|
||||
|
||||
# new build, python and compile in parallel:
|
||||
./cmk.sh -bpj5
|
||||
./cmk.sh -cbpj5
|
||||
|
||||
#To use the system zmq (/usr/lib64) instead
|
||||
./cmk.sh -bj5 -q /usr/lib64
|
||||
#For rebuilding only certain sections
|
||||
./cmk.sh -tg #only text client and gui
|
||||
./cmk.sh -r #only receiver
|
||||
|
||||
.. note ::
|
||||
|
||||
For v7.x.x of slsDetectorPackage and older, refer :ref:`zeromq notes for cmk script option to hint library location. <zeromq for different slsDetectorPackage versions>`
|
||||
|
||||
|
||||
Build on old distributions
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
If your linux distribution doesn't come with a C++11 compiler (gcc>4.8) then
|
||||
it's possible to install a newer gcc using conda and build the slsDetectorPackage
|
||||
@ -202,7 +189,7 @@ using this compiler
|
||||
.. code-block:: bash
|
||||
|
||||
#Create an environment with the dependencies
|
||||
conda create -n myenv gxx_linux-64 cmake zmq
|
||||
conda create -n myenv gxx_linux-64 cmake
|
||||
conda activate myenv
|
||||
|
||||
# outside slsDetecorPackage folder
|
||||
@ -211,11 +198,17 @@ using this compiler
|
||||
make -j12
|
||||
|
||||
|
||||
.. note ::
|
||||
|
||||
For v7.x.x of slsDetectorPackage and older, refer :ref:`zeromq notes for dependencies for conda. <zeromq for different slsDetectorPackage versions>`
|
||||
|
||||
|
||||
|
||||
Build slsDetectorGui (Qt5)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
1. Using pre-built binary on conda
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
conda create -n myenv slsdetgui=7.0.0
|
||||
@ -223,13 +216,22 @@ Build slsDetectorGui (Qt5)
|
||||
|
||||
|
||||
2. Using system installation on RHEL7
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
yum install qt5-qtbase-devel.x86_64
|
||||
yum install qt5-qtsvg-devel.x86_64
|
||||
|
||||
3. Using system installation on RHEL8
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
yum install qt5-qtbase-devel.x86_64
|
||||
yum install qt5-qtsvg-devel.x86_64
|
||||
yum install expat-devel.x86_64
|
||||
|
||||
4. Using conda
|
||||
|
||||
3. Using conda
|
||||
.. code-block:: bash
|
||||
|
||||
#Add channels for dependencies and our library
|
||||
@ -239,9 +241,9 @@ Build slsDetectorGui (Qt5)
|
||||
|
||||
# create environment to compile
|
||||
# on rhel7
|
||||
conda create -n slsgui zeromq gxx_linux-64 gxx_linux-64 mesa-libgl-devel-cos6-x86_64 qt
|
||||
conda create -n slsgui gxx_linux-64 gxx_linux-64 mesa-libgl-devel-cos6-x86_64 qt
|
||||
# on fedora or newer systems
|
||||
conda create -n slsgui zeromq qt
|
||||
conda create -n slsgui qt
|
||||
|
||||
# when using conda compilers, would also need libgl, but no need for it on fedora unless maybe using it with ROOT
|
||||
|
||||
@ -257,11 +259,14 @@ Build slsDetectorGui (Qt5)
|
||||
cd slsDetectorPackage
|
||||
./cmk.sh -cbgj9
|
||||
|
||||
.. note ::
|
||||
|
||||
For v7.x.x of slsDetectorPackage and older, refer :ref:`zeromq notes for dependencies for conda. <zeromq for different slsDetectorPackage versions>`
|
||||
|
||||
|
||||
|
||||
Build this documentation
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The documentation for the slsDetectorPackage is build using a combination
|
||||
of Doxygen, Sphinx and Breathe. The easiest way to install the dependencies
|
||||
@ -269,7 +274,7 @@ is to use conda
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
conda create -n myenv python sphinx_rtd_theme breathe
|
||||
conda create -n myenv python=3.12 sphinx sphinx_rtd_theme breathe doxygen numpy
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
@ -281,3 +286,53 @@ is to use conda
|
||||
|
||||
make docs # generate API docs and build Sphinx RST
|
||||
make rst # rst only, saves time in case the API did not change
|
||||
|
||||
|
||||
Pybind and Zeromq
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. _pybind for different slsDetectorPackage versions:
|
||||
|
||||
|
||||
| **Pybind11 for Python**
|
||||
| v8.0.0+:
|
||||
| pybind11 is built
|
||||
| * by default from tar file in repo (libs/pybind/v2.1x.0.tar.gz)
|
||||
| * or use advanced option SLS_FETCH_PYBIND11_FROM_GITHUB [`link <https://github.com/pybind/pybind11>`__].
|
||||
| * v9.0.0+: pybind11 (v2.13.6)
|
||||
| * v8.x.x : pybind11 (v2.11.0)
|
||||
|
|
||||
| v7.x.x:
|
||||
| pybind11 packaged into 'libs/pybind'. No longer a submodule. No need for "recursive" or "submodule update".
|
||||
|
|
||||
| Older versions:
|
||||
| pybind11 is a submodule. Must be cloned using "recursive" and updated when switching between versions using the following commands.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Note: Only for v6.x.x versions and older
|
||||
|
||||
# clone using recursive to get pybind11 submodule
|
||||
git clone --recursive https://github.com/slsdetectorgroup/slsDetectorPackage.git
|
||||
|
||||
# update submodule when switching between releases
|
||||
cd slsDetectorPackage
|
||||
git submodule update --init
|
||||
|
||||
|
||||
.. _zeromq for different slsDetectorPackage versions:
|
||||
|
||||
|
||||
|
||||
| **Zeromq**
|
||||
| v8.0.0+:
|
||||
| zeromq (v4.3.4) is built
|
||||
| * by default from tar file in repo (libs/libzmq/libzmq-4.3.4.tar.gz)
|
||||
| * or use advanced option SLS_FETCH_ZMQ_FROM_GITHUB [`link <https://github.com/zeromq/libzmq.git>`__].
|
||||
|
|
||||
| v7.x.x and older:
|
||||
| zeromq-devel must be installed and one can hint its location using
|
||||
| * cmake option:'-DZeroMQ_HINT=/usr/lib64' or
|
||||
| * option '-q' in cmk.sh script: : ./cmk.sh -cbj5 -q /usr/lib64
|
||||
| * 'zeromq' dependency added when installing using conda
|
||||
|
||||
|
408
docs/src/masterfileattributes.rst
Normal file
408
docs/src/masterfileattributes.rst
Normal file
@ -0,0 +1,408 @@
|
||||
|
||||
.. _master file attributes:
|
||||
Master File Attributes
|
||||
=======================
|
||||
|
||||
These attributes are the same in binary and HDF5 file, but vary depending on detector type.
|
||||
|
||||
|
||||
Eiger
|
||||
^^^^^
|
||||
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| **Key** | **Description** |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Version | Version of the master file |
|
||||
| | Current value:8.0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timestamp | Timestamp of creation of master file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Detector Type | Detector type |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timing Mode | Timing Mode |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Geometry | Number of UDP ports in x and y dimension for |
|
||||
| | complete detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Image Size in bytes | Image size in bytes per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Pixels | Number of pixels in x and y dimension |
|
||||
| | per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Max Frames Per File | Maximum frames per file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Discard Policy | Receiever Frame discard policy |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Padding | Receiver Frame padding enable |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Scan Parameters | Scanning mode on detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Total Frames | Total number of frames and triggers expected |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Receiver Roi | Receiver ROI in file including xmax and ymax |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Dynamic Range | Bits per pixel |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Ten Giga | 10GbE enable for data |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Exptime | Exposure time |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Period | Period between frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Threshold Energy | Threshold energy |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Sub Exptime | Sub exposure time in 32 bit mode |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Sub Period | Sub period between frames in 32 bit mode |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Quad | Quad enable (hardware) |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Number of rows | Number of rows enabled for readout |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Rate Corrections | Rate Corrections |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frames in File | Number of frames written to file by Receiver 0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Header Format | Expected frame header format for the data files |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
|
||||
|
||||
Jungfrau
|
||||
^^^^^^^^
|
||||
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| **Key** | **Description** |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Version | Version of the master file |
|
||||
| | Current value:8.0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timestamp | Timestamp of creation of master file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Detector Type | Detector type |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timing Mode | Timing Mode |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Geometry | Number of UDP ports in x and y dimension for |
|
||||
| | complete detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Image Size in bytes | Image size in bytes per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Pixels | Number of pixels in x and y dimension |
|
||||
| | per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Max Frames Per File | Maximum frames per file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Discard Policy | Receiever Frame discard policy |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Padding | Receiver Frame padding enable |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Scan Parameters | Scanning mode on detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Total Frames | Total number of frames and triggers expected |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Receiver Roi | Receiver ROI in file including xmax and ymax |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Exptime | Exposure time |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Period | Period between frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Number of UDP | Number of UDP Interfaces enabled per module |
|
||||
| Interfaces | |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Number of rows | Number of rows enabled for readout |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frames in File | Number of frames written to file by Receiver 0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Header Format | Expected frame header format for the data files |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
|
||||
Gotthard II
|
||||
^^^^^^^^^^^^
|
||||
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| **Key** | **Description** |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Version | Version of the master file |
|
||||
| | Current value:8.0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timestamp | Timestamp of creation of master file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Detector Type | Detector type |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timing Mode | Timing Mode |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Geometry | Number of UDP ports in x and y dimension for |
|
||||
| | complete detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Image Size in bytes | Image size in bytes per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Pixels | Number of pixels in x and y dimension |
|
||||
| | per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Max Frames Per File | Maximum frames per file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Discard Policy | Receiever Frame discard policy |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Padding | Receiver Frame padding enable |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Scan Parameters | Scanning mode on detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Total Frames | Total number of frames and triggers expected |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Receiver Roi | Receiver ROI in file including xmax and ymax |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Exptime | Exposure time |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Period | Period between frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Burst Mode | Burst mode of detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frames in File | Number of frames written to file by Receiver 0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Header Format | Expected frame header format for the data files |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
|
||||
Mythen3
|
||||
^^^^^^^
|
||||
|
||||
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| **Key** | **Description** |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Version | Version of the master file |
|
||||
| | Current value:8.0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timestamp | Timestamp of creation of master file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Detector Type | Detector type |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timing Mode | Timing Mode |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Geometry | Number of UDP ports in x and y dimension for |
|
||||
| | complete detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Image Size in bytes | Image size in bytes per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Pixels | Number of pixels in x and y dimension |
|
||||
| | per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Max Frames Per File | Maximum frames per file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Discard Policy | Receiever Frame discard policy |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Padding | Receiver Frame padding enable |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Scan Parameters | Scanning mode on detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Total Frames | Total number of frames and triggers expected |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Receiver Roi | Receiver ROI in file including xmax and ymax |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Dynamic Range | Bits per pixel |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Ten Giga | 10GbE enable for data |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Period | Period between frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Counter Mask | Mask of counters enabled |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Exptime1 | Exposure time of counter 1 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Exptime2 | Exposure time of counter 2 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Exptime3 | Exposure time of counter 3 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| GateDelay1 | Gate delay of counter 1 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| GateDelay2 | Gate delay of counter 2 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| GateDelay3 | Gate delay of counter 3 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Gates | Number of gates |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Threshold energies | Threshold energy of all 3 counters |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frames in File | Number of frames written to file by Receiver 0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Header Format | Expected frame header format for the data files |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
|
||||
|
||||
Moench
|
||||
^^^^^^
|
||||
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| **Key** | **Description** |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Version | Version of the master file |
|
||||
| | Current value:8.0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timestamp | Timestamp of creation of master file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Detector Type | Detector type |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timing Mode | Timing Mode |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Geometry | Number of UDP ports in x and y dimension for |
|
||||
| | complete detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Image Size in bytes | Image size in bytes per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Pixels | Number of pixels in x and y dimension |
|
||||
| | per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Max Frames Per File | Maximum frames per file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Discard Policy | Receiever Frame discard policy |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Padding | Receiver Frame padding enable |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Scan Parameters | Scanning mode on detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Total Frames | Total number of frames and triggers expected |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Receiver Roi | Receiver ROI in file including xmax and ymax |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Exptime | Exposure time |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Period | Period between frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Number of UDP | Number of UDP Interfaces enabled per module |
|
||||
| Interfaces | |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Number of rows | Number of rows enabled for readout |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frames in File | Number of frames written to file by Receiver 0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Header Format | Expected frame header format for the data files |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
|
||||
Gotthard I
|
||||
^^^^^^^^^^^
|
||||
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| **Key** | **Description** |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Version | Version of the master file |
|
||||
| | Current value:8.0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timestamp | Timestamp of creation of master file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Detector Type | Detector type |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timing Mode | Timing Mode |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Geometry | Number of UDP ports in x and y dimension for |
|
||||
| | complete detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Image Size in bytes | Image size in bytes per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Pixels | Number of pixels in x and y dimension |
|
||||
| | per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Max Frames Per File | Maximum frames per file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Discard Policy | Receiever Frame discard policy |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Padding | Receiver Frame padding enable |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Scan Parameters | Scanning mode on detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Total Frames | Total number of frames and triggers expected |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Receiver Roi | Receiver ROI in file including xmax and ymax |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Exptime | Exposure time |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Period | Period between frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Detector Roi | Roi in detector restricted to an ADC. |
|
||||
| | Includes xmax |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Burst Mode | Burst mode of detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frames in File | Number of frames written to file by Receiver 0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Header Format | Expected frame header format for the data files |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
|
||||
Chip Test Board
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| **Key** | **Description** |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Version | Version of the master file |
|
||||
| | Current value:8.0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timestamp | Timestamp of creation of master file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Detector Type | Detector type |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Timing Mode | Timing Mode |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Geometry | Number of UDP ports in x and y dimension for |
|
||||
| | complete detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Image Size in bytes | Image size in bytes per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Pixels | Number of pixels in x and y dimension |
|
||||
| | per UDP port |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Max Frames Per File | Maximum frames per file |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Discard Policy | Receiever Frame discard policy |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Padding | Receiver Frame padding enable |
|
||||
| | for partial frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Scan Parameters | Scanning mode on detector |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Total Frames | Total number of frames and triggers expected |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Receiver Roi | Receiver ROI in file including xmax and ymax |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Exptime | Exposure time |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Period | Period between frames |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Ten Giga | Ten giga enable |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| ADC Mask | Mask of channels enabled in ADC |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Analog Flag | Analog readout enable |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Analog Samples | Number of analog samples |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Digital Flag | Digital readout enable |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Digital Samples | Number of digital samples |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Dbit Offset | Digital offset of valid data in bytes |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Dbit Bitset | Digital 64 bit mask of bits enabled in receiver |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Transceiver Mask | Mask of channels enabled in Transceiver |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Transceiver Flag | Transceiver readout enable |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Transceiver Samples | Number of transceiver samples |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frames in File | Number of frames written to file by Receiver 0 |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Frame Header Format | Expected frame header format for the data files |
|
||||
+-----------------------+-------------------------------------------------+
|
@ -6,7 +6,7 @@ Getting Started
|
||||
Which Python?
|
||||
--------------------
|
||||
|
||||
We require at least Python 3.6 and strongly recommended that you don't use the system
|
||||
We require at least Python 3.8 and strongly recommended that you don't use the system
|
||||
Python installation. The examples in this documentation uses `conda
|
||||
<https://docs.conda.io/en/latest/miniconda.html>`_ since it provides good support
|
||||
also for non Python packages but there are also other alternatives like, pyenv.
|
||||
|
@ -109,12 +109,14 @@ For Multiple Modules
|
||||
# connects to mulitple modules
|
||||
hostname bchipxxx+bchipyyy+
|
||||
|
||||
# connects to receivers at ports 2012 and 2014
|
||||
rx_hostname mpc1922:2012+mpc1922:2013+
|
||||
# tcp port increases for each module (multi detector command)
|
||||
rx_tcpport 2012
|
||||
|
||||
# sets differernt destination udp ports
|
||||
0:udp_dstport 50012
|
||||
1:udp_dstport 50014
|
||||
# connects to receivers at ports 2012 and 2014
|
||||
rx_hostname mpc1922
|
||||
|
||||
# increasing udp ports (multi detector command)
|
||||
udp_dstport 50012
|
||||
|
||||
# source udp ips must be same subnet at destintaion udp ips
|
||||
0:udp_srcip 192.168.1.112
|
||||
|
@ -1,3 +1,5 @@
|
||||
.. _Result Class:
|
||||
|
||||
Result
|
||||
==============================================
|
||||
|
||||
|
@ -52,8 +52,13 @@ Client Commands
|
||||
|
||||
# multi modules with custom ports
|
||||
rx_hostname xxx:1955+xxx:1956+
|
||||
|
||||
|
||||
# multi modules using increasing tcp ports when using multi detector command
|
||||
rx_tcpport 1955
|
||||
rx_hostname xxx
|
||||
|
||||
# multi modules with custom ports on same rxr pc
|
||||
# or specify multi modules with custom ports on same rxr pc
|
||||
0:rx_tcpport 1954
|
||||
1:rx_tcpport 1955
|
||||
2:rx_tcpport 1956
|
||||
@ -86,69 +91,6 @@ Client Commands
|
||||
sls_detector_get -h rx_framescaught
|
||||
|
||||
|
||||
File format
|
||||
--------------
|
||||
|
||||
Master file is in json format.
|
||||
|
||||
The file name format is [fpath]/[fname]_dx_fy_[findex].raw, where x is module index and y is file index. **fname** is file name prefix and by default "run". **fpath** is '/' by default.
|
||||
|
||||
|
||||
Each acquisition will have an increasing acquisition index or findex (if file write enabled). This can be retrieved by using **findex** command.
|
||||
|
||||
|
||||
Each acquisition can have multiple files (the file index number **y**), with **rx_framesperfile** being the maximum number of frames per file. The default varies for each detector type.
|
||||
|
||||
|
||||
Some file name examples:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# first file
|
||||
path-to-file/run_d0_f0_0.raw
|
||||
|
||||
# second file after reaching max frames in first file
|
||||
path-to-file/run_d0_f1_0.raw
|
||||
|
||||
# second acquisition, first file
|
||||
path-to-file/run_d0_f0_1.raw
|
||||
|
||||
|
||||
Each acquisition will create a master file that can be enabled/disabled using **fmaster**. This should have parameters relevant to the acquisition.
|
||||
|
||||
|
||||
SLS Receiver Header consist of SLS Detector Header + 64 bytes of bitmask, altogether 112 bytes. The packetNumber in the sls detector header part, will be updated to number of packets caught by receiver for that frame. Furthermore, the bit mask will specify which packets have been received.
|
||||
|
||||
**Binary file format**
|
||||
|
||||
This is the default file format.
|
||||
|
||||
|
||||
Each data file will consist of frames, each consisting of slsReceiver Header followed by data for 1 frame.
|
||||
|
||||
|
||||
Master file is of ASCII format and will also include the format of the slsReceiver Header.
|
||||
|
||||
|
||||
**HDF5 file formats**
|
||||
|
||||
#. Compile the package with HDF5 option enabled
|
||||
|
||||
#. Using cmk script: ./cmk.sh -hj9 -d [path of hdf5 dir]
|
||||
|
||||
#. Enable using cmake **-DCMAKE_INSTALL_PREFIX=/path/to/hdf/installation** and **-DSLS_USE_HDF5=ON**
|
||||
|
||||
#. Start Receiver process
|
||||
|
||||
#. Load config file
|
||||
|
||||
#. Set file format from client or in config file
|
||||
.. code-block:: bash
|
||||
|
||||
sls_detector_put fformat hdf5
|
||||
|
||||
|
||||
| For multiple, modules, a virtual file linking all the modules is created. Both the data files and virtual files are linked in the master file.
|
||||
|
||||
|
||||
Performance
|
||||
|
40
docs/src/slsreceiverheaderformat.rst
Normal file
40
docs/src/slsreceiverheaderformat.rst
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
.. _sls receiver header format:
|
||||
|
||||
SLS Receiver Header Format
|
||||
====================================================
|
||||
|
||||
It is 112 bytes and consists of:
|
||||
* 48 bytes of the SLS Detector Header
|
||||
* 64 bytes of packet mask
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
typedef struct {
|
||||
uint64_t frameNumber;
|
||||
uint32_t expLength;
|
||||
uint32_t packetNumber;
|
||||
uint64_t detSpec1;
|
||||
uint64_t timestamp;
|
||||
uint16_t modId;
|
||||
uint16_t row;
|
||||
uint16_t column;
|
||||
uint16_t detSpec2;
|
||||
uint32_t detSpec3;
|
||||
uint16_t detSpec4;
|
||||
uint8_t detType;
|
||||
uint8_t version;
|
||||
} sls_detector_header;
|
||||
|
||||
struct sls_receiver_header {
|
||||
sls_detector_header detHeader; /**< is the detector header */
|
||||
sls_bitset packetsMask; /**< is the packets caught bit mask */
|
||||
};
|
||||
|
||||
|
||||
|
||||
| **sls_detector_header** (described in :ref:`the current detector header <detector udp header>`)
|
||||
|
||||
| The **packetNumber** from detector UDP header is modified in **sls_receiver_header** to number of packets caught by receiver for that frame and the bit mask for each packet caught is the **packetsMask**. The packetsMask is a total of 512 bits due to the largest number of packets per frame among our detectors.
|
||||
|
||||
| For eg. Jungfrau has 128 packets per frame. If **packetNumeber** is 128, then this frame is complete. If it is 127 or less, it is a partial frame due to missing packets. If one would still like to use it, the **packetsMask** will specify which packet has been received or is missing.
|
@ -22,6 +22,8 @@ Common
|
||||
* Check transeiver and fibers are compatible (all MMF 850nm or all SMF 1030nm)
|
||||
* Check fiber
|
||||
* Check fiber polarity (if short range, unplug the link anywhere, and look at the light/dark pattern: dark has to mate with light)
|
||||
* For Jungfrau, check if the blue sfp light is blinking rapidly (even when it is not sending data). If so, most likely the link is down and something is wrong with the board. If it connected to a switch, then you do not see it with the ethtool command if link is down. One option is to connect it directly to a pc to see if link is down.
|
||||
* With nc, try "nc -u -p 50001 -l" in receiving pc, and from another pc try "echo hallo | nc -u 10.1.2.172 50001" to send something to the recieving pc interface to see if the link is up and see if the other nc console receives the hallo.
|
||||
|
||||
#. Detector is not acquiring (Not Eiger)
|
||||
* Take an acquisition with many images and using the following steps instead of acquire:
|
||||
@ -47,11 +49,20 @@ Common
|
||||
* Ensure that the interfaces (on NIC and the switch) used in receiver pc have MTU 9000 (jumbo frames) enabled.
|
||||
|
||||
|
||||
#. Check if 'rx_frames' counter in 'ifconfig' do not increment for interface.
|
||||
#. Check if 'rx packets' counter in 'ifconfig' do not increment for interface.
|
||||
* If no, check switch configuration if present. Port counters of switch can also help to identify problem.
|
||||
* If yes, but receiver software does not see it:
|
||||
|
||||
* Check no firewall (eg. firewalld) is present or add rules
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Stop and disable firewall
|
||||
service firewalld stop
|
||||
systemctl disable firewalld
|
||||
# Check status
|
||||
service firewalld status
|
||||
|
||||
* Check that selinux is disabled ( or add rules)
|
||||
|
||||
#. Source UDP IP in config file (Not Eiger)
|
||||
@ -92,6 +103,9 @@ Common
|
||||
sls_detector_put rx_arping 1
|
||||
|
||||
|
||||
#. Only the slaves get no data
|
||||
* Check trigger cabling and trigger configuration
|
||||
* When you cannot stop Jungfrau slaves in sync mode, refer to :ref:`Cannot stop slaves<Jungfrau Troubleshooting Sync Slaves Cannot Stop>`.
|
||||
|
||||
.. _Receiver PC Tuning:
|
||||
|
||||
@ -380,6 +394,14 @@ Missing first frame or next frame after a delay
|
||||
Connect the data link from the Module directly to receiver pc or to a private network.
|
||||
|
||||
|
||||
Mythen3
|
||||
--------
|
||||
|
||||
Detector status is waiting even in auto timing mode
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Check if the control board or the flat band cable is connected properly. If not, connect them properly and try again.
|
||||
|
||||
|
||||
Jungfrau
|
||||
---------
|
||||
|
||||
@ -421,3 +443,20 @@ Cannot get multi module data
|
||||
* Comment out this line in the config file: powerchip 1
|
||||
* Powering on the chip increases the power consumption by a considerable amount. If commenting out this line aids in getting data (strange data due to powered off chip), then it could be the power supply current limit. Fix it (possibly to 8A current limit) and uncomment the powerchip line back in config file.
|
||||
|
||||
|
||||
|
||||
.. _Jungfrau Troubleshooting Sync Slaves Cannot Stop:
|
||||
|
||||
Cannot stop slaves in sync mode
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
#. If cabling is accessible, ensure termination board and flatband cable between the masters and the slaves are connnected properly. Then try to stop.
|
||||
#. If cabling is inaccessible, unsync first so that the slaves can get the stop directly from the client using the command. Then, don't use sync mode until the cabling is fixed.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# unsync, slaves command will fail as it is still in waiting state
|
||||
sls_detector_put sync 0
|
||||
|
||||
# stop should now be successful as master does not determine the stop anymore
|
||||
sls_detector_put stop
|
||||
|
@ -3,7 +3,7 @@
|
||||
Format
|
||||
=======
|
||||
|
||||
The UDP data format for the packets consist of a common header for all detectors, followed by the data for that one packet.
|
||||
The UDP data format for the packets consist of a common header of 48 bytes for all detectors, followed by the data for that one packet.
|
||||
|
||||
|
||||
Current Version
|
||||
@ -11,7 +11,26 @@ Current Version
|
||||
|
||||
**v2.0 (slsDetectorPackage v7.0.0+)**
|
||||
|
||||
.. table:: <---------------------------------------------------- 8 bytes ---------------------------------------------------->
|
||||
.. code-block:: cpp
|
||||
|
||||
typedef struct {
|
||||
uint64_t frameNumber;
|
||||
uint32_t expLength;
|
||||
uint32_t packetNumber;
|
||||
uint64_t detSpec1;
|
||||
uint64_t timestamp;
|
||||
uint16_t modId;
|
||||
uint16_t row;
|
||||
uint16_t column;
|
||||
uint16_t detSpec2;
|
||||
uint32_t detSpec3;
|
||||
uint16_t detSpec4;
|
||||
uint8_t detType;
|
||||
uint8_t version;
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
.. table:: <---------------------------------------------------- 8 bytes per row --------------------------------------------->
|
||||
:align: center
|
||||
:widths: 30,30,30,15,15
|
||||
|
||||
@ -63,6 +82,8 @@ Description
|
||||
* **version**: current version of the detector header (0x2).
|
||||
|
||||
|
||||
.. _detector enum:
|
||||
|
||||
Detector Enum
|
||||
--------------
|
||||
|
||||
|
@ -86,7 +86,8 @@ For a Single Module (With Options)
|
||||
udp_dstport 50012
|
||||
|
||||
# source udp ips must be same subnet at destintaion udp ips
|
||||
udp_srcip 192.168.1.112
|
||||
# takes the same ip as hostname
|
||||
udp_srcip auto
|
||||
|
||||
# destination udp ip picked up from rx_hostname (if auto)
|
||||
udp_dstip auto
|
||||
@ -101,12 +102,14 @@ For Multiple Modules
|
||||
virtual 2 1912
|
||||
# or hostname localhost:1912+localhost:1914+
|
||||
|
||||
# connects to receivers at ports 2012 and 2014
|
||||
rx_hostname mpc1922:2012+mpc1922:2013+
|
||||
# increasing receiver tcp ports (multi detector command)
|
||||
rx_tcpport 2012
|
||||
|
||||
# sets differernt destination udp ports
|
||||
0:udp_dstport 50012
|
||||
1:udp_dstport 50014
|
||||
# connects to reciever at port 2012 and 2013
|
||||
rx_hostname mpc1922
|
||||
|
||||
# sets increasing destination udp ports
|
||||
udp_dstport 50012
|
||||
|
||||
# source udp ips must be same subnet at destintaion udp ips
|
||||
0:udp_srcip 192.168.1.112
|
||||
|
137
docs/src/zmqjsonheaderformat.rst
Normal file
137
docs/src/zmqjsonheaderformat.rst
Normal file
@ -0,0 +1,137 @@
|
||||
ZMQ: Json Header Format
|
||||
========================
|
||||
|
||||
|
||||
**Change in field names from slsDetectorPackage v6.x.x to v7.0.0**
|
||||
|
||||
* detSpec1 <- bunchId
|
||||
* detSpec2 <- reserved
|
||||
* detSpec3 <- debug
|
||||
* detSpec4 <- roundRNumber
|
||||
|
||||
|
||||
**Format**
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
{
|
||||
"jsonversion": unsigned int,
|
||||
"bitmode": unsigned int,
|
||||
"fileIndex": unsigned long int,
|
||||
"detshape": [
|
||||
unsigned int,
|
||||
unsigned int
|
||||
],
|
||||
"shape": [
|
||||
unsigned int,
|
||||
unsigned int
|
||||
],
|
||||
"size": unsigned int,
|
||||
"acqIndex": unsigned long int,
|
||||
"frameIndex": unsigned long int,
|
||||
"progress": double,
|
||||
"fname": string,
|
||||
"data": unsigned int,
|
||||
"completeImage": unsigned int,
|
||||
|
||||
"frameNumber": unsigned long long int,
|
||||
"expLength": unsigned int,
|
||||
"packetNumber": unsigned int,
|
||||
"detSpec1": unsigned long int,
|
||||
"timestamp": unsigned long int,
|
||||
"modId": unsigned int,
|
||||
"row": unsigned int,
|
||||
"column": unsigned int,
|
||||
"detSpec2": unsigned int,
|
||||
"detSpec3": unsigned int,
|
||||
"detSpec4": unsigned int,
|
||||
"detType": unsigned int,
|
||||
"version": unsigned int,
|
||||
|
||||
"flipRows": unsigned int,
|
||||
"quad": unsigned int,
|
||||
"addJsonHeader": {
|
||||
string : string
|
||||
}
|
||||
}
|
||||
|
||||
+--------------+----------------------------------------------+
|
||||
| Field | Description |
|
||||
+--------------+----------------------------------------------+
|
||||
| jsonversion | Version of the json header. |
|
||||
| | Value at 4 for v6.x.x and v7.x.x |
|
||||
+--------------+----------------------------------------------+
|
||||
| bitmode | Bits per pixel [4|8|16|32] |
|
||||
+--------------+----------------------------------------------+
|
||||
| fileIndex | Current file acquisition index |
|
||||
+--------------+----------------------------------------------+
|
||||
| detshape | Geometry of the entire detector |
|
||||
+--------------+----------------------------------------------+
|
||||
| shape | Geometry of the current port streamed out |
|
||||
+--------------+----------------------------------------------+
|
||||
| size | Size of image of current port in bytesout |
|
||||
+--------------+----------------------------------------------+
|
||||
| acqIndex | Frame number from the detector (redundant) |
|
||||
+--------------+----------------------------------------------+
|
||||
| frameIndex | Frame number of current acquisition |
|
||||
| | (Starting at 0) |
|
||||
+--------------+----------------------------------------------+
|
||||
| progress | Progress of current acquisition in % |
|
||||
+--------------+----------------------------------------------+
|
||||
| fname | Current file name |
|
||||
+--------------+----------------------------------------------+
|
||||
| data | 1 if there is data following |
|
||||
| | 0 if dummy header |
|
||||
+--------------+----------------------------------------------+
|
||||
| completeImage| 1 if no missing packets for this frame |
|
||||
| | in this port, else 0 |
|
||||
+--------------+----------------------------------------------+
|
||||
| frameNumber | Frame number |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| expLength | subframe number (32 bit eiger) |
|
||||
| | or real time exposure time in 100ns (others) |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| packetNumber | Number of packets caught for that frame |
|
||||
+--------------+----------------------------------------------+
|
||||
| detSpec1 | See :ref:`here<Detector Specific Fields>` |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| timestamp | Timestamp with 10 MHz clock |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| modId | Module Id |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| row | Row number in detector |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| column | Column number in detector |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| detSpec2 | See :ref:`here<Detector Specific Fields>` |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| detSpec3 | See :ref:`here<Detector Specific Fields>` |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| detSpec4 | See :ref:`here<Detector Specific Fields>` |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| detType | Detector type enum |
|
||||
| detSpec3 | See :ref:`Detector enum<detector enum>` |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| version | Detector header version. At 2 |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| flipRows | 1 if rows should be flipped. |
|
||||
| | Usually for Eiger bottom. |
|
||||
+--------------+----------------------------------------------+
|
||||
| quad | 1 if its an Eiger quad. |
|
||||
+--------------+----------------------------------------------+
|
||||
| addJsonHeader| Optional custom parameters that is required |
|
||||
| | for processing code. |
|
||||
+--------------+----------------------------------------------+
|
||||
|
6
examples/badchannel.txt
Normal file
6
examples/badchannel.txt
Normal file
@ -0,0 +1,6 @@
|
||||
0
|
||||
10, 30
|
||||
40:45 50:52
|
||||
1279
|
||||
# all bad channels are applied for all counters in deector
|
||||
|
@ -4,27 +4,33 @@ detsize 1024 512
|
||||
# detector hostname for controls
|
||||
hostname beb059+beb058+
|
||||
|
||||
# 1Gb receiver pc hostname with tcp port to configure receiver
|
||||
rx_hostname x12sa-vcons:1991+x12sa-vcons:1992
|
||||
# increasing receiver tcp port (multi detector command)
|
||||
rx_tcpport 1991
|
||||
|
||||
# 1Gb receiver pc hostname to configure receiver
|
||||
rx_hostname x12sa-vcons
|
||||
|
||||
# or 1Gb receiver pc hostname with tcp port to configure receiver
|
||||
#rx_hostname x12sa-vcons:1991+x12sa-vcons:1992
|
||||
|
||||
# increasing udp destination ports for all half modules
|
||||
udp_dstport 50011
|
||||
|
||||
# udp port first quadrant, first halfmodule
|
||||
0:udp_dstport 50011
|
||||
|
||||
#0:udp_dstport 50011
|
||||
# udp port second quadrant, first halfmodule
|
||||
0:udp_dstport2 50012
|
||||
|
||||
#0:udp_dstport2 50012
|
||||
# udp port first quadrant, second halfmodule
|
||||
#1:udp_dstport 50013
|
||||
# udp port second quadrant, second halfmodule
|
||||
#1:udp_dstport2 50014
|
||||
|
||||
# udp IP of the receiver over 10Gb
|
||||
0:udp_dstip 10.0.30.210
|
||||
|
||||
# first half module 10 Gb IP (same subnet as 0:udp_dstip)
|
||||
0:udp_srcip 10.0.30.100
|
||||
|
||||
# udp port first quadrant, second halfmodule
|
||||
1:udp_dstport 50013
|
||||
|
||||
# udp port second quadrant, second halfmodule
|
||||
1:udp_dstport2 50014
|
||||
|
||||
# udp IP of the receiver over 10Gb,
|
||||
1:udp_dstip 10.0.40.210
|
||||
|
||||
|
@ -4,18 +4,23 @@ detsize 1024 512
|
||||
# detector hostname for controls
|
||||
hostname beb059+beb058+
|
||||
|
||||
# 1Gb receiver pc hostname with tcp port to configure receiver
|
||||
rx_hostname x12sa-vcons:1991+x12sa-vcons:1992
|
||||
# increasing receiver tcp port (multi detector command)
|
||||
rx_tcpport 1991
|
||||
|
||||
# 1Gb receiver pc hostname to configure receiver
|
||||
rx_hostname x12sa-vcons
|
||||
|
||||
# increasing udp destination ports for all half modules
|
||||
udp_dstport 50011
|
||||
|
||||
# udp port first quadrant, first halfmodule
|
||||
0:udp_dstport 50011
|
||||
#0:udp_dstport 50011
|
||||
#udp port second quadrant, first halfmodule
|
||||
0:udp_dstport2 50012
|
||||
|
||||
#0:udp_dstport2 50012
|
||||
# udp port first quadrant, second halfmodule
|
||||
1:udp_dstport 50013
|
||||
#1:udp_dstport 50013
|
||||
# udp port second quadrant, second halfmodule
|
||||
1:udp_dstport2 50014
|
||||
#1:udp_dstport2 50014
|
||||
|
||||
# output directory
|
||||
fpath /sls/X12SA/data/x12saop/Data10/Eiger0.5M
|
||||
|
@ -4,14 +4,18 @@ detsize 1024 1024
|
||||
# detector hostname
|
||||
hostname bchip048+bchip052+
|
||||
|
||||
# 1Gb receiver pc hostname (default tcpport: 1954)
|
||||
rx_hostname pcmoench01:1954+pcmoench01:1955+
|
||||
# increasing receiver ports 1954 and 1955 (multi detector command)
|
||||
rx_tcpport 1954
|
||||
|
||||
# 1Gb receiver pc hostname
|
||||
rx_hostname pcmoench01
|
||||
|
||||
|
||||
# increasing udp ports 50004 and 50005 (multi detector command)
|
||||
udp_dstport 50004
|
||||
# or custom udp destination port (receiver) for 1st module
|
||||
#0:udp_dstport 50014
|
||||
|
||||
# udp configurations for 1st module
|
||||
# udp destination port (receiver)
|
||||
0:udp_dstport 50004
|
||||
|
||||
# udp destination ip (receiver)
|
||||
0:udp_dstip 10.1.1.100
|
||||
@ -19,17 +23,11 @@ rx_hostname pcmoench01:1954+pcmoench01:1955+
|
||||
# udp source ip (same subnet as 0:udp_dstip)
|
||||
0:udp_srcip 10.1.1.10
|
||||
|
||||
|
||||
|
||||
# udp configurations for 2nd module
|
||||
# udp destination port (receiver)
|
||||
1:udp_dstport 50005
|
||||
|
||||
# udp destination ip (receiver)
|
||||
1:udp_dstip 10.1.1.100
|
||||
1:udp_dstip 10.1.2.100
|
||||
|
||||
# udp source ip (same subnet as 1:udp_dstip)
|
||||
1:udp_srcip 10.1.1.11
|
||||
1:udp_srcip 10.1.2.11
|
||||
|
||||
|
||||
|
||||
@ -45,5 +43,5 @@ timing trigger
|
||||
# output file directory
|
||||
fpath /external_pool/jungfrau_data/softwaretest
|
||||
|
||||
# disable file writing
|
||||
# disable file writing (default)
|
||||
fwrite 0
|
22
examples/rawdata.config
Normal file
22
examples/rawdata.config
Normal file
@ -0,0 +1,22 @@
|
||||
numfiles 1
|
||||
nthreads 5,
|
||||
fifosize 5000
|
||||
nsigma 5
|
||||
gainfile none
|
||||
detectorMode counting
|
||||
threshold 0
|
||||
pedestalfile none
|
||||
nframes 0
|
||||
xMin 0
|
||||
xMax 400
|
||||
yMin 0
|
||||
yMax 400
|
||||
outdir ./
|
||||
indir ./
|
||||
flist none
|
||||
fformat none
|
||||
runmin 0
|
||||
runmax -1
|
||||
readnrows 400
|
||||
eMin 0
|
||||
eMax 16000
|
@ -1,18 +1,18 @@
|
||||
# detector hostname
|
||||
hostname localhost:1910
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2010
|
||||
|
||||
# udp destination ports
|
||||
udp_dstport 50010
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
|
||||
# udp source ip (same subnet as udp_dstip)
|
||||
udp_srcip 192.168.1.100
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2010
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
|
||||
# output file directory
|
||||
fpath /tmp
|
||||
|
||||
@ -27,418 +27,7 @@ dbitclk 40
|
||||
|
||||
|
||||
# patterns
|
||||
patword 0x0000 0x0000000000000000
|
||||
patword 0x0001 0x0000000000000000
|
||||
patword 0x0002 0x0008000900080000
|
||||
patword 0x0003 0x0008000900080000
|
||||
patword 0x0004 0x0008000900080000
|
||||
patword 0x0005 0x0008000900080000
|
||||
patword 0x0006 0x0008000900080000
|
||||
patword 0x0007 0x0008000900080000
|
||||
patword 0x0008 0x0008000900080000
|
||||
patword 0x0009 0x0008000900080000
|
||||
patword 0x000a 0x0008000900080000
|
||||
patword 0x000b 0x0008000900080000
|
||||
patword 0x000c 0x0008000900080000
|
||||
patword 0x000d 0x0008000900080000
|
||||
patword 0x000e 0x0008000900080000
|
||||
patword 0x000f 0x0008000900080000
|
||||
patword 0x0010 0x0008000900080000
|
||||
patword 0x0011 0x0008000900080000
|
||||
patword 0x0012 0x0008000900080000
|
||||
patword 0x0013 0x0008000900080000
|
||||
patword 0x0014 0x0008000900080000
|
||||
patword 0x0015 0x0008000900080000
|
||||
patword 0x0016 0x0008400900080020
|
||||
patword 0x0017 0x0008400900080020
|
||||
patword 0x0018 0x0008599f0418503a
|
||||
patword 0x0019 0x0008599f0418503a
|
||||
patword 0x001a 0x0108599f0418503a
|
||||
patword 0x001b 0x0108599f0418503a
|
||||
patword 0x001c 0x0108599f0418503a
|
||||
patword 0x001d 0x0108599f0418503a
|
||||
patword 0x001e 0x0108599f0418503a
|
||||
patword 0x001f 0x0108599f0418503a
|
||||
patword 0x0020 0x0108599f0418503a
|
||||
patword 0x0021 0x0108599f0418503a
|
||||
patword 0x0022 0x0108599f0418503a
|
||||
patword 0x0023 0x0108599f0418503a
|
||||
patword 0x0024 0x0108599f0418503a
|
||||
patword 0x0025 0x0108599f0418503a
|
||||
patword 0x0026 0x0108599f0418503a
|
||||
patword 0x0027 0x0108599f0418503a
|
||||
patword 0x0028 0x0108599f0418503a
|
||||
patword 0x0029 0x0108599f0418503a
|
||||
patword 0x002a 0x0108599f0418503a
|
||||
patword 0x002b 0x0108599f0418503a
|
||||
patword 0x002c 0x0108599f0418503a
|
||||
patword 0x002d 0x0108599f0418503a
|
||||
patword 0x002e 0x0108599f0418503a
|
||||
patword 0x002f 0x0108599f0418503a
|
||||
patword 0x0030 0x0108599f0418503a
|
||||
patword 0x0031 0x0108599f0418503a
|
||||
patword 0x0032 0x0108599f0418503a
|
||||
patword 0x0033 0x0108599f0418503a
|
||||
patword 0x0034 0x0108599f0418503a
|
||||
patword 0x0035 0x0108599f0418503a
|
||||
patword 0x0036 0x0108599f0418503a
|
||||
patword 0x0037 0x0108599f0418503a
|
||||
patword 0x0038 0x0108599f0418503a
|
||||
patword 0x0039 0x0108599f0418503a
|
||||
patword 0x003a 0x0108599f0418503a
|
||||
patword 0x003b 0x0108599f0418503a
|
||||
patword 0x003c 0x0108599f0418503a
|
||||
patword 0x003d 0x0108599f0418503a
|
||||
patword 0x003e 0x0108599f0418503a
|
||||
patword 0x003f 0x0108599f0418503a
|
||||
patword 0x0040 0x0108599f0418503a
|
||||
patword 0x0041 0x0108599f0418503a
|
||||
patword 0x0042 0x0108599f0418503a
|
||||
patword 0x0043 0x0108599f0418503a
|
||||
patword 0x0044 0x0108599f0418503a
|
||||
patword 0x0045 0x0108599f0418503a
|
||||
patword 0x0046 0x0108599f0418503a
|
||||
patword 0x0047 0x0108599f0418503a
|
||||
patword 0x0048 0x0108599f0418503a
|
||||
patword 0x0049 0x0108599f0418503a
|
||||
patword 0x004a 0x0108599f0418503a
|
||||
patword 0x004b 0x0108599f0418503a
|
||||
patword 0x004c 0x0108599f0418503a
|
||||
patword 0x004d 0x0108599f0418503a
|
||||
patword 0x004e 0x0108599f0418503a
|
||||
patword 0x004f 0x0108599f0418503a
|
||||
patword 0x0050 0x0108599f0418503a
|
||||
patword 0x0051 0x0108599f0418503a
|
||||
patword 0x0052 0x0108599f0418503a
|
||||
patword 0x0053 0x0108599f0418503a
|
||||
patword 0x0054 0x0108599f0418503a
|
||||
patword 0x0055 0x0108599f0418503a
|
||||
patword 0x0056 0x0108599f0418503a
|
||||
patword 0x0057 0x0108599f0418503a
|
||||
patword 0x0058 0x0108599f0418503a
|
||||
patword 0x0059 0x0108599f0418503a
|
||||
patword 0x005a 0x0108599f0418503a
|
||||
patword 0x005b 0x0108599f0418503a
|
||||
patword 0x005c 0x0108599f0418503a
|
||||
patword 0x005d 0x0108599f0418503a
|
||||
patword 0x005e 0x0108599f0418503a
|
||||
patword 0x005f 0x0108599f0418503a
|
||||
patword 0x0060 0x0108599f0418503a
|
||||
patword 0x0061 0x0108599f0418503a
|
||||
patword 0x0062 0x0108599f0418503a
|
||||
patword 0x0063 0x0108599f0418503a
|
||||
patword 0x0064 0x0108599f0418503a
|
||||
patword 0x0065 0x0108599f0418503a
|
||||
patword 0x0066 0x0108599f0418503a
|
||||
patword 0x0067 0x0108599f0418503a
|
||||
patword 0x0068 0x0108599f0418503a
|
||||
patword 0x0069 0x0108599f0418503a
|
||||
patword 0x006a 0x0108599f0418503a
|
||||
patword 0x006b 0x0108599f0418503a
|
||||
patword 0x006c 0x0108599f0418503a
|
||||
patword 0x006d 0x0108599f0418503a
|
||||
patword 0x006e 0x0108599f0418503a
|
||||
patword 0x006f 0x0108599f0418503a
|
||||
patword 0x0070 0x0108599f0418503a
|
||||
patword 0x0071 0x0108599f0418503a
|
||||
patword 0x0072 0x0108599f0418503a
|
||||
patword 0x0073 0x0108599f0418503a
|
||||
patword 0x0074 0x0108599f0418503a
|
||||
patword 0x0075 0x0108599f0418503a
|
||||
patword 0x0076 0x0108599f0418503a
|
||||
patword 0x0077 0x0108599f0418503a
|
||||
patword 0x0078 0x0108599f0418503a
|
||||
patword 0x0079 0x0108599f0418503a
|
||||
patword 0x007a 0x0108599f0418503a
|
||||
patword 0x007b 0x0108599f0418503a
|
||||
patword 0x007c 0x0108599f0418503a
|
||||
patword 0x007d 0x0108599f0418503a
|
||||
patword 0x007e 0x010859960418503a
|
||||
patword 0x007f 0x010859960418503a
|
||||
patword 0x0080 0x010859960418503a
|
||||
patword 0x0081 0x010859960418503a
|
||||
patword 0x0082 0x010859960418503a
|
||||
patword 0x0083 0x010859960418503a
|
||||
patword 0x0084 0x010859960418503a
|
||||
patword 0x0085 0x010859960418503a
|
||||
patword 0x0086 0x010859960418503a
|
||||
patword 0x0087 0x010859960418503a
|
||||
patword 0x0088 0x010859960418503a
|
||||
patword 0x0089 0x010859960418503a
|
||||
patword 0x008a 0x010859960418503a
|
||||
patword 0x008b 0x010859960418503a
|
||||
patword 0x008c 0x010859960418503a
|
||||
patword 0x008d 0x010859960418503a
|
||||
patword 0x008e 0x010859960418503a
|
||||
patword 0x008f 0x010859960418503a
|
||||
patword 0x0090 0x010859960418503a
|
||||
patword 0x0091 0x010859960418503a
|
||||
patword 0x0092 0x010819960418501a
|
||||
patword 0x0093 0x010819960418501a
|
||||
patword 0x0094 0x010819960418501a
|
||||
patword 0x0095 0x010819960418501a
|
||||
patword 0x0096 0x030819960418501a
|
||||
patword 0x0097 0x030819960418501a
|
||||
patword 0x0098 0x030819960418501a
|
||||
patword 0x0099 0x030819960418501a
|
||||
patword 0x009a 0x030819960418501a
|
||||
patword 0x009b 0x030819960418501a
|
||||
patword 0x009c 0x030819960418501a
|
||||
patword 0x009d 0x030819960418501a
|
||||
patword 0x009e 0x030819960418501a
|
||||
patword 0x009f 0x030819960418501a
|
||||
patword 0x00a0 0x030819960418501a
|
||||
patword 0x00a1 0x030819960418501a
|
||||
patword 0x00a2 0x030819960418501a
|
||||
patword 0x00a3 0x030819960418501a
|
||||
patword 0x00a4 0x030819960418501a
|
||||
patword 0x00a5 0x030819960418501a
|
||||
patword 0x00a6 0x030819960418501a
|
||||
patword 0x00a7 0x030819960418501a
|
||||
patword 0x00a8 0x030819960418501a
|
||||
patword 0x00a9 0x030819960418501a
|
||||
patword 0x00aa 0x030819960418501a
|
||||
patword 0x00ab 0x030819960418501a
|
||||
patword 0x00ac 0x030819960008501a
|
||||
patword 0x00ad 0x030819960008501a
|
||||
patword 0x00ae 0x030819960008501a
|
||||
patword 0x00af 0x030819960008501a
|
||||
patword 0x00b0 0x030819960008501a
|
||||
patword 0x00b1 0x030819960008501a
|
||||
patword 0x00b2 0x030819960008501a
|
||||
patword 0x00b3 0x030819960008501a
|
||||
patword 0x00b4 0x030819960008501a
|
||||
patword 0x00b5 0x030819960008501a
|
||||
patword 0x00b6 0x030819960008501a
|
||||
patword 0x00b7 0x030819960008501a
|
||||
patword 0x00b8 0x030819960008501a
|
||||
patword 0x00b9 0x030819960008501a
|
||||
patword 0x00ba 0x030819960008501a
|
||||
patword 0x00bb 0x030819960008501a
|
||||
patword 0x00bc 0x030819960008501a
|
||||
patword 0x00bd 0x030819960008501a
|
||||
patword 0x00be 0x030819960008501a
|
||||
patword 0x00bf 0x030819960008501a
|
||||
patword 0x00c0 0x0308199f0008501a
|
||||
patword 0x00c1 0x0308199f0008501a
|
||||
patword 0x00c2 0x0308199f0008501a
|
||||
patword 0x00c3 0x0308199f0008501a
|
||||
patword 0x00c4 0x0308199f0008501a
|
||||
patword 0x00c5 0x0308199f0008501a
|
||||
patword 0x00c6 0x0308199f0008501a
|
||||
patword 0x00c7 0x0308199f0008501a
|
||||
patword 0x00c8 0x0308199f0008501a
|
||||
patword 0x00c9 0x0308199f0008501a
|
||||
patword 0x00ca 0x0308199f0008501a
|
||||
patword 0x00cb 0x0308199f0008501a
|
||||
patword 0x00cc 0x0308199f0008501a
|
||||
patword 0x00cd 0x0308199f0008501a
|
||||
patword 0x00ce 0x0308199f0008501a
|
||||
patword 0x00cf 0x0308199f0008501a
|
||||
patword 0x00d0 0x0308199f0008501a
|
||||
patword 0x00d1 0x0308199f0008501a
|
||||
patword 0x00d2 0x0308199f0008501a
|
||||
patword 0x00d3 0x0308199f0008501a
|
||||
patword 0x00d4 0x0308599f0008503a
|
||||
patword 0x00d5 0x0308599f0008503a
|
||||
patword 0x00d6 0x030c599f000850ba
|
||||
patword 0x00d7 0x030c599f000850ba
|
||||
patword 0x00d8 0x030c599f000850ba
|
||||
patword 0x00d9 0x030c599f000850ba
|
||||
patword 0x00da 0x030c599f000850ba
|
||||
patword 0x00db 0x030c599f000850ba
|
||||
patword 0x00dc 0x030c599f000850ba
|
||||
patword 0x00dd 0x030c599f000850ba
|
||||
patword 0x00de 0x030c599f000850ba
|
||||
patword 0x00df 0x030c599f000850ba
|
||||
patword 0x00e0 0x030c599f000850ba
|
||||
patword 0x00e1 0x030c599f000850ba
|
||||
patword 0x00e2 0x030c599f000850ba
|
||||
patword 0x00e3 0x030c599f000850ba
|
||||
patword 0x00e4 0x030c599f000850ba
|
||||
patword 0x00e5 0x030c599f000850ba
|
||||
patword 0x00e6 0x030c599f000850ba
|
||||
patword 0x00e7 0x030c599f000850ba
|
||||
patword 0x00e8 0x030c599f000850ba
|
||||
patword 0x00e9 0x030c599f000850ba
|
||||
patword 0x00ea 0x030c799f010858ba
|
||||
patword 0x00eb 0x030c799f010858ba
|
||||
patword 0x00ec 0x030c599f000850ba
|
||||
patword 0x00ed 0x030c599f000850ba
|
||||
patword 0x00ee 0x030c599f000850ba
|
||||
patword 0x00ef 0x030c599f000850ba
|
||||
patword 0x00f0 0x030c599f000850ba
|
||||
patword 0x00f1 0x030c599f000850ba
|
||||
patword 0x00f2 0x030c599f000850ba
|
||||
patword 0x00f3 0x030c599f000850ba
|
||||
patword 0x00f4 0x030c599f000850ba
|
||||
patword 0x00f5 0x030c599f000850ba
|
||||
patword 0x00f6 0x030c599f000850ba
|
||||
patword 0x00f7 0x030c599f000850ba
|
||||
patword 0x00f8 0x030c599f000850ba
|
||||
patword 0x00f9 0x030c599f000850ba
|
||||
patword 0x00fa 0x030c599f000850ba
|
||||
patword 0x00fb 0x030c599f000850ba
|
||||
patword 0x00fc 0x030c599f000850ba
|
||||
patword 0x00fd 0x030c599f000850ba
|
||||
patword 0x00fe 0x030c599f000850ba
|
||||
patword 0x00ff 0x030c599f000850ba
|
||||
patword 0x0100 0x030c599f000850ba
|
||||
patword 0x0101 0x030c599f000850ba
|
||||
patword 0x0102 0x030c599f400850ba
|
||||
patword 0x0103 0x030c599f400850ba
|
||||
patword 0x0104 0x030c599f600850ba
|
||||
patword 0x0105 0x030c599f400850ba
|
||||
patword 0x0106 0x030c599f400850ba
|
||||
patword 0x0107 0x030c599f400850ba
|
||||
patword 0x0108 0x870c599f682e50ba
|
||||
patword 0x0109 0x870c599f482850ba
|
||||
patword 0x010a 0x870c599f000e50ba
|
||||
patword 0x010b 0x870c599f000850ba
|
||||
patword 0x010c 0x870c599f000e50ba
|
||||
patword 0x010d 0x870c599f000850ba
|
||||
patword 0x010e 0x870c599f000e50ba
|
||||
patword 0x010f 0x870c599f000850ba
|
||||
patword 0x0110 0x870c599f000e50ba
|
||||
patword 0x0111 0x870c599f000850ba
|
||||
patword 0x0112 0x870c599f000e50ba
|
||||
patword 0x0113 0x870c599f000850ba
|
||||
patword 0x0114 0x870c599f000e50ba
|
||||
patword 0x0115 0x870c599f000850ba
|
||||
patword 0x0116 0x870c599f000e50ba
|
||||
patword 0x0117 0x870c599f000850ba
|
||||
patword 0x0118 0x870c599f000e50ba
|
||||
patword 0x0119 0x870c599f000850ba
|
||||
patword 0x011a 0x870c599f000e50ba
|
||||
patword 0x011b 0x870c599f000850ba
|
||||
patword 0x011c 0x870c599f000e50ba
|
||||
patword 0x011d 0x870c599f000850ba
|
||||
patword 0x011e 0x870c599f000e50ba
|
||||
patword 0x011f 0x870c599f000850ba
|
||||
patword 0x0120 0x870c599f000e50ba
|
||||
patword 0x0121 0x870c599f000850ba
|
||||
patword 0x0122 0x870c599f200e50ba
|
||||
patword 0x0123 0x870c599f000850ba
|
||||
patword 0x0124 0x870c599f000e50ba
|
||||
patword 0x0125 0x870c599f000850ba
|
||||
patword 0x0126 0x870c599f000e50ba
|
||||
patword 0x0127 0x870c599f000850ba
|
||||
patword 0x0128 0x870c599f000e50ba
|
||||
patword 0x0129 0x870c599f000850ba
|
||||
patword 0x012a 0x870c599f000e50ba
|
||||
patword 0x012b 0x870c599f000850ba
|
||||
patword 0x012c 0x870c599f000e50ba
|
||||
patword 0x012d 0x870c599f000850ba
|
||||
patword 0x012e 0x870c599f000e50ba
|
||||
patword 0x012f 0x870c599f000850ba
|
||||
patword 0x0130 0x870c599f000e50ba
|
||||
patword 0x0131 0x870c599f000850ba
|
||||
patword 0x0132 0x870c599f000e50ba
|
||||
patword 0x0133 0x870c599f000850ba
|
||||
patword 0x0134 0x870c599f000e50ba
|
||||
patword 0x0135 0x870c599f000850ba
|
||||
patword 0x0136 0x870c599f000e50ba
|
||||
patword 0x0137 0x870c599f000850ba
|
||||
patword 0x0138 0x870c599f000e50ba
|
||||
patword 0x0139 0x870c599f000850ba
|
||||
patword 0x013a 0x870c599f282e50ba
|
||||
patword 0x013b 0x870c599f082850ba
|
||||
patword 0x013c 0x870c599f000e50ba
|
||||
patword 0x013d 0x870c599f000850ba
|
||||
patword 0x013e 0x870c599f000e50ba
|
||||
patword 0x013f 0x870c599f000850ba
|
||||
patword 0x0140 0x870c599f000e50ba
|
||||
patword 0x0141 0x870c599f000850ba
|
||||
patword 0x0142 0x870c599f000e50ba
|
||||
patword 0x0143 0x870c599f000850ba
|
||||
patword 0x0144 0x870c599f000e50ba
|
||||
patword 0x0145 0x870c599f000850ba
|
||||
patword 0x0146 0x870c599f000e50ba
|
||||
patword 0x0147 0x870c599f000850ba
|
||||
patword 0x0148 0x870c599f000e50ba
|
||||
patword 0x0149 0x870c599f000850ba
|
||||
patword 0x014a 0x870c599f000e50ba
|
||||
patword 0x014b 0x870c599f000850ba
|
||||
patword 0x014c 0x870c599f000e50ba
|
||||
patword 0x014d 0x870c599f000850ba
|
||||
patword 0x014e 0x870c599f000e50ba
|
||||
patword 0x014f 0x870c599f000850ba
|
||||
patword 0x0150 0x870c599f000e50ba
|
||||
patword 0x0151 0x870c599f000850ba
|
||||
patword 0x0152 0x870c599f000e50ba
|
||||
patword 0x0153 0x870c599f000850ba
|
||||
patword 0x0154 0x870c599f200e50ba
|
||||
patword 0x0155 0x870c599f000850ba
|
||||
patword 0x0156 0x870c599f000e50ba
|
||||
patword 0x0157 0x870c599f000850ba
|
||||
patword 0x0158 0x870c599f000e50ba
|
||||
patword 0x0159 0x870c599f000850ba
|
||||
patword 0x015a 0x870c599f000e50ba
|
||||
patword 0x015b 0x870c599f000850ba
|
||||
patword 0x015c 0x870c599f000e50ba
|
||||
patword 0x015d 0x870c599f000850ba
|
||||
patword 0x015e 0x870c599f000e50ba
|
||||
patword 0x015f 0x870c599f000850ba
|
||||
patword 0x0160 0x870c599f000e50ba
|
||||
patword 0x0161 0x870c599f000850ba
|
||||
patword 0x0162 0x870c599f000e50ba
|
||||
patword 0x0163 0x870c599f000850ba
|
||||
patword 0x0164 0x870c599f000e50ba
|
||||
patword 0x0165 0x870c599f000850ba
|
||||
patword 0x0166 0x870c599f000e50ba
|
||||
patword 0x0167 0x870c599f000850ba
|
||||
patword 0x0168 0x870c599f000e50ba
|
||||
patword 0x0169 0x870c599f000850ba
|
||||
patword 0x016a 0x870c599f000e50ba
|
||||
patword 0x016b 0x870c599f000850ba
|
||||
patword 0x016c 0x070c599f000850ba
|
||||
patword 0x016d 0x070c599f000850ba
|
||||
patword 0x016e 0x000c599f000850ba
|
||||
patword 0x016f 0x000c599f000850ba
|
||||
patword 0x0170 0x0008599f200e503a
|
||||
patword 0x0171 0x0008599f0008503a
|
||||
patword 0x0172 0x0008599f200e503a
|
||||
patword 0x0173 0x0008599f0008503a
|
||||
patword 0x0174 0x0008599f0008503a
|
||||
patword 0x0175 0x0008599f0008503a
|
||||
patword 0x0176 0x0008599f0008503a
|
||||
patword 0x0177 0x0008599f0008503a
|
||||
patword 0x0178 0x0008599f0008503a
|
||||
patword 0x0179 0x0008599f0008503a
|
||||
patword 0x017a 0x0008599f0008503a
|
||||
patword 0x017b 0x0008599f0008503a
|
||||
patword 0x017c 0x0008599f0008503a
|
||||
patword 0x017d 0x0008599f0008503a
|
||||
patword 0x017e 0x0008599f0008503a
|
||||
patword 0x017f 0x0008599f0008503a
|
||||
patword 0x0180 0x0008599f0008503a
|
||||
patword 0x0181 0x0008599f0008503a
|
||||
patword 0x0182 0x0008599f0008503a
|
||||
patword 0x0183 0x0008599f0008503a
|
||||
patword 0x0184 0x0008599f0008503a
|
||||
patword 0x0185 0x0008599f0008503a
|
||||
patword 0x0186 0x0008599f0008503a
|
||||
patword 0x0187 0x0008599f0008503a
|
||||
patword 0x0188 0x0008599f0008503a
|
||||
patword 0x0189 0x0008599f0008503a
|
||||
patword 0x018a 0x0008599f0008503a
|
||||
patword 0x018b 0x0008599f0008503a
|
||||
patword 0x018c 0x0008599f0008503a
|
||||
patword 0x018d 0x0008599f0008503a
|
||||
patioctrl 0x8f0effff6dbffdbf
|
||||
patlimits 0x0000 0x018c
|
||||
patloop 0 0x013a 0x016b
|
||||
patnloop 0 0x199
|
||||
patloop 1 0x0400 0x0400
|
||||
patnloop 1 0
|
||||
patloop 2 0x0400 0x0400
|
||||
patnloop 2 0
|
||||
patwait 0 0x00aa
|
||||
patwaittime 0 10000
|
||||
patwait 1 0x0400
|
||||
patwaittime 1 0
|
||||
patwait 2 0x0400
|
||||
patwaittime 2 0
|
||||
pattern /tmp/pattern.pat
|
||||
|
||||
# dacs
|
||||
dac 6 800
|
||||
|
@ -1,13 +1,13 @@
|
||||
# detector hostname
|
||||
hostname localhost:1900
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2000
|
||||
|
||||
# udp destination ports
|
||||
udp_dstport 50000
|
||||
udp_dstport2 50001
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2000
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
|
||||
|
@ -1,15 +1,13 @@
|
||||
# detector hostname
|
||||
hostname localhost:1900+localhost:1902+
|
||||
|
||||
# udp destination ports
|
||||
udp_dstport 50000
|
||||
udp_dstport2 50001
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2000+mpc1922:2001+
|
||||
|
||||
# udp destination ports
|
||||
0:udp_dstport 50000
|
||||
0:udp_dstport2 50001
|
||||
1:udp_dstport 50002
|
||||
1:udp_dstport2 50003
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
# detector hostname
|
||||
hostname localhost:1904
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2004
|
||||
|
||||
# udp destination ports
|
||||
udp_dstport 50004
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
|
||||
# udp source ip (same subnet as udp_dstip)
|
||||
udp_srcip 192.168.1.100
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2004
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
|
||||
# output file directory
|
||||
fpath /tmp
|
||||
|
||||
|
@ -1,24 +1,12 @@
|
||||
# detector hostname
|
||||
hostname localhost:1914
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2014
|
||||
|
||||
# udp destination ports
|
||||
udp_dstport 50014
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
|
||||
# udp source ip (same subnet as udp_dstip)
|
||||
udp_srcip 192.168.1.100
|
||||
|
||||
# output file directory
|
||||
fpath /tmp
|
||||
|
||||
# disable file writing
|
||||
fwrite 0
|
||||
|
||||
# enable 2nd interface for veto debugging
|
||||
# udp destination port for veto
|
||||
udp_dstport2 50015
|
||||
@ -27,6 +15,18 @@ udp_dstip2 auto
|
||||
# udp source ip (same subnet as udp_dstip)
|
||||
udp_srcip2 192.168.1.100
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2014
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
|
||||
# output file directory
|
||||
fpath /tmp
|
||||
|
||||
# disable file writing
|
||||
fwrite 0
|
||||
|
||||
# to enable 2nd interface for veto debugging
|
||||
numinterfaces 2
|
||||
|
||||
|
@ -1,21 +1,21 @@
|
||||
# detector hostname
|
||||
hostname localhost:1906
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2006
|
||||
|
||||
# udp destination ports
|
||||
udp_dstport 50006
|
||||
udp_dstport2 50007
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
udp_dstip2 auto
|
||||
|
||||
# udp source ip (same subnet as udp_dstip)
|
||||
udp_srcip 192.168.1.100
|
||||
udp_srcip2 192.168.1.100
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2006
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
udp_dstip2 auto
|
||||
|
||||
# output file directory
|
||||
fpath /tmp
|
||||
|
||||
|
@ -4,31 +4,33 @@ detsize 2048 1024
|
||||
# detector hostname
|
||||
virtual 4 1952
|
||||
|
||||
# receiver hostname and tcpports
|
||||
0:rx_tcpport 1970
|
||||
1:rx_tcpport 1971
|
||||
2:rx_tcpport 1972
|
||||
3:rx_tcpport 1973
|
||||
rx_hostname mpc1922
|
||||
|
||||
# udp destination ports
|
||||
0:udp_dstport2 50001
|
||||
0:udp_dstport2 50002
|
||||
1:udp_dstport 50003
|
||||
1:udp_dstport2 50004
|
||||
2:udp_dstport 50005
|
||||
2:udp_dstport2 50006
|
||||
3:udp_dstport 50007
|
||||
3:udp_dstport2 50008
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
udp_dstip2 auto
|
||||
udp_dstport 50001
|
||||
#0:udp_dstport2 50001
|
||||
#0:udp_dstport2 50002
|
||||
#1:udp_dstport 50003
|
||||
#1:udp_dstport2 50004
|
||||
#2:udp_dstport 50005
|
||||
#2:udp_dstport2 50006
|
||||
#3:udp_dstport 50007
|
||||
#3:udp_dstport2 50008
|
||||
|
||||
# udp source ip (same subnet as udp_dstip)
|
||||
udp_srcip 192.168.1.100
|
||||
udp_srcip2 192.168.1.100
|
||||
|
||||
# receiver hostname and tcpports
|
||||
rx_tcpport 1970
|
||||
#0:rx_tcpport 1970
|
||||
#1:rx_tcpport 1971
|
||||
#2:rx_tcpport 1972
|
||||
#3:rx_tcpport 1973
|
||||
rx_hostname mpc1922
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
udp_dstip2 auto
|
||||
|
||||
# transmission delay frame
|
||||
0:txndelay_frame 0
|
||||
1:txndelay_frame 1
|
||||
|
@ -1,18 +1,18 @@
|
||||
# detector hostname
|
||||
hostname localhost:1908
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2008
|
||||
|
||||
# udp destination ports
|
||||
udp_dstport 50008
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
|
||||
# udp source ip (same subnet as udp_dstip)
|
||||
udp_srcip 192.168.1.100
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2008
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
|
||||
# output file directory
|
||||
fpath /tmp
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
# detector hostname
|
||||
hostname localhost:1912
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2012
|
||||
|
||||
# udp destination ports
|
||||
udp_dstport 50012
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
|
||||
# udp source ip (same subnet as udp_dstip)
|
||||
udp_srcip 192.168.1.100
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2012
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
udp_dstip auto
|
||||
|
||||
# output file directory
|
||||
fpath /tmp
|
||||
|
||||
|
16
examples/zmq.config
Normal file
16
examples/zmq.config
Normal file
@ -0,0 +1,16 @@
|
||||
numinterfaces 1
|
||||
rx_zmqip 10.1.2.102
|
||||
rx_zmqport 1978
|
||||
zmqip 129.129.202.57
|
||||
zmqport 1979
|
||||
nthreads 6
|
||||
fifosize 5000
|
||||
nsigma 5
|
||||
gainfile none
|
||||
nbinsx 5
|
||||
nbinsy 5
|
||||
etafile none
|
||||
etabinsx 1000
|
||||
etabinsy 1000
|
||||
etamin -1
|
||||
etamax 2
|
BIN
libs/libzmq/libzmq-4.3.4.tar.gz
Normal file
BIN
libs/libzmq/libzmq-4.3.4.tar.gz
Normal file
Binary file not shown.
@ -1,299 +0,0 @@
|
||||
# CMakeLists.txt -- Build system for the pybind11 modules
|
||||
#
|
||||
# Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch>
|
||||
#
|
||||
# All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
cmake_minimum_required(VERSION 3.4)
|
||||
|
||||
# The `cmake_minimum_required(VERSION 3.4...3.22)` syntax does not work with
|
||||
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||
# the behavior using the following workaround:
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.22)
|
||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||
else()
|
||||
cmake_policy(VERSION 3.22)
|
||||
endif()
|
||||
|
||||
# Avoid infinite recursion if tests include this as a subdirectory
|
||||
if(DEFINED PYBIND11_MASTER_PROJECT)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Extract project version from source
|
||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/pybind11/detail/common.h"
|
||||
pybind11_version_defines REGEX "#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) ")
|
||||
|
||||
foreach(ver ${pybind11_version_defines})
|
||||
if(ver MATCHES [[#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$]])
|
||||
set(PYBIND11_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(PYBIND11_VERSION_PATCH MATCHES [[\.([a-zA-Z0-9]+)$]])
|
||||
set(pybind11_VERSION_TYPE "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
string(REGEX MATCH "^[0-9]+" PYBIND11_VERSION_PATCH "${PYBIND11_VERSION_PATCH}")
|
||||
|
||||
project(
|
||||
pybind11
|
||||
LANGUAGES CXX
|
||||
VERSION "${PYBIND11_VERSION_MAJOR}.${PYBIND11_VERSION_MINOR}.${PYBIND11_VERSION_PATCH}")
|
||||
|
||||
# Standard includes
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(CMakeDependentOption)
|
||||
|
||||
if(NOT pybind11_FIND_QUIETLY)
|
||||
message(STATUS "pybind11 v${pybind11_VERSION} ${pybind11_VERSION_TYPE}")
|
||||
endif()
|
||||
|
||||
# Check if pybind11 is being used directly or via add_subdirectory
|
||||
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
||||
### Warn if not an out-of-source builds
|
||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
set(lines
|
||||
"You are building in-place. If that is not what you intended to "
|
||||
"do, you can clean the source directory with:\n"
|
||||
"rm -r CMakeCache.txt CMakeFiles/ cmake_uninstall.cmake pybind11Config.cmake "
|
||||
"pybind11ConfigVersion.cmake tests/CMakeFiles/\n")
|
||||
message(AUTHOR_WARNING ${lines})
|
||||
endif()
|
||||
|
||||
set(PYBIND11_MASTER_PROJECT ON)
|
||||
|
||||
if(OSX AND CMAKE_VERSION VERSION_LESS 3.7)
|
||||
# Bug in macOS CMake < 3.7 is unable to download catch
|
||||
message(WARNING "CMAKE 3.7+ needed on macOS to download catch, and newer HIGHLY recommended")
|
||||
elseif(WINDOWS AND CMAKE_VERSION VERSION_LESS 3.8)
|
||||
# Only tested with 3.8+ in CI.
|
||||
message(WARNING "CMAKE 3.8+ tested on Windows, previous versions untested")
|
||||
endif()
|
||||
|
||||
message(STATUS "CMake ${CMAKE_VERSION}")
|
||||
|
||||
if(CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
endif()
|
||||
|
||||
set(pybind11_system "")
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
else()
|
||||
set(PYBIND11_MASTER_PROJECT OFF)
|
||||
set(pybind11_system SYSTEM)
|
||||
endif()
|
||||
|
||||
# Options
|
||||
option(PYBIND11_INSTALL "Install pybind11 header files?" ${PYBIND11_MASTER_PROJECT})
|
||||
option(PYBIND11_TEST "Build pybind11 test suite?" ${PYBIND11_MASTER_PROJECT})
|
||||
option(PYBIND11_NOPYTHON "Disable search for Python" OFF)
|
||||
set(PYBIND11_INTERNALS_VERSION
|
||||
""
|
||||
CACHE STRING "Override the ABI version, may be used to enable the unstable ABI.")
|
||||
|
||||
cmake_dependent_option(
|
||||
USE_PYTHON_INCLUDE_DIR
|
||||
"Install pybind11 headers in Python include directory instead of default installation prefix"
|
||||
OFF "PYBIND11_INSTALL" OFF)
|
||||
|
||||
cmake_dependent_option(PYBIND11_FINDPYTHON "Force new FindPython" OFF
|
||||
"NOT CMAKE_VERSION VERSION_LESS 3.12" OFF)
|
||||
|
||||
# NB: when adding a header don't forget to also add it to setup.py
|
||||
set(PYBIND11_HEADERS
|
||||
include/pybind11/detail/class.h
|
||||
include/pybind11/detail/common.h
|
||||
include/pybind11/detail/descr.h
|
||||
include/pybind11/detail/init.h
|
||||
include/pybind11/detail/internals.h
|
||||
include/pybind11/detail/type_caster_base.h
|
||||
include/pybind11/detail/typeid.h
|
||||
include/pybind11/attr.h
|
||||
include/pybind11/buffer_info.h
|
||||
include/pybind11/cast.h
|
||||
include/pybind11/chrono.h
|
||||
include/pybind11/common.h
|
||||
include/pybind11/complex.h
|
||||
include/pybind11/options.h
|
||||
include/pybind11/eigen.h
|
||||
include/pybind11/embed.h
|
||||
include/pybind11/eval.h
|
||||
include/pybind11/gil.h
|
||||
include/pybind11/iostream.h
|
||||
include/pybind11/functional.h
|
||||
include/pybind11/numpy.h
|
||||
include/pybind11/operators.h
|
||||
include/pybind11/pybind11.h
|
||||
include/pybind11/pytypes.h
|
||||
include/pybind11/stl.h
|
||||
include/pybind11/stl_bind.h
|
||||
include/pybind11/stl/filesystem.h)
|
||||
|
||||
# Compare with grep and warn if mismatched
|
||||
if(PYBIND11_MASTER_PROJECT AND NOT CMAKE_VERSION VERSION_LESS 3.12)
|
||||
file(
|
||||
GLOB_RECURSE _pybind11_header_check
|
||||
LIST_DIRECTORIES false
|
||||
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
CONFIGURE_DEPENDS "include/pybind11/*.h")
|
||||
set(_pybind11_here_only ${PYBIND11_HEADERS})
|
||||
set(_pybind11_disk_only ${_pybind11_header_check})
|
||||
list(REMOVE_ITEM _pybind11_here_only ${_pybind11_header_check})
|
||||
list(REMOVE_ITEM _pybind11_disk_only ${PYBIND11_HEADERS})
|
||||
if(_pybind11_here_only)
|
||||
message(AUTHOR_WARNING "PYBIND11_HEADERS has extra files:" ${_pybind11_here_only})
|
||||
endif()
|
||||
if(_pybind11_disk_only)
|
||||
message(AUTHOR_WARNING "PYBIND11_HEADERS is missing files:" ${_pybind11_disk_only})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# CMake 3.12 added list(TRANSFORM <list> PREPEND
|
||||
# But we can't use it yet
|
||||
string(REPLACE "include/" "${CMAKE_CURRENT_SOURCE_DIR}/include/" PYBIND11_HEADERS
|
||||
"${PYBIND11_HEADERS}")
|
||||
|
||||
# Cache variable so this can be used in parent projects
|
||||
set(pybind11_INCLUDE_DIR
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include"
|
||||
CACHE INTERNAL "Directory where pybind11 headers are located")
|
||||
|
||||
# Backward compatible variable for add_subdirectory mode
|
||||
if(NOT PYBIND11_MASTER_PROJECT)
|
||||
set(PYBIND11_INCLUDE_DIR
|
||||
"${pybind11_INCLUDE_DIR}"
|
||||
CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
# Note: when creating targets, you cannot use if statements at configure time -
|
||||
# you need generator expressions, because those will be placed in the target file.
|
||||
# You can also place ifs *in* the Config.in, but not here.
|
||||
|
||||
# This section builds targets, but does *not* touch Python
|
||||
# Non-IMPORT targets cannot be defined twice
|
||||
if(NOT TARGET pybind11_headers)
|
||||
# Build the headers-only target (no Python included):
|
||||
# (long name used here to keep this from clashing in subdirectory mode)
|
||||
add_library(pybind11_headers INTERFACE)
|
||||
add_library(pybind11::pybind11_headers ALIAS pybind11_headers) # to match exported target
|
||||
add_library(pybind11::headers ALIAS pybind11_headers) # easier to use/remember
|
||||
|
||||
target_include_directories(
|
||||
pybind11_headers ${pybind11_system} INTERFACE $<BUILD_INTERFACE:${pybind11_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
|
||||
target_compile_features(pybind11_headers INTERFACE cxx_inheriting_constructors cxx_user_literals
|
||||
cxx_right_angle_brackets)
|
||||
if(NOT "${PYBIND11_INTERNALS_VERSION}" STREQUAL "")
|
||||
target_compile_definitions(
|
||||
pybind11_headers INTERFACE "PYBIND11_INTERNALS_VERSION=${PYBIND11_INTERNALS_VERSION}")
|
||||
endif()
|
||||
else()
|
||||
# It is invalid to install a target twice, too.
|
||||
set(PYBIND11_INSTALL OFF)
|
||||
endif()
|
||||
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11Common.cmake")
|
||||
|
||||
# Relative directory setting
|
||||
if(USE_PYTHON_INCLUDE_DIR AND DEFINED Python_INCLUDE_DIRS)
|
||||
file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${Python_INCLUDE_DIRS})
|
||||
elseif(USE_PYTHON_INCLUDE_DIR AND DEFINED PYTHON_INCLUDE_DIR)
|
||||
file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${PYTHON_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(PYBIND11_INSTALL)
|
||||
install(DIRECTORY ${pybind11_INCLUDE_DIR}/pybind11 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
set(PYBIND11_CMAKECONFIG_INSTALL_DIR
|
||||
"${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}"
|
||||
CACHE STRING "install path for pybind11Config.cmake")
|
||||
|
||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
set(pybind11_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
|
||||
else()
|
||||
set(pybind11_INCLUDEDIR "\$\{PACKAGE_PREFIX_DIR\}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
endif()
|
||||
|
||||
configure_package_config_file(
|
||||
tools/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||
INSTALL_DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 3.14)
|
||||
# Remove CMAKE_SIZEOF_VOID_P from ConfigVersion.cmake since the library does
|
||||
# not depend on architecture specific settings or libraries.
|
||||
set(_PYBIND11_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
|
||||
unset(CMAKE_SIZEOF_VOID_P)
|
||||
|
||||
write_basic_package_version_file(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion)
|
||||
|
||||
set(CMAKE_SIZEOF_VOID_P ${_PYBIND11_CMAKE_SIZEOF_VOID_P})
|
||||
else()
|
||||
# CMake 3.14+ natively supports header-only libraries
|
||||
write_basic_package_version_file(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion ARCH_INDEPENDENT)
|
||||
endif()
|
||||
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
||||
tools/FindPythonLibsNew.cmake
|
||||
tools/pybind11Common.cmake
|
||||
tools/pybind11Tools.cmake
|
||||
tools/pybind11NewTools.cmake
|
||||
DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
|
||||
|
||||
if(NOT PYBIND11_EXPORT_NAME)
|
||||
set(PYBIND11_EXPORT_NAME "${PROJECT_NAME}Targets")
|
||||
endif()
|
||||
|
||||
install(TARGETS pybind11_headers EXPORT "${PYBIND11_EXPORT_NAME}")
|
||||
|
||||
install(
|
||||
EXPORT "${PYBIND11_EXPORT_NAME}"
|
||||
NAMESPACE "pybind11::"
|
||||
DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
|
||||
|
||||
# Uninstall target
|
||||
if(PYBIND11_MASTER_PROJECT)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
||||
|
||||
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# BUILD_TESTING takes priority, but only if this is the master project
|
||||
if(PYBIND11_MASTER_PROJECT AND DEFINED BUILD_TESTING)
|
||||
if(BUILD_TESTING)
|
||||
if(_pybind11_nopython)
|
||||
message(FATAL_ERROR "Cannot activate tests in NOPYTHON mode")
|
||||
else()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
if(PYBIND11_TEST)
|
||||
if(_pybind11_nopython)
|
||||
message(FATAL_ERROR "Cannot activate tests in NOPYTHON mode")
|
||||
else()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Better symmetry with find_package(pybind11 CONFIG) mode.
|
||||
if(NOT PYBIND11_MASTER_PROJECT)
|
||||
set(pybind11_FOUND
|
||||
TRUE
|
||||
CACHE INTERNAL "True if pybind11 and all required components found on the system")
|
||||
endif()
|
@ -1,29 +0,0 @@
|
||||
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>, All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Please also refer to the file .github/CONTRIBUTING.md, which clarifies licensing of
|
||||
external contributions to this project including patches, pull requests, etc.
|
@ -1,5 +0,0 @@
|
||||
recursive-include pybind11/include/pybind11 *.h
|
||||
recursive-include pybind11 *.py
|
||||
recursive-include pybind11 py.typed
|
||||
include pybind11/share/cmake/pybind11/*.cmake
|
||||
include LICENSE README.rst pyproject.toml setup.py setup.cfg
|
@ -1,180 +0,0 @@
|
||||
.. figure:: https://github.com/pybind/pybind11/raw/master/docs/pybind11-logo.png
|
||||
:alt: pybind11 logo
|
||||
|
||||
**pybind11 — Seamless operability between C++11 and Python**
|
||||
|
||||
|Latest Documentation Status| |Stable Documentation Status| |Gitter chat| |GitHub Discussions| |CI| |Build status|
|
||||
|
||||
|Repology| |PyPI package| |Conda-forge| |Python Versions|
|
||||
|
||||
`Setuptools example <https://github.com/pybind/python_example>`_
|
||||
• `Scikit-build example <https://github.com/pybind/scikit_build_example>`_
|
||||
• `CMake example <https://github.com/pybind/cmake_example>`_
|
||||
|
||||
.. start
|
||||
|
||||
|
||||
**pybind11** is a lightweight header-only library that exposes C++ types
|
||||
in Python and vice versa, mainly to create Python bindings of existing
|
||||
C++ code. Its goals and syntax are similar to the excellent
|
||||
`Boost.Python <http://www.boost.org/doc/libs/1_58_0/libs/python/doc/>`_
|
||||
library by David Abrahams: to minimize boilerplate code in traditional
|
||||
extension modules by inferring type information using compile-time
|
||||
introspection.
|
||||
|
||||
The main issue with Boost.Python—and the reason for creating such a
|
||||
similar project—is Boost. Boost is an enormously large and complex suite
|
||||
of utility libraries that works with almost every C++ compiler in
|
||||
existence. This compatibility has its cost: arcane template tricks and
|
||||
workarounds are necessary to support the oldest and buggiest of compiler
|
||||
specimens. Now that C++11-compatible compilers are widely available,
|
||||
this heavy machinery has become an excessively large and unnecessary
|
||||
dependency.
|
||||
|
||||
Think of this library as a tiny self-contained version of Boost.Python
|
||||
with everything stripped away that isn't relevant for binding
|
||||
generation. Without comments, the core header files only require ~4K
|
||||
lines of code and depend on Python (3.6+, or PyPy) and the C++
|
||||
standard library. This compact implementation was possible thanks to
|
||||
some of the new C++11 language features (specifically: tuples, lambda
|
||||
functions and variadic templates). Since its creation, this library has
|
||||
grown beyond Boost.Python in many ways, leading to dramatically simpler
|
||||
binding code in many common situations.
|
||||
|
||||
Tutorial and reference documentation is provided at
|
||||
`pybind11.readthedocs.io <https://pybind11.readthedocs.io/en/latest>`_.
|
||||
A PDF version of the manual is available
|
||||
`here <https://pybind11.readthedocs.io/_/downloads/en/latest/pdf/>`_.
|
||||
And the source code is always available at
|
||||
`github.com/pybind/pybind11 <https://github.com/pybind/pybind11>`_.
|
||||
|
||||
|
||||
Core features
|
||||
-------------
|
||||
|
||||
|
||||
pybind11 can map the following core C++ features to Python:
|
||||
|
||||
- Functions accepting and returning custom data structures per value,
|
||||
reference, or pointer
|
||||
- Instance methods and static methods
|
||||
- Overloaded functions
|
||||
- Instance attributes and static attributes
|
||||
- Arbitrary exception types
|
||||
- Enumerations
|
||||
- Callbacks
|
||||
- Iterators and ranges
|
||||
- Custom operators
|
||||
- Single and multiple inheritance
|
||||
- STL data structures
|
||||
- Smart pointers with reference counting like ``std::shared_ptr``
|
||||
- Internal references with correct reference counting
|
||||
- C++ classes with virtual (and pure virtual) methods can be extended
|
||||
in Python
|
||||
|
||||
Goodies
|
||||
-------
|
||||
|
||||
In addition to the core functionality, pybind11 provides some extra
|
||||
goodies:
|
||||
|
||||
- Python 3.6+, and PyPy3 7.3 are supported with an implementation-agnostic
|
||||
interface (pybind11 2.9 was the last version to support Python 2 and 3.5).
|
||||
|
||||
- It is possible to bind C++11 lambda functions with captured
|
||||
variables. The lambda capture data is stored inside the resulting
|
||||
Python function object.
|
||||
|
||||
- pybind11 uses C++11 move constructors and move assignment operators
|
||||
whenever possible to efficiently transfer custom data types.
|
||||
|
||||
- It's easy to expose the internal storage of custom data types through
|
||||
Pythons' buffer protocols. This is handy e.g. for fast conversion
|
||||
between C++ matrix classes like Eigen and NumPy without expensive
|
||||
copy operations.
|
||||
|
||||
- pybind11 can automatically vectorize functions so that they are
|
||||
transparently applied to all entries of one or more NumPy array
|
||||
arguments.
|
||||
|
||||
- Python's slice-based access and assignment operations can be
|
||||
supported with just a few lines of code.
|
||||
|
||||
- Everything is contained in just a few header files; there is no need
|
||||
to link against any additional libraries.
|
||||
|
||||
- Binaries are generally smaller by a factor of at least 2 compared to
|
||||
equivalent bindings generated by Boost.Python. A recent pybind11
|
||||
conversion of PyRosetta, an enormous Boost.Python binding project,
|
||||
`reported <https://graylab.jhu.edu/Sergey/2016.RosettaCon/PyRosetta-4.pdf>`_
|
||||
a binary size reduction of **5.4x** and compile time reduction by
|
||||
**5.8x**.
|
||||
|
||||
- Function signatures are precomputed at compile time (using
|
||||
``constexpr``), leading to smaller binaries.
|
||||
|
||||
- With little extra effort, C++ types can be pickled and unpickled
|
||||
similar to regular Python objects.
|
||||
|
||||
Supported compilers
|
||||
-------------------
|
||||
|
||||
1. Clang/LLVM 3.3 or newer (for Apple Xcode's clang, this is 5.0.0 or
|
||||
newer)
|
||||
2. GCC 4.8 or newer
|
||||
3. Microsoft Visual Studio 2017 or newer
|
||||
4. Intel classic C++ compiler 18 or newer (ICC 20.2 tested in CI)
|
||||
5. Cygwin/GCC (previously tested on 2.5.1)
|
||||
6. NVCC (CUDA 11.0 tested in CI)
|
||||
7. NVIDIA PGI (20.9 tested in CI)
|
||||
|
||||
About
|
||||
-----
|
||||
|
||||
This project was created by `Wenzel
|
||||
Jakob <http://rgl.epfl.ch/people/wjakob>`_. Significant features and/or
|
||||
improvements to the code were contributed by Jonas Adler, Lori A. Burns,
|
||||
Sylvain Corlay, Eric Cousineau, Aaron Gokaslan, Ralf Grosse-Kunstleve, Trent Houliston, Axel
|
||||
Huebl, @hulucc, Yannick Jadoul, Sergey Lyskov Johan Mabille, Tomasz Miąsko,
|
||||
Dean Moldovan, Ben Pritchard, Jason Rhinelander, Boris Schäling, Pim
|
||||
Schellart, Henry Schreiner, Ivan Smirnov, Boris Staletic, and Patrick Stewart.
|
||||
|
||||
We thank Google for a generous financial contribution to the continuous
|
||||
integration infrastructure used by this project.
|
||||
|
||||
|
||||
Contributing
|
||||
~~~~~~~~~~~~
|
||||
|
||||
See the `contributing
|
||||
guide <https://github.com/pybind/pybind11/blob/master/.github/CONTRIBUTING.md>`_
|
||||
for information on building and contributing to pybind11.
|
||||
|
||||
License
|
||||
~~~~~~~
|
||||
|
||||
pybind11 is provided under a BSD-style license that can be found in the
|
||||
`LICENSE <https://github.com/pybind/pybind11/blob/master/LICENSE>`_
|
||||
file. By using, distributing, or contributing to this project, you agree
|
||||
to the terms and conditions of this license.
|
||||
|
||||
.. |Latest Documentation Status| image:: https://readthedocs.org/projects/pybind11/badge?version=latest
|
||||
:target: http://pybind11.readthedocs.org/en/latest
|
||||
.. |Stable Documentation Status| image:: https://img.shields.io/badge/docs-stable-blue.svg
|
||||
:target: http://pybind11.readthedocs.org/en/stable
|
||||
.. |Gitter chat| image:: https://img.shields.io/gitter/room/gitterHQ/gitter.svg
|
||||
:target: https://gitter.im/pybind/Lobby
|
||||
.. |CI| image:: https://github.com/pybind/pybind11/workflows/CI/badge.svg
|
||||
:target: https://github.com/pybind/pybind11/actions
|
||||
.. |Build status| image:: https://ci.appveyor.com/api/projects/status/riaj54pn4h08xy40?svg=true
|
||||
:target: https://ci.appveyor.com/project/wjakob/pybind11
|
||||
.. |PyPI package| image:: https://img.shields.io/pypi/v/pybind11.svg
|
||||
:target: https://pypi.org/project/pybind11/
|
||||
.. |Conda-forge| image:: https://img.shields.io/conda/vn/conda-forge/pybind11.svg
|
||||
:target: https://github.com/conda-forge/pybind11-feedstock
|
||||
.. |Repology| image:: https://repology.org/badge/latest-versions/python:pybind11.svg
|
||||
:target: https://repology.org/project/python:pybind11/versions
|
||||
.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/pybind11.svg
|
||||
:target: https://pypi.org/project/pybind11/
|
||||
.. |GitHub Discussions| image:: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github
|
||||
:target: https://github.com/pybind/pybind11/discussions
|
@ -1,21 +0,0 @@
|
||||
PROJECT_NAME = pybind11
|
||||
INPUT = ../include/pybind11/
|
||||
RECURSIVE = YES
|
||||
|
||||
GENERATE_HTML = NO
|
||||
GENERATE_LATEX = NO
|
||||
GENERATE_XML = YES
|
||||
XML_OUTPUT = .build/doxygenxml
|
||||
XML_PROGRAMLISTING = YES
|
||||
|
||||
MACRO_EXPANSION = YES
|
||||
EXPAND_ONLY_PREDEF = YES
|
||||
EXPAND_AS_DEFINED = PYBIND11_RUNTIME_EXCEPTION
|
||||
|
||||
ALIASES = "rst=\verbatim embed:rst"
|
||||
ALIASES += "endrst=\endverbatim"
|
||||
|
||||
QUIET = YES
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = NO
|
||||
PREDEFINED = PYBIND11_NOINLINE
|
@ -1,192 +0,0 @@
|
||||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = .build
|
||||
|
||||
# User-friendly check for sphinx-build
|
||||
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
|
||||
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
|
||||
endif
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
# the i18n builder cannot share the environment and doctrees with the others
|
||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " dirhtml to make HTML files named index.html in directories"
|
||||
@echo " singlehtml to make a single large HTML file"
|
||||
@echo " pickle to make pickle files"
|
||||
@echo " json to make JSON files"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " qthelp to make HTML files and a qthelp project"
|
||||
@echo " applehelp to make an Apple Help Book"
|
||||
@echo " devhelp to make HTML files and a Devhelp project"
|
||||
@echo " epub to make an epub"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
|
||||
@echo " text to make text files"
|
||||
@echo " man to make manual pages"
|
||||
@echo " texinfo to make Texinfo files"
|
||||
@echo " info to make Texinfo files and run them through makeinfo"
|
||||
@echo " gettext to make PO message catalogs"
|
||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
||||
@echo " xml to make Docutils-native XML files"
|
||||
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||
@echo " coverage to run coverage check of the documentation (if enabled)"
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)/*
|
||||
|
||||
html:
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
dirhtml:
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
singlehtml:
|
||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||
|
||||
pickle:
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
json:
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
htmlhelp:
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||
|
||||
qthelp:
|
||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pybind11.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pybind11.qhc"
|
||||
|
||||
applehelp:
|
||||
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
|
||||
@echo
|
||||
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
|
||||
@echo "N.B. You won't be able to view it unless you put it in" \
|
||||
"~/Library/Documentation/Help or install it in your application" \
|
||||
"bundle."
|
||||
|
||||
devhelp:
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/pybind11"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/pybind11"
|
||||
@echo "# devhelp"
|
||||
|
||||
epub:
|
||||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||
@echo
|
||||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||
|
||||
latex:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||
"(use \`make latexpdf' here to do that automatically)."
|
||||
|
||||
latexpdf:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through pdflatex..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
latexpdfja:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through platex and dvipdfmx..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
text:
|
||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||
@echo
|
||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||
|
||||
man:
|
||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||
@echo
|
||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||
|
||||
texinfo:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo
|
||||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
||||
@echo "Run \`make' in that directory to run these through makeinfo" \
|
||||
"(use \`make info' here to do that automatically)."
|
||||
|
||||
info:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo "Running Texinfo files through makeinfo..."
|
||||
make -C $(BUILDDIR)/texinfo info
|
||||
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
||||
|
||||
gettext:
|
||||
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
||||
@echo
|
||||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
||||
|
||||
changes:
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||
@echo
|
||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
||||
|
||||
linkcheck:
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
"or in $(BUILDDIR)/linkcheck/output.txt."
|
||||
|
||||
doctest:
|
||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||
@echo "Testing of doctests in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/doctest/output.txt."
|
||||
|
||||
coverage:
|
||||
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
|
||||
@echo "Testing of coverage in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/coverage/python.txt."
|
||||
|
||||
xml:
|
||||
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
|
||||
@echo
|
||||
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
|
||||
|
||||
pseudoxml:
|
||||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
||||
@echo
|
||||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
3
libs/pybind/docs/_static/css/custom.css
vendored
3
libs/pybind/docs/_static/css/custom.css
vendored
@ -1,3 +0,0 @@
|
||||
.highlight .go {
|
||||
color: #707070;
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
Chrono
|
||||
======
|
||||
|
||||
When including the additional header file :file:`pybind11/chrono.h` conversions
|
||||
from C++11 chrono datatypes to python datetime objects are automatically enabled.
|
||||
This header also enables conversions of python floats (often from sources such
|
||||
as ``time.monotonic()``, ``time.perf_counter()`` and ``time.process_time()``)
|
||||
into durations.
|
||||
|
||||
An overview of clocks in C++11
|
||||
------------------------------
|
||||
|
||||
A point of confusion when using these conversions is the differences between
|
||||
clocks provided in C++11. There are three clock types defined by the C++11
|
||||
standard and users can define their own if needed. Each of these clocks have
|
||||
different properties and when converting to and from python will give different
|
||||
results.
|
||||
|
||||
The first clock defined by the standard is ``std::chrono::system_clock``. This
|
||||
clock measures the current date and time. However, this clock changes with to
|
||||
updates to the operating system time. For example, if your time is synchronised
|
||||
with a time server this clock will change. This makes this clock a poor choice
|
||||
for timing purposes but good for measuring the wall time.
|
||||
|
||||
The second clock defined in the standard is ``std::chrono::steady_clock``.
|
||||
This clock ticks at a steady rate and is never adjusted. This makes it excellent
|
||||
for timing purposes, however the value in this clock does not correspond to the
|
||||
current date and time. Often this clock will be the amount of time your system
|
||||
has been on, although it does not have to be. This clock will never be the same
|
||||
clock as the system clock as the system clock can change but steady clocks
|
||||
cannot.
|
||||
|
||||
The third clock defined in the standard is ``std::chrono::high_resolution_clock``.
|
||||
This clock is the clock that has the highest resolution out of the clocks in the
|
||||
system. It is normally a typedef to either the system clock or the steady clock
|
||||
but can be its own independent clock. This is important as when using these
|
||||
conversions as the types you get in python for this clock might be different
|
||||
depending on the system.
|
||||
If it is a typedef of the system clock, python will get datetime objects, but if
|
||||
it is a different clock they will be timedelta objects.
|
||||
|
||||
Provided conversions
|
||||
--------------------
|
||||
|
||||
.. rubric:: C++ to Python
|
||||
|
||||
- ``std::chrono::system_clock::time_point`` → ``datetime.datetime``
|
||||
System clock times are converted to python datetime instances. They are
|
||||
in the local timezone, but do not have any timezone information attached
|
||||
to them (they are naive datetime objects).
|
||||
|
||||
- ``std::chrono::duration`` → ``datetime.timedelta``
|
||||
Durations are converted to timedeltas, any precision in the duration
|
||||
greater than microseconds is lost by rounding towards zero.
|
||||
|
||||
- ``std::chrono::[other_clocks]::time_point`` → ``datetime.timedelta``
|
||||
Any clock time that is not the system clock is converted to a time delta.
|
||||
This timedelta measures the time from the clocks epoch to now.
|
||||
|
||||
.. rubric:: Python to C++
|
||||
|
||||
- ``datetime.datetime`` or ``datetime.date`` or ``datetime.time`` → ``std::chrono::system_clock::time_point``
|
||||
Date/time objects are converted into system clock timepoints. Any
|
||||
timezone information is ignored and the type is treated as a naive
|
||||
object.
|
||||
|
||||
- ``datetime.timedelta`` → ``std::chrono::duration``
|
||||
Time delta are converted into durations with microsecond precision.
|
||||
|
||||
- ``datetime.timedelta`` → ``std::chrono::[other_clocks]::time_point``
|
||||
Time deltas that are converted into clock timepoints are treated as
|
||||
the amount of time from the start of the clocks epoch.
|
||||
|
||||
- ``float`` → ``std::chrono::duration``
|
||||
Floats that are passed to C++ as durations be interpreted as a number of
|
||||
seconds. These will be converted to the duration using ``duration_cast``
|
||||
from the float.
|
||||
|
||||
- ``float`` → ``std::chrono::[other_clocks]::time_point``
|
||||
Floats that are passed to C++ as time points will be interpreted as the
|
||||
number of seconds from the start of the clocks epoch.
|
@ -1,93 +0,0 @@
|
||||
Custom type casters
|
||||
===================
|
||||
|
||||
In very rare cases, applications may require custom type casters that cannot be
|
||||
expressed using the abstractions provided by pybind11, thus requiring raw
|
||||
Python C API calls. This is fairly advanced usage and should only be pursued by
|
||||
experts who are familiar with the intricacies of Python reference counting.
|
||||
|
||||
The following snippets demonstrate how this works for a very simple ``inty``
|
||||
type that that should be convertible from Python types that provide a
|
||||
``__int__(self)`` method.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
struct inty { long long_value; };
|
||||
|
||||
void print(inty s) {
|
||||
std::cout << s.long_value << std::endl;
|
||||
}
|
||||
|
||||
The following Python snippet demonstrates the intended usage from the Python side:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class A:
|
||||
def __int__(self):
|
||||
return 123
|
||||
|
||||
|
||||
from example import print
|
||||
|
||||
print(A())
|
||||
|
||||
To register the necessary conversion routines, it is necessary to add an
|
||||
instantiation of the ``pybind11::detail::type_caster<T>`` template.
|
||||
Although this is an implementation detail, adding an instantiation of this
|
||||
type is explicitly allowed.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namespace pybind11 { namespace detail {
|
||||
template <> struct type_caster<inty> {
|
||||
public:
|
||||
/**
|
||||
* This macro establishes the name 'inty' in
|
||||
* function signatures and declares a local variable
|
||||
* 'value' of type inty
|
||||
*/
|
||||
PYBIND11_TYPE_CASTER(inty, const_name("inty"));
|
||||
|
||||
/**
|
||||
* Conversion part 1 (Python->C++): convert a PyObject into a inty
|
||||
* instance or return false upon failure. The second argument
|
||||
* indicates whether implicit conversions should be applied.
|
||||
*/
|
||||
bool load(handle src, bool) {
|
||||
/* Extract PyObject from handle */
|
||||
PyObject *source = src.ptr();
|
||||
/* Try converting into a Python integer value */
|
||||
PyObject *tmp = PyNumber_Long(source);
|
||||
if (!tmp)
|
||||
return false;
|
||||
/* Now try to convert into a C++ int */
|
||||
value.long_value = PyLong_AsLong(tmp);
|
||||
Py_DECREF(tmp);
|
||||
/* Ensure return code was OK (to avoid out-of-range errors etc) */
|
||||
return !(value.long_value == -1 && !PyErr_Occurred());
|
||||
}
|
||||
|
||||
/**
|
||||
* Conversion part 2 (C++ -> Python): convert an inty instance into
|
||||
* a Python object. The second and third arguments are used to
|
||||
* indicate the return value policy and parent object (for
|
||||
* ``return_value_policy::reference_internal``) and are generally
|
||||
* ignored by implicit casters.
|
||||
*/
|
||||
static handle cast(inty src, return_value_policy /* policy */, handle /* parent */) {
|
||||
return PyLong_FromLong(src.long_value);
|
||||
}
|
||||
};
|
||||
}} // namespace pybind11::detail
|
||||
|
||||
.. note::
|
||||
|
||||
A ``type_caster<T>`` defined with ``PYBIND11_TYPE_CASTER(T, ...)`` requires
|
||||
that ``T`` is default-constructible (``value`` is first default constructed
|
||||
and then ``load()`` assigns to it).
|
||||
|
||||
.. warning::
|
||||
|
||||
When using custom type casters, it's important to declare them consistently
|
||||
in every compilation unit of the Python extension module. Otherwise,
|
||||
undefined behavior can ensue.
|
@ -1,310 +0,0 @@
|
||||
Eigen
|
||||
#####
|
||||
|
||||
`Eigen <http://eigen.tuxfamily.org>`_ is C++ header-based library for dense and
|
||||
sparse linear algebra. Due to its popularity and widespread adoption, pybind11
|
||||
provides transparent conversion and limited mapping support between Eigen and
|
||||
Scientific Python linear algebra data types.
|
||||
|
||||
To enable the built-in Eigen support you must include the optional header file
|
||||
:file:`pybind11/eigen.h`.
|
||||
|
||||
Pass-by-value
|
||||
=============
|
||||
|
||||
When binding a function with ordinary Eigen dense object arguments (for
|
||||
example, ``Eigen::MatrixXd``), pybind11 will accept any input value that is
|
||||
already (or convertible to) a ``numpy.ndarray`` with dimensions compatible with
|
||||
the Eigen type, copy its values into a temporary Eigen variable of the
|
||||
appropriate type, then call the function with this temporary variable.
|
||||
|
||||
Sparse matrices are similarly copied to or from
|
||||
``scipy.sparse.csr_matrix``/``scipy.sparse.csc_matrix`` objects.
|
||||
|
||||
Pass-by-reference
|
||||
=================
|
||||
|
||||
One major limitation of the above is that every data conversion implicitly
|
||||
involves a copy, which can be both expensive (for large matrices) and disallows
|
||||
binding functions that change their (Matrix) arguments. Pybind11 allows you to
|
||||
work around this by using Eigen's ``Eigen::Ref<MatrixType>`` class much as you
|
||||
would when writing a function taking a generic type in Eigen itself (subject to
|
||||
some limitations discussed below).
|
||||
|
||||
When calling a bound function accepting a ``Eigen::Ref<const MatrixType>``
|
||||
type, pybind11 will attempt to avoid copying by using an ``Eigen::Map`` object
|
||||
that maps into the source ``numpy.ndarray`` data: this requires both that the
|
||||
data types are the same (e.g. ``dtype='float64'`` and ``MatrixType::Scalar`` is
|
||||
``double``); and that the storage is layout compatible. The latter limitation
|
||||
is discussed in detail in the section below, and requires careful
|
||||
consideration: by default, numpy matrices and Eigen matrices are *not* storage
|
||||
compatible.
|
||||
|
||||
If the numpy matrix cannot be used as is (either because its types differ, e.g.
|
||||
passing an array of integers to an Eigen parameter requiring doubles, or
|
||||
because the storage is incompatible), pybind11 makes a temporary copy and
|
||||
passes the copy instead.
|
||||
|
||||
When a bound function parameter is instead ``Eigen::Ref<MatrixType>`` (note the
|
||||
lack of ``const``), pybind11 will only allow the function to be called if it
|
||||
can be mapped *and* if the numpy array is writeable (that is
|
||||
``a.flags.writeable`` is true). Any access (including modification) made to
|
||||
the passed variable will be transparently carried out directly on the
|
||||
``numpy.ndarray``.
|
||||
|
||||
This means you can write code such as the following and have it work as
|
||||
expected:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
void scale_by_2(Eigen::Ref<Eigen::VectorXd> v) {
|
||||
v *= 2;
|
||||
}
|
||||
|
||||
Note, however, that you will likely run into limitations due to numpy and
|
||||
Eigen's difference default storage order for data; see the below section on
|
||||
:ref:`storage_orders` for details on how to bind code that won't run into such
|
||||
limitations.
|
||||
|
||||
.. note::
|
||||
|
||||
Passing by reference is not supported for sparse types.
|
||||
|
||||
Returning values to Python
|
||||
==========================
|
||||
|
||||
When returning an ordinary dense Eigen matrix type to numpy (e.g.
|
||||
``Eigen::MatrixXd`` or ``Eigen::RowVectorXf``) pybind11 keeps the matrix and
|
||||
returns a numpy array that directly references the Eigen matrix: no copy of the
|
||||
data is performed. The numpy array will have ``array.flags.owndata`` set to
|
||||
``False`` to indicate that it does not own the data, and the lifetime of the
|
||||
stored Eigen matrix will be tied to the returned ``array``.
|
||||
|
||||
If you bind a function with a non-reference, ``const`` return type (e.g.
|
||||
``const Eigen::MatrixXd``), the same thing happens except that pybind11 also
|
||||
sets the numpy array's ``writeable`` flag to false.
|
||||
|
||||
If you return an lvalue reference or pointer, the usual pybind11 rules apply,
|
||||
as dictated by the binding function's return value policy (see the
|
||||
documentation on :ref:`return_value_policies` for full details). That means,
|
||||
without an explicit return value policy, lvalue references will be copied and
|
||||
pointers will be managed by pybind11. In order to avoid copying, you should
|
||||
explicitly specify an appropriate return value policy, as in the following
|
||||
example:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
class MyClass {
|
||||
Eigen::MatrixXd big_mat = Eigen::MatrixXd::Zero(10000, 10000);
|
||||
public:
|
||||
Eigen::MatrixXd &getMatrix() { return big_mat; }
|
||||
const Eigen::MatrixXd &viewMatrix() { return big_mat; }
|
||||
};
|
||||
|
||||
// Later, in binding code:
|
||||
py::class_<MyClass>(m, "MyClass")
|
||||
.def(py::init<>())
|
||||
.def("copy_matrix", &MyClass::getMatrix) // Makes a copy!
|
||||
.def("get_matrix", &MyClass::getMatrix, py::return_value_policy::reference_internal)
|
||||
.def("view_matrix", &MyClass::viewMatrix, py::return_value_policy::reference_internal)
|
||||
;
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
a = MyClass()
|
||||
m = a.get_matrix() # flags.writeable = True, flags.owndata = False
|
||||
v = a.view_matrix() # flags.writeable = False, flags.owndata = False
|
||||
c = a.copy_matrix() # flags.writeable = True, flags.owndata = True
|
||||
# m[5,6] and v[5,6] refer to the same element, c[5,6] does not.
|
||||
|
||||
Note in this example that ``py::return_value_policy::reference_internal`` is
|
||||
used to tie the life of the MyClass object to the life of the returned arrays.
|
||||
|
||||
You may also return an ``Eigen::Ref``, ``Eigen::Map`` or other map-like Eigen
|
||||
object (for example, the return value of ``matrix.block()`` and related
|
||||
methods) that map into a dense Eigen type. When doing so, the default
|
||||
behaviour of pybind11 is to simply reference the returned data: you must take
|
||||
care to ensure that this data remains valid! You may ask pybind11 to
|
||||
explicitly *copy* such a return value by using the
|
||||
``py::return_value_policy::copy`` policy when binding the function. You may
|
||||
also use ``py::return_value_policy::reference_internal`` or a
|
||||
``py::keep_alive`` to ensure the data stays valid as long as the returned numpy
|
||||
array does.
|
||||
|
||||
When returning such a reference of map, pybind11 additionally respects the
|
||||
readonly-status of the returned value, marking the numpy array as non-writeable
|
||||
if the reference or map was itself read-only.
|
||||
|
||||
.. note::
|
||||
|
||||
Sparse types are always copied when returned.
|
||||
|
||||
.. _storage_orders:
|
||||
|
||||
Storage orders
|
||||
==============
|
||||
|
||||
Passing arguments via ``Eigen::Ref`` has some limitations that you must be
|
||||
aware of in order to effectively pass matrices by reference. First and
|
||||
foremost is that the default ``Eigen::Ref<MatrixType>`` class requires
|
||||
contiguous storage along columns (for column-major types, the default in Eigen)
|
||||
or rows if ``MatrixType`` is specifically an ``Eigen::RowMajor`` storage type.
|
||||
The former, Eigen's default, is incompatible with ``numpy``'s default row-major
|
||||
storage, and so you will not be able to pass numpy arrays to Eigen by reference
|
||||
without making one of two changes.
|
||||
|
||||
(Note that this does not apply to vectors (or column or row matrices): for such
|
||||
types the "row-major" and "column-major" distinction is meaningless).
|
||||
|
||||
The first approach is to change the use of ``Eigen::Ref<MatrixType>`` to the
|
||||
more general ``Eigen::Ref<MatrixType, 0, Eigen::Stride<Eigen::Dynamic,
|
||||
Eigen::Dynamic>>`` (or similar type with a fully dynamic stride type in the
|
||||
third template argument). Since this is a rather cumbersome type, pybind11
|
||||
provides a ``py::EigenDRef<MatrixType>`` type alias for your convenience (along
|
||||
with EigenDMap for the equivalent Map, and EigenDStride for just the stride
|
||||
type).
|
||||
|
||||
This type allows Eigen to map into any arbitrary storage order. This is not
|
||||
the default in Eigen for performance reasons: contiguous storage allows
|
||||
vectorization that cannot be done when storage is not known to be contiguous at
|
||||
compile time. The default ``Eigen::Ref`` stride type allows non-contiguous
|
||||
storage along the outer dimension (that is, the rows of a column-major matrix
|
||||
or columns of a row-major matrix), but not along the inner dimension.
|
||||
|
||||
This type, however, has the added benefit of also being able to map numpy array
|
||||
slices. For example, the following (contrived) example uses Eigen with a numpy
|
||||
slice to multiply by 2 all coefficients that are both on even rows (0, 2, 4,
|
||||
...) and in columns 2, 5, or 8:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
m.def("scale", [](py::EigenDRef<Eigen::MatrixXd> m, double c) { m *= c; });
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# a = np.array(...)
|
||||
scale_by_2(myarray[0::2, 2:9:3])
|
||||
|
||||
The second approach to avoid copying is more intrusive: rearranging the
|
||||
underlying data types to not run into the non-contiguous storage problem in the
|
||||
first place. In particular, that means using matrices with ``Eigen::RowMajor``
|
||||
storage, where appropriate, such as:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
using RowMatrixXd = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
||||
// Use RowMatrixXd instead of MatrixXd
|
||||
|
||||
Now bound functions accepting ``Eigen::Ref<RowMatrixXd>`` arguments will be
|
||||
callable with numpy's (default) arrays without involving a copying.
|
||||
|
||||
You can, alternatively, change the storage order that numpy arrays use by
|
||||
adding the ``order='F'`` option when creating an array:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
myarray = np.array(source, order="F")
|
||||
|
||||
Such an object will be passable to a bound function accepting an
|
||||
``Eigen::Ref<MatrixXd>`` (or similar column-major Eigen type).
|
||||
|
||||
One major caveat with this approach, however, is that it is not entirely as
|
||||
easy as simply flipping all Eigen or numpy usage from one to the other: some
|
||||
operations may alter the storage order of a numpy array. For example, ``a2 =
|
||||
array.transpose()`` results in ``a2`` being a view of ``array`` that references
|
||||
the same data, but in the opposite storage order!
|
||||
|
||||
While this approach allows fully optimized vectorized calculations in Eigen, it
|
||||
cannot be used with array slices, unlike the first approach.
|
||||
|
||||
When *returning* a matrix to Python (either a regular matrix, a reference via
|
||||
``Eigen::Ref<>``, or a map/block into a matrix), no special storage
|
||||
consideration is required: the created numpy array will have the required
|
||||
stride that allows numpy to properly interpret the array, whatever its storage
|
||||
order.
|
||||
|
||||
Failing rather than copying
|
||||
===========================
|
||||
|
||||
The default behaviour when binding ``Eigen::Ref<const MatrixType>`` Eigen
|
||||
references is to copy matrix values when passed a numpy array that does not
|
||||
conform to the element type of ``MatrixType`` or does not have a compatible
|
||||
stride layout. If you want to explicitly avoid copying in such a case, you
|
||||
should bind arguments using the ``py::arg().noconvert()`` annotation (as
|
||||
described in the :ref:`nonconverting_arguments` documentation).
|
||||
|
||||
The following example shows an example of arguments that don't allow data
|
||||
copying to take place:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// The method and function to be bound:
|
||||
class MyClass {
|
||||
// ...
|
||||
double some_method(const Eigen::Ref<const MatrixXd> &matrix) { /* ... */ }
|
||||
};
|
||||
float some_function(const Eigen::Ref<const MatrixXf> &big,
|
||||
const Eigen::Ref<const MatrixXf> &small) {
|
||||
// ...
|
||||
}
|
||||
|
||||
// The associated binding code:
|
||||
using namespace pybind11::literals; // for "arg"_a
|
||||
py::class_<MyClass>(m, "MyClass")
|
||||
// ... other class definitions
|
||||
.def("some_method", &MyClass::some_method, py::arg().noconvert());
|
||||
|
||||
m.def("some_function", &some_function,
|
||||
"big"_a.noconvert(), // <- Don't allow copying for this arg
|
||||
"small"_a // <- This one can be copied if needed
|
||||
);
|
||||
|
||||
With the above binding code, attempting to call the the ``some_method(m)``
|
||||
method on a ``MyClass`` object, or attempting to call ``some_function(m, m2)``
|
||||
will raise a ``RuntimeError`` rather than making a temporary copy of the array.
|
||||
It will, however, allow the ``m2`` argument to be copied into a temporary if
|
||||
necessary.
|
||||
|
||||
Note that explicitly specifying ``.noconvert()`` is not required for *mutable*
|
||||
Eigen references (e.g. ``Eigen::Ref<MatrixXd>`` without ``const`` on the
|
||||
``MatrixXd``): mutable references will never be called with a temporary copy.
|
||||
|
||||
Vectors versus column/row matrices
|
||||
==================================
|
||||
|
||||
Eigen and numpy have fundamentally different notions of a vector. In Eigen, a
|
||||
vector is simply a matrix with the number of columns or rows set to 1 at
|
||||
compile time (for a column vector or row vector, respectively). NumPy, in
|
||||
contrast, has comparable 2-dimensional 1xN and Nx1 arrays, but *also* has
|
||||
1-dimensional arrays of size N.
|
||||
|
||||
When passing a 2-dimensional 1xN or Nx1 array to Eigen, the Eigen type must
|
||||
have matching dimensions: That is, you cannot pass a 2-dimensional Nx1 numpy
|
||||
array to an Eigen value expecting a row vector, or a 1xN numpy array as a
|
||||
column vector argument.
|
||||
|
||||
On the other hand, pybind11 allows you to pass 1-dimensional arrays of length N
|
||||
as Eigen parameters. If the Eigen type can hold a column vector of length N it
|
||||
will be passed as such a column vector. If not, but the Eigen type constraints
|
||||
will accept a row vector, it will be passed as a row vector. (The column
|
||||
vector takes precedence when both are supported, for example, when passing a
|
||||
1D numpy array to a MatrixXd argument). Note that the type need not be
|
||||
explicitly a vector: it is permitted to pass a 1D numpy array of size 5 to an
|
||||
Eigen ``Matrix<double, Dynamic, 5>``: you would end up with a 1x5 Eigen matrix.
|
||||
Passing the same to an ``Eigen::MatrixXd`` would result in a 5x1 Eigen matrix.
|
||||
|
||||
When returning an Eigen vector to numpy, the conversion is ambiguous: a row
|
||||
vector of length 4 could be returned as either a 1D array of length 4, or as a
|
||||
2D array of size 1x4. When encountering such a situation, pybind11 compromises
|
||||
by considering the returned Eigen type: if it is a compile-time vector--that
|
||||
is, the type has either the number of rows or columns set to 1 at compile
|
||||
time--pybind11 converts to a 1D numpy array when returning the value. For
|
||||
instances that are a vector only at run-time (e.g. ``MatrixXd``,
|
||||
``Matrix<float, Dynamic, 4>``), pybind11 returns the vector as a 2D array to
|
||||
numpy. If this isn't want you want, you can use ``array.reshape(...)`` to get
|
||||
a view of the same data in the desired dimensions.
|
||||
|
||||
.. seealso::
|
||||
|
||||
The file :file:`tests/test_eigen.cpp` contains a complete example that
|
||||
shows how to pass Eigen sparse and dense data types in more detail.
|
@ -1,109 +0,0 @@
|
||||
Functional
|
||||
##########
|
||||
|
||||
The following features must be enabled by including :file:`pybind11/functional.h`.
|
||||
|
||||
|
||||
Callbacks and passing anonymous functions
|
||||
=========================================
|
||||
|
||||
The C++11 standard brought lambda functions and the generic polymorphic
|
||||
function wrapper ``std::function<>`` to the C++ programming language, which
|
||||
enable powerful new ways of working with functions. Lambda functions come in
|
||||
two flavors: stateless lambda function resemble classic function pointers that
|
||||
link to an anonymous piece of code, while stateful lambda functions
|
||||
additionally depend on captured variables that are stored in an anonymous
|
||||
*lambda closure object*.
|
||||
|
||||
Here is a simple example of a C++ function that takes an arbitrary function
|
||||
(stateful or stateless) with signature ``int -> int`` as an argument and runs
|
||||
it with the value 10.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
int func_arg(const std::function<int(int)> &f) {
|
||||
return f(10);
|
||||
}
|
||||
|
||||
The example below is more involved: it takes a function of signature ``int -> int``
|
||||
and returns another function of the same kind. The return value is a stateful
|
||||
lambda function, which stores the value ``f`` in the capture object and adds 1 to
|
||||
its return value upon execution.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
std::function<int(int)> func_ret(const std::function<int(int)> &f) {
|
||||
return [f](int i) {
|
||||
return f(i) + 1;
|
||||
};
|
||||
}
|
||||
|
||||
This example demonstrates using python named parameters in C++ callbacks which
|
||||
requires using ``py::cpp_function`` as a wrapper. Usage is similar to defining
|
||||
methods of classes:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
py::cpp_function func_cpp() {
|
||||
return py::cpp_function([](int i) { return i+1; },
|
||||
py::arg("number"));
|
||||
}
|
||||
|
||||
After including the extra header file :file:`pybind11/functional.h`, it is almost
|
||||
trivial to generate binding code for all of these functions.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include <pybind11/functional.h>
|
||||
|
||||
PYBIND11_MODULE(example, m) {
|
||||
m.def("func_arg", &func_arg);
|
||||
m.def("func_ret", &func_ret);
|
||||
m.def("func_cpp", &func_cpp);
|
||||
}
|
||||
|
||||
The following interactive session shows how to call them from Python.
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
$ python
|
||||
>>> import example
|
||||
>>> def square(i):
|
||||
... return i * i
|
||||
...
|
||||
>>> example.func_arg(square)
|
||||
100L
|
||||
>>> square_plus_1 = example.func_ret(square)
|
||||
>>> square_plus_1(4)
|
||||
17L
|
||||
>>> plus_1 = func_cpp()
|
||||
>>> plus_1(number=43)
|
||||
44L
|
||||
|
||||
.. warning::
|
||||
|
||||
Keep in mind that passing a function from C++ to Python (or vice versa)
|
||||
will instantiate a piece of wrapper code that translates function
|
||||
invocations between the two languages. Naturally, this translation
|
||||
increases the computational cost of each function call somewhat. A
|
||||
problematic situation can arise when a function is copied back and forth
|
||||
between Python and C++ many times in a row, in which case the underlying
|
||||
wrappers will accumulate correspondingly. The resulting long sequence of
|
||||
C++ -> Python -> C++ -> ... roundtrips can significantly decrease
|
||||
performance.
|
||||
|
||||
There is one exception: pybind11 detects case where a stateless function
|
||||
(i.e. a function pointer or a lambda function without captured variables)
|
||||
is passed as an argument to another C++ function exposed in Python. In this
|
||||
case, there is no overhead. Pybind11 will extract the underlying C++
|
||||
function pointer from the wrapped function to sidestep a potential C++ ->
|
||||
Python -> C++ roundtrip. This is demonstrated in :file:`tests/test_callbacks.cpp`.
|
||||
|
||||
.. note::
|
||||
|
||||
This functionality is very useful when generating bindings for callbacks in
|
||||
C++ libraries (e.g. GUI libraries, asynchronous networking libraries, etc.).
|
||||
|
||||
The file :file:`tests/test_callbacks.cpp` contains a complete example
|
||||
that demonstrates how to work with callbacks and anonymous functions in
|
||||
more detail.
|
@ -1,43 +0,0 @@
|
||||
.. _type-conversions:
|
||||
|
||||
Type conversions
|
||||
################
|
||||
|
||||
Apart from enabling cross-language function calls, a fundamental problem
|
||||
that a binding tool like pybind11 must address is to provide access to
|
||||
native Python types in C++ and vice versa. There are three fundamentally
|
||||
different ways to do this—which approach is preferable for a particular type
|
||||
depends on the situation at hand.
|
||||
|
||||
1. Use a native C++ type everywhere. In this case, the type must be wrapped
|
||||
using pybind11-generated bindings so that Python can interact with it.
|
||||
|
||||
2. Use a native Python type everywhere. It will need to be wrapped so that
|
||||
C++ functions can interact with it.
|
||||
|
||||
3. Use a native C++ type on the C++ side and a native Python type on the
|
||||
Python side. pybind11 refers to this as a *type conversion*.
|
||||
|
||||
Type conversions are the most "natural" option in the sense that native
|
||||
(non-wrapped) types are used everywhere. The main downside is that a copy
|
||||
of the data must be made on every Python ↔ C++ transition: this is
|
||||
needed since the C++ and Python versions of the same type generally won't
|
||||
have the same memory layout.
|
||||
|
||||
pybind11 can perform many kinds of conversions automatically. An overview
|
||||
is provided in the table ":ref:`conversion_table`".
|
||||
|
||||
The following subsections discuss the differences between these options in more
|
||||
detail. The main focus in this section is on type conversions, which represent
|
||||
the last case of the above list.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
overview
|
||||
strings
|
||||
stl
|
||||
functional
|
||||
chrono
|
||||
eigen
|
||||
custom
|
@ -1,170 +0,0 @@
|
||||
Overview
|
||||
########
|
||||
|
||||
.. rubric:: 1. Native type in C++, wrapper in Python
|
||||
|
||||
Exposing a custom C++ type using :class:`py::class_` was covered in detail
|
||||
in the :doc:`/classes` section. There, the underlying data structure is
|
||||
always the original C++ class while the :class:`py::class_` wrapper provides
|
||||
a Python interface. Internally, when an object like this is sent from C++ to
|
||||
Python, pybind11 will just add the outer wrapper layer over the native C++
|
||||
object. Getting it back from Python is just a matter of peeling off the
|
||||
wrapper.
|
||||
|
||||
.. rubric:: 2. Wrapper in C++, native type in Python
|
||||
|
||||
This is the exact opposite situation. Now, we have a type which is native to
|
||||
Python, like a ``tuple`` or a ``list``. One way to get this data into C++ is
|
||||
with the :class:`py::object` family of wrappers. These are explained in more
|
||||
detail in the :doc:`/advanced/pycpp/object` section. We'll just give a quick
|
||||
example here:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
void print_list(py::list my_list) {
|
||||
for (auto item : my_list)
|
||||
std::cout << item << " ";
|
||||
}
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> print_list([1, 2, 3])
|
||||
1 2 3
|
||||
|
||||
The Python ``list`` is not converted in any way -- it's just wrapped in a C++
|
||||
:class:`py::list` class. At its core it's still a Python object. Copying a
|
||||
:class:`py::list` will do the usual reference-counting like in Python.
|
||||
Returning the object to Python will just remove the thin wrapper.
|
||||
|
||||
.. rubric:: 3. Converting between native C++ and Python types
|
||||
|
||||
In the previous two cases we had a native type in one language and a wrapper in
|
||||
the other. Now, we have native types on both sides and we convert between them.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
void print_vector(const std::vector<int> &v) {
|
||||
for (auto item : v)
|
||||
std::cout << item << "\n";
|
||||
}
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> print_vector([1, 2, 3])
|
||||
1 2 3
|
||||
|
||||
In this case, pybind11 will construct a new ``std::vector<int>`` and copy each
|
||||
element from the Python ``list``. The newly constructed object will be passed
|
||||
to ``print_vector``. The same thing happens in the other direction: a new
|
||||
``list`` is made to match the value returned from C++.
|
||||
|
||||
Lots of these conversions are supported out of the box, as shown in the table
|
||||
below. They are very convenient, but keep in mind that these conversions are
|
||||
fundamentally based on copying data. This is perfectly fine for small immutable
|
||||
types but it may become quite expensive for large data structures. This can be
|
||||
avoided by overriding the automatic conversion with a custom wrapper (i.e. the
|
||||
above-mentioned approach 1). This requires some manual effort and more details
|
||||
are available in the :ref:`opaque` section.
|
||||
|
||||
.. _conversion_table:
|
||||
|
||||
List of all builtin conversions
|
||||
-------------------------------
|
||||
|
||||
The following basic data types are supported out of the box (some may require
|
||||
an additional extension header to be included). To pass other data structures
|
||||
as arguments and return values, refer to the section on binding :ref:`classes`.
|
||||
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| Data type | Description | Header file |
|
||||
+====================================+===========================+===================================+
|
||||
| ``int8_t``, ``uint8_t`` | 8-bit integers | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``int16_t``, ``uint16_t`` | 16-bit integers | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``int32_t``, ``uint32_t`` | 32-bit integers | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``int64_t``, ``uint64_t`` | 64-bit integers | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``ssize_t``, ``size_t`` | Platform-dependent size | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``float``, ``double`` | Floating point types | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``bool`` | Two-state Boolean type | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``char`` | Character literal | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``char16_t`` | UTF-16 character literal | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``char32_t`` | UTF-32 character literal | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``wchar_t`` | Wide character literal | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``const char *`` | UTF-8 string literal | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``const char16_t *`` | UTF-16 string literal | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``const char32_t *`` | UTF-32 string literal | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``const wchar_t *`` | Wide string literal | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::string`` | STL dynamic UTF-8 string | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::u16string`` | STL dynamic UTF-16 string | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::u32string`` | STL dynamic UTF-32 string | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::wstring`` | STL dynamic wide string | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::string_view``, | STL C++17 string views | :file:`pybind11/pybind11.h` |
|
||||
| ``std::u16string_view``, etc. | | |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::pair<T1, T2>`` | Pair of two custom types | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::tuple<...>`` | Arbitrary tuple of types | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::reference_wrapper<...>`` | Reference type wrapper | :file:`pybind11/pybind11.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::complex<T>`` | Complex numbers | :file:`pybind11/complex.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::array<T, Size>`` | STL static array | :file:`pybind11/stl.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::vector<T>`` | STL dynamic array | :file:`pybind11/stl.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::deque<T>`` | STL double-ended queue | :file:`pybind11/stl.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::valarray<T>`` | STL value array | :file:`pybind11/stl.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::list<T>`` | STL linked list | :file:`pybind11/stl.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::map<T1, T2>`` | STL ordered map | :file:`pybind11/stl.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::unordered_map<T1, T2>`` | STL unordered map | :file:`pybind11/stl.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::set<T>`` | STL ordered set | :file:`pybind11/stl.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::unordered_set<T>`` | STL unordered set | :file:`pybind11/stl.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::optional<T>`` | STL optional type (C++17) | :file:`pybind11/stl.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::experimental::optional<T>`` | STL optional type (exp.) | :file:`pybind11/stl.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::variant<...>`` | Type-safe union (C++17) | :file:`pybind11/stl.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::filesystem::path<T>`` | STL path (C++17) [#]_ | :file:`pybind11/stl/filesystem.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::function<...>`` | STL polymorphic function | :file:`pybind11/functional.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::chrono::duration<...>`` | STL time duration | :file:`pybind11/chrono.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``std::chrono::time_point<...>`` | STL date/time | :file:`pybind11/chrono.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``Eigen::Matrix<...>`` | Eigen: dense matrix | :file:`pybind11/eigen.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``Eigen::Map<...>`` | Eigen: mapped memory | :file:`pybind11/eigen.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
| ``Eigen::SparseMatrix<...>`` | Eigen: sparse matrix | :file:`pybind11/eigen.h` |
|
||||
+------------------------------------+---------------------------+-----------------------------------+
|
||||
|
||||
.. [#] ``std::filesystem::path`` is converted to ``pathlib.Path`` and
|
||||
``os.PathLike`` is converted to ``std::filesystem::path``.
|
@ -1,249 +0,0 @@
|
||||
STL containers
|
||||
##############
|
||||
|
||||
Automatic conversion
|
||||
====================
|
||||
|
||||
When including the additional header file :file:`pybind11/stl.h`, conversions
|
||||
between ``std::vector<>``/``std::deque<>``/``std::list<>``/``std::array<>``/``std::valarray<>``,
|
||||
``std::set<>``/``std::unordered_set<>``, and
|
||||
``std::map<>``/``std::unordered_map<>`` and the Python ``list``, ``set`` and
|
||||
``dict`` data structures are automatically enabled. The types ``std::pair<>``
|
||||
and ``std::tuple<>`` are already supported out of the box with just the core
|
||||
:file:`pybind11/pybind11.h` header.
|
||||
|
||||
The major downside of these implicit conversions is that containers must be
|
||||
converted (i.e. copied) on every Python->C++ and C++->Python transition, which
|
||||
can have implications on the program semantics and performance. Please read the
|
||||
next sections for more details and alternative approaches that avoid this.
|
||||
|
||||
.. note::
|
||||
|
||||
Arbitrary nesting of any of these types is possible.
|
||||
|
||||
.. seealso::
|
||||
|
||||
The file :file:`tests/test_stl.cpp` contains a complete
|
||||
example that demonstrates how to pass STL data types in more detail.
|
||||
|
||||
.. _cpp17_container_casters:
|
||||
|
||||
C++17 library containers
|
||||
========================
|
||||
|
||||
The :file:`pybind11/stl.h` header also includes support for ``std::optional<>``
|
||||
and ``std::variant<>``. These require a C++17 compiler and standard library.
|
||||
In C++14 mode, ``std::experimental::optional<>`` is supported if available.
|
||||
|
||||
Various versions of these containers also exist for C++11 (e.g. in Boost).
|
||||
pybind11 provides an easy way to specialize the ``type_caster`` for such
|
||||
types:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// `boost::optional` as an example -- can be any `std::optional`-like container
|
||||
namespace pybind11 { namespace detail {
|
||||
template <typename T>
|
||||
struct type_caster<boost::optional<T>> : optional_caster<boost::optional<T>> {};
|
||||
}}
|
||||
|
||||
The above should be placed in a header file and included in all translation units
|
||||
where automatic conversion is needed. Similarly, a specialization can be provided
|
||||
for custom variant types:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// `boost::variant` as an example -- can be any `std::variant`-like container
|
||||
namespace pybind11 { namespace detail {
|
||||
template <typename... Ts>
|
||||
struct type_caster<boost::variant<Ts...>> : variant_caster<boost::variant<Ts...>> {};
|
||||
|
||||
// Specifies the function used to visit the variant -- `apply_visitor` instead of `visit`
|
||||
template <>
|
||||
struct visit_helper<boost::variant> {
|
||||
template <typename... Args>
|
||||
static auto call(Args &&...args) -> decltype(boost::apply_visitor(args...)) {
|
||||
return boost::apply_visitor(args...);
|
||||
}
|
||||
};
|
||||
}} // namespace pybind11::detail
|
||||
|
||||
The ``visit_helper`` specialization is not required if your ``name::variant`` provides
|
||||
a ``name::visit()`` function. For any other function name, the specialization must be
|
||||
included to tell pybind11 how to visit the variant.
|
||||
|
||||
.. warning::
|
||||
|
||||
When converting a ``variant`` type, pybind11 follows the same rules as when
|
||||
determining which function overload to call (:ref:`overload_resolution`), and
|
||||
so the same caveats hold. In particular, the order in which the ``variant``'s
|
||||
alternatives are listed is important, since pybind11 will try conversions in
|
||||
this order. This means that, for example, when converting ``variant<int, bool>``,
|
||||
the ``bool`` variant will never be selected, as any Python ``bool`` is already
|
||||
an ``int`` and is convertible to a C++ ``int``. Changing the order of alternatives
|
||||
(and using ``variant<bool, int>``, in this example) provides a solution.
|
||||
|
||||
.. note::
|
||||
|
||||
pybind11 only supports the modern implementation of ``boost::variant``
|
||||
which makes use of variadic templates. This requires Boost 1.56 or newer.
|
||||
|
||||
.. _opaque:
|
||||
|
||||
Making opaque types
|
||||
===================
|
||||
|
||||
pybind11 heavily relies on a template matching mechanism to convert parameters
|
||||
and return values that are constructed from STL data types such as vectors,
|
||||
linked lists, hash tables, etc. This even works in a recursive manner, for
|
||||
instance to deal with lists of hash maps of pairs of elementary and custom
|
||||
types, etc.
|
||||
|
||||
However, a fundamental limitation of this approach is that internal conversions
|
||||
between Python and C++ types involve a copy operation that prevents
|
||||
pass-by-reference semantics. What does this mean?
|
||||
|
||||
Suppose we bind the following function
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
void append_1(std::vector<int> &v) {
|
||||
v.push_back(1);
|
||||
}
|
||||
|
||||
and call it from Python, the following happens:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> v = [5, 6]
|
||||
>>> append_1(v)
|
||||
>>> print(v)
|
||||
[5, 6]
|
||||
|
||||
As you can see, when passing STL data structures by reference, modifications
|
||||
are not propagated back the Python side. A similar situation arises when
|
||||
exposing STL data structures using the ``def_readwrite`` or ``def_readonly``
|
||||
functions:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/* ... definition ... */
|
||||
|
||||
class MyClass {
|
||||
std::vector<int> contents;
|
||||
};
|
||||
|
||||
/* ... binding code ... */
|
||||
|
||||
py::class_<MyClass>(m, "MyClass")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("contents", &MyClass::contents);
|
||||
|
||||
In this case, properties can be read and written in their entirety. However, an
|
||||
``append`` operation involving such a list type has no effect:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> m = MyClass()
|
||||
>>> m.contents = [5, 6]
|
||||
>>> print(m.contents)
|
||||
[5, 6]
|
||||
>>> m.contents.append(7)
|
||||
>>> print(m.contents)
|
||||
[5, 6]
|
||||
|
||||
Finally, the involved copy operations can be costly when dealing with very
|
||||
large lists. To deal with all of the above situations, pybind11 provides a
|
||||
macro named ``PYBIND11_MAKE_OPAQUE(T)`` that disables the template-based
|
||||
conversion machinery of types, thus rendering them *opaque*. The contents of
|
||||
opaque objects are never inspected or extracted, hence they *can* be passed by
|
||||
reference. For instance, to turn ``std::vector<int>`` into an opaque type, add
|
||||
the declaration
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
PYBIND11_MAKE_OPAQUE(std::vector<int>);
|
||||
|
||||
before any binding code (e.g. invocations to ``class_::def()``, etc.). This
|
||||
macro must be specified at the top level (and outside of any namespaces), since
|
||||
it adds a template instantiation of ``type_caster``. If your binding code consists of
|
||||
multiple compilation units, it must be present in every file (typically via a
|
||||
common header) preceding any usage of ``std::vector<int>``. Opaque types must
|
||||
also have a corresponding ``class_`` declaration to associate them with a name
|
||||
in Python, and to define a set of available operations, e.g.:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
py::class_<std::vector<int>>(m, "IntVector")
|
||||
.def(py::init<>())
|
||||
.def("clear", &std::vector<int>::clear)
|
||||
.def("pop_back", &std::vector<int>::pop_back)
|
||||
.def("__len__", [](const std::vector<int> &v) { return v.size(); })
|
||||
.def("__iter__", [](std::vector<int> &v) {
|
||||
return py::make_iterator(v.begin(), v.end());
|
||||
}, py::keep_alive<0, 1>()) /* Keep vector alive while iterator is used */
|
||||
// ....
|
||||
|
||||
.. seealso::
|
||||
|
||||
The file :file:`tests/test_opaque_types.cpp` contains a complete
|
||||
example that demonstrates how to create and expose opaque types using
|
||||
pybind11 in more detail.
|
||||
|
||||
.. _stl_bind:
|
||||
|
||||
Binding STL containers
|
||||
======================
|
||||
|
||||
The ability to expose STL containers as native Python objects is a fairly
|
||||
common request, hence pybind11 also provides an optional header file named
|
||||
:file:`pybind11/stl_bind.h` that does exactly this. The mapped containers try
|
||||
to match the behavior of their native Python counterparts as much as possible.
|
||||
|
||||
The following example showcases usage of :file:`pybind11/stl_bind.h`:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// Don't forget this
|
||||
#include <pybind11/stl_bind.h>
|
||||
|
||||
PYBIND11_MAKE_OPAQUE(std::vector<int>);
|
||||
PYBIND11_MAKE_OPAQUE(std::map<std::string, double>);
|
||||
|
||||
// ...
|
||||
|
||||
// later in binding code:
|
||||
py::bind_vector<std::vector<int>>(m, "VectorInt");
|
||||
py::bind_map<std::map<std::string, double>>(m, "MapStringDouble");
|
||||
|
||||
When binding STL containers pybind11 considers the types of the container's
|
||||
elements to decide whether the container should be confined to the local module
|
||||
(via the :ref:`module_local` feature). If the container element types are
|
||||
anything other than already-bound custom types bound without
|
||||
``py::module_local()`` the container binding will have ``py::module_local()``
|
||||
applied. This includes converting types such as numeric types, strings, Eigen
|
||||
types; and types that have not yet been bound at the time of the stl container
|
||||
binding. This module-local binding is designed to avoid potential conflicts
|
||||
between module bindings (for example, from two separate modules each attempting
|
||||
to bind ``std::vector<int>`` as a python type).
|
||||
|
||||
It is possible to override this behavior to force a definition to be either
|
||||
module-local or global. To do so, you can pass the attributes
|
||||
``py::module_local()`` (to make the binding module-local) or
|
||||
``py::module_local(false)`` (to make the binding global) into the
|
||||
``py::bind_vector`` or ``py::bind_map`` arguments:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
py::bind_vector<std::vector<int>>(m, "VectorInt", py::module_local(false));
|
||||
|
||||
Note, however, that such a global binding would make it impossible to load this
|
||||
module at the same time as any other pybind module that also attempts to bind
|
||||
the same container type (``std::vector<int>`` in the above example).
|
||||
|
||||
See :ref:`module_local` for more details on module-local bindings.
|
||||
|
||||
.. seealso::
|
||||
|
||||
The file :file:`tests/test_stl_binders.cpp` shows how to use the
|
||||
convenience STL container wrappers.
|
@ -1,292 +0,0 @@
|
||||
Strings, bytes and Unicode conversions
|
||||
######################################
|
||||
|
||||
Passing Python strings to C++
|
||||
=============================
|
||||
|
||||
When a Python ``str`` is passed from Python to a C++ function that accepts
|
||||
``std::string`` or ``char *`` as arguments, pybind11 will encode the Python
|
||||
string to UTF-8. All Python ``str`` can be encoded in UTF-8, so this operation
|
||||
does not fail.
|
||||
|
||||
The C++ language is encoding agnostic. It is the responsibility of the
|
||||
programmer to track encodings. It's often easiest to simply `use UTF-8
|
||||
everywhere <http://utf8everywhere.org/>`_.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
m.def("utf8_test",
|
||||
[](const std::string &s) {
|
||||
cout << "utf-8 is icing on the cake.\n";
|
||||
cout << s;
|
||||
}
|
||||
);
|
||||
m.def("utf8_charptr",
|
||||
[](const char *s) {
|
||||
cout << "My favorite food is\n";
|
||||
cout << s;
|
||||
}
|
||||
);
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> utf8_test("🎂")
|
||||
utf-8 is icing on the cake.
|
||||
🎂
|
||||
|
||||
>>> utf8_charptr("🍕")
|
||||
My favorite food is
|
||||
🍕
|
||||
|
||||
.. note::
|
||||
|
||||
Some terminal emulators do not support UTF-8 or emoji fonts and may not
|
||||
display the example above correctly.
|
||||
|
||||
The results are the same whether the C++ function accepts arguments by value or
|
||||
reference, and whether or not ``const`` is used.
|
||||
|
||||
Passing bytes to C++
|
||||
--------------------
|
||||
|
||||
A Python ``bytes`` object will be passed to C++ functions that accept
|
||||
``std::string`` or ``char*`` *without* conversion. In order to make a function
|
||||
*only* accept ``bytes`` (and not ``str``), declare it as taking a ``py::bytes``
|
||||
argument.
|
||||
|
||||
|
||||
Returning C++ strings to Python
|
||||
===============================
|
||||
|
||||
When a C++ function returns a ``std::string`` or ``char*`` to a Python caller,
|
||||
**pybind11 will assume that the string is valid UTF-8** and will decode it to a
|
||||
native Python ``str``, using the same API as Python uses to perform
|
||||
``bytes.decode('utf-8')``. If this implicit conversion fails, pybind11 will
|
||||
raise a ``UnicodeDecodeError``.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
m.def("std_string_return",
|
||||
[]() {
|
||||
return std::string("This string needs to be UTF-8 encoded");
|
||||
}
|
||||
);
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> isinstance(example.std_string_return(), str)
|
||||
True
|
||||
|
||||
|
||||
Because UTF-8 is inclusive of pure ASCII, there is never any issue with
|
||||
returning a pure ASCII string to Python. If there is any possibility that the
|
||||
string is not pure ASCII, it is necessary to ensure the encoding is valid
|
||||
UTF-8.
|
||||
|
||||
.. warning::
|
||||
|
||||
Implicit conversion assumes that a returned ``char *`` is null-terminated.
|
||||
If there is no null terminator a buffer overrun will occur.
|
||||
|
||||
Explicit conversions
|
||||
--------------------
|
||||
|
||||
If some C++ code constructs a ``std::string`` that is not a UTF-8 string, one
|
||||
can perform a explicit conversion and return a ``py::str`` object. Explicit
|
||||
conversion has the same overhead as implicit conversion.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
// This uses the Python C API to convert Latin-1 to Unicode
|
||||
m.def("str_output",
|
||||
[]() {
|
||||
std::string s = "Send your r\xe9sum\xe9 to Alice in HR"; // Latin-1
|
||||
py::str py_s = PyUnicode_DecodeLatin1(s.data(), s.length());
|
||||
return py_s;
|
||||
}
|
||||
);
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> str_output()
|
||||
'Send your résumé to Alice in HR'
|
||||
|
||||
The `Python C API
|
||||
<https://docs.python.org/3/c-api/unicode.html#built-in-codecs>`_ provides
|
||||
several built-in codecs.
|
||||
|
||||
|
||||
One could also use a third party encoding library such as libiconv to transcode
|
||||
to UTF-8.
|
||||
|
||||
Return C++ strings without conversion
|
||||
-------------------------------------
|
||||
|
||||
If the data in a C++ ``std::string`` does not represent text and should be
|
||||
returned to Python as ``bytes``, then one can return the data as a
|
||||
``py::bytes`` object.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
m.def("return_bytes",
|
||||
[]() {
|
||||
std::string s("\xba\xd0\xba\xd0"); // Not valid UTF-8
|
||||
return py::bytes(s); // Return the data without transcoding
|
||||
}
|
||||
);
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> example.return_bytes()
|
||||
b'\xba\xd0\xba\xd0'
|
||||
|
||||
|
||||
Note the asymmetry: pybind11 will convert ``bytes`` to ``std::string`` without
|
||||
encoding, but cannot convert ``std::string`` back to ``bytes`` implicitly.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
m.def("asymmetry",
|
||||
[](std::string s) { // Accepts str or bytes from Python
|
||||
return s; // Looks harmless, but implicitly converts to str
|
||||
}
|
||||
);
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> isinstance(example.asymmetry(b"have some bytes"), str)
|
||||
True
|
||||
|
||||
>>> example.asymmetry(b"\xba\xd0\xba\xd0") # invalid utf-8 as bytes
|
||||
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 0: invalid start byte
|
||||
|
||||
|
||||
Wide character strings
|
||||
======================
|
||||
|
||||
When a Python ``str`` is passed to a C++ function expecting ``std::wstring``,
|
||||
``wchar_t*``, ``std::u16string`` or ``std::u32string``, the ``str`` will be
|
||||
encoded to UTF-16 or UTF-32 depending on how the C++ compiler implements each
|
||||
type, in the platform's native endianness. When strings of these types are
|
||||
returned, they are assumed to contain valid UTF-16 or UTF-32, and will be
|
||||
decoded to Python ``str``.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
#define UNICODE
|
||||
#include <windows.h>
|
||||
|
||||
m.def("set_window_text",
|
||||
[](HWND hwnd, std::wstring s) {
|
||||
// Call SetWindowText with null-terminated UTF-16 string
|
||||
::SetWindowText(hwnd, s.c_str());
|
||||
}
|
||||
);
|
||||
m.def("get_window_text",
|
||||
[](HWND hwnd) {
|
||||
const int buffer_size = ::GetWindowTextLength(hwnd) + 1;
|
||||
auto buffer = std::make_unique< wchar_t[] >(buffer_size);
|
||||
|
||||
::GetWindowText(hwnd, buffer.data(), buffer_size);
|
||||
|
||||
std::wstring text(buffer.get());
|
||||
|
||||
// wstring will be converted to Python str
|
||||
return text;
|
||||
}
|
||||
);
|
||||
|
||||
Strings in multibyte encodings such as Shift-JIS must transcoded to a
|
||||
UTF-8/16/32 before being returned to Python.
|
||||
|
||||
|
||||
Character literals
|
||||
==================
|
||||
|
||||
C++ functions that accept character literals as input will receive the first
|
||||
character of a Python ``str`` as their input. If the string is longer than one
|
||||
Unicode character, trailing characters will be ignored.
|
||||
|
||||
When a character literal is returned from C++ (such as a ``char`` or a
|
||||
``wchar_t``), it will be converted to a ``str`` that represents the single
|
||||
character.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
m.def("pass_char", [](char c) { return c; });
|
||||
m.def("pass_wchar", [](wchar_t w) { return w; });
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> example.pass_char("A")
|
||||
'A'
|
||||
|
||||
While C++ will cast integers to character types (``char c = 0x65;``), pybind11
|
||||
does not convert Python integers to characters implicitly. The Python function
|
||||
``chr()`` can be used to convert integers to characters.
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> example.pass_char(0x65)
|
||||
TypeError
|
||||
|
||||
>>> example.pass_char(chr(0x65))
|
||||
'A'
|
||||
|
||||
If the desire is to work with an 8-bit integer, use ``int8_t`` or ``uint8_t``
|
||||
as the argument type.
|
||||
|
||||
Grapheme clusters
|
||||
-----------------
|
||||
|
||||
A single grapheme may be represented by two or more Unicode characters. For
|
||||
example 'é' is usually represented as U+00E9 but can also be expressed as the
|
||||
combining character sequence U+0065 U+0301 (that is, the letter 'e' followed by
|
||||
a combining acute accent). The combining character will be lost if the
|
||||
two-character sequence is passed as an argument, even though it renders as a
|
||||
single grapheme.
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> example.pass_wchar("é")
|
||||
'é'
|
||||
|
||||
>>> combining_e_acute = "e" + "\u0301"
|
||||
|
||||
>>> combining_e_acute
|
||||
'é'
|
||||
|
||||
>>> combining_e_acute == "é"
|
||||
False
|
||||
|
||||
>>> example.pass_wchar(combining_e_acute)
|
||||
'e'
|
||||
|
||||
Normalizing combining characters before passing the character literal to C++
|
||||
may resolve *some* of these issues:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> example.pass_wchar(unicodedata.normalize("NFC", combining_e_acute))
|
||||
'é'
|
||||
|
||||
In some languages (Thai for example), there are `graphemes that cannot be
|
||||
expressed as a single Unicode code point
|
||||
<http://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries>`_, so there is
|
||||
no way to capture them in a C++ character type.
|
||||
|
||||
|
||||
C++17 string views
|
||||
==================
|
||||
|
||||
C++17 string views are automatically supported when compiling in C++17 mode.
|
||||
They follow the same rules for encoding and decoding as the corresponding STL
|
||||
string type (for example, a ``std::u16string_view`` argument will be passed
|
||||
UTF-16-encoded data, and a returned ``std::string_view`` will be decoded as
|
||||
UTF-8).
|
||||
|
||||
References
|
||||
==========
|
||||
|
||||
* `The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) <https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/>`_
|
||||
* `C++ - Using STL Strings at Win32 API Boundaries <https://msdn.microsoft.com/en-ca/magazine/mt238407.aspx>`_
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user