Merge branch 'developer' into jf_h5reader

This commit is contained in:
hinger_v 2024-10-29 12:03:17 +01:00
commit b587e95717
38 changed files with 300 additions and 552 deletions

View File

@ -2,7 +2,7 @@
# Copyright (C) 2021 Contributors to the SLS Detector Package # Copyright (C) 2021 Contributors to the SLS Detector Package
cmake_minimum_required(VERSION 3.14) cmake_minimum_required(VERSION 3.14)
project(slsDetectorPackage) project(slsDetectorPackage)
set(PROJECT_VERSION 7.0.0) set(PROJECT_VERSION 9.0.0)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")

View File

@ -1,7 +1,7 @@
SLS Detector Package Major Release 7.x.x released on xx.xx.2023 SLS Detector Package Major Release x.x.x released on xx.xx.202x
=============================================================== ===============================================================
This document describes the differences between v7.x.x and v7.0.2 This document describes the differences between vx.x.x and vx.0.2
@ -28,9 +28,6 @@ This document describes the differences between v7.x.x and v7.0.2
===================================== =====================================
- moench being made compatible with jungfrau 2.0 boards (jungfrau structure, away from ctb)
- eiger febl and feb in versions
- fix ctb slow adcs
@ -38,22 +35,24 @@ This document describes the differences between v7.x.x and v7.0.2
========================================== ==========================================
Eiger 7.0.0 Eiger 9.0.0
Jungfrau 7.0.2 Jungfrau 9.0.0
Mythen3 7.0.0 Mythen3 9.0.0
Gotthard2 7.0.0 Gotthard2 9.0.0
Gotthard 7.0.0 Gotthard 9.0.0
Moench 7.0.0 Moench 9.0.0
Ctb 7.0.0
On-board Detector Server Upgrade On-board Detector Server Upgrade
-------------------------------- --------------------------------
From v6.1.0 (without tftp): From v6.1.0 (without tftp):
Using command 'updatedetectorserver' update only on-board detector server
From 5.0.0 (with tftp): Using command 'updatedetectorserver'
Using command 'copydetectorserver'
udpate both on-board detector server and firmware simultaneously
Using command 'update'
Instructions available at Instructions available at
https://slsdetectorgroup.github.io/devdoc/serverupgrade.html https://slsdetectorgroup.github.io/devdoc/serverupgrade.html
@ -65,22 +64,20 @@ This document describes the differences between v7.x.x and v7.0.2
======================== ========================
Eiger 20.02.2023 (v31) Eiger 02.10.2023 (v32) (updated in 7.0.3)
Jungfrau 04.11.2022 (v1.4, HW v1.0) Jungfrau 20.09.2023 (v1.5, HW v1.0) (updated in 8.0.0)
03.11.2022 (v2.4, HW v2.0) 21.09.2023 (v2.5, HW v2.0) (updated in 8.0.0)
Mythen3 24.01.2023 (v1.4) Mythen3 11.10.2024 (v1.5) (updated in 9.0.0)
Gotthard2 23.11.2022 (v0.3) Gotthard2 03.10.2024 (v1.0) (updated in 9.0.0)
Moench 26.10.2023 (v2.0) (updated in 9.0.0)
Gotthard 08.02.2018 (50um and 25um Master) Gotthard 08.02.2018 (50um and 25um Master)
09.02.2018 (25 um Slave) 09.02.2018 (25 um Slave)
Moench 05.12.2022 (v0.3)
Ctb 03.04.2023 (v1.2?)
Detector Upgrade Detector Upgrade
---------------- ----------------
@ -92,7 +89,6 @@ This document describes the differences between v7.x.x and v7.0.2
Mythen3 via command <.rbf> Mythen3 via command <.rbf>
Gotthard2 via command <.rbf> Gotthard2 via command <.rbf>
Moench via command <.pof> Moench via command <.pof>
Ctb via command <.pof>
Gotthard cannot be upgraded remotely Gotthard cannot be upgraded remotely
@ -100,7 +96,7 @@ This document describes the differences between v7.x.x and v7.0.2
upgrade upgrade
Using command 'programfpga' or Using command 'programfpga' or
udpate both server and firmware simultaneously udpate both on-board detector server and firmware simultaneously
Using command 'update' Using command 'update'
@ -113,6 +109,7 @@ This document describes the differences between v7.x.x and v7.0.2
4 Kernel Requirements 4 Kernel Requirements
====================== ======================
Blackfin Blackfin
-------- --------
Latest version: Fri Oct 29 00:00:00 2021 Latest version: Fri Oct 29 00:00:00 2021
@ -120,10 +117,12 @@ This document describes the differences between v7.x.x and v7.0.2
Older ones will work, but might have issues with programming firmware via Older ones will work, but might have issues with programming firmware via
the package. the package.
Nios Nios
----- -----
Compatible version: Mon May 10 18:00:21 CEST 2021 Compatible version: Mon May 10 18:00:21 CEST 2021
Kernel Upgrade Kernel Upgrade
--------------- ---------------
Eiger via bit files Eiger via bit files

View File

@ -8,7 +8,7 @@ Commands can be used either with sls_detector_get or sls_detector_put
.. code-block:: .. code-block::
sls_detector_get vrf sls_detector_get exptime
Help Help
-------- --------
@ -25,6 +25,16 @@ Help
sls_detector_get -h fpath sls_detector_get -h fpath
sls_detector_help fpath sls_detector_help fpath
# list of deprecated commands
list deprecated
# autocompletion
# bash_autocomplete.sh or zsh_autocomplete.sh must be sourced from the
# main package folder to enable auto completion of commands and arguments
# for the command line on that shell.
source bash_autocomplete.sh
Commands Commands
----------- -----------

View File

