merge conflict resolved from 4.0.0

This commit is contained in:
maliakal_d 2018-09-28 16:28:21 +02:00
commit def79807f6
86 changed files with 1112 additions and 2326 deletions

View File

@ -2,7 +2,7 @@
Detailed documentation can be found on the [official site.](https://www.psi.ch/detectors/users-support) Detailed documentation can be found on the [official site.](https://www.psi.ch/detectors/users-support)
### Binaries ### Binaries
Documentation to obtain the binaries via the conda package is available [here.](https://github.com/slsdetectorgroup/sls_detector_software) Documentation to obtain the binaries via the conda package is available for [lib](https://github.com/slsdetectorgroup/sls_detector_lib) and [gui](https://github.com/slsdetectorgroup/sls_detector_gui)
### Source code ### Source code
One can also obtain the source code from this repository and compile while realizing the setup dependencies as required. One can also obtain the source code from this repository and compile while realizing the setup dependencies as required.
@ -19,7 +19,7 @@ Requirements: Qt 4.8 and Qwt 6.0
``` ```
If either of them does not exist, the GUI client will not be built. If either of them does not exist, the GUI client will not be built.
* Calibration wizards<br> * Advanced user Calibration wizards<br>
Requirements: ROOT Requirements: ROOT
``` ```
export ROOTSYS=/usr/local/root-5.34 export ROOTSYS=/usr/local/root-5.34
@ -43,6 +43,7 @@ Usage: [-c] [-b] [-h] [-d HDF5 directory] [-j]<br>
* -r: Build/Rebuilds only receiver<br> * -r: Build/Rebuilds only receiver<br>
* -g: Build/Rebuilds only gui<br> * -g: Build/Rebuilds only gui<br>
* -j: Number of threads to compile through<br> * -j: Number of threads to compile through<br>
* -e: Debug mode
Basic Option: Basic Option:
./cmk.sh -b ./cmk.sh -b
@ -86,5 +87,5 @@ After compiling, the libraries and executables will be found at `bin` directory
``` ```
$ ls bin/ $ ls bin/
gui_client libSlsDetector.a libSlsDetector.so libSlsReceiver.a libSlsReceiver.so gui_client libSlsDetector.a libSlsDetector.so libSlsReceiver.a libSlsReceiver.so
sls_detector_acquire sls_detector_get slsDetectorGui sls_detector_help sls_detector_put slsReceiver sls_detector_acquire sls_detector_get slsDetectorGui sls_detector_help sls_detector_put slsReceiver slsMultiReceiver
``` ```

View File

@ -1,71 +1,80 @@
SLS Detector Package 4.0.0 released on 2018-08-22 SLS Detector Package 4.0.0 released on 27.09.2018
================================================= =================================================
INTRODUCTION INTRODUCTION
This document describes the differences between 4.0.0 and 3.2.0 releases. This document describes the differences between 4.0.0 and 3.1.4 releases.
The conda package of the binaries can be downloaded from Download
--------
https://github.com/slsdetectorgroup/sls_detector_software.git The Source Code (Default C++ API):
https://github.com/slsdetectorgroup/slsDetectorPackage
The Python interface to the software package (including the package) is at The Conda Lib Package:
https://github.com/slsdetectorgroup/sls_detector_lib
https://github.com/slsdetectorgroup/sls_detector.git The Conda GUI Package:
https://github.com/slsdetectorgroup/sls_detector_gui
Manual (both HTML and pdf versions) are provided in The Python Interface (including the package):
https://github.com/slsdetectorgroup/sls_detector
manual/docs/
Documentation from Source Code can be found for the Command Line and C++ API in Documentation
-------------
html: Manual (HTML & PDF):
https://www.psi.ch/detectors/documentation
slsDetectorPackage/manual/docs/
Command Line Documentation:
manual/docs/html/slsDetectorClientDocs/index.html manual/docs/html/slsDetectorClientDocs/index.html
manual/docs/html/slsDetectorUsersDocs/index.html
pdf:
manual/docs/pdf/slsDetectorClientDocs.pdf manual/docs/pdf/slsDetectorClientDocs.pdf
C++ API Documentation:
manual/docs/html/slsDetectorUsersDocs/index.html
manual/docs/pdf/slsDetectorUsersDocs.pdf manual/docs/pdf/slsDetectorUsersDocs.pdf
Documentation to the python API is available at C++ API Example:
manual/manual-api/mainClient.cpp
manual/manual-api/mainReceiver.cpp
Python API Documentation:
https://slsdetectorgroup.github.io/sls_detector/ https://slsdetectorgroup.github.io/sls_detector/
Example for detector and receiver API can be found in Further Documentation:
manual/manual-api
User documentation can also be accessed directly at this location:
https://www.psi.ch/detectors/users-support https://www.psi.ch/detectors/users-support
Please send any software related questions or comments to:
Support
-------
General Software related:
dhanya.thattil@psi.ch dhanya.thattil@psi.ch
anna.bergamaschi@psi.ch anna.bergamaschi@psi.ch
Please send any python related questions or comments to: Python related:
erik.frojdh@psi.ch erik.frojdh@psi.ch
CONTENTS CONTENTS
- Firmware Requirements 1. Firmware Requirements
- Changes in User Interface 2. Changes in User Interface
- New/Modified Commands 3. New/Modified Commands
- Other New Features 4. Other New Features
- Resolved Issues 5. Resolved Issues
- Known Issues 6. Known Issues
- Neat Release Plans 7. Next Major Release Plans
1. Firmware Requirements
Firmware Requirements ========================
=====================
Gotthard Gotthard
======== ========
@ -79,8 +88,8 @@ Firmware Requirements
Jungfrau Jungfrau
======== ========
Minimum compatible version : 26.02.2018 Minimum compatible version : 15.06.2018
Latest version : 26.02.2018 Latest version : 15.06.2018
Detector Upgrade Detector Upgrade
@ -94,14 +103,13 @@ Firmware Requirements
under Detector Upgrade -> [Detector Type] -> Firmware. under Detector Upgrade -> [Detector Type] -> Firmware.
Please refer to the link below for more details on the firmware versions. Please refer to the link below for more details on the firmware versions.
https://www.psi.ch/detectors/firmware. https://www.psi.ch/detectors/firmware.
Changes in User Interface 2. Changes in User Interface
========================= ============================
Client Client
------ ------
@ -209,8 +217,8 @@ Changes in User Interface
New/Modified Commands 3. New/Modified Commands
===================== ========================
Client Client
------ ------
@ -250,9 +258,9 @@ New/Modified Commands
4. r_discardpolicy: 4. r_discardpolicy:
sets/gets the frame discard policy in the receiver. sets/gets the frame discard policy in the receiver.
0 - no discard (default), nodiscard - no discard (default),
1 - discard only empty frames, discardempty - discard only empty frames,
2 - discard any partial frame(fastest) discardpartial - discard any partial frame(fastest)
5. r_padding: 5. r_padding:
sets/gets the frame padding in the receiver. sets/gets the frame padding in the receiver.
@ -309,7 +317,7 @@ New/Modified Commands
previous one) in s in 32 bit mode. previous one) in s in 32 bit mode.
6. flags(modified): 6. flags(modified):
extra flags "overflow" (default) and "nooverflow" for sub images in 32 extra flags "nooverflow" (default) and "overflow" for sub images in 32
bit mode. If set to overflow, it will set MSB of pixel data high if bit mode. If set to overflow, it will set MSB of pixel data high if
there was any saturation in any of the sub images 32 bit mode. there was any saturation in any of the sub images 32 bit mode.
@ -328,8 +336,8 @@ New/Modified Commands
Other New Features 4. Other New Features
================== =====================
Client Client
------ ------
@ -340,8 +348,8 @@ Other New Features
continue to have them. continue to have them.
2. Depending on 1d position of detectors and detsizechan in config file, 2. Depending on 1d position of detectors and detsizechan in config file,
xcoord and ycoord are given to detector servers (Eiger and Jungfrau) row and column (previously xcoord and ycoord) are given to detector
to encode into the udp header. servers (Eiger and Jungfrau) to encode into the udp header.
3. (Eiger) Setting threshold energy changes such as CAL dac is irrelevant 3. (Eiger) Setting threshold energy changes such as CAL dac is irrelevant
when interpolating between two energies and VRS dac is interpolated, not copied. when interpolating between two energies and VRS dac is interpolated, not copied.
@ -374,7 +382,8 @@ Other New Features
1. slsMultiReceiver executable added that creates multiple receiver child processes. 1. slsMultiReceiver executable added that creates multiple receiver child processes.
./slsMultiReceiver [start_tcp_port] [num_receivers] [1 for call back, 0 for none] ./slsMultiReceiver [start_tcp_port] [num_receivers] [1 for call back, 0 for none]
2. Default xcoord and ycoord are hardcoded for missing packets. (Eiger and Jungfrau) 2. Default row and column (previously xcoord and ycoord) are hardcoded
for missing packets. (Eiger and Jungfrau)
Gui Gui
@ -405,8 +414,8 @@ Other New Features
Resolved Issues 5. Resolved Issues
=============== ==================
Client Client
------ ------
@ -424,6 +433,8 @@ Resolved Issues
5. (Jungfrau) Programming FPGA now creates the rawbin file from pof in tmp 5. (Jungfrau) Programming FPGA now creates the rawbin file from pof in tmp
rather than source file location (for permission issues). rather than source file location (for permission issues).
6. (Gotthard) ROI segmentation fault fixed.
Receiver Receiver
-------- --------
@ -433,15 +444,15 @@ Resolved Issues
used that are handled inside the package. used that are handled inside the package.
3. Global optind variable initialized to instantiate multiple receivers 3. Global optind variable initialized to instantiate multiple receivers
in same process. in same process. Also removed static members to enable this feature.
4. Socket buffer size attempts to set for each acquiistion and provide 4. Socket buffer size attempts to set for each acquiistion and provide
warning if no capabilities. Warnings can be removed using instruction with warning if no capabilities. Warnings can be removed using instruction with
error provided. Default Jungfrau UDP socket buffer size if 2 GB, default is error provided. Default Jungfrau UDP socket buffer size if 2 GB, default is
100 MB. 100 MB.
5. Refactored code a bit for performance and robustness, including removing 5. Refactored code a bit for performance and robustness, blocking push
many static members, blocking push in buffer between listener and dataprocessor in buffer between listener and dataprocessor
Detector Server Detector Server
@ -452,9 +463,12 @@ Resolved Issues
2. (Eiger) Bug fix for saving trimbits to file (Advanced users). 2. (Eiger) Bug fix for saving trimbits to file (Advanced users).
3. (Gotthard 25um) config.txt is not read again after detector startup,
no matter the number of times the detector server is restarted.
Known Issues
============ 6. Known Issues
===============
Receiver Receiver
-------- --------
@ -470,10 +484,14 @@ Known Issues
firmware versions. Else one cannot ping it anymore. Will need to flash firmware firmware versions. Else one cannot ping it anymore. Will need to flash firmware
again to recover. again to recover.
2. (Gotthard) To switch back to all ADC from single ADC ROI, one must take
even number of images for the receiver to understand complete images.
This will be fixed in the next firmware upgrade.
Neat Release Plans
================== 7. Next Major Release Plans
===========================
Client Client
------ ------

15
cmk.sh
View File

@ -6,6 +6,7 @@ COMPILERTHREADS=0
TEXTCLIENT=0 TEXTCLIENT=0
RECEIVER=0 RECEIVER=0
GUI=0 GUI=0
DEBUG=0
CLEAN=0 CLEAN=0
@ -24,6 +25,7 @@ Usage: $0 [-c] [-b] [-h] [-d <HDF5 directory>] [-j]
-r: Build/Rebuilds only receiver -r: Build/Rebuilds only receiver
-g: Build/Rebuilds only gui -g: Build/Rebuilds only gui
-j: Number of threads to compile through -j: Number of threads to compile through
-e: Debug mode
For only make: For only make:
./cmk.sh ./cmk.sh
@ -53,7 +55,7 @@ For rebuilding only certain sections
" ; exit 1; } " ; exit 1; }
while getopts ":bchd:j:trg" opt ; do while getopts ":bchd:j:trge" opt ; do
case $opt in case $opt in
b) b)
echo "Building of CMake files Required" echo "Building of CMake files Required"
@ -91,6 +93,10 @@ while getopts ":bchd:j:trg" opt ; do
GUI=1 GUI=1
REBUILD=1 REBUILD=1
;; ;;
e)
echo "Compiling Options: Debug"
DEBUG=1
;;
\?) \?)
echo "Invalid option: -$OPTARG" echo "Invalid option: -$OPTARG"
usage usage
@ -145,7 +151,12 @@ else
fi fi
fi fi
#CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug " #Debug
if [ $DEBUG -eq 1 ]; then
CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug "
echo "Debug Option enabled"
fi
#hdf5 rebuild #hdf5 rebuild
if [ $HDF5 -eq 1 ]; then if [ $HDF5 -eq 1 ]; then

View File

@ -99,18 +99,18 @@ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){
slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata; slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata;
slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader; slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader;
PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.xCoord, PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row,
"#### %d GetData: ####\n" "#### %d GetData: ####\n"
"frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu" "frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu"
"\t\ttimestamp: %llu\t\tmodId: %u\t\t" "\t\ttimestamp: %llu\t\tmodId: %u\t\t"
"xCoord: %u\t\tyCoord: %u\t\tzCoord: %u\t\tdebug: %u" "row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u"
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u" "\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
//"\t\tpacketsMask:%s" //"\t\tpacketsMask:%s"
"\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", "\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
detectorHeader.xCoord, (long long unsigned int)detectorHeader.frameNumber, detectorHeader.row, (long long unsigned int)detectorHeader.frameNumber,
detectorHeader.expLength, detectorHeader.packetNumber, (long long unsigned int)detectorHeader.bunchId, detectorHeader.expLength, detectorHeader.packetNumber, (long long unsigned int)detectorHeader.bunchId,
(long long unsigned int)detectorHeader.timestamp, detectorHeader.modId, (long long unsigned int)detectorHeader.timestamp, detectorHeader.modId,
detectorHeader.xCoord, detectorHeader.yCoord, detectorHeader.zCoord, detectorHeader.row, detectorHeader.column, detectorHeader.reserved,
detectorHeader.debug, detectorHeader.roundRNumber, detectorHeader.debug, detectorHeader.roundRNumber,
detectorHeader.detType, detectorHeader.version, detectorHeader.detType, detectorHeader.version,
//header->packetsMask.to_string().c_str(), //header->packetsMask.to_string().c_str(),
@ -133,18 +133,18 @@ void GetData(char* metadata, char* datapointer, uint32_t &revDatasize, void* p){
slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata; slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata;
slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader; slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader;
PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.xCoord, PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row,
"#### %d GetData: ####\n" "#### %d GetData: ####\n"
"frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu" "frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu"
"\t\ttimestamp: %llu\t\tmodId: %u\t\t" "\t\ttimestamp: %llu\t\tmodId: %u\t\t"
"xCoord: %u\t\tyCoord: %u\t\tzCoord: %u\t\tdebug: %u" "row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u"
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u" "\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
//"\t\tpacketsMask:%s" //"\t\tpacketsMask:%s"
"\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", "\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
detectorHeader.xCoord, (long long unsigned int)detectorHeader.frameNumber, detectorHeader.row, (long long unsigned int)detectorHeader.frameNumber,
detectorHeader.expLength, detectorHeader.packetNumber, (long long unsigned int)detectorHeader.bunchId, detectorHeader.expLength, detectorHeader.packetNumber, (long long unsigned int)detectorHeader.bunchId,
(long long unsigned int)detectorHeader.timestamp, detectorHeader.modId, (long long unsigned int)detectorHeader.timestamp, detectorHeader.modId,
detectorHeader.xCoord, detectorHeader.yCoord, detectorHeader.zCoord, detectorHeader.row, detectorHeader.column, detectorHeader.reserved,
detectorHeader.debug, detectorHeader.roundRNumber, detectorHeader.debug, detectorHeader.roundRNumber,
detectorHeader.detType, detectorHeader.version, detectorHeader.detType, detectorHeader.version,
//header->packetsMask.to_string().c_str(), //header->packetsMask.to_string().c_str(),

Binary file not shown.

View File

@ -548,7 +548,7 @@ the SLS Detectors group.
\indent Minimum compatible version: \\ \indent Minimum compatible version: \\
\indent \indent 11.01.2013 \\ \indent \indent 11.01.2013 \\
\indent Latest version: \\ \indent Latest version: \\
\indent \indent 26.06.2018 (50um) \\ \indent \indent 08.02.2018 (50um) \\
\indent \indent 08.02.2018 (25 um Master) \\ \indent \indent 08.02.2018 (25 um Master) \\
\indent \indent 09.02.2018 (25 um Slave) \\ \indent \indent 09.02.2018 (25 um Slave) \\
@ -747,7 +747,7 @@ Detector Group.
\item Update the latest SLS Detector package installed. \item Update the latest SLS Detector package installed.
\item Update the on-board software as per the instructions in the next \item Update the on-board software as per the instructions in the next
section. section.
\item Start the on-board server in debug mode: \item Start the on-board server in update mode:
\begin{enumerate} \begin{enumerate}
\item Connect to the blackfin on the detector\\ \item Connect to the blackfin on the detector\\
\verb=telnet bchipxxx= \verb=telnet bchipxxx=
@ -757,10 +757,10 @@ section.
\item Comment out the line \item Comment out the line
\verb=#ttyS0::respawn:/jungfrauDetectorServervxxx= \verb=#ttyS0::respawn:/jungfrauDetectorServervxxx=
\item Reboot blackfin using \verb=reboot= \item Reboot blackfin using \verb=reboot=
\item Run \verb=ps= to ensure no gotthardDetectorServers are running \item Run \verb=ps= to ensure no jungfrauDetectorServers are running
\end{enumerate} \end{enumerate}
\item Start the server in debug mode using: \\ \item Start the server in update mode using: \\
\verb=./jungfrauDetectorServerxxx -debug= \\ \verb=./jungfrauDetectorServerxxx -update= \\
Leave this console on to come back to it later. Leave this console on to come back to it later.
\end{enumerate} \end{enumerate}
\item From the command line of the pc, clear shared memory \\ \item From the command line of the pc, clear shared memory \\
@ -773,7 +773,7 @@ script in \verb=slsDetectorPackage/cleansharedmemory.sh=
\verb=./sls_detector_put programfpga xxx.pof= \verb=./sls_detector_put programfpga xxx.pof=
\item Once the programming is done: \item Once the programming is done:
\begin{enumerate} \begin{enumerate}
\item Switch to the console that has the debug server running and kill it \item Switch to the console that has the update server running and kill it
using Ctrl+C and ensure no jungfrauDetectorServers are using Ctrl+C and ensure no jungfrauDetectorServers are
running running
\item Restart the new server to see if it runs with the new firmware \\ \item Restart the new server to see if it runs with the new firmware \\

View File

@ -0,0 +1 @@
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.0.0.22.0

View File

@ -0,0 +1 @@
../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv4.0.0.3

View File

@ -0,0 +1 @@
../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv4.0.0.0

View File

@ -51,7 +51,7 @@
<enum>QTabWidget::North</enum> <enum>QTabWidget::North</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>4</number> <number>3</number>
</property> </property>
<property name="elideMode"> <property name="elideMode">
<enum>Qt::ElideLeft</enum> <enum>Qt::ElideLeft</enum>
@ -124,7 +124,7 @@
<rect> <rect>
<x>5</x> <x>5</x>
<y>10</y> <y>10</y>
<width>467</width> <width>495</width>
<height>66</height> <height>66</height>
</rect> </rect>
</property> </property>
@ -946,7 +946,7 @@ An extension given by the modules serial number will be attached.
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>135</y> <y>132</y>
<width>736</width> <width>736</width>
<height>171</height> <height>171</height>
</rect> </rect>
@ -960,7 +960,7 @@ An extension given by the modules serial number will be attached.
<x>420</x> <x>420</x>
<y>140</y> <y>140</y>
<width>291</width> <width>291</width>
<height>25</height> <height>29</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
@ -975,9 +975,9 @@ An extension given by the modules serial number will be attached.
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>25</x> <x>25</x>
<y>25</y> <y>21</y>
<width>686</width> <width>686</width>
<height>148</height> <height>119</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_8"> <layout class="QGridLayout" name="gridLayout_8">
@ -1355,9 +1355,9 @@ An extension given by the modules serial number will be attached.
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>35</x> <x>35</x>
<y>15</y> <y>10</y>
<width>686</width> <width>686</width>
<height>146</height> <height>123</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_6"> <layout class="QGridLayout" name="gridLayout_6">

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorGui Path: slsDetectorsPackage/slsDetectorGui
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 6bb7195a2c7dc9526088882e0244a7455d3c15b2 Repsitory UUID: d2bce7e372c241cd235977b92be18555bca6a77d
Revision: 511 Revision: 521
Branch: 3.3.0-rc Branch: 4.0.0
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3941 Last Changed Rev: 4020
Last Changed Date: 2018-07-17 16:15:43.000000002 +0200 ./src/qTabSettings.cpp Last Changed Date: 2018-09-27 16:09:16.000000002 +0200 ./src/qTabSettings.cpp

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "6bb7195a2c7dc9526088882e0244a7455d3c15b2" #define GITREPUUID "d2bce7e372c241cd235977b92be18555bca6a77d"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3941 #define GITREV 0x4020
#define GITDATE 0x20180717 #define GITDATE 0x20180927
#define GITBRANCH "3.3.0-rc" #define GITBRANCH "4.0.0"

View File

@ -246,7 +246,7 @@ void qDrawPlot::SetupWidgetWindow(){
this->setLayout(layout); this->setLayout(layout);
histFrameIndexTitle = new QLabel(""); histFrameIndexTitle = new QLabel("");
histFrameIndexTitle->setFixedHeight(10);
boxPlot = new QGroupBox(""); boxPlot = new QGroupBox("");
layout->addWidget(boxPlot,1,0); layout->addWidget(boxPlot,1,0);
boxPlot->setAlignment(Qt::AlignHCenter); boxPlot->setAlignment(Qt::AlignHCenter);

View File

@ -146,19 +146,6 @@ typedef struct {
} sls_detector_module; } sls_detector_module;
/**
@short structure for a region of interest
xmin,xmax,ymin,ymax define the limits of the region
*/
typedef struct {
int xmin; /**< is the roi xmin (in channel number) */
int xmax; /**< is the roi xmax (in channel number)*/
int ymin; /**< is the roi ymin (in channel number)*/
int ymax; /**< is the roi ymax (in channel number)*/
} ROI ;
/* /\* */ /* /\* */
/* @short structure for a generic integer array */ /* @short structure for a generic integer array */
/* *\/ */ /* *\/ */

View File

@ -1,5 +1,6 @@
/** API versions */ /** API versions */
#define APIRECEIVER 0x180718 #define APIRECEIVER 0x180927
#define APIEIGER 0x180820 #define APIEIGER 0x180820
#define APIJUNGFRAU 0x180820 #define APIJUNGFRAU 0x180925
#define APIGOTTHARD 0x180820 #define APIGOTTHARD 0x180928

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 548036a602123cb3c06bbf4f9a40c9acd6c527fc Repsitory UUID: c52025dd7c4b44b93e64353a22997d971996ab18
Revision: 349 Revision: 350
Branch: developer Branch: developer
Last Changed Author: Dhanya_Thattil Last Changed Author: Gemma_Tinti
Last Changed Rev: 3988 Last Changed Rev: 3999
Last Changed Date: 2018-08-23 11:57:31.000000002 +0200 ./Makefile.virtual Last Changed Date: 2018-09-28 14:11:53.000000002 +0200 ./Makefile.virtual

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "548036a602123cb3c06bbf4f9a40c9acd6c527fc" #define GITREPUUID "c52025dd7c4b44b93e64353a22997d971996ab18"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Gemma_Tinti"
#define GITREV 0x3988 #define GITREV 0x3999
#define GITDATE 0x20180823 #define GITDATE 0x20180928
#define GITBRANCH "developer" #define GITBRANCH "developer"

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware Path: slsDetectorsPackage/slsDetectorSoftware
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 6bb7195a2c7dc9526088882e0244a7455d3c15b2 Repsitory UUID: d2bce7e372c241cd235977b92be18555bca6a77d
Revision: 1992 Revision: 2040
Branch: 3.3.0-rc Branch: 4.0.0
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3941 Last Changed Rev: 4020
Last Changed Date: 2018-07-18 12:26:21.000000002 +0200 ./threadFiles/ThreadPool.o Last Changed Date: 2018-09-27 18:22:10.000000002 +0200 ./sharedMemory/SharedMemory.o

View File

@ -16,7 +16,7 @@ INSTMODE= 0777
BINS = testlib_sharedlibc BINS = testlib_sharedlibc
SRCS = server.c firmware_funcs.c server_funcs.c communication_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c SRCS = server.c firmware_funcs.c server_funcs.c communication_funcs.c mcb_funcs.c
OBJS = $(SRCS:%.c=%.o) OBJS = $(SRCS:%.c=%.o)
@ -31,6 +31,7 @@ versioning:
$(PROGS): $(OBJS) $(PROGS): $(OBJS)
# echo $(OBJS) # echo $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
rm gotthardDetectorServer.gdb
install: $(PROGS) install: $(PROGS)

View File

@ -16,7 +16,7 @@ INSTMODE= 0777
BINS = testlib_sharedlibc BINS = testlib_sharedlibc
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c
OBJS = $(SRCS:%.c=%.o) OBJS = $(SRCS:%.c=%.o)

View File

@ -8,7 +8,7 @@ CFLAGS += -Wall -DGOTTHARDD -DMCB_FUNCS -DDACS_INT -DDEBUG -DVIRTUAL
PROGS= $(DESTDIR)/gotthardDetectorServer_virtual PROGS= $(DESTDIR)/gotthardDetectorServer_virtual
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c
OBJS = $(SRCS:%.c=%.o) OBJS = $(SRCS:%.c=%.o)
gotthardVirtualServer = $(PROGS) gotthardVirtualServer = $(PROGS)

View File

@ -4,10 +4,6 @@
#include "mcb_funcs.h" #include "mcb_funcs.h"
#include "registers_g.h" #include "registers_g.h"
#ifdef SHAREDMEMORY
#include "sharedmemory.h"
#endif
#include <sys/ipc.h> #include <sys/ipc.h>
#include <sys/shm.h> #include <sys/shm.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -34,9 +30,7 @@ int dataBytes=NMAXMOD*NCHIP*NCHAN*2;
int storeInRAM=0; int storeInRAM=0;
int ROI_flag=0; int ROI_flag=0;
int adcConfigured=-1; int adcConfigured=-1;
u_int32_t *ram_values=NULL;
volatile char *now_ptr=NULL;
volatile u_int16_t *values;
int ram_size=0; int ram_size=0;
int64_t totalTime=1; int64_t totalTime=1;
@ -64,6 +58,8 @@ int slaveadcphase = 0;
int rsttosw1delay = 2; int rsttosw1delay = 2;
int startacqdelay = 1; int startacqdelay = 1;
int detectorFirstServer = 1;
#ifdef MCB_FUNCS #ifdef MCB_FUNCS
extern const int nChans; extern const int nChans;
@ -187,9 +183,6 @@ int mapCSP0(void) {
printf("CSPObase is 0x%llx \n",CSP0BASE); printf("CSPObase is 0x%llx \n",CSP0BASE);
printf("CSPOBASE=from %llx to %llx\n",CSP0BASE,CSP0BASE+MEM_SIZE); printf("CSPOBASE=from %llx to %llx\n",CSP0BASE,CSP0BASE+MEM_SIZE);
u_int32_t address;
address = FIFO_DATA_REG_OFF;
values=(u_int16_t*)(CSP0BASE+address*2);
printf("statusreg=%08x\n",bus_r(STATUS_REG)); printf("statusreg=%08x\n",bus_r(STATUS_REG));
printf("\n\n"); printf("\n\n");
return OK; return OK;
@ -273,12 +266,20 @@ void setMasterSlaveConfiguration(){
} }
else { else {
cprintf(RED,"could not scan masterflags %s value from config file\n",value); cprintf(RED,"could not scan masterflags %s value from config file\n",value);
fclose(fd);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (!detectorFirstServer) {
cprintf(BLUE, "Server has been started up before. Ignoring rest of config file\n");
fclose(fd);
return;
}
} }
else { else {
if(sscanf(value,"%d",&ival)<=0) { if(sscanf(value,"%d",&ival)<=0) {
cprintf(RED,"could not scan patternphase %s value from config file\n",value); cprintf(RED,"could not scan patternphase %s value from config file\n",value);
fclose(fd);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -298,6 +299,7 @@ void setMasterSlaveConfiguration(){
startacqdelay = ival; startacqdelay = ival;
else { else {
cprintf(RED,"could not scan parameter name %s from config file\n",key); cprintf(RED,"could not scan parameter name %s from config file\n",key);
fclose(fd);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -384,6 +386,7 @@ int setPhaseShiftOnce(){
//bus_w(addr,0x0); //clear the reg //bus_w(addr,0x0); //clear the reg
if(reg==0){ if(reg==0){
detectorFirstServer = 1;
printf("\nImplementing phase shift of %d\n",phase_shift); printf("\nImplementing phase shift of %d\n",phase_shift);
for (i=1;i<phase_shift;i++) { for (i=1;i<phase_shift;i++) {
bus_w(addr,(INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT|PHASE_STEP_BIT));//0x2821 bus_w(addr,(INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT|PHASE_STEP_BIT));//0x2821
@ -392,7 +395,7 @@ int setPhaseShiftOnce(){
#ifdef VERBOSE #ifdef VERBOSE
printf("Multipupose reg now:%x\n",bus_r(addr)); printf("Multipupose reg now:%x\n",bus_r(addr));
#endif #endif
} } else detectorFirstServer = 0;
return OK; return OK;
} }
@ -839,18 +842,6 @@ u_int32_t testFpga(void) {
} }
// for fpga test
u_int32_t testRAM(void) {
int result=OK;
int i=0;
allocateRAM();
// while(i<100000) {
memcpy((char*)ram_values, (char*)values, dataBytes);
printf ("Testing RAM:\t%d: copied fifo %x to memory %x size %d\n",i++, (unsigned int)(values), (unsigned int)(ram_values), dataBytes);
// }
return result;
}
int getNModBoard() { int getNModBoard() {
return nModX; return nModX;
} }
@ -1261,7 +1252,6 @@ int setADC(int adc){
int configureMAC(int ipad,long long int macad,long long int detectormacad, int detipad, int ival, int udpport){ int configureMAC(int ipad,long long int macad,long long int detectormacad, int detipad, int ival, int udpport){
#ifdef DDEBUG #ifdef DDEBUG
printf("Chip of Intrst Reg:%x\n",bus_r(CHIP_OF_INTRST_REG)); printf("Chip of Intrst Reg:%x\n",bus_r(CHIP_OF_INTRST_REG));
printf("IP Packet Size:%d\n",ipPacketSize); printf("IP Packet Size:%d\n",ipPacketSize);
@ -1492,11 +1482,7 @@ int startStateMachine(){
//#endif //#endif
cleanFifo(); cleanFifo();
// fifoReset(); // fifoReset();
now_ptr=(char*)ram_values;
#ifdef SHAREDMEMORY
write_stop_sm(0);
write_status_sm("Started");
#endif
bus_w16(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT); bus_w16(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT);
bus_w16(CONTROL_REG, 0x0); bus_w16(CONTROL_REG, 0x0);
printf("statusreg=%08x\n",bus_r(STATUS_REG)); printf("statusreg=%08x\n",bus_r(STATUS_REG));
@ -1572,30 +1558,11 @@ u_int32_t fifo_full(void)
} }
u_int32_t* fifo_read_event() void waitForAcquisitionFinish(){
{
#ifdef VIRTUAL
return NULL;
#endif
#ifdef VERBOSE
printf("before looping\n");
#endif
volatile u_int32_t t = bus_r(LOOK_AT_ME_REG); volatile u_int32_t t = bus_r(LOOK_AT_ME_REG);
#ifdef VERBOSE #ifdef VERBOSE
printf("lookatmereg=x%x\n",t); printf("lookatmereg=x%x\n",t);
#endif #endif
/*
while ((t&0x1)==0)
{
t = bus_r(LOOK_AT_ME_REG);
if (!runBusy()){
return NULL;
}
}
*/
while((t&0x1)==0) { while((t&0x1)==0) {
if (runBusy()==0) { if (runBusy()==0) {
t = bus_r(LOOK_AT_ME_REG); t = bus_r(LOOK_AT_ME_REG);
@ -1604,7 +1571,7 @@ u_int32_t* fifo_read_event()
printf("no frame found - exiting "); printf("no frame found - exiting ");
printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
#endif #endif
return NULL; return;
} else { } else {
#ifdef VERBOSE #ifdef VERBOSE
printf("no frame found %x status %x\n", bus_r(LOOK_AT_ME_REG),runState()); printf("no frame found %x status %x\n", bus_r(LOOK_AT_ME_REG),runState());
@ -1614,37 +1581,11 @@ u_int32_t* fifo_read_event()
} }
t = bus_r(LOOK_AT_ME_REG); t = bus_r(LOOK_AT_ME_REG);
} }
#ifdef VERBOSE
printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
#endif
dma_memcpy(now_ptr,values ,dataBytes);
#ifdef VERYVERBOSE
int a;
for (a=0;a<8; a=a+2)
printf("\n%d %d: x%04x x%04x ",a+1,a,*(now_ptr+a+1),*(now_ptr+a) );
for (a=2554;a<2560; a=a+2)
printf("\n%d %d: x%04x x%04x ",a+1,a,*(now_ptr+a+1),*(now_ptr+a) );
printf("********\n");
//memcpy(now_ptr, values, dataBytes);
#endif
#ifdef VERBOSE
printf("Copying to ptr %08x %d\n",(unsigned int)(now_ptr), dataBytes);
printf("after readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
#endif
if (storeInRAM>0) {
now_ptr+=dataBytes;
}
return ram_values;
} }
u_int32_t* decode_data(int *datain) u_int32_t* decode_data(int *datain)
{ {
u_int32_t *dataout; u_int32_t *dataout;
@ -1759,83 +1700,10 @@ int testBus() {
int setStoreInRAM(int b) { int setStoreInRAM(int b) {
if (b>0) return 0;
storeInRAM=1;
else
storeInRAM=0;
return allocateRAM();
} }
int allocateRAM() {
size_t size;
u_int32_t nt, nf;
nt=setTrains(-1);
nf=setFrames(-1);
if (nt==0) nt=1;
if (nf==0) nf=1;
// ret=clearRAM();
if (storeInRAM) {
size=dataBytes*nf*nt;
if (size<dataBytes)
size=dataBytes;
} else
size=dataBytes;
#ifdef VERBOSE
printf("\nnmodx=%d nmody=%d dynamicRange=%d dataBytes=%d nFrames=%d nTrains=%d, size=%d\n",nModX,nModY,dynamicRange,dataBytes,nf,nt,(int)size );
#endif
if (size==ram_size) {
#ifdef VERBOSE
printf("RAM of size %d already allocated: nothing to be done\n",(int) size);
#endif
return OK;
}
#ifdef VERBOSE
printf("reallocating ram %x\n",(unsigned int)ram_values);
#endif
// clearRAM();
// ram_values=malloc(size);
//+2 was added since dma_memcpy would switch the 16 bit values and the mem is 32 bit
ram_values=realloc(ram_values,size)+2;
if (ram_values) {
now_ptr=(char*)ram_values;
#ifdef VERBOSE
printf("ram allocated 0x%x of size %d to %x\n",(int)now_ptr,(unsigned int) size,(unsigned int)(now_ptr+size));
#endif
ram_size=size;
return OK;
} else {
printf("could not allocate %d bytes\n",(int)size);
if (storeInRAM==1) {
printf("retrying\n");
storeInRAM=0;
size=dataBytes;
ram_values=realloc(ram_values,size)+2;
if (ram_values==NULL)
printf("Fatal error: there must be a memory leak somewhere! You can't allocate even one frame!\n");
else {
now_ptr=(char*)ram_values;
ram_size=size;
#ifdef VERBOSE
printf("ram allocated 0x%x of size %d to %x\n",(int)now_ptr,(unsigned int) size,(unsigned int)(now_ptr+size));
#endif
}
} else {
printf("Fatal error: there must be a memory leak somewhere! You can't allocate even one frame!\n");
}
return FAIL;
}
}
int configureADC(){ int configureADC(){
@ -1857,7 +1725,7 @@ int configureADC(){
// start point // start point
valw=0xff; valw=0xffffffff;
bus_w(ADC_SPI_REG,(valw)); bus_w(ADC_SPI_REG,(valw));
//chip sel bar down //chip sel bar down
@ -1868,23 +1736,28 @@ int configureADC(){
//cldwn //cldwn
valw=valw&(~(0x1<<cdx)); valw=valw&(~(0x1<<cdx));
bus_w(ADC_SPI_REG,valw); bus_w(ADC_SPI_REG,valw);
usleep(0); //usleep(0);
//write data (i) //write data (i)
valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx); valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx);
bus_w(ADC_SPI_REG,valw); bus_w(ADC_SPI_REG,valw);
usleep(0); //usleep(0);
//clkup //clkup
valw=valw+(0x1<<cdx); valw=valw+(0x1<<cdx);
bus_w(ADC_SPI_REG,valw); bus_w(ADC_SPI_REG,valw);
usleep(0); //usleep(0);
} }
valw |= csmask;
bus_w(ADC_SPI_REG,valw);
//usleep(0);
// stop point =start point // stop point =start point
valw=valw&(~(0x1<<cdx)); valw=valw&(~(0x1<<cdx));
usleep(0); bus_w(ADC_SPI_REG,(valw));
valw=0xff;
valw = 0xffffffff;
bus_w(ADC_SPI_REG,(valw)); bus_w(ADC_SPI_REG,(valw));
//usleep in between //usleep in between
@ -1892,78 +1765,9 @@ int configureADC(){
} }
return OK; return OK;
/*
codata=0;
codata=(0x14<<8)+(0x0); //command and value;
valw=0xff; bus_w(ADC_SPI_REG,(valw)); // start point
valw=((0xffffffff&(~csmask)));bus_w(ADC_SPI_REG,valw); //chip sel bar down
for (i=0;i<24;i++) {
valw=valw&(~(0x1<<cdx));bus_w(ADC_SPI_REG,valw);usleep(0); //cldwn
valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx); bus_w(ADC_SPI_REG,valw); usleep(0); //write data (i)
valw=valw+(0x1<<cdx);bus_w(ADC_SPI_REG,valw); usleep(0); //clkup
}
valw=valw&(~(0x1<<cdx));usleep(0);
valw=0xff; bus_w(ADC_SPI_REG,(valw)); // stop point =start point
usleep(5000);
codata=0;
codata=(0x08<<8)+(0x3); //command and value;Power modes(global) reset
valw=0xff; bus_w(ADC_SPI_REG,(valw)); // start point
valw=((0xffffffff&(~csmask)));bus_w(ADC_SPI_REG,valw); //chip sel bar down
for (i=0;i<24;i++) {
valw=valw&(~(0x1<<cdx));bus_w(ADC_SPI_REG,valw);usleep(0); //cldwn
valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx); bus_w(ADC_SPI_REG,valw); usleep(0); //write data (i)
valw=valw+(0x1<<cdx);bus_w(ADC_SPI_REG,valw); usleep(0); //clkup
}
valw=valw&(~(0x1<<cdx));usleep(0);
valw=0xff; bus_w(ADC_SPI_REG,(valw)); // stop point =start point
usleep(50000);
codata=0;
codata=(0x08<<8)+(0x0); //command and value;Power modes(global) reset
valw=0xff; bus_w(ADC_SPI_REG,(valw)); // start point
valw=((0xffffffff&(~csmask)));bus_w(ADC_SPI_REG,valw); //chip sel bar down
for (i=0;i<24;i++) {
valw=valw&(~(0x1<<cdx));bus_w(ADC_SPI_REG,valw);usleep(0); //cldwn
valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx); bus_w(ADC_SPI_REG,valw); usleep(0); //write data (i)
valw=valw+(0x1<<cdx);bus_w(ADC_SPI_REG,valw); usleep(0); //clkup
}
valw=valw&(~(0x1<<cdx));usleep(0);
valw=0xff; bus_w(ADC_SPI_REG,(valw)); // stop point =start point
*/
} }
int clearRAM() {
if (ram_values) {
//#ifdef VERBOSE
//printf("clearing RAM 0x%x\n", ram_values);
//#endif
free(ram_values);
ram_values=NULL;
now_ptr=NULL;
}
//#ifdef VERBOSE
//printf("done 0x%x\n", ram_values);
//#endif
return OK;
}
@ -2111,113 +1915,7 @@ int resetCounterBlock(int startACQ){
int calibratePedestal(int frames){ int calibratePedestal(int frames){
printf("---------------------------\n"); // removed this functionlity as it requires reading via cpu
printf("In Calibrate Pedestal\n");
int64_t framesBefore = getFrames();
int64_t periodBefore = getPeriod();
setFrames(frames);
setPeriod(1000000);
int dataret = OK;
double avg[1280];
int numberFrames = 0;
int adc = 3;
int adcCh = 3;
int Ch = 3;
int i = 0;
for(i =0; i < 1280; i++){
avg[i] = 0.0;
}
startReceiver(0);
startStateMachine();
while(dataret==OK){
//got data
if (fifo_read_event()) {
dataret=OK;
//sendDataOnly(file_des,&dataret,sizeof(dataret));
//sendDataOnly(file_des,dataretval,dataBytes);
printf("received frame\n");
unsigned short *frame = (unsigned short *)now_ptr;
int a;
for (a=0;a<1280; a++){
//unsigned short v = (frame[a] << 8) + (frame[a] >> 8);
// printf("%i: %i %i\n",a, frame[a],v);
avg[a] += ((double)frame[a])/(double)frames;
//if(frame[a] == 8191)
// printf("ch %i: %u\n",a,frame[a]);
}
// printf("********\n");
numberFrames++;
}
//no more data or no data
else {
if(getFrames()>-2) {
dataret=FAIL;
printf("no data and run stopped: %d frames left\n",(int)(getFrames()+2));
} else {
dataret=FINISHED;
printf("acquisition successfully finished\n");
}
printf("dataret %d\n",dataret);
}
}
//double nf = (double)numberFrames;
for(i =0; i < 1280; i++){
adc = i / 256;
adcCh = (i - adc * 256) / 32;
Ch = i - adc * 256 - adcCh * 32;
adc--;
double v2 = avg[i];
avg[i] = avg[i]/ ((double)numberFrames/(double)frames);
unsigned short v = (unsigned short)avg[i];
printf("setting avg for channel %i(%i,%i,%i): %i (double= %f (%f))\t", i,adc,adcCh,Ch, v,avg[i],v2);
v=i*100;
ram_w16(DARK_IMAGE_REG,adc,adcCh,Ch,v-4096);
if(ram_r16(DARK_IMAGE_REG,adc,adcCh,Ch) != v-4096){
printf("value is wrong (%i,%i,%i): %i \n",adc,adcCh,Ch, ram_r16(DARK_IMAGE_REG,adc,adcCh,Ch));
}
}
/*for(adc = 1; adc < 5; adc++){
for(adcCh = 0; adcCh < 8; adcCh++){
for(Ch=0 ; Ch < 32; Ch++){
int channel = (adc+1) * 32 * 8 + adcCh * 32 + Ch;
double v2 = avg[channel];
avg[channel] = avg[channel]/ ((double)numberFrames/(double)frames);
unsigned short v = (unsigned short)avg[channel];
printf("setting avg for channel %i: %i (double= %f (%f))\t", channel, v,avg[channel],v2);
ram_w16(DARK_IMAGE_REG,adc,adcCh,Ch,v-4096);
if(ram_r16(DARK_IMAGE_REG,adc,adcCh,Ch) != v-4096){
printf("value is wrong (%i,%i,%i): %i \n",adc,adcCh,Ch, ram_r16(DARK_IMAGE_REG,adc,adcCh,Ch));
}
}
}
}*/
printf("frames: %i\n",numberFrames);
printf("corrected avg by: %f\n",(double)numberFrames/(double)frames);
printf("restoring previous condition\n");
setFrames(framesBefore);
setPeriod(periodBefore);
printf("---------------------------\n"); printf("---------------------------\n");
return 0; return 0;
} }

View File

@ -77,7 +77,6 @@ u_int32_t getFirmwareVersion();
u_int32_t getFirmwareSVNVersion(); u_int32_t getFirmwareSVNVersion();
int testFifos(void); int testFifos(void);
u_int32_t testFpga(void); u_int32_t testFpga(void);
u_int32_t testRAM(void);
int testBus(void); int testBus(void);
int setDigitalTestBit(int ival); int setDigitalTestBit(int ival);
@ -128,8 +127,8 @@ u_int32_t fifoReadStatus();
u_int32_t fifo_full(void); u_int32_t fifo_full(void);
void waitForAcquisitionFinish();
u_int32_t* fifo_read_event();
u_int32_t* decode_data(int* datain); u_int32_t* decode_data(int* datain);
//u_int32_t move_data(u_int64_t* datain, u_int64_t* dataout); //u_int32_t move_data(u_int64_t* datain, u_int64_t* dataout);
int setDynamicRange(int dr); int setDynamicRange(int dr);
@ -137,8 +136,7 @@ int getDynamicRange();
int getNModBoard(); int getNModBoard();
int setNMod(int n); int setNMod(int n);
int setStoreInRAM(int b); int setStoreInRAM(int b);
int allocateRAM();
int clearRAM();

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/gotthardDetectorServer Path: slsDetectorsPackage/slsDetectorSoftware/gotthardDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 548036a602123cb3c06bbf4f9a40c9acd6c527fc Repsitory UUID: c52025dd7c4b44b93e64353a22997d971996ab18
Revision: 236 Revision: 237
Branch: developer Branch: developer
Last Changed Author: Dhanya_Thattil Last Changed Author: Gemma_Tinti
Last Changed Rev: 3988 Last Changed Rev: 3999
Last Changed Date: 2018-08-23 11:57:31.000000002 +0200 ./server_funcs.h Last Changed Date: 2018-09-28 16:10:41.000000002 +0200 ./server_funcs.c

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "548036a602123cb3c06bbf4f9a40c9acd6c527fc" #define GITREPUUID "c52025dd7c4b44b93e64353a22997d971996ab18"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Gemma_Tinti"
#define GITREV 0x3988 #define GITREV 0x3999
#define GITDATE 0x20180823 #define GITDATE 0x20180928
#define GITBRANCH "developer" #define GITBRANCH "developer"

View File

@ -107,7 +107,6 @@ int initDetector() {
// initChip(0, 0,ALLMOD); // initChip(0, 0,ALLMOD);
//nModX=n; //nModX=n;
// //
allocateRAM();
return OK; return OK;
@ -1831,205 +1830,19 @@ int testDataInOut(int num, int imod) {
int testExtPulse(int imod) { int testExtPulse(int imod) {
int i, ichan, ichip, result=OK; // reading via cPU doesnt work, so removed this functionality
int *val1;
printf("Testing counter for module %d\n", imod);
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
putout("0000000000000000",ALLMOD);
putout("0000100000000000",ALLMOD);
putout("0000000000000000",ALLMOD);
for (i=0; i<NCHAN; i++) {
putout("0000000000000000",ALLMOD);
putout("0000000000001000",ALLMOD);
putout("0000000000000000",ALLMOD);
extPulse(1,ALLMOD);
}
clearSSregister(ALLMOD);
putout("0000000000000000",ALLMOD);
// Readout with SM
//startStateMachine();
startReadOut();
usleep(100);
val1=(int*)(decode_data((int*)(fifo_read_event())));
// val1=fifo_read_event();
//imod=0;
//for (imod=0; imod<nModX; imod++) {
for (ichip=0; ichip<NCHIP; ichip++) {
for (ichan=0; ichan<NCHAN; ichan++) {//
if ((*(val1+ichan+(ichip+imod*NCHIP)*NCHAN))!=ichan) {
result++;
printf("Counter test: channel %d read %d instead of %d\n",ichan+(ichip+imod*NCHIP)*NCHAN, val1[ichan+(ichip+imod*NCHIP)*NCHAN], ichan);
}
}
}
//}
free(val1);
if (result)
return 1;
else
return 0; return 0;
} }
int testExtPulseMux(int imod, int ow) { int testExtPulseMux(int imod, int ow) {
// reading via cPU doesnt work, so removed this functionality
int i, ichan, ichip, result=0, ind, chipr=0;
int *values, *v1;
int vright,v;
int nbit_mask=0xffffff;
printf("Testing counter for module %d, mux %d\n", imod, ow);
setExposureTime(0);
setFrames(1);
setTrains(1);
if (ow==2)
nbit_mask=0xffff;
else if (ow==3)
nbit_mask=0xff;
else if (ow==4)
nbit_mask=0xf;
else if (ow==5)
nbit_mask=0x1;
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
initChipWithProbes(0, ow,0,ALLMOD);
// initChip(0, ow,ALLMOD);
for (ichip=0; ichip<NCHIP; ichip++) {
setSSregister(ALLMOD);
for (i=0; i<NCHAN; i++) {
putout("0000000000000000",ALLMOD);
putout("0000000000001000",ALLMOD);
putout("0000000000000000",ALLMOD);
extPulse(1,ALLMOD);
}
nextChip(ALLMOD);
}
setCSregister(ALLMOD);
clearSSregister(ALLMOD);
putout("0000000000000000",ALLMOD);
// Readout with SM
startReadOut();
usleep(100);
v1=(int*)(fifo_read_event());
if (v1)
values=(int*)(decode_data(v1));
else {
printf("no data found in fifos\n");
return 1;
}
for (ichip=0; ichip<NCHIP; ichip++) {
chipr=0;
for (ichan=0; ichan<NCHAN; ichan++) {
ind=ichan+(ichip+imod*NCHIP)*NCHAN;
v=values[ind];
vright=(ichan*(ichip+1))&nbit_mask;
if (v!=vright) {
result++;
chipr++;
printf("Counter test mux %d mode: channel %d chip %d read %d instead of %d\n",ow, ichan+(ichip+imod*NCHIP)*NCHAN, ichip, v, vright);
//break;
}
//printf("\n");
}
if (chipr)
printf("Test Counter module %d chip%d mux %d: %d errors\n", imod,ichip, ow,chipr);
}
free(values);
if (result)
printf("Test Counter module %d mux %d: %d errors\n", imod,ow,result);
if (result)
return 1;
else
return 0; return 0;
} }
int testDataInOutMux(int imod, int ow, int num) { int testDataInOutMux(int imod, int ow, int num) {
// reading via cPU doesnt work, so removed this functionality
int ichan, ichip, result=0, chipr=0, ind;
int vright,v;
int nbit_mask=0xffffff;
int *values, *v1;
printf("Testing data inout for module %d, mux %d, pattern 0x%x\n", imod, ow, num);
setExposureTime(0);
setFrames(1);
setTrains(1);
if (ow==2)
nbit_mask=0xffff;
else if (ow==3)
nbit_mask=0xff;
else if (ow==4)
nbit_mask=0xf;
else if (ow==5)
nbit_mask=0x1;
vright=num&nbit_mask;
setCSregister(ALLMOD);
//printf("Testin data in out\n");
setSSregister(ALLMOD);
counterClear(ALLMOD);
initChannel(0,0,0,0,0,num,ALLMOD);
putout("0000000000000000",ALLMOD);
clearSSregister(ALLMOD);
initChipWithProbes(0, ow,0,ALLMOD);
clearSSregister(ALLMOD);
putout("0000000000000000",ALLMOD);
// Readout with SM
printf("mux %d\n",ow);
startReadOut();
usleep(100);
v1=(int*)(fifo_read_event());
if (v1)
values=(int*)(decode_data(v1));
else {
printf("no data found in fifos\n");
return 1;
}
for (ichip=0; ichip<NCHIP; ichip++) {
chipr=0;
for (ichan=0; ichan<NCHAN; ichan++) {
ind=ichan+(ichip+imod*NCHIP)*NCHAN;
v=values[ind];
if (v!=vright) {
result++;
chipr++;
printf("DataInOut test mux %d mode: channel %d chip %d read %d instead of %d\n",ow, ichan+(ichip+imod*NCHIP)*NCHAN, ichip, v, vright);
//break;
}
//printf("\n");
}
if (chipr)
printf("Test DatInOut module %d chip %d mux %d: %d errors\n", imod,ichip, ow,chipr);
}
if (result)
printf("Test DatInOut module %d mux %d: %d errors\n", imod,ow,result);
free(values);
if (result)
return 1;
else
return 0; return 0;
} }
@ -2486,7 +2299,7 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret){
} }
} }
} }
printf("\tGoing to enable adc: %d\n", adc);
//set rois for just 1 adc - take only 1st roi //set rois for just 1 adc - take only 1st roi
if(adc!=-1){ if(adc!=-1){
@ -2495,10 +2308,14 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret){
rois[0].ymin=-1; rois[0].ymin=-1;
rois[0].ymax=-1; rois[0].ymax=-1;
nROI = 1; nROI = 1;
printf("\tActual xmin:%d xmax:%d\n",rois[0].xmin,rois[0].xmax);
}else }else
nROI = 0; nROI = 0;
if((arg[0].xmin!=rois[0].xmin)||(arg[0].xmax!=rois[0].xmax)||(arg[0].ymin!=rois[0].ymin)||(arg[0].ymax!=rois[0].ymax)) if((n!=0) && ((arg[0].xmin!=rois[0].xmin)||
(arg[0].xmax!=rois[0].xmax)||
(arg[0].ymin!=rois[0].ymin)||
(arg[0].ymax!=rois[0].ymax)))
*ret=FAIL; *ret=FAIL;
if(n!=nROI) if(n!=nROI)
*ret=FAIL; *ret=FAIL;
@ -2508,9 +2325,11 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret){
} }
//#ifdef VERBOSE //#ifdef VERBOSE
if (nROI) {
printf("Rois:\n"); printf("Rois:\n");
for( i=0;i<nROI;i++) for( i=0;i<nROI;i++)
printf("%d\t%d\t%d\t%d\n",rois[i].xmin,rois[i].xmax,rois[i].ymin,rois[i].ymax); printf("\t%d\t%d\t%d\t%d\n\n",rois[i].xmin,rois[i].xmax,rois[i].ymin,rois[i].ymax);
}else printf("Rois: 0\n\n");
//#endif //#endif
*retvalsize = nROI; *retvalsize = nROI;
return rois; return rois;

View File

@ -47,8 +47,8 @@
#define DEFAULT_PHASE_SHIFT 120 #define DEFAULT_PHASE_SHIFT 120
#define DEFAULT_IP_PACKETSIZE 0x0522 #define DEFAULT_IP_PACKETSIZE 0x0522
#define DEFAULT_UDP_PACKETSIZE 0x050E #define DEFAULT_UDP_PACKETSIZE 0x050E
#define ADC1_IP_PACKETSIZE 256*2+14+20 #define ADC1_IP_PACKETSIZE (256*2+14+20)
#define ADC1_UDP_PACKETSIZE 256*2+4+8+2 #define ADC1_UDP_PACKETSIZE (256*2+4+8+2)
#ifdef VIRTUAL #ifdef VIRTUAL
#define DEBUGOUT #define DEBUGOUT

View File

@ -7,7 +7,6 @@
#endif #endif
#include "firmware_funcs.h" #include "firmware_funcs.h"
#include "mcb_funcs.h" #include "mcb_funcs.h"
#include "trimming_funcs.h"
#include "registers_g.h" #include "registers_g.h"
#include "gitInfoGotthard.h" #include "gitInfoGotthard.h"
#include "AD9257.h" // include "commonServerFunctions.h" #include "AD9257.h" // include "commonServerFunctions.h"
@ -82,11 +81,11 @@ int init_detector( int b) {
printf("Initializing Detector\n"); printf("Initializing Detector\n");
#endif #endif
testFpga(); testFpga();
testRAM();
//gotthard specific //gotthard specific
setPhaseShiftOnce(); setPhaseShiftOnce();
configureADC(); configureADC();
setADC(-1); //already does setdaqreg and clean fifo setADC(-1); //already does setdaqreg and clean fifo
setSettings(DYNAMICGAIN,-1); setSettings(DYNAMICGAIN,-1);
setDefaultDacs(); setDefaultDacs();
@ -101,7 +100,7 @@ int init_detector( int b) {
setTiming(GET_EXTERNAL_COMMUNICATION_MODE); setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
setMaster(GET_MASTER); setMaster(GET_MASTER);
setSynchronization(GET_SYNCHRONIZATION_MODE); setSynchronization(GET_SYNCHRONIZATION_MODE);
startReceiver(0); startReceiver(1);
setMasterSlaveConfiguration(); setMasterSlaveConfiguration();
} }
strcpy(mess,"dummy message"); strcpy(mess,"dummy message");
@ -709,9 +708,9 @@ int digital_test(int file_des) {
case DETECTOR_FIRMWARE_TEST: case DETECTOR_FIRMWARE_TEST:
retval=testFpga(); retval=testFpga();
break; break;
case DETECTOR_MEMORY_TEST: /*case DETECTOR_MEMORY_TEST:
ret=testRAM(); ret=testRAM();
break; break;*/
case DETECTOR_BUS_TEST: case DETECTOR_BUS_TEST:
retval=testBus(); retval=testBus();
break; break;
@ -1918,92 +1917,43 @@ int get_run_status(int file_des) {
} }
int read_frame(int file_des) { int read_frame(int file_des) {
dataret = FAIL;
strcpy(mess,"wait for read frame failed\n");
if (differentClients==1 && lockStatus==1) { if (differentClients==1 && lockStatus==1) {
dataret=FAIL; dataret=FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP); sprintf(mess,"Detector locked by %s\n",lastClientIP);
cprintf(RED,"%s\n",mess);
sendDataOnly(file_des,&dataret,sizeof(dataret)); sendDataOnly(file_des,&dataret,sizeof(dataret));
sendDataOnly(file_des,mess,sizeof(mess)); sendDataOnly(file_des,mess,sizeof(mess));
#ifdef VERBOSE
printf("dataret %d\n",dataret);
#endif
return dataret; return dataret;
} }
if (storeInRAM==0) {
if ((dataretval=(char*)fifo_read_event())) { #ifdef VIRTUAL
dataret=OK; dataret = FINISHED;
#ifdef VERYVERBOSE strcpy(mess,"acquisition successfully finished\n");
printf("Sending ptr %x %d\n",(unsigned int)(dataretval), dataBytes); #else
#endif waitForAcquisitionFinish();
sendDataOnly(file_des,&dataret,sizeof(dataret));
sendDataOnly(file_des,dataretval,dataBytes); // set return value and message
#ifdef VERBOSE
printf("sent %d bytes \n",dataBytes);
printf("dataret OK\n");
#endif
return OK;
} else {
//might add delay????
if(getFrames()>-2) { if(getFrames()>-2) {
dataret = FAIL; dataret = FAIL;
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2)); sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2));
printf("%s\n",mess); cprintf(RED,"%s\n",mess);
} else { } else {
dataret = FINISHED; dataret = FINISHED;
sprintf(mess,"acquisition successfully finished\n"); sprintf(mess,"acquisition successfully finished\n");
printf("%s\n",mess); cprintf(GREEN,"%s",mess);
} }
#ifdef VERYVERBOSE
printf("%d %d %x %s\n",(int)(sizeof(mess)),(int)(strlen(mess)),(unsigned int)( mess),mess);
#endif #endif
sendDataOnly(file_des,&dataret,sizeof(dataret));
sendDataOnly(file_des,mess,sizeof(mess));
#ifdef VERYVERBOSE
printf("message sent %s\n",mess);
#endif
printf("dataret %d\n",dataret);
return dataret;
}
} else {
nframes=0;
while(fifo_read_event()) {
nframes++;
}
dataretval=(char*)ram_values;
dataret=OK;
#ifdef VERBOSE
printf("sending data of %d frames\n",nframes);
#endif
for (iframes=0; iframes<nframes; iframes++) {
sendDataOnly(file_des,&dataret,sizeof(dataret));
#ifdef VERYVERBOSE
printf("sending pointer %x of size %d\n",(unsigned int)(dataretval),dataBytes);
#endif
sendDataOnly(file_des,dataretval,dataBytes);
dataretval+=dataBytes;
}
if (getFrames()>-2) {
dataret=FAIL;
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2));
printf("%s\n",mess);
} else {
dataret=FINISHED;
sprintf(mess,"acquisition successfully finished\n");
printf("%s\n",mess);
if (differentClients) if (differentClients)
dataret=FORCE_UPDATE; dataret=FORCE_UPDATE;
}
#ifdef VERBOSE
printf("Frames left %d\n",(int)(getFrames()));
#endif
sendDataOnly(file_des,&dataret,sizeof(dataret)); sendDataOnly(file_des,&dataret,sizeof(dataret));
sendDataOnly(file_des,mess,sizeof(mess)); sendDataOnly(file_des,mess,sizeof(mess));
printf("dataret %d\n",dataret);
return dataret;
}
printf("dataret %d\n",dataret);
return dataret; return dataret;
} }
@ -2096,9 +2046,9 @@ int set_timer(int file_des) {
printf(mess); printf(mess);
} }
#ifdef VERBOSE //#ifdef VERBOSE
printf("setting timer %d to %lld ns\n",ind,tns); printf("setting timer %d to %lld ns\n",ind,tns);
#endif //#endif
if (ret==OK) { if (ret==OK) {
if (differentClients==1 && lockStatus==1 && tns!=-1) { if (differentClients==1 && lockStatus==1 && tns!=-1) {
@ -2149,10 +2099,6 @@ int set_timer(int file_des) {
if (ret!=OK) { if (ret!=OK) {
printf(mess); printf(mess);
printf("set timer failed\n"); printf("set timer failed\n");
} else if (ind==FRAME_NUMBER) {
ret=allocateRAM();
if (ret!=OK)
sprintf(mess, "could not allocate RAM for %lld frames\n", tns);
} }
n = sendDataOnly(file_des,&ret,sizeof(ret)); n = sendDataOnly(file_des,&ret,sizeof(ret));
@ -2293,12 +2239,6 @@ int set_dynamic_range(int file_des) {
//if (dr>=0 && retval!=dr) ret=FAIL; //if (dr>=0 && retval!=dr) ret=FAIL;
if (ret!=OK) { if (ret!=OK) {
sprintf(mess,"set dynamic range failed\n"); sprintf(mess,"set dynamic range failed\n");
} else {
ret=allocateRAM();
if (ret!=OK)
sprintf(mess,"Could not allocate RAM for the dynamic range selected\n");
else if (differentClients)
ret=FORCE_UPDATE;
} }
n = sendDataOnly(file_des,&ret,sizeof(ret)); n = sendDataOnly(file_des,&ret,sizeof(ret));
@ -2341,9 +2281,9 @@ int set_roi(int file_des) {
ret=FAIL; ret=FAIL;
} }
//#ifdef VERBOSE //#ifdef VERBOSE
printf("Setting ROI to:"); printf("\n\nSetting ROI: nroi=%d\n",nroi);
for( i=0;i<nroi;i++) for( i=0;i<nroi;i++)
printf("%d\t%d\t%d\t%d\n",arg[i].xmin,arg[i].xmax,arg[i].ymin,arg[i].ymax); printf("\t%d\t%d\t%d\t%d\n",arg[i].xmin,arg[i].xmax,arg[i].ymin,arg[i].ymax);
//#endif //#endif
} }
/* execute action if the arguments correctly arrived*/ /* execute action if the arguments correctly arrived*/

View File

@ -1,39 +0,0 @@
#include "sharedmemory.h"
struct statusdata *stdata;
int inism(int clsv) {
static int scansmid;
if (clsv==SMSV) {
if ( (scansmid=shmget(SMKEY,1024,IPC_CREAT | 0666 ))==-1 ) {
return -1;
}
if ( (stdata=shmat(scansmid,NULL,0))==(void*)-1) {
return -2;
}
}
if (clsv==SMCL) {
if ( (scansmid=shmget(SMKEY,0,0) )==-1 ) {
return -3;
}
if ( (stdata=shmat(scansmid,NULL,0))==(void*)-1) {
return -4;
}
}
return 1;
}
void write_status_sm(char *status) {
strcpy(stdata->status,status);
}
void write_stop_sm(int v) {
stdata->stop=v;
}
void write_runnumber_sm(int v) {
stdata->runnumber=v;
}

View File

@ -1,48 +0,0 @@
#ifndef SM
#define SM
#include "sls_detector_defs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
//#include <asm/page.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
#include <sys/shm.h>
#include <sys/ipc.h>
#include <sys/stat.h>
/* key for shared memory */
#define SMKEY 10001
#define SMSV 1
#define SMCL 2
struct statusdata {
int runnumber;
int stop;
char status[20];
} ;
/* for shared memory */
int inism(int clsv);
void write_status_sm(char *status);
void write_stop_sm(int v);
void write_runnumber_sm(int v);
#endif

View File

@ -1,749 +0,0 @@
#ifndef PICASSOD
#include "server_defs.h"
#else
#include "picasso_defs.h"
#endif
#include "trimming_funcs.h"
#include "mcb_funcs.h"
#include "firmware_funcs.h"
#include <math.h>
extern int nModX;
//extern int *values;
extern const int nChans;
extern const int nChips;
extern const int nDacs;
extern const int nAdcs;
int trim_fixed_settings(int countlim, int par2, int im)
{
int retval=OK;
#ifdef VERBOSE
printf("Trimming with fixed settings\n");
#endif
#ifdef VIRTUAL
return OK;
#endif
if (par2<=0)
retval=trim_with_level(countlim, im);
else
retval=trim_with_median(countlim,im);
return retval;
}
int trim_with_noise(int countlim, int nsigma, int im)
{
int retval=OK, retval1=OK, retval2=OK;
#ifdef VERBOSE
printf("Trimming using noise\n");
#endif
#ifdef VIRTUAL
return OK;
#endif
/* threshold scan */
#ifdef VERBOSE
printf("chosing vthresh and vtrim.....");
#endif
retval1=choose_vthresh_and_vtrim(countlim,nsigma, im);
#ifdef VERBOSE
printf("trimming with noise.....\n");
#endif
retval2=trim_with_level(countlim, im);
#ifdef DEBUGOUT
printf("done\n");
#endif
if (retval1==OK && retval2==OK)
retval=OK;
else
retval=FAIL;
return retval;
}
int trim_with_beam(int countlim, int nsigma, int im) //rpc
{
int retval=OK, retval1=OK, retval2=OK;
printf("Trimming using beam\n");
//return OK;
#ifdef VIRTUAL
printf("Trimming using beam\n");
return OK;
#endif
/* threshold scan */
#ifdef DEBUGOUT
printf("chosing vthresh and vtrim.....");
#endif
retval1=choose_vthresh_and_vtrim(countlim,nsigma,im);
retval2=trim_with_median(TRIM_DR, im);
#ifdef DEBUGOUT
printf("done\n");
#endif
if (retval1==OK && retval2==OK)
retval=OK;
else
retval=FAIL;
return retval;
}
int trim_improve(int maxit, int par2, int im) //rpc
{
int retval=OK, retval1=OK, retval2=OK;
#ifdef VERBOSE
printf("Improve the trimming\n");
#endif
#ifdef VIRTUAL
return OK;
#endif
if (par2!=0 && im==ALLMOD)
retval1=choose_vthresh();
retval2=trim_with_median(2*maxit+1, im);
#ifdef DEBUGOUT
printf("done\n");
#endif
if (retval1==OK && retval2==OK)
retval=OK;
else
retval=FAIL;
return retval;
}
int calcthr_from_vcal(int vcal) {
int thrmin;
//thrmin=140+3*vcal/5;
thrmin=180+3*vcal/5;
return thrmin;
}
int calccal_from_vthr(int vthr) {
int vcal;
vcal=5*(vthr-140)/3;
return vcal;
}
int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
int retval=OK;
#ifdef MCB_FUNCS
int modma, modmi, nm;
int thr, thrstep=5, nthr=31;
int *fifodata;
double vthreshmean, vthreshSTDev;
int *thrmi, *thrma;
double c;
//double b=BVTRIM;
//double a=AVTRIM;
int *trim;
int ich, imod, ichan;
int nvalid=0;
u_int32_t *scan;
int ithr;
sls_detector_channel myChan;
setFrames(1);
// setNMod(getNModBoard());
if (im==ALLMOD){
modmi=0;
modma=nModX;
} else {
modmi=im;
modma=im+1;
}
nm=modma-modmi;
trim=malloc(sizeof(int)*nChans*nChips*nModX);
thrmi=malloc(sizeof(int)*nModX);
thrma=malloc(sizeof(int)*nModX);
for (ich=0; ich<nChans*nChips*nm; ich++)
trim[ich]=-1;
/*
setCSregister(im);
setSSregister(im);
initChannel(0,0,0,1,0,0,im);
counterClear(im);
clearSSregister(im);
usleep(500);
*/
myChan.chan=-1;
myChan.chip=-1;
myChan.module=ALLMOD;
myChan.reg=COMPARATOR_ENABLE;
initChannelbyNumber(myChan);
for (ithr=0; ithr<nthr; ithr++) {
fifoReset();
/* scanning threshold */
for (imod=modmi; imod<modma; imod++) {
//commented out by dhanya thr=getDACbyIndexDACU(VTHRESH,imod);
if (ithr==0) {
thrmi[imod]=thr;
//commented out by dhanya initDACbyIndexDACU(VTHRESH,thr,imod);
} else
;//commented out by dhanya initDACbyIndexDACU(VTHRESH,thr+thrstep,imod);
}
/* setCSregister(ALLMOD);
setSSregister(ALLMOD);
initChannel(0,0,0,1,0,0,im);
setDynamicRange(32);
*/
counterClear(ALLMOD);
clearSSregister(ALLMOD);
usleep(500);
startStateMachine();
while (runBusy()) {
}
usleep(500);
fifodata=(int*)fifo_read_event();
scan=decode_data(fifodata);
for (imod=modmi; imod<modma; imod++) {
for (ichan=0; ichan<nChans*nChips; ichan++){
ich=imod*nChips*nChans+ichan;
if (scan[ich]>countlim && trim[ich]==-1) {
//commented out by dhanya trim[ich]=getDACbyIndexDACU(VTHRESH,imod);
#ifdef VERBOSE
// printf("yes: %d %d %d\n",ich,ithr,scan[ich]);
#endif
}
#ifdef VERBOSE
/* else {
printf("no: %d %d %d\n",ich,ithr,scan[ich]);
}*/
#endif
}
}
free(scan);
}
for (imod=modmi; imod<modma; imod++) {
vthreshmean=0;
vthreshSTDev=0;
nvalid=0;
//commented out by dhanya thrma[imod]=getDACbyIndexDACU(VTHRESH,imod);
for (ichan=0; ichan<nChans*nChips; ichan++){
ich=imod*nChans*nChips+ichan;
if(trim[ich]>thrmi[imod] && trim[ich]<thrma[imod]) {
vthreshmean=vthreshmean+trim[ich];
vthreshSTDev=vthreshSTDev+trim[ich]*trim[ich];
nvalid++;
}
}
if (nvalid>0) {
vthreshmean=vthreshmean/nvalid;
//commented out by dhanya vthreshSTDev=sqrt((vthreshSTDev/nvalid)-vthreshmean*vthreshmean);
} else {
vthreshmean=thrmi[imod];
vthreshSTDev=nthr*thrstep;
printf("No valid channel for module %d\n",imod);
retval=FAIL;
}
#ifdef DEBUGOUT
printf("module= %d nvalid = %d mean=%f RMS=%f\n",imod, nvalid, vthreshmean,vthreshSTDev);
#endif
// *vthresh=round(vthreshmean-nsigma*vthreshSTDev);
thr=(int)(vthreshmean-nsigma*vthreshSTDev);
if (thr<0 || thr>(DAC_DR-1)) {
thr=thrmi[imod]/2;
printf("Can't find correct threshold for module %d\n",imod);
retval=FAIL;
}
//commented out by dhanya initDACbyIndexDACU(VTHRESH,thr,imod);
#ifdef VERBOSE
printf("vthresh=%d \n",thr);
#endif
c=CVTRIM-2.*nsigma*vthreshSTDev/63.;
//commented out by dhanya thr=(int)((-b-sqrt(b*b-4*a*c))/(2*a));
if (thr<500 || thr>(DAC_DR-1)) {
thr=750;
printf("Can't find correct trimbit size for module %d\n",imod);
retval=FAIL;
}
//commented out by dhanya initDACbyIndexDACU(VTRIM,thr,imod);
#ifdef VERBOSE
printf("vtrim=%d \n",thr);
#endif
}
free(trim);
free(thrmi);
free(thrma);
#endif
return retval;
}
int trim_with_level(int countlim, int im) {
int ich, itrim, ichan, ichip, imod;
u_int32_t *scan;
int *inttrim;
int modma, modmi, nm;
int retval=OK;
int *fifodata;
sls_detector_channel myChan;
printf("trimming module number %d", im);
#ifdef MCB_FUNCS
setFrames(1);
// setNMod(getNModBoard());
if (im==ALLMOD){
modmi=0;
modma=nModX;
} else {
modmi=im;
modma=im+1;
}
nm=modma-modmi;
inttrim=malloc(sizeof(int)*nChips*nChans*nModX);
printf("countlim=%d\n",countlim);
for (ich=0; ich<nChans*nChips*nModX; ich++)
inttrim[ich]=-1;
for (itrim=0; itrim<TRIM_DR+1; itrim++) {
fifoReset();
printf("Trimbit %d\n",itrim);
myChan.chan=-1;
myChan.chip=-1;
myChan.module=ALLMOD;
myChan.reg=COMPARATOR_ENABLE|(itrim<<TRIMBIT_OFF);
initChannelbyNumber(myChan);
/*
setCSregister(im);
setSSregister(im);
initChannel(itrim,0,0,1,0,0,ALLMOD);
setDynamicRange(32);
*/
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
clearSSregister(ALLMOD);
usleep(500);
startStateMachine();
while (runBusy()) {
}
usleep(500);
fifodata=(int*)fifo_read_event();
scan=decode_data(fifodata);
for (imod=modmi; imod<modma; imod++) {
for (ichan=0; ichan<nChans*nChips; ichan++) {
ich=ichan+imod*nChans*nChips;
if (inttrim[ich]==-1) {
if (scan[ich]>countlim){
inttrim[ich]=itrim;
if (scan[ich]>2*countlim && itrim>0) {
//if (scan[ich]>2*countlim || itrim==0) {
inttrim[ich]=itrim-1;
}
#ifdef VERBOSE
printf("Channel %d trimbit %d counted %d (%08x) countlim %d\n",ich,itrim,scan[ich],fifodata[ich],countlim);
#endif
}
}
#ifdef VERBOSE
/* else
printf("Channel %d trimbit %d counted %d countlim %d\n",ich,itrim,scan[ich],countlim);*/
#endif
}
}
free(scan);
}
for (imod=modmi; imod<modma; imod++) {
clearCSregister(imod);
firstChip(im);
for (ichip=0; ichip<nChips; ichip++) {
clearSSregister(imod);
for (ichan=0; ichan<nChans; ichan++) {
nextStrip(imod);
ich=ichan+imod*nChans*nChips+ichip*nChans;
if (*(inttrim+ich)==-1) {
*(inttrim+ich)=TRIM_DR;
// printf("could not trim channel %d chip %d module %d - set to %d\n", ichan, ichip, imod, *(inttrim+ich) );
retval=FAIL;
}
#ifdef VERBOSE
// else
// printf("channel %d trimbit %d\n",ich,*(inttrim+ich) );
#endif
initChannel(inttrim[ich],0,0,1,0,0,imod);
}
nextChip(imod);
}
}
free(inttrim);
#endif
return retval;
}
#define ELEM_SWAP(a,b) { register int t=(a);(a)=(b);(b)=t; }
#define median(a,n) kth_smallest(a,n,(((n)&1)?((n)/2):(((n)/2)-1)))
int kth_smallest(int *a, int n, int k)
{
register int i,j,l,m ;
register double x ;
l=0 ; m=n-1 ;
while (l<m) {
x=a[k] ;
i=l ;
j=m ;
do {
while (a[i]<x) i++ ;
while (x<a[j]) j-- ;
if (i<=j) {
ELEM_SWAP(a[i],a[j]) ;
i++ ; j-- ;
}
} while (i<=j) ;
if (j<k) l=i ;
if (k<i) m=j ;
}
return a[k] ;
}
int ave(int *a, int n)
{
int av=0,i;
for (i=0; i<n; i++)
av=av+((double)*(a+i))/((double)n);
return av;
}
int choose_vthresh() {
int retval=OK;
#ifdef MCB_FUNCS
int imod, ichan;
u_int32_t *scan, *scan1;
int olddiff[nModX], direction[nModX];
int med[nModX], med1[nModX], diff, media;
int change_flag=1;
int iteration=0;
int maxiterations=10;
int vthreshmean=0;
int vthresh;
int im=ALLMOD;
int modma, modmi, nm;
int *fifodata;
setFrames(1);
// setNMod(getNModBoard());
if (im==ALLMOD){
modmi=0;
modma=nModX;
} else {
modmi=im;
modma=im+1;
}
nm=modma-modmi;
setDynamicRange(32);
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
clearSSregister(ALLMOD);
usleep(500);
startStateMachine();
while (runBusy()) {
//printf(".");
}
usleep(500);
fifodata=(int*)fifo_read_event();
scan=decode_data(fifodata);
//
scan1=decode_data(fifodata);
for (imod=modmi; imod<modma; imod++) {
//
med[imod]=(int)median((int*)scan1+imod*nChans*nChips,nChans*nChips);
med1[imod]=med[imod];
//commented out by dhanya vthreshmean=vthreshmean+getDACbyIndexDACU(VTHRESH,imod);
olddiff[imod]=0xffffff;
direction[imod]=0;
printf("Median of module %d=%d\n",imod,med[imod]);
}
vthreshmean=vthreshmean/nm;
//media=median(scan,nChans*nChips*nModX);
//printf("Median overall=%d\n",media);
media=median(med1+modmi,nm);
printf("Median of modules=%d\n",media);
free(scan);
free(scan1);
while(change_flag && iteration<maxiterations) {
setDynamicRange(32);
fifoReset();
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
clearSSregister(ALLMOD);
usleep(500);
startStateMachine();
while (runBusy()) {
}
usleep(500);
fifodata=(int*)fifo_read_event();
scan=decode_data(fifodata);
//
scan1=decode_data(fifodata);
change_flag=0;
printf("Vthresh iteration %3d 0f %3d\n",iteration, maxiterations);
for (ichan=modmi; ichan<modma; ichan++) {
med[ichan]=(int)median((int*)scan1+ichan*nChans*nChips,nChans*nChips);
med1[imod]=med[imod];
media=median(med1+modmi,nm);
diff=med[ichan]-media;
if (direction[ichan]==0) {
if (diff>0)
direction[ichan]=1;
else
direction[ichan]=-1;
}
//commented out by dhanya vthresh=getDACbyIndexDACU(VTHRESH,imod);
if ( direction[ichan]!=-3) {
if (abs(diff)>abs(olddiff[ichan])) {
vthresh=vthresh-direction[ichan];
if (vthresh>(DAC_DR-1)) {
vthresh=(DAC_DR-1);
printf("can't equalize threshold for module %d\n", ichan);
retval=FAIL;
}
if (vthresh<0) {
vthresh=0;
printf("can't equalize threshold for module %d\n", ichan);
retval=FAIL;
}
direction[ichan]=-3;
} else {
vthresh=vthresh+direction[ichan];
olddiff[ichan]=diff;
change_flag=1;
}
//commented out by dhanya initDACbyIndex(VTHRESH,vthresh, ichan);
}
}
iteration++;
free(scan);
free(scan1);
}
#endif
return retval;
}
int trim_with_median(int stop, int im) {
int retval=OK;
#ifdef MCB_FUNCS
int ichan, imod, ichip, ich;
u_int32_t *scan, *scan1;
int *olddiff, *direction;
int med, diff;
int change_flag=1;
int iteration=0;
int me[nModX], me1[nModX];
int modma, modmi, nm;
int trim;
int *fifodata;
setFrames(1);
// setNMod(getNModBoard());
if (im==ALLMOD){
modmi=0;
modma=nModX;
} else {
modmi=im;
modma=im+1;
}
nm=modma-modmi;
olddiff=malloc(4*nModX*nChips*nChans);
direction=malloc(4*nModX*nChips*nChans);
for (imod=modmi; imod<modma; imod++) {
for (ichip=0; ichip<nChips; ichip++) {
for (ich=0; ich<nChans; ich++) {
ichan=imod*nChips*nChans+ichip*nChans+ich;
direction[ichan]=0;
olddiff[ichan]=0x0fffffff;
}
}
}
/********
fifoReset();
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
clearSSregister(ALLMOD);
usleep(500);
startStateMachine();
while (runBusy()) {
}
usleep(500);
scan=decode_data(fifo_read_event());
for (imod=modmi; imod<modma; imod++) {
me[imod]=median(scan+imod*nChans*nChips,nChans*nChips);
printf("Median of module %d=%d\n",imod,me[imod]);
}
med=median(me,nm);
printf("median is %d\n",med);
free(scan);
**************/
while(change_flag && iteration<stop) {
setDynamicRange(32);
fifoReset();
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
clearSSregister(ALLMOD);
usleep(500);
startStateMachine();
while (runBusy()) {
}
usleep(500);
fifodata=(int*)fifo_read_event();
scan=decode_data(fifodata);
scan1=decode_data(fifodata);
/********* calculates median every time ***********/
for (imod=modmi; imod<modma; imod++) {
me[imod]=median((int*)scan1+imod*nChans*nChips,nChans*nChips);
me1[imod]=me[imod];
printf("Median of module %d=%d\n",imod,me[imod]);
}
med=median(me1,nm);
printf("median is %d\n",med);
change_flag=0;
printf("Trimbits iteration %d of %d\n",iteration, stop);
for (imod=modmi; imod<modma; imod++) {
for (ichip=0; ichip<nChips; ichip++) {
selChip(ichip,imod);
clearSSregister(imod);
for (ich=0; ich<nChans; ich++) {
ichan=imod*nChips*nChans+ichip*nChans+ich;
nextStrip(imod);
diff=scan[ichan]-me[imod];
if (direction[ichan]==0) {
if (diff>0) {
direction[ichan]=1;
} else {
direction[ichan]=-1;
}
}
if ( direction[ichan]!=-3) {
if (abs(diff)>abs(olddiff[ichan])) {
trim=getTrimbit(imod,ichip,ich)+direction[ichan];
printf("%d old diff %d < new diff %d %d - trimbit %d\n",ichan, olddiff[ichan], diff, direction[ichan], trim);
direction[ichan]=-3;
} else {
trim=getTrimbit(imod,ichip,ich)-direction[ichan];
olddiff[ichan]=diff;
change_flag=1;
}
if (trim>TRIM_DR) {
trim=63;
printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim);
retval=FAIL;
}
if (trim<0) {
printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim);
trim=0;
retval=FAIL;
}
initChannel(trim,0,0,1,0,0,imod);
}
}
}
}
iteration++;
free(scan);
free(scan1);
}
free(olddiff);
free(direction);
#endif
return retval;
}

View File

@ -1,20 +0,0 @@
#ifndef TRIMMING_FUNCS_H
#define TRIMMING_FUNCS_H
#include "sls_detector_defs.h"
int trim_fixed_settings(int countlim, int par2, int imod);
int trim_with_noise(int countlim, int nsigma, int imod);
int trim_with_beam(int countlim, int nsigma, int imod);
int trim_improve(int maxit, int par2, int imod);
int calcthr_from_vcal(int vcal);
int calccal_from_vthr(int vthr);
int choose_vthresh_and_vtrim(int countlim, int nsigma, int imod);
int choose_vthresh();
int trim_with_level(int countlim, int imod);
int trim_with_median(int stop, int imod);
int calcthr_from_vcal(int vcal);
int calccal_from_vthr(int vthr);
#endif

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 548036a602123cb3c06bbf4f9a40c9acd6c527fc Repsitory UUID: c52025dd7c4b44b93e64353a22997d971996ab18
Revision: 162 Revision: 163
Branch: developer Branch: developer
Last Changed Author: Dhanya_Thattil Last Changed Author: Gemma_Tinti
Last Changed Rev: 3988 Last Changed Rev: 3999
Last Changed Date: 2018-08-23 11:57:31.000000002 +0200 ./RegisterDefs.h Last Changed Date: 2018-09-28 14:11:53.000000002 +0200 ./RegisterDefs.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "548036a602123cb3c06bbf4f9a40c9acd6c527fc" #define GITREPUUID "c52025dd7c4b44b93e64353a22997d971996ab18"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Gemma_Tinti"
#define GITREV 0x3988 #define GITREV 0x3999
#define GITDATE 0x20180823 #define GITDATE 0x20180928
#define GITBRANCH "developer" #define GITBRANCH "developer"

View File

