mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-14 13:57:13 +02:00
Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
cfbe3c86cc | |||
4b414bfddb | |||
5ab64efe3e | |||
bfe53c6693 | |||
c64e87a2b6 | |||
14e11e8b5b | |||
af3dc1e7f4 | |||
8174fc9691 | |||
d6eac6da71 | |||
9b9b09ceaf | |||
4613c54f57 | |||
58ac7ac280 | |||
82edfa75d3 | |||
b6ef3bc39e | |||
2035666792 | |||
1ff4d806e7 | |||
3861379653 | |||
91140bbb71 | |||
d44329117d | |||
6c67025ea8 | |||
37ce3d6f59 | |||
1484d038de | |||
fb0090c79e | |||
adc68cd519 | |||
1566eef247 | |||
e7cd90db78 | |||
45414149fe | |||
48759f440e | |||
b367b7e431 | |||
f0b2a6f6f9 |
@ -2,7 +2,7 @@
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(slsDetectorPackage)
|
||||
set(PROJECT_VERSION 7.0.2)
|
||||
set(PROJECT_VERSION 7.0.3)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
|
||||
|
160
RELEASE.txt
160
RELEASE.txt
@ -1,7 +1,7 @@
|
||||
SLS Detector Package Major Release 7.0.2 released on 12.07.2023
|
||||
SLS Detector Package Major Release 7.0.3 released on 14.11.2023
|
||||
===============================================================
|
||||
|
||||
This document describes the differences between v7.0.2 and v7.0.1
|
||||
This document describes the differences between v7.0.3 and v7.0.2
|
||||
|
||||
|
||||
|
||||
@ -22,72 +22,118 @@ This document describes the differences between v7.0.2 and v7.0.1
|
||||
Firmware
|
||||
--------
|
||||
|
||||
* [Jungfrau] Stopping acquisition in sync mode
|
||||
Previously, stopping acquisition in sync mode would result in the slave
|
||||
status remaining in Running status for next acquisition and framesl (frames
|
||||
left) would be stuck from the previous acquisition. This is fixed in firmware.
|
||||
|
||||
|
||||
|
||||
Detector Server
|
||||
---------------
|
||||
|
||||
* [Jungfrau] Changing master to slave in sync mode
|
||||
When in sync mode, changing from master to slave would change the status
|
||||
to Running in firmware. A workaround in the detector server fixes this.
|
||||
|
||||
* [Jungfrau] Row and column for multi module Jungfrau
|
||||
This mainly affected only the GUI, unless one was using the row and column
|
||||
sent out by the detector. Row and column values were mixed up, but fixed now.
|
||||
|
||||
* [Jungfrau] Timing in sync mode
|
||||
When sync is enabled, setting or getting timing would give an error. This
|
||||
is fixed now.
|
||||
* [Eiger] Blocking trigger on quad
|
||||
Previously, blocking software trigger on a quad was not blocking. Fixed
|
||||
with firmware v32.
|
||||
|
||||
|
||||
Client
|
||||
------
|
||||
|
||||
* [Jungfrau] Multi module sync mode
|
||||
For start, stop and trigger acquisition, the procedure to start the slaves
|
||||
(or the master for stop acquisition) first had to be obeyed. This is fixed
|
||||
now.
|
||||
|
||||
|
||||
ZMQ
|
||||
---
|
||||
|
||||
* [Jungfrau][Gotthard2] Client ZMQ port when using 2 interfaces
|
||||
When switching between 1 and 2 interfaces, the client or gui zmq port
|
||||
was not set properly and resulted in dummy streaming forever. This is
|
||||
fixed now.
|
||||
|
||||
* Rx_roi
|
||||
This parameter is now also streamed in the zmq header to be able to use in
|
||||
external GUIs.
|
||||
* Limit port number max to 65535
|
||||
Previously, one could set the port numbers (TCP, UDP, ZMQ) to values
|
||||
higher than 65535 and also to 0. However, it was truncated to 16 bit
|
||||
in the background, but not relayed to the user.
|
||||
Now, it will throw if it is 0 or greater than 65535 (16 bit).
|
||||
|
||||
|
||||
GUI
|
||||
---
|
||||
* Stopping acqusition for a single or subset of modules
|
||||
The Detector API previously stopped all modules.
|
||||
Now, it takes into account which modules the user wanted to stop.
|
||||
|
||||
* [Jungfrau] Show Fix_G0 in expert mode
|
||||
Fix_G0 was only shown when expert mode was enabled from Settings Tab. Now,
|
||||
fixed to show when expert mode enabled from any tab.
|
||||
|
||||
* [Jungfrau] Stop in sync mode
|
||||
When stopping acquisition in sync mode, only the master module sometimes
|
||||
returns 'Idle' state instead of 'Stopped'. The software threw an
|
||||
exception for the different states then.
|
||||
Now, it does not throw and a fix will be added to the next firmware
|
||||
release for the different states (with SW release: v8.0.0).
|
||||
|
||||
|
||||
* [Eiger] Incorrect error message in Stop
|
||||
When stopping acquisition, if a half module were to give an error in a
|
||||
rare case while the others succeeded, this would result in an re-attempt
|
||||
to stop 9 more times before throwing an incorrect exception messsage that
|
||||
it could not stop.
|
||||
Now, it is handled and will throw an exception of the error status
|
||||
immediately.
|
||||
|
||||
|
||||
Receiver
|
||||
--------
|
||||
|
||||
|
||||
* Limit TCP port number (command line) to max of 65535
|
||||
Refer issue under 'Client'.
|
||||
|
||||
|
||||
Detector Simulator
|
||||
------------------
|
||||
|
||||
|
||||
* Limit TCP port number (command line) to max of 65535
|
||||
Refer issue under 'Client'.
|
||||
|
||||
|
||||
* Some commands such as 'readnrows' would complain that it cannot be set
|
||||
because the detector is not idle, but was setting it anyway. Fixed.
|
||||
|
||||
|
||||
Gui/ Client Callback
|
||||
--------------------
|
||||
|
||||
|
||||
* [Jungfrau] Gui: corrected color map of gain plot
|
||||
Previously, color on the gain plot did not update after the first image,
|
||||
unless there were x/y min/max changes or window resizing. Fixed.
|
||||
|
||||
|
||||
* [Jungfrau] Acquisition finished callback error status in sync mode
|
||||
When stopping acquisition in multi module Jungfrau sync mode,
|
||||
different status (master 'idle' and slaves 'stopped' in
|
||||
firmware 2.4.1 or 1.4.1) show as 'error' in acquisition finished call
|
||||
back (mainly used for gui). This is fixed.
|
||||
|
||||
|
||||
* [Jungfrau] Gui: Next frame number shown as 0 for inconsistency
|
||||
When stopping an acquisition in a multi module Jungfrau, the next
|
||||
frame numbers might be different, for which the Gui shows an error message
|
||||
but keeps the number as 0. Now, it is fixed to show -1 for inconsistency
|
||||
and error message shown. So, setting 0 will also prompt an error message
|
||||
that 0 is an invalid input.
|
||||
|
||||
|
||||
Data Processing
|
||||
---------------
|
||||
|
||||
|
||||
* [Moench] Segmentation fault with moench03RawDataPrcess
|
||||
Previously, it crashed when nframes > 0. Fixed.
|
||||
|
||||
|
||||
* [Moench] Interpolation issues fixed.
|
||||
|
||||
|
||||
* [Moench] When receiver in discard_partial mode and gets an empty frame,
|
||||
it sends a zmq packet with header and no data. This is handled in post
|
||||
processing as a temporary solution.
|
||||
|
||||
|
||||
|
||||
|
||||
2 On-board Detector Server Compatibility
|
||||
==========================================
|
||||
|
||||
|
||||
Eiger 7.0.0
|
||||
Jungfrau 7.0.2
|
||||
Mythen3 7.0.0
|
||||
Gotthard2 7.0.0
|
||||
Gotthard 7.0.0
|
||||
Moench 7.0.0
|
||||
Ctb 7.0.0
|
||||
Eiger 7.0.3
|
||||
Jungfrau 7.0.3
|
||||
Mythen3 7.0.3
|
||||
Gotthard2 7.0.3
|
||||
Gotthard 7.0.3
|
||||
Moench 7.0.3
|
||||
Ctb 7.0.3
|
||||
|
||||
|
||||
On-board Detector Server Upgrade
|
||||
@ -108,21 +154,21 @@ This document describes the differences between v7.0.2 and v7.0.1
|
||||
========================
|
||||
|
||||
|
||||
Eiger 20.02.2023 (v31)
|
||||
Eiger 02.10.2023 (v32) (updated in 7.0.3)
|
||||
|
||||
Jungfrau 16.05.2023 (v1.4.1, HW v1.0)
|
||||
15.05.2023 (v2.4.1, HW v2.0)
|
||||
Jungfrau 16.05.2023 (v1.4.1, HW v1.0) (updated in 7.0.2)
|
||||
15.05.2023 (v2.4.1, HW v2.0) (updated in 7.0.2)
|
||||
|
||||
Mythen3 24.01.2023 (v1.4)
|
||||
Mythen3 24.01.2023 (v1.4) (updated in 7.0.0)
|
||||
|
||||
Gotthard2 23.11.2022 (v0.3)
|
||||
Gotthard2 23.11.2022 (v0.3) (updated in 7.0.0)
|
||||
|
||||
Gotthard 08.02.2018 (50um and 25um Master)
|
||||
09.02.2018 (25 um Slave)
|
||||
|
||||
Moench 05.12.2022 (v0.3)
|
||||
Moench 05.12.2022 (v0.3) (updated in 7.0.0)
|
||||
|
||||
Ctb 05.12.2022 (v1.1)
|
||||
Ctb 05.12.2022 (v1.1) (updated in 7.0.0)
|
||||
|
||||
|
||||
Detector Upgrade
|
||||
|
@ -3,6 +3,5 @@ python:
|
||||
- 3.9
|
||||
- 3.10
|
||||
- 3.11
|
||||
- 3.12
|
||||
|
||||
numpy:
|
||||
- 1.17
|
||||
|
@ -3,33 +3,34 @@
|
||||
### edit with hostname or IP address of your detector
|
||||
############################################
|
||||
#hostname bchip181+
|
||||
hostname bchip135
|
||||
hostname bchip076
|
||||
|
||||
#############################################
|
||||
### edit with hostname or 1Gbs IP address of your server
|
||||
############################################
|
||||
rx_hostname mpc2011
|
||||
rx_hostname mpc2011:7777
|
||||
|
||||
#############################################
|
||||
### edit with 10 Gbs IP of your server
|
||||
############################################
|
||||
udp_dstip 10.1.1.102
|
||||
udp_dstip 10.1.2.102
|
||||
#############################################
|
||||
### edit with any number in the subnet of your server (first 3 numbers as above)
|
||||
############################################
|
||||
udp_srcip 10.1.1.19
|
||||
udp_dstport 32411
|
||||
udp_srcip 10.1.2.19
|
||||
udp_dstport 32777
|
||||
|
||||
|
||||
#############################################
|
||||
### edit with 10 Gbs IP of your server
|
||||
############################################
|
||||
rx_zmqip 10.1.1.102
|
||||
rx_zmqport 50003
|
||||
rx_zmqip 10.1.2.102
|
||||
rx_zmqport 9003
|
||||
#############################################
|
||||
### edit with 1 Gbs IP of PC where you will run the GUI
|
||||
############################################
|
||||
zmqip 129.129.202.57
|
||||
zmqport 50001
|
||||
zmqport 9005
|
||||
|
||||
|
||||
|
||||
@ -38,7 +39,7 @@ rx_zmqstream 1
|
||||
|
||||
|
||||
|
||||
frames 100000
|
||||
frames 1
|
||||
period 0.0006
|
||||
exptime 0.00035
|
||||
|
||||
@ -49,7 +50,7 @@ fpath /mnt/moench_data/scratch1/
|
||||
|
||||
fwrite 0
|
||||
|
||||
rx_jsonpara frameMode frame
|
||||
rx_jsonpara frameMode newPedestal
|
||||
rx_jsonpara detectorMode counting
|
||||
rx_discardpolicy discardpartial
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv7.0.0
|
1
serverBin/ctbDetectorServerv7.0.3
Symbolic link
1
serverBin/ctbDetectorServerv7.0.3
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv7.0.3
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv7.0.0
|
1
serverBin/eigerDetectorServerv7.0.3
Symbolic link
1
serverBin/eigerDetectorServerv7.0.3
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv7.0.3
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv7.0.0
|
1
serverBin/gotthard2DetectorServerv7.0.3
Symbolic link
1
serverBin/gotthard2DetectorServerv7.0.3
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv7.0.3
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv7.0.0
|
1
serverBin/gotthardDetectorServerv7.0.3
Symbolic link
1
serverBin/gotthardDetectorServerv7.0.3
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv7.0.3
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv7.0.2
|
1
serverBin/jungfrauDetectorServerv7.0.3
Symbolic link
1
serverBin/jungfrauDetectorServerv7.0.3
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv7.0.3
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv7.0.0
|
1
serverBin/moenchDetectorServerv7.0.3
Symbolic link
1
serverBin/moenchDetectorServerv7.0.3
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv7.0.3
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv7.0.0
|
1
serverBin/mythen3DetectorServerv7.0.3
Symbolic link
1
serverBin/mythen3DetectorServerv7.0.3
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv7.0.3
|
@ -42,7 +42,7 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int nSamples;
|
||||
|
||||
int headerSize;
|
||||
double ghost[200][25];
|
||||
|
||||
// Single point of definition if we need to customize
|
||||
@ -62,7 +62,7 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
|
||||
moench03T1ReceiverDataNew(int ns = 5000)
|
||||
: slsDetectorData<uint16_t>(400, 400, ns * 2 * 32 + sizeof(header)),
|
||||
nSamples(ns) {
|
||||
|
||||
headerSize=112;
|
||||
int nadc = 32;
|
||||
int sc_width = 25;
|
||||
int sc_height = 200;
|
||||
@ -250,13 +250,22 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
np = 0;
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
if (filebin.is_open()) {
|
||||
|
||||
if (filebin.read(data, headerSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
if (np>0)
|
||||
filebin.read(data+headerSize, dataSize-headerSize);
|
||||
return data;
|
||||
}
|
||||
/* if (filebin.read(data, dataSize)) { */
|
||||
/* ff = getFrameNumber(data); */
|
||||
/* np = getPacketNumber(data); */
|
||||
/* return data; */
|
||||
/* } */
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -13,22 +13,7 @@ class etaInterpolationGlobal : public etaInterpolationBase {
|
||||
|
||||
virtual void prepareInterpolation(int &ok) {
|
||||
ok = 1;
|
||||
#ifdef MYROOT1
|
||||
if (hhx)
|
||||
delete hhx;
|
||||
if (hhy)
|
||||
delete hhy;
|
||||
|
||||
hhx = new TH2D("hhx", "hhx", heta->GetNbinsX(),
|
||||
heta->GetXaxis()->GetXmin(), heta->GetXaxis()->GetXmax(),
|
||||
heta->GetNbinsY(), heta->GetYaxis()->GetXmin(),
|
||||
heta->GetYaxis()->GetXmax());
|
||||
hhy = new TH2D("hhy", "hhy", heta->GetNbinsX(),
|
||||
heta->GetXaxis()->GetXmin(), heta->GetXaxis()->GetXmax(),
|
||||
heta->GetNbinsY(), heta->GetYaxis()->GetXmin(),
|
||||
heta->GetYaxis()->GetXmax());
|
||||
|
||||
#endif
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
double bsize = 1. / nSubPixels; // precision
|
||||
|
@ -357,6 +357,16 @@ class slsInterpolation {
|
||||
}
|
||||
}
|
||||
|
||||
/* cout << "(((" << totquad << "\t" << corner << endl; */
|
||||
/* for (int iy=0; iy<3; iy++) { */
|
||||
/* for (int ix=0; ix<3; ix++) */
|
||||
/* cout << cl[ix+iy*3] <<"\t"; */
|
||||
/* cout << endl; */
|
||||
|
||||
/* } */
|
||||
|
||||
/* cout << ")))" << endl; */
|
||||
|
||||
return corner;
|
||||
}
|
||||
|
||||
@ -370,6 +380,10 @@ class slsInterpolation {
|
||||
etax = r / totquad;
|
||||
etay = t / totquad;
|
||||
}
|
||||
/* cout << "************" << endl; */
|
||||
/* cout << sDum[0][0]<< "\t"<<sDum[0][1] << endl << sDum[1][0]<< "\t"<<sDum[1][1] << endl; */
|
||||
/* cout << "***************" <<endl; */
|
||||
/* cout << etax << " " << etay << endl; */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
|
||||
#ifndef FF
|
||||
if (argc < 9) {
|
||||
cout << "Wrong usage! Should be: " << argv[0]
|
||||
<< " infile etafile outfile runmin runmax ns cmin cmax" << endl;
|
||||
<< " infile etafile outfile runmin runmax ns [cmin cmax xmin xmax ymin ymax]" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
@ -41,7 +41,7 @@ int main(int argc, char *argv[]) {
|
||||
#ifdef FF
|
||||
if (argc < 7) {
|
||||
cout << "Wrong usage! Should be: " << argv[0]
|
||||
<< " infile etafile runmin runmax cmin cmax" << endl;
|
||||
<< " infile etafile runmin runmax [cmin cmax xmin xmax ymin ymax]" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
@ -65,13 +65,30 @@ int main(int argc, char *argv[]) {
|
||||
nsubpix = atoi(argv[iarg++]);
|
||||
cout << "Subpix: " << nsubpix << endl;
|
||||
#endif
|
||||
float cmin = atof(argv[iarg++]);
|
||||
float cmax = atof(argv[iarg++]);
|
||||
|
||||
float cmin = 0;
|
||||
float cmax=1000000;
|
||||
if (argc>iarg)
|
||||
cmin=atof(argv[iarg++]);
|
||||
if (argc>iarg)
|
||||
cmax= atof(argv[iarg++]);
|
||||
cout << "Energy min: " << cmin << endl;
|
||||
cout << "Energy max: " << cmax << endl;
|
||||
int xmin=0, xmax=NC, ymin=0, ymax=NR;
|
||||
|
||||
if (argc>iarg)
|
||||
xmin=atof(argv[iarg++]);
|
||||
if (argc>iarg)
|
||||
xmax= atof(argv[iarg++]);
|
||||
|
||||
if (argc>iarg)
|
||||
ymin=atof(argv[iarg++]);
|
||||
if (argc>iarg)
|
||||
ymax= atof(argv[iarg++]);
|
||||
|
||||
// int etabins=500;
|
||||
int etabins = 1000; // nsubpix*2*100;
|
||||
double etamin = -1, etamax = 2;
|
||||
double etamin = -0.25, etamax = 1.25;
|
||||
// double etamin=-0.1, etamax=1.1;
|
||||
// double eta3min = -2, eta3max = 2;
|
||||
double sum, totquad;
|
||||
@ -80,7 +97,7 @@ int main(int argc, char *argv[]) {
|
||||
// double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
|
||||
|
||||
int ix, iy, isx, isy;
|
||||
int nframes = 0, lastframe = -1;
|
||||
int nframes = 0, lastframe = -1, iframe, nphFrame;
|
||||
//double d_x, d_y, res = 5, xx, yy;
|
||||
int nph = 0, totph = 0;
|
||||
//badph = 0,
|
||||
@ -98,7 +115,7 @@ int main(int argc, char *argv[]) {
|
||||
// int nSubPixels = nsubpix;
|
||||
#ifndef NOINTERPOLATION
|
||||
eta2InterpolationPosXY *interp =
|
||||
new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
new eta2InterpolationPosXY(NC, NR, nsubpix, nsubpix, etabins, etabins, etamin, etamax);
|
||||
// eta2InterpolationCleverAdaptiveBins *interp=new
|
||||
// eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin,
|
||||
// etamax);
|
||||
@ -107,8 +124,8 @@ int main(int argc, char *argv[]) {
|
||||
noInterpolation *interp = new noInterpolation(NC, NR, nsubpix);
|
||||
#endif
|
||||
|
||||
#ifndef FF
|
||||
int quad;
|
||||
#ifndef FF
|
||||
#ifndef NOINTERPOLATION
|
||||
char fname[10000];
|
||||
int ok;
|
||||
@ -142,19 +159,26 @@ int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
int irun;
|
||||
for (irun = runmin; irun < runmax; irun++) {
|
||||
for (irun = runmin; irun <= runmax; irun++) {
|
||||
sprintf(infname, argv[1], irun);
|
||||
#ifndef FF
|
||||
sprintf(outfname, argv[3], irun);
|
||||
#endif
|
||||
|
||||
|
||||
f = fopen(infname, "r");
|
||||
if (f) {
|
||||
cout << infname << endl;
|
||||
nframes = 0;
|
||||
//f0 = -1;
|
||||
|
||||
while (cl.read(f)) {
|
||||
//iff=0;
|
||||
while (fread((void*)&iframe, 1, sizeof(int), f)) {
|
||||
//n=0;
|
||||
if (fread((void*)&nphFrame, 1, sizeof(int), f)) {
|
||||
for (int iph=0; iph<nphFrame; iph++) {
|
||||
//while (cl.read(f)) {
|
||||
if (cl.read(f)) {
|
||||
totph++;
|
||||
if (lastframe != cl.iframe) {
|
||||
lastframe = cl.iframe;
|
||||
@ -165,18 +189,28 @@ int main(int argc, char *argv[]) {
|
||||
nframes++;
|
||||
}
|
||||
// quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||
#ifndef FF
|
||||
// #ifndef FF
|
||||
// quad = interp->calcEta(cl.get_cluster(), etax, etay, sum,
|
||||
// totquad, sDum);
|
||||
// #endif
|
||||
// #ifdef FF
|
||||
|
||||
quad = interp->calcEta(cl.get_cluster(), etax, etay, sum,
|
||||
totquad, sDum);
|
||||
#endif
|
||||
#ifdef FF
|
||||
interp->calcEta(cl.get_cluster(), etax, etay, sum,
|
||||
totquad, sDum);
|
||||
#endif
|
||||
|
||||
|
||||
/* cl.print();
|
||||
cout << "(" << etax <<","<< etay <<")"<< quad<< endl;
|
||||
*/
|
||||
//#endif
|
||||
|
||||
if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 &&
|
||||
sum < cmax) {
|
||||
nph++;
|
||||
if (totquad > cmin && cl.x >= xmin && cl.x <= xmax &&
|
||||
cl.y >= ymin && cl.y <= ymax &&
|
||||
totquad < cmax) {
|
||||
|
||||
// if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 &&
|
||||
// sum < cmax) {
|
||||
nph++;
|
||||
// if (sum>200 && sum<580) {
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y,
|
||||
// totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||
@ -227,9 +261,12 @@ int main(int argc, char *argv[]) {
|
||||
#ifdef FF
|
||||
interp->writeFlatField(outfname);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
#ifdef FF
|
||||
|
@ -304,18 +304,38 @@ int main(int argc, char *argv[]) {
|
||||
int ifile = 0;
|
||||
|
||||
mt->setFrameMode(eFrame);
|
||||
int filelist=0;
|
||||
ifstream flist;
|
||||
flist.open (fformat, std::ifstream::in);
|
||||
if (flist.is_open()) {
|
||||
runmin=0;
|
||||
runmax=0;
|
||||
while (flist.getline(ffname,10000)){
|
||||
cout << ffname << endl;
|
||||
runmax++;
|
||||
}
|
||||
runmax--;
|
||||
flist.close();
|
||||
cout << "Found " << runmax << " files " << endl;
|
||||
flist.open (fformat, std::ifstream::in);
|
||||
}
|
||||
|
||||
for (int irun = runmin; irun <= runmax; irun++) {
|
||||
cout << "DATA ";
|
||||
// sprintf(fn,fformat,irun);
|
||||
sprintf(ffname, "%s/%s.raw", indir, fformat);
|
||||
sprintf(fname, (const char*)ffname, irun);
|
||||
sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
||||
sprintf(imgfname, (const char*)ffname, irun);
|
||||
sprintf(ffname, "%s/%s.clust", outdir, fformat);
|
||||
sprintf(cfname, (const char*)ffname, irun);
|
||||
if (flist.is_open()) {
|
||||
flist.getline(ffname,10000);
|
||||
cout << "file list " << ffname << endl;
|
||||
} else {
|
||||
sprintf(ffname,(const char*)fformat,irun);
|
||||
cout << "loop " << ffname << endl;
|
||||
}
|
||||
cout << "ffname "<<ffname << endl;
|
||||
sprintf(fname, "%s/%s.raw",indir,ffname);
|
||||
sprintf(imgfname, "%s/%s.tiff",outdir,ffname);
|
||||
sprintf(cfname, "%s/%s.clust",outdir,ffname);
|
||||
cout << fname << " ";
|
||||
cout << imgfname << endl;
|
||||
cout << imgfname << " " << cfname << endl;
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
// cout << fname << " " << outfname << " " << imgfname << endl;
|
||||
@ -349,13 +369,15 @@ int main(int argc, char *argv[]) {
|
||||
mt->popFree(buff);
|
||||
|
||||
ifr++;
|
||||
if (ifr % 100 == 0)
|
||||
if (ifr % 10000 == 0)
|
||||
cout << ifr << " " << ff << endl;
|
||||
if (nframes > 0) {
|
||||
if (ifr % nframes == 0) {
|
||||
sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat,
|
||||
ifile);
|
||||
sprintf(imgfname, (const char*)ffname, irun);
|
||||
|
||||
sprintf(imgfname, "%s/%s_f%05d.tiff",outdir,ffname,ifile);
|
||||
|
||||
while (mt->isBusy())
|
||||
;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
mt->clearImage();
|
||||
ifile++;
|
||||
@ -374,13 +396,13 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
if (nframes >= 0) {
|
||||
if (nframes > 0) {
|
||||
sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat, ifile);
|
||||
sprintf(imgfname, (const char*)ffname, irun);
|
||||
sprintf(imgfname, "%s/%s_f%05d.tiff",outdir,ffname,ifile);
|
||||
} else {
|
||||
sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
||||
sprintf(imgfname, (const char*)ffname, irun);
|
||||
sprintf(imgfname, "%s/%s_f%05d.tiff",outdir,ffname,ifile);
|
||||
}
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||
while (mt->isBusy())
|
||||
;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
mt->clearImage();
|
||||
if (of) {
|
||||
@ -395,11 +417,12 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Could not open " << fname << " for reading " << endl;
|
||||
}
|
||||
if (nframes < 0) {
|
||||
sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
||||
strcpy(imgfname, ffname);
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
sprintf(imgfname, "%s/%s_tot.tiff",outdir,ffname);
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
}
|
||||
if (flist.is_open()) {
|
||||
flist.close();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -720,6 +720,22 @@ int main(int argc, char *argv[]) {
|
||||
ymin >> ymax;
|
||||
}
|
||||
|
||||
if (addJsonHeader.find("xMin") != addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("xMin")) >> xmin;
|
||||
}
|
||||
|
||||
if (addJsonHeader.find("yMin") != addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("yMin")) >> ymin;
|
||||
}
|
||||
|
||||
if (addJsonHeader.find("xMax") != addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("xMax")) >> xmax;
|
||||
}
|
||||
|
||||
if (addJsonHeader.find("yMax") != addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("yMax")) >> ymax;
|
||||
}
|
||||
|
||||
cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
|
||||
mt->setROI(xmin, xmax, ymin, ymax);
|
||||
if (addJsonHeader.find("dynamicRange") != addJsonHeader.end()) {
|
||||
|
@ -533,7 +533,7 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
|
||||
(clusters + nph)->print();
|
||||
cout << max << " " << val[iy * nx + ix] << endl;
|
||||
}
|
||||
good = 1;
|
||||
//good = 1;
|
||||
if (eMin > 0 && tot < eMin)
|
||||
good = 0;
|
||||
if (eMax > 0 && tot > eMax)
|
||||
@ -542,7 +542,7 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
|
||||
nph++;
|
||||
image[iy * nx + ix]++;
|
||||
}
|
||||
|
||||
good=1;
|
||||
} else if (ee == PEDESTAL) {
|
||||
addToPedestal(data, ix, iy, cm);
|
||||
} /*else {
|
||||
|
@ -193,6 +193,7 @@ void qDrawPlot::SetupPlots() {
|
||||
gainplot2d = new SlsQt2DPlot(boxPlot, true);
|
||||
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5,
|
||||
nPixelsY - 0.5, gainData);
|
||||
gainplot2d->Update();
|
||||
gainplot2d->hide();
|
||||
connect(plot2d, SIGNAL(PlotZoomedSignal(const QRectF &)), this,
|
||||
SLOT(Zoom2DGainPlot(const QRectF &)));
|
||||
@ -1009,6 +1010,7 @@ void qDrawPlot::Update2dPlot() {
|
||||
if (isGainDataExtracted) {
|
||||
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5,
|
||||
nPixelsY - 0.5, gainData);
|
||||
gainplot2d->Update();
|
||||
if (!gainplot2d->isVisible()) {
|
||||
gainplot2d->setFixedWidth(plot2d->width() /
|
||||
qDefs::DATA_GAIN_PLOT_RATIO);
|
||||
|
@ -849,8 +849,9 @@ void qTabMeasurement::GetNextFrameNumber() {
|
||||
"Inconsistent starting frame number for all detectors.");
|
||||
spinNextFrameNumber->setValue(retval);
|
||||
}
|
||||
CATCH_DISPLAY("Could not get starting frame number.",
|
||||
"qTabMeasurement::GetNextFrameNumber")
|
||||
CATCH_HANDLE("Could not get starting frame number.",
|
||||
"qTabMeasurement::GetNextFrameNumber", spinNextFrameNumber,
|
||||
&QSpinBox::setValue, -1)
|
||||
connect(spinNextFrameNumber, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetNextFrameNumber(int)));
|
||||
}
|
||||
|
Binary file not shown.
BIN
slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv7.0.3
Executable file
BIN
slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv7.0.3
Executable file
Binary file not shown.
Binary file not shown.
@ -5,7 +5,7 @@
|
||||
|
||||
#define LINKED_SERVER_NAME "eigerDetectorServer"
|
||||
|
||||
#define REQUIRED_FIRMWARE_VERSION (31)
|
||||
#define REQUIRED_FIRMWARE_VERSION (32)
|
||||
// virtual ones renamed for consistency
|
||||
// real ones keep previous name for compatibility (already in production)
|
||||
#ifdef VIRTUAL
|
||||
|
Binary file not shown.
BIN
slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv7.0.3
Executable file
BIN
slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv7.0.3
Executable file
Binary file not shown.
@ -3323,6 +3323,27 @@ void *start_timer(void *arg) {
|
||||
break;
|
||||
}
|
||||
|
||||
// change gain and data for every frame
|
||||
{
|
||||
const int nchannels = NCHIP * NCHAN;
|
||||
int gainVal = 0;
|
||||
for (int i = 0; i < nchannels; ++i) {
|
||||
if ((i % nchannels) < 400) {
|
||||
gainVal = 1 + frameNr;
|
||||
} else if ((i % nchannels) < 800) {
|
||||
gainVal = 2 + frameNr;
|
||||
} else {
|
||||
gainVal = 3 + frameNr;
|
||||
}
|
||||
int dataVal =
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t)));
|
||||
dataVal += frameNr;
|
||||
int channelVal =
|
||||
(dataVal & ~GAIN_VAL_MSK) | (gainVal << GAIN_VAL_OFST);
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||
(uint16_t)channelVal;
|
||||
}
|
||||
}
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
|
Binary file not shown.
BIN
slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv7.0.3
Executable file
BIN
slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv7.0.3
Executable file
Binary file not shown.
Binary file not shown.
BIN
slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv7.0.3
Executable file
BIN
slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv7.0.3
Executable file
Binary file not shown.
@ -2632,6 +2632,7 @@ void *start_timer(void *arg) {
|
||||
if (i % pixelsPerPacket == 0) {
|
||||
++dataVal;
|
||||
}
|
||||
|
||||
if ((i % 1024) < 300) {
|
||||
gainVal = 1;
|
||||
} else if ((i % 1024) < 600) {
|
||||
@ -2672,6 +2673,28 @@ void *start_timer(void *arg) {
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
|
||||
// change gain and data for every frame
|
||||
{
|
||||
const int npixels = (NCHAN * NCHIP);
|
||||
for (int i = 0; i < npixels; ++i) {
|
||||
int gainVal = 0;
|
||||
if ((i % 1024) < 300) {
|
||||
gainVal = 1 + iframes;
|
||||
} else if ((i % 1024) < 600) {
|
||||
gainVal = 2 + iframes;
|
||||
} else {
|
||||
gainVal = 3 + iframes;
|
||||
}
|
||||
int dataVal =
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t)));
|
||||
dataVal += iframes;
|
||||
int pixelVal =
|
||||
(dataVal & ~GAIN_VAL_MSK) | (gainVal << GAIN_VAL_OFST);
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||
(uint16_t)pixelVal;
|
||||
}
|
||||
}
|
||||
|
||||
int srcOffset = 0;
|
||||
int srcOffset2 = DATA_BYTES / 2;
|
||||
int row0 = (numInterfaces == 1 ? detPos[1] : detPos[3]);
|
||||
|
Binary file not shown.
BIN
slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv7.0.3
Executable file
BIN
slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv7.0.3
Executable file
Binary file not shown.
Binary file not shown.
BIN
slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv7.0.3
Executable file
BIN
slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv7.0.3
Executable file
Binary file not shown.
@ -13,6 +13,7 @@
|
||||
#include "slsDetectorServer_funcs.h"
|
||||
|
||||
#include <getopt.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
@ -276,6 +277,14 @@ int main(int argc, char *argv[]) {
|
||||
LOG(logERROR, ("Could not set handler function for SIGINT"));
|
||||
}
|
||||
|
||||
// validate control and stop port number
|
||||
if (0 >= portno || portno > USHRT_MAX || 0 >= (portno + 1) ||
|
||||
(portno + 1) > USHRT_MAX) {
|
||||
LOG(logERROR, ("Invalid control server or stop server port "
|
||||
"numbers (%d, %d). It must be in range 1 - %d",
|
||||
portno, portno + 1, USHRT_MAX));
|
||||
return -1;
|
||||
}
|
||||
if (sharedMemory_create(portno) == FAIL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -515,6 +515,11 @@ int executeCommand(char *command, char *result, enum TLogLevel level) {
|
||||
|
||||
fflush(stdout);
|
||||
FILE *sysFile = popen(cmd, "r");
|
||||
if (sysFile == NULL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Executing cmd[%s] failed\n", cmd);
|
||||
return ret;
|
||||
}
|
||||
while (fgets(temp, tempsize, sysFile) != NULL) {
|
||||
// size left excludes terminating character
|
||||
size_t sizeleft = MAX_STR_LENGTH - strlen(result) - 1;
|
||||
@ -530,17 +535,15 @@ int executeCommand(char *command, char *result, enum TLogLevel level) {
|
||||
if (strlen(result) == 0) {
|
||||
strcpy(result, "No result");
|
||||
}
|
||||
|
||||
int retval = OK;
|
||||
int success = pclose(sysFile);
|
||||
if (success) {
|
||||
retval = FAIL;
|
||||
LOG(logERROR, ("Executing cmd[%s]:%s\n", cmd, result));
|
||||
if (success == -1) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, result);
|
||||
LOG(logERROR, ("Executing cmd[%s] failed:%s\n", cmd, mess));
|
||||
} else {
|
||||
LOG(level, ("Result:\n[%s]\n", result));
|
||||
}
|
||||
|
||||
return retval;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int M_nofunc(int file_des) {
|
||||
@ -568,7 +571,7 @@ int exec_command(int file_des) {
|
||||
|
||||
// set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
ret = executeCommand(cmd, retval, logINFO);
|
||||
executeCommand(cmd, retval, logINFO);
|
||||
}
|
||||
return Server_SendResult(file_des, OTHER, retval, sizeof(retval));
|
||||
}
|
||||
@ -4664,7 +4667,8 @@ int set_read_n_rows(int file_des) {
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if ((Server_VerifyLock() == OK) &&
|
||||
(check_detector_idle("set number of rows") == OK)) {
|
||||
if (arg <= 0 || arg > MAX_ROWS_PER_READOUT) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
@ -4696,8 +4700,7 @@ int set_read_n_rows(int file_des) {
|
||||
LOG(logERROR, (mess));
|
||||
} else
|
||||
#elif JUNGFRAUD
|
||||
if ((check_detector_idle("set number of rows") == OK) &&
|
||||
(arg % READ_N_ROWS_MULTIPLE != 0)) {
|
||||
if (arg % READ_N_ROWS_MULTIPLE != 0) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set number of rows. %d must be a multiple "
|
||||
@ -8280,9 +8283,9 @@ int set_master(int file_des) {
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if ((check_detector_idle("set master") == OK) &&
|
||||
(arg != 0 && arg != 1)) {
|
||||
if ((Server_VerifyLock() == OK) &&
|
||||
(check_detector_idle("set master") == OK)) {
|
||||
if (arg != 0 && arg != 1) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set master. Invalid argument %d.\n", arg);
|
||||
LOG(logERROR, (mess));
|
||||
@ -8836,9 +8839,9 @@ int set_flip_rows(int file_des) {
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if ((check_detector_idle("set flip rows") == OK) &&
|
||||
(arg != 0 && arg != 1)) {
|
||||
if ((Server_VerifyLock() == OK) &&
|
||||
(check_detector_idle("set flip rows") == OK)) {
|
||||
if (arg != 0 && arg != 1) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set flip rows. Invalid argument %d.\n",
|
||||
arg);
|
||||
@ -10160,9 +10163,9 @@ int set_synchronization(int file_des) {
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if ((check_detector_idle("set synchronization") == OK) &&
|
||||
(arg != 0 && arg != 1)) {
|
||||
if ((Server_VerifyLock() == OK) &&
|
||||
(check_detector_idle("set synchronization") == OK)) {
|
||||
if (arg != 0 && arg != 1) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set synchronization. Invalid argument %d.\n",
|
||||
|
@ -2008,7 +2008,7 @@ class Detector {
|
||||
///@}
|
||||
|
||||
private:
|
||||
std::vector<int> getPortNumbers(int start_port);
|
||||
std::vector<int> getValidPortNumbers(int start_port);
|
||||
void updateRxRateCorrections();
|
||||
void setNumberofUDPInterfaces_(int n, Positions pos);
|
||||
};
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "sls/ToString.h"
|
||||
#include "sls/TypeTraits.h"
|
||||
#include "sls/container_utils.h"
|
||||
|
||||
namespace sls {
|
||||
@ -128,6 +129,25 @@ template <class T, class Allocator = std::allocator<T>> class Result {
|
||||
/** Test whether all elements of the result are equal */
|
||||
bool equal() const noexcept { return allEqual(vec); }
|
||||
|
||||
/** Test whether any element of the result are equal to a value */
|
||||
bool any(const T &value) const noexcept { return anyEqualTo(vec, value); }
|
||||
|
||||
template <typename V, typename... Args, typename = AllSame<V, Args...>>
|
||||
typename std::enable_if<std::is_same<V, T>::value, bool>::type
|
||||
contains_only(const V &a, const Args &...args) const noexcept {
|
||||
auto values = {a, args...};
|
||||
for (const auto &element : vec) {
|
||||
int found = 0;
|
||||
for (const auto &value : values) {
|
||||
if (value == element)
|
||||
found++;
|
||||
}
|
||||
if (!found)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Convert Result<T> to std::vector<T> */
|
||||
operator std::vector<T>() { return vec; }
|
||||
};
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include <thread>
|
||||
|
||||
namespace sls {
|
||||
@ -108,6 +109,9 @@ void Detector::setHostname(const std::vector<std::string> &hostname) {
|
||||
}
|
||||
|
||||
void Detector::setVirtualDetectorServers(int numServers, int startingPort) {
|
||||
for (int i = 0; i != numServers; ++i) {
|
||||
validatePortNumber(startingPort + i * 2);
|
||||
}
|
||||
pimpl->setVirtualDetectorServers(numServers, startingPort);
|
||||
}
|
||||
|
||||
@ -845,18 +849,26 @@ void Detector::startDetectorReadout() {
|
||||
|
||||
void Detector::stopDetector(Positions pos) {
|
||||
|
||||
// stop and check status X times
|
||||
int retries{0};
|
||||
// avoid default construction of runStatus::IDLE on squash
|
||||
auto status = getDetectorStatus().squash(defs::runStatus::RUNNING);
|
||||
while (status != defs::runStatus::IDLE &&
|
||||
status != defs::runStatus::STOPPED) {
|
||||
if (status == defs::runStatus::ERROR) {
|
||||
throw RuntimeError(
|
||||
"Could not stop detector. Returned error status.");
|
||||
auto status = getDetectorStatus(pos);
|
||||
|
||||
// jf sync fix: status [stopped or idle] = [stopped]
|
||||
// sync issue: (master idle sometimes, slaves stopped)
|
||||
|
||||
// eiger fix: stop multiple times from multi client till all modules stopped
|
||||
// issue: asynchronous start and stop scripts with a module being started
|
||||
// (stop before) and waiting for the other to be done. So a module that was
|
||||
// idle before stopping will return running (after async start script) when
|
||||
// getting status after, which will then be stopped again.
|
||||
|
||||
while (!status.contains_only(defs::runStatus::IDLE,
|
||||
defs::runStatus::STOPPED)) {
|
||||
if (status.any(defs::runStatus::ERROR)) {
|
||||
throw RuntimeError("Could not stop detector. At least one module "
|
||||
"returned error status.");
|
||||
}
|
||||
pimpl->stopDetector(pos);
|
||||
status = getDetectorStatus().squash(defs::runStatus::RUNNING);
|
||||
status = getDetectorStatus(pos);
|
||||
++retries;
|
||||
|
||||
if (retries == 10)
|
||||
@ -875,7 +887,7 @@ void Detector::stopDetector(Positions pos) {
|
||||
for (auto it : res) {
|
||||
maxVal = std::max(maxVal, it);
|
||||
}
|
||||
setNextFrameNumber(maxVal + 1);
|
||||
setNextFrameNumber(maxVal + 1, pos);
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
@ -1087,12 +1099,13 @@ Result<int> Detector::getDestinationUDPPort(Positions pos) const {
|
||||
|
||||
void Detector::setDestinationUDPPort(int port, int module_id) {
|
||||
if (module_id == -1) {
|
||||
std::vector<int> port_list = getPortNumbers(port);
|
||||
std::vector<int> port_list = getValidPortNumbers(port);
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setDestinationUDPPort, {idet},
|
||||
port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
validatePortNumber(port);
|
||||
pimpl->Parallel(&Module::setDestinationUDPPort, {module_id}, port);
|
||||
}
|
||||
}
|
||||
@ -1103,12 +1116,13 @@ Result<int> Detector::getDestinationUDPPort2(Positions pos) const {
|
||||
|
||||
void Detector::setDestinationUDPPort2(int port, int module_id) {
|
||||
if (module_id == -1) {
|
||||
std::vector<int> port_list = getPortNumbers(port);
|
||||
std::vector<int> port_list = getValidPortNumbers(port);
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setDestinationUDPPort2, {idet},
|
||||
port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
validatePortNumber(port);
|
||||
pimpl->Parallel(&Module::setDestinationUDPPort2, {module_id}, port);
|
||||
}
|
||||
}
|
||||
@ -1220,9 +1234,11 @@ void Detector::setRxPort(int port, int module_id) {
|
||||
it = port++;
|
||||
}
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
validatePortNumber(port_list[idet]);
|
||||
pimpl->Parallel(&Module::setReceiverPort, {idet}, port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
validatePortNumber(port);
|
||||
pimpl->Parallel(&Module::setReceiverPort, {module_id}, port);
|
||||
}
|
||||
}
|
||||
@ -1420,12 +1436,13 @@ void Detector::setRxZmqPort(int port, int module_id) {
|
||||
bool previouslyReceiverStreaming =
|
||||
getRxZmqDataStream(std::vector<int>{module_id}).squash(false);
|
||||
if (module_id == -1) {
|
||||
std::vector<int> port_list = getPortNumbers(port);
|
||||
std::vector<int> port_list = getValidPortNumbers(port);
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setReceiverStreamingPort, {idet},
|
||||
port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
validatePortNumber(port);
|
||||
pimpl->Parallel(&Module::setReceiverStreamingPort, {module_id}, port);
|
||||
}
|
||||
if (previouslyReceiverStreaming) {
|
||||
@ -1454,12 +1471,13 @@ Result<int> Detector::getClientZmqPort(Positions pos) const {
|
||||
void Detector::setClientZmqPort(int port, int module_id) {
|
||||
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
||||
if (module_id == -1) {
|
||||
std::vector<int> port_list = getPortNumbers(port);
|
||||
std::vector<int> port_list = getValidPortNumbers(port);
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setClientStreamingPort, {idet},
|
||||
port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
validatePortNumber(port);
|
||||
pimpl->Parallel(&Module::setClientStreamingPort, {module_id}, port);
|
||||
}
|
||||
if (previouslyClientStreaming) {
|
||||
@ -2463,6 +2481,7 @@ Result<int> Detector::getControlPort(Positions pos) const {
|
||||
}
|
||||
|
||||
void Detector::setControlPort(int value, Positions pos) {
|
||||
validatePortNumber(value);
|
||||
pimpl->Parallel(&Module::setControlPort, pos, value);
|
||||
}
|
||||
|
||||
@ -2471,6 +2490,7 @@ Result<int> Detector::getStopPort(Positions pos) const {
|
||||
}
|
||||
|
||||
void Detector::setStopPort(int value, Positions pos) {
|
||||
validatePortNumber(value);
|
||||
pimpl->Parallel(&Module::setStopPort, pos, value);
|
||||
}
|
||||
|
||||
@ -2505,13 +2525,17 @@ Result<ns> Detector::getMeasurementTime(Positions pos) const {
|
||||
|
||||
std::string Detector::getUserDetails() const { return pimpl->getUserDetails(); }
|
||||
|
||||
std::vector<int> Detector::getPortNumbers(int start_port) {
|
||||
std::vector<int> Detector::getValidPortNumbers(int start_port) {
|
||||
int num_sockets_per_detector = getNumberofUDPInterfaces({}).tsquash(
|
||||
"Number of UDP Interfaces is not consistent among modules");
|
||||
std::vector<int> res;
|
||||
res.reserve(size());
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
res.push_back(start_port + (idet * num_sockets_per_detector));
|
||||
int port = start_port + (idet * num_sockets_per_detector);
|
||||
for (int i = 0; i != num_sockets_per_detector; ++i) {
|
||||
validatePortNumber(port + i);
|
||||
}
|
||||
res.push_back(port);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -288,6 +288,7 @@ void DetectorImpl::addModule(const std::string &hostname) {
|
||||
if (res.size() > 1) {
|
||||
host = res[0];
|
||||
port = StringTo<int>(res[1]);
|
||||
validatePortNumber(port);
|
||||
}
|
||||
|
||||
if (host != "localhost") {
|
||||
@ -1233,10 +1234,26 @@ int DetectorImpl::acquire() {
|
||||
dataProcessingThread.join();
|
||||
|
||||
if (acquisition_finished != nullptr) {
|
||||
int status = Parallel(&Module::getRunStatus, {}).squash(ERROR);
|
||||
// status
|
||||
runStatus status = IDLE;
|
||||
auto statusList = Parallel(&Module::getRunStatus, {});
|
||||
status = statusList.squash(ERROR);
|
||||
// difference, but none error
|
||||
if (status == ERROR && (!statusList.any(ERROR))) {
|
||||
// handle jf sync issue (master idle, slaves stopped)
|
||||
if (statusList.contains_only(IDLE, STOPPED)) {
|
||||
status = STOPPED;
|
||||
} else
|
||||
status = statusList.squash(RUNNING);
|
||||
}
|
||||
|
||||
// progress
|
||||
auto a = Parallel(&Module::getReceiverProgress, {});
|
||||
double progress = (*std::max_element(a.begin(), a.end()));
|
||||
acquisition_finished(progress, status, acqFinished_p);
|
||||
|
||||
// callback
|
||||
acquisition_finished(progress, static_cast<int>(status),
|
||||
acqFinished_p);
|
||||
}
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
|
@ -1350,7 +1350,9 @@ void Module::setReceiverHostname(const std::string &receiverIP,
|
||||
auto res = split(host, ':');
|
||||
if (res.size() > 1) {
|
||||
host = res[0];
|
||||
shm()->rxTCPPort = std::stoi(res[1]);
|
||||
int port = StringTo<int>(res[1]);
|
||||
validatePortNumber(port);
|
||||
shm()->rxTCPPort = port;
|
||||
}
|
||||
strcpy_safe(shm()->rxHostname, host.c_str());
|
||||
shm()->useReceiverFlag = true;
|
||||
@ -3871,8 +3873,8 @@ void Module::sendProgram(bool blackfin, std::vector<char> buffer,
|
||||
|
||||
void Module::simulatingActivityinDetector(const std::string &functionType,
|
||||
const int timeRequired) {
|
||||
LOG(logINFO) << "(Simulating) " << functionType << " for module "
|
||||
<< moduleIndex << " (" << shm()->hostname << ")";
|
||||
LOG(logINFO) << functionType << " for module " << moduleIndex << " ("
|
||||
<< shm()->hostname << ")";
|
||||
printf("%d%%\r", 0);
|
||||
std::cout << std::flush;
|
||||
const int ERASE_TIME = timeRequired;
|
||||
|
@ -11,6 +11,31 @@ namespace sls {
|
||||
using test::GET;
|
||||
using test::PUT;
|
||||
|
||||
void test_valid_port(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id,
|
||||
int action, int port_number) {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
std::string string_port_number = std::to_string(port_number);
|
||||
REQUIRE_THROWS_WITH(proxy.Call(command, arguments, detector_id, action),
|
||||
"Invalid port number " + string_port_number +
|
||||
". It must be in range 1 - 65535");
|
||||
}
|
||||
|
||||
void test_valid_port(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id,
|
||||
int action) {
|
||||
std::vector<std::string> arg(arguments);
|
||||
arg.push_back("0");
|
||||
|
||||
int test_values[2] = {77797, -1};
|
||||
for (int i = 0; i != 2; ++i) {
|
||||
int port_number = test_values[i];
|
||||
arg[arg.size() - 1] = std::to_string(port_number);
|
||||
test_valid_port(command, arg, detector_id, action, port_number);
|
||||
}
|
||||
}
|
||||
|
||||
void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
|
@ -5,6 +5,14 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
void test_valid_port(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id,
|
||||
int action, int port_number);
|
||||
|
||||
void test_valid_port(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id,
|
||||
int action);
|
||||
|
||||
void test_dac(slsDetectorDefs::dacIndex index, const std::string &dacname,
|
||||
int dacvalue);
|
||||
void test_onchip_dac(slsDetectorDefs::dacIndex index,
|
||||
|
@ -689,10 +689,11 @@ TEST_CASE("confadc", "[.cmd]") {
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
|
||||
if (det_type == defs::GOTTHARD2) {
|
||||
int ndet = det.size();
|
||||
int nchip = 10;
|
||||
int nadc = 32;
|
||||
int prev_val[ndet][nchip][nadc];
|
||||
const int ndet = det.size();
|
||||
const int nchip = 10;
|
||||
const int nadc = 32;
|
||||
std::vector<std::vector<std::vector<int>>> prev_val(
|
||||
ndet, std::vector<std::vector<int>>(nchip, std::vector<int>(nadc)));
|
||||
for (int i = 0; i != ndet; ++i) {
|
||||
for (int j = 0; j != nchip; ++j) {
|
||||
for (int k = 0; k != nadc; ++k) {
|
||||
|
@ -550,6 +550,34 @@ TEST_CASE("sync", "[.cmd]") {
|
||||
proxy.Call("sync", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "sync 1\n");
|
||||
}
|
||||
// setting sync when running
|
||||
{
|
||||
auto prev_timing =
|
||||
det.getTimingMode().tsquash("inconsistent timing mode in test");
|
||||
auto prev_frames =
|
||||
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
|
||||
auto prev_exptime =
|
||||
det.getExptime().tsquash("inconsistent exptime in test");
|
||||
auto prev_period =
|
||||
det.getPeriod().tsquash("inconsistent period in test");
|
||||
det.setTimingMode(defs::AUTO_TIMING);
|
||||
det.setNumberOfFrames(10000);
|
||||
det.setExptime(std::chrono::microseconds(200));
|
||||
det.setPeriod(std::chrono::milliseconds(1000));
|
||||
det.setSynchronization(1);
|
||||
det.startDetector();
|
||||
REQUIRE_THROWS(proxy.Call("sync", {"0"}, -1, PUT));
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("sync", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "sync 1\n");
|
||||
}
|
||||
det.stopDetector();
|
||||
det.setTimingMode(prev_timing);
|
||||
det.setNumberOfFrames(prev_frames);
|
||||
det.setExptime(prev_exptime);
|
||||
det.setPeriod(prev_period);
|
||||
}
|
||||
det.setSynchronization(prev_val);
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("sync", {}, -1, GET));
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/Version.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "test-CmdProxy-global.h"
|
||||
#include <sstream>
|
||||
|
||||
#include "sls/versionAPI.h"
|
||||
@ -237,6 +238,22 @@ TEST_CASE("rx_tcpport", "[.cmd][.rx]") {
|
||||
proxy.Call("rx_tcpport", {}, i, GET, oss);
|
||||
REQUIRE(oss.str() == "rx_tcpport " + std::to_string(port + i) + '\n');
|
||||
}
|
||||
|
||||
test_valid_port("rx_tcpport", {}, -1, PUT);
|
||||
test_valid_port("rx_tcpport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
test_valid_port("rx_tcpport", {"65535"}, -1, PUT, 65536);
|
||||
auto rxHostname = det.getRxHostname().squash("none");
|
||||
if (rxHostname != "none") {
|
||||
std::ostringstream oss;
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
oss << rxHostname << ":" << 65536 + i << "+";
|
||||
}
|
||||
test_valid_port("rx_hostname", {oss.str()}, -1, PUT, 65536);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setRxPort(prev_val[i], i);
|
||||
}
|
||||
@ -828,6 +845,12 @@ TEST_CASE("rx_zmqport", "[.cmd][.rx]") {
|
||||
std::to_string(port + i * socketsperdetector) +
|
||||
'\n');
|
||||
}
|
||||
test_valid_port("rx_zmqport", {}, -1, PUT);
|
||||
test_valid_port("rx_zmqport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
test_valid_port("rx_zmqport", {"65535"}, -1, PUT, 65536);
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setRxZmqPort(prev_val_zmqport[i], i);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/file_utils.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "test-CmdProxy-global.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
@ -76,7 +77,13 @@ TEST_CASE("hostname", "[.cmd]") {
|
||||
REQUIRE_NOTHROW(proxy.Call("hostname", {}, -1, GET));
|
||||
}
|
||||
|
||||
// virtual: not testing
|
||||
TEST_CASE("virtual", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
REQUIRE_THROWS(proxy.Call("virtual", {}, -1, GET));
|
||||
test_valid_port("virtual", {"1"}, -1, PUT);
|
||||
test_valid_port("virtual", {"3", "65534"}, -1, PUT, 65536);
|
||||
}
|
||||
|
||||
TEST_CASE("versions", "[.cmd]") {
|
||||
Detector det;
|
||||
@ -1221,10 +1228,10 @@ TEST_CASE("dbitphase", "[.cmd]") {
|
||||
}
|
||||
{
|
||||
std::ostringstream oss1, oss2;
|
||||
proxy.Call("dbitphase", {"20", "deg"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "dbitphase 20 deg\n");
|
||||
proxy.Call("dbitphase", {"23", "deg"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "dbitphase 23 deg\n");
|
||||
proxy.Call("dbitphase", {"deg"}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "dbitphase 20 deg\n");
|
||||
REQUIRE(oss2.str() == "dbitphase 23 deg\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDBITPhase(prev_val[i], {i});
|
||||
@ -2618,6 +2625,13 @@ TEST_CASE("udp_dstport", "[.cmd]") {
|
||||
proxy.Call("udp_dstport", {"50084"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "udp_dstport 50084\n");
|
||||
}
|
||||
test_valid_port("udp_dstport", {}, -1, PUT);
|
||||
test_valid_port("udp_dstport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
test_valid_port("udp_dstport", {"65535"}, -1, PUT, 65536);
|
||||
}
|
||||
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDestinationUDPPort(prev_val[i], {i});
|
||||
}
|
||||
@ -2702,8 +2716,18 @@ TEST_CASE("udp_dstport2", "[.cmd]") {
|
||||
proxy.Call("udp_dstport2", {"50084"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "udp_dstport2 50084\n");
|
||||
}
|
||||
|
||||
test_valid_port("udp_dstport2", {}, -1, PUT);
|
||||
test_valid_port("udp_dstport2", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
test_valid_port("udp_dstport2", {"65535"}, -1, PUT, 65536);
|
||||
}
|
||||
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDestinationUDPPort2(prev_val[i], {i});
|
||||
if (prev_val[i] != 0) {
|
||||
det.setDestinationUDPPort2(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("udp_dstport2", {}, -1, GET));
|
||||
@ -2922,6 +2946,13 @@ TEST_CASE("zmqport", "[.cmd]") {
|
||||
std::to_string(port + i * socketsperdetector) +
|
||||
'\n');
|
||||
}
|
||||
test_valid_port("zmqport", {}, -1, PUT);
|
||||
test_valid_port("zmqport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
test_valid_port("zmqport", {"65535"}, -1, PUT, 65536);
|
||||
}
|
||||
|
||||
if (det_type == defs::JUNGFRAU) {
|
||||
det.setNumberofUDPInterfaces(prev);
|
||||
}
|
||||
@ -3266,6 +3297,13 @@ TEST_CASE("port", "[.cmd]") {
|
||||
proxy.Call("port", {}, 0, GET, oss);
|
||||
REQUIRE(oss.str() == "port 1942\n");
|
||||
}
|
||||
test_valid_port("port", {}, -1, PUT);
|
||||
test_valid_port("port", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
test_valid_port("port", {"65536"}, -1, PUT, 65536);
|
||||
}
|
||||
|
||||
det.setControlPort(prev_val, {0});
|
||||
}
|
||||
|
||||
@ -3283,6 +3321,12 @@ TEST_CASE("stopport", "[.cmd]") {
|
||||
proxy.Call("stopport", {}, 0, GET, oss);
|
||||
REQUIRE(oss.str() == "stopport 1942\n");
|
||||
}
|
||||
test_valid_port("stopport", {}, -1, PUT);
|
||||
test_valid_port("stopport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
test_valid_port("stopport", {"65536"}, -1, PUT, 65536);
|
||||
}
|
||||
det.setStopPort(prev_val, {0});
|
||||
}
|
||||
|
||||
@ -3313,7 +3357,7 @@ TEST_CASE("lock", "[.cmd]") {
|
||||
TEST_CASE("execcommand", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
REQUIRE_NOTHROW(proxy.Call("execcommand", {"ls"}, -1, PUT));
|
||||
REQUIRE_NOTHROW(proxy.Call("execcommand", {"ls *.txt"}, -1, PUT));
|
||||
}
|
||||
|
||||
TEST_CASE("framecounter", "[.cmd]") {
|
||||
|
@ -196,4 +196,24 @@ TEST_CASE("String conversions") {
|
||||
"[{one: 1}, {one: 1, three: 3, two: 2}, {one: 1}]");
|
||||
}
|
||||
|
||||
TEST_CASE("Any element is equal") {
|
||||
Result<int> r{1, 2, 3, 4, 5};
|
||||
REQUIRE(r.any(3));
|
||||
REQUIRE_FALSE(r.any(9));
|
||||
}
|
||||
|
||||
TEST_CASE("Result contains only the specified elements") {
|
||||
Result<int> r{1, 1, 1};
|
||||
REQUIRE(r.contains_only(1));
|
||||
REQUIRE(r.contains_only(1, 1));
|
||||
}
|
||||
|
||||
TEST_CASE("Only with multiple values") {
|
||||
Result<int> r{1, 1, 2, 1, 2, 1, 1};
|
||||
REQUIRE_FALSE(r.contains_only(1));
|
||||
REQUIRE_FALSE(r.contains_only(2));
|
||||
REQUIRE(r.contains_only(1, 2));
|
||||
REQUIRE(r.contains_only(2, 1));
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
|
@ -45,6 +45,7 @@ ClientInterface::ClientInterface(int portNumber)
|
||||
: detType(GOTTHARD),
|
||||
portNumber(portNumber > 0 ? portNumber : DEFAULT_TCP_RX_PORTNO),
|
||||
server(portNumber) {
|
||||
validatePortNumber(portNumber);
|
||||
functionTable();
|
||||
parentThreadId = gettid();
|
||||
tcpThread =
|
||||
|
@ -103,4 +103,13 @@ template <typename T> struct is_vector : public std::false_type {};
|
||||
template <typename T>
|
||||
struct is_vector<std::vector<T>> : public std::true_type {};
|
||||
|
||||
template <class...> struct Conjunction : std::true_type {};
|
||||
template <class B1> struct Conjunction<B1> : B1 {};
|
||||
template <class B1, class... Bn>
|
||||
struct Conjunction<B1, Bn...>
|
||||
: std::conditional<bool(B1::value), Conjunction<Bn...>, B1>::type {};
|
||||
|
||||
template <typename T, typename... Ts>
|
||||
using AllSame =
|
||||
typename std::enable_if<Conjunction<std::is_same<T, Ts>...>::value>::type;
|
||||
} // namespace sls
|
@ -88,5 +88,5 @@ IpAddr HostnameToIp(const char *hostname);
|
||||
std::string IpToInterfaceName(const std::string &ip);
|
||||
MacAddr InterfaceNameToMac(const std::string &inf);
|
||||
IpAddr InterfaceNameToIp(const std::string &ifn);
|
||||
|
||||
void validatePortNumber(int port);
|
||||
} // namespace sls
|
||||
|
@ -1,13 +1,13 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
/** API versions */
|
||||
#define RELEASE "7.0.2"
|
||||
#define APICTB "7.0.0 0x230222"
|
||||
#define APIGOTTHARD "7.0.0 0x230222"
|
||||
#define APIGOTTHARD2 "7.0.0 0x230222"
|
||||
#define APIMYTHEN3 "7.0.0 0x230222"
|
||||
#define APIMOENCH "7.0.0 0x230222"
|
||||
#define APIEIGER "7.0.0 0x230222"
|
||||
#define APIJUNGFRAU "7.0.2 0x230710"
|
||||
#define APILIB "7.0.2 0x230712"
|
||||
#define APIRECEIVER "7.0.2 0x230712"
|
||||
#define RELEASE "7.0.3"
|
||||
#define APILIB "7.0.3 0x231108"
|
||||
#define APIRECEIVER "7.0.3 0x231108"
|
||||
#define APICTB "7.0.3 0x231109"
|
||||
#define APIGOTTHARD "7.0.3 0x231109"
|
||||
#define APIGOTTHARD2 "7.0.3 0x231109"
|
||||
#define APIJUNGFRAU "7.0.3 0x231109"
|
||||
#define APIMYTHEN3 "7.0.3 0x231109"
|
||||
#define APIMOENCH "7.0.3 0x231109"
|
||||
#define APIEIGER "7.0.3 0x231109"
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <cstring>
|
||||
#include <ifaddrs.h>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <net/if.h>
|
||||
#include <netdb.h>
|
||||
#include <sstream>
|
||||
@ -203,4 +204,13 @@ MacAddr InterfaceNameToMac(const std::string &inf) {
|
||||
return MacAddr(mac);
|
||||
}
|
||||
|
||||
void validatePortNumber(int port) {
|
||||
if (0 >= port || port > std::numeric_limits<uint16_t>::max()) {
|
||||
std::ostringstream oss;
|
||||
oss << "Invalid port number " << port << ". It must be in range 1 - "
|
||||
<< std::numeric_limits<uint16_t>::max();
|
||||
throw RuntimeError(oss.str());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
|
Reference in New Issue
Block a user