refactor receiver client interface, moved defs into one sls_detector_defs.h

This commit is contained in:
maliakal_d 2018-10-11 12:25:18 +02:00
parent d0950ba001
commit 5a356534e6
56 changed files with 1155 additions and 2386 deletions

View File

@ -1,508 +0,0 @@
SLS Detector Package 4.0.0 released on 27.09.2018
=================================================
INTRODUCTION
This document describes the differences between 4.0.0 and 3.1.4 releases.
Download
--------
The Source Code (Default C++ API):
https://github.com/slsdetectorgroup/slsDetectorPackage
The Conda Lib Package:
https://github.com/slsdetectorgroup/sls_detector_lib
The Conda GUI Package:
https://github.com/slsdetectorgroup/sls_detector_gui
The Python Interface (including the package):
https://github.com/slsdetectorgroup/sls_detector
Documentation
-------------
Manual (HTML & PDF):
https://www.psi.ch/detectors/documentation
slsDetectorPackage/manual/docs/
Command Line Documentation:
manual/docs/html/slsDetectorClientDocs/index.html
manual/docs/pdf/slsDetectorClientDocs.pdf
C++ API Documentation:
manual/docs/html/slsDetectorUsersDocs/index.html
manual/docs/pdf/slsDetectorUsersDocs.pdf
C++ API Example:
manual/manual-api/mainClient.cpp
manual/manual-api/mainReceiver.cpp
Python API Documentation:
https://slsdetectorgroup.github.io/sls_detector/
Further Documentation:
https://www.psi.ch/detectors/users-support
Support
-------
General Software related:
dhanya.thattil@psi.ch
anna.bergamaschi@psi.ch
Python related:
erik.frojdh@psi.ch
CONTENTS
1. Firmware Requirements
2. Changes in User Interface
3. New/Modified Commands
4. Other New Features
5. Resolved Issues
6. Known Issues
7. Next Major Release Plans
1. Firmware Requirements
========================
Gotthard
========
Minimum compatible version : 11.01.2013
Latest version : 08.02.2018 (50um and 25um Master)
09.02.2018 (25 um Slave)
Eiger
=====
Minimum compatible version : 22
Latest version : 22
Jungfrau
========
Minimum compatible version : 15.06.2018
Latest version : 15.06.2018
Detector Upgrade
================
Gotthard Cannot be upgraded remotely. Requires programming via USB blaster
Eiger Can be upgraded remotely via bit files
Jungfrau Can be upgraded remotely using sls_detector_put programfpga <pof>
Instructions available at
https://www.psi.ch/detectors/installation-instructions
under Detector Upgrade -> [Detector Type] -> Firmware.
Please refer to the link below for more details on the firmware versions.
https://www.psi.ch/detectors/firmware.
2. Changes in User Interface
============================
Client
------
1. Shared Memory:
POSIX shared memory has been implemented and they are typically created in
/dev/shm/ folder.
A multiSlsDetector object will create a shared memory segment with naming style:
slsDetectorPackage_x_[_z]
and an slsDetector object will create a shared memory segment with naming style:
slsDetectorPackage_x_sls_y[_z]
where
x is the multi detector id
y is the sls detector id
z is the environment variable SLSDETNAME, if set.
They can be deleted directly.
Environment variable SLSDETNAME included for user-friendliness
of using 2 different detectors from the same client pc. One needn't use
different multi detector id if the SLSDETNAME is different for both consoles.
Constructor will fail if shared memory size is different (different package
releases/detectors). Loading config file cleans shared memory.
2. Exceptions in constructors:
All constructors that have an error throws an exception. For this release,
this is caught within the package and interfaced as error codes or messages
to the users using command line or API.
As a result:
- slsDetectorsUsers constructor signature now includes a success flag.
- If one uses multiSlsDetector, slsDetector, ZmqSocket classes directly,
catch exceptions from constructors.
- In future releases, the exception will be thrown
outside the package for the users to handle it.
3. API Compatibility:
Client now checks API version of Detector Server - Client and Receiver - Client
when connecting for the first time to detector server or receiver server
and the online flags have not been set in shm.
Upon failure, error messages will ensue and further commands will not
be executed. Detector servers referred to are only for Eiger, Jungfrau and Gotthard.
Previously, the detector server would exit on mismatched Firmware-Detector
server mismatch. They now wait for client to ask for compatibility check,
which is done the first time client connects to the detector and the
online flag in shm has not been set.
4. Commands "type", "id" and "replace" are removed.
Receiver
--------
1. Reciever Header Structure in file writing and call back:
sls_receiver_header structure added to sls_receiver_defs.h for image headers
in file writing.
#define MAX_NUM_PACKETS 512
typedef std::bitset<MAX_NUM_PACKETS> sls_bitset;
typedef struct {
sls_detector_header detHeader; /**< is the detector header */
sls_bitset packetsMask; /**< is the packets caught bit mask */
} sls_receiver_header;
It includes the detector header structure + bitmask of 512 bits,
where each bit represents a packet caught. This is useful in saving time
in writing to file by not padding missing packets and still retaining useful data.
The binary and HDF5 writer version number changed from 1.0 to 2.0.
The detector header version remains as 1.0.
registerCallBackRawDataReady modified to give this structure pointer,
instead of individual structure member pointers.
2. ZmqSocket class:
If one uses ZmqSocket.h, then the json header has to be parsed outside
the class to allow the user to remove the restriction in extracting all data
from the json header.
3. Receiver Call back with modified size:
registerCallBackRawDataModifyReady call back that is similar to the receiver
registerCallBackRawDataReady has been added to allow the call back to
specify an updated size of image after call back. This is in view to process
an image in call back (including extract only a region of the image) and
provide this updated size in callback. This new resized/processed image
will be written to file or streamed out via zmq. This is useful in ROI
selection in the receiver.
This also means that the call back is now called before writing to file.
3. New/Modified Commands
========================
Client
------
1. add (modified):
appends detector to end of multi detector list.
2. replace:
sets hostname/ip address for a single detector.
3. user:
get user details from shared memory.
4. checkdetversion:
checks client version compatibility with detector server.
5. checkrecversion:
checks client version compatibility with receiver server.
Receiver
--------
1. rx_zmqip:
sets/gets the zmq (TCP) ip of the receiver from where data is streamed
out from. (Eg. to the gui or intermediate process). By default, it is
the same as the zmqip.
2. zmqip:
sets/gets the zmq (TCP) ip, where client listens to, to reconstuct images.
(Eg. from receiver or intermediate process). By default, it is the same
as rx_zmqip.
3. rx_jsonaddheader:
sets/gets additional json header to be streamed out with the zmq from
receiver. Default is empty. Eg. p rx_jsonaddheader \"what\":\"nothing\"
4. r_discardpolicy:
sets/gets the frame discard policy in the receiver.
nodiscard - no discard (default),
discardempty - discard only empty frames,
discardpartial - discard any partial frame(fastest)
5. r_padding:
sets/gets the frame padding in the receiver.
0 does not pad partial frames(fastest),
1 (default) pads partial frames.
One can look at bitmask in the sls_receiver_header to process the unpadded
partial frames later.
6. activate (modified):
Extra option added to pad or unpad images in receivers when deactivated.
activate i [padding option], where i is activate/deactivate and padding
option is "padding" (default) or "nopadding".
7. rx_udpsocksize:
sets/gets the UDP socket buffer size. Already attempts to set by default
to 100mb, 2gb for Jungfrau. Does not remember custom values in client
shared memory, so must be initialized each time after setting receiver
hostname in config file.
8. rx_realudpsocksize:
gets the actual UDP socket buffer size. Usually double the set udp socket
buffer size due to kernel bookkeeping.
9. r_framesperfile:
sets/gets the frames per file in receiver. 0 means infinite or all frames
in a single file. Default of Eiger changed from 2k to 10k.
Eiger Specific
--------------
1. status trigger:
To trigger internally via software, one can use "status trigger".
2. subdeadtime:
sets/gets sub frame dead time in s in 32 bit mode. Subperiod is set in
the detector by subexptime + subdeadtime. This value is normally a
constant set by an expert catered to individual detector modules in the
config file. Receiver files writes master file metadata subperiod
instead of subdeadtime.
3. gappixels:
enables/disables gap pixels in system (detector & receiver). 1 sets,
0 unsets. In Receiver, 4 bit gap pixels mode is not implemented, but is
implemented in client data call back. Gap pixels are at module level
and not at multi module level.
4. measuredperiod:
gets the measured frame period (time between last frame and the previous
one) in s. Makes sense only for acquisitions of more than 1 frame.
5. measuredsubperiod:
gets the measured subframe period (time between last subframe and the
previous one) in s in 32 bit mode.
6. flags(modified):
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
there was any saturation in any of the sub images 32 bit mode.
Jungfrau Specific
-----------------
1. storagecells:
sets/gets number of additional storage cells per acquisition. For very
advanced users only. Range: 0-15. Default: 0.
The #images = #frames * #cycles * (#storagecells +1).
2. storage_start:
sets/gets the storage cell that stores the first acquisition of the series.
For very advanced users only. Range: 0-15. Default: 15(0xf).
4. Other New Features
=====================
Client
------
1. (Jungfrau & Gotthard) Settingsdir and caldir is removed from config file.
Default dacs are stored in detector server. Hence, these folders
are also removed from slsDetectorPackage/settingsdir. Eiger and Mythen
continue to have them.
2. Depending on 1d position of detectors and detsizechan in config file,
row and column (previously xcoord and ycoord) are given to detector
servers (Eiger and Jungfrau) to encode into the udp header.
3. (Eiger) Setting threshold energy changes such as CAL dac is irrelevant
when interpolating between two energies and VRS dac is interpolated, not copied.
4. Users API updated with the following functions:
- setReceiverFramesDiscardPolicy
- setReceiverPartialFramesPadding
- setReceiverFramesPerFile
- sendSoftwareTrigger
- setSubFrameExposureDeadTime
- setSubFrameExposureTime
- enableGapPixels
- getMeasuredPeriod
- getMeasuredSubFramePeriod
- setOverflowMode
- setNumberOfStorageCells
- setStoragecellStart
- setThresholdEnergy (overloaded)
- resetFramesCaughtInReceiver
- setReceiverFifoDepth
- setFlowControl10G
- setTenGigabitEthernet
- getNMods
- setReceiverDataStreamingOutIP
- setClientDataStreamingInIP
SlsReceiver
-----------
1. slsMultiReceiver executable added that creates multiple receiver child processes.
./slsMultiReceiver [start_tcp_port] [num_receivers] [1 for call back, 0 for none]
2. Default row and column (previously xcoord and ycoord) are hardcoded
for missing packets. (Eiger and Jungfrau)
Gui
---
1. (Jungfrau) Gain plot included. Option under 2D options in Plot tab.
2. Option to maintain aspect ratio
3. Start and Stop separated to prevent multiple click syndrome.
Detector Server
---------------
1. (Jungfrau) To use programfpga command, one must start server with -update
mode and then restart server without -update mode.
2. (Jungfrau) ASIC Timer configured at server start up and changed a few
startup values for firmware v0.7 such as adc phase, ADC_PORT_INVERT_VAL
and ADC offset half speed value.
3. (Jungfrau) Minimum exposure time of 50 us was implemented.
4. (Eiger and Jungfrau) They can be configured to have x and y coord values
of the detector in their udp header.
5. Resolved Issues
==================
Client
------
memory leak for multi threading
1. Compiler flag -std=c++98 enforced. Debug flag removed.
2. If trimen gives different list from different detectors, it returns a -1.
3. Version format for each submodule of the package changed to just date YYMMDD.
Users class fixed to give correct version, instead of -1.
4. Getting settings in users class gave -1. Fixed now.
5. (Jungfrau) Programming FPGA now creates the rawbin file from pof in tmp
rather than source file location (for permission issues).
6. (Gotthard) ROI segmentation fault fixed.
Receiver
--------
1. Silent feature of receiver fixed.
2. Socket descriptor misused earlier for success flag, instead exceptions
used that are handled inside the package.
3. Global optind variable initialized to instantiate multiple receivers
in same process. Also removed static members to enable this feature.
4. Socket buffer size attempts to set for each acquiistion and provide
warning if no capabilities. Warnings can be removed using instruction with
error provided. Default Jungfrau UDP socket buffer size if 2 GB, default is
100 MB.
5. Refactored code a bit for performance and robustness, blocking push
in buffer between listener and dataprocessor
Detector Server
---------------
1. (Jungfrau) Stop server also mapped during a reset. Reading power status
instead of user input register for power.
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.
6. Known Issues
===============
Receiver
--------
1. HDF5 compression and filters are not implemented yet.
Detector Server
---------------
1. (Eiger) Registers mapped differently between firmware v20 and v22.
So, please ensure correct on-board server before switching between
firmware versions. Else one cannot ping it anymore. Will need to flash firmware
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.
7. Next Major Release Plans
===========================
Client
------
1. Exceptions thrown to the user to be handled.
2. Compilation using c++11.
3. Support of Mythen II restricted to this major and its minor releases.
4. Restructuring and refactoring of client code.

View File

@ -16,7 +16,7 @@ It is linked in manual/manual-api from slsReceiverSoftware/include ]
*/ */
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include "slsReceiverUsers.h" #include "slsReceiverUsers.h"
#include <iostream> #include <iostream>
@ -96,8 +96,8 @@ void AcquisitionFinished(uint64_t frames, void*p){
* @param p pointer to object * @param p pointer to object
*/ */
void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){
slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata; slsDetectorDefs::sls_receiver_header* header = (slsDetectorDefs::sls_receiver_header*)metadata;
slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader; slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row, PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row,
"#### %d GetData: ####\n" "#### %d GetData: ####\n"
@ -130,8 +130,8 @@ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){
* @param p pointer to object * @param p pointer to object
*/ */
void GetData(char* metadata, char* datapointer, uint32_t &revDatasize, void* p){ void GetData(char* metadata, char* datapointer, uint32_t &revDatasize, void* p){
slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata; slsDetectorDefs::sls_receiver_header* header = (slsDetectorDefs::sls_receiver_header*)metadata;
slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader; slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row, PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row,
"#### %d GetData: ####\n" "#### %d GetData: ####\n"
@ -221,10 +221,10 @@ int main(int argc, char *argv[]) {
char temp[10]; char temp[10];
sprintf(temp,"%d",startTCPPort + i); sprintf(temp,"%d",startTCPPort + i);
char* args[] = {(char*)"ignored", (char*)"--rx_tcpport", temp}; char* args[] = {(char*)"ignored", (char*)"--rx_tcpport", temp};
int ret = slsReceiverDefs::OK; int ret = slsDetectorDefs::OK;
/** - create slsReceiverUsers object with appropriate arguments */ /** - create slsReceiverUsers object with appropriate arguments */
slsReceiverUsers *receiver = new slsReceiverUsers(3, args, ret); slsReceiverUsers *receiver = new slsReceiverUsers(3, args, ret);
if(ret==slsReceiverDefs::FAIL){ if(ret==slsDetectorDefs::FAIL){
delete receiver; delete receiver;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -251,7 +251,7 @@ int main(int argc, char *argv[]) {
/** - start tcp server thread */ /** - start tcp server thread */
if (receiver->start() == slsReceiverDefs::FAIL){ if (receiver->start() == slsDetectorDefs::FAIL){
delete receiver; delete receiver;
cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

View File

@ -2,12 +2,10 @@ CC = g++
CLAGS += -DVERBOSE #VERYBOSE CLAGS += -DVERBOSE #VERYBOSE
LDLIBS += -lm -lstdc++ -pthread LDLIBS += -lm -lstdc++ -pthread
LDIR = ../../slsDetectorSoftware
RDIR = ../../slsReceiverSoftware
DDIR = ../../bin DDIR = ../../bin
INCLUDES = -I ../../slsSupportLib/include -I $(LDIR)/slsDetector -I ../include -I $(RDIR)/include INCLUDES = -I ../../slsSupportLib/include -I ../include
SRC_CLNT = qClient.cpp SRC_CLNT = qClient.cpp
DEPSINCLUDES= qClient.h $(RDIR)/include/MySocketTCP.h $(LDIR)/slsDetector/slsDetectorBase.h ../../slsSupportLib/include/sls_detector_defs.h DEPSINCLUDES= qClient.h ../../slsSupportLib/include/MySocketTCP.h ../../slsSupportLib/include/sls_detector_defs.h
all: client all: client

View File

@ -8,7 +8,6 @@
#include "qClient.h" #include "qClient.h"
// Project Class Headers // Project Class Headers
#include "MySocketTCP.h" #include "MySocketTCP.h"
#include "slsDetectorBase.h"
// C++ Include Headers // C++ Include Headers
#include <iostream> #include <iostream>
@ -166,7 +165,7 @@ string qClient::getStatus(){
sprintf(answer,"%d%% ",progress); sprintf(answer,"%d%% ",progress);
strcat(answer,slsDetectorBase::runStatusType((runStatus)retval).c_str()); strcat(answer,slsDetectorDefs::runStatusType((runStatus)retval).c_str());
return string(answer); return string(answer);
} }

View File

@ -146,7 +146,6 @@ HEADERS = \
include/qTabMessages.h\ include/qTabMessages.h\
include/gitInfoGui.h\ include/gitInfoGui.h\
../slsSupportLib/include/sls_detector_defs.h\ ../slsSupportLib/include/sls_detector_defs.h\
../slsReceiverSoftware/include/sls_receiver_defs.h\
include/qServer.h include/qServer.h

View File

@ -291,7 +291,7 @@ void qDetectorMain::SetUpDetector(const string fName){
actionLoadTrimbits->setText("Load Settings"); actionSaveTrimbits->setText("Save Settings"); actionLoadTrimbits->setText("Load Settings"); actionSaveTrimbits->setText("Save Settings");
break; break;
default: default:
string detName = myDet->slsDetectorBase::getDetectorType(detType); string detName = myDet->slsDetectorDefs::getDetectorType(detType);
qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector"); qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector");
cout << "ERROR: " + host + " has unknown detector type \"" + detName + "\". Exiting GUI." << endl; cout << "ERROR: " + host + " has unknown detector type \"" + detName + "\". Exiting GUI." << endl;
string errorMess = host+string(" has unknown detector type \"")+ string errorMess = host+string(" has unknown detector type \"")+
@ -300,9 +300,9 @@ void qDetectorMain::SetUpDetector(const string fName){
exit(-1); exit(-1);
} }
setWindowTitle("SLS Detector GUI : "+ setWindowTitle("SLS Detector GUI : "+
QString(slsDetectorBase::getDetectorType(detType).c_str())+ " - "+QString(host.c_str())); QString(slsDetectorDefs::getDetectorType(detType).c_str())+ " - "+QString(host.c_str()));
//#ifdef VERBOSE //#ifdef VERBOSE
cout << endl << "Type : " << slsDetectorBase::getDetectorType(detType) << "\nDetector : " << host << endl; cout << endl << "Type : " << slsDetectorDefs::getDetectorType(detType) << "\nDetector : " << host << endl;
//#endif //#endif
myDet->setOnline(slsDetectorDefs::ONLINE_FLAG); myDet->setOnline(slsDetectorDefs::ONLINE_FLAG);
if(detType != slsDetectorDefs::MYTHEN) if(detType != slsDetectorDefs::MYTHEN)

View File

@ -1300,7 +1300,7 @@ int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){
#ifdef VERBOSE #ifdef VERBOSE
cout << "\nEntering Acquisition Finished with status " ; cout << "\nEntering Acquisition Finished with status " ;
#endif #endif
QString status = QString(slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str()); QString status = QString(slsDetectorDefs::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str());
#ifdef VERBOSE #ifdef VERBOSE
cout << status.toAscii().constData() << " and progress " << currentProgress << endl; cout << status.toAscii().constData() << " and progress " << currentProgress << endl;
#endif #endif

View File

@ -222,7 +222,7 @@ void qTabAdvanced::SetupWidgetWindow(){
#endif #endif
// jungfrau // jungfrau
if (detType == slsReceiverDefs::JUNGFRAU) { if (detType == slsDetectorDefs::JUNGFRAU) {
lblNumStoragecells->setEnabled(true); lblNumStoragecells->setEnabled(true);
spinNumStoragecells->setEnabled(true); spinNumStoragecells->setEnabled(true);
spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1));
@ -327,7 +327,7 @@ void qTabAdvanced::Initialization(){
connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(setROI())); connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(setROI()));
} }
if(detType == slsReceiverDefs::JUNGFRAU) { if(detType == slsDetectorDefs::JUNGFRAU) {
connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int)));
} else if (detType == slsDetectorDefs::EIGER) { } else if (detType == slsDetectorDefs::EIGER) {
//Exposure Time //Exposure Time
@ -1581,14 +1581,14 @@ void qTabAdvanced::Refresh(){
updateAllTrimbitsFromServer(); updateAllTrimbitsFromServer();
// storage cells // storage cells
if (detType == slsReceiverDefs::JUNGFRAU) { if (detType == slsDetectorDefs::JUNGFRAU) {
disconnect(spinNumStoragecells,SIGNAL(valueChanged(int)),this, SLOT(SetNumStoragecells(int))); disconnect(spinNumStoragecells,SIGNAL(valueChanged(int)),this, SLOT(SetNumStoragecells(int)));
spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1));
connect(spinNumStoragecells,SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); connect(spinNumStoragecells,SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int)));
} }
// sub exptime and sub period // sub exptime and sub period
else if (detType == slsReceiverDefs::EIGER) { else if (detType == slsDetectorDefs::EIGER) {
disconnect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); disconnect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime()));
disconnect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubExposureTime())); disconnect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubExposureTime()));
disconnect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod())); disconnect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod()));

View File

@ -878,19 +878,19 @@ void qTabDataOutput::SetupFileFormat(){
//To be able to index items on a combo box //To be able to index items on a combo box
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(comboFileFormat->model()); QStandardItemModel* model = qobject_cast<QStandardItemModel*>(comboFileFormat->model());
QModelIndex index[slsReceiverDefs::NUM_FILE_FORMATS]; QModelIndex index[slsDetectorDefs::NUM_FILE_FORMATS];
QStandardItem* item[slsReceiverDefs::NUM_FILE_FORMATS]; QStandardItem* item[slsDetectorDefs::NUM_FILE_FORMATS];
if (model) { if (model) {
for(int i=0;i<slsReceiverDefs::NUM_FILE_FORMATS;i++){ for(int i=0;i<slsDetectorDefs::NUM_FILE_FORMATS;i++){
index[i] = model->index(i, comboFileFormat->modelColumn(), comboFileFormat->rootModelIndex()); index[i] = model->index(i, comboFileFormat->modelColumn(), comboFileFormat->rootModelIndex());
item[i] = model->itemFromIndex(index[i]); item[i] = model->itemFromIndex(index[i]);
} }
//Enabling/Disabling depending on the detector type //Enabling/Disabling depending on the detector type
switch(detType){ switch(detType){
case slsDetectorDefs::MYTHEN: case slsDetectorDefs::MYTHEN:
item[(int)slsReceiverDefs::BINARY]->setEnabled(false); item[(int)slsDetectorDefs::BINARY]->setEnabled(false);
item[(int)slsReceiverDefs::ASCII]->setEnabled(true); item[(int)slsDetectorDefs::ASCII]->setEnabled(true);
item[(int)slsReceiverDefs::HDF5]->setEnabled(false); item[(int)slsDetectorDefs::HDF5]->setEnabled(false);
break; break;
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
@ -898,9 +898,9 @@ void qTabDataOutput::SetupFileFormat(){
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::JUNGFRAUCTB: case slsDetectorDefs::JUNGFRAUCTB:
item[(int)slsReceiverDefs::BINARY]->setEnabled(true); item[(int)slsDetectorDefs::BINARY]->setEnabled(true);
item[(int)slsReceiverDefs::ASCII]->setEnabled(false); item[(int)slsDetectorDefs::ASCII]->setEnabled(false);
item[(int)slsReceiverDefs::HDF5]->setEnabled(true); item[(int)slsDetectorDefs::HDF5]->setEnabled(true);
break; break;
default: default:
cout << "Unknown detector type " << endl; cout << "Unknown detector type " << endl;
@ -938,7 +938,7 @@ void qTabDataOutput::SetFileFormat(int format){
#endif #endif
disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int)));
int ret = (int)myDet->setFileFormat((slsReceiverDefs::fileFormat)comboFileFormat->currentIndex()); int ret = (int)myDet->setFileFormat((slsDetectorDefs::fileFormat)comboFileFormat->currentIndex());
if (ret != comboFileFormat->currentIndex()) { if (ret != comboFileFormat->currentIndex()) {
qDefs::Message(qDefs::WARNING,"Could not set file format.","qTabDataOutput::SetFileFormat"); qDefs::Message(qDefs::WARNING,"Could not set file format.","qTabDataOutput::SetFileFormat");
comboFileFormat->setCurrentIndex((int)ret); comboFileFormat->setCurrentIndex((int)ret);

View File

@ -165,7 +165,7 @@ void qTabDebugging::UpdateStatus(){
det = myDet->getSlsDetector(comboDetector->currentIndex()); det = myDet->getSlsDetector(comboDetector->currentIndex());
qDefs::checkErrorMessage(myDet,"qTabDebugging::UpdateStatus"); qDefs::checkErrorMessage(myDet,"qTabDebugging::UpdateStatus");
int detStatus = (int)det->getRunStatus(); int detStatus = (int)det->getRunStatus();
string status = slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detStatus)); string status = slsDetectorDefs::runStatusType(slsDetectorDefs::runStatus(detStatus));
lblStatus->setText(QString(status.c_str()).toUpper()); lblStatus->setText(QString(status.c_str()).toUpper());
qDefs::checkErrorMessage(det,"qTabDebugging::UpdateStatus"); qDefs::checkErrorMessage(det,"qTabDebugging::UpdateStatus");

View File

@ -165,8 +165,8 @@ void qTabDeveloper::SetupWidgetWindow() {
break; break;
default: default:
cout << "ERROR: Unknown detector type: " + myDet->slsDetectorBase::getDetectorType(detType) << endl; cout << "ERROR: Unknown detector type: " + myDet->slsDetectorDefs::getDetectorType(detType) << endl;
qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorBase::getDetectorType(detType),"qTabDeveloper::SetupWidgetWindow"); qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorDefs::getDetectorType(detType),"qTabDeveloper::SetupWidgetWindow");
exit(-1); exit(-1);
break; break;
} }
@ -493,8 +493,8 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index){
} }
break; break;
default: default:
cout << "Unknown detector type:" + myDet->slsDetectorBase::getDetectorType(detType) << endl; cout << "Unknown detector type:" + myDet->slsDetectorDefs::getDetectorType(detType) << endl;
qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorBase::getDetectorType(detType),"qTabDeveloper::getSLSIndex"); qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorDefs::getDetectorType(detType),"qTabDeveloper::getSLSIndex");
qDefs::checkErrorMessage(myDet,"qTabDeveloper::getSLSIndex"); qDefs::checkErrorMessage(myDet,"qTabDeveloper::getSLSIndex");
exit(-1); exit(-1);
break; break;

View File

@ -634,7 +634,7 @@ void qTabMeasurement::SetTimingMode(int mode){
spinNumTriggers->setValue(1); spinNumTriggers->setValue(1);
spinNumFrames->setValue(1); spinNumFrames->setValue(1);
if (detType == slsDetectorDefs::JUNGFRAU) if (detType == slsDetectorDefs::JUNGFRAU)
myDet->setTimer(slsReceiverDefs::STORAGE_CELL_NUMBER, 0); myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, 0);
if(myDet->setExternalCommunicationMode(slsDetectorDefs::AUTO_TIMING)==slsDetectorDefs::AUTO_TIMING) if(myDet->setExternalCommunicationMode(slsDetectorDefs::AUTO_TIMING)==slsDetectorDefs::AUTO_TIMING)
success = true; success = true;
break; break;
@ -713,7 +713,7 @@ void qTabMeasurement::SetTimingMode(int mode){
"Number of Frames \t: 1\nNumber of Triggers \t: 1","qTabMeasurement::SetTimingMode"); "Number of Frames \t: 1\nNumber of Triggers \t: 1","qTabMeasurement::SetTimingMode");
spinNumFrames->setValue(1); spinNumFrames->setValue(1);
spinNumTriggers->setValue(1); spinNumTriggers->setValue(1);
if (detType == slsReceiverDefs::JUNGFRAU) if (detType == slsDetectorDefs::JUNGFRAU)
myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, 0); myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, 0);
comboTimingMode->setCurrentIndex((int)None); comboTimingMode->setCurrentIndex((int)None);
return; return;

View File

@ -38,7 +38,7 @@ void qTabSettings::SetupWidgetWindow(){
detType=myDet->getDetectorsType(); detType=myDet->getDetectorsType();
// Settings // Settings
if (detType != slsReceiverDefs::JUNGFRAUCTB) { if (detType != slsDetectorDefs::JUNGFRAUCTB) {
SetupDetectorSettings(); SetupDetectorSettings();
} else } else
comboSettings->setEnabled(false); comboSettings->setEnabled(false);
@ -210,7 +210,7 @@ void qTabSettings::SetupDetectorSettings(){
void qTabSettings::Initialization(){ void qTabSettings::Initialization(){
// Settings // Settings
if (detType != slsReceiverDefs::JUNGFRAUCTB) if (detType != slsDetectorDefs::JUNGFRAUCTB)
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int)));
// Number of Modules // Number of Modules
connect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); connect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int)));
@ -238,7 +238,7 @@ void qTabSettings::setSettings(int index){
else{ else{
slsDetectorDefs::detectorSettings sett = myDet->setSettings((slsDetectorDefs::detectorSettings)index); slsDetectorDefs::detectorSettings sett = myDet->setSettings((slsDetectorDefs::detectorSettings)index);
#ifdef VERBOSE #ifdef VERBOSE
cout << endl << "Settings have been set to " << myDet->slsDetectorBase::getDetectorSettings(sett) << endl; cout << endl << "Settings have been set to " << myDet->slsDetectorDefs::getDetectorSettings(sett) << endl;
#endif #endif
//threshold //threshold
@ -322,7 +322,7 @@ void qTabSettings::Refresh(){
cout << endl << "**Updating Settings Tab" << endl; cout << endl << "**Updating Settings Tab" << endl;
#endif #endif
if (detType != slsReceiverDefs::JUNGFRAUCTB) if (detType != slsDetectorDefs::JUNGFRAUCTB)
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int)));
disconnect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); disconnect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int)));
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
@ -342,7 +342,7 @@ void qTabSettings::Refresh(){
GetDynamicRange(); GetDynamicRange();
// Settings // Settings
if (detType != slsReceiverDefs::JUNGFRAUCTB) { if (detType != slsDetectorDefs::JUNGFRAUCTB) {
#ifdef VERBOSE #ifdef VERBOSE
cout << "Getting settings" << endl; cout << "Getting settings" << endl;
#endif #endif
@ -369,7 +369,7 @@ void qTabSettings::Refresh(){
} }
} }
if (detType != slsReceiverDefs::JUNGFRAUCTB) if (detType != slsDetectorDefs::JUNGFRAUCTB)
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int)));
connect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); connect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int)));
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));