@ -11,7 +11,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "CmdProxy.h" #include "Caller.h"
#include "sls/Detector.h" #include "sls/Detector.h"
#include "sls/sls_detector_defs.h" #include "sls/sls_detector_defs.h"
@ -37,8 +37,8 @@ int main() {
std::cout << "Generating command line documentation!\n"; std::cout << "Generating command line documentation!\n";
sls::CmdProxy proxy(nullptr); sls::Caller caller(nullptr);
auto commands = proxy.GetProxyCommands(); auto commands = caller.getAllCommands();
std::ofstream fs("commands.rst"); std::ofstream fs("commands.rst");
fs << ".. glossary::\n"; fs << ".. glossary::\n";
@ -46,7 +46,7 @@ int main() {
for (const auto &cmd : commands) { for (const auto &cmd : commands) {
std::ostringstream os; std::ostringstream os;
std::cout << cmd << '\n'; std::cout << cmd << '\n';
proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os); caller.call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os);
auto tmp = os.str().erase(0, cmd.size()); auto tmp = os.str().erase(0, cmd.size());
auto usage = tmp.substr(0, tmp.find_first_of('\n')); auto usage = tmp.substr(0, tmp.find_first_of('\n'));
@ -57,7 +57,7 @@ int main() {
std::ofstream fs2("deprecated.csv"); std::ofstream fs2("deprecated.csv");
fs2 << "Old, New\n"; fs2 << "Old, New\n";
auto cmds = proxy.GetDeprecatedCommands(); auto cmds = caller.GetDeprecatedCommands();
for (auto it : cmds) { for (auto it : cmds) {
fs2 << it.first << ", " << it.second << '\n'; fs2 << it.first << ", " << it.second << '\n';
} }

View File

@ -213,7 +213,7 @@ ZMQ: Json Header Format
| | [From detector udp header] | | | [From detector udp header] |
+--------------+----------------------------------------------+ +--------------+----------------------------------------------+
| detType | Detector type enum | | detType | Detector type enum |
| detSpec3 | See :ref:`Detector enum<Detector Enum>` | | detSpec3 | See :ref:`Detector enum<detector enum>` |
| | [From detector udp header] | | | [From detector udp header] |
+--------------+----------------------------------------------+ +--------------+----------------------------------------------+
| version | Detector header version. At 2 | | version | Detector header version. At 2 |

View File

@ -63,6 +63,8 @@ Description
* **version**: current version of the detector header (0x2). * **version**: current version of the detector header (0x2).
.. _detector enum:
Detector Enum Detector Enum
-------------- --------------

View File

@ -21,11 +21,13 @@ void init_det(py::module &m) {
using sls::Positions; using sls::Positions;
using sls::Result; using sls::Result;
m.def("freeSharedMemory",
(void (*)(const int, const int)) & sls::freeSharedMemory,
py::arg() = 0, py::arg() = -1);
py::class_<Detector> CppDetectorApi(m, "CppDetectorApi"); py::class_<Detector> CppDetectorApi(m, "CppDetectorApi");
CppDetectorApi.def(py::init<int>()); CppDetectorApi.def(py::init<int>());
CppDetectorApi.def("freeSharedMemory",
(void (Detector::*)()) & Detector::freeSharedMemory);
CppDetectorApi.def("loadConfig", CppDetectorApi.def("loadConfig",
(void (Detector::*)(const std::string &)) & (void (Detector::*)(const std::string &)) &
Detector::loadConfig, Detector::loadConfig,

View File

@ -18,6 +18,8 @@ void init_det(py::module &m) {
using sls::Positions; using sls::Positions;
using sls::Result; using sls::Result;
m.def("freeSharedMemory", (void (*)(const int, const int)) &sls::freeSharedMemory, py::arg() = 0, py::arg() = -1);
py::class_<Detector> CppDetectorApi(m, "CppDetectorApi"); py::class_<Detector> CppDetectorApi(m, "CppDetectorApi");
CppDetectorApi.def(py::init<int>()); CppDetectorApi.def(py::init<int>());

View File

@ -457,7 +457,7 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If sub images have missing packets&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If sub images have missing packets&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Complete Image</string> <string/>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
@ -523,6 +523,7 @@
</property> </property>
<property name="font"> <property name="font">
<font> <font>
<family>Cantarell</family>
<pointsize>10</pointsize> <pointsize>10</pointsize>
</font> </font>
</property> </property>

View File

@ -123,7 +123,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
QString zTitle2d{"Intensity"}; QString zTitle2d{"Intensity"};
QString plotTitle{""}; QString plotTitle{""};
QString indexTitle{""}; QString indexTitle{""};
bool completeImage{false}; bool completeImage{true};
bool xyRangeChanged{false}; bool xyRangeChanged{false};
double xyRange[4]{0, 0, 0, 0}; double xyRange[4]{0, 0, 0, 0};
bool isXYRange[4]{false, false, false, false}; bool isXYRange[4]{false, false, false, false};

View File

@ -107,7 +107,7 @@ void qDrawPlot::SetupPlots() {
LOG(logINFO) << "nPixelsY:" << nPixelsY; LOG(logINFO) << "nPixelsY:" << nPixelsY;
widgetStatistics->hide(); widgetStatistics->hide();
lblCompleteImage->hide(); lblCompleteImage->show();
lblInCompleteImage->hide(); lblInCompleteImage->hide();
lblRxRoiEnabled->hide(); lblRxRoiEnabled->hide();

View File

@ -987,6 +987,8 @@ int readConfigFile() {
// to inform powerchip config parameters are set // to inform powerchip config parameters are set
startupPowerChipConfigDone = 1; startupPowerChipConfigDone = 1;
chipConfigured = 1;
LOG(logINFOBLUE, ("Chip configured\n"));
} }
return initError; return initError;
} }
@ -2278,8 +2280,7 @@ int powerChip(int on, char *mess) {
if (on) { if (on) {
LOG(logINFO, ("Powering chip: on\n")); LOG(logINFO, ("Powering chip: on\n"));
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PWR_CHIP_MSK); bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PWR_CHIP_MSK);
// only if power chip config done, configure chip with current set up if (configureChip(mess) == FAIL)
if (startupPowerChipConfigDone == 1 && configureChip(mess) == FAIL)
return FAIL; return FAIL;
} else { } else {
// throw if high voltage on // throw if high voltage on
@ -2310,6 +2311,12 @@ int getPowerChip() {
int isChipConfigured() { return chipConfigured; } int isChipConfigured() { return chipConfigured; }
int configureChip(char *mess) { int configureChip(char *mess) {
if (!startupPowerChipConfigDone) {
LOG(logINFOBLUE,
("Startup: Chip to be configured when reading config file\n"));
return OK;
}
LOG(logINFOBLUE, ("\tConfiguring chip\n")); LOG(logINFOBLUE, ("\tConfiguring chip\n"));
// on chip dacs // on chip dacs

View File

@ -2555,6 +2555,7 @@ void getPedestalParameters(uint8_t *frames, uint16_t *loops) {
} }
void setPedestalMode(int enable, uint8_t frames, uint16_t loops) { void setPedestalMode(int enable, uint8_t frames, uint16_t loops) {
// Note: loops is 8 bit in firmware as a bug.To be fixed in next version
int prevPedestalEnable = getPedestalMode(); int prevPedestalEnable = getPedestalMode();
uint32_t addr = PEDESTAL_MODE_REG; uint32_t addr = PEDESTAL_MODE_REG;

View File

@ -5,8 +5,8 @@
#include "sls/sls_detector_defs.h" #include "sls/sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x171220 #define MIN_REQRD_VRSN_T_RD_API 0x171220
#define REQRD_FRMWRE_VRSN_BOARD2 0x241001 // 1.0 pcb (version = 010) #define REQRD_FRMWRE_VRSN_BOARD2 0x230920 // 1.0 pcb (version = 010)
#define REQRD_FRMWRE_VRSN 0x241001 // 2.0 pcb (version = 011) #define REQRD_FRMWRE_VRSN 0x230921 // 2.0 pcb (version = 011)
#define NUM_HARDWARE_VERSIONS (2) #define NUM_HARDWARE_VERSIONS (2)
#define HARDWARE_VERSION_NUMBERS \ #define HARDWARE_VERSION_NUMBERS \
@ -62,6 +62,7 @@
#define DEFAULT_TIMING_INFO_DECODER (SWISSFEL) #define DEFAULT_TIMING_INFO_DECODER (SWISSFEL)
#define DEFAULT_ELECTRON_COLLECTION_MODE (0) #define DEFAULT_ELECTRON_COLLECTION_MODE (0)
#define MAX_PEDESTAL_LOOPS (0xFF) // until fixed in firmware
#define HIGHVOLTAGE_MIN (60) #define HIGHVOLTAGE_MIN (60)
#define HIGHVOLTAGE_MAX (200) #define HIGHVOLTAGE_MAX (200)
#define DAC_MIN_MV (0) #define DAC_MIN_MV (0)

View File

@ -9863,11 +9863,12 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
strcpy(mess, "Server name is the same as the symbolic link. Please " strcpy(mess, "Server name is the same as the symbolic link. Please "
"use a different server name\n"); "use a different server name\n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
Server_SendResult(file_des, INT32, NULL, 0);
} }
// in same folder as current process (will also work for virtual then // in same folder as current process (will also work for virtual then
// with write permissions) // with write permissions)
{ if (ret == OK) {
const int fileNameSize = 128; const int fileNameSize = 128;
char fname[fileNameSize]; char fname[fileNameSize];
if (getAbsPath(fname, fileNameSize, serverName) == FAIL) { if (getAbsPath(fname, fileNameSize, serverName) == FAIL) {
@ -11038,6 +11039,13 @@ int set_pedestal_mode(int file_des) {
"be 0. [%hhu, %hu].\n", "be 0. [%hhu, %hu].\n",
frames, loops); frames, loops);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else if (loops > MAX_PEDESTAL_LOOPS) {
ret = FAIL;
sprintf(mess,
"Could not set pedestal mode. Loops [%hu] cannot be "
"greater than %d.\n",
loops, MAX_PEDESTAL_LOOPS);
LOG(logERROR, (mess));
} else { } else {
setPedestalMode(enable, frames, loops); setPedestalMode(enable, frames, loops);
int retvalEnable = getPedestalMode(); int retvalEnable = getPedestalMode();

View File

@ -55,6 +55,7 @@ class Caller {
} }
std::vector<std::string> getAllCommands(); std::vector<std::string> getAllCommands();
std::map<std::string, std::string> GetDeprecatedCommands();
std::string list(int action); std::string list(int action);
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1) // THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1)

View File

@ -793,7 +793,7 @@ selinterface:
input_types: [ bool ] input_types: [ bool ]
udp_firstdst: udp_firstdst:
help: "\n[0 - 31 (or number of udp destinations)]\n\t[Jungfrau][Moench][Gotthard2]\n[0-63]\n\t[Mythen3]\n\n\t One can set which is the first destination that the detector will stream images out from in a round robin fashion. The entry must not have been empty. Default: 0" help: "\n\t[0 - N]\n\twhere N is the max number of udp destinations - 1.\n\t[Jungfrau][Moench][Gotthard2] Max number of udp destinations is 32.\n\t[Mythen3] Max number of udp destination is 64.\n\t One can set which is the first destination that the detector will stream images out from in a round robin fashion. The entry must not have been empty. Default: 0"
inherit_actions: INTEGER_COMMAND_VEC_ID inherit_actions: INTEGER_COMMAND_VEC_ID
actions: actions:
GET: GET:
@ -1074,7 +1074,7 @@ interruptsubframe:
input_types: [ bool ] input_types: [ bool ]
activate: activate:
help: "[0, 1] \n\t[Eiger] 1 is default. 0 deactivates readout and does not send data." help: "[0, 1]\n\t[Eiger] 1 is default. 0 deactivates readout and does not send data."
inherit_actions: INTEGER_COMMAND_VEC_ID inherit_actions: INTEGER_COMMAND_VEC_ID
actions: actions:
GET: GET:
@ -1779,7 +1779,7 @@ udp_validate:
clearroi: clearroi:
inherit_actions: EXECUTE_SET_COMMAND inherit_actions: EXECUTE_SET_COMMAND
help: "[Gotthard] Resets Region of interest in detector. All channels enabled. Default is all channels enabled." help: "\n\t[Gotthard] Resets Region of interest in detector. All channels enabled. Default is all channels enabled."
actions: actions:
PUT: PUT:
function: clearROI function: clearROI
@ -2034,7 +2034,7 @@ framecounter:
################# GET_COMMAND_HEX ############################ ################# GET_COMMAND_HEX ############################
serialnumber: serialnumber:
inherit_actions: GET_COMMAND inherit_actions: GET_COMMAND
help: "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb]\nSerial number of detector." help: "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb]\n\tSerial number of detector."
actions: actions:
GET: GET:
function: getSerialNumber function: getSerialNumber
@ -3429,7 +3429,7 @@ udp_dstlist:
output: [ ToString(args) ] output: [ ToString(args) ]
txdelay: txdelay:
help: "[n_delay]\n\t[Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for all modules in the detector using the step size provided.Sets up \n\t\t[Eiger] txdelay_left to (2 * mod_index * n_delay), \n\t\t[Eiger] txdelay_right to ((2 * mod_index + 1) * n_delay) and \n\t\t[Eiger] txdelay_frame to (2 *num_modules * n_delay) \n\t\t[Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules * n_delay) \nfor every module." help: "[n_delay]\n\t[Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for all modules in the detector using the step size provided.Sets up \n\t[Eiger] txdelay_left to (2 * mod_index * n_delay), \n\t[Eiger] txdelay_right to ((2 * mod_index + 1) * n_delay) and \n\t[Eiger] txdelay_frame to (2 *num_modules * n_delay)\n\t[Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules * n_delay) for every module."
actions: actions:
GET: GET:
argc: 0 argc: 0
@ -3963,7 +3963,7 @@ patloop:
output: [level,"' '" , "'['" , "ToStringHex(start, 4)" , '", "' , "ToStringHex(stop, 4)", "']'" ] output: [level,"' '" , "'['" , "ToStringHex(start, 4)" , '", "' , "ToStringHex(stop, 4)", "']'" ]
patloop0: patloop0:
help: "Deprecated command. Use patloop." help: "\n\tDeprecated command. Use patloop."
inherit_actions: patloop inherit_actions: patloop
actions: actions:
GET: GET:
@ -4010,7 +4010,7 @@ patnloop:
output: [ level,"' '" , nloops ] output: [ level,"' '" , nloops ]
patnloop0: patnloop0:
help: "Deprecated command. Use patnloop." help: "\n\tDeprecated command. Use patnloop."
inherit_actions: patnloop inherit_actions: patnloop
actions: actions:
GET: GET:
@ -4056,7 +4056,7 @@ patwait:
output: [level,"' '" , "ToStringHex(addr, 4)" ] output: [level,"' '" , "ToStringHex(addr, 4)" ]
patwait0: patwait0:
help: "Deprecated command. Use patwait." help: "\n\tDeprecated command. Use patwait."
inherit_actions: patwait inherit_actions: patwait
actions: actions:
GET: GET:
@ -4102,7 +4102,7 @@ patwaittime:
output: [level,"' '" , "waittime" ] output: [level,"' '" , "waittime" ]
patwaittime0: patwaittime0:
help: "Deprecated command. Use patwaittime." help: "\n\tDeprecated command. Use patwaittime."
inherit_actions: patwaittime inherit_actions: patwaittime
actions: actions:
GET: GET:

View File

@ -67,8 +67,7 @@ activate:
store_result_in_t: false store_result_in_t: false
command_name: activate command_name: activate
function_alias: activate function_alias: activate
help: "[0, 1] \n\t[Eiger] 1 is default. 0 deactivates readout and does not send\ help: "[0, 1]\n\t[Eiger] 1 is default. 0 deactivates readout and does not send data."
\ data."
infer_action: true infer_action: true
template: true template: true
adcclk: adcclk:
@ -1206,8 +1205,8 @@ clearroi:
store_result_in_t: false store_result_in_t: false
command_name: clearroi command_name: clearroi
function_alias: clearroi function_alias: clearroi
help: '[Gotthard] Resets Region of interest in detector. All channels enabled. Default help: "\n\t[Gotthard] Resets Region of interest in detector. All channels enabled.\
is all channels enabled.' \ Default is all channels enabled."
infer_action: true infer_action: true
template: true template: true
clientversion: clientversion:
@ -6078,7 +6077,7 @@ patloop0:
store_result_in_t: false store_result_in_t: false
command_name: patloop0 command_name: patloop0
function_alias: patloop0 function_alias: patloop0
help: Deprecated command. Use patloop. help: "\n\tDeprecated command. Use patloop."
infer_action: true infer_action: true
patloop1: patloop1:
actions: actions:
@ -6147,7 +6146,7 @@ patloop1:
store_result_in_t: false store_result_in_t: false
command_name: patloop1 command_name: patloop1
function_alias: patloop1 function_alias: patloop1
help: Deprecated command. Use patloop. help: "\n\tDeprecated command. Use patloop."
infer_action: true infer_action: true
patloop2: patloop2:
actions: actions:
@ -6216,7 +6215,7 @@ patloop2:
store_result_in_t: false store_result_in_t: false
command_name: patloop2 command_name: patloop2
function_alias: patloop2 function_alias: patloop2
help: Deprecated command. Use patloop. help: "\n\tDeprecated command. Use patloop."
infer_action: true infer_action: true
patmask: patmask:
actions: actions:
@ -6377,7 +6376,7 @@ patnloop0:
store_result_in_t: false store_result_in_t: false
command_name: patnloop0 command_name: patnloop0
function_alias: patnloop0 function_alias: patnloop0
help: Deprecated command. Use patnloop. help: "\n\tDeprecated command. Use patnloop."
infer_action: true infer_action: true
patnloop1: patnloop1:
actions: actions:
@ -6435,7 +6434,7 @@ patnloop1:
store_result_in_t: false store_result_in_t: false
command_name: patnloop1 command_name: patnloop1
function_alias: patnloop1 function_alias: patnloop1
help: Deprecated command. Use patnloop. help: "\n\tDeprecated command. Use patnloop."
infer_action: true infer_action: true
patnloop2: patnloop2:
actions: actions:
@ -6493,7 +6492,7 @@ patnloop2:
store_result_in_t: false store_result_in_t: false
command_name: patnloop2 command_name: patnloop2
function_alias: patnloop2 function_alias: patnloop2
help: Deprecated command. Use patnloop. help: "\n\tDeprecated command. Use patnloop."
infer_action: true infer_action: true
patsetbit: patsetbit:
actions: actions:
@ -6700,7 +6699,7 @@ patwait0:
store_result_in_t: false store_result_in_t: false
command_name: patwait0 command_name: patwait0
function_alias: patwait0 function_alias: patwait0
help: Deprecated command. Use patwait. help: "\n\tDeprecated command. Use patwait."
infer_action: true infer_action: true
patwait1: patwait1:
actions: actions:
@ -6758,7 +6757,7 @@ patwait1:
store_result_in_t: false store_result_in_t: false
command_name: patwait1 command_name: patwait1
function_alias: patwait1 function_alias: patwait1
help: Deprecated command. Use patwait. help: "\n\tDeprecated command. Use patwait."
infer_action: true infer_action: true
patwait2: patwait2:
actions: actions:
@ -6816,7 +6815,7 @@ patwait2:
store_result_in_t: false store_result_in_t: false
command_name: patwait2 command_name: patwait2
function_alias: patwait2 function_alias: patwait2
help: Deprecated command. Use patwait. help: "\n\tDeprecated command. Use patwait."
infer_action: true infer_action: true
patwaittime: patwaittime:
actions: actions:
@ -6937,7 +6936,7 @@ patwaittime0:
store_result_in_t: false store_result_in_t: false
command_name: patwaittime0 command_name: patwaittime0
function_alias: patwaittime0 function_alias: patwaittime0
help: Deprecated command. Use patwaittime. help: "\n\tDeprecated command. Use patwaittime."
infer_action: true infer_action: true
patwaittime1: patwaittime1:
actions: actions:
@ -6995,7 +6994,7 @@ patwaittime1:
store_result_in_t: false store_result_in_t: false
command_name: patwaittime1 command_name: patwaittime1
function_alias: patwaittime1 function_alias: patwaittime1
help: Deprecated command. Use patwaittime. help: "\n\tDeprecated command. Use patwaittime."
infer_action: true infer_action: true
patwaittime2: patwaittime2:
actions: actions:
@ -7053,7 +7052,7 @@ patwaittime2:
store_result_in_t: false store_result_in_t: false
command_name: patwaittime2 command_name: patwaittime2
function_alias: patwaittime2 function_alias: patwaittime2
help: Deprecated command. Use patwaittime. help: "\n\tDeprecated command. Use patwaittime."
infer_action: true infer_action: true
patword: patword:
actions: actions:
@ -9754,7 +9753,7 @@ serialnumber:
store_result_in_t: true store_result_in_t: true
command_name: serialnumber command_name: serialnumber
function_alias: serialnumber function_alias: serialnumber
help: "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb]\nSerial number\ help: "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb]\n\tSerial number\
\ of detector." \ of detector."
infer_action: true infer_action: true
template: true template: true
@ -11913,11 +11912,11 @@ txdelay:
command_name: txdelay command_name: txdelay
function_alias: txdelay function_alias: txdelay
help: "[n_delay]\n\t[Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for\ help: "[n_delay]\n\t[Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for\
\ all modules in the detector using the step size provided.Sets up \n\t\t[Eiger]\ \ all modules in the detector using the step size provided.Sets up \n\t[Eiger]\
\ txdelay_left to (2 * mod_index * n_delay), \n\t\t[Eiger] txdelay_right to ((2\ \ txdelay_left to (2 * mod_index * n_delay), \n\t[Eiger] txdelay_right to ((2\
\ * mod_index + 1) * n_delay) and \n\t\t[Eiger] txdelay_frame to (2 *num_modules\ \ * mod_index + 1) * n_delay) and \n\t[Eiger] txdelay_frame to (2 *num_modules\
\ * n_delay) \n\t\t[Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules\ \ * n_delay)\n\t[Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules * n_delay)\
\ * n_delay) \nfor every module." \ for every module."
infer_action: true infer_action: true
txdelay_frame: txdelay_frame:
actions: actions:
@ -12417,10 +12416,11 @@ udp_firstdst:
store_result_in_t: false store_result_in_t: false
command_name: udp_firstdst command_name: udp_firstdst
function_alias: udp_firstdst function_alias: udp_firstdst
help: "\n[0 - 31 (or number of udp destinations)]\n\t[Jungfrau][Moench][Gotthard2]\n\ help: "\n\t[0 - N]\n\twhere N is the max number of udp destinations - 1.\n\t[Jungfrau][Moench][Gotthard2]\
[0-63]\n\t[Mythen3]\n\n\t One can set which is the first destination that the\ \ Max number of udp destinations is 32.\n\t[Mythen3] Max number of udp destination\
\ detector will stream images out from in a round robin fashion. The entry must\ \ is 64.\n\t One can set which is the first destination that the detector will\
\ not have been empty. Default: 0" \ stream images out from in a round robin fashion. The entry must not have been\
\ empty. Default: 0"
infer_action: true infer_action: true
template: true template: true
udp_numdst: udp_numdst:

View File

@ -60,7 +60,6 @@ def generate(
if command["help"].startswith('code:'): if command["help"].startswith('code:'):
codegen.write_line(command["help"].strip('code:')) codegen.write_line(command["help"].strip('code:'))
else: else:
codegen.write_line(f'os << "Command: {command_name}" << std::endl;')
codegen.write_line(f'os << R"V0G0N({command["help"]} )V0G0N" << std::endl;') codegen.write_line(f'os << R"V0G0N({command["help"]} )V0G0N" << std::endl;')
codegen.write_line('return os.str();') codegen.write_line('return os.str();')

View File

@ -28,7 +28,7 @@ The dump.json is the AST of the file `slsDetectorPackage/slsSupportLib/src/ToStr
```sh ```sh
# to generate the dump.json file # to generate the dump.json file
cd slsSupportLib/src cd slsSupportLib/src
clang++ -Xclang -ast-dump=json -Xclang -ast-dump-filter -Xclang StringTo -c ToString.cpp -I ../include/ -std=gnu++11 > ../../slsDetectorSoftware/generator/autocomplete/dump.json clang++ -Xclang -ast-dump=json -Xclang -ast-dump-filter -Xclang StringTo -c ToString.cpp -I ../include/ -std=gnu++11 > ../../slsDetectorSoftware/generator/autocomplete/dump.json
# clang version used: 14.0.0-1ubuntu1.1 # clang version used: 14.0.0-1ubuntu1.1
``` ```

View File

@ -20,7 +20,7 @@ class IpAddr;
// Free function to avoid dependence on class // Free function to avoid dependence on class
// and avoid the option to free another objects // and avoid the option to free another objects
// shm by mistake // shm by mistake
void freeSharedMemory(int detectorIndex, int moduleIndex = -1); void freeSharedMemory(const int detectorIndex = 0, const int moduleIndex = -1);
/** /**
* \class Detector * \class Detector
@ -46,9 +46,13 @@ class Detector {
Detector(int shm_id = 0); Detector(int shm_id = 0);
~Detector(); ~Detector();
/** Free the shared memory of this detector and all modules // Disable copy since SharedMemory object is unique in DetectorImpl
belonging to it */ Detector(const Detector &other) = delete;
void freeSharedMemory(); Detector &operator=(const Detector &other) = delete;
// Move constructor and assignment operator
Detector(Detector &&other) noexcept;
Detector &operator=(Detector &&other) noexcept;
/** Frees shared memory before loading configuration file. Set up once /** Frees shared memory before loading configuration file. Set up once
normally */ normally */

File diff suppressed because it is too large Load Diff

View File

@ -55,6 +55,7 @@ class Caller {
} }
std::vector<std::string> getAllCommands(); std::vector<std::string> getAllCommands();
std::map<std::string, std::string> GetDeprecatedCommands();
std::string list(int action); std::string list(int action);
std::string acquire(int action); std::string acquire(int action);

View File

@ -16,6 +16,10 @@ std::vector<std::string> Caller::getAllCommands() {
return ret; return ret;
} }
std::map<std::string, std::string> Caller::GetDeprecatedCommands() {
return deprecated_functions;
}
void Caller::call(const std::string &command, void Caller::call(const std::string &command,
const std::vector<std::string> &arguments, int detector_id, const std::vector<std::string> &arguments, int detector_id,
int action, std::ostream &os, int receiver_id) { int action, std::ostream &os, int receiver_id) {
@ -63,12 +67,35 @@ bool Caller::ReplaceIfDeprecated(std::string &command) {
} }
std::string Caller::list(int action) { std::string Caller::list(int action) {
std::string ret = "free\n"; if (action == defs::HELP_ACTION) {
for (auto &f : functions) { return "[deprecated(optional)]\n\tlists all available commands, list "
ret += f.first + "\n"; "deprecated - list deprecated commands\n";
}
if (args.empty()) {
std::string ret = "free\n";
for (auto &f : functions) {
ret += f.first + "\n";
}
return ret;
} else if (args.size() == 1) {
if (args[0] == "deprecated") {
std::ostringstream os;
os << "The following " << deprecated_functions.size()
<< " commands are deprecated\n";
const size_t field_width = 20;
for (const auto &it : deprecated_functions) {
os << std::right << std::setw(field_width) << it.first << " -> "
<< it.second << '\n';
}
return os.str();
} else {
throw RuntimeError(
"Could not decode argument. Possible options: deprecated");
}
} else {
WrongNumberOfParameters(0);
return "";
} }
return ret;
} }
/* Network Configuration (Detector<->Receiver) */ /* Network Configuration (Detector<->Receiver) */

View File

@ -23,7 +23,7 @@
namespace sls { namespace sls {
void freeSharedMemory(int detectorIndex, int moduleIndex) { void freeSharedMemory(const int detectorIndex, const int moduleIndex) {
// single module // single module
if (moduleIndex >= 0) { if (moduleIndex >= 0) {
@ -34,10 +34,10 @@ void freeSharedMemory(int detectorIndex, int moduleIndex) {
return; return;
} }
// detector - multi module - get number of detectors from shm
SharedMemory<sharedDetector> detectorShm(detectorIndex, -1);
int numDetectors = 0; int numDetectors = 0;
// detector - multi module - get number of detectors from shm
SharedMemory<sharedDetector> detectorShm(detectorIndex, -1);
if (detectorShm.exists()) { if (detectorShm.exists()) {
detectorShm.openSharedMemory(false); detectorShm.openSharedMemory(false);
numDetectors = detectorShm()->totalNumberOfModules; numDetectors = detectorShm()->totalNumberOfModules;
@ -58,15 +58,19 @@ void freeSharedMemory(int detectorIndex, int moduleIndex) {
using defs = slsDetectorDefs; using defs = slsDetectorDefs;
Detector::Detector(int shm_id) : pimpl(make_unique<DetectorImpl>(shm_id)) {} Detector::Detector(int shm_id) : pimpl(make_unique<DetectorImpl>(shm_id)) {}
Detector::~Detector() = default; Detector::~Detector() = default;
// Move constructor
Detector::Detector(Detector &&other) noexcept = default;
// Move assignment operator
Detector &Detector::operator=(Detector &&other) noexcept = default;
// Configuration // Configuration
void Detector::freeSharedMemory() { pimpl->freeSharedMemory(); }
void Detector::loadConfig(const std::string &fname) { void Detector::loadConfig(const std::string &fname) {
int shm_id = getShmId(); int shm_id = getShmId();
freeSharedMemory(); freeSharedMemory(shm_id);
pimpl = make_unique<DetectorImpl>(shm_id); pimpl = make_unique<DetectorImpl>(shm_id);
LOG(logINFO) << "Loading configuration file: " << fname; LOG(logINFO) << "Loading configuration file: " << fname;
loadParameters(fname); loadParameters(fname);
@ -105,13 +109,30 @@ Result<std::string> Detector::getHostname(Positions pos) const {
} }
void Detector::setHostname(const std::vector<std::string> &hostname) { void Detector::setHostname(const std::vector<std::string> &hostname) {
if (pimpl->hasModulesInSharedMemory()) {
LOG(logWARNING) << "There are already module(s) in shared memory."
"Freeing Shared memory now.";
auto numChannels = getDetectorSize();
auto initialChecks = getInitialChecks();
freeSharedMemory(getShmId());
pimpl = make_unique<DetectorImpl>(getShmId());
setDetectorSize(numChannels);
setInitialChecks(initialChecks);
}
pimpl->setHostname(hostname); pimpl->setHostname(hostname);
} }
void Detector::setVirtualDetectorServers(int numServers, void Detector::setVirtualDetectorServers(int numServers,
uint16_t startingPort) { uint16_t startingPort) {
validatePortRange(startingPort, numServers * 2); validatePortRange(startingPort, numServers * 2);
pimpl->setVirtualDetectorServers(numServers, startingPort);
std::vector<std::string> hostnames;
for (int i = 0; i < numServers; ++i) {
// * 2 is for control and stop port
hostnames.push_back(std::string("localhost:") +
std::to_string(startingPort + i * 2));
}
setHostname(hostnames);
} }
int Detector::getShmId() const { return pimpl->getDetectorIndex(); } int Detector::getShmId() const { return pimpl->getDetectorIndex(); }

View File

@ -37,8 +37,6 @@ DetectorImpl::DetectorImpl(int detector_index, bool verify, bool update)
setupDetector(verify, update); setupDetector(verify, update);
} }
DetectorImpl::~DetectorImpl() = default;
void DetectorImpl::setupDetector(bool verify, bool update) { void DetectorImpl::setupDetector(bool verify, bool update) {
initSharedMemory(verify); initSharedMemory(verify);
initializeMembers(verify); initializeMembers(verify);
@ -59,51 +57,6 @@ void DetectorImpl::setAcquiringFlag(bool flag) { shm()->acquiringFlag = flag; }
int DetectorImpl::getDetectorIndex() const { return detectorIndex; } int DetectorImpl::getDetectorIndex() const { return detectorIndex; }
void DetectorImpl::freeSharedMemory(int detectorIndex, int detPos) {
// single
if (detPos >= 0) {
SharedMemory<sharedModule> moduleShm(detectorIndex, detPos);
if (moduleShm.exists()) {
moduleShm.removeSharedMemory();
}
return;
}
// multi - get number of modules from shm
SharedMemory<sharedDetector> detectorShm(detectorIndex, -1);
int numModules = 0;
if (detectorShm.exists()) {
detectorShm.openSharedMemory(false);
numModules = detectorShm()->totalNumberOfModules;
detectorShm.removeSharedMemory();
}
for (int i = 0; i < numModules; ++i) {
SharedMemory<sharedModule> moduleShm(detectorIndex, i);
moduleShm.removeSharedMemory();
}
SharedMemory<CtbConfig> ctbShm(detectorIndex, -1, CtbConfig::shm_tag());
if (ctbShm.exists())
ctbShm.removeSharedMemory();
}
void DetectorImpl::freeSharedMemory() {
zmqSocket.clear();
for (auto &module : modules) {
module->freeSharedMemory();
}
modules.clear();
// clear detector shm
shm.removeSharedMemory();
client_downstream = false;
if (ctb_shm.exists())
ctb_shm.removeSharedMemory();
}
std::string DetectorImpl::getUserDetails() { std::string DetectorImpl::getUserDetails() {
if (modules.empty()) { if (modules.empty()) {
return std::string("none"); return std::string("none");
@ -242,24 +195,11 @@ std::string DetectorImpl::exec(const char *cmd) {
return result; return result;
} }
void DetectorImpl::setVirtualDetectorServers(const int numdet, bool DetectorImpl::hasModulesInSharedMemory() {
const uint16_t port) { return (shm.exists() && shm()->totalNumberOfModules > 0);
std::vector<std::string> hostnames;
for (int i = 0; i < numdet; ++i) {
// * 2 is for control and stop port
hostnames.push_back(std::string("localhost:") +
std::to_string(port + i * 2));
}
setHostname(hostnames);
} }
void DetectorImpl::setHostname(const std::vector<std::string> &name) { void DetectorImpl::setHostname(const std::vector<std::string> &name) {
// do not free always to allow the previous detsize/ initialchecks command
if (shm.exists() && shm()->totalNumberOfModules != 0) {
LOG(logWARNING) << "There are already module(s) in shared memory."
"Freeing Shared memory now.";
freeSharedMemory();
}
// could be called after freeing shm from API // could be called after freeing shm from API
if (!shm.exists()) { if (!shm.exists()) {
setupDetector(); setupDetector();
@ -292,8 +232,8 @@ void DetectorImpl::addModule(const std::string &name) {
// gotthard cannot have more than 2 modules (50um=1, 25um=2 // gotthard cannot have more than 2 modules (50um=1, 25um=2
if ((type == GOTTHARD || type == GOTTHARD2) && modules.size() > 2) { if ((type == GOTTHARD || type == GOTTHARD2) && modules.size() > 2) {
freeSharedMemory(); throw RuntimeError("Gotthard cannot have more than 2 modules. Please "
throw RuntimeError("Gotthard cannot have more than 2 modules"); "free the shared memory and start again.");
} }
auto pos = modules.size(); auto pos = modules.size();
@ -390,7 +330,8 @@ slsDetectorDefs::xy DetectorImpl::getNumberOfChannels() const {
} }
void DetectorImpl::setNumberOfChannels(const slsDetectorDefs::xy c) { void DetectorImpl::setNumberOfChannels(const slsDetectorDefs::xy c) {
if (size() > 1) { // detsize is set before hostname
if (size() >= 1) {
throw RuntimeError( throw RuntimeError(
"Set the number of channels before setting hostname."); "Set the number of channels before setting hostname.");
} }
@ -616,7 +557,7 @@ void DetectorImpl::readFrameFromReceiver() {
memset(multiframe.get(), 0xFF, multisize); memset(multiframe.get(), 0xFF, multisize);
} }
completeImage = (numZmqRunning == (int)zmqSocket.size()); completeImage = true;
// get each frame // get each frame
for (unsigned int isocket = 0; isocket < zmqSocket.size(); ++isocket) { for (unsigned int isocket = 0; isocket < zmqSocket.size(); ++isocket) {
@ -633,7 +574,6 @@ void DetectorImpl::readFrameFromReceiver() {
// parse error, version error or end of acquisition for // parse error, version error or end of acquisition for
// socket // socket
runningList[isocket] = false; runningList[isocket] = false;
completeImage = false;
--numZmqRunning; --numZmqRunning;
continue; continue;
} }

View File

@ -5,6 +5,7 @@
#include "CtbConfig.h" #include "CtbConfig.h"
#include "SharedMemory.h" #include "SharedMemory.h"
#include "sls/Result.h" #include "sls/Result.h"
#include "sls/ZmqSocket.h"
#include "sls/logger.h" #include "sls/logger.h"
#include "sls/sls_detector_defs.h" #include "sls/sls_detector_defs.h"
@ -19,7 +20,6 @@
namespace sls { namespace sls {
class ZmqSocket;
class detectorData; class detectorData;
class Module; class Module;
@ -79,11 +79,6 @@ class DetectorImpl : public virtual slsDetectorDefs {
explicit DetectorImpl(int detector_index = 0, bool verify = true, explicit DetectorImpl(int detector_index = 0, bool verify = true,
bool update = true); bool update = true);
/**
* Destructor
*/
virtual ~DetectorImpl();
template <class CT> struct NonDeduced { using type = CT; }; template <class CT> struct NonDeduced { using type = CT; };
template <typename RT, typename... CT> template <typename RT, typename... CT>
Result<RT> Parallel(RT (Module::*somefunc)(CT...), Result<RT> Parallel(RT (Module::*somefunc)(CT...),
@ -198,14 +193,6 @@ class DetectorImpl : public virtual slsDetectorDefs {
/** return detector index in shared memory */ /** return detector index in shared memory */
int getDetectorIndex() const; int getDetectorIndex() const;
/** Free specific shared memory from the command line without creating
* object */
static void freeSharedMemory(int detectorIndex, int detPos = -1);
/** Free all modules from current multi Id shared memory and delete members
*/
void freeSharedMemory();
/** Get user details of shared memory */ /** Get user details of shared memory */
std::string getUserDetails(); std::string getUserDetails();
@ -215,12 +202,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
* default enabled */ * default enabled */
void setInitialChecks(const bool value); void setInitialChecks(const bool value);
/** bool hasModulesInSharedMemory();
* Connect to Virtual Detector Servers at local host
* @param numdet number of modules
* @param port starting port number
*/
void setVirtualDetectorServers(const int numdet, const uint16_t port);
/** Sets the hostname of all sls modules in shared memory and updates /** Sets the hostname of all sls modules in shared memory and updates
* local cache */ * local cache */
@ -452,7 +434,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
/** data streaming (down stream) enabled in client (zmq sckets created) */ /** data streaming (down stream) enabled in client (zmq sckets created) */
bool client_downstream{false}; bool client_downstream{false};
std::vector<std::unique_ptr<ZmqSocket>> zmqSocket; std::vector<std::unique_ptr<ZmqSocket>> zmqSocket;
volatile int numZmqRunning{0}; std::atomic<int> numZmqRunning{0};
/** mutex to synchronize main and data processing threads */ /** mutex to synchronize main and data processing threads */
mutable std::mutex mp; mutable std::mutex mp;

View File

@ -53,14 +53,6 @@ Module::Module(int det_id, int module_index, bool verify)
initSharedMemory(type, det_id, verify); initSharedMemory(type, det_id, verify);
} }
Module::~Module() = default;
void Module::freeSharedMemory() {
if (shm.exists()) {
shm.removeSharedMemory();
}
}
bool Module::isFixedPatternSharedMemoryCompatible() const { bool Module::isFixedPatternSharedMemoryCompatible() const {
return (shm()->shmversion >= MODULE_SHMAPIVERSION); return (shm()->shmversion >= MODULE_SHMAPIVERSION);
} }

View File

@ -75,12 +75,6 @@ class Module : public virtual slsDetectorDefs {
verify is if shared memory version matches existing one */ verify is if shared memory version matches existing one */
explicit Module(int det_id = 0, int module_index = 0, bool verify = true); explicit Module(int det_id = 0, int module_index = 0, bool verify = true);
virtual ~Module();
/** Frees shared memory and deletes shared memory structure
Safe to call only if detector shm also deleted or its numberOfModules is
updated */
void freeSharedMemory();
bool isFixedPatternSharedMemoryCompatible() const; bool isFixedPatternSharedMemoryCompatible() const;
std::string getHostname() const; std::string getHostname() const;

View File

@ -33,6 +33,7 @@ target_sources(tests PRIVATE
target_include_directories(tests target_include_directories(tests
PUBLIC PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include/sls>"
PRIVATE PRIVATE
${SLS_INTERNAL_RAPIDJSON_DIR} ${SLS_INTERNAL_RAPIDJSON_DIR}
) )

View File

@ -530,13 +530,14 @@ TEST_CASE("pedestalmode", "[.cmdcall]") {
REQUIRE_THROWS(caller.call("pedestalmode", {"256", "10"}, -1, PUT)); REQUIRE_THROWS(caller.call("pedestalmode", {"256", "10"}, -1, PUT));
REQUIRE_THROWS(caller.call("pedestalmode", {"-1", "10"}, 0, PUT)); REQUIRE_THROWS(caller.call("pedestalmode", {"-1", "10"}, 0, PUT));
REQUIRE_THROWS(caller.call("pedestalmode", {"20", "65536"}, 0, PUT)); REQUIRE_THROWS(caller.call("pedestalmode", {"20", "1000"}, 0, PUT));
REQUIRE_THROWS(caller.call("pedestalmode", {"2000", "100"}, 0, PUT));
REQUIRE_THROWS(caller.call("pedestalmode", {"20", "-1"}, 0, PUT)); REQUIRE_THROWS(caller.call("pedestalmode", {"20", "-1"}, 0, PUT));
{ {
std::ostringstream oss; std::ostringstream oss;
caller.call("pedestalmode", {"30", "1000"}, -1, PUT, oss); caller.call("pedestalmode", {"30", "100"}, -1, PUT, oss);
REQUIRE(oss.str() == "pedestalmode [30, 1000]\n"); REQUIRE(oss.str() == "pedestalmode [30, 100]\n");
} }
// cannot change any of these in pedestal mode // cannot change any of these in pedestal mode
REQUIRE_THROWS_WITH(caller.call("frames", {"200"}, -1, PUT), REQUIRE_THROWS_WITH(caller.call("frames", {"200"}, -1, PUT),
@ -563,20 +564,20 @@ TEST_CASE("pedestalmode", "[.cmdcall]") {
{ {
std::ostringstream oss; std::ostringstream oss;
caller.call("pedestalmode", {"50", "500"}, -1, PUT, oss); caller.call("pedestalmode", {"50", "100"}, -1, PUT, oss);
REQUIRE(oss.str() == "pedestalmode [50, 500]\n"); REQUIRE(oss.str() == "pedestalmode [50, 100]\n");
} }
{ {
std::ostringstream oss; std::ostringstream oss;
caller.call("pedestalmode", {}, -1, GET, oss); caller.call("pedestalmode", {}, -1, GET, oss);
REQUIRE(oss.str() == "pedestalmode [enabled, 50, 500]\n"); REQUIRE(oss.str() == "pedestalmode [enabled, 50, 100]\n");
} }
{ {
auto pedemode = det.getPedestalMode().tsquash( auto pedemode = det.getPedestalMode().tsquash(
"Inconsistent pedestal mode to test"); "Inconsistent pedestal mode to test");
REQUIRE(pedemode.enable == true); REQUIRE(pedemode.enable == true);
REQUIRE(pedemode.frames == 50); REQUIRE(pedemode.frames == 50);
REQUIRE(pedemode.loops == 500); REQUIRE(pedemode.loops == 100);
} }
{ {
std::ostringstream oss; std::ostringstream oss;
@ -590,7 +591,7 @@ TEST_CASE("pedestalmode", "[.cmdcall]") {
} }
uint8_t pedestalFrames = 50; uint8_t pedestalFrames = 50;
uint16_t pedestalLoops = 1000; uint16_t pedestalLoops = 100;
int64_t expNumFrames = pedestalFrames * pedestalLoops * 2; int64_t expNumFrames = pedestalFrames * pedestalLoops * 2;
auto origFrames = det.getNumberOfFrames().squash(-1); auto origFrames = det.getNumberOfFrames().squash(-1);
auto origTriggers = det.getNumberOfTriggers().squash(-1); auto origTriggers = det.getNumberOfTriggers().squash(-1);
@ -671,11 +672,11 @@ TEST_CASE("timing_info_decoder", "[.cmdcall]") {
Caller caller(&det); Caller caller(&det);
if (det.getDetectorType().squash() == defs::JUNGFRAU) { if (det.getDetectorType().squash() == defs::JUNGFRAU) {
auto prev_val = det.getTimingInfoDecoder(); auto prev_val = det.getTimingInfoDecoder();
{ /*{
std::ostringstream oss; std::ostringstream oss;
caller.call("timing_info_decoder", {"shine"}, -1, PUT, oss); caller.call("timing_info_decoder", {"shine"}, -1, PUT, oss);
REQUIRE(oss.str() == "timing_info_decoder shine\n"); REQUIRE(oss.str() == "timing_info_decoder shine\n");
} }*/
{ {
std::ostringstream oss; std::ostringstream oss;
caller.call("timing_info_decoder", {"swissfel"}, -1, PUT, oss); caller.call("timing_info_decoder", {"swissfel"}, -1, PUT, oss);

View File

@ -1,5 +1,6 @@
// SPDX-License-Identifier: LGPL-3.0-or-other // SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
#include "Detector.h"
#include "Module.h" #include "Module.h"
#include "SharedMemory.h" #include "SharedMemory.h"
#include "catch.hpp" #include "catch.hpp"
@ -10,7 +11,9 @@ using dt = slsDetectorDefs::detectorType;
TEST_CASE("Construction with a defined detector type") { TEST_CASE("Construction with a defined detector type") {
Module m(dt::EIGER); Module m(dt::EIGER);
REQUIRE(m.getDetectorType() == dt::EIGER); REQUIRE(m.getDetectorType() == dt::EIGER);
m.freeSharedMemory(); // clean up freeSharedMemory(0, 0); // clean up
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
} }
TEST_CASE("Read back detector type from shm") { TEST_CASE("Read back detector type from shm") {
@ -23,7 +26,9 @@ TEST_CASE("Read back detector type from shm") {
// Now both objects point to the same shm so we can only // Now both objects point to the same shm so we can only
// free one! // free one!
m2.freeSharedMemory(); freeSharedMemory(0, 0);
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
} }
TEST_CASE("Is shm fixed pattern shm compatible") { TEST_CASE("Is shm fixed pattern shm compatible") {
@ -41,25 +46,33 @@ TEST_CASE("Is shm fixed pattern shm compatible") {
// Should fail since version is set to 0 // Should fail since version is set to 0
REQUIRE(m.isFixedPatternSharedMemoryCompatible() == false); REQUIRE(m.isFixedPatternSharedMemoryCompatible() == false);
m.freeSharedMemory(); freeSharedMemory(0, 0);
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
} }
TEST_CASE("Get default control port") { TEST_CASE("Get default control port") {
Module m(dt::MYTHEN3); Module m(dt::MYTHEN3);
REQUIRE(m.getControlPort() == 1952); REQUIRE(m.getControlPort() == 1952);
m.freeSharedMemory(); freeSharedMemory(0, 0);
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
} }
TEST_CASE("Get default stop port") { TEST_CASE("Get default stop port") {
Module m(dt::GOTTHARD2); Module m(dt::GOTTHARD2);
REQUIRE(m.getStopPort() == 1953); REQUIRE(m.getStopPort() == 1953);
m.freeSharedMemory(); freeSharedMemory(0, 0);
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
} }
TEST_CASE("Get default receiver TCP port") { TEST_CASE("Get default receiver TCP port") {
Module m(dt::MYTHEN3); Module m(dt::MYTHEN3);
REQUIRE(m.getReceiverPort() == 1954); REQUIRE(m.getReceiverPort() == 1954);
m.freeSharedMemory(); freeSharedMemory(0, 0);
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
} }
} // namespace sls } // namespace sls

View File

@ -11,10 +11,11 @@
*@short constructs the fifo structure *@short constructs the fifo structure
*/ */
#include "sls/CircularFifo.h"
#include "sls/logger.h" #include "sls/logger.h"
#include "sls/sls_detector_defs.h" #include "sls/sls_detector_defs.h"
#include "sls/CircularFifo.h" #include <atomic>
namespace sls { namespace sls {
@ -49,8 +50,8 @@ class Fifo : private virtual slsDetectorDefs {
CircularFifo<char> *fifoFree; CircularFifo<char> *fifoFree;
CircularFifo<char> *fifoStream; CircularFifo<char> *fifoStream;
int fifoDepth; int fifoDepth;
volatile int status_fifoBound; std::atomic<int> status_fifoBound;
volatile int status_fifoFree; std::atomic<int> status_fifoFree;
}; };
} // namespace sls } // namespace sls

View File

@ -2,13 +2,13 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */ /** API versions */
#define RELEASE "developer" #define RELEASE "developer"
#define APILIB "developer 0x230224"
#define APIRECEIVER "developer 0x230224"
#define APICTB "developer 0x240918" #define APICTB "developer 0x240918"
#define APIGOTTHARD "developer 0x240918" #define APIGOTTHARD "developer 0x240918"
#define APIMOENCH "developer 0x240918" #define APIMOENCH "developer 0x240918"
#define APIXILINXCTB "developer 0x240918" #define APIXILINXCTB "developer 0x240918"
#define APIEIGER "developer 0x240918" #define APIEIGER "developer 0x240918"
#define APIMYTHEN3 "developer 0x241001" #define APIMYTHEN3 "developer 0x241001"
#define APIJUNGFRAU "developer 0x241001" #define APIRECEIVER "developer 0x241014"
#define APIGOTTHARD2 "developer 0x241007" #define APILIB "developer 0x241021"
#define APIGOTTHARD2 "developer 0x241022"
#define APIJUNGFRAU "developer 0x241024"

View File

@ -51,6 +51,20 @@ def killProcess(name):
else: else:
print('process not running : ' + name) print('process not running : ' + name)
def killAllStaleProcesses():
killProcess('eigerDetectorServer_virtual')
killProcess('jungfrauDetectorServer_virtual')
killProcess('mythen3DetectorServer_virtual')
killProcess('gotthard2DetectorServer_virtual')
killProcess('gotthardDetectorServer_virtual')
killProcess('ctbDetectorServer_virtual')
killProcess('moenchDetectorServer_virtual')
killProcess('xilinx_ctbDetectorServer_virtual')
killProcess('slsReceiver')
killProcess('slsMultiReceiver')
cleanSharedmemory()
def cleanup(name): def cleanup(name):
''' '''
kill both servers, receivers and clean shared memory kill both servers, receivers and clean shared memory
@ -202,6 +216,8 @@ with open(fname, 'w') as fp:
Log(Fore.BLUE, 'General tests (results: ' + file_results + ')') Log(Fore.BLUE, 'General tests (results: ' + file_results + ')')
startGeneralTests(fp, file_results) startGeneralTests(fp, file_results)
killAllStaleProcesses()
for server in servers: for server in servers:
try: try:
# print to terminal for progress # print to terminal for progress

1
zsh_autocomplete.sh Symbolic link
View File

@ -0,0 +1 @@
slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh