Compare commits

...

37 Commits

Author SHA1 Message Date
12c5844bc9 removed commented out lines 2022-04-28 11:38:07 +02:00
3db8f9957c fixed location of cmake files 2022-04-28 11:32:52 +02:00
6bad9e9f31 build only py 2022-04-28 09:30:54 +02:00
b7153fe3e0 cmake fix 2022-04-27 11:29:04 +02:00
2db2694660 m3 rxr: inconsistent generaldata default (#435)
* inconsistent copy with generalData and implementation members, especially for m3 (non default rxr generic values), issue caught on second configure with non m3 default values, eg tengiga 0

* removing test
2022-04-22 16:02:10 +02:00
e1642cf37c bugfix cmake zeromq 2022-04-19 20:11:31 +02:00
086d22f1a3 Cleaning up the find zmq (#431) 2022-04-19 17:17:31 +02:00
52882cba20 M3: polarity, interpolation, pump probe (#421)
* wip, adding m3 functions: polarity, inerpolation, pumpprobe

* added interpol, polarity, pump probe, analog pulsing, digital pulsing

* tests

* binaries in

* update release

* added python polarity enum

* fixed python and minor readability in mythen3.c

* binarie sin

* added all the m3 funcs also in list.c and enablingall counters for enabling interpolation

* binarie sin
2022-04-08 15:18:01 +02:00
27c7fd9a97 Merge pull request #423 from slsdetectorgroup/rmoldserver
copy detector server: rm old server
2022-04-08 14:56:50 +02:00
5d16ba7e16 update release 2022-04-08 11:10:15 +02:00
d8c6f9141d Fixed crash on gendoc (#430)
Fixed by checking for help action before using the detector
added test that checks that for all helps this doesn't crash
Disabled Timer tests by default since they take ~2s
2022-04-07 16:20:54 +02:00
e9dc3d8c38 minor changes (#429)
Various small changes to the data processor
2022-04-07 14:39:26 +02:00
62418c1316 sls_receiver_header* in callbacks (#425)
* char* to sls_receiver_header* in receiver data call backs

* uint32_t to size_t in callbacks

* string to const std::string & for callbacks
2022-04-07 10:19:47 +02:00
835aa575b0 remaining for removing copydetectorserver 2022-04-05 14:55:45 +02:00
b42d65c5e2 merge fix 2022-04-05 14:33:43 +02:00
150d27cf95 removed copydetectorserver 2022-04-05 14:11:04 +02:00
11bf6a5c58 update release notes 2022-04-04 15:44:34 +02:00
8bce87c082 delete old servers also for copy detector server (via tftp) 2022-04-04 15:41:58 +02:00
61f38bf5a9 clearer error message for unknown detector type when hostname error 2022-04-04 13:10:27 +02:00
cbc7066620 Merge branch 'rmoldserver' of github.com:slsdetectorgroup/slsDetectorPackage into rmoldserver 2022-04-04 12:47:19 +02:00
509ed9101f comments 2022-04-04 12:47:12 +02:00
191cfa0abe binaries in 2022-04-04 12:46:14 +02:00
f712847061 minor 2022-04-04 12:45:19 +02:00
b875a95bd5 binaries in 2022-04-04 12:44:03 +02:00
45f57ebeb7 compile, wip 2022-04-04 12:41:30 +02:00
0309eba3c6 redundant of getting abs path starting with '/' 2022-04-04 12:40:10 +02:00
f0448b3cec binaries in 2022-04-04 12:36:47 +02:00
a18af0b726 fix inittab to minimum, wip 2022-04-04 12:31:26 +02:00
6aa5cb8d3e abs path of abs path, wip 2022-04-04 12:26:02 +02:00
479906a9eb minor 2022-04-04 12:16:24 +02:00
28a503ed5a minor 2022-04-04 12:12:21 +02:00
b3c5a431d0 resolve abs path in root dir, wip 2022-04-04 11:58:36 +02:00
43cde3609a minor 2022-04-04 11:27:34 +02:00
9d2d8fe1d7 resolve for doubel slashes, wip 2022-04-04 11:17:41 +02:00
1826dd46cb minor 2022-04-04 10:57:27 +02:00
cf6423dbbe delete old servers, wip 2022-04-04 10:45:44 +02:00
8b1851e652 wip, copy server delete old name 2022-04-01 17:52:27 +02:00
55 changed files with 1300 additions and 636 deletions

View File

@ -19,6 +19,7 @@ Checks: '*,
-google-readability-braces-around-statements,
-modernize-use-trailing-return-type,
-readability-isolate-declaration,
-readability-implicit-bool-conversion,
-llvmlibc-*'
HeaderFilterRegex: \.h

View File

@ -12,6 +12,8 @@ include(cmake/project_version.cmake)
#functions to add compiler flags
include(cmake/SlsAddFlag.cmake)
include(cmake/SlsFindZeroMQ.cmake)
# Include additional modules that are used unconditionally
include(GNUInstallDirs)
@ -69,6 +71,7 @@ if(SLS_BUILD_ONLY_MOENCH)
endif()
set(ClangFormat_EXCLUDE_PATTERNS "build/"
"libs/"
"slsDetectorCalibration/"
@ -100,6 +103,7 @@ else()
endif()
#Add two fake libraries to manage options
add_library(slsProjectOptions INTERFACE)
add_library(slsProjectWarnings INTERFACE)
@ -186,42 +190,11 @@ install(TARGETS slsProjectOptions slsProjectWarnings rapidjson
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_INSTALL_RPATH $ORIGIN)
# set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
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_DIR}
)
else()
find_package(ZeroMQ 4 QUIET)
endif()
# libzmq autotools install: fallback to pkg-config
if(NOT ZeroMQ_FOUND)
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}/libzmq-pkg-config)
find_package(ZeroMQ 4 REQUIRED)
endif()
custom_find_zmq()
# 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 INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "zmq: ${VAR}")
if (SLS_USE_TESTS)
enable_testing()
@ -253,8 +226,6 @@ 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/pybind11)
add_subdirectory(python)
endif(SLS_USE_PYTHON)

View File

@ -59,6 +59,15 @@ This document describes the differences between v7.0.0 and v6.x.x
- gotthard 25 um image reconstructed in gui and virtual hdf5 (firmware updated for slave to reverse channels)
- master binary file in json format now
- fixed bug introduced in 6.0.0: hdf5 files created 1 file per frame after the initial file which had maxframesperfile
- m3 polarity, interpolation (enables all counters when enabled), pump probe, analog pulsing, digital pulsing
- updatedetectorserver - removes old server current binary pointing to for blackfin
- removing copydetectorserver using tftp
>>>>>>> developer
- registerCallBackRawDataReady and registerCallBackRawDataModifyReady now gives a sls_receiver_header* instead of a char*, and uint32_t to size_t
- registerCallBackStartAcquisition gave incorrect imagesize (+120 bytes). corrected.
- registerCallBackStartAcquisition parameter is a const string reference
- m3 (runnig config second time with tengiga 0, dr !=32, counters !=0x7) calculated incorrect image size expected
2. Resolved Issues
==================

38
cmake/SlsFindZeroMQ.cmake Normal file
View File

@ -0,0 +1,38 @@
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()

View File

@ -0,0 +1,36 @@
#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 )

View File

@ -26,7 +26,7 @@ install(FILES
)
install(FILES
"${CMAKE_SOURCE_DIR}/libzmq-pkg-config/FindZeroMQ.cmake"
"${CMAKE_SOURCE_DIR}/cmake/libzmq-pkg-config/FindZeroMQ.cmake"
COMPONENT devel
DESTINATION ${CMAKE_INSTALL_DIR}/libzmq-pkg-config
)

View File

@ -19,4 +19,4 @@ cp build/install/bin/slsMultiReceiver $PREFIX/bin/.
cp build/install/include/sls/* $PREFIX/include/sls
cp -r build/install/share/ $PREFIX/share
cp -rv build/install/share $PREFIX

View File

@ -45,6 +45,7 @@ int main() {
for (const auto &cmd : commands) {
std::ostringstream os;
std::cout << cmd << '\n';
proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os);
auto tmp = os.str().erase(0, cmd.size());

View File

@ -136,7 +136,7 @@ can use dir()
'__str__', '__subclasshook__', '_adc_register', '_frozen',
'_register', 'acquire', 'adcclk', 'adcphase', 'adcpipeline',
'adcreg', 'asamples', 'auto_comp_disable', 'clearAcquiringFlag',
'clearBit', 'clearROI', 'client_version', 'config', 'copyDetectorServer',
'clearBit', 'clearROI', 'client_version', 'config',
'counters', 'daclist', 'dacvalues', 'dbitclk', 'dbitphase' ...
Since the list for Detector is rather long it's an good idea to filter it.

View File

@ -5,17 +5,42 @@ Detector Server Upgrade
**Location:** slsDetectorPackage/serverBin/ folder for every release.
.. note ::
For Mythen3, Gotthard2 and Eiger, you need to add scripts to automatically start detector server upon power on. See :ref:`Automatic start<Automatic start servers>` for more details.
.. note ::
Eiger requires a manual reboot. Or killall the servers and restart the new linked one. If you are in the process of updating firmware, then don't reboot yet.
From 6.1.1 and above (no tftp required)
---------------------------------------
#. Program from console
.. code-block:: bash
# the following command copies new server, creates a soft link to xxxDetectorServerxxx
# [Jungfrau][CTB][Moench] also deletes the old server binary and edits initttab to respawn server on reboot
# Then, the detector controller will reboot (except Eiger)
sls_detector_put updatedetectorserver /complete-path-to-binary/xxxDetectorServerxxx
#. Copy the detector server specific config files or any others required to the detector:
.. code-block:: bash
sls_detector_put execcommand "tftp pcxxx -r configxxx -g"
5.0.0 - 6.1.1
--------------
#. Install tftp and copy detector server binary to tftp folder
#. Program from console
.. note ::
These instructions are for upgrades from v5.0.0. For earlier versions, contact us.
.. code-block:: bash
# copies new server from pc tftp folder, creates a soft link to xxxDetectorServerxxx
# the following command copies new server from pc tftp folder, creates a soft link to xxxDetectorServerxxx
# [Jungfrau][CTB][Moench] also edits initttab to respawn server on reboot
# Then, the detector controller will reboot (except Eiger)
sls_detector_put copydetectorserver xxxDetectorServerxxx pcxxx
@ -27,18 +52,15 @@ Detector Server Upgrade
sls_detector_put execcommand "tftp pcxxx -r configxxx -g"
.. note ::
For Mythen3, Gotthard2 and Eiger, you need to add scripts to automatically start detector server upon power on. See :ref:`Automatic start<Automatic start servers>` for more details.
.. note ::
Eiger requires a manual reboot. Or killall the servers and restart the new linked one. If you are in the process of updating firmware, then don't reboot yet.
Errors
------
Troubleshooting with tftp
^^^^^^^^^^^^^^^^^^^^^^^^^
#. tftp write error: There is no space left. Please delete some old binaries and try again.
#. text file busy: You are trying to copy the same server.
#. text file busy: You are trying to copy the same server.
Older than 5.0.0
-----------------
Please contact us.

View File

@ -1,27 +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_library(ZeroMQ_LIBRARY NAMES libzmq.so libzmq.dylib libzmq.dll
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS})
find_library(ZeroMQ_STATIC_LIBRARY NAMES libzmq-static.a libzmq.a libzmq.dll.a
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS})
if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY)
set(ZeroMQ_FOUND ON)
endif()
if (TARGET libzmq)
# avoid errors defining targets twice
return()
endif()
add_library(libzmq SHARED IMPORTED)
set_property(TARGET libzmq PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PC_LIBZMQ_INCLUDE_DIRS})
set_property(TARGET libzmq PROPERTY IMPORTED_LOCATION ${ZeroMQ_LIBRARY})
add_library(libzmq-static STATIC IMPORTED ${PC_LIBZMQ_INCLUDE_DIRS})
set_property(TARGET libzmq-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PC_LIBZMQ_INCLUDE_DIRS})
set_property(TARGET libzmq-static PROPERTY IMPORTED_LOCATION ${ZeroMQ_STATIC_LIBRARY})

View File

@ -1,6 +1,17 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
#if we are only building the python extension
cmake_minimum_required(VERSION 3.12)
project(slsdet)
find_package(slsDetectorPackage 6 REQUIRED)
endif()
find_package (Python 3.6 COMPONENTS Interpreter Development)
add_subdirectory(../libs/pybind11 ${CMAKE_BINARY_DIR}/bin/)
pybind11_add_module(_slsdet
src/main.cpp
src/enums.cpp

View File

@ -3498,10 +3498,60 @@ class Detector(CppDetectorApi):
def readout(self):
"""
Mythen3] Starts detector readout. Status changes to TRANSMITTING and automatically returns to idle at the end of readout.
[Mythen3] Starts detector readout. Status changes to TRANSMITTING and automatically returns to idle at the end of readout.
"""
self.startDetectorReadout()
@property
@element
def polarity(self):
"""[Mythen3] Set positive or negative polarity. Enum: polarity"""
return self.getPolarity()
@polarity.setter
def polarity(self, value):
ut.set_using_dict(self.setPolarity, value)
@property
@element
def interpolation(self):
"""[Mythen3] Enable or disable interpolation. Enabling also enables all counters """
return self.getInterpolation()
@interpolation.setter
def interpolation(self, value):
ut.set_using_dict(self.setInterpolation, value)
@property
@element
def pumpprobe(self):
"""[Mythen3] Enable or disable pump probe mode. """
return self.getPumpProbe()
@pumpprobe.setter
def pumpprobe(self, value):
ut.set_using_dict(self.setPumpProbe, value)
@property
@element
def apulse(self):
"""[Mythen3] Enable or disable analog pulsing. """
return self.getAnalogPulsing()
@apulse.setter
def apulse(self, value):
ut.set_using_dict(self.setAnalogPulsing, value)
@property
@element
def dpulse(self):
"""[Mythen3] Enable or disable digital pulsing. """
return self.getDigitalPulsing()
@dpulse.setter
def dpulse(self, value):
ut.set_using_dict(self.setDigitalPulsing, value)
"""
---------------------------<<<Debug>>>---------------------------

View File

@ -1290,6 +1290,46 @@ void init_det(py::module &m) {
.def("getGainCaps",
(Result<int>(Detector::*)(sls::Positions)) & Detector::getGainCaps,
py::arg() = Positions{})
.def("getPolarity",
(Result<defs::polarity>(Detector::*)(sls::Positions) const) &
Detector::getPolarity,
py::arg() = Positions{})
.def("setPolarity",
(void (Detector::*)(defs::polarity, sls::Positions)) &
Detector::setPolarity,
py::arg(), py::arg() = Positions{})
.def("getInterpolation",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getInterpolation,
py::arg() = Positions{})
.def("setInterpolation",
(void (Detector::*)(bool, sls::Positions)) &
Detector::setInterpolation,
py::arg(), py::arg() = Positions{})
.def("getPumpProbe",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getPumpProbe,
py::arg() = Positions{})
.def("setPumpProbe",
(void (Detector::*)(bool, sls::Positions)) &
Detector::setPumpProbe,
py::arg(), py::arg() = Positions{})
.def("getAnalogPulsing",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getAnalogPulsing,
py::arg() = Positions{})
.def("setAnalogPulsing",
(void (Detector::*)(bool, sls::Positions)) &
Detector::setAnalogPulsing,
py::arg(), py::arg() = Positions{})
.def("getDigitalPulsing",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getDigitalPulsing,
py::arg() = Positions{})
.def("setDigitalPulsing",
(void (Detector::*)(bool, sls::Positions)) &
Detector::setDigitalPulsing,
py::arg(), py::arg() = Positions{})
.def("getNumberOfAnalogSamples",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getNumberOfAnalogSamples,
@ -1551,11 +1591,6 @@ void init_det(py::module &m) {
.def("resetFPGA",
(void (Detector::*)(sls::Positions)) & Detector::resetFPGA,
py::arg() = Positions{})
.def("copyDetectorServer",
(void (Detector::*)(const std::string &, const std::string &,
sls::Positions)) &
Detector::copyDetectorServer,
py::arg(), py::arg(), py::arg() = Positions{})
.def("updateDetectorServer",
(void (Detector::*)(const std::string &, sls::Positions)) &
Detector::updateDetectorServer,

View File

@ -315,4 +315,9 @@ void init_enums(py::module &m) {
.value("FIX_G2", slsDetectorDefs::gainMode::FIX_G2)
.value("FIX_G0", slsDetectorDefs::gainMode::FIX_G0)
.export_values();
py::enum_<slsDetectorDefs::polarity>(Defs, "polarity")
.value("POSITIVE", slsDetectorDefs::polarity::POSITIVE)
.value("NEGATIVE", slsDetectorDefs::polarity::NEGATIVE)
.export_values();
}

View File

@ -10,20 +10,6 @@
#include <string.h>
/*
// Common C/C++ structure to handle pattern data
typedef struct __attribute__((packed)) {
uint64_t word[MAX_PATTERN_LENGTH];
uint64_t ioctrl;
uint32_t limits[2];
// loop0 start, loop0 stop .. loop2 start, loop2 stop
uint32_t loop[6];
uint32_t nloop[3];
uint32_t wait[3];
uint64_t waittime[3];
} patternParameters;
*/
int chipStatusRegister = 0;
int setBit(int ibit, int patword) { return patword |= (1 << ibit); }
@ -32,44 +18,6 @@ int clearBit(int ibit, int patword) { return patword &= ~(1 << ibit); }
int getChipStatusRegister() { return chipStatusRegister; }
int gainCapsToCsr(int caps) {
// Translates bit representation
int csr = 0;
if (!(caps & M3_C10pre))
csr |= 1 << _CSR_C10pre;
if (caps & M3_C15sh)
csr |= 1 << CSR_C15sh;
if (caps & M3_C30sh)
csr |= 1 << CSR_C30sh;
if (caps & M3_C50sh)
csr |= 1 << CSR_C50sh;
if (caps & M3_C225ACsh)
csr |= 1 << CSR_C225ACsh;
if (!(caps & M3_C15pre))
csr |= 1 << _CSR_C15pre;
return csr;
}
int csrToGainCaps(int csr) {
// Translates bit representation
int caps = 0;
if (!(csr & (1 << _CSR_C10pre)))
caps |= M3_C10pre;
if (csr & (1 << CSR_C15sh))
caps |= M3_C15sh;
if (csr & (1 << CSR_C30sh))
caps |= M3_C30sh;
if (csr & (1 << CSR_C50sh))
caps |= M3_C50sh;
if (csr & (1 << CSR_C225ACsh))
caps |= M3_C225ACsh;
if (!(csr & (1 << _CSR_C15pre)))
caps |= M3_C15pre;
return caps;
}
patternParameters *setChipStatusRegisterPattern(int csr) {
int iaddr = 0;
int nbits = 18;
@ -149,54 +97,116 @@ patternParameters *setChipStatusRegisterPattern(int csr) {
return pat;
}
patternParameters *setInterpolation(int mask) {
int csr;
if (mask)
csr = chipStatusRegister | (1 << CSR_interp);
else
csr = chipStatusRegister & ~(1 << CSR_interp);
int getGainCaps() {
int csr = chipStatusRegister;
// Translates bit representation
int caps = 0;
if (!(csr & (1 << _CSR_C10pre)))
caps |= M3_C10pre;
if (csr & (1 << CSR_C15sh))
caps |= M3_C15sh;
if (csr & (1 << CSR_C30sh))
caps |= M3_C30sh;
if (csr & (1 << CSR_C50sh))
caps |= M3_C50sh;
if (csr & (1 << CSR_C225ACsh))
caps |= M3_C225ACsh;
if (!(csr & (1 << _CSR_C15pre)))
caps |= M3_C15pre;
return setChipStatusRegisterPattern(csr);
return caps;
}
patternParameters *setPumpProbe(int mask) {
int csr;
if (mask)
csr = chipStatusRegister | (1 << CSR_pumprobe);
else
csr = chipStatusRegister & ~(1 << CSR_pumprobe);
int M3SetGainCaps(int caps) {
int csr = chipStatusRegister & ~GAIN_MASK;
return setChipStatusRegisterPattern(csr);
// Translates bit representation
if (!(caps & M3_C10pre))
csr |= 1 << _CSR_C10pre;
if (caps & M3_C15sh)
csr |= 1 << CSR_C15sh;
if (caps & M3_C30sh)
csr |= 1 << CSR_C30sh;
if (caps & M3_C50sh)
csr |= 1 << CSR_C50sh;
if (caps & M3_C225ACsh)
csr |= 1 << CSR_C225ACsh;
if (!(caps & M3_C15pre))
csr |= 1 << _CSR_C15pre;
return csr;
}
patternParameters *setDigitalPulsing(int mask) {
int csr;
if (mask)
csr = chipStatusRegister | (1 << CSR_dpulse);
else
csr = chipStatusRegister & ~(1 << CSR_dpulse);
return setChipStatusRegisterPattern(csr);
int getInterpolation() {
return ((chipStatusRegister & CSR_interp_MSK) >> CSR_interp);
}
patternParameters *setAnalogPulsing(int mask) {
int csr;
if (mask)
csr = chipStatusRegister | (1 << CSR_apulse);
int M3SetInterpolation(int enable) {
int csr = 0;
if (enable)
csr = chipStatusRegister | CSR_interp_MSK;
else
csr = chipStatusRegister & ~(1 << CSR_apulse);
return setChipStatusRegisterPattern(csr);
csr = chipStatusRegister & ~CSR_interp_MSK;
return csr;
}
patternParameters *setNegativePolarity(int mask) {
int csr;
if (mask)
csr = chipStatusRegister | (1 << CSR_invpol);
int getPumpProbe() {
return ((chipStatusRegister & CSR_pumprobe_MSK) >> CSR_pumprobe);
}
int M3SetPumpProbe(int enable) {
LOG(logINFO, ("%s Pump Probe\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = 0;
if (enable)
csr = chipStatusRegister | CSR_pumprobe_MSK;
else
csr = chipStatusRegister & ~(1 << CSR_invpol);
csr = chipStatusRegister & ~CSR_pumprobe_MSK;
return csr;
}
return setChipStatusRegisterPattern(csr);
int getDigitalPulsing() {
return ((chipStatusRegister & CSR_dpulse_MSK) >> CSR_dpulse);
}
int M3SetDigitalPulsing(int enable) {
LOG(logINFO,
("%s Digital Pulsing\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = 0;
if (enable)
csr = chipStatusRegister | CSR_dpulse_MSK;
else
csr = chipStatusRegister & ~CSR_dpulse_MSK;
return csr;
}
int getAnalogPulsing() {
return ((chipStatusRegister & CSR_apulse_MSK) >> CSR_apulse);
}
int M3SetAnalogPulsing(int enable) {
LOG(logINFO,
("%s Analog Pulsing\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = 0;
if (enable)
csr = chipStatusRegister | CSR_apulse_MSK;
else
csr = chipStatusRegister & ~CSR_apulse_MSK;
return csr;
}
int getNegativePolarity() {
return ((chipStatusRegister & CSR_invpol_MSK) >> CSR_invpol);
}
int M3SetNegativePolarity(int enable) {
LOG(logINFO,
("%s Negative Polarity\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = 0;
if (enable)
csr = chipStatusRegister | CSR_invpol_MSK;
else
csr = chipStatusRegister & ~CSR_invpol_MSK;
return csr;
}
patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits) {

View File

@ -49,6 +49,12 @@
// shaper)
#define _CSR_C15pre 14 // negative polarity
#define CSR_invpol_MSK (0x1 << CSR_invpol)
#define CSR_dpulse_MSK (0x1 << CSR_dpulse)
#define CSR_interp_MSK (0x1 << CSR_interp)
#define CSR_pumprobe_MSK (0x1 << CSR_pumprobe)
#define CSR_apulse_MSK (0x1 << CSR_apulse)
#define CSR_default (1 << _CSR_C10pre) | (1 << CSR_C30sh)
#define GAIN_MASK \
@ -58,15 +64,20 @@
int setBit(int ibit, int patword);
int clearBit(int ibit, int patword);
int getChipStatusRegister();
int gainCapsToCsr(int caps);
int csrToGainCaps(int csr);
patternParameters *setChipStatusRegisterPattern(int csr);
patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits);
patternParameters *setInterpolation(int mask);
patternParameters *setPumpProbe(int mask);
patternParameters *setDigitalPulsing(int mask);
patternParameters *setAnalogPulsing(int mask);
patternParameters *setNegativePolarity(int mask);
int getGainCaps();
int M3SetGainCaps(int caps);
int getInterpolation();
int M3SetInterpolation(int enable);
int getPumpProbe();
int M3SetPumpProbe(int enable);
int getDigitalPulsing();
int M3SetDigitalPulsing(int enable);
int getAnalogPulsing();
int M3SetAnalogPulsing(int enable);
int getNegativePolarity();
int M3SetNegativePolarity(int enable);
#endif

View File

@ -1689,6 +1689,55 @@ void setInitialExtSignals() {
DOUTIF_RISING_LNGTH_PORT_1_MSK));
}
int setGainCaps(int caps) {
LOG(logINFO, ("Setting gain caps to: %u\n", caps));
int csr = M3SetGainCaps(caps);
return setChipStatusRegister(csr);
}
int setInterpolation(int enable) {
LOG(logINFO,
("%s Interpolation\n", enable == 0 ? "Disabling" : "Enabling"));
if (enable) {
setCounterMask(MAX_COUNTER_MSK);
if (getCounterMask() != MAX_COUNTER_MSK) {
LOG(logERROR,
("Could not set interpolation. Could not enable all counters"));
return FAIL;
}
LOG(logINFO, ("\tEnabled all counters\n"));
}
int csr = M3SetInterpolation(enable);
return setChipStatusRegister(csr);
}
int setPumpProbe(int enable) {
LOG(logINFO, ("%s Pump Probe\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = M3SetPumpProbe(enable);
return setChipStatusRegister(csr);
}
int setDigitalPulsing(int enable) {
LOG(logINFO,
("%s Digital Pulsing\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = M3SetDigitalPulsing(enable);
return setChipStatusRegister(csr);
}
int setAnalogPulsing(int enable) {
LOG(logINFO,
("%s Analog Pulsing\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = M3SetAnalogPulsing(enable);
return setChipStatusRegister(csr);
}
int setNegativePolarity(int enable) {
LOG(logINFO,
("%s Negative Polarity\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = M3SetNegativePolarity(enable);
return setChipStatusRegister(csr);
}
void setExtSignal(int signalIndex, enum externalSignalFlag mode) {
LOG(logDEBUG1, ("Setting signal flag[%d] to %d\n", signalIndex, mode));
@ -2623,21 +2672,3 @@ int setChipStatusRegister(int csr) {
return iret;
}
int setGainCaps(int caps) {
LOG(logINFO, ("Setting gain caps to: %u\n", caps));
// Update only gain caps, leave the rest of the CSR unchanged
int csr = getChipStatusRegister();
csr &= ~GAIN_MASK;
caps = gainCapsToCsr(caps);
// caps &= GAIN_MASK;
csr |= caps;
return setChipStatusRegister(csr);
}
int getGainCaps() {
int csr = getChipStatusRegister();
int caps = csrToGainCaps(csr);
return caps;
}

View File

@ -66,3 +66,5 @@ int moveBinaryFile(char *mess, char *dest, char *src, char *errorPrefix);
int createEmptyFile(char *mess, char *fname, char *errorPrefix);
int deleteFile(char *mess, char *fname, char *errorPrefix);
int deleteOldServers(char *mess, char *newServerPath, char *errorPrefix);

View File

@ -376,7 +376,7 @@ int setHighVoltage(int val);
// parameters - timing, extsig
#ifdef EIGERD
int setMaster(enum MASTERINDEX m);
int setTop(enum TOPINDEX t);
int setTop(enum TOPINDEX t);
int isTop(int *retval);
#endif
#if defined(MYTHEN3D) || defined(EIGERD) || defined(GOTTHARDD) || \
@ -391,9 +391,13 @@ void setTiming(enum timingMode arg);
enum timingMode getTiming();
#ifdef MYTHEN3D
void setInitialExtSignals();
int setGainCaps(int caps);
int getGainCaps();
int setChipStatusRegister(int csr);
int setGainCaps(int caps);
int setInterpolation(int enable);
int setPumpProbe(int enable);
int setDigitalPulsing(int enable);
int setAnalogPulsing(int enable);
int setNegativePolarity(int enable);
int setDACS(int *dacs);
#endif
#if defined(GOTTHARDD) || defined(MYTHEN3D)

View File

@ -132,7 +132,6 @@ int check_version(int);
int software_trigger(int);
int led(int);
int digital_io_delay(int);
int copy_detector_server(int);
int reboot_controller(int);
int set_adc_enable_mask(int);
int get_adc_enable_mask(int);
@ -293,4 +292,14 @@ void receive_program_default(int file_des, enum PROGRAM_INDEX index,
int get_update_mode(int);
int set_update_mode(int);
int get_top(int);
int set_top(int);
int set_top(int);
int get_polarity(int);
int set_polarity(int);
int get_interpolation(int);
int set_interpolation(int);
int get_pump_probe(int);
int set_pump_probe(int);
int get_analog_pulsing(int);
int set_analog_pulsing(int);
int get_digital_pulsing(int);
int set_digital_pulsing(int);

View File

@ -50,6 +50,10 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
}
int getAbsPath(char *buf, size_t bufSize, char *fname) {
if (fname[0] == '/') {
strcpy(buf, fname);
return OK;
}
// get path of current binary
char path[bufSize];
memset(path, 0, bufSize);
@ -60,10 +64,14 @@ int getAbsPath(char *buf, size_t bufSize, char *fname) {
}
path[len] = '\0';
// get dir path and attach config file name
// get dir path and attach file name
char *dir = dirname(path);
memset(buf, 0, bufSize);
sprintf(buf, "%s/%s", dir, fname);
if (!strcmp(dir, "/")) {
sprintf(buf, "/%s", fname);
} else {
sprintf(buf, "%s/%s", dir, fname);
}
LOG(logDEBUG1, ("full path for %s: %s\n", fname, buf));
return OK;
}
@ -466,7 +474,7 @@ int setupDetectorServer(char *mess, char *sname) {
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tSymbolic link created\n"));
LOG(logINFO, ("\tSymbolic link created %s -> %s\n", linkname, sname));
// blackfin boards (respawn) (only kept for backwards compatibility)
#ifndef VIRTUAL
@ -485,7 +493,7 @@ int setupDetectorServer(char *mess, char *sname) {
// add new link name to /etc/inittab
if (snprintf(cmd, MAX_STR_LENGTH,
"echo 'ttyS0::respawn:/./%s' >> /etc/inittab",
"echo 'ttyS0::respawn:%s' >> /etc/inittab",
linkname) >= MAX_STR_LENGTH) {
strcpy(mess, "Could not copy detector server. Command "
"to add new server for spawning is too long\n");
@ -670,3 +678,26 @@ int deleteFile(char *mess, char *fname, char *errorPrefix) {
}
return OK;
}
int deleteOldServers(char *mess, char *newServerPath, char *errorPrefix) {
LOG(logINFO, ("\tChecking if current binary is to be deleted ...\n"))
// get path of current binary (get file name if link)
char currentBinary[MAX_STR_LENGTH];
memset(currentBinary, 0, MAX_STR_LENGTH);
ssize_t len = readlink("/proc/self/exe", currentBinary, MAX_STR_LENGTH - 1);
if (len < 0) {
LOG(logWARNING, ("(%s): Could not delete old servers. Could not "
"readlink current binary\n",
errorPrefix));
return FAIL;
}
currentBinary[len] = '\0';
LOG(logDEBUG1, ("Current binary:%s\n", currentBinary));
// delete file
if (deleteFile(mess, currentBinary, errorPrefix) == FAIL) {
LOG(logWARNING, ("(%s). Could not delete old servers\n", errorPrefix));
return FAIL;
}
return OK;
}

View File

@ -93,7 +93,6 @@ int updateModeAllowedFunction(int file_des) {
F_PROGRAM_FPGA,
F_RESET_FPGA,
F_CHECK_VERSION,
F_COPY_DET_SERVER,
F_REBOOT_CONTROLLER,
F_GET_KERNEL_VERSION,
F_UPDATE_KERNEL,
@ -322,7 +321,6 @@ void function_table() {
flist[F_SOFTWARE_TRIGGER] = &software_trigger;
flist[F_LED] = &led;
flist[F_DIGITAL_IO_DELAY] = &digital_io_delay;
flist[F_COPY_DET_SERVER] = &copy_detector_server;
flist[F_REBOOT_CONTROLLER] = &reboot_controller;
flist[F_SET_ADC_ENABLE_MASK] = &set_adc_enable_mask;
flist[F_GET_ADC_ENABLE_MASK] = &get_adc_enable_mask;
@ -472,6 +470,16 @@ void function_table() {
flist[F_SET_MASTER] = &set_master;
flist[F_GET_TOP] = &get_top;
flist[F_SET_TOP] = &set_top;
flist[F_GET_POLARITY] = &get_polarity;
flist[F_SET_POLARITY] = &set_polarity;
flist[F_GET_INTERPOLATION] = &get_interpolation;
flist[F_SET_INTERPOLATION] = &set_interpolation;
flist[F_GET_PUMP_PROBE] = &get_pump_probe;
flist[F_SET_PUMP_PROBE] = &set_pump_probe;
flist[F_GET_ANALOG_PULSING] = &get_analog_pulsing;
flist[F_SET_ANALOG_PULSING] = &set_analog_pulsing;
flist[F_GET_DIGITAL_PULSING] = &get_digital_pulsing;
flist[F_SET_DIGITAL_PULSING] = &set_digital_pulsing;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -4143,65 +4151,15 @@ int digital_io_delay(int file_des) {
return Server_SendResult(file_des, INT32, NULL, 0);
}
int copy_detector_server(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
char args[2][MAX_STR_LENGTH];
char retvals[MAX_STR_LENGTH] = {0};
memset(args, 0, sizeof(args));
memset(retvals, 0, sizeof(retvals));
if (receiveData(file_des, args, sizeof(args), OTHER) < 0)
return printSocketReadError();
#ifdef VIRTUAL
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
char *sname = args[0];
char *hostname = args[1];
LOG(logINFOBLUE, ("Copying server %s from host %s\n", sname, hostname));
char cmd[MAX_STR_LENGTH] = {0};
#ifdef BLACKFIN_DEFINED
// check update is allowed (Non Amd OR AMD + current kernel)
ret = allowUpdate(mess, "copy detector server");
#endif
// tftp server
if (ret == OK) {
if (snprintf(cmd, MAX_STR_LENGTH, "tftp %s -r %s -g", hostname,
sname) >= MAX_STR_LENGTH) {
ret = FAIL;
strcpy(mess, "Could not copy detector server. Command to copy "
"server too long\n");
LOG(logERROR, (mess));
} else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
ret = FAIL;
snprintf(mess, MAX_STR_LENGTH,
"Could not copy detector server (tftp). %s\n",
retvals);
// LOG(logERROR, (mess)); already printed in executecommand
} else {
LOG(logINFO, ("\tServer copied\n"));
}
}
if (ret == OK) {
ret = setupDetectorServer(mess, sname);
}
}
#endif
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
}
int reboot_controller(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
#ifdef EIGERD
functionNotImplemented();
#elif VIRTUAL
ret = GOODBYE;
#elif defined(MYTHEN3D) || defined(GOTTHARD2D)
if (getHardwareVersionNumber() == 0) {
ret = FAIL;
strcpy(mess, "Old board version, reboot by yourself please!\n");
@ -4209,20 +4167,11 @@ int reboot_controller(int file_des) {
Server_SendResult(file_des, INT32, NULL, 0);
return GOODBYE;
}
#ifdef VIRTUAL
ret = GOODBYE;
ret = REBOOT;
#else
ret = REBOOT;
#endif
#elif EIGERD
functionNotImplemented();
#else
#ifdef VIRTUAL
ret = GOODBYE;
#else
ret = REBOOT;
#endif
#endif
Server_SendResult(file_des, INT32, NULL, 0);
return ret;
}
@ -8297,33 +8246,35 @@ int set_gain_caps(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting gain caps to: %u\n", arg));
int retval = -1;
#ifndef MYTHEN3D
functionNotImplemented();
#else
if (Server_VerifyLock() == OK) {
setGainCaps(arg);
retval = getChipStatusRegister(); // TODO! fix
LOG(logDEBUG1, ("gain caps retval: %u\n", retval));
ret = setGainCaps(arg);
if (ret == FAIL) {
strcpy(mess, "Could not set gain caps.\n");
LOG(logERROR, (mess));
} else {
int retval = getGainCaps();
validate(&ret, mess, (int)arg, (int)retval, "set gain caps", DEC);
LOG(logDEBUG1, ("gain caps retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_gain_caps(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logINFO, ("Getting gain caps\n"));
LOG(logDEBUG1, ("Getting gain caps\n"));
#ifndef MYTHEN3D
functionNotImplemented();
#else
if (Server_VerifyLock() == OK) {
retval = getGainCaps();
LOG(logDEBUG1, ("Gain caps: %u\n", retval));
}
retval = getGainCaps();
LOG(logDEBUG1, ("Gain caps: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
@ -9449,10 +9400,18 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
if (receiveData(file_des, &forceDeleteNormalFile,
sizeof(forceDeleteNormalFile), INT32) < 0)
return printSocketReadError();
LOG(logINFO,
("\tForce Delete Normal File flag? %s\n", (forceDeleteNormalFile ? "Y" : "N")));
LOG(logINFO, ("\tForce Delete Normal File flag? %s\n",
(forceDeleteNormalFile ? "Y" : "N")));
#endif
// ensure the name is not the same as the linked name
if (!strcmp(serverName, LINKED_SERVER_NAME)) {
ret = FAIL;
strcpy(mess, "Server name is the same as the symbolic link. Please "
"use a different server name\n");
LOG(logERROR, (mess));
}
// in same folder as current process (will also work for virtual then
// with write permissions)
{
@ -9477,7 +9436,8 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
checksum, serverName);
#else
receive_program_via_blackfin(file_des, index, functionType,
filesize, checksum, serverName, forceDeleteNormalFile);
filesize, checksum, serverName,
forceDeleteNormalFile);
#endif
}
@ -9493,7 +9453,8 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
char *functionType, uint64_t filesize,
char *checksum, char *serverName, int forceDeleteNormalFile) {
char *checksum, char *serverName,
int forceDeleteNormalFile) {
#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && \
!defined(GOTTHARDD)
@ -9595,6 +9556,8 @@ void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
totalsize, forceDeleteNormalFile);
break;
case PROGRAM_SERVER:
// a fail here is not a show stopper (just for memory)
deleteOldServers(mess, serverName, "update detector server");
ret = moveBinaryFile(mess, serverName, TEMP_PROG_FILE_NAME,
"update detector server");
if (ret == OK) {
@ -9821,4 +9784,246 @@ int set_top(int file_des) {
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_polarity(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum polarity retval = POSITIVE;
LOG(logDEBUG1, ("Getting negativepolarity\n"));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// get only
retval = getNegativePolarity() ? NEGATIVE : POSITIVE;
LOG(logDEBUG1, ("negative polarity retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_polarity(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum polarity arg = POSITIVE;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logDEBUG1, ("Setting negative polarity: %u\n", (int)arg));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
switch (arg) {
case POSITIVE:
ret = setNegativePolarity(0);
break;
case NEGATIVE:
ret = setNegativePolarity(1);
break;
default:
modeNotImplemented("Polarity index", (int)arg);
break;
}
if (ret == FAIL) {
sprintf(mess, "Could not set polarity\n");
LOG(logERROR, (mess));
} else {
enum polarity retval = getNegativePolarity() ? NEGATIVE : POSITIVE;
validate(&ret, mess, (int)arg, (int)retval, "set polarity", DEC);
LOG(logDEBUG1, ("negative polarity retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_interpolation(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logDEBUG1, ("Getting interpolation\n"));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// get only
retval = getInterpolation();
LOG(logDEBUG1, ("interpolation retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_interpolation(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logINFO, ("Setting interpolation: %u\n", arg));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
ret = setInterpolation(arg);
if (ret == FAIL) {
if (arg)
sprintf(mess, "Could not set interpolation or enable all "
"counters for it.\n");
else
sprintf(mess, "Could not set interpolation\n");
LOG(logERROR, (mess));
} else {
int retval = getInterpolation();
validate(&ret, mess, (int)arg, (int)retval, "set interpolation",
DEC);
LOG(logDEBUG1, ("interpolation retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_pump_probe(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logDEBUG1, ("Getting pump probe\n"));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// get only
retval = getPumpProbe();
LOG(logDEBUG1, ("pump probe retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_pump_probe(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logINFO, ("Setting pump probe: %u\n", arg));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
ret = setPumpProbe(arg);
if (ret == FAIL) {
sprintf(mess, "Could not set pump probe\n");
LOG(logERROR, (mess));
} else {
int retval = getPumpProbe();
validate(&ret, mess, (int)arg, (int)retval, "set pump probe", DEC);
LOG(logDEBUG1, ("pump probe retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_analog_pulsing(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logDEBUG1, ("Getting analog pulsing\n"));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// get only
retval = getAnalogPulsing();
LOG(logDEBUG1, ("analog pulsing retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_analog_pulsing(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logINFO, ("Setting analog pulsing: %u\n", arg));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
ret = setAnalogPulsing(arg);
if (ret == FAIL) {
sprintf(mess, "Could not set analog pulsing\n");
LOG(logERROR, (mess));
} else {
int retval = getAnalogPulsing();
validate(&ret, mess, (int)arg, (int)retval, "set analog pulsing",
DEC);
LOG(logDEBUG1, ("analog pulsing retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_digital_pulsing(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logDEBUG1, ("Getting digital pulsing\n"));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// get only
retval = getDigitalPulsing();
LOG(logDEBUG1, ("digital pulsing retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_digital_pulsing(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logINFO, ("Setting digital pulsing: %u\n", arg));
#ifndef MYTHEN3D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
ret = setDigitalPulsing(arg);
if (ret == FAIL) {
sprintf(mess, "Could not set digital pulsing\n");
LOG(logERROR, (mess));
} else {
int retval = getDigitalPulsing();
validate(&ret, mess, (int)arg, (int)retval, "set digital pulsing",
DEC);
LOG(logDEBUG1, ("digital pulsing retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}

View File

@ -1472,6 +1472,36 @@ class Detector {
Result<int> getGainCaps(Positions pos = {});
/** [Mythen3] */
Result<defs::polarity> getPolarity(Positions pos = {}) const;
/** [Mythen3] */
void setPolarity(defs::polarity value, Positions pos = {});
/** [Mythen3] */
Result<bool> getInterpolation(Positions pos = {}) const;
/** [Mythen3] Also enables all counters */
void setInterpolation(bool value, Positions pos = {});
/** [Mythen3] */
Result<bool> getPumpProbe(Positions pos = {}) const;
/** [Mythen3] */
void setPumpProbe(bool value, Positions pos = {});
/** [Mythen3] */
Result<bool> getAnalogPulsing(Positions pos = {}) const;
/** [Mythen3] */
void setAnalogPulsing(bool value, Positions pos = {});
/** [Mythen3] */
Result<bool> getDigitalPulsing(Positions pos = {}) const;
/** [Mythen3] */
void setDigitalPulsing(bool value, Positions pos = {});
///@}
/** @name CTB / Moench Specific */
@ -1614,12 +1644,11 @@ class Detector {
/** [CTB] Default is enabled. */
void setLEDEnable(bool enable, Positions pos = {});
void setDacNames(const std::vector<std::string> names);
std::vector<std::string> getDacNames() const;
defs::dacIndex getDacIndex(const std::string& name);
defs::dacIndex getDacIndex(const std::string &name);
std::string getDacName(defs::dacIndex i);
///@}
@ -1766,23 +1795,11 @@ class Detector {
/** [Jungfrau][CTB][Moench] Advanced user Function! */
void resetFPGA(Positions pos = {});
/** [[deprecated ("Replaced by updateDetectorServer, which does not require
* tftp")]] [Jungfrau][Eiger][Gotthard][CTB][Moench][Mythen3][Gotthard2]
* Advanced user Function! \n
* Copy detector server fname from tftp folder of hostname to detector. Also
* creates a symbolic link to a shorter name (without vx.x.x). Then the
* detector controller reboots (except eiger) \n
* [Jungfrau][Gotthard][CTB][Moench] Also changes respawn server (to the
* link), which is effective after a reboot.
*/
void copyDetectorServer(const std::string &fname,
const std::string &hostname, Positions pos = {});
/** [Jungfrau][Eiger][Ctb][Moench][Mythen3][Gotthard2] Copies detector
* server via TCP (without tftp).\nMakes a symbolic link with a shorter
* name (without vx.x.x).\nThen, detector controller reboots (except
* Eiger).\n[Jungfrau][Ctb][Moench]Also changes respawn server to the
* link, which is effective after a reboot.
* Eiger).\n[Jungfrau][Ctb][Moench] Also deletes old server binary and
* changes respawn server to the link, which is effective after a reboot.
*/
void updateDetectorServer(const std::string &fname, Positions pos = {});
@ -1797,19 +1814,6 @@ class Detector {
* Function! */
void rebootController(Positions pos = {});
/** [[deprecated ("Replaced by overloaded updateDetectorServer, which does
* not require tftp and has one less argument")]] Advanced user Function!\n
* [Jungfrau][Gotthard][CTB][Moench] Updates the firmware, detector server,
* make a soft link and then reboots detector controller. \n
* [Mythen3][Gotthard2] Will require a script to start up the shorter named
* server link at start up \n sname is name of detector server binary found
* on tftp folder of host pc \n hostname is name of pc to tftp from \n fname
* is programming file name with full path to it
*/
void updateFirmwareAndServer(const std::string &sname,
const std::string &hostname,
const std::string &fname, Positions pos = {});
/**
* Advanced user Function!\n [Jungfrau][Gotthard][CTB][Moench] Updates the
* firmware, detector server, make a soft link and then reboots detector

View File

@ -1056,7 +1056,18 @@ std::string CmdProxy::TemperatureValues(int action) {
std::string CmdProxy::Dac(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (args.size() == 0) {
os << GetHelpDac(std::to_string(0)) << '\n';
} else {
os << args[0] << ' ' << GetHelpDac(args[0]) << '\n';
}
return os.str();
}
auto type = det->getDetectorType().squash();
// dac indices only for ctb
if (args.size() > 0 && action != defs::HELP_ACTION) {
if (is_int(args[0]) && type != defs::CHIPTESTBOARD) {
@ -1066,13 +1077,7 @@ std::string CmdProxy::Dac(int action) {
}
}
if (action == defs::HELP_ACTION) {
if (args.size() == 0) {
os << GetHelpDac(std::to_string(0)) << '\n';
} else {
os << args[0] << ' ' << GetHelpDac(args[0]) << '\n';
}
} else if (action == defs::GET_ACTION) {
if (action == defs::GET_ACTION) {
if (args.empty())
WrongNumberOfParameters(1); // This prints slightly wrong
@ -2911,35 +2916,6 @@ std::string CmdProxy::ProgramFpga(int action) {
return os.str();
}
std::string CmdProxy::CopyDetectorServer(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
LOG(logWARNING) << "Deprecated! Replaced by updatedetectorserver that "
"requires no tftp.\n";
os << "[server_name (in tftp folder)] "
"[pc_host_name]\n\t[Jungfrau][Eiger][Ctb][Moench][Mythen3]["
"Gotthard2] Copies detector server via TFTP from pc. Ensure that "
"server is in the pc's tftp folder. Makes a symbolic link with a "
"shorter name (without vx.x.x). Then, detector controller "
"reboots (except "
"Eiger).\n\t[Jungfrau][Ctb][Moench]Also changes respawn server "
"to the link, which is effective after a reboot."
<< '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
} else if (action == defs::PUT_ACTION) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
det->copyDetectorServer(args[0], args[1], std::vector<int>{det_id});
os << "successful\n";
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::UpdateDetectorServer(int action) {
std::ostringstream os;
os << cmd << ' ';
@ -2996,23 +2972,21 @@ std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "\n\tUsing tftp: Deprecated!! [server_name"
" (in tftp folder)] [pc_host_name] [fname.pof (incl full path)]"
"\n\tWithout tftp: Recommended [server_name (incl fullpath)] "
os << "\n\tWithout tftp: [server_name (incl fullpath)] "
"[fname.pof (incl full path)] "
"This does not use tftp."
"\n\t\t[Jungfrau][Gotthard][CTB][Moench] Updates the "
"firmware, detector server, creates the symbolic link and then "
"firmware, detector server, deletes old server, creates the symbolic link and then "
"reboots detector controller. \n\t\t[Mythen3][Gotthard2] will "
"require a script to start up the shorter named server link at "
"start up. \n\t\tsname is full path name of detector server "
"start up. \n\t\tserver_name is full path name of detector server "
"binary"
"\n\t\tfname is full path of programming file"
<< '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
} else if (action == defs::PUT_ACTION) {
if (args.size() != 3 && args.size() != 2) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
@ -3021,17 +2995,8 @@ std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
args[fpos].find(".rbf") == std::string::npos) {
throw sls::RuntimeError("Programming file must be a pof/rbf file.");
}
if (args.size() == 3) {
LOG(logWARNING)
<< "Deprecated! Recommend to use same command without tftp (no "
"pc name) and using full path to the server binary";
det->updateFirmwareAndServer(args[0], args[1], args[2],
det->updateFirmwareAndServer(args[0], args[1],
std::vector<int>{det_id});
} else {
det->updateFirmwareAndServer(args[0], args[1],
std::vector<int>{det_id});
}
os << "successful\n";
} else {
throw sls::RuntimeError("Unknown action");

View File

@ -743,7 +743,11 @@ class CmdProxy {
/* Pattern */
/* Moench */
/* Advanced */
{"copydetectorserver", "updatedetectorserver"},
/* Insignificant */
{"nframes", "framecounter"},
{"now", "runtime"},
@ -992,6 +996,11 @@ class CmdProxy {
{"gatedelay2", &CmdProxy::GateDelay},
{"gatedelay3", &CmdProxy::GateDelay},
{"gaincaps", &CmdProxy::GainCaps},
{"polarity", &CmdProxy::polarity},
{"interpolation", &CmdProxy::interpolation},
{"pumpprobe", &CmdProxy::pumpprobe},
{"apulse", &CmdProxy::apulse},
{"dpulse", &CmdProxy::dpulse},
/* CTB/ Moench Specific */
{"samples", &CmdProxy::Samples},
@ -1062,7 +1071,6 @@ class CmdProxy {
/* Advanced */
{"programfpga", &CmdProxy::ProgramFpga},
{"resetfpga", &CmdProxy::resetfpga},
{"copydetectorserver", &CmdProxy::CopyDetectorServer},
{"updatedetectorserver", &CmdProxy::UpdateDetectorServer},
{"updatekernel", &CmdProxy::UpdateKernel},
{"rebootcontroller", &CmdProxy::rebootcontroller},
@ -1189,7 +1197,6 @@ class CmdProxy {
std::string JsonParameter(int action);
/* Advanced */
std::string ProgramFpga(int action);
std::string CopyDetectorServer(int action);
std::string UpdateDetectorServer(int action);
std::string UpdateKernel(int action);
std::string UpdateFirmwareAndDetectorServer(int action);
@ -2032,6 +2039,31 @@ class CmdProxy {
"[n_gates]\n\t[Mythen3] Number of external gates in gating "
"or trigger_gating mode (external gating).");
INTEGER_COMMAND_VEC_ID(polarity, getPolarity, setPolarity,
StringTo<defs::polarity>,
"[pos|neg]\n\t[Mythen3] Sets negative or positive "
"polarity. Default is positive");
INTEGER_COMMAND_VEC_ID(interpolation, getInterpolation, setInterpolation,
StringTo<int>,
"[0, 1]\n\t[Mythen3] Enables or disables "
"interpolation. Default is disabled. Enabling also "
"enables all counters. ");
INTEGER_COMMAND_VEC_ID(pumpprobe, getPumpProbe, setPumpProbe, StringTo<int>,
"[0, 1]\n\t[Mythen3] Enables or disables pump probe "
"mode. Default is disabled");
INTEGER_COMMAND_VEC_ID(apulse, getAnalogPulsing, setAnalogPulsing,
StringTo<int>,
"[0, 1]\n\t[Mythen3] Enables or disables analog "
"pulsing. Default is disabled");
INTEGER_COMMAND_VEC_ID(dpulse, getDigitalPulsing, setDigitalPulsing,
StringTo<int>,
"[0, 1]\n\t[Mythen3] Enables or disables digital "
"pulsing. Default is disabled");
/* CTB/ Moench Specific */
INTEGER_COMMAND_VEC_ID(

View File

@ -5,9 +5,9 @@
#include "CmdParser.h"
#include "CmdProxy.h"
#include "CtbConfig.h"
#include "DetectorImpl.h"
#include "Module.h"
#include "CtbConfig.h"
#include "sls/Pattern.h"
#include "sls/container_utils.h"
#include "sls/file_utils.h"
@ -1875,6 +1875,46 @@ Result<int> Detector::getGainCaps(Positions pos) {
return pimpl->Parallel(&Module::getGainCaps, pos);
}
Result<defs::polarity> Detector::getPolarity(Positions pos) const {
return pimpl->Parallel(&Module::getPolarity, pos);
}
void Detector::setPolarity(defs::polarity value, Positions pos) {
pimpl->Parallel(&Module::setPolarity, pos, value);
}
Result<bool> Detector::getInterpolation(Positions pos) const {
return pimpl->Parallel(&Module::getInterpolation, pos);
}
void Detector::setInterpolation(bool value, Positions pos) {
pimpl->Parallel(&Module::setInterpolation, pos, value);
}
Result<bool> Detector::getPumpProbe(Positions pos) const {
return pimpl->Parallel(&Module::getPumpProbe, pos);
}
void Detector::setPumpProbe(bool value, Positions pos) {
pimpl->Parallel(&Module::setPumpProbe, pos, value);
}
Result<bool> Detector::getAnalogPulsing(Positions pos) const {
return pimpl->Parallel(&Module::getAnalogPulsing, pos);
}
void Detector::setAnalogPulsing(bool value, Positions pos) {
pimpl->Parallel(&Module::setAnalogPulsing, pos, value);
}
Result<bool> Detector::getDigitalPulsing(Positions pos) const {
return pimpl->Parallel(&Module::getDigitalPulsing, pos);
}
void Detector::setDigitalPulsing(bool value, Positions pos) {
pimpl->Parallel(&Module::setDigitalPulsing, pos, value);
}
// CTB/ Moench Specific
Result<int> Detector::getNumberOfAnalogSamples(Positions pos) const {
@ -2242,15 +2282,6 @@ void Detector::resetFPGA(Positions pos) {
pimpl->Parallel(&Module::resetFPGA, pos);
}
void Detector::copyDetectorServer(const std::string &fname,
const std::string &hostname, Positions pos) {
LOG(logINFO) << "Updating Detector Server (via tftp)...";
pimpl->Parallel(&Module::copyDetectorServer, pos, fname, hostname);
if (getDetectorType().squash() != defs::EIGER) {
rebootController(pos);
}
}
void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
LOG(logINFO) << "Updating Detector Server (no tftp)...";
std::vector<char> buffer = readBinaryFile(fname, "Update Detector Server");
@ -2272,16 +2303,6 @@ void Detector::rebootController(Positions pos) {
pimpl->Parallel(&Module::rebootController, pos);
}
void Detector::updateFirmwareAndServer(const std::string &sname,
const std::string &hostname,
const std::string &fname,
Positions pos) {
LOG(logINFO) << "Updating Firmware and Detector Server (with tftp)...";
LOG(logINFO) << "Updating Detector Server (via tftp)...";
pimpl->Parallel(&Module::copyDetectorServer, pos, sname, hostname);
programFPGA(fname, false, pos);
}
void Detector::updateFirmwareAndServer(const std::string &sname,
const std::string &fname,
Positions pos) {

View File

@ -1288,8 +1288,13 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
throw RuntimeError("Programming file must be an rbf file.");
}
break;
default:
case EIGER:
case GOTTHARD:
throw RuntimeError("programfpga not implemented for this detector");
default:
throw RuntimeError(
"Unknown detector type. Did the 'hostname' command execute "
"successfully? Or use update mode in the detector server side.");
}
LOG(logINFO) << "This can take awhile. Please be patient.";

View File

@ -2256,11 +2256,52 @@ int Module::getChipStatusRegister() const {
}
void Module::setGainCaps(int caps) {
sendToDetector<int>(F_SET_GAIN_CAPS, caps);
sendToDetector(F_SET_GAIN_CAPS, caps, nullptr);
}
int Module::getGainCaps() { return sendToDetector<int>(F_GET_GAIN_CAPS); }
defs::polarity Module::getPolarity() const {
return sendToDetector<defs::polarity>(F_GET_POLARITY);
}
void Module::setPolarity(const defs::polarity value) {
sendToDetector(F_SET_POLARITY, static_cast<int>(value), nullptr);
}
bool Module::getInterpolation() const {
return sendToDetector<int>(F_GET_INTERPOLATION);
}
void Module::setInterpolation(const bool enable) {
sendToDetector(F_SET_INTERPOLATION, static_cast<int>(enable), nullptr);
setCounterMask(getCounterMask());
}
bool Module::getPumpProbe() const {
return sendToDetector<int>(F_GET_PUMP_PROBE);
}
void Module::setPumpProbe(const bool enable) {
sendToDetector(F_SET_PUMP_PROBE, static_cast<int>(enable), nullptr);
}
bool Module::getAnalogPulsing() const {
return sendToDetector<int>(F_GET_ANALOG_PULSING);
}
void Module::setAnalogPulsing(const bool enable) {
sendToDetector(F_SET_ANALOG_PULSING, static_cast<int>(enable), nullptr);
}
bool Module::getDigitalPulsing() const {
return sendToDetector<int>(F_GET_DIGITAL_PULSING);
}
void Module::setDigitalPulsing(const bool enable) {
sendToDetector(F_SET_DIGITAL_PULSING, static_cast<int>(enable), nullptr);
}
// CTB / Moench Specific
int Module::getNumberOfAnalogSamples() const {
return sendToDetector<int>(F_GET_NUM_ANALOG_SAMPLES);
@ -2611,28 +2652,6 @@ void Module::programFPGA(std::vector<char> buffer,
void Module::resetFPGA() { sendToDetector(F_RESET_FPGA); }
void Module::copyDetectorServer(const std::string &fname,
const std::string &hostname) {
char args[2][MAX_STR_LENGTH]{};
sls::strcpy_safe(args[0], fname.c_str());
sls::strcpy_safe(args[1], hostname.c_str());
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): Sending detector server " << args[0] << " from host "
<< args[1];
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_COPY_DET_SERVER);
client.Send(args);
if (client.Receive<int>() == FAIL) {
std::cout << '\n';
std::ostringstream os;
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw DetectorError(os.str());
}
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): Detector server copied";
}
void Module::updateDetectorServer(std::vector<char> buffer,
const std::string &serverName) {
switch (shm()->detType) {

View File

@ -466,6 +466,16 @@ class Module : public virtual slsDetectorDefs {
int getChipStatusRegister() const;
void setGainCaps(int caps);
int getGainCaps();
defs::polarity getPolarity() const;
void setPolarity(const defs::polarity enable);
bool getInterpolation() const;
void setInterpolation(const bool enable);
bool getPumpProbe() const;
void setPumpProbe(const bool enable);
bool getAnalogPulsing() const;
void setAnalogPulsing(const bool enable);
bool getDigitalPulsing() const;
void setDigitalPulsing(const bool enable);
/**************************************************
* *
@ -548,8 +558,6 @@ class Module : public virtual slsDetectorDefs {
void programFPGA(std::vector<char> buffer,
const bool forceDeleteNormalFile);
void resetFPGA();
void copyDetectorServer(const std::string &fname,
const std::string &hostname);
void updateDetectorServer(std::vector<char> buffer,
const std::string &serverName);
void updateKernel(std::vector<char> buffer);

View File

@ -462,4 +462,152 @@ TEST_CASE("gatedelay3", "[.cmd]") {
} else {
REQUIRE_THROWS(proxy.Call("gatedelay3", {}, -1, GET));
}
}
TEST_CASE("polarity", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
if (det.getDetectorType().squash() == defs::MYTHEN3) {
auto prev_val = det.getPolarity();
{
std::ostringstream oss;
proxy.Call("polarity", {"pos"}, -1, PUT, oss);
REQUIRE(oss.str() == "polarity pos\n");
}
{
std::ostringstream oss;
proxy.Call("polarity", {"neg"}, -1, PUT, oss);
REQUIRE(oss.str() == "polarity neg\n");
}
{
std::ostringstream oss;
proxy.Call("polarity", {}, -1, GET, oss);
REQUIRE(oss.str() == "polarity neg\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPolarity(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("polarity", {}, -1, GET));
}
}
TEST_CASE("interpolation", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
if (det.getDetectorType().squash() == defs::MYTHEN3) {
auto prev_val = det.getInterpolation();
auto mask = det.getCounterMask();
{
proxy.Call("counters", {"0", "1"}, -1, PUT);
std::ostringstream oss;
proxy.Call("interpolation", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "interpolation 1\n");
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") ==
7);
}
{
proxy.Call("counters", {"0", "1"}, -1, PUT);
std::ostringstream oss;
proxy.Call("interpolation", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "interpolation 0\n");
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") ==
3);
}
{
std::ostringstream oss;
proxy.Call("interpolation", {}, -1, GET, oss);
REQUIRE(oss.str() == "interpolation 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setCounterMask(mask[i], {i});
det.setInterpolation(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("interpolation", {}, -1, GET));
}
}
TEST_CASE("pumpprobe", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
if (det.getDetectorType().squash() == defs::MYTHEN3) {
auto prev_val = det.getPumpProbe();
{
std::ostringstream oss;
proxy.Call("pumpprobe", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "pumpprobe 1\n");
}
{
std::ostringstream oss;
proxy.Call("pumpprobe", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "pumpprobe 0\n");
}
{
std::ostringstream oss;
proxy.Call("pumpprobe", {}, -1, GET, oss);
REQUIRE(oss.str() == "pumpprobe 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPumpProbe(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("pumpprobe", {}, -1, GET));
}
}
TEST_CASE("apulse", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
if (det.getDetectorType().squash() == defs::MYTHEN3) {
auto prev_val = det.getAnalogPulsing();
{
std::ostringstream oss;
proxy.Call("apulse", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "apulse 1\n");
}
{
std::ostringstream oss;
proxy.Call("apulse", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "apulse 0\n");
}
{
std::ostringstream oss;
proxy.Call("apulse", {}, -1, GET, oss);
REQUIRE(oss.str() == "apulse 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setAnalogPulsing(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("apulse", {}, -1, GET));
}
}
TEST_CASE("dpulse", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
if (det.getDetectorType().squash() == defs::MYTHEN3) {
auto prev_val = det.getDigitalPulsing();
{
std::ostringstream oss;
proxy.Call("dpulse", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "dpulse 1\n");
}
{
std::ostringstream oss;
proxy.Call("dpulse", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "dpulse 0\n");
}
{
std::ostringstream oss;
proxy.Call("dpulse", {}, -1, GET, oss);
REQUIRE(oss.str() == "dpulse 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setDigitalPulsing(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("dpulse", {}, -1, GET));
}
}

View File

@ -16,6 +16,17 @@ using sls::Detector;
using test::GET;
using test::PUT;
TEST_CASE("Calling help doesn't throw or cause segfault"){
//Dont add [.cmd] tag this should run with normal tests
CmdProxy proxy(nullptr);
auto commands = proxy.GetProxyCommands();
std::ostringstream os;
for (const auto &cmd : commands)
REQUIRE_NOTHROW(proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os));
}
TEST_CASE("Unknown command", "[.cmd]") {
Detector det;
@ -2776,25 +2787,6 @@ TEST_CASE("resetfpga", "[.cmd]") {
}
}
TEST_CASE("copydetectorserver", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
det_type == defs::MOENCH || det_type == defs::MYTHEN3 ||
det_type == defs::GOTTHARD2) {
// TODO: send real server?
// std::ostringstream oss;
// proxy.Call("copydetectorserver",{"jungfrauDetectorServerv4.0.1.0",
// "pc13784"}, -1, PUT, oss);
// REQUIRE(oss.str() == "copydetectorserver successful\n");
REQUIRE_THROWS(proxy.Call("copydetectorserver", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("copydetectorserver", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("copydetectorserver", {}, -1, PUT));
}
}
TEST_CASE("updatekernel", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);

View File

@ -39,52 +39,50 @@ class Receiver : private virtual slsDetectorDefs {
int64_t getReceiverVersion();
/**
* Call back for start acquisition
* callback arguments are
* filepath
* filename
* fileindex
* datasize
*
* return value is undefined at the moment
* we write depending on file write enable
* users get data to write depending on call backs registered
* Start Acquisition Call back (slsMultiReceiver writes data if file write enabled)
* if registerCallBackRawDataReady or registerCallBackRawDataModifyReady registered,
* users get data
* callback arguments are:
* - file path
* - file name prefix
* - file index
* - image size in bytes
*/
void registerCallBackStartAcquisition(int (*func)(std::string, std::string,
uint64_t, uint32_t,
void *),
void registerCallBackStartAcquisition(int (*func)(const std::string &, const std::string &,
uint64_t, size_t, void *),
void *arg);
/**
* Call back for acquisition finished
* callback argument is
* total frames caught
* callback argument is:
* - total frames caught
*/
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
void *arg);
/**
* Call back for raw data
* args to raw data ready callback are
* sls_receiver_header frame metadata,
* dataPointer is the pointer to the data,
* dataSize in bytes is the size of the data in bytes.
* args to raw data ready callback are:
* - sls_receiver_header frame metadata,
* - pointer to data
* - image size in bytes
*/
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t,
void *),
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
char *, size_t, void *),
void *arg);
/**
* Call back for raw data (modified)
* args to raw data ready callback are
* sls_receiver_header frame metadata,
* dataPointer is the pointer to the data,
* revDatasize is the reference of data size in bytes.
* args to raw data ready callback are:
* - sls_receiver_header frame metadata,
* - pointer to data
* - revDatasize is the reference of data size in bytes.
* Can be modified to the new size to be written/streamed. (only smaller
* value).
* value allowed).
*/
void registerCallBackRawDataModifyReady(void (*func)(char *, char *,
uint32_t &, void *),
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
char *, size_t &,
void *),
void *arg);
private:

View File

@ -55,7 +55,7 @@ int64_t ClientInterface::getReceiverVersion() { return APIRECEIVER; }
/***callback functions***/
void ClientInterface::registerCallBackStartAcquisition(
int (*func)(std::string, std::string, uint64_t, uint32_t, void *),
int (*func)(const std::string &, const std::string &, uint64_t, size_t, void *),
void *arg) {
startAcquisitionCallBack = func;
pStartAcquisition = arg;
@ -69,13 +69,13 @@ void ClientInterface::registerCallBackAcquisitionFinished(void (*func)(uint64_t,
}
void ClientInterface::registerCallBackRawDataReady(
void (*func)(char *, char *, uint32_t, void *), void *arg) {
void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
rawDataReadyCallBack = func;
pRawDataReady = arg;
}
void ClientInterface::registerCallBackRawDataModifyReady(
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
rawDataModifyReadyCallBack = func;
pRawDataReady = arg;
}

View File

@ -30,25 +30,24 @@ class ClientInterface : private virtual slsDetectorDefs {
int64_t getReceiverVersion();
//***callback functions***
/** params: filepath, filename, fileindex, datasize */
void registerCallBackStartAcquisition(int (*func)(std::string, std::string,
uint64_t, uint32_t,
void *),
/** params: file path, file name, file index, image size */
void registerCallBackStartAcquisition(int (*func)(const std::string &, const std::string &,
uint64_t, size_t, void *),
void *arg);
/** params: total frames caught */
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
void *arg);
/** params: sls_receiver_header frame metadata, dataPointer, dataSize */
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t,
void *),
/** params: sls_receiver_header pointer, pointer to data, image size */
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
char *, size_t, void *),
void *arg);
/** params: sls_receiver_header frame metadata, dataPointer, modified size
*/
void registerCallBackRawDataModifyReady(void (*func)(char *, char *,
uint32_t &, void *),
/** params: sls_receiver_header pointer, pointer to data, reference to image size */
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
char *, size_t &,
void *),
void *arg);
private:
@ -180,13 +179,14 @@ class ClientInterface : private virtual slsDetectorDefs {
//***callback parameters***
int (*startAcquisitionCallBack)(std::string, std::string, uint64_t,
uint32_t, void *) = nullptr;
int (*startAcquisitionCallBack)(const std::string &, const std::string &, uint64_t, size_t,
void *) = nullptr;
void *pStartAcquisition{nullptr};
void (*acquisitionFinishedCallBack)(uint64_t, void *) = nullptr;
void *pAcquisitionFinished{nullptr};
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *) = nullptr;
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &,
void (*rawDataReadyCallBack)(sls_receiver_header *, char *, size_t,
void *) = nullptr;
void (*rawDataModifyReadyCallBack)(sls_receiver_header *, char *, size_t &,
void *) = nullptr;
void *pRawDataReady{nullptr};

View File

@ -42,14 +42,10 @@ DataProcessor::DataProcessor(int index, detectorType detectorType, Fifo *fifo,
ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false) {
LOG(logDEBUG) << "DataProcessor " << index << " created";
memset((void *)&timerbegin_, 0, sizeof(timespec));
}
DataProcessor::~DataProcessor() { DeleteFiles(); }
/** getters */
bool DataProcessor::GetStartedFlag() const { return startedFlag_; }
void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; }
@ -66,10 +62,8 @@ void DataProcessor::ResetParametersforNewAcquisition() {
void DataProcessor::RecordFirstIndex(uint64_t fnum) {
// listen to this fnum, later +1
currentFrameIndex_ = fnum;
startedFlag_ = true;
firstIndex_ = fnum;
LOG(logDEBUG1) << index << " First Index:" << firstIndex_;
}
@ -84,10 +78,8 @@ void DataProcessor::CloseFiles() {
void DataProcessor::DeleteFiles() {
CloseFiles();
if (dataFile_) {
delete dataFile_;
dataFile_ = nullptr;
}
delete dataFile_;
dataFile_ = nullptr;
}
void DataProcessor::SetupFileWriter(const bool filewriteEnable,
const fileFormat fileFormatType,
@ -231,13 +223,11 @@ std::string DataProcessor::CreateMasterFile(
void DataProcessor::ThreadExecution() {
char *buffer = nullptr;
fifo_->PopAddress(buffer);
LOG(logDEBUG5) << "DataProcessor " << index
<< ", "
"pop 0x"
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer;
LOG(logDEBUG5) << "DataProcessor " << index << ", " << std::hex
<< static_cast<void *>(buffer) << std::dec << ":" << buffer;
// check dummy
auto numBytes = (uint32_t)(*((uint32_t *)buffer));
auto numBytes = *reinterpret_cast<uint32_t *>(buffer);
LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes;
if (numBytes == DUMMY_PACKET_VALUE) {
StopProcessing(buffer);
@ -282,7 +272,7 @@ void DataProcessor::StopProcessing(char *buf) {
uint64_t DataProcessor::ProcessAnImage(char *buf) {
auto *rheader = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES);
auto *rheader = reinterpret_cast<sls_receiver_header *>(buf + FIFO_HEADER_NUMBYTES);
sls_detector_header header = rheader->detHeader;
uint64_t fnum = header.frameNumber;
currentFrameIndex_ = fnum;
@ -316,16 +306,17 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
try {
// normal call back
if (rawDataReadyCallBack != nullptr) {
rawDataReadyCallBack((char *)rheader,
std::size_t dsize = *reinterpret_cast<uint32_t *>(buf);
rawDataReadyCallBack(rheader,
buf + FIFO_HEADER_NUMBYTES +
sizeof(sls_receiver_header),
(uint32_t)(*((uint32_t *)buf)), pRawDataReady);
dsize, pRawDataReady);
}
// call back with modified size
else if (rawDataModifyReadyCallBack != nullptr) {
auto revsize = (uint32_t)(*((uint32_t *)buf));
rawDataModifyReadyCallBack((char *)rheader,
std::size_t revsize = *reinterpret_cast<uint32_t *>(buf);
rawDataModifyReadyCallBack(rheader,
buf + FIFO_HEADER_NUMBYTES +
sizeof(sls_receiver_header),
revsize, pRawDataReady);
@ -369,14 +360,15 @@ bool DataProcessor::CheckTimer() {
struct timespec end;
clock_gettime(CLOCK_REALTIME, &end);
LOG(logDEBUG1) << index << " Timer elapsed time:"
<< ((end.tv_sec - timerbegin_.tv_sec) +
(end.tv_nsec - timerbegin_.tv_nsec) / 1000000000.0)
auto elapsed_s = (end.tv_sec - timerbegin_.tv_sec) +
(end.tv_nsec - timerbegin_.tv_nsec) / 1e9;
double timer_s = *streamingTimerInMs_ / 1e3;
LOG(logDEBUG1) << index << " Timer elapsed time:" << elapsed_s
<< " seconds";
// still less than streaming timer, keep waiting
if (((end.tv_sec - timerbegin_.tv_sec) +
(end.tv_nsec - timerbegin_.tv_nsec) / 1000000000.0) <
((double)*streamingTimerInMs_ / 1000.00))
if (elapsed_s < timer_s)
return false;
// restart timer
@ -393,15 +385,14 @@ bool DataProcessor::CheckCount() {
return false;
}
void DataProcessor::registerCallBackRawDataReady(void (*func)(char *, char *,
uint32_t, void *),
void *arg) {
void DataProcessor::registerCallBackRawDataReady(
void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
rawDataReadyCallBack = func;
pRawDataReady = arg;
}
void DataProcessor::registerCallBackRawDataModifyReady(
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
rawDataModifyReadyCallBack = func;
pRawDataReady = arg;
}
@ -410,7 +401,8 @@ void DataProcessor::PadMissingPackets(char *buf) {
LOG(logDEBUG) << index << ": Padding Missing Packets";
uint32_t pperFrame = generalData_->packetsPerFrame;
auto *header = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES);
auto *header =
reinterpret_cast<sls_receiver_header *>(buf + FIFO_HEADER_NUMBYTES);
uint32_t nmissing = pperFrame - header->detHeader.packetNumber;
sls_bitset pmask = header->packetsMask;
@ -483,7 +475,7 @@ void DataProcessor::RearrangeDbitData(char *buf) {
// ceil as numResult8Bits could be decimal
const int numResult8Bits =
ceil((double)(numSamples * (*ctbDbitList_).size()) / 8.00);
ceil((numSamples * (*ctbDbitList_).size()) / 8.00);
std::vector<uint8_t> result(numResult8Bits);
uint8_t *dest = &result[0];
@ -499,7 +491,7 @@ void DataProcessor::RearrangeDbitData(char *buf) {
}
// loop through the frame digital data
for (auto ptr = source; ptr < (source + numSamples);) {
for (auto *ptr = source; ptr < (source + numSamples);) {
// get selected bit from each 8 bit
uint8_t bit = (*ptr++ >> bi) & 1;
*dest |= bit << bitoffset;

View File

@ -79,28 +79,16 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
const fileFormat fileFormatType,
MasterAttributes *attr,
std::mutex *hdf5LibMutex);
/**
* Call back for raw data
* args to raw data ready callback are
* sls_receiver_header frame metadata
* dataPointer is the pointer to the data
* dataSize in bytes is the size of the data in bytes.
*/
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t,
void *),
/** params: sls_receiver_header pointer, pointer to data, image size */
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
char *, size_t, void *),
void *arg);
/**
* Call back for raw data (modified)
* args to raw data ready callback are
* sls_receiver_header frame metadata
* dataPointer is the pointer to the data
* revDatasize is the reference of data size in bytes.
* Can be modified to the new size to be written/streamed. (only smaller
* value).
*/
void registerCallBackRawDataModifyReady(void (*func)(char *, char *,
uint32_t &, void *),
/** params: sls_receiver_header pointer, pointer to data, reference to image size */
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
char *, size_t &,
void *),
void *arg);
private:
@ -167,7 +155,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
uint32_t *streamingTimerInMs_;
uint32_t *streamingStartFnum_;
uint32_t currentFreqCount_{0};
struct timespec timerbegin_;
struct timespec timerbegin_{};
bool *framePadding_;
std::vector<int> *ctbDbitList_;
int *ctbDbitOffset_;
@ -195,7 +183,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* dataPointer is the pointer to the data
* dataSize in bytes is the size of the data in bytes.
*/
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *) = nullptr;
void (*rawDataReadyCallBack)(sls_receiver_header *, char *, size_t,
void *) = nullptr;
/**
* Call back for raw data (modified)
@ -205,7 +194,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* revDatasize is the reference of data size in bytes. Can be modified to
* the new size to be written/streamed. (only smaller value).
*/
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &,
void (*rawDataModifyReadyCallBack)(sls_receiver_header *, char *, size_t &,
void *) = nullptr;
void *pRawDataReady{nullptr};

View File

@ -62,6 +62,7 @@ class GeneralData {
uint32_t adcEnableMaskOneGiga{BIT32_MASK};
uint32_t adcEnableMaskTenGiga{BIT32_MASK};
slsDetectorDefs::ROI roi{};
uint32_t counterMask{0};
GeneralData(){};
virtual ~GeneralData(){};
@ -122,8 +123,8 @@ class GeneralData {
ThrowGenericError("SetNumberofInterfaces");
};
virtual void SetNumberofCounters(const int n) {
ThrowGenericError("SetNumberofCounters");
virtual void SetCounterMask(const int n) {
ThrowGenericError("setCounterMask");
};
virtual int GetNumberOfAnalogDatabytes() {
@ -359,13 +360,12 @@ class JungfrauData : public GeneralData {
class Mythen3Data : public GeneralData {
private:
int ncounters;
int ncounters{0};
const int NCHAN = 1280;
public:
Mythen3Data() {
myDetectorType = slsDetectorDefs::MYTHEN3;
ncounters = 3;
nPixelsY = 1;
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
maxFramesPerFile = MYTHEN3_MAX_FRAMES_PER_FILE;
@ -376,6 +376,7 @@ class Mythen3Data : public GeneralData {
defaultUdpSocketBufferSize = (1000 * 1024 * 1024);
dynamicRange = 32;
tengigaEnable = true;
SetCounterMask(0x7);
UpdateImageSize();
};
@ -389,7 +390,13 @@ class Mythen3Data : public GeneralData {
UpdateImageSize();
};
virtual void SetNumberofCounters(const int n) {
virtual void SetCounterMask(const int mask) {
int n = __builtin_popcount(mask);
if (n < 1 || n > 3) {
throw sls::RuntimeError("Invalid number of counters " +
std::to_string(n) + ". Expected 1-3.");
}
counterMask = mask;
ncounters = n;
UpdateImageSize();
};

View File

@ -153,10 +153,20 @@ void Implementation::setDetectorType(const detectorType d) {
default:
break;
}
numUDPInterfaces = generalData->numUDPInterfaces;
fifoDepth = generalData->defaultFifoDepth;
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
framesPerFile = generalData->maxFramesPerFile;
fifoDepth = generalData->defaultFifoDepth;
numUDPInterfaces = generalData->numUDPInterfaces;
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
dynamicRange = generalData->dynamicRange;
tengigaEnable = generalData->tengigaEnable;
numberOfAnalogSamples = generalData->nAnalogSamples;
numberOfDigitalSamples = generalData->nDigitalSamples;
readoutType = generalData->readoutType;
adcEnableMaskOneGiga = generalData->adcEnableMaskOneGiga;
adcEnableMaskTenGiga = generalData->adcEnableMaskTenGiga;
roi = generalData->roi;
counterMask = generalData->counterMask;
SetLocalNetworkParameters();
SetupFifoStructure();
@ -523,9 +533,9 @@ void Implementation::startReceiver() {
// callbacks
if (startAcquisitionCallBack) {
try {
startAcquisitionCallBack(filePath, fileName, fileIndex,
(generalData->imageSize) +
(generalData->fifoBufferHeaderSize),
std::size_t imageSize =
static_cast<uint32_t>(generalData->imageSize);
startAcquisitionCallBack(filePath, fileName, fileIndex, imageSize,
pStartAcquisition);
} catch (const std::exception &e) {
throw sls::RuntimeError("Start Acquisition Callback Error: " +
@ -1395,14 +1405,8 @@ uint32_t Implementation::getCounterMask() const { return counterMask; }
void Implementation::setCounterMask(const uint32_t i) {
if (counterMask != i) {
int ncounters = __builtin_popcount(i);
if (ncounters < 1 || ncounters > 3) {
throw sls::RuntimeError("Invalid number of counters " +
std::to_string(ncounters) +
". Expected 1-3.");
}
generalData->SetCounterMask(i);
counterMask = i;
generalData->SetNumberofCounters(ncounters);
SetupFifoStructure();
}
LOG(logINFO) << "Counter mask: " << sls::ToStringHex(counterMask);
@ -1627,7 +1631,8 @@ void Implementation::setDbitOffset(const int s) { ctbDbitOffset = s; }
* *
* ************************************************/
void Implementation::registerCallBackStartAcquisition(
int (*func)(std::string, std::string, uint64_t, uint32_t, void *),
int (*func)(const std::string &, const std::string &, uint64_t, size_t,
void *),
void *arg) {
startAcquisitionCallBack = func;
pStartAcquisition = arg;
@ -1641,7 +1646,7 @@ void Implementation::registerCallBackAcquisitionFinished(void (*func)(uint64_t,
}
void Implementation::registerCallBackRawDataReady(
void (*func)(char *, char *, uint32_t, void *), void *arg) {
void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
rawDataReadyCallBack = func;
pRawDataReady = arg;
for (const auto &it : dataProcessor)
@ -1649,7 +1654,7 @@ void Implementation::registerCallBackRawDataReady(
}
void Implementation::registerCallBackRawDataModifyReady(
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
rawDataModifyReadyCallBack = func;
pRawDataReady = arg;
for (const auto &it : dataProcessor)

View File

@ -252,17 +252,21 @@ class Implementation : private virtual slsDetectorDefs {
* Callbacks *
* *
* ************************************************/
void registerCallBackStartAcquisition(int (*func)(std::string, std::string,
uint64_t, uint32_t,
void *),
/** params: file path, file name, file index, image size */
void registerCallBackStartAcquisition(int (*func)(const std::string &, const std::string &,
uint64_t, size_t, void *),
void *arg);
/** params: total frames caught */
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
void *arg);
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t,
void *),
/** params: sls_receiver_header pointer, pointer to data, image size */
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
char *, size_t, void *),
void *arg);
void registerCallBackRawDataModifyReady(void (*func)(char *, char *,
uint32_t &, void *),
/** params: sls_receiver_header pointer, pointer to data, reference to image size */
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
char *, size_t &,
void *),
void *arg);
private:
@ -369,13 +373,14 @@ class Implementation : private virtual slsDetectorDefs {
int ctbDbitOffset{0};
// callbacks
int (*startAcquisitionCallBack)(std::string, std::string, uint64_t,
uint32_t, void *){nullptr};
int (*startAcquisitionCallBack)(const std::string &, const std::string &, uint64_t, size_t,
void *){nullptr};
void *pStartAcquisition{nullptr};
void (*acquisitionFinishedCallBack)(uint64_t, void *){nullptr};
void *pAcquisitionFinished{nullptr};
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *){nullptr};
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &,
void (*rawDataReadyCallBack)(sls_receiver_header *, char *, size_t,
void *){nullptr};
void (*rawDataModifyReadyCallBack)(sls_receiver_header *, char *, size_t &,
void *){nullptr};
void *pRawDataReady{nullptr};

View File

@ -47,32 +47,21 @@ void printHelp() {
}
/**
* Start Acquisition Call back
* slsReceiver writes data if file write enabled.
* Users get data to write using call back if registerCallBackRawDataReady is
* registered.
* @param filepath file path
* @param filename file name
* @param fileindex file index
* @param datasize data size in bytes
* @param p pointer to object
* \returns ignored
* Start Acquisition Call back (slsMultiReceiver writes data if file write enabled)
* if registerCallBackRawDataReady or registerCallBackRawDataModifyReady registered,
* users get data
*/
int StartAcq(std::string filepath, std::string filename, uint64_t fileindex,
uint32_t datasize, void *p) {
LOG(logINFOBLUE) << "#### StartAcq: filepath:" << filepath
<< " filename:" << filename << " fileindex:" << fileindex
<< " datasize:" << datasize << " ####";
int StartAcq(const std::string & filePath, const std::string & fileName, uint64_t fileIndex,
size_t imageSize, void *objectPointer) {
LOG(logINFOBLUE) << "#### StartAcq: filePath:" << filePath
<< " fileName:" << fileName << " fileIndex:" << fileIndex
<< " imageSize:" << imageSize << " ####";
return 0;
}
/**
* Acquisition Finished Call back
* @param frames Number of frames caught
* @param p pointer to object
*/
void AcquisitionFinished(uint64_t frames, void *p) {
LOG(logINFOBLUE) << "#### AcquisitionFinished: frames:" << frames
/** Acquisition Finished Call back */
void AcquisitionFinished(uint64_t framesCaught, void *objectPointer) {
LOG(logINFOBLUE) << "#### AcquisitionFinished: framesCaught:" << framesCaught
<< " ####";
}
@ -80,14 +69,9 @@ void AcquisitionFinished(uint64_t frames, void *p) {
* Get Receiver Data Call back
* Prints in different colors(for each receiver process) the different headers
* for each image call back.
* @param metadata sls_receiver_header metadata
* @param datapointer pointer to data
* @param datasize data size in bytes.
* @param p pointer to object
*/
void GetData(char *metadata, char *datapointer, uint32_t datasize, void *p) {
slsDetectorDefs::sls_receiver_header *header =
(slsDetectorDefs::sls_receiver_header *)metadata;
void GetData(slsDetectorDefs::sls_receiver_header *header, char *dataPointer,
size_t imageSize, void *objectPointer) {
slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
PRINT_IN_COLOR(
@ -98,7 +82,7 @@ void GetData(char *metadata, char *datapointer, uint32_t datasize, void *p) {
"row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u"
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
//"\t\tpacketsMask:%s"
"\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
"\t\tfirstbytedata: 0x%x\t\tdatsize: %zu\n\n",
detectorHeader.row, (long unsigned int)detectorHeader.frameNumber,
detectorHeader.expLength, detectorHeader.packetNumber,
(long unsigned int)detectorHeader.bunchId,
@ -107,23 +91,18 @@ void GetData(char *metadata, char *datapointer, uint32_t datasize, void *p) {
detectorHeader.debug, detectorHeader.roundRNumber,
detectorHeader.detType, detectorHeader.version,
// header->packetsMask.to_string().c_str(),
((uint8_t)(*((uint8_t *)(datapointer)))), datasize);
((uint8_t)(*((uint8_t *)(dataPointer)))), imageSize);
}
/**
* Get Receiver Data Call back (modified)
* Prints in different colors(for each receiver process) the different headers
* for each image call back.
* @param metadata sls_receiver_header metadata
* @param datapointer pointer to data
* @param revDatasize new data size in bytes after the callback.
* @param modifiedImageSize new data size in bytes after the callback.
* This will be the size written/streamed. (only smaller value is allowed).
* @param p pointer to object
*/
void GetData(char *metadata, char *datapointer, uint32_t &revDatasize,
void *p) {
slsDetectorDefs::sls_receiver_header *header =
(slsDetectorDefs::sls_receiver_header *)metadata;
void GetData(slsDetectorDefs::sls_receiver_header *header, char *dataPointer,
size_t &modifiedImageSize, void *objectPointer) {
slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
PRINT_IN_COLOR(
@ -135,7 +114,7 @@ void GetData(char *metadata, char *datapointer, uint32_t &revDatasize,
"row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u"
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
//"\t\tpacketsMask:%s"
"\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
"\t\tfirstbytedata: 0x%x\t\tdatsize: %zu\n\n",
detectorHeader.row, (long long unsigned int)detectorHeader.frameNumber,
detectorHeader.expLength, detectorHeader.packetNumber,
(long long unsigned int)detectorHeader.bunchId,
@ -144,10 +123,10 @@ void GetData(char *metadata, char *datapointer, uint32_t &revDatasize,
detectorHeader.debug, detectorHeader.roundRNumber,
detectorHeader.detType, detectorHeader.version,
// header->packetsMask.to_string().c_str(),
((uint8_t)(*((uint8_t *)(datapointer)))), revDatasize);
((uint8_t)(*((uint8_t *)(dataPointer)))), modifiedImageSize);
// if data is modified, eg ROI and size is reduced
revDatasize = 26000;
modifiedImageSize = 26000;
}
/**

View File

@ -129,7 +129,7 @@ int64_t Receiver::getReceiverVersion() {
}
void Receiver::registerCallBackStartAcquisition(
int (*func)(std::string, std::string, uint64_t, uint32_t, void *),
int (*func)(const std::string &, const std::string &, uint64_t, size_t, void *),
void *arg) {
tcpipInterface->registerCallBackStartAcquisition(func, arg);
}
@ -140,14 +140,13 @@ void Receiver::registerCallBackAcquisitionFinished(void (*func)(uint64_t,
tcpipInterface->registerCallBackAcquisitionFinished(func, arg);
}
void Receiver::registerCallBackRawDataReady(void (*func)(char *, char *,
uint32_t, void *),
void *arg) {
void Receiver::registerCallBackRawDataReady(
void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
tcpipInterface->registerCallBackRawDataReady(func, arg);
}
void Receiver::registerCallBackRawDataModifyReady(
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
tcpipInterface->registerCallBackRawDataModifyReady(func, arg);
}

View File

@ -43,6 +43,7 @@ std::string ToString(const defs::portPosition s);
std::string ToString(const defs::streamingInterface s);
std::string ToString(const defs::vetoAlgorithm s);
std::string ToString(const defs::gainMode s);
std::string ToString(const defs::polarity s);
std::string ToString(const slsDetectorDefs::xy &coord);
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord);
@ -313,6 +314,7 @@ template <> defs::portPosition StringTo(const std::string &s);
template <> defs::streamingInterface StringTo(const std::string &s);
template <> defs::vetoAlgorithm StringTo(const std::string &s);
template <> defs::gainMode StringTo(const std::string &s);
template <> defs::polarity StringTo(const std::string &s);
template <> uint32_t StringTo(const std::string &s);
template <> uint64_t StringTo(const std::string &s);

View File

@ -438,6 +438,8 @@ enum streamingInterface {
FIX_G0
};
enum polarity { POSITIVE, NEGATIVE };
#ifdef __cplusplus
/** scan structure */

View File

@ -111,7 +111,6 @@ enum detFuncs {
F_SOFTWARE_TRIGGER,
F_LED,
F_DIGITAL_IO_DELAY,
F_COPY_DET_SERVER,
F_REBOOT_CONTROLLER,
F_SET_ADC_ENABLE_MASK,
F_GET_ADC_ENABLE_MASK,
@ -261,9 +260,19 @@ enum detFuncs {
F_SET_MASTER,
F_GET_TOP,
F_SET_TOP,
F_GET_POLARITY,
F_SET_POLARITY,
F_GET_INTERPOLATION,
F_SET_INTERPOLATION,
F_GET_PUMP_PROBE,
F_SET_PUMP_PROBE,
F_GET_ANALOG_PULSING,
F_SET_ANALOG_PULSING,
F_GET_DIGITAL_PULSING,
F_SET_DIGITAL_PULSING,
NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
RECEIVER_ENUM_START = 512, /**< detector function should not exceed this
(detector server should not compile anyway) */
F_EXEC_RECEIVER_COMMAND,
@ -477,7 +486,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER";
case F_LED: return "F_LED";
case F_DIGITAL_IO_DELAY: return "F_DIGITAL_IO_DELAY";
case F_COPY_DET_SERVER: return "F_COPY_DET_SERVER";
case F_REBOOT_CONTROLLER: return "F_REBOOT_CONTROLLER";
case F_SET_ADC_ENABLE_MASK: return "F_SET_ADC_ENABLE_MASK";
case F_GET_ADC_ENABLE_MASK: return "F_GET_ADC_ENABLE_MASK";
@ -625,6 +633,16 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_MASTER: return "F_SET_MASTER";
case F_GET_TOP: return "F_GET_TOP";
case F_SET_TOP: return "F_SET_TOP";
case F_GET_POLARITY: return "F_GET_POLARITY";
case F_SET_POLARITY: return "F_SET_POLARITY";
case F_GET_INTERPOLATION: return "F_GET_INTERPOLATION";
case F_SET_INTERPOLATION: return "F_SET_INTERPOLATION";
case F_GET_PUMP_PROBE: return "F_GET_PUMP_PROBE";
case F_SET_PUMP_PROBE: return "F_SET_PUMP_PROBE";
case F_GET_ANALOG_PULSING: return "F_GET_ANALOG_PULSING";
case F_SET_ANALOG_PULSING: return "F_SET_ANALOG_PULSING";
case F_GET_DIGITAL_PULSING: return "F_GET_DIGITAL_PULSING";
case F_SET_DIGITAL_PULSING: return "F_SET_DIGITAL_PULSING";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

@ -2,14 +2,14 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */
#define GITBRANCH "developer"
#define APILIB 0x211125
#define APIRECEIVER 0x211124
#define APIGUI 0x211124
#define APILIB 0x220408
#define APIRECEIVER 0x220408
#define APIGUI 0x220328
#define APIEIGER 0x220324
#define APICTB 0x220328
#define APIGOTTHARD 0x220328
#define APIGOTTHARD2 0x220328
#define APIJUNGFRAU 0x220328
#define APIMOENCH 0x220328
#define APIMYTHEN3 0x220404
#define APICTB 0x220408
#define APIGOTTHARD 0x220408
#define APIGOTTHARD2 0x220408
#define APIJUNGFRAU 0x220408
#define APIMYTHEN3 0x220408
#define APIMOENCH 0x220408
#define APIEIGER 0x220408

View File

@ -642,6 +642,17 @@ std::string ToString(const defs::gainMode s) {
}
}
std::string ToString(const defs::polarity s) {
switch (s) {
case defs::POSITIVE:
return std::string("pos");
case defs::NEGATIVE:
return std::string("neg");
default:
return std::string("Unknown");
}
}
const std::string &ToString(const std::string &s) { return s; }
template <> defs::detectorType StringTo(const std::string &s) {
@ -1055,6 +1066,14 @@ template <> defs::gainMode StringTo(const std::string &s) {
throw sls::RuntimeError("Unknown gain mode " + s);
}
template <> defs::polarity StringTo(const std::string &s) {
if (s == "pos")
return defs::POSITIVE;
if (s == "neg")
return defs::NEGATIVE;
throw sls::RuntimeError("Unknown polarity mode " + s);
}
template <> uint32_t StringTo(const std::string &s) {
int base = s.find("0x") != std::string::npos ? 16 : 10;
return std::stoul(s, nullptr, base);

View File

@ -6,7 +6,7 @@
#include <chrono>
#include <thread>
TEST_CASE("Time 1s restart then time 2s") {
TEST_CASE("Time 1s restart then time 2s", "[.timer]") {
auto sleep_duration = std::chrono::seconds(1);
auto t = sls::Timer();
std::this_thread::sleep_for(sleep_duration);
@ -17,7 +17,7 @@ TEST_CASE("Time 1s restart then time 2s") {
REQUIRE(t.elapsed_s() == Approx(2).epsilon(0.01));
}
TEST_CASE("Return ms") {
TEST_CASE("Return ms", "[.timer]") {
auto sleep_duration = std::chrono::milliseconds(1300);
auto t = sls::Timer();
std::this_thread::sleep_for(sleep_duration);