View File

@ -46,7 +46,6 @@ set(PUBLICHEADERS
../slsSupportLib/include/container_utils.h ../slsSupportLib/include/container_utils.h
sharedMemory/SharedMemory.h sharedMemory/SharedMemory.h
slsDetector/slsDetector.h slsDetector/slsDetector.h
slsDetector/slsDetectorBase.h
slsDetector/slsDetectorUsers.h slsDetector/slsDetectorUsers.h
slsDetector/detectorData.h slsDetector/detectorData.h
multiSlsDetector/multiSlsDetector.h multiSlsDetector/multiSlsDetector.h

View File

@ -17,7 +17,7 @@ LIBZMQDIR = ../slsSupportLib/include
LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq
SRC_CLNT= slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp ../slsSupportLib/include/ReceiverInterface.cpp slsDetector/slsDetectorUsers.cpp sharedMemory/SharedMemory.cpp ../slsSupportLib/include/utilities.cpp SRC_CLNT= slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp ../slsSupportLib/include/ReceiverInterface.cpp slsDetector/slsDetectorUsers.cpp sharedMemory/SharedMemory.cpp ../slsSupportLib/include/utilities.cpp
DEPSINCLUDES = ../slsSupportLib/include/sls_receiver_defs.h ../slsSupportLib/include/sls_receiver_funcs.h ../slsSupportLib/include/ansi.h ../slsSupportLib/include/sls_detector_defs.h ../slsSupportLib/include/sls_detector_funcs.h ../slsSupportLib/include/error_defs.h slsDetector/slsDetectorBase.h slsDetector/detectorData.h sharedMemory/SharedMemory.h ../slsSupportLib/include/sls_receiver_exceptions.h ../slsSupportLib/include/versionAPI.h ../slsSupportLib/include/utilities.h ../slsSupportLib/include/container_utils.h DEPSINCLUDES = ../slsSupportLib/include/sls_receiver_funcs.h ../slsSupportLib/include/ansi.h ../slsSupportLib/include/sls_detector_defs.h ../slsSupportLib/include/sls_detector_funcs.h ../slsSupportLib/include/error_defs.h slsDetector/detectorData.h sharedMemory/SharedMemory.h ../slsSupportLib/include/sls_receiver_exceptions.h ../slsSupportLib/include/versionAPI.h ../slsSupportLib/include/utilities.h ../slsSupportLib/include/container_utils.h

View File

@ -88,14 +88,12 @@ INPUT = ../slsSupportLib/include/communication_funcs.h \
../slsSupportLib/include/genericSocket.h \ ../slsSupportLib/include/genericSocket.h \
../slsSupportLib/include/logger.h \ ../slsSupportLib/include/logger.h \
../slsSupportLib/include/MySocketTCP.h \ ../slsSupportLib/include/MySocketTCP.h \
../slsSupportLib/include/sls_receiver_defs.h \
../slsSupportLib/include/sls_receiver_funcs.h \ ../slsSupportLib/include/sls_receiver_funcs.h \
../slsSupportLib/include/utilities.h \ ../slsSupportLib/include/utilities.h \
../slsSupportLib/include/ZmqSocket.h \ ../slsSupportLib/include/ZmqSocket.h \
multiSlsDetector/multiSlsDetectorClient.h \ multiSlsDetector/multiSlsDetectorClient.h \
multiSlsDetector/multiSlsDetectorCommand.h \ multiSlsDetector/multiSlsDetectorCommand.h \
multiSlsDetector/multiSlsDetector.h \ multiSlsDetector/multiSlsDetector.h \
slsDetector/slsDetectorBase.h \
slsDetector/slsDetectorCommand.h \ slsDetector/slsDetectorCommand.h \
slsDetector/slsDetector.h \ slsDetector/slsDetector.h \
slsDetector/slsDetectorUsers.h \ slsDetector/slsDetectorUsers.h \

View File

@ -2766,7 +2766,7 @@ int multiSlsDetector::setReceiverFramesPerFile(int f, int detPos) {
} }
slsReceiverDefs::frameDiscardPolicy multiSlsDetector::setReceiverFramesDiscardPolicy( slsDetectorDefs::frameDiscardPolicy multiSlsDetector::setReceiverFramesDiscardPolicy(
frameDiscardPolicy f, int detPos) { frameDiscardPolicy f, int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
@ -2791,7 +2791,7 @@ int multiSlsDetector::setReceiverPartialFramesPadding(int f, int detPos) {
} }
slsReceiverDefs::fileFormat multiSlsDetector::getFileFormat(int detPos) { slsDetectorDefs::fileFormat multiSlsDetector::getFileFormat(int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
return detectors[detPos]->getFileFormat(); return detectors[detPos]->getFileFormat();
@ -2803,7 +2803,7 @@ slsReceiverDefs::fileFormat multiSlsDetector::getFileFormat(int detPos) {
} }
slsReceiverDefs::fileFormat multiSlsDetector::setFileFormat(fileFormat f, int detPos) { slsDetectorDefs::fileFormat multiSlsDetector::setFileFormat(fileFormat f, int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
return detectors[detPos]->setFileFormat(f); return detectors[detPos]->setFileFormat(f);

View File

@ -7,7 +7,8 @@
* @author Anna Bergamaschi * @author Anna Bergamaschi
*/ */
#include "slsDetectorBase.h" #include "sls_detector_defs.h"
#include "error_defs.h"
class slsDetector; class slsDetector;
class SharedMemory; class SharedMemory;
@ -24,7 +25,7 @@ class detectorData;
#define SHORT_STRING_LENGTH 50 #define SHORT_STRING_LENGTH 50
#define DATE_LENGTH 30 #define DATE_LENGTH 30
class multiSlsDetector : public slsDetectorBase { class multiSlsDetector : public virtual slsDetectorDefs, public virtual errorDefs {
private: private:
@ -294,7 +295,7 @@ public:
void addMultipleDetectors(const char* name); void addMultipleDetectors(const char* name);
using slsDetectorBase::getDetectorType; using slsDetectorDefs::getDetectorType;
/** /**
* Get Detector type for a particular sls detector or get the first one * Get Detector type for a particular sls detector or get the first one
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position

View File

@ -7,6 +7,7 @@
#include "versionAPI.h" #include "versionAPI.h"
#include "slsDetectorCommand.h" #include "slsDetectorCommand.h"
#include "utilities.h" #include "utilities.h"
#include "MySocketTCP.h"
#include <sys/types.h> #include <sys/types.h>
@ -183,9 +184,7 @@ int slsDetector::checkVersionCompatibility(portType t) {
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
// data port // data port
if (connectData() == OK){ if (connectData() == OK){
// ignoring retval ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), NULL, 0);
int64_t retval = -1;
ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret==FAIL){ if (ret==FAIL){
setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY));
if(strstr(mess,"Unrecognized Function")!=NULL) if(strstr(mess,"Unrecognized Function")!=NULL)
@ -828,7 +827,7 @@ int slsDetector::receiveModule(sls_detector_module* myMod) {
} }
slsReceiverDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, bool verify) { slsDetectorDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, bool verify) {
detectorType type = GENERIC; detectorType type = GENERIC;
SharedMemory* shm = 0; SharedMemory* shm = 0;
@ -3628,7 +3627,7 @@ std::string slsDetector::setReceiver(std::string receiverIP) {
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Setting up receiver with" << std::endl; std::cout << "Setting up receiver with" << std::endl;
std::cout << "detector type:" << slsDetectorBase::getDetectorType( std::cout << "detector type:" << slsDetectorDefs::getDetectorType(
thisDetector->myDetectorType) << std::endl; thisDetector->myDetectorType) << std::endl;
std::cout << "detector id:" << detId << std::endl; std::cout << "detector id:" << detId << std::endl;
std::cout << "detector hostname:" << thisDetector->hostname << std::endl; std::cout << "detector hostname:" << thisDetector->hostname << std::endl;
@ -5972,25 +5971,18 @@ std::string slsDetector::getReceiverLastClientIP() {
int slsDetector::exitReceiver() { int slsDetector::exitReceiver() {
int retval;
int fnum = F_EXIT_RECEIVER; int fnum = F_EXIT_RECEIVER;
int ret = FAIL;
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (dataSocket) { if (connectData() == OK){
dataSocket->Connect(); ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0);
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
disconnectData(); disconnectData();
} }
} }
if (retval!=OK) { if (ret == OK) {
std::cout<< std::endl; std::cout << std::endl << "Shutting down the receiver" << std::endl << std::endl;
std::cout<< "Shutting down the receiver" << std::endl;
std::cout<< std::endl;
} }
return retval; return ret;
} }
int slsDetector::execReceiverCommand(std::string cmd) { int slsDetector::execReceiverCommand(std::string cmd) {
@ -6313,7 +6305,7 @@ int slsDetector::setReceiverFramesPerFile(int f) {
} }
slsReceiverDefs::frameDiscardPolicy slsDetector::setReceiverFramesDiscardPolicy(frameDiscardPolicy f) { slsDetectorDefs::frameDiscardPolicy slsDetector::setReceiverFramesDiscardPolicy(frameDiscardPolicy f) {
int fnum = F_RECEIVER_DISCARD_POLICY; int fnum = F_RECEIVER_DISCARD_POLICY;
int ret = FAIL; int ret = FAIL;
int retval = -1; int retval = -1;
@ -6367,7 +6359,7 @@ int slsDetector::setReceiverPartialFramesPadding(int f) {
return thisDetector->receiver_framePadding; return thisDetector->receiver_framePadding;
} }
slsReceiverDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { slsDetectorDefs::fileFormat slsDetector::setFileFormat(fileFormat f) {
if (f == GET_FILE_FORMAT) if (f == GET_FILE_FORMAT)
return getFileFormat(); return getFileFormat();
@ -6397,7 +6389,7 @@ slsReceiverDefs::fileFormat slsDetector::setFileFormat(fileFormat f) {
slsReceiverDefs::fileFormat slsDetector::getFileFormat() { slsDetectorDefs::fileFormat slsDetector::getFileFormat() {
return thisDetector->receiver_fileFormatType; return thisDetector->receiver_fileFormatType;
} }

View File

@ -9,12 +9,14 @@
* @author Anna Bergamaschi * @author Anna Bergamaschi
*/ */
#include "slsDetectorBase.h" #include "sls_detector_defs.h"
#include "MySocketTCP.h" #include "error_defs.h"
#include "math.h"
class multiSlsDetector; class multiSlsDetector;
class SharedMemory; class SharedMemory;
class ClientInterface; class ClientInterface;
class MySocketTCP;
#define SLS_SHMVERSION 0x181005 #define SLS_SHMVERSION 0x181005
#define NCHIPSMAX 10 #define NCHIPSMAX 10
@ -38,7 +40,7 @@ typedef struct detParameterList {
} detParameterList; } detParameterList;
class slsDetector : public slsDetectorBase { class slsDetector : public virtual slsDetectorDefs, public virtual errorDefs {
private: private:
/** /**
@ -388,7 +390,7 @@ public:
*/ */
void disconnectStop(); void disconnectStop();
using slsDetectorBase::getDetectorType; using slsDetectorDefs::getDetectorType;
/** /**
* Get detector type by connecting to the detector without creating an object * Get detector type by connecting to the detector without creating an object

View File

@ -1,360 +0,0 @@
#ifndef SLS_DETECTOR_BASE_H
#define SLS_DETECTOR_BASE_H
/**
\mainpage Common C++ library for SLS detectors data acquisition
*
* \section intro_sec Introduction
* \subsection mot_sec Motivation
Although the SLS detectors group delvelops several types of detectors (1/2D, counting/integrating etc.) it is common interest of the group to use a common platfor for data acquisition
\subsection arch_sec System Architecture
The architecture of the acquisitions system is intended as follows:
\li A socket server running on the detector (or more than one in some special cases)
\li C++ classes common to all detectors for client-server communication. These can be supplied to users as libraries and embedded also in acquisition systems which are not developed by the SLS
\li the possibility of using a Qt-based graphical user interface (with eventually root analisys capabilities)
\li the possibility of running all commands from command line. In order to ensure a fast operation of this so called "text client" the detector parameters should not be re-initialized everytime. For this reason a shared memory block is allocated where the main detector flags and parameters are stored
\li a Root library for data postprocessing and detector calibration (energy, angle).
\section howto_sec How to use it
The detectors can be simply operated by using the provided GUi or command line executable. <br>
In case you need to embed the detector control e.g in the beamline control software, compile these classes using
<BR>
make package
<br>
and link the shared library created to your software slsDetectorSoftware/bin/libSlsDetector.so
<br>
The software can also be installed (with super-user rights)<br>
make install
<br>
<br>
Most methods of interest for the user are implemented in the ::slsDetectorBase interface class, but the classes to be implemented in the main program are either ::slsDetector (for single controller detectors) or ::multiSlsDetector (for multiple controllers, but can work also for single controllers).
@author Anna Bergamaschi
@version 0.1alpha
*/
/**
*
*
*
* @author Anna Bergamaschi
* @version 0.1alpha
*/
#include "sls_detector_defs.h"
#include "sls_receiver_defs.h"
#include "slsDetectorUsers.h"
#include "error_defs.h"
#include <string>
/**
@libdoc The slsDetectorBase contains also a set of purely virtual functions useful for the implementation of the derived classes
* @short This is the base class for all detector functionalities
*/
//public virtual slsDetectorUsers,
class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDefs {
public:
/** default constructor */
slsDetectorBase(){};
/** virtual destructor */
virtual ~slsDetectorBase(){};
/** returns detector type std::string from detector type index
\param t std::string can be Eiger, Gotthard, Jungfrau, Unknown
\returns EIGER, GOTTHARD, JUNGFRAU, GENERIC
*/
static std::string getDetectorType(detectorType t){\
switch (t) {\
case EIGER: return std::string("Eiger"); \
case GOTTHARD: return std::string("Gotthard"); \
case JUNGFRAU: return std::string("Jungfrau"); \
case JUNGFRAUCTB: return std::string("JungfrauCTB"); \
default: return std::string("Unknown"); \
}};
/** returns detector type index from detector type std::string
\param type can be EIGER, GOTTHARD, JUNGFRAU, GENERIC
\returns Eiger, Gotthard, Jungfrau, Unknown
*/
static detectorType getDetectorType(std::string const type){\
if (type=="Eiger") return EIGER; \
if (type=="Gotthard") return GOTTHARD; \
if (type=="Jungfrau") return JUNGFRAU; \
if (type=="JungfrauCTB") return JUNGFRAUCTB; \
return GENERIC;};
/** returns std::string from external signal type index
\param f can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, =TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG
\returns std::string off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, gnd, vcc, sync, unknown
*/
static std::string externalSignalType(externalSignalFlag f){\
switch(f) { \
case SIGNAL_OFF: return std::string( "off"); \
case GATE_IN_ACTIVE_HIGH: return std::string( "gate_in_active_high"); \
case GATE_IN_ACTIVE_LOW: return std::string( "gate_in_active_low"); \
case TRIGGER_IN_RISING_EDGE: return std::string( "trigger_in_rising_edge"); \
case TRIGGER_IN_FALLING_EDGE: return std::string( "trigger_in_falling_edge"); \
case RO_TRIGGER_IN_RISING_EDGE: return std::string( "ro_trigger_in_rising_edge"); \
case RO_TRIGGER_IN_FALLING_EDGE: return std::string( "ro_trigger_in_falling_edge"); \
case GATE_OUT_ACTIVE_HIGH: return std::string( "gate_out_active_high"); \
case GATE_OUT_ACTIVE_LOW: return std::string( "gate_out_active_low"); \
case TRIGGER_OUT_RISING_EDGE: return std::string( "trigger_out_rising_edge"); \
case TRIGGER_OUT_FALLING_EDGE: return std::string( "trigger_out_falling_edge"); \
case RO_TRIGGER_OUT_RISING_EDGE: return std::string( "ro_trigger_out_rising_edge"); \
case RO_TRIGGER_OUT_FALLING_EDGE: return std::string( "ro_trigger_out_falling_edge"); \
case MASTER_SLAVE_SYNCHRONIZATION: return std::string("sync"); \
case OUTPUT_LOW: return std::string("gnd"); \
case OUTPUT_HIGH: return std::string("vcc"); \
default: return std::string( "unknown"); \
} };
/** returns external signal type index from std::string
\param sval off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, gnd, vcc, sync, unknown
\returns can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG (if unknown)
*/
static externalSignalFlag externalSignalType(std::string sval){\
if (sval=="off") return SIGNAL_OFF;\
if (sval=="gate_in_active_high") return GATE_IN_ACTIVE_HIGH; \
if (sval=="gate_in_active_low") return GATE_IN_ACTIVE_LOW;\
if (sval=="trigger_in_rising_edge") return TRIGGER_IN_RISING_EDGE;\
if (sval=="trigger_in_falling_edge") return TRIGGER_IN_FALLING_EDGE;\
if (sval=="ro_trigger_in_rising_edge") return RO_TRIGGER_IN_RISING_EDGE;\
if (sval=="ro_trigger_in_falling_edge") return RO_TRIGGER_IN_FALLING_EDGE;\
if (sval=="gate_out_active_high") return GATE_OUT_ACTIVE_HIGH;\
if (sval=="gate_out_active_low") return GATE_OUT_ACTIVE_LOW;\
if (sval=="trigger_out_rising_edge") return TRIGGER_OUT_RISING_EDGE;\
if (sval=="trigger_out_falling_edge") return TRIGGER_OUT_FALLING_EDGE;\
if (sval=="ro_trigger_out_rising_edge") return RO_TRIGGER_OUT_RISING_EDGE;\
if (sval=="ro_trigger_out_falling_edge") return RO_TRIGGER_OUT_FALLING_EDGE;\
if (sval=="sync") return MASTER_SLAVE_SYNCHRONIZATION;\
if (sval=="gnd") return OUTPUT_LOW;\
if (sval=="vcc") return OUTPUT_HIGH;\
return GET_EXTERNAL_SIGNAL_FLAG ;};
/** returns detector settings std::string from index
\param s can be STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, LOWNOISE,
DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2, GET_SETTINGS
\returns standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, lownoise,
dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2, verylowgain, undefined
*/
static std::string getDetectorSettings(detectorSettings s){\
switch(s) { \
case STANDARD: return std::string("standard"); \
case FAST: return std::string("fast"); \
case HIGHGAIN: return std::string("highgain"); \
case DYNAMICGAIN: return std::string("dynamicgain"); \
case LOWGAIN: return std::string("lowgain"); \
case MEDIUMGAIN: return std::string("mediumgain"); \
case VERYHIGHGAIN: return std::string("veryhighgain"); \
case LOWNOISE: return std::string("lownoise"); \
case DYNAMICHG0: return std::string("dynamichg0"); \
case FIXGAIN1: return std::string("fixgain1"); \
case FIXGAIN2: return std::string("fixgain2"); \
case FORCESWITCHG1: return std::string("forceswitchg1");\
case FORCESWITCHG2: return std::string("forceswitchg2");\
case VERYLOWGAIN: return std::string("verylowgain");\
default: return std::string("undefined"); \
}};
/** returns detector settings std::string from index
\param s can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, lownoise,
dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2, undefined
\returns setting index STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN,LOWNOISE,
DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2, VERYLOWGAIN, GET_SETTINGS
*/
static detectorSettings getDetectorSettings(std::string s){ \
if (s=="standard") return STANDARD; \
if (s=="fast") return FAST; \
if (s=="highgain") return HIGHGAIN; \
if (s=="dynamicgain") return DYNAMICGAIN; \
if (s=="lowgain") return LOWGAIN; \
if (s=="mediumgain") return MEDIUMGAIN; \
if (s=="veryhighgain") return VERYHIGHGAIN; \
if (s=="lownoise") return LOWNOISE; \
if (s=="dynamichg0") return DYNAMICHG0; \
if (s=="fixgain1") return FIXGAIN1; \
if (s=="fixgain2") return FIXGAIN2; \
if (s=="forceswitchg1") return FORCESWITCHG1; \
if (s=="forceswitchg2") return FORCESWITCHG2; \
if (s=="verylowgain") return VERYLOWGAIN; \
return GET_SETTINGS; \
};
/**
returns external communication mode std::string from index
\param f can be AUTO_TIMING, TRIGGER_EXPOSURE, TRIGGER_READOUT, GATE_FIX_NUMBER, GATE_WITH_START_TRIGGER, BURST_TRIGGER, GET_EXTERNAL_COMMUNICATION_MODE
\returns auto, trigger, ro_trigger, gating, triggered_gating, unknown
*/
static std::string externalCommunicationType(externalCommunicationMode f){ \
switch(f) { \
case AUTO_TIMING: return std::string( "auto"); \
case TRIGGER_EXPOSURE: return std::string("trigger"); \
case TRIGGER_READOUT: return std::string("ro_trigger"); \
case GATE_FIX_NUMBER: return std::string("gating"); \
case GATE_WITH_START_TRIGGER: return std::string("triggered_gating"); \
case BURST_TRIGGER: return std::string("burst_trigger"); \
default: return std::string( "unknown"); \
} };
/**
returns external communication mode index from std::string
\param sval can be auto, trigger, ro_trigger, gating, triggered_gating
\returns AUTO_TIMING, TRIGGER_EXPOSURE, TRIGGER_READOUT, GATE_FIX_NUMBER, GATE_WITH_START_TRIGGER, BURST_TRIGGER, GET_EXTERNAL_COMMUNICATION_MODE
*/
static externalCommunicationMode externalCommunicationType(std::string sval){\
if (sval=="auto") return AUTO_TIMING;\
if (sval=="trigger") return TRIGGER_EXPOSURE; \
if (sval=="ro_trigger") return TRIGGER_READOUT;\
if (sval=="gating") return GATE_FIX_NUMBER;\
if (sval=="triggered_gating") return GATE_WITH_START_TRIGGER;\
if (sval=="burst_trigger") return BURST_TRIGGER;\
return GET_EXTERNAL_COMMUNICATION_MODE; \
};
/** returns std::string from run status index
\param s can be ERROR, WAITING, RUNNING, TRANSMITTING, RUN_FINISHED
\returns std::string error, waiting, running, data, finished
*/
static std::string runStatusType(runStatus s){\
switch (s) { \
case ERROR: return std::string("error"); \
case WAITING: return std::string("waiting"); \
case RUNNING: return std::string("running");\
case TRANSMITTING: return std::string("data"); \
case RUN_FINISHED: return std::string("finished"); \
default: return std::string("idle"); \
}};
/** returns std::string from file format index
\param s can be RAW, HDF5
\returns std::string raw, hdf5
*/
static std::string fileFormats(fileFormat f){\
switch (f) { \
case BINARY: return std::string("binary"); \
case ASCII: return std::string("ascii"); \
case HDF5: return std::string("hdf5"); \
default: return std::string("unknown"); \
}};
/** returns std::string from timer index
\param s can be FRAME_NUMBER,ACQUISITION_TIME,FRAME_PERIOD, DELAY_AFTER_TRIGGER,GATES_NUMBER, CYCLES_NUMBER, ACTUAL_TIME,MEASUREMENT_TIME, PROGRESS,MEASUREMENTS_NUMBER,FRAMES_FROM_START,FRAMES_FROM_START_PG,SAMPLES_JCTB,SUBFRAME_ACQUISITION_TIME,STORAGE_CELL_NUMBER, SUBFRAME_DEADTIME
\returns std::string frame_number,acquisition_time,frame_period, delay_after_trigger,gates_number, cycles_number, actual_time,measurement_time, progress,measurements_number,frames_from_start,frames_from_start_pg,samples_jctb,subframe_acquisition_time,storage_cell_number, SUBFRAME_DEADTIME
*/
static std::string getTimerType(timerIndex t){ \
switch (t) { \
case FRAME_NUMBER: return std::string("frame_number"); \
case ACQUISITION_TIME: return std::string("acquisition_time"); \
case FRAME_PERIOD: return std::string("frame_period"); \
case DELAY_AFTER_TRIGGER: return std::string("delay_after_trigger"); \
case GATES_NUMBER: return std::string("gates_number"); \
case CYCLES_NUMBER: return std::string("cycles_number"); \
case ACTUAL_TIME: return std::string("actual_time"); \
case MEASUREMENT_TIME: return std::string("measurement_time"); \
case PROGRESS: return std::string("progress"); \
case MEASUREMENTS_NUMBER: return std::string("measurements_number"); \
case FRAMES_FROM_START: return std::string("frames_from_start"); \
case FRAMES_FROM_START_PG: return std::string("frames_from_start_pg"); \
case SAMPLES_JCTB: return std::string("samples_jctb"); \
case SUBFRAME_ACQUISITION_TIME: return std::string("subframe_acquisition_time"); \
case SUBFRAME_DEADTIME: return std::string("subframe_deadtime"); \
case STORAGE_CELL_NUMBER: return std::string("storage_cell_number"); \
default: return std::string("unknown"); \
}};
/**
@short returns adc index from std::string
\param s can be temp_fpga, temp_fpgaext, temp_10ge, temp_dcdc, temp_sodl, temp_sodr, temp_fpgafl, temp_fpgafr
\returns TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT, TEMPERATURE_10GE, TEMPERATURE_DCDC, TEMPERATURE_SODL,
TEMPERATURE_SODR, TEMPERATURE_FPGA2, TEMPERATURE_FPGA3, -1 when unknown mode
*/
static int getADCIndex(std::string s){ \
if (s=="temp_fpga") return TEMPERATURE_FPGA; \
if (s=="temp_fpgaext") return TEMPERATURE_FPGAEXT; \
if (s=="temp_10ge") return TEMPERATURE_10GE; \
if (s=="temp_dcdc") return TEMPERATURE_DCDC; \
if (s=="temp_sodl") return TEMPERATURE_SODL; \
if (s=="temp_sodr") return TEMPERATURE_SODR; \
if (s=="temp_fpgafl") return TEMPERATURE_FPGA2; \
if (s=="temp_fpgafr") return TEMPERATURE_FPGA3; \
return -1; \
}; \
/**
@short returns dac index from std::string
\param s can be vcmp_ll, vcmp_lr, vcmp_rl, vcmp_rr, vthreshold, vrf, vrs, vtr, vcall, vcp
\returns E_Vcmp_ll, E_Vcmp_lr, E_Vcmp_rl, E_Vcmp_rr, THRESHOLD, E_Vrf, E_Vrs, E_Vtr, E_cal, E_Vcp , -1 when unknown mode
*/
static int getDACIndex(std::string s){ \
if (s=="vcmp_ll") return E_Vcmp_ll; \
if (s=="vcmp_lr") return E_Vcmp_lr; \
if (s=="vcmp_rl") return E_Vcmp_rl; \
if (s=="vcmp_rr") return E_Vcmp_rr; \
if (s=="vthreshold") return THRESHOLD; \
if (s=="vrf") return E_Vrf; \
if (s=="vrs") return E_Vrs; \
if (s=="vtr") return E_Vtr; \
if (s=="vcall") return E_cal; \
if (s=="vcp") return E_Vcp; \
return -1; \
}; \
/**
@short returns receiver frame discard policy from std::string
\param s can be nodiscard, discardempty, discardpartial
\returns NO_DISCARD, DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES, GET_FRAME_DISCARD_POLICY when unknown mode
*/
static frameDiscardPolicy getReceiverFrameDiscardPolicy(std::string s){ \
if (s=="nodiscard") return NO_DISCARD; \
if (s=="discardempty") return DISCARD_EMPTY_FRAMES; \
if (s=="discardpartial") return DISCARD_PARTIAL_FRAMES; \
return GET_FRAME_DISCARD_POLICY; \
}; \
/** returns std::string from frame discard policy
\param f can be NO_DISCARD, DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES
\returns std::string nodiscard, discardempty, discardpartial, unknown
*/
static std::string getReceiverFrameDiscardPolicy(frameDiscardPolicy f){ \
switch (f) { \
case NO_DISCARD: return std::string("nodiscard"); \
case DISCARD_EMPTY_FRAMES: return std::string("discardempty"); \
case DISCARD_PARTIAL_FRAMES: return std::string("discardpartial"); \
default: return std::string("unknown"); \
}}; \
};
#endif

View File

@ -94,11 +94,11 @@ int64_t slsDetectorUsers::getReceiverSoftwareVersion(int detPos){
} }
bool slsDetectorUsers::isDetectorVersionCompatible(int detPos) { bool slsDetectorUsers::isDetectorVersionCompatible(int detPos) {
return (myDetector->checkVersionCompatibility(slsDetectorDefs::CONTROL_PORT, detPos) == slsReceiverDefs::OK); return (myDetector->checkVersionCompatibility(slsDetectorDefs::CONTROL_PORT, detPos) == slsDetectorDefs::OK);
} }
bool slsDetectorUsers::isReceiverVersionCompatible(int detPos) { bool slsDetectorUsers::isReceiverVersionCompatible(int detPos) {
return (myDetector->checkVersionCompatibility(slsDetectorDefs::DATA_PORT, detPos) == slsReceiverDefs::OK); return (myDetector->checkVersionCompatibility(slsDetectorDefs::DATA_PORT, detPos) == slsDetectorDefs::OK);
} }
int slsDetectorUsers::startMeasurement(){ int slsDetectorUsers::startMeasurement(){

View File

@ -127,7 +127,7 @@ public:
/** /**
* Gets detector type * Gets detector type
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
* @returns detector type (EIGER, JUNGFRAU, GOTTHARD) slsReceiverDefs * @returns detector type (EIGER, JUNGFRAU, GOTTHARD) slsDetectorDefs
*/ */
std::string getDetectorType(int detPos = -1); std::string getDetectorType(int detPos = -1);

View File

@ -1,5 +1,4 @@
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "sls_receiver_defs.h"
#include "server_funcs.h" #include "server_funcs.h"
#include "server_defs.h" #include "server_defs.h"
#include "firmware_funcs.h" #include "firmware_funcs.h"

View File

@ -2,7 +2,7 @@
#ifndef SLS_DETECTOR_FUNCTION_LIST_H #ifndef SLS_DETECTOR_FUNCTION_LIST_H
#define SLS_DETECTOR_FUNCTION_LIST_H #define SLS_DETECTOR_FUNCTION_LIST_H
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h #include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,7 +1,7 @@
#ifndef SERVER_FUNCS_H #ifndef SERVER_FUNCS_H
#define SERVER_FUNCS_H #define SERVER_FUNCS_H
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include <stdlib.h> #include <stdlib.h>
// initialization functions // initialization functions

View File

@ -56,7 +56,7 @@ add_library(slsReceiverShared SHARED
) )
set(PUBLICHEADERS set(PUBLICHEADERS
../slsSupportLib/include/sls_receiver_defs.h ../slsSupportLib/include/sls_detector_defs.h
../slsSupportLib/include/ansi.h ../slsSupportLib/include/ansi.h
../slsSupportLib/include/sls_receiver_funcs.h ../slsSupportLib/include/sls_receiver_funcs.h
../slsSupportLib/include/MySocketTCP.h ../slsSupportLib/include/MySocketTCP.h

View File

@ -27,7 +27,7 @@ LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq
SRC_CLNT = ThreadObject.cpp Listener.cpp DataProcessor.cpp DataStreamer.cpp Fifo.cpp File.cpp BinaryFile.cpp slsReceiverImplementation.cpp slsReceiverTCPIPInterface.cpp slsReceiver.cpp slsReceiverUsers.cpp $(COMMONDIR)/utilities.cpp SRC_CLNT = ThreadObject.cpp Listener.cpp DataProcessor.cpp DataStreamer.cpp Fifo.cpp File.cpp BinaryFile.cpp slsReceiverImplementation.cpp slsReceiverTCPIPInterface.cpp slsReceiver.cpp slsReceiverUsers.cpp $(COMMONDIR)/utilities.cpp
DEPSINCLUDES = $(COMMONDIR)/ansi.h $(COMMONDIR)/sls_receiver_defs.h $(COMMONDIR)/sls_receiver_funcs.h $(COMMONDIR)/GeneralData.h $(INCDIR)/circularFifo.h $(COMMONDIR)/genericSocket.h $(COMMONDIR)/logger.h $(INCDIR)/receiver_defs.h $(COMMONDIR)/utilities.h $(COMMONDIR)/ZmqSocket.h $(INCDIR)/BinaryFileStatic.h $(INCDIR)/HDF5FileStatic.h $(COMMONDIR)/sls_receiver_exceptions.h DEPSINCLUDES = $(COMMONDIR)/ansi.h $(COMMONDIR)/sls_detector_defs.h $(COMMONDIR)/sls_receiver_funcs.h $(COMMONDIR)/GeneralData.h $(INCDIR)/circularFifo.h $(COMMONDIR)/genericSocket.h $(COMMONDIR)/logger.h $(INCDIR)/receiver_defs.h $(COMMONDIR)/utilities.h $(COMMONDIR)/ZmqSocket.h $(INCDIR)/BinaryFileStatic.h $(INCDIR)/HDF5FileStatic.h $(COMMONDIR)/sls_receiver_exceptions.h
ifeq ($(HDF5),yes) ifeq ($(HDF5),yes)

View File

@ -6,4 +6,4 @@ Revision: 840
Branch: refactor Branch: refactor
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4039 Last Changed Rev: 4039
Last Changed Date: 2018-10-02 10:40:58.000000002 +0200 ./include/sls_receiver_defs.h Last Changed Date: 2018-10-02 10:40:58.000000002 +0200

View File

@ -14,7 +14,7 @@
#include <string> #include <string>
class BinaryFile : private virtual slsReceiverDefs, public File, public BinaryFileStatic { class BinaryFile : private virtual slsDetectorDefs, public File, public BinaryFileStatic {
public: public:
/** /**

View File

@ -18,7 +18,7 @@ class DataStreamer;
#include <vector> #include <vector>
class DataProcessor : private virtual slsReceiverDefs, public ThreadObject { class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
public: public:
/** /**

View File

@ -16,7 +16,7 @@ class ZmqSocket;
#include <vector> #include <vector>
class DataStreamer : private virtual slsReceiverDefs, public ThreadObject { class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
public: public:
/** /**

View File

@ -9,12 +9,12 @@
*@short constructs the fifo structure *@short constructs the fifo structure
*/ */
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include "logger.h" #include "logger.h"
#include "circularFifo.h" #include "circularFifo.h"
class Fifo : private virtual slsReceiverDefs { class Fifo : private virtual slsDetectorDefs {
public: public:
/** /**

View File

@ -8,13 +8,13 @@
*@short sets/gets properties for the file, creates/closes the file and writes data to it *@short sets/gets properties for the file, creates/closes the file and writes data to it
*/ */
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include "logger.h" #include "logger.h"
#include <string> #include <string>
class File : private virtual slsReceiverDefs { class File : private virtual slsDetectorDefs {
public: public:
/** /**

View File

@ -7,7 +7,7 @@
*@short abstract for setting/getting properties of detector data *@short abstract for setting/getting properties of detector data
*/ */
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include "receiver_defs.h" #include "receiver_defs.h"
#include <math.h> //ceil #include <math.h> //ceil
@ -19,7 +19,7 @@ class GeneralData {
public: public:
/** DetectorType */ /** DetectorType */
slsReceiverDefs::detectorType myDetectorType; slsDetectorDefs::detectorType myDetectorType;
/** Number of Pixels in x axis */ /** Number of Pixels in x axis */
uint32_t nPixelsX; uint32_t nPixelsX;
@ -92,7 +92,7 @@ public:
/** Cosntructor */ /** Cosntructor */
GeneralData(): GeneralData():
myDetectorType(slsReceiverDefs::GENERIC), myDetectorType(slsDetectorDefs::GENERIC),
nPixelsX(0), nPixelsX(0),
nPixelsY(0), nPixelsY(0),
emptyHeader(0), emptyHeader(0),
@ -160,7 +160,7 @@ public:
* Set ROI * Set ROI
* @param i ROI * @param i ROI
*/ */
virtual void SetROI(std::vector<slsReceiverDefs::ROI> i) { virtual void SetROI(std::vector<slsDetectorDefs::ROI> i) {
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
}; };
@ -170,7 +170,7 @@ public:
* @param i pointer to a vector of ROI pointers * @param i pointer to a vector of ROI pointers
* @returns adc configured * @returns adc configured
*/ */
virtual const int GetAdcConfigured(int index, std::vector<slsReceiverDefs::ROI>* i) const{ virtual const int GetAdcConfigured(int index, std::vector<slsDetectorDefs::ROI>* i) const{
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
return 0; return 0;
}; };
@ -216,7 +216,7 @@ public:
*/ */
virtual void Print() const { virtual void Print() const {
FILE_LOG(logDEBUG) << "\n\nDetector Data Variables:"; FILE_LOG(logDEBUG) << "\n\nDetector Data Variables:";
FILE_LOG(logDEBUG) << "myDetectorType: " << slsReceiverDefs::getDetectorType(myDetectorType); FILE_LOG(logDEBUG) << "myDetectorType: " << slsDetectorDefs::getDetectorType(myDetectorType);
FILE_LOG(logDEBUG) << "Pixels X: " << nPixelsX; FILE_LOG(logDEBUG) << "Pixels X: " << nPixelsX;
FILE_LOG(logDEBUG) << "Pixels Y: " << nPixelsY; FILE_LOG(logDEBUG) << "Pixels Y: " << nPixelsY;
FILE_LOG(logDEBUG) << "Empty Header: " << emptyHeader; FILE_LOG(logDEBUG) << "Empty Header: " << emptyHeader;
@ -253,7 +253,7 @@ private:
/** Constructor */ /** Constructor */
GotthardData(){ GotthardData(){
myDetectorType = slsReceiverDefs::GOTTHARD; myDetectorType = slsDetectorDefs::GOTTHARD;
nPixelsX = 1280; nPixelsX = 1280;
nPixelsY = 1; nPixelsY = 1;
headerSizeinPacket = 4; headerSizeinPacket = 4;
@ -265,7 +265,7 @@ private:
frameIndexOffset = 1; frameIndexOffset = 1;
packetIndexMask = 1; packetIndexMask = 1;
maxFramesPerFile = MAX_FRAMES_PER_FILE; maxFramesPerFile = MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
defaultFifoDepth = 50000; defaultFifoDepth = 50000;
}; };
@ -323,7 +323,7 @@ private:
* Set ROI * Set ROI
* @param i ROI * @param i ROI
*/ */
virtual void SetROI(std::vector<slsReceiverDefs::ROI> i) { virtual void SetROI(std::vector<slsDetectorDefs::ROI> i) {
// all adcs // all adcs
if(!i.size()) { if(!i.size()) {
nPixelsX = 1280; nPixelsX = 1280;
@ -335,7 +335,7 @@ private:
frameIndexOffset = 1; frameIndexOffset = 1;
packetIndexMask = 1; packetIndexMask = 1;
maxFramesPerFile = MAX_FRAMES_PER_FILE; maxFramesPerFile = MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
defaultFifoDepth = 50000; defaultFifoDepth = 50000;
nPixelsXComplete = 0; nPixelsXComplete = 0;
nPixelsYComplete = 0; nPixelsYComplete = 0;
@ -353,7 +353,7 @@ private:
frameIndexOffset = 0; frameIndexOffset = 0;
packetIndexMask = 0; packetIndexMask = 0;
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE; maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
defaultFifoDepth = 25000; defaultFifoDepth = 25000;
nPixelsXComplete = 1280; nPixelsXComplete = 1280;
nPixelsYComplete = 1; nPixelsYComplete = 1;
@ -367,7 +367,7 @@ private:
* @param i pointer to a vector of ROI * @param i pointer to a vector of ROI
* @returns adc configured * @returns adc configured
*/ */
virtual const int GetAdcConfigured(int index, std::vector<slsReceiverDefs::ROI>* i) const{ virtual const int GetAdcConfigured(int index, std::vector<slsDetectorDefs::ROI>* i) const{
int adc = -1; int adc = -1;
// single adc // single adc
if(i->size()) { if(i->size()) {
@ -407,7 +407,7 @@ class PropixData : public GeneralData {
/** Constructor */ /** Constructor */
PropixData(){ PropixData(){
myDetectorType = slsReceiverDefs::PROPIX; myDetectorType = slsDetectorDefs::PROPIX;
nPixelsX = 22; nPixelsX = 22;
nPixelsY = 22; nPixelsY = 22;
headerSizeinPacket = 4; headerSizeinPacket = 4;
@ -419,7 +419,7 @@ class PropixData : public GeneralData {
frameIndexOffset = 1; frameIndexOffset = 1;
packetIndexMask = 1; packetIndexMask = 1;
maxFramesPerFile = MAX_FRAMES_PER_FILE; maxFramesPerFile = MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
defaultFifoDepth = 50000; defaultFifoDepth = 50000;
}; };
}; };
@ -434,7 +434,7 @@ class Moench02Data : public GeneralData {
/** Constructor */ /** Constructor */
Moench02Data(){ Moench02Data(){
myDetectorType = slsReceiverDefs::MOENCH; myDetectorType = slsDetectorDefs::MOENCH;
nPixelsX = 160; nPixelsX = 160;
nPixelsY = 160; nPixelsY = 160;
headerSizeinPacket = 4; headerSizeinPacket = 4;
@ -446,7 +446,7 @@ class Moench02Data : public GeneralData {
frameIndexOffset = 8; frameIndexOffset = 8;
packetIndexMask = 0xFF; packetIndexMask = 0xFF;
maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE; maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
defaultFifoDepth = 2500; defaultFifoDepth = 2500;
}; };
@ -466,7 +466,7 @@ class Moench03Data : public GeneralData {
/** Constructor */ /** Constructor */
Moench03Data(){ Moench03Data(){
myDetectorType = slsReceiverDefs::MOENCH; myDetectorType = slsDetectorDefs::MOENCH;
nPixelsX = 400; nPixelsX = 400;
nPixelsY = 400; nPixelsY = 400;
headerSizeinPacket = 22; headerSizeinPacket = 22;
@ -478,7 +478,7 @@ class Moench03Data : public GeneralData {
frameIndexOffset = (6+8); frameIndexOffset = (6+8);
packetIndexMask = 0xFFFFFFFF; packetIndexMask = 0xFFFFFFFF;
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE; maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
defaultFifoDepth = 2500; defaultFifoDepth = 2500;
}; };
}; };
@ -506,7 +506,7 @@ private:
/** Constructor */ /** Constructor */
JCTBData(){ JCTBData(){
myDetectorType = slsReceiverDefs::JUNGFRAUCTB; myDetectorType = slsDetectorDefs::JUNGFRAUCTB;
nPixelsX = 400; nPixelsX = 400;
nPixelsY = 400; nPixelsY = 400;
headerSizeinPacket = 22; headerSizeinPacket = 22;
@ -516,7 +516,7 @@ private:
imageSize = nPixelsX * nPixelsY * 2; imageSize = nPixelsX * nPixelsY * 2;
frameIndexMask = 0xFFFFFF; frameIndexMask = 0xFFFFFF;
maxFramesPerFile = JFCTB_MAX_FRAMES_PER_FILE; maxFramesPerFile = JFCTB_MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
defaultFifoDepth = 2500; defaultFifoDepth = 2500;
}; };
@ -578,17 +578,17 @@ class JungfrauData : public GeneralData {
/** Constructor */ /** Constructor */
JungfrauData(){ JungfrauData(){
myDetectorType = slsReceiverDefs::JUNGFRAU; myDetectorType = slsDetectorDefs::JUNGFRAU;
nPixelsX = (256*4); nPixelsX = (256*4);
nPixelsY = 512; nPixelsY = 512;
emptyHeader = 6; emptyHeader = 6;
headerSizeinPacket = emptyHeader + sizeof(slsReceiverDefs::sls_detector_header); headerSizeinPacket = emptyHeader + sizeof(slsDetectorDefs::sls_detector_header);
dataSize = 8192; dataSize = 8192;
packetSize = headerSizeinPacket + dataSize; packetSize = headerSizeinPacket + dataSize;
packetsPerFrame = 128; packetsPerFrame = 128;
imageSize = dataSize*packetsPerFrame; imageSize = dataSize*packetsPerFrame;
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE; maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
defaultFifoDepth = 2500; defaultFifoDepth = 2500;
standardheader = true; standardheader = true;
defaultUdpSocketBufferSize = (2000 * 1024 * 1024); defaultUdpSocketBufferSize = (2000 * 1024 * 1024);
@ -603,16 +603,16 @@ class EigerData : public GeneralData {
/** Constructor */ /** Constructor */
EigerData(){ EigerData(){
myDetectorType = slsReceiverDefs::EIGER; myDetectorType = slsDetectorDefs::EIGER;
nPixelsX = (256*2); nPixelsX = (256*2);
nPixelsY = 256; nPixelsY = 256;
headerSizeinPacket = sizeof(slsReceiverDefs::sls_detector_header); headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
dataSize = 1024; dataSize = 1024;
packetSize = headerSizeinPacket + dataSize; packetSize = headerSizeinPacket + dataSize;
packetsPerFrame = 256; packetsPerFrame = 256;
imageSize = dataSize*packetsPerFrame; imageSize = dataSize*packetsPerFrame;
maxFramesPerFile = EIGER_MAX_FRAMES_PER_FILE; maxFramesPerFile = EIGER_MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header); fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
defaultFifoDepth = 100; defaultFifoDepth = 100;
threadsPerReceiver = 2; threadsPerReceiver = 2;
headerPacketSize = 40; headerPacketSize = 40;

View File

@ -19,7 +19,7 @@
#endif #endif
class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileStatic { class HDF5File : private virtual slsDetectorDefs, public File, public HDF5FileStatic {
public: public:
/** /**

View File

@ -13,7 +13,7 @@
#ifndef H5_NO_NAMESPACE #ifndef H5_NO_NAMESPACE
using namespace H5; using namespace H5;
#endif #endif
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include "logger.h" #include "logger.h"
#include <iostream> #include <iostream>
@ -24,7 +24,7 @@ using namespace H5;
#include <sstream> #include <sstream>
#include <cstring> //memset #include <cstring> //memset
class HDF5FileStatic: public virtual slsReceiverDefs { class HDF5FileStatic: public virtual slsDetectorDefs {
public: public:

View File

@ -15,7 +15,7 @@ class GeneralData;
class Fifo; class Fifo;
class genericSocket; class genericSocket;
class Listener : private virtual slsReceiverDefs, public ThreadObject { class Listener : private virtual slsDetectorDefs, public ThreadObject {
public: public:
/** /**

View File

@ -7,14 +7,14 @@
*@short creates/destroys a thread *@short creates/destroys a thread
*/ */
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include "logger.h" #include "logger.h"
#include <pthread.h> #include <pthread.h>
#include <semaphore.h> #include <semaphore.h>
#include <string> #include <string>
class ThreadObject : private virtual slsReceiverDefs { class ThreadObject : private virtual slsDetectorDefs {
public: public:
/** /**

View File

@ -7,7 +7,6 @@
* modified by the sls detetor group * modified by the sls detetor group
* */ * */
//#include "sls_receiver_defs.h"
#include <semaphore.h> #include <semaphore.h>
#include <vector> #include <vector>
#include <iostream> #include <iostream>

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include <stdint.h> #include <stdint.h>
#define MAX_DIMENSIONS 2 #define MAX_DIMENSIONS 2

View File

@ -8,14 +8,14 @@
class slsReceiverTCPIPInterface; class slsReceiverTCPIPInterface;
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
/** /**
*@short creates the UDP and TCP class objects *@short creates the UDP and TCP class objects
*/ */
class slsReceiver : private virtual slsReceiverDefs { class slsReceiver : private virtual slsDetectorDefs {
public: public:
/** /**

View File

@ -6,7 +6,7 @@
/** /**
* @short does all the functions for a receiver, set/get parameters, start/stop etc. * @short does all the functions for a receiver, set/get parameters, start/stop etc.
*/ */
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include "receiver_defs.h" #include "receiver_defs.h"
#include "logger.h" #include "logger.h"
@ -19,7 +19,7 @@ class Fifo;
#include <exception> #include <exception>
#include <vector> #include <vector>
class slsReceiverImplementation: private virtual slsReceiverDefs { class slsReceiverImplementation: private virtual slsDetectorDefs {
public: public:
@ -346,7 +346,7 @@ class slsReceiverImplementation: private virtual slsReceiverDefs {
* Set File Format * Set File Format
* @param f fileformat binary or hdf5 * @param f fileformat binary or hdf5
*/ */
void setFileFormat(slsReceiverDefs::fileFormat f); void setFileFormat(slsDetectorDefs::fileFormat f);
/** /**
* Set File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw)) * Set File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw))

View File

@ -5,7 +5,7 @@
***********************************************/ ***********************************************/
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include "receiver_defs.h" #include "receiver_defs.h"
class MySocketTCP; class MySocketTCP;
@ -18,7 +18,7 @@ class slsReceiverImplementation;
*@short interface between receiver and client *@short interface between receiver and client
*/ */
class slsReceiverTCPIPInterface : private virtual slsReceiverDefs { class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
public: public:

View File

@ -37,7 +37,7 @@ void BinaryFile::PrintMembers() {
FILE_LOG(logINFO) << "Number of Frames in File: " << numFramesInFile; FILE_LOG(logINFO) << "Number of Frames in File: " << numFramesInFile;
} }
slsReceiverDefs::fileFormat BinaryFile::GetFileType() { slsDetectorDefs::fileFormat BinaryFile::GetFileType() {
return BINARY; return BINARY;
} }

View File

@ -116,7 +116,7 @@ void HDF5File::SetNumberofPixels(uint32_t nx, uint32_t ny) {
} }
slsReceiverDefs::fileFormat HDF5File::GetFileType() { slsDetectorDefs::fileFormat HDF5File::GetFileType() {
return HDF5; return HDF5;
} }

View File

@ -1,7 +1,7 @@
/* A simple server in the internet domain using TCP /* A simple server in the internet domain using TCP
The port number is passed as an argument */ The port number is passed as an argument */
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include "slsReceiverUsers.h" #include "slsReceiverUsers.h"
#include <iostream> #include <iostream>
@ -40,8 +40,8 @@ void AcquisitionFinished(uint64_t frames, void*p){
void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){
slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata; slsDetectorDefs::sls_receiver_header* header = (slsDetectorDefs::sls_receiver_header*)metadata;
slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader; slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row, PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row,
"#### %d GetData: ####\n" "#### %d GetData: ####\n"
@ -89,9 +89,9 @@ int main(int argc, char *argv[]) {
} }
int ret = slsReceiverDefs::OK; int ret = slsDetectorDefs::OK;
slsReceiverUsers *receiver = new slsReceiverUsers(argc, argv, ret); slsReceiverUsers *receiver = new slsReceiverUsers(argc, argv, ret);
if(ret==slsReceiverDefs::FAIL){ if(ret==slsDetectorDefs::FAIL){
delete receiver; delete receiver;
cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -140,7 +140,7 @@ int main(int argc, char *argv[]) {
//start tcp server thread //start tcp server thread
if (receiver->start() == slsReceiverDefs::FAIL){ if (receiver->start() == slsDetectorDefs::FAIL){
delete receiver; delete receiver;
cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

View File

@ -169,7 +169,7 @@ bool slsReceiverImplementation::getGapPixelsEnable() const {
} }
/***file parameters***/ /***file parameters***/
slsReceiverDefs::fileFormat slsReceiverImplementation::getFileFormat() const{ slsDetectorDefs::fileFormat slsReceiverImplementation::getFileFormat() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return fileFormatType; return fileFormatType;
} }
@ -211,7 +211,7 @@ uint32_t slsReceiverImplementation::getFramesPerFile() const{
return framesPerFile; return framesPerFile;
} }
slsReceiverDefs::frameDiscardPolicy slsReceiverImplementation::getFrameDiscardPolicy() const{ slsDetectorDefs::frameDiscardPolicy slsReceiverImplementation::getFrameDiscardPolicy() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return frameDiscardMode; return frameDiscardMode;
} }
@ -305,7 +305,7 @@ char *slsReceiverImplementation::getEthernetInterface() const{
/***acquisition parameters***/ /***acquisition parameters***/
std::vector<slsReceiverDefs::ROI> slsReceiverImplementation::getROI() const{ std::vector<slsDetectorDefs::ROI> slsReceiverImplementation::getROI() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return roi; return roi;
} }
@ -370,7 +370,7 @@ uint32_t slsReceiverImplementation::getFifoDepth() const{
} }
/***receiver status***/ /***receiver status***/
slsReceiverDefs::runStatus slsReceiverImplementation::getStatus() const{ slsDetectorDefs::runStatus slsReceiverImplementation::getStatus() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return status;} return status;}
@ -615,7 +615,7 @@ int slsReceiverImplementation::setUDPSocketBufferSize(const uint32_t s) {
/***acquisition parameters***/ /***acquisition parameters***/
int slsReceiverImplementation::setROI(const std::vector<slsReceiverDefs::ROI> i) { int slsReceiverImplementation::setROI(const std::vector<slsDetectorDefs::ROI> i) {
if (myDetectorType != GOTTHARD) { if (myDetectorType != GOTTHARD) {
cprintf(RED, "Error: Can not set ROI for this detector\n"); cprintf(RED, "Error: Can not set ROI for this detector\n");
return FAIL; return FAIL;

File diff suppressed because it is too large Load Diff

View File

@ -6,9 +6,9 @@ slsReceiverUsers::slsReceiverUsers(int argc, char *argv[], int &success) {
try { try {
slsReceiver* r = new slsReceiver(argc, argv); slsReceiver* r = new slsReceiver(argc, argv);
receiver = r; receiver = r;
success = slsReceiverDefs::OK; success = slsDetectorDefs::OK;
} catch (...) { } catch (...) {
success = slsReceiverDefs::FAIL; success = slsDetectorDefs::FAIL;
} }
} }

View File

@ -30,8 +30,24 @@ int ClientInterface::PrintSocketReadError() {
} }
void ClientInterface::Server_SendResult(int ret, void* retval, int retvalSize) { void ClientInterface::Server_SendResult(bool diffClients, int ret,
void* retval, int retvalSize, char* mess) {
// update if different clients
if (diffClients)
ret = FORCE_UPDATE;
// send success of operation
mySocket->SendDataOnly(&ret,sizeof(ret)); mySocket->SendDataOnly(&ret,sizeof(ret));
if(ret == FAIL) {
// send error message
if (mess)
mySocket->SendDataOnly(mess, MAX_STR_LENGTH);
// debugging feature. should not happen.
else
FILE_LOG(logERROR) << "No error message provided for this failure. Will mess up TCP\n";
}
// send return value
mySocket->SendDataOnly(retval, retvalSize); mySocket->SendDataOnly(retval, retvalSize);
} }

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include "MySocketTCP.h" #include "MySocketTCP.h"
@ -10,7 +10,7 @@
*/ */
// Do not overload to make it easier for manual comparison between client and server functions // Do not overload to make it easier for manual comparison between client and server functions
class ClientInterface: public virtual slsReceiverDefs{ class ClientInterface: public virtual slsDetectorDefs{
public: public:
@ -39,12 +39,14 @@ public:
int PrintSocketReadError(); int PrintSocketReadError();
/** /**
* Server sends result to client * Server sends result to client (also set ret to force_update if different clients)
* @param diffClients true if different clients, else false
* @param ret success of operation * @param ret success of operation
* @param retval pointer to result * @param retval pointer to result
* @param retvalSize size of result * @param retvalSize size of result
* @param mess message
*/ */
void Server_SendResult(int ret, void* retval, int retvalSize); void Server_SendResult(bool diffClients, int ret, void* retval, int retvalSize, char* mess = 0);
/** /**
* Get message from server * Get message from server

View File

@ -1,5 +1,11 @@
#ifndef SLS_DETECTOR_DEFS_H #pragma once
#define SLS_DETECTOR_DEFS_H /************************************************
* @file sls_detector_defs.h
* @short contains all the constants, enum definitions and enum-string conversions
***********************************************/
/**
*@short contains all the constants, enum definitions and enum-string conversions
*/
#ifdef __CINT__ #ifdef __CINT__
@ -7,10 +13,29 @@
#define __cplusplus #define __cplusplus
#endif #endif
//#include <stdint.h> #include <stdint.h>
#include "sls_receiver_defs.h" #ifdef __cplusplus
#include <bitset>
#include <string>
#endif
#include "ansi.h"
typedef double double32_t;
typedef float float32_t;
typedef int int32_t;
/** default ports */
#define DEFAULT_PORTNO 1952
#define DEFAULT_UDP_PORTNO 50001
#define DEFAULT_GUI_PORTNO 65001
#define DEFAULT_ZMQ_CL_PORTNO 30001
#define DEFAULT_ZMQ_RX_PORTNO 30001
#define SLS_DETECTOR_HEADER_VERSION 0x2
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x3
/** maximum rois */ /** maximum rois */
#define MAX_ROIS 100 #define MAX_ROIS 100
@ -20,40 +45,183 @@
/** maximum unit size of program sent to detector */ /** maximum unit size of program sent to detector */
#define MAX_FPGAPROGRAMSIZE (2 * 1024 *1024) #define MAX_FPGAPROGRAMSIZE (2 * 1024 *1024)
typedef char mystring[MAX_STR_LENGTH]; /** get flag form most functions */
#define GET_FLAG -1
#define DEFAULT_DET_MAC "00:aa:bb:cc:dd:ee" #define DEFAULT_DET_MAC "00:aa:bb:cc:dd:ee"
#define DEFAULT_DET_IP "129.129.202.46" #define DEFAULT_DET_IP "129.129.202.46"
/** default maximum string length */
/** #define MAX_STR_LENGTH 1000
\file sls_detector_defs.h #define MAX_FRAMES_PER_FILE 20000
This file contains all the basic definitions common to the slsDetector class #define SHORT_MAX_FRAMES_PER_FILE 100000
and to the server programs running on the detector #define MOENCH_MAX_FRAMES_PER_FILE 1000
#define EIGER_MAX_FRAMES_PER_FILE 10000
#define JFRAU_MAX_FRAMES_PER_FILE 10000
#define JFCTB_MAX_FRAMES_PER_FILE 100000
* @author Anna Bergamaschi #define DEFAULT_STREAMING_TIMER_IN_MS 200
* @version 0.1alpha (any string)
* @see slsDetector
*/
/** get flag form most functions */ typedef char mystring[MAX_STR_LENGTH];
#define GET_FLAG -1
#ifdef __cplusplus #ifdef __cplusplus
class slsDetectorDefs {
/** @short class containing all the structures, constants and enum definitions */
class slsDetectorDefs: public virtual slsReceiverDefs{
public: public:
slsDetectorDefs(){}; slsDetectorDefs(){};
#endif #endif
/**
Type of the detector
*/
enum detectorType {
GET_DETECTOR_TYPE=-1, /**< the detector will return its type */
GENERIC, /**< generic sls detector */
EIGER, /**< eiger */
GOTTHARD, /**< gotthard */
MOENCH, /**< moench */
JUNGFRAU, /**< jungfrau */
JUNGFRAUCTB, /**< jungfrauCTBversion */
PROPIX, /**< propix */
MYTHEN3 /**< mythen 3 */
};
/**
return values
*/
enum {
OK, /**< function succeeded */
FAIL, /**< function failed */
FINISHED, /**< acquisition finished */
FORCE_UPDATE
};
/**
indexes for the acquisition timers
*/
enum timerIndex {
FRAME_NUMBER, /**< number of real time frames: total number of acquisitions is number or frames*number of cycles */
ACQUISITION_TIME, /**< exposure time */
FRAME_PERIOD, /**< period between exposures */
DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or readout (in triggered mode) */
GATES_NUMBER, /**< number of gates per frame (in gated mode) */
CYCLES_NUMBER, /**< number of cycles: total number of acquisitions is number or frames*number of cycles */
ACTUAL_TIME, /**< Actual time of the detector's internal timer */
MEASUREMENT_TIME, /**< Time of the measurement from the detector (fifo) */
PROGRESS, /**< fraction of measurement elapsed - only get! */
MEASUREMENTS_NUMBER,
FRAMES_FROM_START,
FRAMES_FROM_START_PG,
SAMPLES_JCTB,
SUBFRAME_ACQUISITION_TIME, /**< subframe exposure time */
STORAGE_CELL_NUMBER, /**<number of storage cells */
SUBFRAME_DEADTIME, /**< subframe deadtime */
MEASURED_PERIOD, /**< measured period */
MEASURED_SUBPERIOD, /**< measured subperiod */
MAX_TIMERS
};
/**
staus mask
*/
enum runStatus {
IDLE, /**< detector ready to start acquisition - no data in memory */
ERROR, /**< error i.e. normally fifo full */
WAITING, /**< waiting for trigger or gate signal */
RUN_FINISHED, /**< acquisition not running but data in memory */
TRANSMITTING, /**< acquisition running and data in memory */
RUNNING, /**< acquisition running, no data in memory */
STOPPED /**< acquisition stopped externally */
};
/**
@short structure for a Detector Packet or Image Header
@li frameNumber is the frame number
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
@li packetNumber is the packet number
@li bunchId is the bunch id from beamline
@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 row is the row index in the complete detector system
@li column is the column index in the complete detector system
@li reserved is reserved
@li debug is for debugging purposes
@li roundRNumber is the round robin set number
@li detType is the detector type see :: detectorType
@li version is the version number of this structure format
*/
typedef struct {
uint64_t frameNumber; /**< is the frame number */
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
uint32_t packetNumber; /**< is the packet number */
uint64_t bunchId; /**< is the bunch id from beamline */
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 row; /**< is the row index in the complete detector system */
uint16_t column; /**< is the column index in the complete detector system */
uint16_t reserved; /**< is reserved */
uint32_t debug; /**< is for debugging purposes */
uint16_t roundRNumber; /**< is the round robin set number */
uint8_t detType; /**< is the detector type see :: detectorType */
uint8_t version; /**< is the version number of this structure format */
} sls_detector_header;
#ifdef __cplusplus
#define MAX_NUM_PACKETS 512
typedef std::bitset<MAX_NUM_PACKETS> sls_bitset;
typedef struct {
sls_detector_header detHeader; /**< is the detector header */
sls_bitset packetsMask; /**< is the packets caught bit mask */
} sls_receiver_header;
typedef uint8_t bitset_storage[MAX_NUM_PACKETS/8];
#endif
/**
* frameDiscardPolicy
*/
enum frameDiscardPolicy {
GET_FRAME_DISCARD_POLICY = -1, /**< to get the missing packet mode */
NO_DISCARD, /**< pad incomplete packets with -1, default mode */
DISCARD_EMPTY_FRAMES, /**< discard incomplete frames, fastest mode, save space, not suitable for multiple modules */
DISCARD_PARTIAL_FRAMES, /**< ignore missing packets, must check with packetsMask for data integrity, fast mode and suitable for multiple modules */
NUM_DISCARD_POLICIES
};
/**
format
*/
enum fileFormat {
GET_FILE_FORMAT=-1,/**< the receiver will return its file format */
BINARY, /**< binary format */
ASCII, /**< ascii format */
HDF5, /**< hdf5 format */
NUM_FILE_FORMATS
};
/**
@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 detector module @short structure for a detector module
@ -387,23 +555,337 @@ enum imageType {
}; };
//#if defined(__cplusplus) && !defined(EIGERD)
#ifdef __cplusplus
/** returns string from enabled/disabled
\param b true or false
\returns string enabled, disabled
*/
static std::string stringEnable(bool b){\
if(b) return std::string("enabled"); \
else return std::string("disabled"); \
};
/** returns detector type string from detector type index
\param t string can be EIGER, GOTTHARD, JUNGFRAU, JUNGFRAUCTB
\returns Eiger, Gotthard, Jungfrau, JungfrauCTB, Unknown
*/
static std::string getDetectorType(detectorType t){ \
switch (t) { \
case EIGER: return std::string("Eiger"); \
case GOTTHARD: return std::string("Gotthard"); \
case JUNGFRAU: return std::string("Jungfrau"); \
case JUNGFRAUCTB: return std::string("JungfrauCTB"); \
default: return std::string("Unknown"); \
}};
/** returns detector type index from detector type string
\param type can be Eiger, Gotthard, Jungfrau, JungfrauCTB
\returns EIGER, GOTTHARD, JUNGFRAU, JUNGFRAUCTB, GENERIC
*/
static detectorType getDetectorType(std::string const type){\
if (type=="Eiger") return EIGER; \
if (type=="Gotthard") return GOTTHARD; \
if (type=="Jungfrau") return JUNGFRAU; \
if (type=="JungfrauCTB") return JUNGFRAUCTB; \
return GENERIC; \
};
/** returns string from run status index
\param s can be ERROR, WAITING, RUNNING, TRANSMITTING, RUN_FINISHED, STOPPED
\returns string error, waiting, running, data, finished, stopped, idle
*/
static std::string runStatusType(runStatus s){\
switch (s) { \
case ERROR: return std::string("error"); \
case WAITING: return std::string("waiting"); \
case RUNNING: return std::string("running"); \
case TRANSMITTING: return std::string("data"); \
case RUN_FINISHED: return std::string("finished"); \
case STOPPED: return std::string("stopped"); \
default: return std::string("idle"); \
}};
/** returns string from file format index
\param s can be BINARY, ASCII, HDF5
\returns string binary, ascii, hdf5
*/
static std::string getFileFormatType(fileFormat f){\
switch (f) { \
case ASCII: return std::string("ascii"); \
case HDF5: return std::string("hdf5"); \
case BINARY: return std::string("binary"); \
default: return std::string("unknown"); \
}};
/**
* Returns string of frame discard policy index
* @param f can be NO_DISCARD, DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES
* @returns No Discard, Discard Empty Frames, Discard Partial Frames, unknown
*/
static std::string getFrameDiscardPolicyType(frameDiscardPolicy f) { \
switch (f) { \
case NO_DISCARD: return std::string("No Discard"); \
case DISCARD_EMPTY_FRAMES: return std::string("Discard Empty Frames"); \
case DISCARD_PARTIAL_FRAMES: return std::string("Discard Partial Frames"); \
default: return std::string("unknown"); \
}}; \
/** returns std::string from external signal type index
\param f can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, =TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG
\returns std::string off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, gnd, vcc, sync, unknown
*/
static std::string externalSignalType(externalSignalFlag f){\
switch(f) { \
case SIGNAL_OFF: return std::string( "off"); \
case GATE_IN_ACTIVE_HIGH: return std::string( "gate_in_active_high"); \
case GATE_IN_ACTIVE_LOW: return std::string( "gate_in_active_low"); \
case TRIGGER_IN_RISING_EDGE: return std::string( "trigger_in_rising_edge"); \
case TRIGGER_IN_FALLING_EDGE: return std::string( "trigger_in_falling_edge"); \
case RO_TRIGGER_IN_RISING_EDGE: return std::string( "ro_trigger_in_rising_edge"); \
case RO_TRIGGER_IN_FALLING_EDGE: return std::string( "ro_trigger_in_falling_edge"); \
case GATE_OUT_ACTIVE_HIGH: return std::string( "gate_out_active_high"); \
case GATE_OUT_ACTIVE_LOW: return std::string( "gate_out_active_low"); \
case TRIGGER_OUT_RISING_EDGE: return std::string( "trigger_out_rising_edge"); \
case TRIGGER_OUT_FALLING_EDGE: return std::string( "trigger_out_falling_edge"); \
case RO_TRIGGER_OUT_RISING_EDGE: return std::string( "ro_trigger_out_rising_edge"); \
case RO_TRIGGER_OUT_FALLING_EDGE: return std::string( "ro_trigger_out_falling_edge"); \
case MASTER_SLAVE_SYNCHRONIZATION: return std::string("sync"); \
case OUTPUT_LOW: return std::string("gnd"); \
case OUTPUT_HIGH: return std::string("vcc"); \
default: return std::string( "unknown"); \
} };
/** returns external signal type index from std::string
\param sval off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, gnd, vcc, sync, unknown
\returns can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG (if unknown)
*/
static externalSignalFlag externalSignalType(std::string sval){\
if (sval=="off") return SIGNAL_OFF;\
if (sval=="gate_in_active_high") return GATE_IN_ACTIVE_HIGH; \
if (sval=="gate_in_active_low") return GATE_IN_ACTIVE_LOW;\
if (sval=="trigger_in_rising_edge") return TRIGGER_IN_RISING_EDGE;\
if (sval=="trigger_in_falling_edge") return TRIGGER_IN_FALLING_EDGE;\
if (sval=="ro_trigger_in_rising_edge") return RO_TRIGGER_IN_RISING_EDGE;\
if (sval=="ro_trigger_in_falling_edge") return RO_TRIGGER_IN_FALLING_EDGE;\
if (sval=="gate_out_active_high") return GATE_OUT_ACTIVE_HIGH;\
if (sval=="gate_out_active_low") return GATE_OUT_ACTIVE_LOW;\
if (sval=="trigger_out_rising_edge") return TRIGGER_OUT_RISING_EDGE;\
if (sval=="trigger_out_falling_edge") return TRIGGER_OUT_FALLING_EDGE;\
if (sval=="ro_trigger_out_rising_edge") return RO_TRIGGER_OUT_RISING_EDGE;\
if (sval=="ro_trigger_out_falling_edge") return RO_TRIGGER_OUT_FALLING_EDGE;\
if (sval=="sync") return MASTER_SLAVE_SYNCHRONIZATION;\
if (sval=="gnd") return OUTPUT_LOW;\
if (sval=="vcc") return OUTPUT_HIGH;\
return GET_EXTERNAL_SIGNAL_FLAG ;};
/** returns detector settings std::string from index
\param s can be STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, LOWNOISE,
DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2, GET_SETTINGS
\returns standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, lownoise,
dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2, verylowgain, undefined
*/
static std::string getDetectorSettings(detectorSettings s){\
switch(s) { \
case STANDARD: return std::string("standard"); \
case FAST: return std::string("fast"); \
case HIGHGAIN: return std::string("highgain"); \
case DYNAMICGAIN: return std::string("dynamicgain"); \
case LOWGAIN: return std::string("lowgain"); \
case MEDIUMGAIN: return std::string("mediumgain"); \
case VERYHIGHGAIN: return std::string("veryhighgain"); \
case LOWNOISE: return std::string("lownoise"); \
case DYNAMICHG0: return std::string("dynamichg0"); \
case FIXGAIN1: return std::string("fixgain1"); \
case FIXGAIN2: return std::string("fixgain2"); \
case FORCESWITCHG1: return std::string("forceswitchg1");\
case FORCESWITCHG2: return std::string("forceswitchg2");\
case VERYLOWGAIN: return std::string("verylowgain");\
default: return std::string("undefined"); \
}};
/** returns detector settings std::string from index
\param s can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, lownoise,
dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2, undefined
\returns setting index STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN,LOWNOISE,
DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2, VERYLOWGAIN, GET_SETTINGS
*/
static detectorSettings getDetectorSettings(std::string s){ \
if (s=="standard") return STANDARD; \
if (s=="fast") return FAST; \
if (s=="highgain") return HIGHGAIN; \
if (s=="dynamicgain") return DYNAMICGAIN; \
if (s=="lowgain") return LOWGAIN; \
if (s=="mediumgain") return MEDIUMGAIN; \
if (s=="veryhighgain") return VERYHIGHGAIN; \
if (s=="lownoise") return LOWNOISE; \
if (s=="dynamichg0") return DYNAMICHG0; \
if (s=="fixgain1") return FIXGAIN1; \
if (s=="fixgain2") return FIXGAIN2; \
if (s=="forceswitchg1") return FORCESWITCHG1; \
if (s=="forceswitchg2") return FORCESWITCHG2; \
if (s=="verylowgain") return VERYLOWGAIN; \
return GET_SETTINGS; \
};
/**
returns external communication mode std::string from index
\param f can be AUTO_TIMING, TRIGGER_EXPOSURE, TRIGGER_READOUT, GATE_FIX_NUMBER, GATE_WITH_START_TRIGGER, BURST_TRIGGER, GET_EXTERNAL_COMMUNICATION_MODE
\returns auto, trigger, ro_trigger, gating, triggered_gating, unknown
*/
static std::string externalCommunicationType(externalCommunicationMode f){ \
switch(f) { \
case AUTO_TIMING: return std::string( "auto"); \
case TRIGGER_EXPOSURE: return std::string("trigger"); \
case TRIGGER_READOUT: return std::string("ro_trigger"); \
case GATE_FIX_NUMBER: return std::string("gating"); \
case GATE_WITH_START_TRIGGER: return std::string("triggered_gating"); \
case BURST_TRIGGER: return std::string("burst_trigger"); \
default: return std::string( "unknown"); \
} };
/**
returns external communication mode index from std::string
\param sval can be auto, trigger, ro_trigger, gating, triggered_gating
\returns AUTO_TIMING, TRIGGER_EXPOSURE, TRIGGER_READOUT, GATE_FIX_NUMBER, GATE_WITH_START_TRIGGER, BURST_TRIGGER, GET_EXTERNAL_COMMUNICATION_MODE
*/
static externalCommunicationMode externalCommunicationType(std::string sval){\
if (sval=="auto") return AUTO_TIMING;\
if (sval=="trigger") return TRIGGER_EXPOSURE; \
if (sval=="ro_trigger") return TRIGGER_READOUT;\
if (sval=="gating") return GATE_FIX_NUMBER;\
if (sval=="triggered_gating") return GATE_WITH_START_TRIGGER;\
if (sval=="burst_trigger") return BURST_TRIGGER;\
return GET_EXTERNAL_COMMUNICATION_MODE; \
};
/** returns std::string from file format index
\param s can be RAW, HDF5
\returns std::string raw, hdf5
*/
static std::string fileFormats(fileFormat f){\
switch (f) { \
case BINARY: return std::string("binary"); \
case ASCII: return std::string("ascii"); \
case HDF5: return std::string("hdf5"); \
default: return std::string("unknown"); \
}};
/** returns std::string from timer index
\param s can be FRAME_NUMBER,ACQUISITION_TIME,FRAME_PERIOD, DELAY_AFTER_TRIGGER,GATES_NUMBER, CYCLES_NUMBER, ACTUAL_TIME,MEASUREMENT_TIME, PROGRESS,MEASUREMENTS_NUMBER,FRAMES_FROM_START,FRAMES_FROM_START_PG,SAMPLES_JCTB,SUBFRAME_ACQUISITION_TIME,STORAGE_CELL_NUMBER, SUBFRAME_DEADTIME
\returns std::string frame_number,acquisition_time,frame_period, delay_after_trigger,gates_number, cycles_number, actual_time,measurement_time, progress,measurements_number,frames_from_start,frames_from_start_pg,samples_jctb,subframe_acquisition_time,storage_cell_number, SUBFRAME_DEADTIME
*/
static std::string getTimerType(timerIndex t){ \
switch (t) { \
case FRAME_NUMBER: return std::string("frame_number"); \
case ACQUISITION_TIME: return std::string("acquisition_time"); \
case FRAME_PERIOD: return std::string("frame_period"); \
case DELAY_AFTER_TRIGGER: return std::string("delay_after_trigger"); \
case GATES_NUMBER: return std::string("gates_number"); \
case CYCLES_NUMBER: return std::string("cycles_number"); \
case ACTUAL_TIME: return std::string("actual_time"); \
case MEASUREMENT_TIME: return std::string("measurement_time"); \
case PROGRESS: return std::string("progress"); \
case MEASUREMENTS_NUMBER: return std::string("measurements_number"); \
case FRAMES_FROM_START: return std::string("frames_from_start"); \
case FRAMES_FROM_START_PG: return std::string("frames_from_start_pg"); \
case SAMPLES_JCTB: return std::string("samples_jctb"); \
case SUBFRAME_ACQUISITION_TIME: return std::string("subframe_acquisition_time"); \
case SUBFRAME_DEADTIME: return std::string("subframe_deadtime"); \
case STORAGE_CELL_NUMBER: return std::string("storage_cell_number"); \
default: return std::string("unknown"); \
}};
/**
@short returns adc index from std::string
\param s can be temp_fpga, temp_fpgaext, temp_10ge, temp_dcdc, temp_sodl, temp_sodr, temp_fpgafl, temp_fpgafr
\returns TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT, TEMPERATURE_10GE, TEMPERATURE_DCDC, TEMPERATURE_SODL,
TEMPERATURE_SODR, TEMPERATURE_FPGA2, TEMPERATURE_FPGA3, -1 when unknown mode
*/
static int getADCIndex(std::string s){ \
if (s=="temp_fpga") return TEMPERATURE_FPGA; \
if (s=="temp_fpgaext") return TEMPERATURE_FPGAEXT; \
if (s=="temp_10ge") return TEMPERATURE_10GE; \
if (s=="temp_dcdc") return TEMPERATURE_DCDC; \
if (s=="temp_sodl") return TEMPERATURE_SODL; \
if (s=="temp_sodr") return TEMPERATURE_SODR; \
if (s=="temp_fpgafl") return TEMPERATURE_FPGA2; \
if (s=="temp_fpgafr") return TEMPERATURE_FPGA3; \
return -1; \
}; \
/**
@short returns dac index from std::string
\param s can be vcmp_ll, vcmp_lr, vcmp_rl, vcmp_rr, vthreshold, vrf, vrs, vtr, vcall, vcp
\returns E_Vcmp_ll, E_Vcmp_lr, E_Vcmp_rl, E_Vcmp_rr, THRESHOLD, E_Vrf, E_Vrs, E_Vtr, E_cal, E_Vcp , -1 when unknown mode
*/
static int getDACIndex(std::string s){ \
if (s=="vcmp_ll") return E_Vcmp_ll; \
if (s=="vcmp_lr") return E_Vcmp_lr; \
if (s=="vcmp_rl") return E_Vcmp_rl; \
if (s=="vcmp_rr") return E_Vcmp_rr; \
if (s=="vthreshold") return THRESHOLD; \
if (s=="vrf") return E_Vrf; \
if (s=="vrs") return E_Vrs; \
if (s=="vtr") return E_Vtr; \
if (s=="vcall") return E_cal; \
if (s=="vcp") return E_Vcp; \
return -1; \
}; \
/**
@short returns receiver frame discard policy from std::string
\param s can be nodiscard, discardempty, discardpartial
\returns NO_DISCARD, DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES, GET_FRAME_DISCARD_POLICY when unknown mode
*/
static frameDiscardPolicy getReceiverFrameDiscardPolicy(std::string s){ \
if (s=="nodiscard") return NO_DISCARD; \
if (s=="discardempty") return DISCARD_EMPTY_FRAMES; \
if (s=="discardpartial") return DISCARD_PARTIAL_FRAMES; \
return GET_FRAME_DISCARD_POLICY; \
}; \
/** returns std::string from frame discard policy
\param f can be NO_DISCARD, DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES
\returns std::string nodiscard, discardempty, discardpartial, unknown
*/
static std::string getReceiverFrameDiscardPolicy(frameDiscardPolicy f){ \
switch (f) { \
case NO_DISCARD: return std::string("nodiscard"); \
case DISCARD_EMPTY_FRAMES: return std::string("discardempty"); \
case DISCARD_PARTIAL_FRAMES: return std::string("discardpartial"); \
default: return std::string("unknown"); \
}}; \
#endif
#ifdef __cplusplus #ifdef __cplusplus
protected: protected:
#endif #endif
#ifndef MYROOT #ifndef MYROOT
#include "sls_detector_funcs.h" #include "sls_detector_funcs.h"
//#include "sls_receiver_funcs.h" #include "sls_receiver_funcs.h"
#endif #endif
//#if defined(__cplusplus) && !defined(EIGERD)
#ifdef __cplusplus #ifdef __cplusplus
}; };
#endif #endif
; ;
#endif
;

View File

@ -1,312 +0,0 @@
#pragma once
#ifdef __CINT__
#define MYROOT
#define __cplusplus
#endif
#include <stdint.h>
#ifdef __cplusplus
#include <bitset>
#include <string>
#endif
#include "ansi.h"
typedef double double32_t;
typedef float float32_t;
typedef int int32_t;
/** default maximum string length */
#define MAX_STR_LENGTH 1000
#define MAX_FRAMES_PER_FILE 20000
#define SHORT_MAX_FRAMES_PER_FILE 100000
#define MOENCH_MAX_FRAMES_PER_FILE 1000
#define EIGER_MAX_FRAMES_PER_FILE 10000
#define JFRAU_MAX_FRAMES_PER_FILE 10000
#define JFCTB_MAX_FRAMES_PER_FILE 100000
#define DEFAULT_STREAMING_TIMER_IN_MS 200
/** default ports */
#define DEFAULT_PORTNO 1952
#define DEFAULT_UDP_PORTNO 50001
#define DEFAULT_GUI_PORTNO 65001
#define DEFAULT_ZMQ_CL_PORTNO 30001
#define DEFAULT_ZMQ_RX_PORTNO 30001
#define SLS_DETECTOR_HEADER_VERSION 0x2
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x3
/**
\file sls_receiver_defs.h
This file contains all the basic definitions common to the slsReceiver class
and to the server programs running on the receiver
* @author Anna Bergamaschi
* @version 0.1alpha (any string)
* @see slsDetector
$Revision: 809 $
*/
#ifdef __cplusplus
/** @short class containing all the constants and enum definitions */
class slsReceiverDefs {
public:
slsReceiverDefs(){};
#endif
/**
Type of the detector
*/
enum detectorType {
GET_DETECTOR_TYPE=-1, /**< the detector will return its type */
GENERIC, /**< generic sls detector */
EIGER, /**< eiger */
GOTTHARD, /**< gotthard */
MOENCH, /**< moench */
JUNGFRAU, /**< jungfrau */
JUNGFRAUCTB, /**< jungfrauCTBversion */
PROPIX, /**< propix */
MYTHEN3 /**< mythen 3 */
};
/**
return values
*/
enum {
OK, /**< function succeeded */
FAIL, /**< function failed */
FINISHED, /**< acquisition finished */
FORCE_UPDATE
};
/**
indexes for the acquisition timers
*/
enum timerIndex {
FRAME_NUMBER, /**< number of real time frames: total number of acquisitions is number or frames*number of cycles */
ACQUISITION_TIME, /**< exposure time */
FRAME_PERIOD, /**< period between exposures */
DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or readout (in triggered mode) */
GATES_NUMBER, /**< number of gates per frame (in gated mode) */
CYCLES_NUMBER, /**< number of cycles: total number of acquisitions is number or frames*number of cycles */
ACTUAL_TIME, /**< Actual time of the detector's internal timer */
MEASUREMENT_TIME, /**< Time of the measurement from the detector (fifo) */
PROGRESS, /**< fraction of measurement elapsed - only get! */
MEASUREMENTS_NUMBER,
FRAMES_FROM_START,
FRAMES_FROM_START_PG,
SAMPLES_JCTB,
SUBFRAME_ACQUISITION_TIME, /**< subframe exposure time */
STORAGE_CELL_NUMBER, /**<number of storage cells */
SUBFRAME_DEADTIME, /**< subframe deadtime */
MEASURED_PERIOD, /**< measured period */
MEASURED_SUBPERIOD, /**< measured subperiod */
MAX_TIMERS
};
/**
staus mask
*/
enum runStatus {
IDLE, /**< detector ready to start acquisition - no data in memory */
ERROR, /**< error i.e. normally fifo full */
WAITING, /**< waiting for trigger or gate signal */
RUN_FINISHED, /**< acquisition not running but data in memory */
TRANSMITTING, /**< acquisition running and data in memory */
RUNNING, /**< acquisition running, no data in memory */
STOPPED /**< acquisition stopped externally */
};
/**
@short structure for a Detector Packet or Image Header
@li frameNumber is the frame number
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
@li packetNumber is the packet number
@li bunchId is the bunch id from beamline
@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 row is the row index in the complete detector system
@li column is the column index in the complete detector system
@li reserved is reserved
@li debug is for debugging purposes
@li roundRNumber is the round robin set number
@li detType is the detector type see :: detectorType
@li version is the version number of this structure format
*/
typedef struct {
uint64_t frameNumber; /**< is the frame number */
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
uint32_t packetNumber; /**< is the packet number */
uint64_t bunchId; /**< is the bunch id from beamline */
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 row; /**< is the row index in the complete detector system */
uint16_t column; /**< is the column index in the complete detector system */
uint16_t reserved; /**< is reserved */
uint32_t debug; /**< is for debugging purposes */
uint16_t roundRNumber; /**< is the round robin set number */
uint8_t detType; /**< is the detector type see :: detectorType */
uint8_t version; /**< is the version number of this structure format */
} sls_detector_header;
#ifdef __cplusplus
#define MAX_NUM_PACKETS 512
typedef std::bitset<MAX_NUM_PACKETS> sls_bitset;
typedef struct {
sls_detector_header detHeader; /**< is the detector header */
sls_bitset packetsMask; /**< is the packets caught bit mask */
} sls_receiver_header;
typedef uint8_t bitset_storage[MAX_NUM_PACKETS/8];
#endif
/**
* frameDiscardPolicy
*/
enum frameDiscardPolicy {
GET_FRAME_DISCARD_POLICY = -1, /**< to get the missing packet mode */
NO_DISCARD, /**< pad incomplete packets with -1, default mode */
DISCARD_EMPTY_FRAMES, /**< discard incomplete frames, fastest mode, save space, not suitable for multiple modules */
DISCARD_PARTIAL_FRAMES, /**< ignore missing packets, must check with packetsMask for data integrity, fast mode and suitable for multiple modules */
NUM_DISCARD_POLICIES
};
/**
format
*/
enum fileFormat {
GET_FILE_FORMAT=-1,/**< the receiver will return its file format */
BINARY, /**< binary format */
ASCII, /**< ascii format */
HDF5, /**< hdf5 format */
NUM_FILE_FORMATS
};
/**
@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
/** returns string from enabled/disabled
\param b true or false
\returns string enabled, disabled
*/
static std::string stringEnable(bool b){\
if(b) return std::string("enabled"); \
else return std::string("disabled"); \
};
/** returns detector type string from detector type index
\param t string can be Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown
\returns MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, MÖNCH, GENERIC
*/
static std::string getDetectorType(detectorType t){ \
switch (t) { \
case EIGER: return std::string("Eiger"); \
case GOTTHARD: return std::string("Gotthard"); \
case MOENCH: return std::string("Moench"); \
case JUNGFRAU: return std::string("Jungfrau"); \
case JUNGFRAUCTB: return std::string("JungfrauCTB"); \
case PROPIX: return std::string("Propix"); \
case MYTHEN3: return std::string("Mythen3"); \
default: return std::string("Unknown"); \
}};
/** returns detector type index from detector type string
\param type can be MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC
\returns Mythen, Pilatus, Eiger, Gotthard, Agipd, Mönch, Unknown
*/
static detectorType getDetectorType(std::string const type){\
if (type=="Eiger") return EIGER; \
if (type=="Gotthard") return GOTTHARD; \
if (type=="Moench") return MOENCH; \
if (type=="Jungfrau") return JUNGFRAU; \
if (type=="JungfrauCTB") return JUNGFRAUCTB; \
if (type=="Propix") return PROPIX; \
if (type=="Mythen3") return MYTHEN3; \
return GENERIC; \
};
/** returns string from run status index
\param s can be ERROR, WAITING, RUNNING, TRANSMITTING, RUN_FINISHED
\returns string error, waiting, running, data, finished
*/
static std::string runStatusType(runStatus s){\
switch (s) { \
case ERROR: return std::string("error"); \
case WAITING: return std::string("waiting"); \
case RUNNING: return std::string("running"); \
case TRANSMITTING: return std::string("data"); \
case RUN_FINISHED: return std::string("finished"); \
case STOPPED: return std::string("stopped"); \
default: return std::string("idle"); \
}};
/** returns string from file format index
\param s can be BINARY, ASCII, HDF5
\returns string binary, ascii, hdf5
*/
static std::string getFileFormatType(fileFormat f){\
switch (f) { \
case ASCII: return std::string("ascii"); \
case HDF5: return std::string("hdf5"); \
case BINARY: return std::string("binary"); \
default: return std::string("unknown"); \
}};
/**
* Returns string of frame discard policy index
* @param f can be NO_DISCARD, DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES
* @returns No Discard, Discard Empty Frames, Discard Partial Frames, unknown
*/
static std::string getFrameDiscardPolicyType(frameDiscardPolicy f) { \
switch (f) { \
case NO_DISCARD: return std::string("No Discard"); \
case DISCARD_EMPTY_FRAMES: return std::string("Discard Empty Frames"); \
case DISCARD_PARTIAL_FRAMES: return std::string("Discard Partial Frames"); \
default: return std::string("unknown"); \
}}; \
#endif
#ifdef __cplusplus
protected:
#endif
#ifndef MYROOT
#include "sls_receiver_funcs.h"
#endif
#ifdef __cplusplus
};
#endif
;

View File

@ -13,7 +13,7 @@ int read_config_file(std::string fname, int *tcpip_port_no,
std::ifstream infile; std::ifstream infile;
std::string sLine,sargname, sargvalue; std::string sLine,sargname, sargvalue;
int iline = 0; int iline = 0;
int success = slsReceiverDefs::OK; int success = slsDetectorDefs::OK;
FILE_LOG(logINFO) << "config file name " << fname; FILE_LOG(logINFO) << "config file name " << fname;
@ -21,10 +21,10 @@ int read_config_file(std::string fname, int *tcpip_port_no,
infile.open(fname.c_str(), std::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 = slsDetectorDefs::FAIL;
} }
if (success == slsReceiverDefs::OK && infile.is_open()) { if (success == slsDetectorDefs::OK && infile.is_open()) {
while(infile.good()){ while(infile.good()){
getline(infile,sLine); getline(infile,sLine);
iline++; iline++;
@ -58,7 +58,7 @@ int read_config_file(std::string fname, int *tcpip_port_no,
cprintf(RESET, "dataport: %d\n" , *tcpip_port_no); cprintf(RESET, "dataport: %d\n" , *tcpip_port_no);
else{ else{
cprintf(RED, "could not decode port in config file. Exiting.\n"); cprintf(RED, "could not decode port in config file. Exiting.\n");
success = slsReceiverDefs::FAIL; success = slsDetectorDefs::FAIL;
} }
} }
} }
@ -120,25 +120,25 @@ int readDataFile(std::string fname, short int *data, int nch) {
int writeDataFile(std::ofstream &outfile,int nch, short int *data, int offset) { int writeDataFile(std::ofstream &outfile,int nch, short int *data, int offset) {
if (data==NULL) if (data==NULL)
return slsReceiverDefs::FAIL; return slsDetectorDefs::FAIL;
for (int ichan=0; ichan<nch; ichan++) for (int ichan=0; ichan<nch; ichan++)
outfile << ichan+offset << " " << *(data+ichan) << std::endl; outfile << ichan+offset << " " << *(data+ichan) << std::endl;
return slsReceiverDefs::OK; return slsDetectorDefs::OK;
} }
int writeDataFile(std::string fname,int nch, short int *data) { int writeDataFile(std::string fname,int nch, short int *data) {
std::ofstream outfile; std::ofstream outfile;
if (data==NULL) if (data==NULL)
return slsReceiverDefs::FAIL; return slsDetectorDefs::FAIL;
outfile.open (fname.c_str(),std::ios_base::out); outfile.open (fname.c_str(),std::ios_base::out);
if (outfile.is_open()) { if (outfile.is_open()) {
writeDataFile(outfile, nch, data, 0); writeDataFile(outfile, nch, data, 0);
outfile.close(); outfile.close();
return slsReceiverDefs::OK; return slsDetectorDefs::OK;
} else { } else {
FILE_LOG(logERROR) << "Could not open file " << fname << "for writing"; FILE_LOG(logERROR) << "Could not open file " << fname << "for writing";
return slsReceiverDefs::FAIL; return slsDetectorDefs::FAIL;
} }
} }

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "sls_receiver_defs.h" #include "sls_detector_defs.h"
#include <string> #include <string>
#include <map> #include <map>