Compare commits

...

15 Commits

Author SHA1 Message Date
3307bfab1b fix 2020-03-17 19:11:29 +01:00
ce2c62000d include cmake in build 2020-03-17 18:57:19 +01:00
cf817c4ec1 WIP 2020-03-17 18:29:51 +01:00
bd01a5f2d2 cmake pkg 2020-03-16 19:36:18 +01:00
b059ba7c90 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-16 15:43:55 +01:00
89d70097f6 WIP 2020-03-16 15:43:46 +01:00
41d115a394 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-13 19:36:38 +01:00
45c1d3a553 gotthard2: burst mode fix for all the registers 2020-03-13 19:36:23 +01:00
17227be4df gotthard2: burst mode fix 2020-03-13 17:39:16 +01:00
7f4f8e8f09 help bug emax 2020-03-13 09:56:11 +01:00
6809bd6567 removed header 2020-03-12 12:38:00 +01:00
711d40a56e added sendToReceiver 2020-03-12 11:45:12 +01:00
81911fae3c new version of send to detector 2020-03-11 19:18:26 +01:00
f940397e3a cleaning 2020-03-11 18:10:37 +01:00
dc53887a48 minor clean 2020-03-11 17:49:32 +01:00
25 changed files with 544 additions and 328 deletions

View File

@ -203,11 +203,9 @@ if(SLS_BUILD_DOCS)
add_subdirectory(docs)
endif(SLS_BUILD_DOCS)
if(SLS_MASTER_PROJECT)
# Set install dir CMake packages
set(CMAKE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/cmake/sls)
set(CMAKE_INSTALL_DIR "share/cmake/${PROJECT_NAME}")
# Set the list of exported targets
set(PROJECT_LIBRARIES slsSupportLib slsDetectorShared slsReceiverShared)
# Generate and install package config file and version

View File

@ -15,17 +15,20 @@ configure_package_config_file(
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
COMPATIBILITY SameMajorVersion
)
install(FILES
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config-version.cmake"
COMPONENT devel
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME_LOWER})
DESTINATION ${CMAKE_INSTALL_DIR}
)
if (PROJECT_LIBRARIES OR PROJECT_STATIC_LIBRARIES)
install(
EXPORT "${TARGETS_EXPORT_NAME}"
FILE ${PROJECT_NAME_LOWER}-targets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME_LOWER})
DESTINATION ${CMAKE_INSTALL_DIR}
)
endif ()

View File

@ -5,18 +5,20 @@ mkdir $PREFIX/include
mkdir $PREFIX/include/slsDetectorPackage
#Shared and static libraries
cp build/bin/libSlsDetector.so $PREFIX/lib/.
cp build/bin/libSlsReceiver.so $PREFIX/lib/.
cp build/bin/libSlsSupport.so $PREFIX/lib/.
# cp build/bin/libSlsDetector.so $PREFIX/lib/.
# cp build/bin/libSlsReceiver.so $PREFIX/lib/.
# cp build/bin/libSlsSupport.so $PREFIX/lib/.
cp build/install/lib/* $PREFIX/lib/
#Binaries
cp build/bin/sls_detector_acquire $PREFIX/bin/.
cp build/bin/sls_detector_get $PREFIX/bin/.
cp build/bin/sls_detector_put $PREFIX/bin/.
cp build/bin/sls_detector_help $PREFIX/bin/.
cp build/bin/slsReceiver $PREFIX/bin/.
cp build/bin/slsMultiReceiver $PREFIX/bin/.
cp build/install/bin/sls_detector_acquire $PREFIX/bin/.
cp build/install/bin/sls_detector_get $PREFIX/bin/.
cp build/install/bin/sls_detector_put $PREFIX/bin/.
cp build/install/bin/sls_detector_help $PREFIX/bin/.
cp build/install/bin/slsReceiver $PREFIX/bin/.
cp build/install/bin/slsMultiReceiver $PREFIX/bin/.
#Which headers do we need for development??
cp build/install/include/* $PREFIX/include/slsDetectorPackage/
# cp include/some_lib.h $PREFIX/include/.
cp build/install/include/* $PREFIX/include/
cp -r build/install/share/ $PREFIX/share

View File

@ -3,7 +3,7 @@ find_package(Sphinx)
if (DOXYGEN_FOUND AND SPHINX_FOUND)
message(${CMAKE_PROJECT_SORURCE_DIR}/slsDetectorSoftware/src)
# message(${CMAKE_PROJECT_SORURCE_DIR}/slsDetectorSoftware/src)
# Utility to generate command line documentation
add_executable(gendoc src/gendoc.cpp)
# This is a bit hacky, but better than exposing stuff?
@ -30,6 +30,7 @@ if (DOXYGEN_FOUND AND SPHINX_FOUND)
set(SPHINX_SOURCE_FILES
src/commandline.rst
src/container_utils.rst
src/consuming.rst
src/dependencies.rst
src/detector.rst
src/index.rst
@ -41,6 +42,7 @@ if (DOXYGEN_FOUND AND SPHINX_FOUND)
src/result.rst
src/type_traits.rst
src/ToString.rst
src/examples.rst
)

95
docs/src/consuming.rst Normal file
View File

@ -0,0 +1,95 @@
Consuming slsDetectorPackage
===============================
Depending on how you want to build your integration with
slsDetectorPackage there are a few different ways to
consume our package. The recommended way is to use one of the
CMake approaches.
CMake: slsDetectorPackage as submodule in your project
---------------------------------------
If you are using CMake to build your integration and want to build everything
in one go, we support adding slsDetectorPackage as a subfolder in your cmake project.
A minimal CMakeLists.txt could look like this:
.. code-block:: cmake
project(myDetectorIntegration)
cmake_minimum_required(VERSION 3.12)
add_subdirectory(slsDetectorPackage)
#Add your executable
add_executable(example main.cpp)
target_compile_features(example PRIVATE cxx_std_11)
#Link towards slsDetectorShared
target_link_libraries(example slsDetectorShared)
A fully working example can be found at:
https://github.com/slsdetectorgroup/cmake-subfolder-example
CMake: find_package(slsDetectorPackage)
------------------------------------------
If you have compiled and installed slsDetectorPackage we also support
find_package in CMake. If installed in a system wide location no path
should be needed, otherwise specify cmake prefix path.
.. code-block:: cmake
cmake_minimum_required(VERSION 3.12)
project(myintegration)
find_package(slsDetectorPackage 5.0 REQUIRED)
add_executable(example main.cpp)
target_link_libraries(example slsDetectorShared)
Then assuming the slsDetectorPackage is installed in /path/to/sls/install
you should be able to configure and build your project in this way.
.. code-block:: bash
cmake ../path/to/your/source -DCMAKE_PREFIX_PATH=/path/to/sls/install
make
A minimal example is available at: https://github.com/slsdetectorgroup/minimal-cmake
No tools minimal approach
-----------------------------
While not recommended it is still possible to specify the include and library paths
manually when invoking g++. This can sometimes be handy for a quick try.
.. code-block:: cpp
#include "Detector.h"
#include <iostream>
int main(){
sls::Detector det;
//Get all values and print them
std::cout << "Hostname: " << det.getHostname() << "\n";
std::cout << "Type: " << det.getDetectorType() << "\n";
std::cout << "Udp ip: " << det.getSourceUDPIP() << "\n";
//Get mac addr
const int module = 0;
auto mac = det.getSourceUDPMAC()[module];
std::cout << "Mac addr of module "<< module << " is " << mac.str() << '\n';
}
.. code-block:: bash
g++ -I/install/path/include/ -L/install/path/lib64/ myapp.cpp -lSlsDetector -lSlsSupport -Wl,-rpath=../install/path/lib64

View File

@ -13,7 +13,7 @@ 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.9
* CMake > 3.12
* C++11 compatible compiler. (We test with gcc and clang)
* ZeroMQ version 4
@ -24,7 +24,7 @@ GUI
The GUI is currently using Qt4 but watch out for an upgrade to 5.
* Qt 4.8
* Qwt 6
* Qwt 6.1
-----------------------
Python bindings

115
docs/src/examples.rst Normal file
View File

@ -0,0 +1,115 @@
Examples
===========
Setup
------------
The examples here assume that you have compiled and installed slsDetectorPackage
to ~/sls/install and that the option for SLS_USE_SIMULATOR was enabled. This also builds
the virtual detector servers that we will be using for testing.
We also add ~/sls/detector/install/bin to the path for convenience.
Compile examples
-------------------
The source code of the examples is available at:
https://github.com/slsdetectorgroup/api-examples
.. code-block:: bash
git clone https://github.com/slsdetectorgroup/api-examples.git
mkdir build && cd build
cmake ../api-examples -DCMAKE_PREFIX_PATH=~/sls/detector/install
make
Below follows a short description of what is included in the examples.
Running a config file [e1]
-----------------------------
.. code-block:: cpp
#include "Detector.h"
...
sls::Detector det;
det.loadConfig("path/to/config/file.config");
To configure the connection between PC and detector the easiest
is to run a config file. For this example we first launch a virtual Jungfrau server and
then set up the detector.
**Launch a virtual detector server**
.. code-block:: bash
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.
**Run example to configure**
.. code-block:: bash
./e1-config one_det_no_receiver.config
- 12:01:06.371 INFO: Shared memory deleted /slsDetectorPackage_multi_0_sls_0
- 12:01:06.371 INFO: Shared memory deleted /slsDetectorPackage_multi_0
- 12:01:06.372 INFO: Shared memory created /slsDetectorPackage_multi_0
- 12:01:06.376 INFO: Loading configuration file: one_det_no_receiver.config
- 12:01:06.376 INFO: Adding detector localhost
- 12:01:06.377 INFO: Shared memory created /slsDetectorPackage_multi_0_sls_0
- 12:01:06.377 INFO: Checking Detector Version Compatibility
- 12:01:06.378 INFO: Detector connecting - updating!
hostname [localhost]
Jungfrau detector with 1 modules configured
Using the return type sls::Result [e2]
-----------------------------------------
Since many our detectors have multiple modules we cannot return
a single value when reading from the Detector. Hostname, Ip and also
for example exposure time can differ between modules.
Therefore we return Result<T> which is a thin wrapper around
std::vector.
.. code-block:: cpp
sls::Result<int> res1{1, 1, 1};
std::cout << "res1: " << res1 << '\n';
res1.squash();
res1.squash(-1);
Setting exposure time [e3]
-----------------------------------------
For setting times, like exposure time, period, delay etc.
we use std::chrono::duration.
Example 3 shows how to set and read exposure time as well
as converting to floating point.
.. code-block:: cpp
#include "Detector.h"
#include <chrono>
...
std::chrono::microseconds t0{500};
det.setExptime(t0);

View File

@ -6,12 +6,18 @@
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
.. toctree::
:maxdepth: 1
:caption: Installation:
installation
dependencies
consuming
.. toctree::
:caption: C++ API
@ -20,6 +26,7 @@ Welcome to slsDetectorPackage's documentation!
detector
result
receiver
examples
.. toctree::
:caption: Python API

View File

@ -2,4 +2,24 @@
Installation
==============================================
get the source etc.
Build from source using CMake
---------------------------------
.. 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.
.. code-block:: bash
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git
mkdir build && cd build
cmake ../slsDetectorPackage -DCMAKE_INSTALL_PREFIX=/your/install/path
make -j12
make install

View File

@ -1,9 +1,9 @@
Detector
=====================================================
.. py:currentmodule:: sls_detector
.. py:currentmodule:: slsdet
.. autoclass:: ExperimentalDetector
.. autoclass:: Detector
:members:
:undoc-members:
:show-inheritance:

View File

@ -45,7 +45,7 @@ ext_modules = [
# get_pybind_include(),
# get_pybind_include(user=True),
os.path.join('../libs/pybind11/include'),
os.path.join(get_conda_path(), 'include/slsDetectorPackage'),
os.path.join(get_conda_path(), 'include'),
],
libraries=['SlsDetector', 'SlsReceiver', 'zmq'],

View File

@ -47,9 +47,10 @@ int injectedChannelsIncrement = 0;
int vetoReference[NCHIP][NCHAN];
uint8_t adcConfiguration[NCHIP][NADC];
int burstMode = BURST_INTERNAL;
int64_t numTriggers = 1;
int64_t numBursts = 1;
int64_t burstPeriodNs = 0;
int64_t numTriggersReg = 1;
int64_t delayReg = 0;
int64_t numBurstsReg = 1;
int64_t burstPeriodReg = 0;
int detPos[2] = {};
int isInitCheckDone() {
@ -354,9 +355,10 @@ void setupDetector() {
injectedChannelsOffset = 0;
injectedChannelsIncrement = 0;
burstMode = BURST_INTERNAL;
numTriggers = 1;
numBursts = 1;
burstPeriodNs = 0;
numTriggersReg = 1;
delayReg = 0;
numBurstsReg = 1;
burstPeriodReg = 0;
{
int i, j;
for (i = 0; i < NUM_CLOCKS; ++i) {
@ -736,32 +738,31 @@ int setDynamicRange(int dr){
/* parameters - timer */
void setNumFrames(int64_t val) {
if (val > 0) {
LOG(logINFO, ("Setting number of frames %lld [local]\n", val));
// continuous mode
if (burstMode == BURST_OFF) {
setNumFramesCont(val);
setNumFramesBurst(1);
LOG(logINFO, ("Setting number of frames %lld [Continuous mode]\n", val));
set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
} else {
setNumFramesBurst(val);
setNumFramesCont(1);
LOG(logINFO, ("Setting number of frames %d [Burst mode]\n", (int)val));
bus_w(ASIC_INT_FRAMES_REG, bus_r(ASIC_INT_FRAMES_REG) &~ ASIC_INT_FRAMES_MSK);
bus_w(ASIC_INT_FRAMES_REG, bus_r(ASIC_INT_FRAMES_REG) | (((int)val << ASIC_INT_FRAMES_OFST) & ASIC_INT_FRAMES_MSK));
}
}
}
int64_t getNumFrames() {
if (burstMode == BURST_OFF) {
return getNumFramesCont();
return get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
} else {
return getNumFramesBurst();
return ((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >> ASIC_INT_FRAMES_OFST);
}
}
void setNumTriggers(int64_t val) {
if (val > 0) {
LOG(logINFO, ("Setting number of triggers %lld\n", val));
numTriggers = val;
if (burstMode != BURST_OFF && getTiming() == AUTO_TIMING) {
LOG(logINFO, ("\tBurst and Auto mode: not writing #triggers to register\n"));
if (getTiming() == AUTO_TIMING) {
LOG(logINFO, ("\tNot trigger mode: not writing to register\n"));
numTriggersReg = val;
} else {
set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
}
@ -769,8 +770,8 @@ void setNumTriggers(int64_t val) {
}
int64_t getNumTriggers() {
if (burstMode != BURST_OFF && getTiming() == AUTO_TIMING) {
return numTriggers;
if (getTiming() == AUTO_TIMING) {
return numTriggersReg;
}
return get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
}
@ -778,20 +779,20 @@ int64_t getNumTriggers() {
void setNumBursts(int64_t val) {
if (val > 0) {
LOG(logINFO, ("Setting number of bursts %lld\n", val));
numBursts = val;
if (burstMode != BURST_OFF && getTiming() == AUTO_TIMING) {
set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
} else {
LOG(logINFO, ("\tNot (Burst and Auto mode): not writing #bursts to register\n"));
LOG(logINFO, ("\tNot (Burst and Auto mode): not writing to register\n"));
numBurstsReg = val;
}
}
}
int64_t getNumBursts() {
if (burstMode != BURST_OFF && getTiming() == AUTO_TIMING) {
return get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
return get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
}
return numBursts;
return numBurstsReg;
}
int setExpTime(int64_t val) {
@ -799,17 +800,21 @@ int setExpTime(int64_t val) {
LOG(logERROR, ("Invalid exptime: %lld ns\n", val));
return FAIL;
}
LOG(logINFO, ("Setting exptime %lld ns [local]\n", val));
// continuous mode
if (burstMode == BURST_OFF) {
return setExptimeCont(val);
} else {
return setExptimeBurst(val);
}
LOG(logINFO, ("Setting exptime %lld ns\n", val));
val *= (1E-9 * systemFrequency);
set64BitReg(val, ASIC_INT_EXPTIME_LSB_REG, ASIC_INT_EXPTIME_MSB_REG);
// validate for tolerance
int64_t retval = getExpTime();
val /= (1E-9 * systemFrequency);
if (val != retval) {
return FAIL;
}
return OK;
}
int64_t getExpTime() {
return getExptimeBoth();
return get64BitReg(ASIC_INT_EXPTIME_LSB_REG, ASIC_INT_EXPTIME_MSB_REG) / (1E-9 * systemFrequency);
}
int setPeriod(int64_t val) {
@ -817,110 +822,31 @@ int setPeriod(int64_t val) {
LOG(logERROR, ("Invalid period: %lld ns\n", val));
return FAIL;
}
LOG(logINFO, ("Setting period %lld ns [local]\n", val));
// continuous mode
val *= (1E-9 * systemFrequency);
if (burstMode == BURST_OFF) {
setPeriodBurst(0);
return setPeriodCont(val);
LOG(logINFO, ("Setting period %lld ns [Continuous mode]\n", val));
set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
} else {
//setPeriodCont(0);
return setPeriodBurst(val);
LOG(logINFO, ("Setting period %lld ns [Burst mode]\n", val));
set64BitReg(val, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
}
// validate for tolerance
int64_t retval = getPeriod();
val /= (1E-9 * systemFrequency);
if (val != retval) {
return FAIL;
}
return OK;
}
int64_t getPeriod() {
if (burstMode == BURST_OFF) {
return getPeriodCont();
return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/ (1E-9 * systemFrequency);
} else {
return getPeriodBurst();
return get64BitReg(ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG)/ (1E-9 * systemFrequency);
}
}
void setNumFramesBurst(int64_t val) {
LOG(logINFO, ("Setting number of frames %d [Burst mode]\n", (int)val));
bus_w(ASIC_INT_FRAMES_REG, bus_r(ASIC_INT_FRAMES_REG) &~ ASIC_INT_FRAMES_MSK);
bus_w(ASIC_INT_FRAMES_REG, bus_r(ASIC_INT_FRAMES_REG) | (((int)val << ASIC_INT_FRAMES_OFST) & ASIC_INT_FRAMES_MSK));
}
int64_t getNumFramesBurst() {
return ((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >> ASIC_INT_FRAMES_OFST);
}
void setNumFramesCont(int64_t val) {
LOG(logINFO, ("Setting number of frames %lld [Continuous mode]\n", val));
set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
}
int64_t getNumFramesCont() {
return get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
}
int setExptimeBurst(int64_t val) {
LOG(logINFO, ("Setting exptime %lld ns [Burst mode]\n", val));
return setExptimeBoth(val);
}
int setExptimeCont(int64_t val) {
LOG(logINFO, ("Setting exptime %lld ns [Continuous mode]\n", val));
return setExptimeBoth(val);
}
int setExptimeBoth(int64_t val) {
val *= (1E-9 * systemFrequency);
set64BitReg(val, ASIC_INT_EXPTIME_LSB_REG, ASIC_INT_EXPTIME_MSB_REG);
// validate for tolerance
int64_t retval = getExptimeBoth();
val /= (1E-9 * systemFrequency);
if (val != retval) {
return FAIL;
}
return OK;
}
int64_t getExptimeBoth() {
return get64BitReg(ASIC_INT_EXPTIME_LSB_REG, ASIC_INT_EXPTIME_MSB_REG) / (1E-9 * systemFrequency);
}
int setPeriodBurst(int64_t val) {
LOG(logINFO, ("Setting period %lld ns [Burst mode]\n", val));
val *= (1E-9 * systemFrequency);
set64BitReg(val, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
// validate for tolerance
int64_t retval = getPeriodBurst();
val /= (1E-9 * systemFrequency);
if (val != retval) {
return FAIL;
}
return OK;
}
int64_t getPeriodBurst() {
LOG(logDEBUG, ("Getting period [Burst mode]\n"));
return get64BitReg(ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG)/ (1E-9 * systemFrequency);
}
int setPeriodCont(int64_t val) {
LOG(logINFO, ("Setting period %lld ns [Continuous mode]\n", val));
val *= (1E-9 * systemFrequency);
set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
// validate for tolerance
int64_t retval = getPeriodCont();
val /= (1E-9 * systemFrequency);
if (val != retval) {
return FAIL;
}
return OK;
}
int64_t getPeriodCont() {
LOG(logDEBUG, ("Getting period [Continuous mode]\n"));
return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/ (1E-9 * systemFrequency);
}
int setDelayAfterTrigger(int64_t val) {
if (val < 0) {
LOG(logERROR, ("Invalid delay after trigger: %lld ns\n", val));
@ -928,8 +854,12 @@ int setDelayAfterTrigger(int64_t val) {
}
LOG(logINFO, ("Setting delay after trigger %lld ns\n", val));
val *= (1E-9 * systemFrequency);
set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
if (getTiming() == AUTO_TIMING) {
LOG(logINFO, ("\tNot trigger mode: not writing to register\n"));
delayReg = val;
} else {
set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
}
// validate for tolerance
int64_t retval = getDelayAfterTrigger();
val /= (1E-9 * systemFrequency);
@ -940,6 +870,9 @@ int setDelayAfterTrigger(int64_t val) {
}
int64_t getDelayAfterTrigger() {
if (getTiming() == AUTO_TIMING) {
return delayReg / (1E-9 * systemFrequency);
}
return get64BitReg(SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG) / (1E-9 * systemFrequency);
}
@ -949,12 +882,12 @@ int setBurstPeriod(int64_t val) {
return FAIL;
}
LOG(logINFO, ("Setting burst period %lld ns\n", val));
burstPeriodNs = val;
val *= (1E-9 * systemFrequency);
if (burstMode != BURST_OFF) {
if (burstMode != BURST_OFF && getTiming() == AUTO_TIMING) {
set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
} else {
LOG(logINFO, ("\t(Continuous mode): not writing burst period to register\n"));
LOG(logINFO, ("\tNot (Burst and Auto mode): not writing to register\n"));
burstPeriodReg = val;
}
// validate for tolerance
@ -967,10 +900,10 @@ int setBurstPeriod(int64_t val) {
}
int64_t getBurstPeriod() {
if (burstMode != BURST_OFF) {
if (burstMode != BURST_OFF && getTiming() == AUTO_TIMING) {
return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG) / (1E-9 * systemFrequency);
}
return burstPeriodNs;
return burstPeriodReg / (1E-9 * systemFrequency);
}
int64_t getNumFramesLeft() {
@ -1185,6 +1118,18 @@ int setHighVoltage(int val){
/* parameters - timing */
void setTiming( enum timingMode arg){
// update
// trigger
if (getTiming() == TRIGGER_EXPOSURE) {
numTriggersReg = get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
delayReg = get64BitReg(SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
}
// auto and burst
else if (burstMode != BURST_OFF) {
numBurstsReg = get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
burstPeriodReg = get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
}
switch(arg){
case AUTO_TIMING:
LOG(logINFO, ("Set Timing: Auto\n"));
@ -1198,9 +1143,32 @@ void setTiming( enum timingMode arg){
LOG(logERROR, ("Unknown timing mode %d\n", arg));
}
LOG(logINFO, ("\tUpdating trigger/burst and delay/burst period registers\n"))
setNumTriggers(numTriggers);
setNumBursts(numBursts);
LOG(logINFO, ("\tUpdating registers\n"))
// trigger
if (getTiming() == TRIGGER_EXPOSURE) {
set64BitReg(numTriggersReg, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
set64BitReg(delayReg, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
LOG(logINFO, ("\tTriggers reg: %lld, Delay reg: %lldns\n", getNumTriggers(), getDelayAfterTrigger()));
// burst
if (burstMode != BURST_OFF) {
LOG(logINFO, ("\tFrame reg: 1, Period reg: 0\n"))
set64BitReg(1, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
set64BitReg(0, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
}
}
// auto
else {
LOG(logINFO, ("\tTrigger reg: 1, Delay reg: 0\n"))
set64BitReg(1, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
set64BitReg(0, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
// burst
if (burstMode != BURST_OFF) {
set64BitReg(numBurstsReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
set64BitReg(burstPeriodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
LOG(logINFO, ("\tFrames reg (bursts): %lld, Period reg(burst period): %lldns\n", getNumBursts(), getBurstPeriod()));
}
}
LOG(logINFO, ("\tDone Updating registers\n"))
}
enum timingMode getTiming() {
@ -1875,23 +1843,62 @@ int setBurstModeinFPGA(enum burstMode value) {
int setBurstMode(enum burstMode burst) {
LOG(logINFO, ("Setting burst mode to %s\n", burst == BURST_OFF ? "off" : (burst == BURST_INTERNAL ? "internal" : "external")));
// remember the number of frames and period (before changing burst mode)
int64_t frames = getNumFrames();
int64_t period = getPeriod();
// update
int64_t framesReg = 0;
int64_t periodReg = 0;
// burst
if (burstMode != BURST_OFF) {
framesReg = ((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >> ASIC_INT_FRAMES_OFST);
periodReg = get64BitReg(ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
// auto
if (getTiming() == AUTO_TIMING) {
numBurstsReg = get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
burstPeriodReg = get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
}
}
// continuous
else {
framesReg = get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
periodReg = get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
}
if (setBurstModeinFPGA(burst) == FAIL) {
return FAIL;
}
LOG(logINFO, ("\tUpdating trigger/burst and burst period registers\n"))
setNumTriggers(numTriggers);
setNumBursts(numBursts);
setBurstPeriod(burstPeriodNs);
LOG(logINFO, ("\tUpdating registers\n"));
// continuous
if (burstMode == BURST_OFF) {
set64BitReg(framesReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
set64BitReg(periodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
LOG(logINFO, ("\tFrames reg: %lld, Period reg: %lldns\n", getNumFrames(), getPeriod()));
// set number of frames and period again (set registers according to timing mode)
LOG(logINFO, ("\tUpdating #frames and period registers\n"));
setNumFrames(frames);
setPeriod(period);
LOG(logINFO, ("\tInt. Frame reg: 1, Int. Period reg: 0\n"))
bus_w(ASIC_INT_FRAMES_REG, bus_r(ASIC_INT_FRAMES_REG) &~ ASIC_INT_FRAMES_MSK);
bus_w(ASIC_INT_FRAMES_REG, bus_r(ASIC_INT_FRAMES_REG) | ((1 << ASIC_INT_FRAMES_OFST) & ASIC_INT_FRAMES_MSK));
set64BitReg(0, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
}
// burst
else {
bus_w(ASIC_INT_FRAMES_REG, bus_r(ASIC_INT_FRAMES_REG) &~ ASIC_INT_FRAMES_MSK);
bus_w(ASIC_INT_FRAMES_REG, bus_r(ASIC_INT_FRAMES_REG) | (((int)framesReg << ASIC_INT_FRAMES_OFST) & ASIC_INT_FRAMES_MSK));
set64BitReg(periodReg, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
LOG(logINFO, ("\tInt. Frames reg: %lld, Int. Period reg: %lldns\n", getNumFrames(), getPeriod()));
// trigger
if (getTiming() == TRIGGER_EXPOSURE) {
LOG(logINFO, ("\tFrame reg: 1, Period reg: 0\n"))
set64BitReg(1, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
set64BitReg(0, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
}
//auto
else {
set64BitReg(numBurstsReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
set64BitReg(burstPeriodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
LOG(logINFO, ("\tFrames reg (bursts): %lld, Period reg(burst period): %lldns\n", getNumBursts(), getBurstPeriod()));
}
}
LOG(logINFO, ("\tDone Updating registers\n"))
LOG(logINFO, ("\tSetting %s Mode in Chip\n", burstMode == BURST_OFF ? "Continuous" : "Burst"));
int value = burstMode ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE;

View File

@ -14,15 +14,12 @@ add_executable(jungfrauDetectorServer_virtual
../slsDetectorServer/src/communication_funcs_UDP.c
)
include_directories(
target_include_directories(jungfrauDetectorServer_virtual
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
../slsDetectorServer/include
../../slsSupportLib/include
)
target_include_directories(jungfrauDetectorServer_virtual
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
)
target_compile_definitions(jungfrauDetectorServer_virtual
PUBLIC JUNGFRAUD VIRTUAL STOP_SERVER
)
@ -36,5 +33,6 @@ set_target_properties(jungfrauDetectorServer_virtual PROPERTIES
)
install(TARGETS jungfrauDetectorServer_virtual
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
EXPORT "${TARGETS_EXPORT_NAME}"
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

View File

@ -202,19 +202,6 @@ void setNumBursts(int64_t val);
int64_t getNumBursts();
int setBurstPeriod(int64_t val);
int64_t getBurstPeriod();
void setNumFramesBurst(int64_t val);
int64_t getNumFramesBurst();
void setNumFramesCont(int64_t val);
int64_t getNumFramesCont();
int setExptimeBurst(int64_t val);
int setExptimeCont(int64_t val);
int setExptimeBoth(int64_t val);
int64_t getExptimeBoth();
int setPeriodBurst(int64_t val);
int64_t getPeriodBurst();
int setPeriodCont(int64_t val);
int64_t getPeriodCont();
#endif
#ifdef EIGERD
int setSubExpTime(int64_t val);

View File

@ -1,15 +1,17 @@
#pragma once
#include "Result.h"
#include "network_utils.h"
#include "sls_detector_defs.h"
#include <chrono>
#include <memory>
#include <vector>
class DetectorImpl;
class detectorData;
namespace sls {
using ns = std::chrono::nanoseconds;
class DetectorImpl;
class MacAddr;
class IpAddr;

View File

@ -1782,7 +1782,7 @@ std::string CmdProxy::MinMaxEnergyThreshold(int action) {
os << "[n_value]\n\t[Moench] Minimum energy threshold (soft "
"setting) for processor."
<< '\n';
} else if (cmd == "emin") {
} else if (cmd == "emax") {
os << "[n_value]\n\t[Moench] Maximum energy threshold (soft "
"setting) for processor."
<< '\n';

View File

@ -7,6 +7,7 @@
#include "DetectorImpl.h"
#include "Module.h"
#include "sls_detector_defs.h"
#include "versionAPI.h"
#include <fstream>
@ -97,11 +98,11 @@ void Detector::setVirtualDetectorServers(int numServers, int startingPort) {
int Detector::getShmId() const { return pimpl->getMultiId(); }
std::string Detector::getPackageVersion() const {
return pimpl->getPackageVersion();
return GITBRANCH;
}
int64_t Detector::getClientVersion() const {
return pimpl->getClientSoftwareVersion();
return APILIB;
}
Result<int64_t> Detector::getFirmwareVersion(Positions pos) const {

View File

@ -26,7 +26,7 @@
#include <future>
#include <vector>
using namespace sls;
namespace sls{
DetectorImpl::DetectorImpl(int multi_id, bool verify, bool update)
: multiId(multi_id), multi_shm(multi_id, -1) {
@ -49,10 +49,6 @@ void DetectorImpl::setAcquiringFlag(bool flag) {
int DetectorImpl::getMultiId() const { return multiId; }
std::string DetectorImpl::getPackageVersion() const { return GITBRANCH; }
int64_t DetectorImpl::getClientSoftwareVersion() const { return APILIB; }
void DetectorImpl::freeSharedMemory(int multiId, int detPos) {
// single
if (detPos >= 0) {
@ -160,7 +156,6 @@ void DetectorImpl::initializeDetectorStructure() {
multi_shm()->numberOfChannels.x = 0;
multi_shm()->numberOfChannels.y = 0;
multi_shm()->acquiringFlag = false;
multi_shm()->receiver_upstream = false;
multi_shm()->initialChecks = true;
}
@ -822,46 +817,6 @@ bool DetectorImpl::enableDataStreamingToClient(int enable) {
return client_downstream;
}
void DetectorImpl::savePattern(const std::string &fname) {
// std::ofstream outfile;
// outfile.open(fname.c_str(), std::ios_base::out);
// if (!outfile.is_open()) {
// throw RuntimeError("Could not create file to save pattern");
// }
// // get pattern limits
// auto r = Parallel(&Module::setPatternLoopAddresses, {}, -1, -1, -1)
// .tsquash("Inconsistent pattern limits");
// // pattern words
// for (int i = r[0]; i <= r[1]; ++i) {
// std::ostringstream os;
// os << "patword 0x" << std::hex << i;
// std::string cmd = os.str();
// multiSlsDetectorClient(cmd, GET_ACTION, this, outfile);
// }
// // rest of pattern file
// const std::vector<std::string> commands{
// "patioctrl",
// "patclkctrl",
// "patlimits",
// "patloop0",
// "patnloop0",
// "patloop1",
// "patnloop1",
// "patloop2",
// "patnloop2",
// "patwait0",
// "patwaittime0",
// "patwait1",
// "patwaittime1",
// "patwait2",
// "patwaittime2",
// "patmask",
// "patsetbit",
// };
// for (const auto &cmd : commands)
// multiSlsDetectorClient(cmd, GET_ACTION, this, outfile);
}
void DetectorImpl::registerAcquisitionFinishedCallback(void (*func)(double, int,
void *),
void *pArg) {
@ -1199,3 +1154,5 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
LOG(logINFO) << "Read file into memory";
return buffer;
}
}//namespace sls

View File

@ -5,10 +5,6 @@
#include "logger.h"
#include "sls_detector_defs.h"
namespace sls{
class Module;
}
class ZmqSocket;
class detectorData;
@ -25,6 +21,11 @@ class detectorData;
#include <future>
#include <numeric>
namespace sls{
class Module;
/**
* @short structure allocated in shared memory to store detector settings
* for IPC and cache
@ -64,9 +65,6 @@ struct sharedMultiSlsDetector {
/** flag for acquiring */
bool acquiringFlag;
/** data streaming (up stream) enable in receiver */
bool receiver_upstream;
/** initial checks */
bool initialChecks;
};
@ -202,10 +200,6 @@ class DetectorImpl : public virtual slsDetectorDefs {
/** return multi detector shared memory ID */
int getMultiId() const;
std::string getPackageVersion() const;
int64_t getClientSoftwareVersion() const;
/** Free specific shared memory from the command line without creating object */
static void freeSharedMemory(int multiId, int detPos = -1);
@ -255,8 +249,6 @@ class DetectorImpl : public virtual slsDetectorDefs {
*/
bool enableDataStreamingToClient(int enable = -1);
void savePattern(const std::string &fname);
/**
* register callback for accessing acquisition final data
* @param func function to be called at the end of the acquisition.
@ -393,14 +385,6 @@ class DetectorImpl : public virtual slsDetectorDefs {
*/
int kbhit();
/**
* Convert a double holding time in seconds to an int64_t with nano seconds
* Used for conversion when sending time to detector
* @param t time in seconds
* @returns time in nano seconds
*/
int64_t secondsToNanoSeconds(double t);
/** Multi detector Id */
const int multiId{0};
@ -448,3 +432,5 @@ class DetectorImpl : public virtual slsDetectorDefs {
void (*dataReady)(detectorData *, uint64_t, uint32_t, void *){nullptr};
void *pCallbackArg{nullptr};
};
}//namespace sls

View File

@ -164,6 +164,29 @@ void Module::sendToDetector(int fnum) {
sendToDetector(fnum, nullptr, 0, nullptr, 0);
}
template <typename Ret>
Ret Module::sendToDetector(int fnum){
LOG(logDEBUG1) << "Sending: ["
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
<< ", nullptr, 0, " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
Ret retval{};
sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval));
LOG(logDEBUG1) << "Got back: " << retval;
return retval;
}
template <typename Ret, typename Arg>
Ret Module::sendToDetector(int fnum, const Arg &args){
LOG(logDEBUG1) << "Sending: ["
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
<< ", " << args << ", " << sizeof(args) << ", " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
Ret retval{};
sendToDetector(fnum, &args, sizeof(args), &retval, sizeof(retval));
LOG(logDEBUG1) << "Got back: " << retval;
return retval;
}
void Module::sendToDetectorStop(int fnum, const void *args,
size_t args_size, void *retval,
size_t retval_size) {
@ -265,14 +288,58 @@ void Module::sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const {
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
}
void Module::sendToReceiver(int fnum) {
sendToReceiver(fnum, nullptr, 0, nullptr, 0);
template <typename Ret>
Ret Module::sendToReceiver(int fnum){
LOG(logDEBUG1) << "Sending: ["
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
<< ", nullptr, 0, " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
Ret retval{};
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
LOG(logDEBUG1) << "Got back: " << retval;
return retval;
}
void Module::sendToReceiver(int fnum) const {
sendToReceiver(fnum, nullptr, 0, nullptr, 0);
template <typename Ret>
Ret Module::sendToReceiver(int fnum) const{
LOG(logDEBUG1) << "Sending: ["
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
<< ", nullptr, 0, " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
Ret retval{};
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
LOG(logDEBUG1) << "Got back: " << retval;
return retval;
}
template <typename Ret, typename Arg>
Ret Module::sendToReceiver(int fnum, const Arg &args){
LOG(logDEBUG1) << "Sending: ["
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
<< ", " << args << ", " << sizeof(args) << ", " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
Ret retval{};
sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval));
LOG(logDEBUG1) << "Got back: " << retval;
return retval;
}
template <typename Ret, typename Arg>
Ret Module::sendToReceiver(int fnum, const Arg &args) const{
LOG(logDEBUG1) << "Sending: ["
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
<< ", " << args << ", " << sizeof(args) << ", " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
Ret retval{};
sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval));
LOG(logDEBUG1) << "Got back: " << retval;
return retval;
}
// void Module::sendToReceiver(int fnum) {
// sendToReceiver(fnum, nullptr, 0, nullptr, 0);
// }
// void Module::sendToReceiver(int fnum) const {
// sendToReceiver(fnum, nullptr, 0, nullptr, 0);
// }
void Module::freeSharedMemory() {
if (shm.IsExisting()) {
shm.RemoveSharedMemory();
@ -1277,10 +1344,7 @@ void Module::setNumberOfDigitalSamples(int value) {
}
int64_t Module::getExptime() {
int64_t retval = -1;
sendToDetector(F_GET_EXPTIME, nullptr, retval);
LOG(logDEBUG1) << "exptime :" << retval << "ns";
return retval;
return sendToDetector<int64_t>(F_GET_EXPTIME);
}
void Module::setExptime(int64_t value) {
@ -1303,10 +1367,7 @@ void Module::setExptime(int64_t value) {
}
int64_t Module::getPeriod() {
int64_t retval = -1;
sendToDetector(F_GET_PERIOD, nullptr, retval);
LOG(logDEBUG1) << "period :" << retval << "ns";
return retval;
return sendToDetector<int64_t>(F_GET_PERIOD);
}
void Module::setPeriod(int64_t value) {
@ -1319,10 +1380,7 @@ void Module::setPeriod(int64_t value) {
}
int64_t Module::getDelayAfterTrigger() {
int64_t retval = -1;
sendToDetector(F_GET_DELAY_AFTER_TRIGGER, nullptr, retval);
LOG(logDEBUG1) << "delay after trigger :" << retval << "ns";
return retval;
return sendToDetector<int64_t>(F_GET_DELAY_AFTER_TRIGGER);
}
void Module::setDelayAfterTrigger(int64_t value) {
@ -1331,10 +1389,7 @@ void Module::setDelayAfterTrigger(int64_t value) {
}
int64_t Module::getBurstPeriod() {
int64_t retval = -1;
sendToDetector(F_GET_BURST_PERIOD, nullptr, retval);
LOG(logDEBUG1) << "burst period :" << retval << "ns";
return retval;
return sendToDetector<int64_t>(F_GET_BURST_PERIOD);
}
void Module::setBurstPeriod(int64_t value) {
@ -1343,10 +1398,7 @@ void Module::setBurstPeriod(int64_t value) {
}
int64_t Module::getSubExptime() {
int64_t retval = -1;
sendToDetector(F_GET_SUB_EXPTIME, nullptr, retval);
LOG(logDEBUG1) << "sub exptime :" << retval << "ns";
return retval;
return sendToDetector<int64_t>(F_GET_SUB_EXPTIME);
}
void Module::setSubExptime(int64_t value) {
@ -1369,10 +1421,7 @@ void Module::setSubExptime(int64_t value) {
}
int64_t Module::getSubDeadTime() {
int64_t retval = -1;
sendToDetector(F_GET_SUB_DEADTIME, nullptr, retval);
LOG(logDEBUG1) << "sub deadtime :" << retval << "ns";
return retval;
return sendToDetector<int64_t>(F_GET_SUB_DEADTIME);
}
void Module::setSubDeadTime(int64_t value) {
@ -1623,31 +1672,17 @@ void Module::setInterruptSubframe(const bool enable) {
}
bool Module::getInterruptSubframe() {
int retval = -1;
LOG(logDEBUG1) << "Getting Interrupt subframe";
sendToDetector(F_GET_INTERRUPT_SUBFRAME, nullptr, retval);
LOG(logDEBUG1) << "Interrupt subframe: " << retval;
auto retval = sendToDetector<int>(F_GET_INTERRUPT_SUBFRAME);
return static_cast<bool>(retval);
}
uint32_t Module::writeRegister(uint32_t addr, uint32_t val) {
uint32_t args[]{addr, val};
uint32_t retval = -1;
LOG(logDEBUG1) << "Writing to reg 0x" << std::hex << addr << "data: 0x"
<< std::hex << val << std::dec;
sendToDetector(F_WRITE_REGISTER, args, retval);
LOG(logDEBUG1) << "Reg 0x" << std::hex << addr << ": 0x" << std::hex
<< retval << std::dec;
return retval;
return sendToDetector<uint32_t>(F_WRITE_REGISTER, args);
}
uint32_t Module::readRegister(uint32_t addr) {
uint32_t retval = -1;
LOG(logDEBUG1) << "Reading reg 0x" << std::hex << addr << std::dec;
sendToDetector(F_READ_REGISTER, addr, retval);
LOG(logDEBUG1) << "Reg 0x" << std::hex << addr << ": 0x" << std::hex
<< retval << std::dec;
return retval;
return sendToDetector<uint32_t>(F_READ_REGISTER, addr);
}
uint32_t Module::setBit(uint32_t addr, int n) {
@ -2032,12 +2067,8 @@ void Module::setClientStreamingPort(int port) { shm()->zmqport = port; }
int Module::getClientStreamingPort() { return shm()->zmqport; }
void Module::setReceiverStreamingPort(int port) {
int fnum = F_SET_RECEIVER_STREAMING_PORT;
int retval = -1;
LOG(logDEBUG1) << "Sending receiver streaming port to receiver: "
<< port;
if (shm()->useReceiverFlag) {
sendToReceiver(fnum, port, retval);
auto retval = sendToReceiver<int>(F_SET_RECEIVER_STREAMING_PORT, port);
LOG(logDEBUG1) << "Receiver streaming port: " << retval;
shm()->rxZmqport = retval;
} else {
@ -2278,14 +2309,7 @@ int64_t Module::getReceiverUDPSocketBufferSize() {
}
int64_t Module::getReceiverRealUDPSocketBufferSize() const {
int64_t retval = -1;
LOG(logDEBUG1) << "Getting real UDP Socket Buffer size from receiver";
if (shm()->useReceiverFlag) {
sendToReceiver(F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, nullptr, retval);
LOG(logDEBUG1)
<< "Real Receiver UDP Socket Buffer size: " << retval;
}
return retval;
return sendToReceiver<int64_t>(F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE);
}
void Module::executeFirmwareTest() {
@ -3136,7 +3160,7 @@ sls::IpAddr Module::getReceiverLastClientIP() const {
void Module::exitReceiver() {
LOG(logDEBUG1) << "Sending exit command to receiver server";
if (shm()->useReceiverFlag) {
sendToReceiver(F_EXIT_RECEIVER);
sendToReceiver(F_EXIT_RECEIVER, nullptr, nullptr);
}
}
@ -3431,7 +3455,7 @@ int64_t Module::incrementFileIndex() {
void Module::startReceiver() {
LOG(logDEBUG1) << "Starting Receiver";
if (shm()->useReceiverFlag) {
sendToReceiver(F_START_RECEIVER);
sendToReceiver(F_START_RECEIVER, nullptr, nullptr);
}
}
@ -3635,7 +3659,7 @@ bool Module::setReceiverSilentMode(int value) {
void Module::restreamStopFromReceiver() {
LOG(logDEBUG1) << "Restream stop dummy from Receiver via zmq";
if (shm()->useReceiverFlag) {
sendToReceiver(F_RESTREAM_STOP_FROM_RECEIVER);
sendToReceiver(F_RESTREAM_STOP_FROM_RECEIVER, nullptr, nullptr);
}
}

View File

@ -1915,6 +1915,12 @@ class Module : public virtual slsDetectorDefs {
void sendToDetector(int fnum, std::nullptr_t, Ret &retval);
void sendToDetector(int fnum);
template <typename Ret>
Ret sendToDetector(int fnum);
template <typename Ret, typename Arg>
Ret sendToDetector(int fnum, const Arg &args);
/**
* Send function parameters to detector (stop server)
* @param fnum function enum
@ -1983,9 +1989,17 @@ class Module : public virtual slsDetectorDefs {
template <typename Ret>
void sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const;
void sendToReceiver(int fnum);
template <typename Ret>
Ret sendToReceiver(int fnum);
void sendToReceiver(int fnum) const;
template <typename Ret>
Ret sendToReceiver(int fnum) const;
template <typename Ret, typename Arg>
Ret sendToReceiver(int fnum, const Arg &args);
template <typename Ret, typename Arg>
Ret sendToReceiver(int fnum, const Arg &args) const;
/**
* Get Detector Type from Shared Memory (opening shm without verifying size)

View File

@ -20,7 +20,6 @@ set(PUBLICHEADERS
include/file_utils.h
include/container_utils.h
include/string_utils.h
include/genericSocket.h
include/logger.h
include/ClientSocket.h
include/DataSocket.h

View File

@ -9,7 +9,6 @@ this might be deprecated in the future
*/
// #include "genericSocket.h"
#include "network_utils.h"
#include "sls_detector_exceptions.h"
#include <cstdint>

View File

@ -5,8 +5,8 @@
#define APIGUI 0x200227
#define APICTB 0x200310
#define APIGOTTHARD 0x200310
#define APIGOTTHARD2 0x200310
#define APIJUNGFRAU 0x200310
#define APIMYTHEN3 0x200310
#define APIMOENCH 0x200310
#define APIEIGER 0x200310
#define APIGOTTHARD2 0x200313