@ -43,12 +43,12 @@ multiSlsDetector::multiSlsDetector(int id, bool verify, bool update)
multiSlsDetector::~multiSlsDetector() { multiSlsDetector::~multiSlsDetector() {
// delete zmq sockets first // delete zmq sockets first
for (vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) { for (std::vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
delete(*it); delete(*it);
} }
zmqSocket.clear(); zmqSocket.clear();
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
delete(*it); delete(*it);
} }
detectors.clear(); detectors.clear();
@ -101,12 +101,12 @@ T multiSlsDetector::callDetectorMember(T (slsDetector::*somefunc)())
return minusOneIfDifferent(values); return minusOneIfDifferent(values);
} }
std::string multiSlsDetector::callDetectorMember(string (slsDetector::*somefunc)()) { std::string multiSlsDetector::callDetectorMember(std::string (slsDetector::*somefunc)()) {
string concatenatedValue, firstValue; std::string concatenatedValue, firstValue;
bool valueNotSame = false; bool valueNotSame = false;
for (unsigned int idet = 0; idet < detectors.size(); ++idet) { for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
string thisValue = (detectors[idet]->*somefunc)(); std::string thisValue = (detectors[idet]->*somefunc)();
; ;
if (detectors[idet]->getErrorMask()) if (detectors[idet]->getErrorMask())
setErrorMask(getErrorMask() | (1 << idet)); setErrorMask(getErrorMask() | (1 << idet));
@ -347,14 +347,14 @@ double* multiSlsDetector::decodeData(int* datain, int& nn, double* fdata) {
int multiSlsDetector::writeDataFile(string fname, double* data, double* err, int multiSlsDetector::writeDataFile(std::string fname, double* data, double* err,
double* ang, char dataformat, int nch) { double* ang, char dataformat, int nch) {
#ifdef VERBOSE #ifdef VERBOSE
cout << "using overloaded multiSlsDetector function to write formatted data file " cout << "using overloaded multiSlsDetector function to write formatted data file "
<< getTotalNumberOfChannels() << endl; << getTotalNumberOfChannels() << endl;
#endif #endif
ofstream outfile; std::ofstream outfile;
int choff = 0, off = 0; //idata, int choff = 0, off = 0; //idata,
double *pe = err, *pa = ang; double *pe = err, *pa = ang;
int nch_left = nch, n; //, nd; int nch_left = nch, n; //, nd;
@ -365,7 +365,7 @@ int multiSlsDetector::writeDataFile(string fname, double* data, double* err,
if (data == NULL) if (data == NULL)
return FAIL; return FAIL;
outfile.open(fname.c_str(), ios_base::out); outfile.open(fname.c_str(), std::ios_base::out);
if (outfile.is_open()) { if (outfile.is_open()) {
for (unsigned int i = 0; i < detectors.size(); ++i) { for (unsigned int i = 0; i < detectors.size(); ++i) {
@ -399,8 +399,8 @@ int multiSlsDetector::writeDataFile(string fname, double* data, double* err,
} }
} }
int multiSlsDetector::writeDataFile(string fname, int* data) { int multiSlsDetector::writeDataFile(std::string fname, int* data) {
ofstream outfile; std::ofstream outfile;
int choff = 0, off = 0; int choff = 0, off = 0;
#ifdef VERBOSE #ifdef VERBOSE
cout << "using overloaded multiSlsDetector function to write raw data file " << endl; cout << "using overloaded multiSlsDetector function to write raw data file " << endl;
@ -409,7 +409,7 @@ int multiSlsDetector::writeDataFile(string fname, int* data) {
if (data == NULL) if (data == NULL)
return FAIL; return FAIL;
outfile.open(fname.c_str(), ios_base::out); outfile.open(fname.c_str(), std::ios_base::out);
if (outfile.is_open()) { if (outfile.is_open()) {
for (unsigned int i = 0; i < detectors.size(); ++i) { for (unsigned int i = 0; i < detectors.size(); ++i) {
#ifdef VERBOSE #ifdef VERBOSE
@ -430,22 +430,22 @@ int multiSlsDetector::writeDataFile(string fname, int* data) {
} }
} }
int multiSlsDetector::readDataFile(string fname, double* data, double* err, int multiSlsDetector::readDataFile(std::string fname, double* data, double* err,
double* ang, char dataformat) { double* ang, char dataformat) {
#ifdef VERBOSE #ifdef VERBOSE
cout << "using overloaded multiSlsDetector function to read formatted data file " << endl; cout << "using overloaded multiSlsDetector function to read formatted data file " << endl;
#endif #endif
ifstream infile; std::ifstream infile;
int iline = 0; int iline = 0;
string str; std::string str;
int choff = 0, off = 0; int choff = 0, off = 0;
double *pe = err, *pa = ang; double *pe = err, *pa = ang;
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Opening file " << fname << std::endl; std::cout << "Opening file " << fname << std::endl;
#endif #endif
infile.open(fname.c_str(), ios_base::in); infile.open(fname.c_str(), std::ios_base::in);
if (infile.is_open()) { if (infile.is_open()) {
for (unsigned int i = 0; i < detectors.size(); ++i) { for (unsigned int i = 0; i < detectors.size(); ++i) {
@ -469,19 +469,19 @@ int multiSlsDetector::readDataFile(string fname, double* data, double* err,
return iline; return iline;
} }
int multiSlsDetector::readDataFile(string fname, int* data) { int multiSlsDetector::readDataFile(std::string fname, int* data) {
#ifdef VERBOSE #ifdef VERBOSE
cout << "using overloaded multiSlsDetector function to read raw data file " << endl; cout << "using overloaded multiSlsDetector function to read raw data file " << endl;
#endif #endif
ifstream infile; std::ifstream infile;
int iline = 0; int iline = 0;
string str; std::string str;
int choff = 0, off = 0; int choff = 0, off = 0;
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Opening file " << fname << std::endl; std::cout << "Opening file " << fname << std::endl;
#endif #endif
infile.open(fname.c_str(), ios_base::in); infile.open(fname.c_str(), std::ios_base::in);
if (infile.is_open()) { if (infile.is_open()) {
for (unsigned int i = 0; i < detectors.size(); ++i) { for (unsigned int i = 0; i < detectors.size(); ++i) {
@ -501,17 +501,17 @@ int multiSlsDetector::readDataFile(string fname, int* data) {
} }
string multiSlsDetector::getErrorMessage(int& critical) { std::string multiSlsDetector::getErrorMessage(int& critical) {
int64_t multiMask, slsMask = 0; int64_t multiMask, slsMask = 0;
string retval = ""; std::string retval = "";
char sNumber[100]; char sNumber[100];
critical = 0; critical = 0;
multiMask = getErrorMask(); multiMask = getErrorMask();
if (multiMask) { if (multiMask) {
if (multiMask & MULTI_DETECTORS_NOT_ADDED) { if (multiMask & MULTI_DETECTORS_NOT_ADDED) {
retval.append("Detectors not added:\n" + string(getNotAddedList()) + retval.append("Detectors not added:\n" + std::string(getNotAddedList()) +
string("\n")); std::string("\n"));
critical = 1; critical = 1;
} }
if (multiMask & MULTI_HAVE_DIFFERENT_VALUES) { if (multiMask & MULTI_HAVE_DIFFERENT_VALUES) {
@ -529,13 +529,13 @@ string multiSlsDetector::getErrorMessage(int& critical) {
if (multiMask & (1 << idet)) { if (multiMask & (1 << idet)) {
//append detector id //append detector id
sprintf(sNumber, "%d", idet); sprintf(sNumber, "%d", idet);
retval.append("Detector " + string(sNumber) + string(":\n")); retval.append("Detector " + std::string(sNumber) + std::string(":\n"));
//get sls det error mask //get sls det error mask
slsMask = detectors[idet]->getErrorMask(); slsMask = detectors[idet]->getErrorMask();
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
//append sls det error mask //append sls det error mask
sprintf(sNumber, "0x%lx", slsMask); sprintf(sNumber, "0x%lx", slsMask);
retval.append("Error Mask " + string(sNumber) + string("\n")); retval.append("Error Mask " + std::string(sNumber) + std::string("\n"));
#endif #endif
//get the error critical level //get the error critical level
if ((slsMask > 0xFFFFFFFF) | critical) if ((slsMask > 0xFFFFFFFF) | critical)
@ -610,7 +610,7 @@ slsDetector* multiSlsDetector::getSlsDetector(unsigned int pos) {
return 0; return 0;
} }
slsDetector *multiSlsDetector::operator()(int pos) { slsDetector *multiSlsDetector::operator()(int pos) const {
if (pos >= 0 && pos < (int)detectors.size()) if (pos >= 0 && pos < (int)detectors.size())
return detectors[pos]; return detectors[pos];
return NULL; return NULL;
@ -643,7 +643,7 @@ void multiSlsDetector::freeSharedMemory(int multiId) {
void multiSlsDetector::freeSharedMemory() { void multiSlsDetector::freeSharedMemory() {
// clear zmq vector // clear zmq vector
for (vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) { for (std::vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
delete(*it); delete(*it);
} }
zmqSocket.clear(); zmqSocket.clear();
@ -652,7 +652,7 @@ void multiSlsDetector::freeSharedMemory() {
clearAllErrorMask(); clearAllErrorMask();
// clear sls detector vector shm // clear sls detector vector shm
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
(*it)->freeSharedMemory(); (*it)->freeSharedMemory();
delete (*it); delete (*it);
} }
@ -687,7 +687,7 @@ std::string multiSlsDetector::getUserDetails() {
//type //type
sstream<< "\nType: "; sstream<< "\nType: ";
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it)
sstream<< (*it)->sgetDetectorsType() << "+"; sstream<< (*it)->sgetDetectorsType() << "+";
//PID //PID
sstream << "\nPID: " << thisMultiDetector->lastPID sstream << "\nPID: " << thisMultiDetector->lastPID
@ -695,7 +695,7 @@ std::string multiSlsDetector::getUserDetails() {
<< "\nUser: " << thisMultiDetector->lastUser << "\nUser: " << thisMultiDetector->lastUser
<< "\nDate: " << thisMultiDetector->lastDate << endl; << "\nDate: " << thisMultiDetector->lastDate << endl;
string s = sstream.str(); std::string s = sstream.str();
return s; return s;
} }
@ -876,7 +876,7 @@ void multiSlsDetector::initializeMembers(bool verify) {
badFFList = NULL; badFFList = NULL;
//multiSlsDetector //multiSlsDetector
for (vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) { for (std::vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
delete(*it); delete(*it);
} }
zmqSocket.clear(); zmqSocket.clear();
@ -888,7 +888,7 @@ void multiSlsDetector::initializeMembers(bool verify) {
detectors.push_back(sdet); detectors.push_back(sdet);
} catch (...) { } catch (...) {
// clear detectors list // clear detectors list
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
delete(*it); delete(*it);
} }
detectors.clear(); detectors.clear();
@ -951,21 +951,21 @@ void multiSlsDetector::setHostname(const char* name) {
} }
string multiSlsDetector::getHostname(int pos) { std::string multiSlsDetector::getHostname(int pos) {
return concatResultOrPos(&slsDetector::getHostname, pos); return concatResultOrPos(&slsDetector::getHostname, pos);
} }
void multiSlsDetector::addMultipleDetectors(const char* name) { void multiSlsDetector::addMultipleDetectors(const char* name) {
size_t p1 = 0; size_t p1 = 0;
string temp = string(name); std::string temp = std::string(name);
size_t p2 = temp.find('+', p1); size_t p2 = temp.find('+', p1);
//single //single
if (p2 == string::npos) { if (p2 == std::string::npos) {
addSlsDetector(temp); addSlsDetector(temp);
} }
// multi // multi
else { else {
while(p2 != string::npos) { while(p2 != std::string::npos) {
addSlsDetector(temp.substr(p1, p2-p1)); addSlsDetector(temp.substr(p1, p2-p1));
temp = temp.substr(p2 + 1); temp = temp.substr(p2 + 1);
p2 = temp.find('+'); p2 = temp.find('+');
@ -982,7 +982,7 @@ void multiSlsDetector::addSlsDetector (std::string s) {
#ifdef VERBOSE #ifdef VERBOSE
cout << "Adding detector " << s << endl; cout << "Adding detector " << s << endl;
#endif #endif
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
if ((*it)->getHostname((it-detectors.begin())) == s) { if ((*it)->getHostname((it-detectors.begin())) == s) {
cout << "Detector " << s << "already part of the multiDetector!" << endl cout << "Detector " << s << "already part of the multiDetector!" << endl
<< "Remove it before adding it back in a new position!" << endl; << "Remove it before adding it back in a new position!" << endl;
@ -1048,7 +1048,7 @@ void multiSlsDetector::createThreadPool() {
threadpool = new ThreadPool(numthreads); threadpool = new ThreadPool(numthreads);
switch (threadpool->initialize_threadpool()) { switch (threadpool->initialize_threadpool()) {
case 0: case 0:
cerr << "Failed to initialize thread pool!" << endl; std::cerr << "Failed to initialize thread pool!" << endl;
throw ThreadpoolException(); throw ThreadpoolException();
case 1: case 1:
#ifdef VERBOSE #ifdef VERBOSE
@ -1089,7 +1089,7 @@ void multiSlsDetector::getNumberOfDetectors(int& nx, int& ny) {
int multiSlsDetector::getNMods() { int multiSlsDetector::getNMods() {
int nm = 0; int nm = 0;
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
nm += (*it)->getNMods(); nm += (*it)->getNMods();
} }
return nm; return nm;
@ -1097,7 +1097,7 @@ int multiSlsDetector::getNMods() {
int multiSlsDetector::getNMod(dimension d) { int multiSlsDetector::getNMod(dimension d) {
int nm = 0; int nm = 0;
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
nm += (*it)->getNMod(d); nm += (*it)->getNMod(d);
} }
return nm; return nm;
@ -1105,7 +1105,7 @@ int multiSlsDetector::getNMod(dimension d) {
int multiSlsDetector::getMaxMods() { int multiSlsDetector::getMaxMods() {
int ret = 0; int ret = 0;
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
ret += (*it)->getMaxMods(); ret += (*it)->getMaxMods();
} }
return ret; return ret;
@ -1113,7 +1113,7 @@ int multiSlsDetector::getMaxMods() {
int multiSlsDetector::getMaxMod(dimension d) { int multiSlsDetector::getMaxMod(dimension d) {
int ret = 0, ret1; int ret = 0, ret1;
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
ret1 = (*it)->getNMaxMod(d); ret1 = (*it)->getNMaxMod(d);
#ifdef VERBOSE #ifdef VERBOSE
cout << "detector " << (it-detectors.begin()) << " maxmods " << cout << "detector " << (it-detectors.begin()) << " maxmods " <<
@ -1130,7 +1130,7 @@ int multiSlsDetector::getMaxMod(dimension d) {
int multiSlsDetector::getMaxNumberOfModules(dimension d) { int multiSlsDetector::getMaxNumberOfModules(dimension d) {
int ret = 0; int ret = 0;
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
ret += (*it)->getMaxNumberOfModules(d); ret += (*it)->getMaxNumberOfModules(d);
} }
return ret; return ret;
@ -1181,7 +1181,7 @@ int multiSlsDetector::getChansPerMod(int imod) {
int multiSlsDetector::getTotalNumberOfChannels() { int multiSlsDetector::getTotalNumberOfChannels() {
thisMultiDetector->numberOfChannels = 0; thisMultiDetector->numberOfChannels = 0;
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
thisMultiDetector->numberOfChannels += (*it)->getTotalNumberOfChannels(); thisMultiDetector->numberOfChannels += (*it)->getTotalNumberOfChannels();
} }
return thisMultiDetector->numberOfChannels; return thisMultiDetector->numberOfChannels;
@ -1197,7 +1197,7 @@ int multiSlsDetector::getTotalNumberOfChannelsInclGapPixels(dimension d) {
int multiSlsDetector::getMaxNumberOfChannels() { int multiSlsDetector::getMaxNumberOfChannels() {
thisMultiDetector->maxNumberOfChannels = 0; thisMultiDetector->maxNumberOfChannels = 0;
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
thisMultiDetector->maxNumberOfChannels += (*it)->getMaxNumberOfChannels(); thisMultiDetector->maxNumberOfChannels += (*it)->getMaxNumberOfChannels();
} }
return thisMultiDetector->maxNumberOfChannels; return thisMultiDetector->maxNumberOfChannels;
@ -1401,10 +1401,10 @@ int multiSlsDetector::setOnline(int off) {
} }
string multiSlsDetector::checkOnline() { std::string multiSlsDetector::checkOnline() {
string offlineDetectors = ""; std::string offlineDetectors = "";
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { for (std::vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
string tmp = (*it)->checkOnline(); std::string tmp = (*it)->checkOnline();
if (!tmp.empty()) if (!tmp.empty())
offlineDetectors += tmp + "+"; offlineDetectors += tmp + "+";
} }
@ -1420,7 +1420,7 @@ int multiSlsDetector::lockServer(int p) {
return callDetectorMember(&slsDetector::lockServer, p); return callDetectorMember(&slsDetector::lockServer, p);
} }
string multiSlsDetector::getLastClientIP() { std::string multiSlsDetector::getLastClientIP() {
return callDetectorMember(&slsDetector::getLastClientIP); return callDetectorMember(&slsDetector::getLastClientIP);
} }
@ -1434,26 +1434,26 @@ int multiSlsDetector::exitServer() {
return ival; return ival;
} }
int multiSlsDetector::readConfigurationFile(string const fname) { int multiSlsDetector::readConfigurationFile(std::string const fname) {
freeSharedMemory(); freeSharedMemory();
setupMultiDetector(); setupMultiDetector();
multiSlsDetectorClient* cmd; multiSlsDetectorClient* cmd;
string ans; std::string ans;
string str; std::string str;
ifstream infile; std::ifstream infile;
int iargval; int iargval;
int interrupt = 0; int interrupt = 0;
char* args[1000]; char* args[1000];
char myargs[1000][1000]; char myargs[1000][1000];
string sargname, sargval; std::string sargname, sargval;
int iline = 0; int iline = 0;
std::cout << "config file name " << fname << std::endl; std::cout << "config file name " << fname << std::endl;
infile.open(fname.c_str(), ios_base::in); infile.open(fname.c_str(), std::ios_base::in);
if (infile.is_open()) { if (infile.is_open()) {
while (infile.good() and interrupt == 0) { while (infile.good() and interrupt == 0) {
@ -1463,7 +1463,7 @@ int multiSlsDetector::readConfigurationFile(string const fname) {
++iline; ++iline;
// remove comments that come after // remove comments that come after
if (str.find('#') != string::npos) if (str.find('#') != std::string::npos)
str.erase(str.find('#')); str.erase(str.find('#'));
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "string:" << str << std::endl; std::cout << "string:" << str << std::endl;
@ -1474,7 +1474,7 @@ int multiSlsDetector::readConfigurationFile(string const fname) {
#endif #endif
continue; continue;
} else { } else {
istringstream ssstr(str); std::istringstream ssstr(str);
iargval = 0; iargval = 0;
while (ssstr.good()) { while (ssstr.good()) {
ssstr >> sargname; ssstr >> sargname;
@ -1524,9 +1524,9 @@ int multiSlsDetector::readConfigurationFile(string const fname) {
} }
int multiSlsDetector::writeConfigurationFile(string const fname) { int multiSlsDetector::writeConfigurationFile(std::string const fname) {
string names[] = { std::string names[] = {
"detsizechan", "detsizechan",
"hostname", "hostname",
"master", "master",
@ -1551,10 +1551,10 @@ int multiSlsDetector::writeConfigurationFile(string const fname) {
} }
int ret = OK, ret1 = OK; int ret = OK, ret1 = OK;
ofstream outfile; std::ofstream outfile;
int iline = 0; int iline = 0;
outfile.open(fname.c_str(), ios_base::out); outfile.open(fname.c_str(), std::ios_base::out);
if (outfile.is_open()) { if (outfile.is_open()) {
slsDetectorCommand* cmd = new slsDetectorCommand(this); slsDetectorCommand* cmd = new slsDetectorCommand(this);
@ -1610,7 +1610,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname) {
string multiSlsDetector::getSettingsFile() { std::string multiSlsDetector::getSettingsFile() {
return callDetectorMember(&slsDetector::getSettingsFile); return callDetectorMember(&slsDetector::getSettingsFile);
} }
@ -1774,14 +1774,14 @@ slsDetectorDefs::detectorSettings multiSlsDetector::setSettings(detectorSettings
} }
string multiSlsDetector::getSettingsDir() { std::string multiSlsDetector::getSettingsDir() {
return callDetectorMember(&slsDetector::getSettingsDir); return callDetectorMember(&slsDetector::getSettingsDir);
} }
string multiSlsDetector::setSettingsDir(string s) { std::string multiSlsDetector::setSettingsDir(std::string s) {
if (s.find('+') == string::npos) { if (s.find('+') == std::string::npos) {
for (unsigned int idet = 0; idet < detectors.size(); ++idet) { for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
detectors[idet]->setSettingsDir(s); detectors[idet]->setSettingsDir(s);
if (detectors[idet]->getErrorMask()) if (detectors[idet]->getErrorMask())
@ -1791,7 +1791,7 @@ string multiSlsDetector::setSettingsDir(string s) {
size_t p1 = 0; size_t p1 = 0;
size_t p2 = s.find('+', p1); size_t p2 = s.find('+', p1);
int id = 0; int id = 0;
while (p2 != string::npos) { while (p2 != std::string::npos) {
detectors[id]->setSettingsDir(s.substr(p1, p2 - p1)); detectors[id]->setSettingsDir(s.substr(p1, p2 - p1));
if (detectors[id]->getErrorMask()) if (detectors[id]->getErrorMask())
setErrorMask(getErrorMask() | (1 << id)); setErrorMask(getErrorMask() | (1 << id));
@ -1805,13 +1805,13 @@ string multiSlsDetector::setSettingsDir(string s) {
return getSettingsDir(); return getSettingsDir();
} }
string multiSlsDetector::getCalDir() { std::string multiSlsDetector::getCalDir() {
return callDetectorMember(&slsDetector::getCalDir); return callDetectorMember(&slsDetector::getCalDir);
} }
string multiSlsDetector::setCalDir(string s) { std::string multiSlsDetector::setCalDir(std::string s) {
if (s.find('+') == string::npos) { if (s.find('+') == std::string::npos) {
for (unsigned int idet = 0; idet < detectors.size(); ++idet) { for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
detectors[idet]->setCalDir(s); detectors[idet]->setCalDir(s);
if (detectors[idet]->getErrorMask()) if (detectors[idet]->getErrorMask())
@ -1821,7 +1821,7 @@ string multiSlsDetector::setCalDir(string s) {
size_t p1 = 0; size_t p1 = 0;
size_t p2 = s.find('+', p1); size_t p2 = s.find('+', p1);
int id = 0; int id = 0;
while (p2 != string::npos) { while (p2 != std::string::npos) {
if (detectors[id]) { if (detectors[id]) {
detectors[id]->setCalDir(s.substr(p1, p2 - p1)); detectors[id]->setCalDir(s.substr(p1, p2 - p1));
@ -1839,7 +1839,7 @@ string multiSlsDetector::setCalDir(string s) {
} }
int multiSlsDetector::loadSettingsFile(string fname, int imod) { int multiSlsDetector::loadSettingsFile(std::string fname, int imod) {
int ret = OK; int ret = OK;
// single // single
@ -1864,7 +1864,7 @@ int multiSlsDetector::loadSettingsFile(string fname, int imod) {
int* iret[detectors.size()]; int* iret[detectors.size()];
for (unsigned int idet = 0; idet < detectors.size(); ++idet) { for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
iret[idet] = new int(OK); iret[idet] = new int(OK);
Task* task = new Task(new func2_t<int, string, int>(&slsDetector::loadSettingsFile, Task* task = new Task(new func2_t<int, std::string, int>(&slsDetector::loadSettingsFile,
detectors[idet], fname, imod, iret[idet])); detectors[idet], fname, imod, iret[idet]));
threadpool->add_task(task); threadpool->add_task(task);
} }
@ -1884,7 +1884,7 @@ int multiSlsDetector::loadSettingsFile(string fname, int imod) {
return ret; return ret;
} }
int multiSlsDetector::saveSettingsFile(string fname, int imod) { int multiSlsDetector::saveSettingsFile(std::string fname, int imod) {
int id = -1, im = -1, ret; int id = -1, im = -1, ret;
if (decodeNMod(imod, id, im) >= 0) { if (decodeNMod(imod, id, im) >= 0) {
@ -1905,7 +1905,7 @@ int multiSlsDetector::saveSettingsFile(string fname, int imod) {
} }
int multiSlsDetector::loadCalibrationFile(string fname, int imod) { int multiSlsDetector::loadCalibrationFile(std::string fname, int imod) {
int ret = OK; int ret = OK;
// single // single
@ -1931,7 +1931,7 @@ int multiSlsDetector::loadCalibrationFile(string fname, int imod) {
for (unsigned int idet = 0; idet < detectors.size(); ++idet) { for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
if (detectors[idet]) { if (detectors[idet]) {
iret[idet] = new int(OK); iret[idet] = new int(OK);
Task* task = new Task(new func2_t<int, string, int>(&slsDetector::loadCalibrationFile, Task* task = new Task(new func2_t<int, std::string, int>(&slsDetector::loadCalibrationFile,
detectors[idet], fname, imod, iret[idet])); detectors[idet], fname, imod, iret[idet]));
threadpool->add_task(task); threadpool->add_task(task);
} }
@ -1954,7 +1954,7 @@ int multiSlsDetector::loadCalibrationFile(string fname, int imod) {
return ret; return ret;
} }
int multiSlsDetector::saveCalibrationFile(string fname, int imod) { int multiSlsDetector::saveCalibrationFile(std::string fname, int imod) {
int id = -1, im = -1, ret; int id = -1, im = -1, ret;
if (decodeNMod(imod, id, im) >= 0) { if (decodeNMod(imod, id, im) >= 0) {
if (id < 0 || id >= (int)detectors.size()) if (id < 0 || id >= (int)detectors.size())
@ -2458,7 +2458,7 @@ int* multiSlsDetector::getDataFromDetector() {
int nodatadet = -1; int nodatadet = -1;
int nodatadetectortype = false; int nodatadetectortype = false;
detectorType types = getDetectorsType(); detectorType types = getDetectorsType();
if (types == EIGER || types == JUNGFRAU) { if (types == EIGER || types == JUNGFRAU || GOTTHARD || PROPIX) {
nodatadetectortype = true; nodatadetectortype = true;
} }
@ -3030,21 +3030,21 @@ uint32_t multiSlsDetector::clearBit(uint32_t addr, int n) {
return ret; return ret;
} }
string multiSlsDetector::setNetworkParameter(networkParameter p, string s) { std::string multiSlsDetector::setNetworkParameter(networkParameter p, std::string s) {
if (s.find('+') == string::npos) { if (s.find('+') == std::string::npos) {
if (!threadpool) { if (!threadpool) {
cout << "Error in creating threadpool. Exiting" << endl; cout << "Error in creating threadpool. Exiting" << endl;
return getNetworkParameter(p); return getNetworkParameter(p);
} else { } else {
string* sret[detectors.size()]; std::string* sret[detectors.size()];
for (unsigned int idet = 0; idet < detectors.size(); ++idet) { for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
if (p == RECEIVER_STREAMING_PORT || p == CLIENT_STREAMING_PORT) if (p == RECEIVER_STREAMING_PORT || p == CLIENT_STREAMING_PORT)
s.append("multi\0"); s.append("multi\0");
sret[idet] = new string("error"); sret[idet] = new std::string("error");
Task* task = new Task(new func2_t<string, networkParameter, Task* task = new Task(new func2_t<std::string, networkParameter,
string>(&slsDetector::setNetworkParameter, std::string>(&slsDetector::setNetworkParameter,
detectors[idet], p, s, sret[idet])); detectors[idet], p, s, sret[idet]));
threadpool->add_task(task); threadpool->add_task(task);
} }
@ -3063,7 +3063,7 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s) {
size_t p1 = 0; size_t p1 = 0;
size_t p2 = s.find('+', p1); size_t p2 = s.find('+', p1);
int id = 0; int id = 0;
while (p2 != string::npos) { while (p2 != std::string::npos) {
detectors[id]->setNetworkParameter(p, s.substr(p1, p2 - p1)); detectors[id]->setNetworkParameter(p, s.substr(p1, p2 - p1));
if (detectors[id]->getErrorMask()) if (detectors[id]->getErrorMask())
setErrorMask(getErrorMask() | (1 << id)); setErrorMask(getErrorMask() | (1 << id));
@ -3078,18 +3078,18 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s) {
return getNetworkParameter(p); return getNetworkParameter(p);
} }
string multiSlsDetector::getNetworkParameter(networkParameter p) { std::string multiSlsDetector::getNetworkParameter(networkParameter p) {
string s0 = "", s1 = "", s; std::string s0 = "", s1 = "", s;
string ans = ""; std::string ans = "";
for (unsigned int idet = 0; idet < detectors.size(); ++idet) { for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
s = detectors[idet]->getNetworkParameter(p); s = detectors[idet]->getNetworkParameter(p);
if (detectors[idet]->getErrorMask()) if (detectors[idet]->getErrorMask())
setErrorMask(getErrorMask() | (1 << idet)); setErrorMask(getErrorMask() | (1 << idet));
if (s0 == "") if (s0 == "")
s0 = s + string("+"); s0 = s + std::string("+");
else else
s0 += s + string("+"); s0 += s + std::string("+");
if (s1 == "") if (s1 == "")
s1 = s; s1 = s;
@ -3168,13 +3168,13 @@ int multiSlsDetector::executeTrimming(trimMode mode, int par1, int par2, int imo
} }
int multiSlsDetector::loadImageToDetector(imageType index, string const fname) { int multiSlsDetector::loadImageToDetector(imageType index, std::string const fname) {
int ret = -100, ret1; int ret = -100, ret1;
short int imageVals[thisMultiDetector->numberOfChannels]; short int imageVals[thisMultiDetector->numberOfChannels];
ifstream infile; std::ifstream infile;
infile.open(fname.c_str(), ios_base::in); infile.open(fname.c_str(), std::ios_base::in);
if (infile.is_open()) { if (infile.is_open()) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << std::endl std::cout << std::endl
@ -3204,11 +3204,11 @@ int multiSlsDetector::loadImageToDetector(imageType index, string const fname) {
return ret; return ret;
} }
int multiSlsDetector::writeCounterBlockFile(string const fname, int startACQ) { int multiSlsDetector::writeCounterBlockFile(std::string const fname, int startACQ) {
int ret = OK, ret1 = OK; int ret = OK, ret1 = OK;
short int arg[thisMultiDetector->numberOfChannels]; short int arg[thisMultiDetector->numberOfChannels];
ofstream outfile; std::ofstream outfile;
outfile.open(fname.c_str(), ios_base::out); outfile.open(fname.c_str(), std::ios_base::out);
if (outfile.is_open()) { if (outfile.is_open()) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << std::endl std::cout << std::endl
@ -3872,7 +3872,7 @@ int multiSlsDetector::setStoragecellStart(int pos) {
return parallelCallDetectorMember(&slsDetector::setStoragecellStart, pos); return parallelCallDetectorMember(&slsDetector::setStoragecellStart, pos);
} }
int multiSlsDetector::programFPGA(string fname) { int multiSlsDetector::programFPGA(std::string fname) {
int ret = OK, ret1 = OK; int ret = OK, ret1 = OK;
for (unsigned int i = 0; i < detectors.size(); ++i) { for (unsigned int i = 0; i < detectors.size(); ++i) {
@ -4173,14 +4173,14 @@ int multiSlsDetector::rateCorrect(double* datain, double* errin, double* dataout
} }
int multiSlsDetector::setFlatFieldCorrection(string fname) { int multiSlsDetector::setFlatFieldCorrection(std::string fname) {
double* data = new double[thisMultiDetector->numberOfChannels]; double* data = new double[thisMultiDetector->numberOfChannels];
double* ffcoefficients = new double[thisMultiDetector->numberOfChannels]; double* ffcoefficients = new double[thisMultiDetector->numberOfChannels];
double* fferrors = new double[thisMultiDetector->numberOfChannels]; double* fferrors = new double[thisMultiDetector->numberOfChannels];
char ffffname[MAX_STR_LENGTH * 2]; char ffffname[MAX_STR_LENGTH * 2];
int nch; int nch;
if (fname == "default") { if (fname == "default") {
fname = string(thisMultiDetector->flatFieldFile); fname = std::string(thisMultiDetector->flatFieldFile);
} }
thisMultiDetector->correctionMask &= ~(1 << FLAT_FIELD_CORRECTION); thisMultiDetector->correctionMask &= ~(1 << FLAT_FIELD_CORRECTION);
@ -4200,7 +4200,7 @@ int multiSlsDetector::setFlatFieldCorrection(string fname) {
std::cout << "Setting flat field correction from file " << fname << std::endl; std::cout << "Setting flat field correction from file " << fname << std::endl;
#endif #endif
sprintf(ffffname, "%s/%s", thisMultiDetector->flatFieldDir, fname.c_str()); sprintf(ffffname, "%s/%s", thisMultiDetector->flatFieldDir, fname.c_str());
nch = readDataFile(string(ffffname), data); nch = readDataFile(std::string(ffffname), data);
if (nch > thisMultiDetector->numberOfChannels) if (nch > thisMultiDetector->numberOfChannels)
nch = thisMultiDetector->numberOfChannels; nch = thisMultiDetector->numberOfChannels;
@ -4298,7 +4298,7 @@ int multiSlsDetector::flatFieldCorrect(double* datain, double* errin, double* da
return 0; return 0;
} }
int multiSlsDetector::setBadChannelCorrection(string fname) { int multiSlsDetector::setBadChannelCorrection(std::string fname) {
int badlist[MAX_BADCHANS]; int badlist[MAX_BADCHANS];
int nbad = 0; int nbad = 0;
int ret = 0; int ret = 0;
@ -4306,7 +4306,7 @@ int multiSlsDetector::setBadChannelCorrection(string fname) {
cout << thisMultiDetector->badChanFile << endl; cout << thisMultiDetector->badChanFile << endl;
if (fname == "default") if (fname == "default")
fname = string(thisMultiDetector->badChanFile); fname = std::string(thisMultiDetector->badChanFile);
ret = setBadChannelCorrection(fname, nbad, badlist); ret = setBadChannelCorrection(fname, nbad, badlist);
//#ifdef VERBOSE //#ifdef VERBOSE
@ -4428,11 +4428,11 @@ int multiSlsDetector::getBadChannelCorrection(int* bad) {
} }
int multiSlsDetector::readAngularConversionFile(string fname) { int multiSlsDetector::readAngularConversionFile(std::string fname) {
ifstream infile; std::ifstream infile;
//int nm=0; //int nm=0;
infile.open(fname.c_str(), ios_base::in); infile.open(fname.c_str(), std::ios_base::in);
if (infile.is_open()) { if (infile.is_open()) {
for (unsigned int idet = 0; idet < detectors.size(); ++idet) { for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
@ -4451,11 +4451,11 @@ int multiSlsDetector::readAngularConversionFile(string fname) {
return 0; return 0;
} }
int multiSlsDetector::writeAngularConversion(string fname) { int multiSlsDetector::writeAngularConversion(std::string fname) {
ofstream outfile; std::ofstream outfile;
// int nm=0; // int nm=0;
outfile.open(fname.c_str(), ios_base::out); outfile.open(fname.c_str(), std::ios_base::out);
if (outfile.is_open()) { if (outfile.is_open()) {
for (unsigned int idet = 0; idet < detectors.size(); ++idet) { for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
@ -4548,8 +4548,8 @@ int multiSlsDetector::setReceiverOnline(int off) {
return thisMultiDetector->receiverOnlineFlag; return thisMultiDetector->receiverOnlineFlag;
} }
string multiSlsDetector::checkReceiverOnline() { std::string multiSlsDetector::checkReceiverOnline() {
string retval1 = "", retval; std::string retval1 = "", retval;
for (unsigned int idet = 0; idet < detectors.size(); ++idet) { for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
retval = detectors[idet]->checkReceiverOnline(); retval = detectors[idet]->checkReceiverOnline();
if (!retval.empty()) { if (!retval.empty()) {
@ -4564,7 +4564,7 @@ int multiSlsDetector::lockReceiver(int lock) {
return callDetectorMember(&slsDetector::lockReceiver, lock); return callDetectorMember(&slsDetector::lockReceiver, lock);
} }
string multiSlsDetector::getReceiverLastClientIP() { std::string multiSlsDetector::getReceiverLastClientIP() {
return callDetectorMember(&slsDetector::getReceiverLastClientIP); return callDetectorMember(&slsDetector::getReceiverLastClientIP);
} }
@ -4583,9 +4583,9 @@ std::string multiSlsDetector::getFilePath() {
return setFilePath(); return setFilePath();
} }
string multiSlsDetector::setFilePath(string s) { std::string multiSlsDetector::setFilePath(std::string s) {
string ret = "errorerror", ret1; std::string ret = "errorerror", ret1;
for (unsigned int idet = 0; idet < detectors.size(); ++idet) { for (unsigned int idet = 0; idet < detectors.size(); ++idet) {
ret1 = detectors[idet]->setFilePath(s); ret1 = detectors[idet]->setFilePath(s);
if (detectors[idet]->getErrorMask()) if (detectors[idet]->getErrorMask())
@ -4603,9 +4603,9 @@ std::string multiSlsDetector::getFileName() {
return setFileName(); return setFileName();
} }
string multiSlsDetector::setFileName(string s) { std::string multiSlsDetector::setFileName(std::string s) {
string ret = "error"; std::string ret = "error";
int posmax = detectors.size(); int posmax = detectors.size();
if (!s.empty()) { if (!s.empty()) {
@ -4616,12 +4616,12 @@ string multiSlsDetector::setFileName(string s) {
if (!threadpool) { if (!threadpool) {
cout << "Error in creating threadpool. Exiting" << endl; cout << "Error in creating threadpool. Exiting" << endl;
return string(""); return std::string("");
} else { } else {
string* sret[detectors.size()]; std::string* sret[detectors.size()];
for (int idet = 0; idet < posmax; ++idet) { for (int idet = 0; idet < posmax; ++idet) {
sret[idet] = new string("error"); sret[idet] = new std::string("error");
Task* task = new Task(new func1_t<string, string>(&slsDetector::setFileName, Task* task = new Task(new func1_t<std::string, std::string>(&slsDetector::setFileName,
detectors[idet], s, sret[idet])); detectors[idet], s, sret[idet]));
threadpool->add_task(task); threadpool->add_task(task);
} }
@ -4928,7 +4928,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) {
if (destroy) { if (destroy) {
cprintf(MAGENTA, "Going to destroy data sockets\n"); cprintf(MAGENTA, "Going to destroy data sockets\n");
//close socket //close socket
for (vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) { for (std::vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
(*it)->Close(); (*it)->Close();
delete(*it); delete(*it);
} }
@ -5010,7 +5010,7 @@ void multiSlsDetector::readFrameFromReceiver() {
uint32_t size = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0; uint32_t size = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
float bytesPerPixel = 0; float bytesPerPixel = 0;
// header info every header // header info every header
string currentFileName = ""; std::string currentFileName = "";
uint64_t currentAcquisitionIndex = -1, currentFrameIndex = -1, currentFileIndex = -1; uint64_t currentAcquisitionIndex = -1, currentFrameIndex = -1, currentFileIndex = -1;
uint32_t currentSubFrameIndex = -1, coordX = -1, coordY = -1, flippedDataX = -1; uint32_t currentSubFrameIndex = -1, coordX = -1, coordY = -1, flippedDataX = -1;
@ -5078,11 +5078,11 @@ void multiSlsDetector::readFrameFromReceiver() {
currentFrameIndex = doc["fIndex"].GetUint64(); currentFrameIndex = doc["fIndex"].GetUint64();
currentFileIndex = doc["fileIndex"].GetUint64(); currentFileIndex = doc["fileIndex"].GetUint64();
currentSubFrameIndex = doc["expLength"].GetUint(); currentSubFrameIndex = doc["expLength"].GetUint();
coordX = doc["xCoord"].GetUint(); coordY = doc["row"].GetUint();
coordY = doc["yCoord"].GetUint(); coordX = doc["column"].GetUint();
if (eiger) if (eiger)
coordY = (nY - 1) - coordY; coordY = (nY - 1) - coordY;
//cout << "X:" << doc["xCoord"].GetUint() <<" Y:"<<doc["yCoord"].GetUint(); //cout << "X:" << doc["row"].GetUint() <<" Y:"<<doc["column"].GetUint();
flippedDataX = doc["flippedDataX"].GetUint(); flippedDataX = doc["flippedDataX"].GetUint();
#ifdef VERBOSE #ifdef VERBOSE
cprintf(BLUE, "(Debug) Header Info:\n" cprintf(BLUE, "(Debug) Header Info:\n"
@ -5375,7 +5375,7 @@ int multiSlsDetector::setReceiverSilentMode(int i) {
return callDetectorMember(&slsDetector::setReceiverSilentMode, i); return callDetectorMember(&slsDetector::setReceiverSilentMode, i);
} }
int multiSlsDetector::setCTBPattern(string fname) { int multiSlsDetector::setCTBPattern(std::string fname) {
uint64_t word; uint64_t word;
int addr = 0; int addr = 0;
FILE* fd = fopen(fname.c_str(), "r"); FILE* fd = fopen(fname.c_str(), "r");

View File

@ -491,7 +491,7 @@ public:
* @param pos position in the multi list * @param pos position in the multi list
* @returns slsDetector object * @returns slsDetector object
*/ */
slsDetector *operator()(int pos); slsDetector *operator()(int pos) const;
/** /**
* Free shared memory from the command line * Free shared memory from the command line

View File

@ -19,7 +19,7 @@ class multiSlsDetectorClient {
public: public:
multiSlsDetectorClient(int argc, char *argv[], int action, multiSlsDetector *myDetector=NULL) { \ multiSlsDetectorClient(int argc, char *argv[], int action, multiSlsDetector *myDetector=NULL) { \
string answer; \ std::string answer; \
multiSlsDetectorCommand *myCmd; \ multiSlsDetectorCommand *myCmd; \
int id = -1, pos = -1, iv = 0; \ int id = -1, pos = -1, iv = 0; \
bool verify = true, update = true; \ bool verify = true, update = true; \
@ -90,7 +90,7 @@ public:
strcpy(cmd, argv[0]); \ strcpy(cmd, argv[0]); \
} \ } \
// special commands // special commands
string scmd = cmd; \ std::string scmd = cmd; \
// free without calling multiSlsDetector constructor // free without calling multiSlsDetector constructor
if (scmd == "free") { \ if (scmd == "free") { \
if (pos != -1) \ if (pos != -1) \

View File

@ -28,8 +28,8 @@ class multiSlsDetectorCommand : public slsDetectorCommand {
/* \returns answer string */ /* \returns answer string */
/* *\/ */ /* *\/ */
string executeLine(int narg, char *args[], int action, int id=-1) { \ std::string executeLine(int narg, char *args[], int action, int id=-1) { \
string s; \ std::string s; \
if (id>=0) { if (id>=0) {
slsDetector *d=myDet->getSlsDetector(id); \ slsDetector *d=myDet->getSlsDetector(id); \
if (d) { \ if (d) { \
@ -39,7 +39,7 @@ class multiSlsDetectorCommand : public slsDetectorCommand {
myDet->setErrorMask((myDet->getErrorMask())|(1<<id)); \ myDet->setErrorMask((myDet->getErrorMask())|(1<<id)); \
delete cmd; delete cmd;
} else } else
s=string("detector does no exist"); \ s=std::string("detector does no exist"); \
} else \ } else \
s=slsDetectorCommand::executeLine(narg,args,action); \ s=slsDetectorCommand::executeLine(narg,args,action); \
return s; return s;
@ -48,13 +48,13 @@ class multiSlsDetectorCommand : public slsDetectorCommand {
/** /**
* calls executeLine with PUT_ACTION * calls executeLine with PUT_ACTION
*/ */
string putCommand(int narg, char *args[], int pos=-1){\ std::string putCommand(int narg, char *args[], int pos=-1){\
return executeLine(narg, args,slsDetectorDefs::PUT_ACTION,pos);\ return executeLine(narg, args,slsDetectorDefs::PUT_ACTION,pos);\
}; };
/** /**
* calls executeLine with GET_ACTION * calls executeLine with GET_ACTION
*/ */
string getCommand(int narg, char *args[], int pos=-1){\ std::string getCommand(int narg, char *args[], int pos=-1){\
return executeLine(narg, args,slsDetectorDefs::GET_ACTION,pos);\ return executeLine(narg, args,slsDetectorDefs::GET_ACTION,pos);\
}; };

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "6bb7195a2c7dc9526088882e0244a7455d3c15b2" #define GITREPUUID "d2bce7e372c241cd235977b92be18555bca6a77d"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3941 #define GITREV 0x4020
#define GITDATE 0x20180718 #define GITDATE 0x20180927
#define GITBRANCH "3.3.0-rc" #define GITBRANCH "4.0.0"

View File

@ -768,7 +768,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
thisDetector->nOffset = detlist.nOffset; thisDetector->nOffset = detlist.nOffset;
thisDetector->dynamicRange = detlist.dynamicRange; thisDetector->dynamicRange = detlist.dynamicRange;
thisDetector->moveFlag = detlist.moveFlag; thisDetector->moveFlag = detlist.moveFlag;
detlist.nGappixelsY = detlist.nGappixelsX; thisDetector->nGappixels[X] = detlist.nGappixelsX;
thisDetector->nGappixels[Y] = detlist.nGappixelsY; thisDetector->nGappixels[Y] = detlist.nGappixelsY;
@ -3808,7 +3808,7 @@ int* slsDetector::getDataFromDetector(int *retval) {
int nodatadetectortype = false; int nodatadetectortype = false;
detectorType types = getDetectorsType(); detectorType types = getDetectorsType();
if(types == EIGER || types == JUNGFRAU){ if(types == EIGER || types == JUNGFRAU || GOTTHARD || PROPIX){
nodatadetectortype = true; nodatadetectortype = true;
} }
@ -3949,7 +3949,7 @@ int slsDetector::readAllNoWait() {
int slsDetector::configureMAC() { int slsDetector::configureMAC() {
int i; int i;
int ret=FAIL; int ret=FAIL;
int fnum=F_CONFIGURE_MAC,fnum2=F_RECEIVER_SHORT_FRAME; int fnum=F_CONFIGURE_MAC;
char mess[MAX_STR_LENGTH]=""; char mess[MAX_STR_LENGTH]="";
char arg[6][50];memset(arg,0,sizeof(char)*6*50); char arg[6][50];memset(arg,0,sizeof(char)*6*50);
int retval=-1; int retval=-1;
@ -4149,27 +4149,6 @@ int slsDetector::configureMAC() {
std::cout<< "Configuring MAC failed " << std::endl; std::cout<< "Configuring MAC failed " << std::endl;
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC)); setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
} }
else if (thisDetector->myDetectorType==GOTTHARD){
//set frames per file - only for gotthard
pthread_mutex_lock(&ms);
if(retval==-1)
setFramesPerFile(MAX_FRAMES_PER_FILE);
else
setFramesPerFile(SHORT_MAX_FRAMES_PER_FILE);
pthread_mutex_unlock(&ms);
//connect to receiver
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE
std::cout << "Sending adc val to receiver " << retval << std::endl;
#endif
if (connectData() == OK){
ret=thisReceiver->sendInt(fnum2,retval,retval);
disconnectData();
}
if(ret==FAIL)
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
}
}
return ret; return ret;
} }
@ -5321,6 +5300,9 @@ string slsDetector::setReceiver(string receiverIP) {
setReceiverStreamingIP(getReceiverStreamingIP()); setReceiverStreamingIP(getReceiverStreamingIP());
setAdditionalJsonHeader(getAdditionalJsonHeader()); setAdditionalJsonHeader(getAdditionalJsonHeader());
enableDataStreamingFromReceiver(enableDataStreamingFromReceiver(-1)); enableDataStreamingFromReceiver(enableDataStreamingFromReceiver(-1));
if(thisDetector->myDetectorType == GOTTHARD)
sendROI(-1, NULL);
} }
} }
@ -6065,9 +6047,6 @@ int slsDetector::setROI(int n,ROI roiLimits[]) {
} }
ret = sendROI(n,roiLimits); ret = sendROI(n,roiLimits);
if(ret==FAIL)
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels(); if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels();
return ret; return ret;
@ -6132,17 +6111,39 @@ int slsDetector::sendROI(int n,ROI roiLimits[]) {
} }
//update client //update client
if(ret!=FAIL){ if(ret==FAIL){
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
} else {
for(int i=0;i<retvalsize;++i) for(int i=0;i<retvalsize;++i)
thisDetector->roiLimits[i]=retval[i]; thisDetector->roiLimits[i]=retval[i];
thisDetector->nROI = retvalsize; thisDetector->nROI = retvalsize;
} }
//#ifdef VERBOSE #ifdef VERBOSE
for(int j=0;j<thisDetector->nROI;++j) for(int j=0;j<thisDetector->nROI;++j)
cout<<"get"<< roiLimits[j].xmin<<"\t"<<roiLimits[j].xmax<<"\t" cout<<"ROI [" <<j<<"] ("<< roiLimits[j].xmin<<"\t"<<roiLimits[j].xmax<<"\t"
<<roiLimits[j].ymin<<"\t"<<roiLimits[j].ymax<<endl; <<roiLimits[j].ymin<<"\t"<<roiLimits[j].ymax<<")"<<endl;
//#endif #endif
// old firmware requires configuremac after setting roi
if (thisDetector->myDetectorType == GOTTHARD) {
configureMAC();
}
// update roi in receiver
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
int fnum=F_RECEIVER_SET_ROI;
#ifdef VERBOSE
std::cout << "Sending ROI to receiver " << thisDetector->nROI << std::endl;
#endif
if (connectData() == OK){
ret=thisReceiver->sendROI(fnum, thisDetector->nROI, thisDetector->roiLimits);
disconnectData();
}
if(ret==FAIL)
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
}
return ret; return ret;
} }
@ -9026,13 +9027,6 @@ int slsDetector::startReceiver() {
} }
} }
// tell detector to send to receiver (if start receiver failed, this is not executed)
if(((thisDetector->myDetectorType == GOTTHARD ||
thisDetector->myDetectorType == PROPIX) && ret!= FAIL))
return prepareAcquisition(); // send data to receiver for these detectors
return ret; return ret;
} }
@ -9044,11 +9038,6 @@ int slsDetector::stopReceiver() {
int ret = FAIL; int ret = FAIL;
char mess[MAX_STR_LENGTH] = ""; char mess[MAX_STR_LENGTH] = "";
if(thisDetector->myDetectorType == GOTTHARD ||
thisDetector->myDetectorType == PROPIX)
cleanupAcquisition(); // reset (send data to receiver) for these detectors,
//so back to CPU (dont care about ok/fail at this point)
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Stopping Receiver " << std::endl; std::cout << "Stopping Receiver " << std::endl;

View File

@ -519,7 +519,7 @@ public:
* @param pos insignificant * @param pos insignificant
* @returns hostname * @returns hostname
*/ */
string getHostname(int pos = -1); std::string getHostname(int pos = -1);
/** /**
* Appends detectors to the end of the list in shared memory * Appends detectors to the end of the list in shared memory
@ -582,7 +582,7 @@ public:
* @param type string of detector type * @param type string of detector type
* @returns detector type in receiver * @returns detector type in receiver
*/ */
int setDetectorType(string stype); int setDetectorType(std::string stype);
/** /**
* Get Detector type from shared memory variable * Get Detector type from shared memory variable
@ -596,14 +596,14 @@ public:
* @param pos insignificant * @param pos insignificant
* @returns string version of detector type from shared memory variable * @returns string version of detector type from shared memory variable
*/ */
string sgetDetectorsType(int pos=-1); std::string sgetDetectorsType(int pos=-1);
/** /**
* Just to overload getDetectorType from users * Just to overload getDetectorType from users
* Gets string version of detector type from shared memory variable * Gets string version of detector type from shared memory variable
* @returns gets string version of detector type from shared memory variable * @returns gets string version of detector type from shared memory variable
*/ */
string getDetectorType(); std::string getDetectorType();
/** /**
* Returns number of modules from shared memory (Mythen) * Returns number of modules from shared memory (Mythen)
@ -768,7 +768,7 @@ public:
* @returns empty string if it is online * @returns empty string if it is online
* else returns hostnameif it is offline * else returns hostnameif it is offline
*/ */
string checkOnline(); std::string checkOnline();
/** /**
* Configure the TCP socket communciation and initializes the socket instances * Configure the TCP socket communciation and initializes the socket instances
@ -778,7 +778,7 @@ public:
* @returns OK or FAIL * @returns OK or FAIL
* \sa sharedSlsDetector * \sa sharedSlsDetector
*/ */
int setTCPSocket(string const name="", int const control_port=-1, int const stop_port=-1); int setTCPSocket(std::string const name="", int const control_port=-1, int const stop_port=-1);
/** /**
@ -818,7 +818,7 @@ public:
* Get last client IP saved on detector server * Get last client IP saved on detector server
* @returns last client IP saved on detector server * @returns last client IP saved on detector server
*/ */
string getLastClientIP(); std::string getLastClientIP();
/** /**
* Exit detector server * Exit detector server
@ -833,7 +833,7 @@ public:
* @param answer is the answer from the detector * @param answer is the answer from the detector
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int execCommand(string cmd, string answer); int execCommand(std::string cmd, std::string answer);
/** /**
* Updates some of the shared memory receiving the data from the detector * Updates some of the shared memory receiving the data from the detector
@ -854,14 +854,14 @@ public:
* @param fname configuration file name * @param fname configuration file name
* @return OK or FAIL * @return OK or FAIL
*/ */
int readConfigurationFile(string const fname); int readConfigurationFile(std::string const fname);
/** /**
* Load configuration from a stream * Load configuration from a stream
* @param infile stream * @param infile stream
* @return OK or FAIL * @return OK or FAIL
*/ */
int readConfigurationFile(ifstream &infile); int readConfigurationFile(std::ifstream &infile);
/** /**
* Write current configuration to a file * Write current configuration to a file
@ -869,7 +869,7 @@ public:
* @param fname configuration file name * @param fname configuration file name
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int writeConfigurationFile(string const fname); int writeConfigurationFile(std::string const fname);
/** /**
* Write current configuration to a stream * Write current configuration to a stream
@ -877,13 +877,13 @@ public:
* @param id detector id * @param id detector id
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int writeConfigurationFile(ofstream &outfile, int id=-1); int writeConfigurationFile(std::ofstream &outfile, int id=-1);
/** /**
* Returns the trimfile or settings file name (Useless??) * Returns the trimfile or settings file name (Useless??)
* @returns the trimfile or settings file name * @returns the trimfile or settings file name
*/ */
string getSettingsFile(); std::string getSettingsFile();
/** /**
* Writes a trim/settings file for module number imod, * Writes a trim/settings file for module number imod,
@ -896,7 +896,7 @@ public:
* \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int) * \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
*/ */
using energyConversion::writeSettingsFile; using energyConversion::writeSettingsFile;
int writeSettingsFile(string fname, int imod, int iodelay, int tau); int writeSettingsFile(std::string fname, int imod, int iodelay, int tau);
/** /**
* Get detector settings * Get detector settings
@ -965,7 +965,7 @@ public:
* @param s trimbits/settings directory * @param s trimbits/settings directory
* @returns the trimbit/settings directory * @returns the trimbit/settings directory
*/ */
std::string setSettingsDir(string s); std::string setSettingsDir(std::string s);
/** /**
* Returns the calibration files directory \sa sharedSlsDetector (Mythen) * Returns the calibration files directory \sa sharedSlsDetector (Mythen)
@ -978,7 +978,7 @@ public:
* @param s the calibration files directory * @param s the calibration files directory
* @returns the calibration files directory * @returns the calibration files directory
*/ */
std::string setCalDir(string s); std::string setCalDir(std::string s);
/** /**
* Loads the modules settings/trimbits reading from a specific file * Loads the modules settings/trimbits reading from a specific file
@ -988,7 +988,7 @@ public:
* from which will be calculated the detector index and the module index (-1 for all) * from which will be calculated the detector index and the module index (-1 for all)
* returns OK or FAIL * returns OK or FAIL
*/ */
int loadSettingsFile(string fname, int imod=-1); int loadSettingsFile(std::string fname, int imod=-1);
/** /**
* Saves the modules settings/trimbits to a specific file * Saves the modules settings/trimbits to a specific file
@ -997,7 +997,7 @@ public:
* @param imod module number (-1 for all) * @param imod module number (-1 for all)
* returns OK or FAIL * returns OK or FAIL
*/ */
int saveSettingsFile(string fname, int imod=-1); int saveSettingsFile(std::string fname, int imod=-1);
/** /**
* Loads the modules calibration data reading from a specific file (Mythen) * Loads the modules calibration data reading from a specific file (Mythen)
@ -1006,7 +1006,7 @@ public:
* @param imod module number (-1 for all) * @param imod module number (-1 for all)
* returns OK or FAIL * returns OK or FAIL
*/ */
int loadCalibrationFile(string fname, int imod=-1); int loadCalibrationFile(std::string fname, int imod=-1);
/** /**
* Saves the modules calibration data to a specific file (Mythen) * Saves the modules calibration data to a specific file (Mythen)
@ -1015,7 +1015,7 @@ public:
* @param imod module number (-1 for all) * @param imod module number (-1 for all)
* returns OK or FAIL * returns OK or FAIL
*/ */
int saveCalibrationFile(string fname, int imod=-1); int saveCalibrationFile(std::string fname, int imod=-1);
/** /**
* Sets/gets the detector in position i as master of the structure (Mythen) * Sets/gets the detector in position i as master of the structure (Mythen)
@ -1275,94 +1275,94 @@ public:
* @param s network parameter value * @param s network parameter value
* @returns network parameter value set (from getNetworkParameter) * @returns network parameter value set (from getNetworkParameter)
*/ */
string setNetworkParameter(networkParameter index, string value); std::string setNetworkParameter(networkParameter index, std::string value);
/** /**
* Get network parameter * Get network parameter
* @param p network parameter type * @param p network parameter type
* @returns network parameter value set (from getNetworkParameter) * @returns network parameter value set (from getNetworkParameter)
*/ */
string getNetworkParameter(networkParameter index); std::string getNetworkParameter(networkParameter index);
/** /**
* Returns the detector MAC address\sa sharedSlsDetector * Returns the detector MAC address\sa sharedSlsDetector
* @returns the detector MAC address * @returns the detector MAC address
*/ */
string getDetectorMAC(); std::string getDetectorMAC();
/** /**
* Returns the detector IP address\sa sharedSlsDetector * Returns the detector IP address\sa sharedSlsDetector
* @returns the detector IP address * @returns the detector IP address
*/ */
string getDetectorIP(); std::string getDetectorIP();
/** /**
* Returns the receiver IP address\sa sharedSlsDetector * Returns the receiver IP address\sa sharedSlsDetector
* @returns the receiver IP address * @returns the receiver IP address
*/ */
string getReceiver(); std::string getReceiver();
/** /**
* Returns the receiver UDP IP address\sa sharedSlsDetector * Returns the receiver UDP IP address\sa sharedSlsDetector
* @returns the receiver UDP IP address * @returns the receiver UDP IP address
*/ */
string getReceiverUDPIP(); std::string getReceiverUDPIP();
/** /**
* Returns the receiver UDP MAC address\sa sharedSlsDetector * Returns the receiver UDP MAC address\sa sharedSlsDetector
* @returns the receiver UDP MAC address * @returns the receiver UDP MAC address
*/ */
string getReceiverUDPMAC(); std::string getReceiverUDPMAC();
/** /**
* Returns the receiver UDP port\sa sharedSlsDetector * Returns the receiver UDP port\sa sharedSlsDetector
* @returns the receiver UDP port * @returns the receiver UDP port
*/ */
string getReceiverUDPPort(); std::string getReceiverUDPPort();
/** /**
* Returns the receiver UDP port 2 of same interface\sa sharedSlsDetector * Returns the receiver UDP port 2 of same interface\sa sharedSlsDetector
* @returns the receiver UDP port 2 of same interface * @returns the receiver UDP port 2 of same interface
*/ */
string getReceiverUDPPort2(); std::string getReceiverUDPPort2();
/** /**
* Returns the client zmq port \sa sharedSlsDetector * Returns the client zmq port \sa sharedSlsDetector
* @returns the client zmq port * @returns the client zmq port
*/ */
string getClientStreamingPort(); std::string getClientStreamingPort();
/** /**
* Returns the receiver zmq port \sa sharedSlsDetector * Returns the receiver zmq port \sa sharedSlsDetector
* @returns the receiver zmq port * @returns the receiver zmq port
*/ */
string getReceiverStreamingPort(); std::string getReceiverStreamingPort();
/** /**
* Returns the client zmq ip \sa sharedSlsDetector * Returns the client zmq ip \sa sharedSlsDetector
* @returns the client zmq ip, returns "none" if default setting and no custom ip set * @returns the client zmq ip, returns "none" if default setting and no custom ip set
*/ */
string getClientStreamingIP(); std::string getClientStreamingIP();
/** /**
* Returns the receiver zmq ip \sa sharedSlsDetector * Returns the receiver zmq ip \sa sharedSlsDetector
* @returns the receiver zmq ip, returns "none" if default setting and no custom ip set * @returns the receiver zmq ip, returns "none" if default setting and no custom ip set
*/ */
string getReceiverStreamingIP(); std::string getReceiverStreamingIP();
/** /**
* Validates the format of the detector MAC address and sets it \sa sharedSlsDetector * Validates the format of the detector MAC address and sets it \sa sharedSlsDetector
* @param detectorMAC detector MAC address * @param detectorMAC detector MAC address
* @returns the detector MAC address * @returns the detector MAC address
*/ */
string setDetectorMAC(string detectorMAC); std::string setDetectorMAC(std::string detectorMAC);
/** /**
* Validates the format of the detector IP address and sets it \sa sharedSlsDetector * Validates the format of the detector IP address and sets it \sa sharedSlsDetector
* @param detectorIP detector IP address * @param detectorIP detector IP address
* @returns the detector IP address * @returns the detector IP address
*/ */
string setDetectorIP(string detectorIP); std::string setDetectorIP(std::string detectorIP);
/** /**
* Validates and sets the receiver. * Validates and sets the receiver.
@ -1371,21 +1371,21 @@ public:
* @param receiver receiver hostname or IP address * @param receiver receiver hostname or IP address
* @returns the receiver IP address from shared memory * @returns the receiver IP address from shared memory
*/ */
string setReceiver(string receiver); std::string setReceiver(std::string receiver);
/** /**
* Validates the format of the receiver UDP IP address and sets it \sa sharedSlsDetector * Validates the format of the receiver UDP IP address and sets it \sa sharedSlsDetector
* @param udpip receiver UDP IP address * @param udpip receiver UDP IP address
* @returns the receiver UDP IP address * @returns the receiver UDP IP address
*/ */
string setReceiverUDPIP(string udpip); std::string setReceiverUDPIP(std::string udpip);
/** /**
* Validates the format of the receiver UDP MAC address and sets it \sa sharedSlsDetector * Validates the format of the receiver UDP MAC address and sets it \sa sharedSlsDetector
* @param udpmac receiver UDP MAC address * @param udpmac receiver UDP MAC address
* @returns the receiver UDP MAC address * @returns the receiver UDP MAC address
*/ */
string setReceiverUDPMAC(string udpmac); std::string setReceiverUDPMAC(std::string udpmac);
/** /**
* Sets the receiver UDP port\sa sharedSlsDetector * Sets the receiver UDP port\sa sharedSlsDetector
@ -1407,7 +1407,7 @@ public:
* calculate individual ports) * calculate individual ports)
* @returns the client zmq port * @returns the client zmq port
*/ */
string setClientStreamingPort(string port); std::string setClientStreamingPort(std::string port);
/** /**
* Sets the receiver zmq port\sa sharedSlsDetector * Sets the receiver zmq port\sa sharedSlsDetector
@ -1415,21 +1415,21 @@ public:
* calculate individual ports) * calculate individual ports)
* @returns the receiver zmq port * @returns the receiver zmq port
*/ */
string setReceiverStreamingPort(string port); std::string setReceiverStreamingPort(std::string port);
/** /**
* Sets the client zmq ip\sa sharedSlsDetector * Sets the client zmq ip\sa sharedSlsDetector
* @param sourceIP client zmq ip * @param sourceIP client zmq ip
* @returns the client zmq ip, returns "none" if default setting and no custom ip set * @returns the client zmq ip, returns "none" if default setting and no custom ip set
*/ */
string setClientStreamingIP(string sourceIP); std::string setClientStreamingIP(std::string sourceIP);
/** /**
* Sets the receiver zmq ip\sa sharedSlsDetector * Sets the receiver zmq ip\sa sharedSlsDetector
* @param sourceIP receiver zmq ip. If empty, uses rx_hostname * @param sourceIP receiver zmq ip. If empty, uses rx_hostname
* @returns the receiver zmq ip, returns "none" if default setting and no custom ip set * @returns the receiver zmq ip, returns "none" if default setting and no custom ip set
*/ */
string setReceiverStreamingIP(string sourceIP); std::string setReceiverStreamingIP(std::string sourceIP);
/** /**
* Execute a digital test (Gotthard, Mythen) * Execute a digital test (Gotthard, Mythen)
@ -1455,7 +1455,7 @@ public:
* @param fname file name from which to load image * @param fname file name from which to load image
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int loadImageToDetector(imageType index,string const fname); int loadImageToDetector(imageType index,std::string const fname);
/** /**
* Called from loadImageToDetector to send the image to detector * Called from loadImageToDetector to send the image to detector
@ -1471,7 +1471,7 @@ public:
* @param startACQ is 1 to start acquisition after reading counter * @param startACQ is 1 to start acquisition after reading counter
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int writeCounterBlockFile(string const fname,int startACQ=0); int writeCounterBlockFile(std::string const fname,int startACQ=0);
/** /**
* Gets counter memory block in detector (Gotthard) * Gets counter memory block in detector (Gotthard)
@ -1658,7 +1658,7 @@ public:
* @param fname file name * @param fname file name
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int programFPGA(string fname); int programFPGA(std::string fname);
/** /**
* Resets FPGA (Jungfrau) * Resets FPGA (Jungfrau)
@ -1845,7 +1845,7 @@ public:
* @param fname name of the flat field file (or "" if disable) * @param fname name of the flat field file (or "" if disable)
* @returns 0 if disable (or file could not be read), >0 otherwise * @returns 0 if disable (or file could not be read), >0 otherwise
*/ */
int setFlatFieldCorrection(string fname=""); int setFlatFieldCorrection(std::string fname="");
/** /**
* Set flat field corrections (Mythen) * Set flat field corrections (Mythen)
@ -1880,7 +1880,7 @@ public:
* @param fname file with bad channel list ("" disable) * @param fname file with bad channel list ("" disable)
* @returns 0 if bad channel disabled, >0 otherwise * @returns 0 if bad channel disabled, >0 otherwise
*/ */
int setBadChannelCorrection(string fname=""); int setBadChannelCorrection(std::string fname="");
/** /**
* Set bad channels correction (Mythen) * Set bad channels correction (Mythen)
@ -1905,7 +1905,7 @@ public:
* @param fname file to be read * @param fname file to be read
* @returns 0 if angular conversion disabled, >0 otherwise * @returns 0 if angular conversion disabled, >0 otherwise
*/ */
int readAngularConversionFile(string fname=""); int readAngularConversionFile(std::string fname="");
/** /**
* Reads an angular conversion file (Mythen, Gotthard) * Reads an angular conversion file (Mythen, Gotthard)
@ -1913,7 +1913,7 @@ public:
* @param ifs input stream * @param ifs input stream
* @returns 0 if angular conversion disabled, >0 otherwise * @returns 0 if angular conversion disabled, >0 otherwise
*/ */
int readAngularConversion(ifstream& ifs); int readAngularConversion(std::ifstream& ifs);
/** /**
* Writes an angular conversion file (Mythen, Gotthard) * Writes an angular conversion file (Mythen, Gotthard)
@ -1921,7 +1921,7 @@ public:
* @param fname file to be written * @param fname file to be written
* @returns 0 if angular conversion disabled, >0 otherwise * @returns 0 if angular conversion disabled, >0 otherwise
*/ */
int writeAngularConversion(string fname=""); int writeAngularConversion(std::string fname="");
/** /**
* Writes an angular conversion file (Mythen, Gotthard) * Writes an angular conversion file (Mythen, Gotthard)
@ -1929,7 +1929,7 @@ public:
* @param ofs output stream * @param ofs output stream
* @returns 0 if angular conversion disabled, >0 otherwise * @returns 0 if angular conversion disabled, >0 otherwise
*/ */
int writeAngularConversion(ofstream &ofs); int writeAngularConversion(std::ofstream &ofs);
/** /**
* Get angular conversion (Mythen, Gotthard) * Get angular conversion (Mythen, Gotthard)
@ -1965,7 +1965,7 @@ public:
* Checks if the receiver is really online * Checks if the receiver is really online
* @returns empty string if online, else returns receiver hostname * @returns empty string if online, else returns receiver hostname
*/ */
string checkReceiverOnline(); std::string checkReceiverOnline();
/** /**
* Configure the socket communication and initializes the socket instances * Configure the socket communication and initializes the socket instances
@ -1974,7 +1974,7 @@ public:
* @returns OK is connection succeded, FAIL otherwise * @returns OK is connection succeded, FAIL otherwise
* \sa sharedSlsDetector * \sa sharedSlsDetector
*/ */
int setReceiverTCPSocket(string const name="", int const receiver_port=-1); int setReceiverTCPSocket(std::string const name="", int const receiver_port=-1);
/** /**
* Locks/Unlocks the connection to the receiver * Locks/Unlocks the connection to the receiver
@ -1987,7 +1987,7 @@ public:
* Returns the IP of the last client connecting to the receiver * Returns the IP of the last client connecting to the receiver
* @returns the IP of the last client connecting to the receiver * @returns the IP of the last client connecting to the receiver
*/ */
string getReceiverLastClientIP(); std::string getReceiverLastClientIP();
/** /**
* Exits the receiver TCP server * Exits the receiver TCP server
@ -2028,27 +2028,27 @@ public:
* Returns output file directory * Returns output file directory
* @returns output file directory * @returns output file directory
*/ */
string getFilePath(); std::string getFilePath();
/** /**
* Sets up the file directory * Sets up the file directory
* @param s file directory * @param s file directory
* @returns file dir * @returns file dir
*/ */
string setFilePath(string s=""); std::string setFilePath(std::string s="");
/** /**
* Returns file name prefix * Returns file name prefix
* @returns file name prefix * @returns file name prefix
*/ */
string getFileName(); std::string getFileName();
/** /**
* Sets up the file name prefix * Sets up the file name prefix
* @param s file name prefix * @param s file name prefix
* @returns file name prefix * @returns file name prefix
*/ */
string setFileName(string s=""); std::string setFileName(std::string s="");
/** /**
* Sets the max frames per file in receiver * Sets the max frames per file in receiver
@ -2236,7 +2236,7 @@ public:
* @param fname pattern file to open * @param fname pattern file to open
* @returns OK/FAIL * @returns OK/FAIL
*/ */
int setCTBPattern(string fname); int setCTBPattern(std::string fname);
/** /**
* Writes a pattern word to the CTB * Writes a pattern word to the CTB
@ -2394,33 +2394,33 @@ private:
* Returns the additional json header \sa sharedSlsDetector * Returns the additional json header \sa sharedSlsDetector
* @returns the additional json header, returns "none" if default setting and no custom ip set * @returns the additional json header, returns "none" if default setting and no custom ip set
*/ */
string getAdditionalJsonHeader(); std::string getAdditionalJsonHeader();
/** /**
* Returns the receiver UDP socket buffer size\sa sharedSlsDetector * Returns the receiver UDP socket buffer size\sa sharedSlsDetector
* @returns the receiver UDP socket buffer size * @returns the receiver UDP socket buffer size
*/ */
string getReceiverUDPSocketBufferSize() ; std::string getReceiverUDPSocketBufferSize() ;
/** /**
* Returns the receiver real UDP socket buffer size\sa sharedSlsDetector * Returns the receiver real UDP socket buffer size\sa sharedSlsDetector
* @returns the receiver real UDP socket buffer size * @returns the receiver real UDP socket buffer size
*/ */
string getReceiverRealUDPSocketBufferSize(); std::string getReceiverRealUDPSocketBufferSize();
/** /**
* Sets the additional json header\sa sharedSlsDetector * Sets the additional json header\sa sharedSlsDetector
* @param jsonheader additional json header * @param jsonheader additional json header
* @returns additional json header, returns "none" if default setting and no custom ip set * @returns additional json header, returns "none" if default setting and no custom ip set
*/ */
string setAdditionalJsonHeader(string jsonheader); std::string setAdditionalJsonHeader(std::string jsonheader);
/** /**
* Sets the receiver UDP socket buffer size * Sets the receiver UDP socket buffer size
* @param udpsockbufsize additional json header * @param udpsockbufsize additional json header
* @returns receiver udp socket buffer size * @returns receiver udp socket buffer size
*/ */
string setReceiverUDPSocketBufferSize(int udpsockbufsize=-1); std::string setReceiverUDPSocketBufferSize(int udpsockbufsize=-1);
/** /**
* Sets the transmission delay for left, right or entire frame * Sets the transmission delay for left, right or entire frame
@ -2429,7 +2429,7 @@ private:
* @param delay delay * @param delay delay
* @returns transmission delay * @returns transmission delay
*/ */
string setDetectorNetworkParameter(networkParameter index, int delay); std::string setDetectorNetworkParameter(networkParameter index, int delay);
/** /**

View File

@ -4464,6 +4464,9 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
if (cmd == "roi")
myDet->setReceiverOnline(ONLINE_FLAG);
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
if (cmd=="maxmod") if (cmd=="maxmod")
return string("cannot put!"); return string("cannot put!");
@ -4481,10 +4484,10 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
ROI allroi[val]; ROI allroi[val];
pos=2; pos=2;
for(i=0;i<val;++i){ for(i=0;i<val;++i){
if ((!sscanf(args[++pos],"%d",&allroi[i].xmin)) || if ((!sscanf(args[pos++],"%d",&allroi[i].xmin)) ||
(!sscanf(args[++pos],"%d",&allroi[i].xmax)) || (!sscanf(args[pos++],"%d",&allroi[i].xmax)) ||
(!sscanf(args[++pos],"%d",&allroi[i].ymin)) || (!sscanf(args[pos++],"%d",&allroi[i].ymin)) ||
(!sscanf(args[++pos],"%d",&allroi[i].ymax)) ) (!sscanf(args[pos++],"%d",&allroi[i].ymax)) )
return string("cannot parse arguments for roi"); return string("cannot parse arguments for roi");
} }
myDet->setROI(val,allroi); myDet->setROI(val,allroi);

View File

@ -197,3 +197,21 @@ int receiverInterface::executeFunction(int fnum,char mess[]){
} }
int receiverInterface::sendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]) {
int ret = slsDetectorDefs::FAIL;
char mess[MAX_STR_LENGTH];
memset(mess, 0, MAX_STR_LENGTH);
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(&n,sizeof(n));
dataSocket->SendDataOnly(roiLimits,n * sizeof(slsReceiverDefs::ROI));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==slsDetectorDefs::FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
cprintf(RED, "Receiver returned error: %s", mess);
}
return ret;
}

View File

@ -131,6 +131,15 @@ public:
*/ */
int executeFunction(int fnum,char mess[]); int executeFunction(int fnum,char mess[]);
/**
* Send an integer to receiver
* @param fnum function enum to determine what parameter
* @param n number of ROIs to send
* @param roiLimits ROI structure
* \returns success of operation
*/
int sendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]);
//here one should implement the funcs listed in //here one should implement the funcs listed in
private: private:

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsReceiverSoftware Path: slsDetectorsPackage/slsReceiverSoftware
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 6bb7195a2c7dc9526088882e0244a7455d3c15b2 Repsitory UUID: d2bce7e372c241cd235977b92be18555bca6a77d
Revision: 809 Revision: 839
Branch: 3.3.0-rc Branch: 4.0.0
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3941 Last Changed Rev: 4020
Last Changed Date: 2018-07-18 12:11:38.000000002 +0200 ./include/HDF5FileStatic.h Last Changed Date: 2018-09-27 17:58:04.000000002 +0200 ./src/UDPStandardImplementation.cpp

View File

@ -14,7 +14,6 @@
#include <string> #include <string>
#include <iomanip> #include <iomanip>
#include <string.h> #include <string.h>
using namespace std;
#define MAX_MASTER_FILE_LENGTH 2000 #define MAX_MASTER_FILE_LENGTH 2000
@ -44,10 +43,10 @@ class BinaryFileStatic {
static std::string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable, static std::string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable,
uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0) uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0)
{ {
ostringstream osfn; std::ostringstream osfn;
osfn << fpath << "/" << fnameprefix; osfn << fpath << "/" << fnameprefix;
if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex); if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex);
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << fnum; if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << fnum;
osfn << "_" << findex; osfn << "_" << findex;
osfn << ".raw"; osfn << ".raw";
return osfn.str(); return osfn.str();
@ -60,9 +59,9 @@ class BinaryFileStatic {
* @param findex file index * @param findex file index
* @returns master file name * @returns master file name
*/ */
string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex) std::string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex)
{ {
ostringstream osfn; std::ostringstream osfn;
osfn << fpath << "/" << fnameprefix; osfn << fpath << "/" << fnameprefix;
osfn << "_master"; osfn << "_master";
osfn << "_" << findex; osfn << "_" << findex;
@ -115,7 +114,7 @@ class BinaryFileStatic {
* @param version version of software for binary writing * @param version version of software for binary writing
* @returns 0 for success and 1 for fail * @returns 0 for success and 1 for fail
*/ */
static int CreateMasterDataFile(FILE*& fd, string fname, bool owenable, static int CreateMasterDataFile(FILE*& fd, std::string fname, bool owenable,
uint32_t dr, bool tenE, uint32_t size, uint32_t dr, bool tenE, uint32_t size,
uint32_t nPixelsX, uint32_t nPixelsY, uint64_t nf, uint32_t nPixelsX, uint32_t nPixelsY, uint64_t nf,
uint32_t maxf, uint32_t maxf,
@ -140,8 +139,8 @@ class BinaryFileStatic {
"Dynamic Range : %d\n" "Dynamic Range : %d\n"
"Ten Giga : %d\n" "Ten Giga : %d\n"
"Image Size : %d bytes\n" "Image Size : %d bytes\n"
"x : %d pixels\n" "row : %d pixels\n"
"y : %d pixels\n" "col : %d pixels\n"
"Max. Frames Per File : %u\n" "Max. Frames Per File : %u\n"
"Total Frames : %lld\n" "Total Frames : %lld\n"
"Exptime (ns) : %lld\n" "Exptime (ns) : %lld\n"
@ -157,9 +156,9 @@ class BinaryFileStatic {
"Bunch ID : 8 bytes\n" "Bunch ID : 8 bytes\n"
"Timestamp : 8 bytes\n" "Timestamp : 8 bytes\n"
"Module Id : 2 bytes\n" "Module Id : 2 bytes\n"
"X Coordinate : 2 bytes\n" "Row : 2 bytes\n"
"Y Coordinate : 2 bytes\n" "Column : 2 bytes\n"
"Z Coordinate : 2 bytes\n" "Reserved : 2 bytes\n"
"Debug : 4 bytes\n" "Debug : 4 bytes\n"
"Round Robin Number : 2 bytes\n" "Round Robin Number : 2 bytes\n"
"Detector Type : 1 byte\n" "Detector Type : 1 byte\n"

View File

@ -14,6 +14,8 @@ class Fifo;
class DataStreamer; class DataStreamer;
class ZmqSocket; class ZmqSocket;
#include <vector>
class DataStreamer : private virtual slsReceiverDefs, public ThreadObject { class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
public: public:
@ -23,13 +25,13 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
* @param ind self index * @param ind self index
* @param f address of Fifo pointer * @param f address of Fifo pointer
* @param dr pointer to dynamic range * @param dr pointer to dynamic range
* @param sEnable pointer to short frame enable * @param r roi
* @param fi pointer to file index * @param fi pointer to file index
* @param fd flipped data enable for x and y dimensions * @param fd flipped data enable for x and y dimensions
* @param ajh additional json header * @param ajh additional json header
* @param sm pointer to silent mode * @param sm pointer to silent mode
*/ */
DataStreamer(int ind, Fifo*& f, uint32_t* dr, int* sEnable, DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
uint64_t* fi, int* fd, char* ajh, bool* sm); uint64_t* fi, int* fd, char* ajh, bool* sm);
/** /**
@ -172,8 +174,11 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
/** Pointer to dynamic range */ /** Pointer to dynamic range */
uint32_t* dynamicRange; uint32_t* dynamicRange;
/** Pointer to short frame enable */ /** ROI */
int* shortFrameEnable; std::vector<ROI>* roi;
/** adc Configured */
int adcConfigured;
/** Pointer to file index */ /** Pointer to file index */
uint64_t* fileIndex; uint64_t* fileIndex;

View File

@ -11,6 +11,7 @@
#include "receiver_defs.h" #include "receiver_defs.h"
#include <math.h> //ceil #include <math.h> //ceil
#include <vector>
class GeneralData { class GeneralData {
@ -155,6 +156,25 @@ public:
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset; frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
} }
/**
* Set ROI
* @param i ROI
*/
virtual void SetROI(std::vector<slsReceiverDefs::ROI> i) {
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
};
/**
* Get Adc configured
* @param index thread index for debugging purposes
* @param i pointer to a vector of ROI pointers
* @returns adc configured
*/
virtual const int GetAdcConfigured(int index, std::vector<slsReceiverDefs::ROI>* i) const{
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
return 0;
};
/** /**
* Setting dynamic range changes member variables * Setting dynamic range changes member variables
* @param dr dynamic range * @param dr dynamic range
@ -225,6 +245,10 @@ public:
class GotthardData : public GeneralData { class GotthardData : public GeneralData {
private:
const static int nChip = 10;
const static int nChan = 128;
const static int nChipsPerAdc = 2;
public: public:
/** Constructor */ /** Constructor */
@ -244,32 +268,8 @@ class GotthardData : public GeneralData {
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header);
defaultFifoDepth = 50000; defaultFifoDepth = 50000;
}; };
};
class ShortGotthardData : public GeneralData {
public:
/** Constructor */
ShortGotthardData(){
myDetectorType = slsReceiverDefs::GOTTHARD;
nPixelsX = 256;
nPixelsY = 1;
headerSizeinPacket = 4;
dataSize = 512;
packetSize = 518;
packetsPerFrame = 1;
imageSize = dataSize*packetsPerFrame;
frameIndexMask = 0xFFFFFFFF;
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header);
defaultFifoDepth = 50000;
nPixelsXComplete = 1280;
nPixelsYComplete = 1;
imageSizeComplete = 1280 * 2;
};
/** /**
* Get Header Infomation (frame number, packet number) * Get Header Infomation (frame number, packet number)
* @param index thread index for debugging purposes * @param index thread index for debugging purposes
@ -279,9 +279,16 @@ class ShortGotthardData : public GeneralData {
*/ */
virtual void GetHeaderInfo(int index, char* packetData, uint64_t& frameNumber, uint32_t& packetNumber) const virtual void GetHeaderInfo(int index, char* packetData, uint64_t& frameNumber, uint32_t& packetNumber) const
{ {
if (nPixelsX == 1280) {
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
frameNumber++;
packetNumber = frameNumber&packetIndexMask;
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
} else {
frameNumber = ((uint32_t)(*((uint32_t*)(packetData)))); frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
packetNumber = 0; packetNumber = 0;
} }
}
/** /**
* Get Header Infomation (frame number, packet number) * Get Header Infomation (frame number, packet number)
@ -296,11 +303,96 @@ class ShortGotthardData : public GeneralData {
virtual void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange, virtual void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange,
uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t& bunchId) const uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t& bunchId) const
{ {
if (nPixelsX == 1280) {
subFrameNumber = -1;
bunchId = -1;
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
frameNumber++;
packetNumber = frameNumber&packetIndexMask;
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
} else {
subFrameNumber = -1; subFrameNumber = -1;
bunchId = -1; bunchId = -1;
frameNumber = ((uint32_t)(*((uint32_t*)(packetData)))); frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
packetNumber = 0; packetNumber = 0;
} }
}
/**
* Set ROI
* @param i ROI
*/
virtual void SetROI(std::vector<slsReceiverDefs::ROI> i) {
// all adcs
if(!i.size()) {
nPixelsX = 1280;
dataSize = 1280;
packetSize = GOTTHARD_PACKET_SIZE;
packetsPerFrame = 2;
imageSize = dataSize*packetsPerFrame;
frameIndexMask = 0xFFFFFFFE;
frameIndexOffset = 1;
packetIndexMask = 1;
maxFramesPerFile = MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header);
defaultFifoDepth = 50000;
nPixelsXComplete = 0;
nPixelsYComplete = 0;
imageSizeComplete = 0;
}
// single adc
else {
nPixelsX = 256;
dataSize = 512;
packetSize = 518;
packetsPerFrame = 1;
imageSize = dataSize*packetsPerFrame;
frameIndexMask = 0xFFFFFFFF;
frameIndexOffset = 0;
packetIndexMask = 0;
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header);
defaultFifoDepth = 25000;
nPixelsXComplete = 1280;
nPixelsYComplete = 1;
imageSizeComplete = 1280 * 2;
}
};
/**
* Get Adc configured
* @param index thread index for debugging purposes
* @param i pointer to a vector of ROI
* @returns adc configured
*/
virtual const int GetAdcConfigured(int index, std::vector<slsReceiverDefs::ROI>* i) const{
int adc = -1;
// single adc
if(i->size()) {
// gotthard can have only one adc per detector enabled (or all)
// so just looking at the first roi is enough (more not possible at the moment)
//if its for 1 adc or general
if ((i->at(0).xmin == 0) && (i->at(0).xmax == nChip * nChan))
adc = -1;
else {
//adc = mid value/numchans also for only 1 roi
adc = ((((i->at(0).xmax) + (i->at(0).xmin))/2)/
(nChan * nChipsPerAdc));
if((adc < 0) || (adc > 4)) {
FILE_LOG(logWARNING) << index << ": Deleting ROI. "
"Adc value should be between 0 and 4";
adc = -1;
}
}
}
FILE_LOG(logINFO) << "Adc Configured: " << adc;
return adc;
};
}; };

View File

@ -181,16 +181,16 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
int numFilesinAcquisition; int numFilesinAcquisition;
/** parameter names */ /** parameter names */
vector <const char*> parameterNames; std::vector <const char*> parameterNames;
/** parameter data types */ /** parameter data types */
vector <DataType> parameterDataTypes; std::vector <DataType> parameterDataTypes;
/** Dataspace of parameters */ /** Dataspace of parameters */
DataSpace* dataspace_para; DataSpace* dataspace_para;
/** Dataset array for parameters */ /** Dataset array for parameters */
vector <DataSet*> dataset_para; std::vector <DataSet*> dataset_para;
/** Number of Images (including extended during acquisition) */ /** Number of Images (including extended during acquisition) */
uint64_t extNumImages; uint64_t extNumImages;

View File

@ -23,7 +23,6 @@ using namespace H5;
#include <stdlib.h> //malloc #include <stdlib.h> //malloc
#include <sstream> #include <sstream>
#include <cstring> //memset #include <cstring> //memset
using namespace std;
class HDF5FileStatic: public virtual slsReceiverDefs { class HDF5FileStatic: public virtual slsReceiverDefs {
@ -48,13 +47,13 @@ public:
* @param unitindex unit index * @param unitindex unit index
* @returns complete file name created * @returns complete file name created
*/ */
static string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable, static std::string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable,
uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0) uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0)
{ {
ostringstream osfn; std::ostringstream osfn;
osfn << fpath << "/" << fnameprefix; osfn << fpath << "/" << fnameprefix;
if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex); if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex);
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << fnum; if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << fnum;
osfn << "_" << findex; osfn << "_" << findex;
osfn << ".h5"; osfn << ".h5";
return osfn.str(); return osfn.str();
@ -67,9 +66,9 @@ public:
* @param findex file index * @param findex file index
* @returns master file name * @returns master file name
*/ */
static string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex) static std::string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex)
{ {
ostringstream osfn; std::ostringstream osfn;
osfn << fpath << "/" << fnameprefix; osfn << fpath << "/" << fnameprefix;
osfn << "_master"; osfn << "_master";
osfn << "_" << findex; osfn << "_" << findex;
@ -85,9 +84,9 @@ public:
* @param findex file index * @param findex file index
* @returns virtual file name * @returns virtual file name
*/ */
static string CreateVirtualFileName(char* fpath, char* fnameprefix, uint64_t findex) static std::string CreateVirtualFileName(char* fpath, char* fnameprefix, uint64_t findex)
{ {
ostringstream osfn; std::ostringstream osfn;
osfn << fpath << "/" << fnameprefix; osfn << fpath << "/" << fnameprefix;
osfn << "_virtual"; osfn << "_virtual";
osfn << "_" << findex; osfn << "_" << findex;
@ -197,8 +196,8 @@ public:
* @param parameterDataTypes parameter datatypes * @param parameterDataTypes parameter datatypes
*/ */
static int WriteParameterDatasets(int ind, DataSpace* dspace_para, uint64_t fnum, static int WriteParameterDatasets(int ind, DataSpace* dspace_para, uint64_t fnum,
vector <DataSet*> dset_para,sls_receiver_header* rheader, std::vector <DataSet*> dset_para,sls_receiver_header* rheader,
vector <DataType> parameterDataTypes) std::vector <DataType> parameterDataTypes)
{ {
sls_detector_header header = rheader->detHeader; sls_detector_header header = rheader->detHeader;
hsize_t count[1] = {1}; hsize_t count[1] = {1};
@ -214,9 +213,9 @@ public:
dset_para[3]->write(&header.bunchId, parameterDataTypes[3], memspace, *dspace_para);i=4; dset_para[3]->write(&header.bunchId, parameterDataTypes[3], memspace, *dspace_para);i=4;
dset_para[4]->write(&header.timestamp, parameterDataTypes[4], memspace, *dspace_para);i=5; dset_para[4]->write(&header.timestamp, parameterDataTypes[4], memspace, *dspace_para);i=5;
dset_para[5]->write(&header.modId, parameterDataTypes[5], memspace, *dspace_para);i=6; dset_para[5]->write(&header.modId, parameterDataTypes[5], memspace, *dspace_para);i=6;
dset_para[6]->write(&header.xCoord, parameterDataTypes[6], memspace, *dspace_para);i=7; dset_para[6]->write(&header.row, parameterDataTypes[6], memspace, *dspace_para);i=7;
dset_para[7]->write(&header.yCoord, parameterDataTypes[7], memspace, *dspace_para);i=8; dset_para[7]->write(&header.column, parameterDataTypes[7], memspace, *dspace_para);i=8;
dset_para[8]->write(&header.zCoord, parameterDataTypes[8], memspace, *dspace_para);i=9; dset_para[8]->write(&header.reserved, parameterDataTypes[8], memspace, *dspace_para);i=9;
dset_para[9]->write(&header.debug, parameterDataTypes[9], memspace, *dspace_para);i=10; dset_para[9]->write(&header.debug, parameterDataTypes[9], memspace, *dspace_para);i=10;
dset_para[10]->write(&header.roundRNumber, parameterDataTypes[10], memspace, *dspace_para);i=11; dset_para[10]->write(&header.roundRNumber, parameterDataTypes[10], memspace, *dspace_para);i=11;
dset_para[11]->write(&header.detType, parameterDataTypes[11], memspace, *dspace_para);i=12; dset_para[11]->write(&header.detType, parameterDataTypes[11], memspace, *dspace_para);i=12;
@ -260,7 +259,7 @@ public:
* @returns 0 for success and 1 for fail * @returns 0 for success and 1 for fail
*/ */
static int ExtendDataset(int ind, DataSpace*& dspace, DataSet* dset, static int ExtendDataset(int ind, DataSpace*& dspace, DataSet* dset,
DataSpace*& dspace_para, vector <DataSet*> dset_para, DataSpace*& dspace_para, std::vector <DataSet*> dset_para,
uint64_t initialNumImages) { uint64_t initialNumImages) {
try{ try{
Exception::dontPrint(); //to handle errors Exception::dontPrint(); //to handle errors
@ -309,7 +308,7 @@ public:
* @param version version of software for hdf5 writing * @param version version of software for hdf5 writing
* @returns 0 for success and 1 for fail * @returns 0 for success and 1 for fail
*/ */
static int CreateMasterDataFile(H5File*& fd, string fname, bool owenable, static int CreateMasterDataFile(H5File*& fd, std::string fname, bool owenable,
uint32_t dr, bool tenE, uint32_t size, uint32_t dr, bool tenE, uint32_t size,
uint32_t nPixelsx, uint32_t nPixelsy, uint64_t nf, uint32_t nPixelsx, uint32_t nPixelsy, uint64_t nf,
uint32_t maxf, uint32_t maxf,
@ -357,7 +356,7 @@ public:
dataset = group5.createDataSet ( "dynamic range", PredType::NATIVE_INT, dataspace ); dataset = group5.createDataSet ( "dynamic range", PredType::NATIVE_INT, dataspace );
dataset.write ( &dr, PredType::NATIVE_INT); dataset.write ( &dr, PredType::NATIVE_INT);
attribute = dataset.createAttribute("unit",strdatatype, dataspace); attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, string("bits")); attribute.write(strdatatype, std::string("bits"));
//Ten Giga //Ten Giga
iValue = tenE; iValue = tenE;
@ -368,7 +367,7 @@ public:
dataset = group5.createDataSet ( "image size", PredType::NATIVE_INT, dataspace ); dataset = group5.createDataSet ( "image size", PredType::NATIVE_INT, dataspace );
dataset.write ( &size, PredType::NATIVE_INT); dataset.write ( &size, PredType::NATIVE_INT);
attribute = dataset.createAttribute("unit",strdatatype, dataspace); attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, string("bytes")); attribute.write(strdatatype, std::string("bytes"));
//x //x
dataset = group5.createDataSet ( "number of pixels in x axis", PredType::NATIVE_INT, dataspace ); dataset = group5.createDataSet ( "number of pixels in x axis", PredType::NATIVE_INT, dataspace );
@ -390,30 +389,30 @@ public:
dataset = group5.createDataSet ( "exposure time", PredType::STD_U64LE, dataspace ); dataset = group5.createDataSet ( "exposure time", PredType::STD_U64LE, dataspace );
dataset.write ( &acquisitionTime, PredType::STD_U64LE); dataset.write ( &acquisitionTime, PredType::STD_U64LE);
attribute = dataset.createAttribute("unit",strdatatype, dataspace); attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, string("ns")); attribute.write(strdatatype, std::string("ns"));
//SubExptime //SubExptime
dataset = group5.createDataSet ( "sub exposure time", PredType::STD_U64LE, dataspace ); dataset = group5.createDataSet ( "sub exposure time", PredType::STD_U64LE, dataspace );
dataset.write ( &subexposuretime, PredType::STD_U64LE); dataset.write ( &subexposuretime, PredType::STD_U64LE);
attribute = dataset.createAttribute("unit",strdatatype, dataspace); attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, string("ns")); attribute.write(strdatatype, std::string("ns"));
//SubPeriod //SubPeriod
dataset = group5.createDataSet ( "sub period", PredType::STD_U64LE, dataspace ); dataset = group5.createDataSet ( "sub period", PredType::STD_U64LE, dataspace );
dataset.write ( &subperiod, PredType::STD_U64LE); dataset.write ( &subperiod, PredType::STD_U64LE);
attribute = dataset.createAttribute("unit",strdatatype, dataspace); attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, string("ns")); attribute.write(strdatatype, std::string("ns"));
//Period //Period
dataset = group5.createDataSet ( "acquisition period", PredType::STD_U64LE, dataspace ); dataset = group5.createDataSet ( "acquisition period", PredType::STD_U64LE, dataspace );
dataset.write ( &acquisitionPeriod, PredType::STD_U64LE); dataset.write ( &acquisitionPeriod, PredType::STD_U64LE);
attribute = dataset.createAttribute("unit",strdatatype, dataspace); attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, string("ns")); attribute.write(strdatatype, std::string("ns"));
//Timestamp //Timestamp
time_t t = time(0); time_t t = time(0);
dataset = group5.createDataSet ( "timestamp", strdatatype, dataspace ); dataset = group5.createDataSet ( "timestamp", strdatatype, dataspace );
dataset.write ( string(ctime(&t)), strdatatype ); dataset.write ( std::string(ctime(&t)), strdatatype );
fd->close(); fd->close();
@ -450,13 +449,13 @@ public:
* @param parameterDataTypes parameter datatypes * @param parameterDataTypes parameter datatypes
* @returns 0 for success and 1 for fail * @returns 0 for success and 1 for fail
*/ */
static int CreateDataFile(int ind, bool owenable, string fname, bool frindexenable, static int CreateDataFile(int ind, bool owenable, std::string fname, bool frindexenable,
uint64_t fnum, uint64_t nDimx, uint32_t nDimy, uint32_t nDimz, uint64_t fnum, uint64_t nDimx, uint32_t nDimy, uint32_t nDimz,
DataType dtype, H5File*& fd, DataSpace*& dspace, DataSet*& dset, DataType dtype, H5File*& fd, DataSpace*& dspace, DataSet*& dset,
double version, uint64_t maxchunkedimages, double version, uint64_t maxchunkedimages,
DataSpace*& dspace_para, vector<DataSet*>& dset_para, DataSpace*& dspace_para, std::vector<DataSet*>& dset_para,
vector <const char*> parameterNames, std::vector <const char*> parameterNames,
vector <DataType> parameterDataTypes) std::vector <DataType> parameterDataTypes)
{ {
try { try {
Exception::dontPrint(); //to handle errors Exception::dontPrint(); //to handle errors
@ -488,10 +487,10 @@ public:
//dataset name //dataset name
ostringstream osfn; std::ostringstream osfn;
osfn << "/data"; osfn << "/data";
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << fnum; if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << fnum;
string dsetname = osfn.str(); std::string dsetname = osfn.str();
//dataset //dataset
//fill value //fill value
@ -557,52 +556,52 @@ public:
* @returns 0 for success and 1 for fail * @returns 0 for success and 1 for fail
*/ */
static int CreateVirtualDataFile( static int CreateVirtualDataFile(
string virtualFileName, std::string virtualFileName,
hid_t& fd, string masterFileName, hid_t& fd, std::string masterFileName,
char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable, char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable,
int dindex, int numunits, int dindex, int numunits,
uint32_t maxFramesPerFile, uint64_t numf, uint32_t maxFramesPerFile, uint64_t numf,
string srcDataseName, DataType dataType, std::string srcDataseName, DataType dataType,
int numDety, int numDetz, uint32_t nDimy, uint32_t nDimz, int numDety, int numDetz, uint32_t nDimy, uint32_t nDimz,
double version, double version,
vector <const char*> parameterNames, std::vector <const char*> parameterNames,
vector <DataType> parameterDataTypes) std::vector <DataType> parameterDataTypes)
{ {
//file //file
hid_t dfal = H5Pcreate (H5P_FILE_ACCESS); hid_t dfal = H5Pcreate (H5P_FILE_ACCESS);
if (dfal < 0) if (dfal < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating file access property for virtual file ") std::string("Error in creating file access property for virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0) if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in setting strong file close degree for virtual file ") std::string("Error in setting strong file close degree for virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
fd = H5Fcreate( virtualFileName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, dfal); fd = H5Fcreate( virtualFileName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, dfal);
if (fd < 0) if (fd < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating virtual file ") + virtualFileName + string("\n")); std::string("Error in creating virtual file ") + virtualFileName + std::string("\n"));
//attributes - version //attributes - version
hid_t dataspace_attr = H5Screate (H5S_SCALAR); hid_t dataspace_attr = H5Screate (H5S_SCALAR);
if (dataspace_attr < 0) if (dataspace_attr < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating dataspace for attribute in virtual file ") std::string("Error in creating dataspace for attribute in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
hid_t attrid = H5Acreate2 (fd, "version", H5T_NATIVE_DOUBLE, dataspace_attr, H5P_DEFAULT, H5P_DEFAULT); hid_t attrid = H5Acreate2 (fd, "version", H5T_NATIVE_DOUBLE, dataspace_attr, H5P_DEFAULT, H5P_DEFAULT);
if (attrid < 0) if (attrid < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating attribute in virtual file ") std::string("Error in creating attribute in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
double attr_data = version; double attr_data = version;
if (H5Awrite (attrid, H5T_NATIVE_DOUBLE, &attr_data) < 0) if (H5Awrite (attrid, H5T_NATIVE_DOUBLE, &attr_data) < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in writing attribute in virtual file ") std::string("Error in writing attribute in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
if (H5Aclose (attrid) < 0) if (H5Aclose (attrid) < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in closing attribute in virtual file ") std::string("Error in closing attribute in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
//virtual dataspace //virtual dataspace
@ -610,38 +609,38 @@ public:
hid_t vdsDataspace = H5Screate_simple(3, vdsdims ,NULL); hid_t vdsDataspace = H5Screate_simple(3, vdsdims ,NULL);
if (vdsDataspace < 0) if (vdsDataspace < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating virtual dataspace in virtual file ") std::string("Error in creating virtual dataspace in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
hsize_t vdsdims_para[2] = {numf, (unsigned int) numDety * numDetz}; hsize_t vdsdims_para[2] = {numf, (unsigned int) numDety * numDetz};
hid_t vdsDataspace_para = H5Screate_simple(2, vdsdims_para, NULL); hid_t vdsDataspace_para = H5Screate_simple(2, vdsdims_para, NULL);
if (vdsDataspace_para < 0) if (vdsDataspace_para < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating virtual dataspace (parameters) in virtual file ") std::string("Error in creating virtual dataspace (parameters) in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
//fill values //fill values
hid_t dcpl = H5Pcreate (H5P_DATASET_CREATE); hid_t dcpl = H5Pcreate (H5P_DATASET_CREATE);
if (dcpl < 0) if (dcpl < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating file creation properties in virtual file ") std::string("Error in creating file creation properties in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
int fill_value = -1; int fill_value = -1;
if (H5Pset_fill_value (dcpl, GetDataTypeinC(dataType), &fill_value) < 0) if (H5Pset_fill_value (dcpl, GetDataTypeinC(dataType), &fill_value) < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating fill value in virtual file ") std::string("Error in creating fill value in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
hid_t dcpl_para[parameterNames.size()]; hid_t dcpl_para[parameterNames.size()];
for (unsigned int i = 0; i < parameterNames.size(); ++i) { for (unsigned int i = 0; i < parameterNames.size(); ++i) {
dcpl_para[i] = H5Pcreate (H5P_DATASET_CREATE); dcpl_para[i] = H5Pcreate (H5P_DATASET_CREATE);
if (dcpl_para[i] < 0) if (dcpl_para[i] < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating file creation properties (parameters) in virtual file ") std::string("Error in creating file creation properties (parameters) in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
if (H5Pset_fill_value (dcpl_para[i], GetDataTypeinC(parameterDataTypes[i]), &fill_value) < 0) if (H5Pset_fill_value (dcpl_para[i], GetDataTypeinC(parameterDataTypes[i]), &fill_value) < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating fill value (parameters) in virtual file ") std::string("Error in creating fill value (parameters) in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
} }
//hyperslab //hyperslab
@ -674,22 +673,22 @@ public:
} }
//source file name //source file name
string srcFileName = HDF5FileStatic::CreateFileName(fpath, fnameprefix, findex, std::string srcFileName = HDF5FileStatic::CreateFileName(fpath, fnameprefix, findex,
frindexenable, framesSaved, dindex, numunits, i); frindexenable, framesSaved, dindex, numunits, i);
// find relative path // find relative path
string relative_srcFileName = srcFileName; std::string relative_srcFileName = srcFileName;
{ {
size_t i = srcFileName.rfind('/', srcFileName.length()); size_t i = srcFileName.rfind('/', srcFileName.length());
if (i != string::npos) if (i != std::string::npos)
relative_srcFileName = (srcFileName.substr(i+1, srcFileName.length() - i)); relative_srcFileName = (srcFileName.substr(i+1, srcFileName.length() - i));
} }
//source dataset name //source dataset name
ostringstream osfn; std::ostringstream osfn;
osfn << "/data"; osfn << "/data";
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << framesSaved; if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << framesSaved;
string srcDatasetName = osfn.str(); std::string srcDatasetName = osfn.str();
//source dataspace //source dataspace
hsize_t srcdims[3] = {nDimx, nDimy, nDimz}; hsize_t srcdims[3] = {nDimx, nDimy, nDimz};
@ -697,15 +696,15 @@ public:
hid_t srcDataspace = H5Screate_simple(3, srcdims, srcdimsmax); hid_t srcDataspace = H5Screate_simple(3, srcdims, srcdimsmax);
if (srcDataspace < 0) if (srcDataspace < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating source dataspace in virtual file ") std::string("Error in creating source dataspace in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
hsize_t srcdims_para[1] = {nDimx}; hsize_t srcdims_para[1] = {nDimx};
hsize_t srcdimsmax_para[1] = {H5S_UNLIMITED}; hsize_t srcdimsmax_para[1] = {H5S_UNLIMITED};
hid_t srcDataspace_para = H5Screate_simple(1, srcdims_para, srcdimsmax_para); hid_t srcDataspace_para = H5Screate_simple(1, srcdims_para, srcdimsmax_para);
if (srcDataspace_para < 0) if (srcDataspace_para < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating source dataspace (parameters) in virtual file ") std::string("Error in creating source dataspace (parameters) in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
//mapping //mapping
if (H5Pset_virtual(dcpl, vdsDataspace, relative_srcFileName.c_str(), if (H5Pset_virtual(dcpl, vdsDataspace, relative_srcFileName.c_str(),
@ -737,17 +736,17 @@ public:
} }
if (error) if (error)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in mapping files in virtual file ") std::string("Error in mapping files in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
//dataset //dataset
string virtualDatasetName = srcDataseName; std::string virtualDatasetName = srcDataseName;
hid_t vdsdataset = H5Dcreate2 (fd, virtualDatasetName.c_str(), hid_t vdsdataset = H5Dcreate2 (fd, virtualDatasetName.c_str(),
GetDataTypeinC(dataType), vdsDataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); GetDataTypeinC(dataType), vdsDataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
if (vdsdataset < 0) if (vdsdataset < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating virutal dataset in virtual file ") std::string("Error in creating virutal dataset in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
//virtual parameter dataset //virtual parameter dataset
@ -758,8 +757,8 @@ public:
H5P_DEFAULT, dcpl_para[i], H5P_DEFAULT); H5P_DEFAULT, dcpl_para[i], H5P_DEFAULT);
if (vdsdataset_para < 0) if (vdsdataset_para < 0)
return CloseFileOnError(fd, return CloseFileOnError(fd,
string("Error in creating virutal dataset (parameters) in virtual file ") std::string("Error in creating virutal dataset (parameters) in virtual file ")
+ virtualFileName + string("\n")); + virtualFileName + std::string("\n"));
} }
//close //close
@ -786,8 +785,8 @@ public:
* @returns 0 for success and 1 for fail * @returns 0 for success and 1 for fail
*/ */
template <typename T> template <typename T>
static int CopyVirtualFile(T datatype, bool owenable, string oldFileName, string oldDatasetName, static int CopyVirtualFile(T datatype, bool owenable, std::string oldFileName, std::string oldDatasetName,
string newFileName, string newDatasetName, int rank, std::string newFileName, std::string newDatasetName, int rank,
uint64_t nDimx, uint32_t nDimy, uint32_t nDimz=0) uint64_t nDimx, uint32_t nDimy, uint32_t nDimz=0)
{ {
T *data_out; T *data_out;
@ -814,14 +813,14 @@ public:
FILE_LOG(logERROR) << "unknown datatype"; FILE_LOG(logERROR) << "unknown datatype";
return 1; return 1;
} }
FILE_LOG(logINFO) << "owenable:" << (owenable?1:0) << endl FILE_LOG(logINFO) << "owenable:" << (owenable?1:0) << std::endl
<< "oldFileName:" << oldFileName << endl << "oldFileName:" << oldFileName << std::endl
<< "oldDatasetName:" << oldDatasetName << endl << "oldDatasetName:" << oldDatasetName << std::endl
<< "newFileName:" << newFileName << endl << "newFileName:" << newFileName << std::endl
<< "newDatasetName:" << newDatasetName << endl << "newDatasetName:" << newDatasetName << std::endl
<< "rank:" << rank << endl << "rank:" << rank << std::endl
<< "nDimx:" << nDimx << endl << "nDimx:" << nDimx << std::endl
<< "nDimy:" << nDimy << endl << "nDimy:" << nDimy << std::endl
<< "nDimz:" << nDimz; << "nDimz:" << nDimz;
H5File* oldfd; H5File* oldfd;
@ -884,34 +883,34 @@ public:
* @param parameterNames parameter names * @param parameterNames parameter names
* @returns 0 for success and 1 for fail * @returns 0 for success and 1 for fail
*/ */
static int LinkVirtualInMaster(string masterFileName, string virtualfname, static int LinkVirtualInMaster(std::string masterFileName, std::string virtualfname,
string virtualDatasetname, vector <const char*> parameterNames) { std::string virtualDatasetname, std::vector <const char*> parameterNames) {
char linkname[100]; char linkname[100];
hid_t vfd = 0; hid_t vfd = 0;
hid_t dfal = H5Pcreate (H5P_FILE_ACCESS); hid_t dfal = H5Pcreate (H5P_FILE_ACCESS);
if (dfal < 0) if (dfal < 0)
return CloseFileOnError( vfd, string("Error in creating file access property for link\n")); return CloseFileOnError( vfd, std::string("Error in creating file access property for link\n"));
if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0) if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0)
return CloseFileOnError( vfd, string("Error in setting strong file close degree for link\n")); return CloseFileOnError( vfd, std::string("Error in setting strong file close degree for link\n"));
//open master file //open master file
hid_t mfd = H5Fopen( masterFileName.c_str(), H5F_ACC_RDWR, dfal); hid_t mfd = H5Fopen( masterFileName.c_str(), H5F_ACC_RDWR, dfal);
if (mfd < 0) if (mfd < 0)
return CloseFileOnError( vfd, string("Error in opening master file\n")); return CloseFileOnError( vfd, std::string("Error in opening master file\n"));
//open virtual file //open virtual file
vfd = H5Fopen( virtualfname.c_str(), H5F_ACC_RDWR, dfal); vfd = H5Fopen( virtualfname.c_str(), H5F_ACC_RDWR, dfal);
if (vfd < 0) { if (vfd < 0) {
H5Fclose(mfd); mfd = 0; H5Fclose(mfd); mfd = 0;
return CloseFileOnError( vfd, string("Error in opening virtual file\n")); return CloseFileOnError( vfd, std::string("Error in opening virtual file\n"));
} }
// find relative path // find relative path
string relative_virtualfname = virtualfname; std::string relative_virtualfname = virtualfname;
{ {
size_t i = virtualfname.rfind('/', virtualfname.length()); size_t i = virtualfname.rfind('/', virtualfname.length());
if (i != string::npos) if (i != std::string::npos)
relative_virtualfname = (virtualfname.substr(i+1, virtualfname.length() - i)); relative_virtualfname = (virtualfname.substr(i+1, virtualfname.length() - i));
} }
@ -919,29 +918,29 @@ public:
hid_t vdset = H5Dopen2( vfd, virtualDatasetname.c_str(), H5P_DEFAULT); hid_t vdset = H5Dopen2( vfd, virtualDatasetname.c_str(), H5P_DEFAULT);
if (vdset < 0) { if (vdset < 0) {
H5Fclose(mfd); H5Fclose(mfd);
return CloseFileOnError( vfd, string("Error in opening virtual data dataset\n")); return CloseFileOnError( vfd, std::string("Error in opening virtual data dataset\n"));
} }
sprintf(linkname, "/entry/data/%s",virtualDatasetname.c_str()); sprintf(linkname, "/entry/data/%s",virtualDatasetname.c_str());
if(H5Lcreate_external( relative_virtualfname.c_str(), virtualDatasetname.c_str(), if(H5Lcreate_external( relative_virtualfname.c_str(), virtualDatasetname.c_str(),
mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) { mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) {
H5Fclose(mfd); mfd = 0; H5Fclose(mfd); mfd = 0;
return CloseFileOnError( vfd, string("Error in creating link to data dataset\n")); return CloseFileOnError( vfd, std::string("Error in creating link to data dataset\n"));
} }
H5Dclose(vdset); H5Dclose(vdset);
//**paramter datasets** //**paramter datasets**
for (unsigned int i = 0; i < parameterNames.size(); ++i){ for (unsigned int i = 0; i < parameterNames.size(); ++i){
hid_t vdset_para = H5Dopen2( vfd, (string (parameterNames[i])).c_str(), H5P_DEFAULT); hid_t vdset_para = H5Dopen2( vfd, (std::string (parameterNames[i])).c_str(), H5P_DEFAULT);
if (vdset_para < 0) { if (vdset_para < 0) {
H5Fclose(mfd); mfd = 0; H5Fclose(mfd); mfd = 0;
return CloseFileOnError( vfd, string("Error in opening virtual parameter dataset to create link\n")); return CloseFileOnError( vfd, std::string("Error in opening virtual parameter dataset to create link\n"));
} }
sprintf(linkname, "/entry/data/%s",(string (parameterNames[i])).c_str()); sprintf(linkname, "/entry/data/%s",(std::string (parameterNames[i])).c_str());
if(H5Lcreate_external( relative_virtualfname.c_str(), (string (parameterNames[i])).c_str(), if(H5Lcreate_external( relative_virtualfname.c_str(), (std::string (parameterNames[i])).c_str(),
mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) { mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) {
H5Fclose(mfd); mfd = 0; H5Fclose(mfd); mfd = 0;
return CloseFileOnError( vfd, string("Error in creating link to virtual parameter dataset\n")); return CloseFileOnError( vfd, std::string("Error in creating link to virtual parameter dataset\n"));
} }
} }
@ -956,7 +955,7 @@ public:
* Print Error msg and Close File and called on error * Print Error msg and Close File and called on error
* @returns 1 for fail * @returns 1 for fail
*/ */
static int CloseFileOnError(hid_t& fd, const string msg) { static int CloseFileOnError(hid_t& fd, const std::string msg) {
cprintf(RED, "%s", msg.c_str()); cprintf(RED, "%s", msg.c_str());
if(fd > 0) if(fd > 0)
H5Fclose(fd); H5Fclose(fd);

View File

@ -141,12 +141,12 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
int CreateDummySocketForUDPSocketBufferSize(uint32_t s); int CreateDummySocketForUDPSocketBufferSize(uint32_t s);
/** /**
* Set xcoord and y coord * Set hard coded (calculated but not from detector) row and column
* xcoord is in 1d if detector has not send them yet in firmware, * r is in row index if detector has not send them yet in firmware,
* xcoord is in 2d for jungfrau and eiger (for missing packets/deactivated eiger) * c is in col index for jungfrau and eiger (for missing packets/deactivated eiger)
* ycoord when used is in 2d * c when used is in 2d
*/ */
void SetHardCodedCoords(uint16_t x, uint16_t y); void SetHardCodedPosition(uint16_t r, uint16_t c);
@ -251,14 +251,14 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
/** Silent Mode */ /** Silent Mode */
bool* silentMode; bool* silentMode;
/** x coord hardcoded as 1D or 2d, /** row hardcoded as 1D or 2d,
* if detector does not send them yet or * if detector does not send them yet or
* missing packets/deactivated (eiger/jungfrau sends 2d pos) **/ * missing packets/deactivated (eiger/jungfrau sends 2d pos) **/
uint16_t xcoord; uint16_t row;
/** y coord hardcoded as 2D, /** column hardcoded as 2D,
* deactivated eiger/missing packets (eiger/jungfrau sends 2d pos) **/ * deactivated eiger/missing packets (eiger/jungfrau sends 2d pos) **/
uint16_t ycoord; uint16_t column;
// acquisition start // acquisition start

View File

@ -182,10 +182,10 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
//***acquisition parameters*** //***acquisition parameters***
/** /**
* Get Short Frame Enabled, later will be moved to getROI (so far only for gotthard) * Get ROI
* @return index of adc enabled, else -1 if all enabled * @return index of adc enabled, else -1 if all enabled
*/ */
int getShortFrameEnable() const; std::vector<ROI> getROI() const;
/** /**
* Get the Frequency of Frames Sent to GUI * Get the Frequency of Frames Sent to GUI
@ -332,7 +332,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
* Configure command line parameters * Configure command line parameters
* @param config_map mapping of config parameters passed from command line arguments * @param config_map mapping of config parameters passed from command line arguments
*/ */
void configure(map<string, string> config_map); void configure(std::map<std::string, std::string> config_map);
/* /*
* Set multi detector size * Set multi detector size
@ -448,11 +448,11 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
//***acquisition parameters*** //***acquisition parameters***
/** /**
* Set Short Frame Enabled, later will be moved to getROI (so far only for gotthard) * Set ROI
* @param i index of adc enabled, else -1 if all enabled * @param i ROI
* @return OK or FAIL * @return OK or FAIL
*/ */
int setShortFrameEnable(const int i); int setROI(const std::vector<ROI> i);
/** /**
* Set the Frequency of Frames Sent to GUI * Set the Frequency of Frames Sent to GUI
@ -785,8 +785,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
bool dataCompressionEnable; bool dataCompressionEnable;
//***acquisition parameters*** //***acquisition parameters***
/* Short Frame Enable or index of adc enabled, else -1 if all enabled (gotthard specific) TODO: move to setROI */ /* ROI */
int shortFrameEnable; std::vector<ROI> roi;
/** Frequency of Frames sent to GUI */ /** Frequency of Frames sent to GUI */
uint32_t frameToGuiFrequency; uint32_t frameToGuiFrequency;
/** Timer of Frames sent to GUI when frequency is 0 */ /** Timer of Frames sent to GUI when frequency is 0 */

View File

@ -11,13 +11,13 @@
* @short Base class with all the functions for the UDP inteface of the receiver * @short Base class with all the functions for the UDP inteface of the receiver
*/ */
#include <exception>
#include "sls_receiver_defs.h" #include "sls_receiver_defs.h"
#include "receiver_defs.h" #include "receiver_defs.h"
#include "utilities.h" #include "utilities.h"
#include "logger.h" #include "logger.h"
#include <exception>
#include <vector>
class UDPInterface { class UDPInterface {
@ -54,6 +54,8 @@ class UDPInterface {
* -setStreamingSourceIP * -setStreamingSourceIP
* -setAdditionalJsonHeader * -setAdditionalJsonHeader
* -setDataStreamEnable * -setDataStreamEnable
* -setROI
*
* *
* *
* supported sequence of method-calls: * supported sequence of method-calls:
@ -114,7 +116,7 @@ class UDPInterface {
* @param [in] receiver_type type can be standard or custom (must be derived from base class) * @param [in] receiver_type type can be standard or custom (must be derived from base class)
* @return a UDPInterface reference to object depending on receiver type * @return a UDPInterface reference to object depending on receiver type
*/ */
static UDPInterface *create(string receiver_type = "standard"); static UDPInterface *create(std::string receiver_type = "standard");
/** /**
* Destructor * Destructor
@ -271,10 +273,10 @@ class UDPInterface {
//***acquisition parameters*** //***acquisition parameters***
/** /**
* Get Short Frame Enabled, later will be moved to getROI (so far only for gotthard) * Get ROI
* @return index of adc enabled, else -1 if all enabled * @return index of adc enabled, else -1 if all enabled
*/ */
virtual int getShortFrameEnable() const = 0; virtual std::vector<slsReceiverDefs::ROI> getROI() const = 0;
/** /**
* Get the Frequency of Frames Sent to GUI * Get the Frequency of Frames Sent to GUI
@ -420,7 +422,7 @@ class UDPInterface {
* Configure command line parameters * Configure command line parameters
* @param config_map mapping of config parameters passed from command line arguments * @param config_map mapping of config parameters passed from command line arguments
*/ */
virtual void configure(map<string, string> config_map) = 0; virtual void configure(std::map<std::string, std::string> config_map) = 0;
/* /*
* Set multi detector size * Set multi detector size
@ -535,11 +537,11 @@ class UDPInterface {
//***acquisition parameters*** //***acquisition parameters***
/** /**
* Set Short Frame Enabled, later will be moved to getROI (so far only for gotthard) * Set ROI
* @param i index of adc enabled, else -1 if all enabled * @param i ROI
* @return OK or FAIL * @return OK or FAIL
*/ */
virtual int setShortFrameEnable(const int i) = 0; virtual int setROI(const std::vector<slsReceiverDefs::ROI> i) = 0;
/** /**
* Set the Frequency of Frames Sent to GUI * Set the Frequency of Frames Sent to GUI

View File

@ -14,7 +14,6 @@ class DataProcessor;
class DataStreamer; class DataStreamer;
class Fifo; class Fifo;
#include <vector>
class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBaseImplementation { class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBaseImplementation {
@ -74,11 +73,11 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
void setFileWriteEnable(const bool b); void setFileWriteEnable(const bool b);
/** /**
* Set Short Frame Enabled, later will be moved to getROI (so far only for gotthard) * Set ROI
* @param i index of adc enabled, else -1 if all enabled * @param i ROI
* @return OK or FAIL * @return OK or FAIL
*/ */
int setShortFrameEnable(const int i); int setROI(const std::vector<ROI> i);
/** /**
* Set the Frequency of Frames Sent to GUI * Set the Frequency of Frames Sent to GUI

View File

@ -248,7 +248,7 @@ public:
uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL, uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL,
uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0, uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0,
uint64_t bunchId = 0, uint64_t timestamp = 0, uint64_t bunchId = 0, uint64_t timestamp = 0,
uint16_t modId = 0, uint16_t xCoord = 0, uint16_t yCoord = 0, uint16_t zCoord = 0, uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0,
uint32_t debug = 0, uint16_t roundRNumber = 0, uint32_t debug = 0, uint16_t roundRNumber = 0,
uint8_t detType = 0, uint8_t version = 0, int* flippedData = 0, uint8_t detType = 0, uint8_t version = 0, int* flippedData = 0,
char* additionalJsonHeader = 0) { char* additionalJsonHeader = 0) {
@ -274,9 +274,9 @@ public:
"\"bunchId\":%llu, " "\"bunchId\":%llu, "
"\"timestamp\":%llu, " "\"timestamp\":%llu, "
"\"modId\":%u, " "\"modId\":%u, "
"\"xCoord\":%u, " "\"row\":%u, "
"\"yCoord\":%u, " "\"column\":%u, "
"\"zCoord\":%u, " "\"reserved\":%u, "
"\"debug\":%u, " "\"debug\":%u, "
"\"roundRNumber\":%u, " "\"roundRNumber\":%u, "
"\"detType\":%u, " "\"detType\":%u, "
@ -285,22 +285,22 @@ public:
//additional stuff //additional stuff
"\"flippedDataX\":%u" "\"flippedDataX\":%u"
;//"}\n\0"; ;//"}\n";
int length = sprintf(buf, jsonHeaderFormat, int length = sprintf(buf, jsonHeaderFormat,
jsonversion, dynamicrange, fileIndex, npixelsx, npixelsy, imageSize, jsonversion, dynamicrange, fileIndex, npixelsx, npixelsy, imageSize,
acqIndex, fIndex, (fname == NULL)? "":fname, dummy?0:1, acqIndex, fIndex, (fname == NULL)? "":fname, dummy?0:1,
frameNumber, expLength, packetNumber, bunchId, timestamp, frameNumber, expLength, packetNumber, bunchId, timestamp,
modId, xCoord, yCoord, zCoord, debug, roundRNumber, modId, row, column, reserved, debug, roundRNumber,
detType, version, detType, version,
//additional stuff //additional stuff
((flippedData == 0 ) ? 0 :flippedData[0]) ((flippedData == 0 ) ? 0 :flippedData[0])
); );
if (additionalJsonHeader && strlen(additionalJsonHeader)) { if (additionalJsonHeader && strlen(additionalJsonHeader)) {
length = sprintf(buf, "%s, %s}\n%c", buf, additionalJsonHeader, '\0'); length = sprintf(buf, "%s, %s}\n", buf, additionalJsonHeader);
} else { } else {
length = sprintf(buf, "%s}\n%c", buf, '\0'); length = sprintf(buf, "%s}\n", buf);
} }
#ifdef VERBOSE #ifdef VERBOSE

View File

@ -11,7 +11,6 @@
#include <semaphore.h> #include <semaphore.h>
#include <vector> #include <vector>
#include <iostream> #include <iostream>
using namespace std;
typedef double double32_t; typedef double double32_t;
typedef float float32_t; typedef float float32_t;
@ -46,7 +45,7 @@ public:
int getFreeValue() const; int getFreeValue() const;
private: private:
vector <Element*> array; std::vector <Element*> array;
unsigned int tail; // input index unsigned int tail; // input index
unsigned int head; // output index unsigned int head; // output index
unsigned int Capacity; unsigned int Capacity;

View File

@ -43,7 +43,7 @@ class sockaddr_in;
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include "logger.h" #include "logger.h"
using namespace std;
#define DEFAULT_PACKET_SIZE 1286 #define DEFAULT_PACKET_SIZE 1286
#define SOCKET_BUFFER_SIZE (100*1024*1024) //100 MB #define SOCKET_BUFFER_SIZE (100*1024*1024) //100 MB
@ -142,8 +142,8 @@ public:
strcpy(ip,"0.0.0.0"); strcpy(ip,"0.0.0.0");
clientAddress_length=sizeof(clientAddress); clientAddress_length=sizeof(clientAddress);
if (eth) { if (eth) {
strcpy(ip,nameToIp(string(eth)).c_str()); strcpy(ip,nameToIp(std::string(eth)).c_str());
if (string(ip)==string("0.0.0.0")) if (std::string(ip)==std::string("0.0.0.0"))
strcpy(ip,eth); strcpy(ip,eth);
} }
@ -161,7 +161,7 @@ public:
serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
if (string(ip)!=string("0.0.0.0")) { if (std::string(ip)!=std::string("0.0.0.0")) {
if (inet_pton(AF_INET, ip, &(serverAddress.sin_addr))); if (inet_pton(AF_INET, ip, &(serverAddress.sin_addr)));
else else
serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
@ -493,7 +493,7 @@ public:
* @param ip IP * @param ip IP
* @returns hostname * @returns hostname
*/ */
static string ipToName(string ip) { static std::string ipToName(std::string ip) {
struct ifaddrs *addrs, *iap; struct ifaddrs *addrs, *iap;
struct sockaddr_in *sa; struct sockaddr_in *sa;
@ -507,7 +507,7 @@ public:
if (iap->ifa_addr && (iap->ifa_flags & IFF_UP) && iap->ifa_addr->sa_family == AF_INET) { if (iap->ifa_addr && (iap->ifa_flags & IFF_UP) && iap->ifa_addr->sa_family == AF_INET) {
sa = (struct sockaddr_in *)(iap->ifa_addr); sa = (struct sockaddr_in *)(iap->ifa_addr);
inet_ntop(iap->ifa_addr->sa_family, (void *)&(sa->sin_addr), buf, buf_len); inet_ntop(iap->ifa_addr->sa_family, (void *)&(sa->sin_addr), buf, buf_len);
if (ip==string(buf)) { if (ip==std::string(buf)) {
//printf("%s\n", iap->ifa_name); //printf("%s\n", iap->ifa_name);
strcpy(buf,iap->ifa_name); strcpy(buf,iap->ifa_name);
break; break;
@ -515,7 +515,7 @@ public:
} }
} }
freeifaddrs(addrs); freeifaddrs(addrs);
return string(buf); return std::string(buf);
}; };
/** /**
@ -523,7 +523,7 @@ public:
* @param inf interface * @param inf interface
* @returns mac address * @returns mac address
*/ */
static string nameToMac(string inf) { static std::string nameToMac(std::string inf) {
struct ifreq ifr; struct ifreq ifr;
int sock, j, k; int sock, j, k;
char mac[32]; char mac[32];
@ -534,7 +534,7 @@ public:
if (-1==ioctl(sock, SIOCGIFHWADDR, &ifr)) { if (-1==ioctl(sock, SIOCGIFHWADDR, &ifr)) {
perror("ioctl(SIOCGIFHWADDR) "); perror("ioctl(SIOCGIFHWADDR) ");
return string("00:00:00:00:00:00"); return std::string("00:00:00:00:00:00");
} }
for (j=0, k=0; j<6; j++) { for (j=0, k=0; j<6; j++) {
k+=snprintf(mac+k, mac_len-k-1, j ? ":%02X" : "%02X", k+=snprintf(mac+k, mac_len-k-1, j ? ":%02X" : "%02X",
@ -545,7 +545,7 @@ public:
if(sock!=1){ if(sock!=1){
close(sock); close(sock);
} }
return string(mac); return std::string(mac);
}; };
@ -554,7 +554,7 @@ public:
* @param inf hostname * @param inf hostname
* @returns IP * @returns IP
*/ */
static string nameToIp(string inf){ static std::string nameToIp(std::string inf){
struct ifreq ifr; struct ifreq ifr;
int sock; int sock;
char *p, addr[32]; char *p, addr[32];
@ -565,7 +565,7 @@ public:
if (-1==ioctl(sock, SIOCGIFADDR, &ifr)) { if (-1==ioctl(sock, SIOCGIFADDR, &ifr)) {
perror("ioctl(SIOCGIFADDR) "); perror("ioctl(SIOCGIFADDR) ");
return string("0.0.0.0"); return std::string("0.0.0.0");
} }
p=inet_ntoa(((struct sockaddr_in *)(&ifr.ifr_addr))->sin_addr); p=inet_ntoa(((struct sockaddr_in *)(&ifr.ifr_addr))->sin_addr);
strncpy(addr,p,addr_len-1); strncpy(addr,p,addr_len-1);
@ -574,7 +574,7 @@ public:
if(sock!=1){ if(sock!=1){
close(sock); close(sock);
} }
return string(addr); return std::string(addr);
}; };
@ -584,7 +584,7 @@ public:
* @param ifr interface request structure * @param ifr interface request structure
* @returns sock * @returns sock
*/ */
static int getSock(string inf, struct ifreq *ifr) { static int getSock(std::string inf, struct ifreq *ifr) {
int sock; int sock;
sock=socket(PF_INET, SOCK_STREAM, 0); sock=socket(PF_INET, SOCK_STREAM, 0);

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "6bb7195a2c7dc9526088882e0244a7455d3c15b2" #define GITREPUUID "d2bce7e372c241cd235977b92be18555bca6a77d"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3941 #define GITREV 0x4020
#define GITDATE 0x20180718 #define GITDATE 0x20180927
#define GITBRANCH "3.3.0-rc" #define GITBRANCH "4.0.0"

View File

@ -24,13 +24,13 @@
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x) #define TOSTRING(x) STRINGIFY(x)
#define MYCONCAT(x,y) #define MYCONCAT(x,y)
#define __AT__ string(__FILE__) + string("::") + string(__func__) + string("(): ") #define __AT__ std::string(__FILE__) + std::string("::") + std::string(__func__) + std::string("(): ")
#define __SHORT_FORM_OF_FILE__ \ #define __SHORT_FORM_OF_FILE__ \
(strrchr(__FILE__,'/') \ (strrchr(__FILE__,'/') \
? strrchr(__FILE__,'/')+1 \ ? strrchr(__FILE__,'/')+1 \
: __FILE__ \ : __FILE__ \
) )
#define __SHORT_AT__ string(__SHORT_FORM_OF_FILE__) + string("::") + string(__func__) + string("(): ") #define __SHORT_AT__ std::string(__SHORT_FORM_OF_FILE__) + std::string("::") + std::string(__func__) + std::string("(): ")

View File

@ -28,8 +28,8 @@
#define MAX_CHUNKED_IMAGES 1 #define MAX_CHUNKED_IMAGES 1
//versions //versions
#define HDF5_WRITER_VERSION 2.0 //1 decimal places #define HDF5_WRITER_VERSION 3.0 //1 decimal places
#define BINARY_WRITER_VERSION 2.0 //1 decimal places #define BINARY_WRITER_VERSION 3.0 //1 decimal places
//parameters to calculate fifo depth //parameters to calculate fifo depth

View File

@ -163,8 +163,8 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
/** set detector hostname */ /** set detector hostname */
int set_detector_hostname(); int set_detector_hostname();
/** set short frame */ /** set roi */
int set_short_frame(); int set_roi();
/** Set up UDP Details */ /** Set up UDP Details */
int setup_udp(); int setup_udp();

View File

@ -37,8 +37,8 @@ typedef int int32_t;
#define DEFAULT_ZMQ_CL_PORTNO 30001 #define DEFAULT_ZMQ_CL_PORTNO 30001
#define DEFAULT_ZMQ_RX_PORTNO 30001 #define DEFAULT_ZMQ_RX_PORTNO 30001
#define SLS_DETECTOR_HEADER_VERSION 0x1 #define SLS_DETECTOR_HEADER_VERSION 0x2
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2 #define SLS_DETECTOR_JSON_HEADER_VERSION 0x3
/** /**
\file sls_receiver_defs.h \file sls_receiver_defs.h
@ -143,9 +143,9 @@ public:
@li bunchId is the bunch id from beamline @li bunchId is the bunch id from beamline
@li timestamp is the time stamp with 10 MHz clock @li timestamp is the time stamp with 10 MHz clock
@li modId is the unique module id (unique even for left, right, top, bottom) @li modId is the unique module id (unique even for left, right, top, bottom)
@li xCoord is the x coordinate in the complete detector system @li row is the row index in the complete detector system
@li yCoord is the y coordinate in the complete detector system @li column is the column index in the complete detector system
@li zCoord is the z coordinate in the complete detector system @li reserved is reserved
@li debug is for debugging purposes @li debug is for debugging purposes
@li roundRNumber is the round robin set number @li roundRNumber is the round robin set number
@li detType is the detector type see :: detectorType @li detType is the detector type see :: detectorType
@ -159,9 +159,9 @@ public:
uint64_t bunchId; /**< is the bunch id from beamline */ uint64_t bunchId; /**< is the bunch id from beamline */
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */ uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */ uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
uint16_t xCoord; /**< is the x coordinate in the complete detector system */ uint16_t row; /**< is the row index in the complete detector system */
uint16_t yCoord; /**< is the y coordinate in the complete detector system */ uint16_t column; /**< is the column index in the complete detector system */
uint16_t zCoord; /**< is the z coordinate in the complete detector system */ uint16_t reserved; /**< is reserved */
uint32_t debug; /**< is for debugging purposes */ uint32_t debug; /**< is for debugging purposes */
uint16_t roundRNumber; /**< is the round robin set number */ uint16_t roundRNumber; /**< is the round robin set number */
uint8_t detType; /**< is the detector type see :: detectorType */ uint8_t detType; /**< is the detector type see :: detectorType */
@ -205,6 +205,19 @@ public:
}; };
/**
@short structure for a region of interest
xmin,xmax,ymin,ymax define the limits of the region
*/
typedef struct {
int xmin; /**< is the roi xmin (in channel number) */
int xmax; /**< is the roi xmax (in channel number)*/
int ymin; /**< is the roi ymin (in channel number)*/
int ymax; /**< is the roi ymax (in channel number)*/
} ROI ;
#ifdef __cplusplus #ifdef __cplusplus
/** returns string from enabled/disabled /** returns string from enabled/disabled
\param b true or false \param b true or false

View File

@ -22,7 +22,7 @@ enum recFuncs{
F_SEND_RECEIVER_DETHOSTNAME, /**< set detector hostname to receiver */ F_SEND_RECEIVER_DETHOSTNAME, /**< set detector hostname to receiver */
//network functions //network functions
F_RECEIVER_SHORT_FRAME, /**< Sets receiver to receive short frames */ F_RECEIVER_SET_ROI, /**< Sets receiver ROI */
F_SETUP_RECEIVER_UDP, /**< sets the receiver udp connection and returns receiver mac address */ F_SETUP_RECEIVER_UDP, /**< sets the receiver udp connection and returns receiver mac address */
//Acquisition setup functions //Acquisition setup functions

View File

@ -5,12 +5,11 @@
#include <iostream> #include <iostream>
#include <map> #include <map>
using namespace std;
#include "sls_receiver_defs.h" #include "sls_receiver_defs.h"
/* uncomment next line to enable debug output */ /* uncomment next line to enable debug output */
//#define EIGER_DEBUG //#define EIGER_DEBUG
int read_config_file(string fname, int *tcpip_port_no, map<string, string> * configuration_map); int read_config_file(std::string fname, int *tcpip_port_no, std::map<std::string, std::string> * configuration_map);

View File

@ -9,7 +9,6 @@
#include "Fifo.h" #include "Fifo.h"
#include <iostream> #include <iostream>
using namespace std;
FILE* BinaryFile::masterfd = 0; FILE* BinaryFile::masterfd = 0;

View File

@ -18,9 +18,8 @@
#include <iostream> #include <iostream>
#include <errno.h> #include <errno.h>
#include <cstring> #include <cstring>
using namespace std;
const string DataProcessor::TypeName = "DataProcessor"; const std::string DataProcessor::TypeName = "DataProcessor";
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f, DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
@ -78,7 +77,7 @@ DataProcessor::~DataProcessor() {
} }
/** getters */ /** getters */
string DataProcessor::GetType(){ std::string DataProcessor::GetType(){
return TypeName; return TypeName;
} }
@ -478,7 +477,7 @@ void DataProcessor::PadMissingPackets(char* buf) {
if (!nmissing) if (!nmissing)
break; break;
FILE_LOG(logDEBUG) << "padding for " << index << " for pnum: " << pnum << endl; FILE_LOG(logDEBUG) << "padding for " << index << " for pnum: " << pnum << std::endl;
// missing packet // missing packet
switch(myDetectorType) { switch(myDetectorType) {

View File

@ -11,12 +11,11 @@
#include <iostream> #include <iostream>
#include <errno.h> #include <errno.h>
using namespace std;
const string DataStreamer::TypeName = "DataStreamer"; const std::string DataStreamer::TypeName = "DataStreamer";
DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, int* sEnable, DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
uint64_t* fi, int* fd, char* ajh, bool* sm) : uint64_t* fi, int* fd, char* ajh, bool* sm) :
ThreadObject(ind), ThreadObject(ind),
runningFlag(0), runningFlag(0),
@ -24,7 +23,8 @@ DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, int* sEnable,
fifo(f), fifo(f),
zmqSocket(0), zmqSocket(0),
dynamicRange(dr), dynamicRange(dr),
shortFrameEnable(sEnable), roi(r),
adcConfigured(-1),
fileIndex(fi), fileIndex(fi),
flippedData(fd), flippedData(fd),
additionJsonHeader(ajh), additionJsonHeader(ajh),
@ -51,7 +51,7 @@ DataStreamer::~DataStreamer() {
} }
/** getters */ /** getters */
string DataStreamer::GetType(){ std::string DataStreamer::GetType(){
return TypeName; return TypeName;
} }
@ -88,7 +88,10 @@ void DataStreamer::ResetParametersforNewMeasurement(char* fname){
delete [] completeBuffer; delete [] completeBuffer;
completeBuffer = 0; completeBuffer = 0;
} }
if (*shortFrameEnable >= 0) { if (roi->size()) {
if (generalData->myDetectorType == GOTTHARD) {
adcConfigured = generalData->GetAdcConfigured(index, roi);
}
completeBuffer = new char[generalData->imageSizeComplete]; completeBuffer = new char[generalData->imageSizeComplete];
memset(completeBuffer, 0, generalData->imageSizeComplete); memset(completeBuffer, 0, generalData->imageSizeComplete);
} }
@ -212,11 +215,19 @@ void DataStreamer::ProcessAnImage(char* buf) {
//shortframe gotthard //shortframe gotthard
if (completeBuffer) { if (completeBuffer) {
if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), generalData->nPixelsXComplete, generalData->nPixelsYComplete, false)) //disregarding the size modified from callback (always using imageSizeComplete
// instead of buf (32 bit) because gui needs imagesizecomplete and listener
//write imagesize
if (!SendHeader(header, generalData->imageSizeComplete,
generalData->nPixelsXComplete, generalData->nPixelsYComplete, false))
cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n",
(long long int) fnum, index); (long long int) fnum, index);
memcpy(completeBuffer + ((generalData->imageSize)**shortFrameEnable), buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), (uint32_t)(*((uint32_t*)buf)) ); // new size possibly from callback memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured),
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
(uint32_t)(*((uint32_t*)buf)) );
if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete)) if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete))
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
(long long int) fnum, index); (long long int) fnum, index);
@ -226,11 +237,13 @@ void DataStreamer::ProcessAnImage(char* buf) {
//normal //normal
else { else {
if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), generalData->nPixelsX, generalData->nPixelsY, false)) // new size possibly from callback if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)),
generalData->nPixelsX, generalData->nPixelsY, false)) // new size possibly from callback
cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n",
(long long int) fnum, index); (long long int) fnum, index);
if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), (uint32_t)(*((uint32_t*)buf)) )) // new size possibly from callback if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
(uint32_t)(*((uint32_t*)buf)) )) // new size possibly from callback
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
(long long int) fnum, index); (long long int) fnum, index);
} }
@ -252,7 +265,7 @@ int DataStreamer::SendHeader(sls_receiver_header* rheader, uint32_t size, uint32
nx, ny, size, nx, ny, size,
acquisitionIndex, frameIndex, fileNametoStream, acquisitionIndex, frameIndex, fileNametoStream,
header.frameNumber, header.expLength, header.packetNumber, header.bunchId, header.timestamp, header.frameNumber, header.expLength, header.packetNumber, header.bunchId, header.timestamp,
header.modId, header.xCoord, header.yCoord, header.zCoord, header.modId, header.row, header.column, header.reserved,
header.debug, header.roundRNumber, header.debug, header.roundRNumber,
header.detType, header.version, header.detType, header.version,
flippedData, flippedData,

View File

@ -10,7 +10,6 @@
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
using namespace std;
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth): Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):

View File

@ -7,7 +7,6 @@
#include "File.h" #include "File.h"
#include <iostream> #include <iostream>
using namespace std;
File::File(int ind, uint32_t* maxf, File::File(int ind, uint32_t* maxf,
@ -35,28 +34,28 @@ File::File(int ind, uint32_t* maxf,
File::~File() {} File::~File() {}
string File::GetCurrentFileName() { std::string File::GetCurrentFileName() {
return currentFileName; return currentFileName;
} }
void File::PrintMembers() { void File::PrintMembers() {
FILE_LOG(logINFO) << "\nGeneral Writer Variables:" << endl FILE_LOG(logINFO) << "\nGeneral Writer Variables:" << std::endl
<< "Index: " << index << endl << "Index: " << index << std::endl
<< "Max Frames Per File: " << *maxFramesPerFile << endl << "Max Frames Per File: " << *maxFramesPerFile << std::endl
<< "Number of Detectors in x dir: " << numDetX << endl << "Number of Detectors in x dir: " << numDetX << std::endl
<< "Number of Detectors in y dir: " << numDetY << endl << "Number of Detectors in y dir: " << numDetY << std::endl
<< "File Name Prefix: " << fileNamePrefix << endl << "File Name Prefix: " << fileNamePrefix << std::endl
<< "File Path: " << filePath << endl << "File Path: " << filePath << std::endl
<< "File Index: " << *fileIndex << endl << "File Index: " << *fileIndex << std::endl
<< "Over Write Enable: " << *overWriteEnable << endl << "Over Write Enable: " << *overWriteEnable << std::endl
<< "Detector Index: " << *detIndex << endl << "Detector Index: " << *detIndex << std::endl
<< "Number of Units Per Detector: " << *numUnitsPerDetector << endl << "Number of Units Per Detector: " << *numUnitsPerDetector << std::endl
<< "Number of Images in Acquisition: " << *numImages << endl << "Number of Images in Acquisition: " << *numImages << std::endl
<< "Dynamic Range: " << *dynamicRange << endl << "Dynamic Range: " << *dynamicRange << std::endl
<< "UDP Port number: " << *udpPortNumber << endl << "UDP Port number: " << *udpPortNumber << std::endl
<< "Master File Name: " << masterFileName << endl << "Master File Name: " << masterFileName << std::endl
<< "Current File Name: " << currentFileName << endl << "Current File Name: " << currentFileName << std::endl
<< "Silent Mode: " << *silentMode; << "Silent Mode: " << *silentMode;
} }

View File

@ -11,8 +11,6 @@
#include <iomanip> #include <iomanip>
#include <libgen.h> //basename #include <libgen.h> //basename
#include <string.h> #include <string.h>
using namespace std;
pthread_mutex_t HDF5File::Mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t HDF5File::Mutex = PTHREAD_MUTEX_INITIALIZER;
@ -65,13 +63,13 @@ HDF5File::HDF5File(int ind, uint32_t* maxf,
parameterNames.push_back("mod id"); parameterNames.push_back("mod id");
parameterDataTypes.push_back(PredType::STD_U16LE); parameterDataTypes.push_back(PredType::STD_U16LE);
parameterNames.push_back("x Coord"); parameterNames.push_back("row");
parameterDataTypes.push_back(PredType::STD_U16LE); parameterDataTypes.push_back(PredType::STD_U16LE);
parameterNames.push_back("y Coord"); parameterNames.push_back("column");
parameterDataTypes.push_back(PredType::STD_U16LE); parameterDataTypes.push_back(PredType::STD_U16LE);
parameterNames.push_back("z Coord"); parameterNames.push_back("reserved");
parameterDataTypes.push_back(PredType::STD_U16LE); parameterDataTypes.push_back(PredType::STD_U16LE);
parameterNames.push_back("debug"); parameterNames.push_back("debug");
@ -298,7 +296,7 @@ void HDF5File::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
int HDF5File::CreateVirtualFile(uint64_t numf) { int HDF5File::CreateVirtualFile(uint64_t numf) {
pthread_mutex_lock(&Mutex); pthread_mutex_lock(&Mutex);
string vname = HDF5FileStatic::CreateVirtualFileName(filePath, fileNamePrefix, *fileIndex); std::string vname = HDF5FileStatic::CreateVirtualFileName(filePath, fileNamePrefix, *fileIndex);
if(!(*silentMode)) { if(!(*silentMode)) {
FILE_LOG(logINFO) << "Virtual File: " << vname; FILE_LOG(logINFO) << "Virtual File: " << vname;
} }
@ -321,10 +319,10 @@ int HDF5File::CreateVirtualFile(uint64_t numf) {
// called only by the one maser receiver // called only by the one maser receiver
int HDF5File::LinkVirtualFileinMasterFile() { int HDF5File::LinkVirtualFileinMasterFile() {
//dataset name //dataset name
ostringstream osfn; std::ostringstream osfn;
osfn << "/data"; osfn << "/data";
if ((*numImages > 1)) osfn << "_f" << setfill('0') << setw(12) << 0; if ((*numImages > 1)) osfn << "_f" << std::setfill('0') << std::setw(12) << 0;
string dsetname = osfn.str(); std::string dsetname = osfn.str();
pthread_mutex_lock(&Mutex); pthread_mutex_lock(&Mutex);
int ret = HDF5FileStatic::LinkVirtualInMaster(masterFileName, currentFileName, int ret = HDF5FileStatic::LinkVirtualInMaster(masterFileName, currentFileName,

View File

@ -14,9 +14,8 @@
#include <iostream> #include <iostream>
#include <errno.h> #include <errno.h>
#include <cstring> #include <cstring>
using namespace std;
const string Listener::TypeName = "Listener"; const std::string Listener::TypeName = "Listener";
Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s, Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
@ -41,8 +40,8 @@ Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
activated(act), activated(act),
deactivatedPaddingEnable(depaden), deactivatedPaddingEnable(depaden),
silentMode(sm), silentMode(sm),
xcoord(0), row(0),
ycoord(0), column(0),
acquisitionStartedFlag(false), acquisitionStartedFlag(false),
measurementStartedFlag(false), measurementStartedFlag(false),
firstAcquisitionIndex(0), firstAcquisitionIndex(0),
@ -74,7 +73,7 @@ Listener::~Listener() {
} }
/** getters */ /** getters */
string Listener::GetType(){ std::string Listener::GetType(){
return TypeName; return TypeName;
} }
@ -289,9 +288,9 @@ int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
return OK; return OK;
} }
void Listener::SetHardCodedCoords(uint16_t x, uint16_t y) { void Listener::SetHardCodedPosition(uint16_t r, uint16_t c) {
xcoord = x; row = r;
ycoord = y; column = c;
} }
void Listener::ThreadExecution() { void Listener::ThreadExecution() {
@ -406,8 +405,8 @@ uint32_t Listener::ListenToAnImage(char* buf) {
++currentFrameIndex; ++currentFrameIndex;
} }
new_header->detHeader.frameNumber = currentFrameIndex; new_header->detHeader.frameNumber = currentFrameIndex;
new_header->detHeader.xCoord = xcoord; new_header->detHeader.row = row;
new_header->detHeader.yCoord = ycoord; new_header->detHeader.column = column;
new_header->detHeader.detType = (uint8_t) generalData->myDetectorType; new_header->detHeader.detType = (uint8_t) generalData->myDetectorType;
new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION; new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
return generalData->imageSize; return generalData->imageSize;
@ -448,8 +447,8 @@ uint32_t Listener::ListenToAnImage(char* buf) {
} }
new_header->detHeader.packetNumber = numpackets; new_header->detHeader.packetNumber = numpackets;
if(isHeaderEmpty) { if(isHeaderEmpty) {
new_header->detHeader.xCoord = xcoord; new_header->detHeader.row = row;
new_header->detHeader.yCoord = ycoord; new_header->detHeader.column = column;
} }
return generalData->imageSize; return generalData->imageSize;
} }
@ -488,8 +487,8 @@ uint32_t Listener::ListenToAnImage(char* buf) {
// -------------------old header ------------------------------------------------------------------------------ // -------------------old header ------------------------------------------------------------------------------
else { else {
new_header->detHeader.frameNumber = fnum; new_header->detHeader.frameNumber = fnum;
new_header->detHeader.xCoord = xcoord; new_header->detHeader.row = row;
new_header->detHeader.yCoord = ycoord; new_header->detHeader.column = column;
new_header->detHeader.detType = (uint8_t) generalData->myDetectorType; new_header->detHeader.detType = (uint8_t) generalData->myDetectorType;
new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION; new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
} }
@ -525,8 +524,8 @@ uint32_t Listener::ListenToAnImage(char* buf) {
} }
new_header->detHeader.packetNumber = numpackets; //number of packets caught new_header->detHeader.packetNumber = numpackets; //number of packets caught
if(isHeaderEmpty) { if(isHeaderEmpty) {
new_header->detHeader.xCoord = xcoord; new_header->detHeader.row = row;
new_header->detHeader.yCoord = ycoord; new_header->detHeader.column = column;
} }
return generalData->imageSize; //empty packet now, but not empty image return generalData->imageSize; //empty packet now, but not empty image
} }
@ -584,8 +583,8 @@ uint32_t Listener::ListenToAnImage(char* buf) {
} }
new_header->detHeader.packetNumber = numpackets; //number of packets caught new_header->detHeader.packetNumber = numpackets; //number of packets caught
if(isHeaderEmpty) { if(isHeaderEmpty) {
new_header->detHeader.xCoord = xcoord; new_header->detHeader.row = row;
new_header->detHeader.yCoord = ycoord; new_header->detHeader.column = column;
} }
return generalData->imageSize; return generalData->imageSize;
} }
@ -621,8 +620,8 @@ uint32_t Listener::ListenToAnImage(char* buf) {
// -------------------old header ------------------------------------------------------------------------------ // -------------------old header ------------------------------------------------------------------------------
else { else {
new_header->detHeader.frameNumber = fnum; new_header->detHeader.frameNumber = fnum;
new_header->detHeader.xCoord = xcoord; new_header->detHeader.row = row;
new_header->detHeader.yCoord = ycoord; new_header->detHeader.column = column;
new_header->detHeader.detType = (uint8_t) generalData->myDetectorType; new_header->detHeader.detType = (uint8_t) generalData->myDetectorType;
new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION; new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
} }

View File

@ -7,13 +7,6 @@
#include <iostream> #include <iostream>
#include <cstdio> #include <cstdio>
using namespace std;

View File

@ -9,7 +9,6 @@
#include <iostream> #include <iostream>
#include <syscall.h> #include <syscall.h>
using namespace std;

View File

@ -9,7 +9,6 @@
#include <sys/stat.h> // stat #include <sys/stat.h> // stat
#include <iostream> #include <iostream>
#include <string.h> #include <string.h>
using namespace std;
@ -82,7 +81,7 @@ void UDPBaseImplementation::initializeMembers(){
dataCompressionEnable = false; dataCompressionEnable = false;
//***acquisition parameters*** //***acquisition parameters***
shortFrameEnable = -1; roi.clear();
frameToGuiFrequency = 0; frameToGuiFrequency = 0;
frameToGuiTimerinMS = DEFAULT_STREAMING_TIMER_IN_MS; frameToGuiTimerinMS = DEFAULT_STREAMING_TIMER_IN_MS;
dataStreamEnable = false; dataStreamEnable = false;
@ -250,9 +249,9 @@ char *UDPBaseImplementation::getEthernetInterface() const{
/***acquisition parameters***/ /***acquisition parameters***/
int UDPBaseImplementation::getShortFrameEnable() const{ std::vector<slsReceiverDefs::ROI> UDPBaseImplementation::getROI() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return shortFrameEnable; return roi;
} }
uint32_t UDPBaseImplementation::getFrameToGuiFrequency() const{ uint32_t UDPBaseImplementation::getFrameToGuiFrequency() const{
@ -373,7 +372,7 @@ uint32_t UDPBaseImplementation::getActualUDPSocketBufferSize() const {
*************************************************************************/ *************************************************************************/
/**initial parameters***/ /**initial parameters***/
void UDPBaseImplementation::configure(map<string, string> config_map){ void UDPBaseImplementation::configure(std::map<std::string, std::string> config_map){
FILE_LOG(logERROR) << __AT__ << " doing nothing..."; FILE_LOG(logERROR) << __AT__ << " doing nothing...";
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes"; FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
} }
@ -541,11 +540,27 @@ void UDPBaseImplementation::setEthernetInterface(const char* c){
/***acquisition parameters***/ /***acquisition parameters***/
int UDPBaseImplementation::setShortFrameEnable(const int i){ int UDPBaseImplementation::setROI(const std::vector<slsReceiverDefs::ROI> i){
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
shortFrameEnable = i; roi = i;
FILE_LOG(logINFO) << "Short Frame Enable: " << stringEnable(shortFrameEnable);
std::stringstream sstm;
sstm << "ROI: ";
if (!roi.size())
sstm << "0";
else {
for (unsigned int i = 0; i < roi.size(); ++i) {
sstm << "( " <<
roi[i].xmin << ", " <<
roi[i].xmax << ", " <<
roi[i].ymin << ", " <<
roi[i].ymax << " )";
}
}
std::string message = sstm.str();
FILE_LOG(logINFO) << message;
//overrridden child classes might return FAIL //overrridden child classes might return FAIL
return OK; return OK;
} }

View File

@ -7,16 +7,14 @@
#include <iostream> #include <iostream>
#include <string.h> #include <string.h>
using namespace std;
#include "UDPInterface.h" #include "UDPInterface.h"
#include "UDPBaseImplementation.h" #include "UDPBaseImplementation.h"
#include "UDPStandardImplementation.h" #include "UDPStandardImplementation.h"
using namespace std;
UDPInterface * UDPInterface::create(string receiver_type){ UDPInterface * UDPInterface::create(std::string receiver_type){
if (receiver_type == "standard"){ if (receiver_type == "standard"){
FILE_LOG(logINFO) << "Starting " << receiver_type; FILE_LOG(logINFO) << "Starting " << receiver_type;

View File

@ -16,7 +16,6 @@
#include <cstring> //strcpy #include <cstring> //strcpy
#include <errno.h> //eperm #include <errno.h> //eperm
#include <fstream> #include <fstream>
using namespace std;
/** cosntructor & destructor */ /** cosntructor & destructor */
@ -33,16 +32,16 @@ UDPStandardImplementation::~UDPStandardImplementation() {
void UDPStandardImplementation::DeleteMembers() { void UDPStandardImplementation::DeleteMembers() {
if (generalData) { delete generalData; generalData=0;} if (generalData) { delete generalData; generalData=0;}
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
delete(*it); delete(*it);
listener.clear(); listener.clear();
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
delete(*it); delete(*it);
dataProcessor.clear(); dataProcessor.clear();
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
delete(*it); delete(*it);
dataStreamer.clear(); dataStreamer.clear();
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it) for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
delete(*it); delete(*it);
fifo.clear(); fifo.clear();
} }
@ -69,8 +68,8 @@ uint64_t UDPStandardImplementation::getTotalFramesCaught() const {
uint64_t sum = 0; uint64_t sum = 0;
uint32_t flagsum = 0; uint32_t flagsum = 0;
vector<DataProcessor*>::const_iterator it; std::vector<DataProcessor*>::const_iterator it;
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) { for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
flagsum += ((*it)->GetMeasurementStartedFlag() ? 1 : 0); flagsum += ((*it)->GetMeasurementStartedFlag() ? 1 : 0);
sum += (*it)->GetNumTotalFramesCaught(); sum += (*it)->GetNumTotalFramesCaught();
} }
@ -85,7 +84,7 @@ uint64_t UDPStandardImplementation::getFramesCaught() const {
uint64_t sum = 0; uint64_t sum = 0;
uint32_t flagsum = 0; uint32_t flagsum = 0;
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) { for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0); flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0);
sum += (*it)->GetNumFramesCaught(); sum += (*it)->GetNumFramesCaught();
} }
@ -100,7 +99,7 @@ int64_t UDPStandardImplementation::getAcquisitionIndex() const {
uint64_t sum = 0; uint64_t sum = 0;
uint32_t flagsum = 0; uint32_t flagsum = 0;
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){ for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0); flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0);
sum += (*it)->GetActualProcessedAcquisitionIndex(); sum += (*it)->GetActualProcessedAcquisitionIndex();
} }
@ -120,7 +119,7 @@ int UDPStandardImplementation::setGapPixelsEnable(const bool b) {
// side effects // side effects
generalData->SetGapPixelsEnable(b, dynamicRange); generalData->SetGapPixelsEnable(b, dynamicRange);
// to update npixelsx, npixelsy in file writer // to update npixelsx, npixelsy in file writer
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->SetPixelDimension(); (*it)->SetPixelDimension();
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
@ -144,7 +143,7 @@ void UDPStandardImplementation::setFileFormat(const fileFormat f){
break; break;
} }
//destroy file writer, set file format and create file writer //destroy file writer, set file format and create file writer
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->SetFileFormat(f); (*it)->SetFileFormat(f);
FILE_LOG(logINFO) << "File Format:" << getFileFormatType(fileFormatType); FILE_LOG(logINFO) << "File Format:" << getFileFormatType(fileFormatType);
@ -168,35 +167,64 @@ void UDPStandardImplementation::setFileWriteEnable(const bool b){
int UDPStandardImplementation::setShortFrameEnable(const int i) { int UDPStandardImplementation::setROI(const std::vector<slsReceiverDefs::ROI> i) {
if (myDetectorType != GOTTHARD) { if (myDetectorType != GOTTHARD) {
cprintf(RED, "Error: Can not set short frame for this detector\n"); cprintf(RED, "Error: Can not set ROI for this detector\n");
return FAIL; return FAIL;
} }
if (shortFrameEnable != i) {
shortFrameEnable = i;
if (generalData) bool change = false;
delete generalData; if (roi.size() != i.size())
if (i != -1) change = true;
generalData = new ShortGotthardData(); else {
else for (unsigned int iloop = 0; iloop < i.size(); ++iloop) {
generalData = new GotthardData(); if (
(roi[iloop].xmin != i[iloop].xmin) ||
(roi[iloop].xmax != i[iloop].xmax) ||
(roi[iloop].ymin != i[iloop].ymin) ||
(roi[iloop].xmax != i[iloop].xmax)) {
change = true;
break;
}
}
}
if (change) {
roi = i;
generalData->SetROI(i);
framesPerFile = generalData->maxFramesPerFile; framesPerFile = generalData->maxFramesPerFile;
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
if (SetupFifoStructure() == FAIL) if (SetupFifoStructure() == FAIL)
return FAIL; return FAIL;
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
(*it)->SetGeneralData(generalData); (*it)->SetGeneralData(generalData);
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->SetGeneralData(generalData); (*it)->SetGeneralData(generalData);
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
(*it)->SetGeneralData(generalData); (*it)->SetGeneralData(generalData);
} }
FILE_LOG(logINFO) << "Short Frame Enable: " << shortFrameEnable;
std::stringstream sstm;
sstm << "ROI: ";
if (!roi.size())
sstm << "0";
else {
for (unsigned int i = 0; i < roi.size(); ++i) {
sstm << "( " <<
roi[i].xmin << ", " <<
roi[i].xmax << ", " <<
roi[i].ymin << ", " <<
roi[i].ymax << " )";
}
}
std::string message = sstm.str();
FILE_LOG(logINFO) << message;
return OK; return OK;
} }
@ -216,7 +244,7 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
dataStreamEnable = enable; dataStreamEnable = enable;
//data sockets have to be created again as the client ones are //data sockets have to be created again as the client ones are
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
delete(*it); delete(*it);
dataStreamer.clear(); dataStreamer.clear();
@ -224,13 +252,13 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
for ( int i = 0; i < numThreads; ++i ) { for ( int i = 0; i < numThreads; ++i ) {
try { try {
DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange, DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange,
&shortFrameEnable, &fileIndex, flippedData, additionalJsonHeader, &silentMode); &roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode);
dataStreamer.push_back(s); dataStreamer.push_back(s);
dataStreamer[i]->SetGeneralData(generalData); dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP); dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP);
} }
catch(...) { catch(...) {
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
delete(*it); delete(*it);
dataStreamer.clear(); dataStreamer.clear();
dataStreamEnable = false; dataStreamEnable = false;
@ -269,7 +297,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i) {
generalData->SetDynamicRange(i,tengigaEnable); generalData->SetDynamicRange(i,tengigaEnable);
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange); generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange);
// to update npixelsx, npixelsy in file writer // to update npixelsx, npixelsy in file writer
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->SetPixelDimension(); (*it)->SetPixelDimension();
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
@ -374,10 +402,10 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
} }
catch (...) { catch (...) {
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")"; FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
delete(*it); delete(*it);
listener.clear(); listener.clear();
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
delete(*it); delete(*it);
dataProcessor.clear(); dataProcessor.clear();
return FAIL; return FAIL;
@ -385,9 +413,9 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
} }
//set up writer and callbacks //set up writer and callbacks
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
(*it)->SetGeneralData(generalData); (*it)->SetGeneralData(generalData);
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->SetGeneralData(generalData); (*it)->SetGeneralData(generalData);
SetThreadPriorities(); SetThreadPriorities();
@ -413,27 +441,22 @@ void UDPStandardImplementation::setDetectorPositionId(const int i){
} }
for (unsigned int i = 0; i < listener.size(); ++i) { for (unsigned int i = 0; i < listener.size(); ++i) {
uint16_t x = 0, y = 0; uint16_t row = 0, col = 0;
if (myDetectorType == EIGER || myDetectorType == JUNGFRAU) { row = detID % numDet[1]; // row
x = detID % numDet[1]; // row col = (detID / numDet[1]) * ((myDetectorType == EIGER) ? 2 : 1) + i; // col for horiz. udp ports
y = (detID / numDet[1]) * ((myDetectorType == EIGER) ? 2 : 1) + i; // col for horiz. udp ports listener[i]->SetHardCodedPosition(row, col);
}
// calculate x in 1d
else
x = detID * numThreads + i;
listener[i]->SetHardCodedCoords(x,y);
} }
} }
void UDPStandardImplementation::resetAcquisitionCount() { void UDPStandardImplementation::resetAcquisitionCount() {
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
(*it)->ResetParametersforNewAcquisition(); (*it)->ResetParametersforNewAcquisition();
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->ResetParametersforNewAcquisition(); (*it)->ResetParametersforNewAcquisition();
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
(*it)->ResetParametersforNewAcquisition(); (*it)->ResetParametersforNewAcquisition();
FILE_LOG(logINFO) << "Acquisition Count has been reset"; FILE_LOG(logINFO) << "Acquisition Count has been reset";
@ -444,7 +467,6 @@ void UDPStandardImplementation::resetAcquisitionCount() {
int UDPStandardImplementation::startReceiver(char *c) { int UDPStandardImplementation::startReceiver(char *c) {
cprintf(RESET,"\n"); cprintf(RESET,"\n");
FILE_LOG(logINFO) << "Starting Receiver"; FILE_LOG(logINFO) << "Starting Receiver";
ResetParametersforNewMeasurement(); ResetParametersforNewMeasurement();
//listener //listener
@ -498,10 +520,10 @@ void UDPStandardImplementation::stopReceiver(){
bool running = true; bool running = true;
while(running) { while(running) {
running = false; running = false;
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
if ((*it)->IsRunning()) if ((*it)->IsRunning())
running = true; running = true;
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
if ((*it)->IsRunning()) if ((*it)->IsRunning())
running = true; running = true;
usleep(5000); usleep(5000);
@ -512,8 +534,8 @@ void UDPStandardImplementation::stopReceiver(){
if (fileWriteEnable && fileFormatType == HDF5) { if (fileWriteEnable && fileFormatType == HDF5) {
uint64_t maxIndexCaught = 0; uint64_t maxIndexCaught = 0;
bool anycaught = false; bool anycaught = false;
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) { for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
maxIndexCaught = max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex()); maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
if((*it)->GetMeasurementStartedFlag()) if((*it)->GetMeasurementStartedFlag())
anycaught = true; anycaught = true;
} }
@ -525,7 +547,7 @@ void UDPStandardImplementation::stopReceiver(){
running = true; running = true;
while(running) { while(running) {
running = false; running = false;
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
if ((*it)->IsRunning()) if ((*it)->IsRunning())
running = true; running = true;
usleep(5000); usleep(5000);
@ -575,7 +597,7 @@ void UDPStandardImplementation::startReadout(){
// wait for incoming delayed packets // wait for incoming delayed packets
//current packets caught //current packets caught
volatile int totalP = 0,prev=-1; volatile int totalP = 0,prev=-1;
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
totalP += (*it)->GetPacketsCaught(); totalP += (*it)->GetPacketsCaught();
//wait for all packets //wait for all packets
@ -594,7 +616,7 @@ void UDPStandardImplementation::startReadout(){
prev = totalP; prev = totalP;
totalP = 0; totalP = 0;
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
totalP += (*it)->GetPacketsCaught(); totalP += (*it)->GetPacketsCaught();
#ifdef VERY_VERBOSE #ifdef VERY_VERBOSE
cprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP); cprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP);
@ -613,7 +635,7 @@ void UDPStandardImplementation::startReadout(){
void UDPStandardImplementation::shutDownUDPSockets() { void UDPStandardImplementation::shutDownUDPSockets() {
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
(*it)->ShutDownUDPSocket(); (*it)->ShutDownUDPSocket();
} }
@ -622,9 +644,9 @@ void UDPStandardImplementation::shutDownUDPSockets() {
void UDPStandardImplementation::closeFiles() { void UDPStandardImplementation::closeFiles() {
uint64_t maxIndexCaught = 0; uint64_t maxIndexCaught = 0;
bool anycaught = false; bool anycaught = false;
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) { for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
(*it)->CloseFiles(); (*it)->CloseFiles();
maxIndexCaught = max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex()); maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
if((*it)->GetMeasurementStartedFlag()) if((*it)->GetMeasurementStartedFlag())
anycaught = true; anycaught = true;
} }
@ -640,7 +662,7 @@ int UDPStandardImplementation::setUDPSocketBufferSize(const uint32_t s) {
int UDPStandardImplementation::restreamStop() { int UDPStandardImplementation::restreamStop() {
bool ret = OK; bool ret = OK;
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) { for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) {
if ((*it)->RestreamStop() == FAIL) if ((*it)->RestreamStop() == FAIL)
ret = FAIL; ret = FAIL;
} }
@ -660,14 +682,14 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
int max_back_log; int max_back_log;
const char *proc_file_name = "/proc/sys/net/core/netdev_max_backlog"; const char *proc_file_name = "/proc/sys/net/core/netdev_max_backlog";
{ {
ifstream proc_file(proc_file_name); std::ifstream proc_file(proc_file_name);
proc_file >> max_back_log; proc_file >> max_back_log;
} }
if (max_back_log < MAX_SOCKET_INPUT_PACKET_QUEUE) { if (max_back_log < MAX_SOCKET_INPUT_PACKET_QUEUE) {
ofstream proc_file(proc_file_name); std::ofstream proc_file(proc_file_name);
if (proc_file.good()) { if (proc_file.good()) {
proc_file << MAX_SOCKET_INPUT_PACKET_QUEUE << endl; proc_file << MAX_SOCKET_INPUT_PACKET_QUEUE << std::endl;
cprintf(GREEN, "Max length of input packet queue " cprintf(GREEN, "Max length of input packet queue "
"[/proc/sys/net/core/netdev_max_backlog] modified to %d\n", "[/proc/sys/net/core/netdev_max_backlog] modified to %d\n",
MAX_SOCKET_INPUT_PACKET_QUEUE); MAX_SOCKET_INPUT_PACKET_QUEUE);
@ -683,13 +705,13 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
void UDPStandardImplementation::SetThreadPriorities() { void UDPStandardImplementation::SetThreadPriorities() {
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){ for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) { if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)"; FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)";
return; return;
} }
} }
ostringstream osfn; std::ostringstream osfn;
osfn << "Priorities set - " osfn << "Priorities set - "
"Listener:" << LISTENER_PRIORITY; "Listener:" << LISTENER_PRIORITY;
@ -701,10 +723,10 @@ int UDPStandardImplementation::SetupFifoStructure() {
numberofJobs = 1; numberofJobs = 1;
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it) for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
delete(*it); delete(*it);
fifo.clear(); fifo.clear();
for ( int i = 0; i < numThreads; i++ ) { for ( int i = 0; i < numThreads; ++i ) {
//create fifo structure //create fifo structure
try { try {
@ -714,7 +736,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
fifo.push_back(f); fifo.push_back(f);
} catch (...) { } catch (...) {
cprintf(RED,"Error: Could not allocate memory for fifo structure of index %d\n", i); cprintf(RED,"Error: Could not allocate memory for fifo structure of index %d\n", i);
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it) for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
delete(*it); delete(*it);
fifo.clear(); fifo.clear();
return FAIL; return FAIL;
@ -733,15 +755,15 @@ int UDPStandardImplementation::SetupFifoStructure() {
void UDPStandardImplementation::ResetParametersforNewMeasurement() { void UDPStandardImplementation::ResetParametersforNewMeasurement() {
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
(*it)->ResetParametersforNewMeasurement(); (*it)->ResetParametersforNewMeasurement();
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->ResetParametersforNewMeasurement(); (*it)->ResetParametersforNewMeasurement();
if (dataStreamEnable) { if (dataStreamEnable) {
char fnametostream[MAX_STR_LENGTH]; char fnametostream[MAX_STR_LENGTH];
snprintf(fnametostream, MAX_STR_LENGTH, "%s/%s", filePath, fileName); snprintf(fnametostream, MAX_STR_LENGTH, "%s/%s", filePath, fileName);
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
(*it)->ResetParametersforNewMeasurement(fnametostream); (*it)->ResetParametersforNewMeasurement(fnametostream);
} }
} }
@ -785,15 +807,15 @@ int UDPStandardImplementation::SetupWriter() {
void UDPStandardImplementation::StartRunning() { void UDPStandardImplementation::StartRunning() {
//set running mask and post semaphore to start the inner loop in execution thread //set running mask and post semaphore to start the inner loop in execution thread
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) { for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) {
(*it)->StartRunning(); (*it)->StartRunning();
(*it)->Continue(); (*it)->Continue();
} }
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){ for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
(*it)->StartRunning(); (*it)->StartRunning();
(*it)->Continue(); (*it)->Continue();
} }
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){ for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
(*it)->StartRunning(); (*it)->StartRunning();
(*it)->Continue(); (*it)->Continue();
} }

View File

@ -16,7 +16,6 @@
#include <sys/wait.h> //wait #include <sys/wait.h> //wait
#include <unistd.h> //usleep #include <unistd.h> //usleep
#include <syscall.h> #include <syscall.h>
using namespace std;
bool keeprunning; bool keeprunning;
@ -44,18 +43,18 @@ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){
slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata; slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata;
slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader; slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader;
PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.xCoord, PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row,
"#### %d GetData: ####\n" "#### %d GetData: ####\n"
"frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu" "frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu"
"\t\ttimestamp: %llu\t\tmodId: %u\t\t" "\t\ttimestamp: %llu\t\tmodId: %u\t\t"
"xCoord: %u\t\tyCoord: %u\t\tzCoord: %u\t\tdebug: %u" "xCrow%u\t\tcolumn: %u\t\tcolumn: %u\t\tdebug: %u"
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u" "\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
//"\t\tpacketsMask:%s" //"\t\tpacketsMask:%s"
"\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", "\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
detectorHeader.xCoord, detectorHeader.frameNumber, detectorHeader.row, detectorHeader.frameNumber,
detectorHeader.expLength, detectorHeader.packetNumber, detectorHeader.bunchId, detectorHeader.expLength, detectorHeader.packetNumber, detectorHeader.bunchId,
detectorHeader.timestamp, detectorHeader.modId, detectorHeader.timestamp, detectorHeader.modId,
detectorHeader.xCoord, detectorHeader.yCoord, detectorHeader.zCoord, detectorHeader.row, detectorHeader.column, detectorHeader.column,
detectorHeader.debug, detectorHeader.roundRNumber, detectorHeader.debug, detectorHeader.roundRNumber,
detectorHeader.detType, detectorHeader.version, detectorHeader.detType, detectorHeader.version,
//header->packetsMask.to_string().c_str(), //header->packetsMask.to_string().c_str(),

View File

@ -14,7 +14,6 @@
#include "slsReceiver.h" #include "slsReceiver.h"
#include "gitInfoReceiver.h" #include "gitInfoReceiver.h"
using namespace std;
@ -22,9 +21,9 @@ slsReceiver::slsReceiver(int argc, char *argv[]):
tcpipInterface (0) { tcpipInterface (0) {
// options // options
map<string, string> configuration_map; std::map<std::string, std::string> configuration_map;
int tcpip_port_no = 1954; int tcpip_port_no = 1954;
string fname = ""; std::string fname = "";
int64_t tempval = 0; int64_t tempval = 0;
//parse command line for config //parse command line for config
@ -68,28 +67,28 @@ slsReceiver::slsReceiver(int argc, char *argv[]):
case 'v': case 'v':
tempval = GITREV; tempval = GITREV;
tempval = (tempval <<32) | GITDATE; tempval = (tempval <<32) | GITDATE;
cout << "SLS Receiver " << GITBRANCH << " (0x" << hex << tempval << ")" << endl; std::cout << "SLS Receiver " << GITBRANCH << " (0x" << std::hex << tempval << ")" << std::endl;
throw exception(); throw std::exception();
case 'h': case 'h':
default: default:
string help_message = "\n" std::string help_message = "\n"
+ string(argv[0]) + "\n" + std::string(argv[0]) + "\n"
+ "Usage: " + string(argv[0]) + " [arguments]\n" + "Usage: " + std::string(argv[0]) + " [arguments]\n"
+ "Possible arguments are:\n" + "Possible arguments are:\n"
+ "\t-f, --config <fname> : Loads config from file\n" + "\t-f, --config <fname> : Loads config from file\n"
+ "\t-t, --rx_tcpport <port> : TCP Communication Port with client. \n" + "\t-t, --rx_tcpport <port> : TCP Communication Port with client. \n"
+ "\t Default: 1954. Required for multiple \n" + "\t Default: 1954. Required for multiple \n"
+ "\t receivers\n\n"; + "\t receivers\n\n";
FILE_LOG(logINFO) << help_message << endl; FILE_LOG(logINFO) << help_message << std::endl;
throw exception(); throw std::exception();
} }
} }
if( !fname.empty() && read_config_file(fname, &tcpip_port_no, &configuration_map) == FAIL) { if( !fname.empty() && read_config_file(fname, &tcpip_port_no, &configuration_map) == FAIL) {
throw exception(); throw std::exception();
} }
// might throw an exception // might throw an exception

View File

@ -17,7 +17,7 @@
#include <fstream> #include <fstream>
#include <stdlib.h> #include <stdlib.h>
#include <syscall.h> #include <syscall.h>
using namespace std; #include <vector>
@ -140,7 +140,7 @@ void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){
void slsReceiverTCPIPInterface::startTCPServer(){ void slsReceiverTCPIPInterface::startTCPServer(){
cprintf(BLUE,"Created [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); cprintf(BLUE,"Created [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid));
FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber << endl; FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber << std::endl;
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
FILE_LOG(logDEBUG5) << "Starting Receiver TCP Server"; FILE_LOG(logDEBUG5) << "Starting Receiver TCP Server";
@ -206,7 +206,7 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) {
case F_GET_RECEIVER_ID: return "F_GET_RECEIVER_ID"; case F_GET_RECEIVER_ID: return "F_GET_RECEIVER_ID";
case F_GET_RECEIVER_TYPE: return "F_GET_RECEIVER_TYPE"; case F_GET_RECEIVER_TYPE: return "F_GET_RECEIVER_TYPE";
case F_SEND_RECEIVER_DETHOSTNAME: return "F_SEND_RECEIVER_DETHOSTNAME"; case F_SEND_RECEIVER_DETHOSTNAME: return "F_SEND_RECEIVER_DETHOSTNAME";
case F_RECEIVER_SHORT_FRAME: return "F_RECEIVER_SHORT_FRAME"; case F_RECEIVER_SET_ROI: return "F_RECEIVER_SET_ROI";
case F_SETUP_RECEIVER_UDP: return "F_SETUP_RECEIVER_UDP"; case F_SETUP_RECEIVER_UDP: return "F_SETUP_RECEIVER_UDP";
case F_SET_RECEIVER_TIMER: return "F_SET_RECEIVER_TIMER"; case F_SET_RECEIVER_TIMER: return "F_SET_RECEIVER_TIMER";
case F_SET_RECEIVER_DYNAMIC_RANGE: return "F_SET_RECEIVER_DYNAMIC_RANGE"; case F_SET_RECEIVER_DYNAMIC_RANGE: return "F_SET_RECEIVER_DYNAMIC_RANGE";
@ -263,7 +263,7 @@ int slsReceiverTCPIPInterface::function_table(){
flist[F_GET_RECEIVER_ID] = &slsReceiverTCPIPInterface::get_id; flist[F_GET_RECEIVER_ID] = &slsReceiverTCPIPInterface::get_id;
flist[F_GET_RECEIVER_TYPE] = &slsReceiverTCPIPInterface::set_detector_type; flist[F_GET_RECEIVER_TYPE] = &slsReceiverTCPIPInterface::set_detector_type;
flist[F_SEND_RECEIVER_DETHOSTNAME] = &slsReceiverTCPIPInterface::set_detector_hostname; flist[F_SEND_RECEIVER_DETHOSTNAME] = &slsReceiverTCPIPInterface::set_detector_hostname;
flist[F_RECEIVER_SHORT_FRAME] = &slsReceiverTCPIPInterface::set_short_frame; flist[F_RECEIVER_SET_ROI] = &slsReceiverTCPIPInterface::set_roi;
flist[F_SETUP_RECEIVER_UDP] = &slsReceiverTCPIPInterface::setup_udp; flist[F_SETUP_RECEIVER_UDP] = &slsReceiverTCPIPInterface::setup_udp;
flist[F_SET_RECEIVER_TIMER] = &slsReceiverTCPIPInterface::set_timer; flist[F_SET_RECEIVER_TIMER] = &slsReceiverTCPIPInterface::set_timer;
flist[F_SET_RECEIVER_DYNAMIC_RANGE] = &slsReceiverTCPIPInterface::set_dynamic_range; flist[F_SET_RECEIVER_DYNAMIC_RANGE] = &slsReceiverTCPIPInterface::set_dynamic_range;
@ -535,7 +535,7 @@ int slsReceiverTCPIPInterface::set_port() {
sprintf(mess,"Port Number (%d) too low\n", p_number); sprintf(mess,"Port Number (%d) too low\n", p_number);
FILE_LOG(logERROR) << mess; FILE_LOG(logERROR) << mess;
} else { } else {
FILE_LOG(logINFO) << "set port to " << p_number <<endl; FILE_LOG(logINFO) << "set port to " << p_number <<std::endl;
strcpy(oldLastClientIP, mySock->lastClientIP); strcpy(oldLastClientIP, mySock->lastClientIP);
try { try {
@ -879,16 +879,24 @@ int slsReceiverTCPIPInterface::set_detector_hostname() {
int slsReceiverTCPIPInterface::set_short_frame() { int slsReceiverTCPIPInterface::set_roi() {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
int index = 0; int nroi = 0;
int retval = -100;
// receive arguments // receive arguments
if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) if (mySock->ReceiveDataOnly(&nroi,sizeof(nroi)) < 0 )
return printSocketReadError(); return printSocketReadError();
std::vector <ROI> roiLimits;
int iloop = 0;
for (iloop = 0; iloop < nroi; iloop++) {
ROI temp;
if ( mySock->ReceiveDataOnly(&temp,sizeof(ROI)) < 0 )
return printSocketReadError();
roiLimits.push_back(temp);
}
//does not exist //does not exist
if (myDetectorType != GOTTHARD) if (myDetectorType != GOTTHARD)
functionNotImplemented(); functionNotImplemented();
@ -904,8 +912,8 @@ int slsReceiverTCPIPInterface::set_short_frame() {
else if (receiverBase->getStatus() != IDLE) else if (receiverBase->getStatus() != IDLE)
receiverNotIdle(); receiverNotIdle();
else { else {
receiverBase->setShortFrameEnable(index); ret = receiverBase->setROI(roiLimits);
retval = receiverBase->getShortFrameEnable(); //retval = receiverBase->getROI();
} }
#endif #endif
} }
@ -916,7 +924,8 @@ int slsReceiverTCPIPInterface::set_short_frame() {
mySock->SendDataOnly(&ret,sizeof(ret)); mySock->SendDataOnly(&ret,sizeof(ret));
if (ret == FAIL) if (ret == FAIL)
mySock->SendDataOnly(mess,sizeof(mess)); mySock->SendDataOnly(mess,sizeof(mess));
mySock->SendDataOnly(&retval,sizeof(retval));
roiLimits.clear();
// return ok/fail // return ok/fail
return ret; return ret;
@ -957,7 +966,7 @@ int slsReceiverTCPIPInterface::setup_udp(){
//setup udpip //setup udpip
//get ethernet interface or IP to listen to //get ethernet interface or IP to listen to
FILE_LOG(logINFO) << "Receiver UDP IP: " << args[0]; FILE_LOG(logINFO) << "Receiver UDP IP: " << args[0];
string temp = genericSocket::ipToName(args[0]); std::string temp = genericSocket::ipToName(args[0]);
if (temp == "none"){ if (temp == "none"){
ret = FAIL; ret = FAIL;
strcpy(mess, "Failed to get ethernet interface or IP\n"); strcpy(mess, "Failed to get ethernet interface or IP\n");

View File

@ -11,20 +11,19 @@
#include "logger.h" #include "logger.h"
using namespace std;
int read_config_file(string fname, int *tcpip_port_no, map<string, string> * configuration_map ){ int read_config_file(std::string fname, int *tcpip_port_no, std::map<std::string, std::string> * configuration_map ){
ifstream infile; std::ifstream infile;
string sLine,sargname, sargvalue; std::string sLine,sargname, sargvalue;
int iline = 0; int iline = 0;
int success = slsReceiverDefs::OK; int success = slsReceiverDefs::OK;
FILE_LOG(logINFO) << "config file name " << fname; FILE_LOG(logINFO) << "config file name " << fname;
try { try {
infile.open(fname.c_str(), ios_base::in); infile.open(fname.c_str(), std::ios_base::in);
} catch(...) { } catch(...) {
FILE_LOG(logERROR) << "Could not open configuration file " << fname ; FILE_LOG(logERROR) << "Could not open configuration file " << fname ;
success = slsReceiverDefs::FAIL; success = slsReceiverDefs::FAIL;
@ -37,14 +36,14 @@ int read_config_file(string fname, int *tcpip_port_no, map<string, string> * con
//VERBOSE_PRINT(sLine); //VERBOSE_PRINT(sLine);
if(sLine.find('#') != string::npos) if(sLine.find('#') != std::string::npos)
continue; continue;
else if(sLine.length()<2) else if(sLine.length()<2)
continue; continue;
else{ else{
istringstream sstr(sLine); std::istringstream sstr(sLine);
//parameter name //parameter name
if(sstr.good()){ if(sstr.good()){