diff --git a/RELEASE.txt b/RELEASE.txt index 6c604c6f5..e69de29bb 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -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 - - 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 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. - - - diff --git a/manual/manual-api/mainReceiver.cpp b/manual/manual-api/mainReceiver.cpp index 469eb8a4c..f59cccae0 100644 --- a/manual/manual-api/mainReceiver.cpp +++ b/manual/manual-api/mainReceiver.cpp @@ -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 @@ -96,8 +96,8 @@ void AcquisitionFinished(uint64_t frames, void*p){ * @param p pointer to object */ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){ - slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata; - slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader; + slsDetectorDefs::sls_receiver_header* header = (slsDetectorDefs::sls_receiver_header*)metadata; + slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader; PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row, "#### %d GetData: ####\n" @@ -130,8 +130,8 @@ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){ * @param p pointer to object */ void GetData(char* metadata, char* datapointer, uint32_t &revDatasize, void* p){ - slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata; - slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader; + slsDetectorDefs::sls_receiver_header* header = (slsDetectorDefs::sls_receiver_header*)metadata; + slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader; PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row, "#### %d GetData: ####\n" @@ -221,10 +221,10 @@ int main(int argc, char *argv[]) { char temp[10]; sprintf(temp,"%d",startTCPPort + i); char* args[] = {(char*)"ignored", (char*)"--rx_tcpport", temp}; - int ret = slsReceiverDefs::OK; + int ret = slsDetectorDefs::OK; /** - create slsReceiverUsers object with appropriate arguments */ slsReceiverUsers *receiver = new slsReceiverUsers(3, args, ret); - if(ret==slsReceiverDefs::FAIL){ + if(ret==slsDetectorDefs::FAIL){ delete receiver; exit(EXIT_FAILURE); } @@ -251,7 +251,7 @@ int main(int argc, char *argv[]) { /** - start tcp server thread */ - if (receiver->start() == slsReceiverDefs::FAIL){ + if (receiver->start() == slsDetectorDefs::FAIL){ delete receiver; cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); exit(EXIT_FAILURE); diff --git a/slsDetectorGui/client/Makefile b/slsDetectorGui/client/Makefile index 2ec55c328..beb79cdea 100644 --- a/slsDetectorGui/client/Makefile +++ b/slsDetectorGui/client/Makefile @@ -2,12 +2,10 @@ CC = g++ CLAGS += -DVERBOSE #VERYBOSE LDLIBS += -lm -lstdc++ -pthread -LDIR = ../../slsDetectorSoftware -RDIR = ../../slsReceiverSoftware DDIR = ../../bin -INCLUDES = -I ../../slsSupportLib/include -I $(LDIR)/slsDetector -I ../include -I $(RDIR)/include +INCLUDES = -I ../../slsSupportLib/include -I ../include 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 diff --git a/slsDetectorGui/client/qClient.cpp b/slsDetectorGui/client/qClient.cpp index f12ced4e1..a20e5288f 100644 --- a/slsDetectorGui/client/qClient.cpp +++ b/slsDetectorGui/client/qClient.cpp @@ -8,7 +8,6 @@ #include "qClient.h" // Project Class Headers #include "MySocketTCP.h" -#include "slsDetectorBase.h" // C++ Include Headers #include @@ -166,7 +165,7 @@ string qClient::getStatus(){ sprintf(answer,"%d%% ",progress); - strcat(answer,slsDetectorBase::runStatusType((runStatus)retval).c_str()); + strcat(answer,slsDetectorDefs::runStatusType((runStatus)retval).c_str()); return string(answer); } diff --git a/slsDetectorGui/slsDetectorGui.pro b/slsDetectorGui/slsDetectorGui.pro index e286dde6b..e91bfa219 100644 --- a/slsDetectorGui/slsDetectorGui.pro +++ b/slsDetectorGui/slsDetectorGui.pro @@ -146,7 +146,6 @@ HEADERS = \ include/qTabMessages.h\ include/gitInfoGui.h\ ../slsSupportLib/include/sls_detector_defs.h\ - ../slsReceiverSoftware/include/sls_receiver_defs.h\ include/qServer.h diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index c2f6013a3..3e51fd452 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -291,7 +291,7 @@ void qDetectorMain::SetUpDetector(const string fName){ actionLoadTrimbits->setText("Load Settings"); actionSaveTrimbits->setText("Save Settings"); break; default: - string detName = myDet->slsDetectorBase::getDetectorType(detType); + string detName = myDet->slsDetectorDefs::getDetectorType(detType); qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector"); cout << "ERROR: " + host + " has unknown detector type \"" + detName + "\". Exiting GUI." << endl; string errorMess = host+string(" has unknown detector type \"")+ @@ -300,9 +300,9 @@ void qDetectorMain::SetUpDetector(const string fName){ exit(-1); } 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 - cout << endl << "Type : " << slsDetectorBase::getDetectorType(detType) << "\nDetector : " << host << endl; + cout << endl << "Type : " << slsDetectorDefs::getDetectorType(detType) << "\nDetector : " << host << endl; //#endif myDet->setOnline(slsDetectorDefs::ONLINE_FLAG); if(detType != slsDetectorDefs::MYTHEN) diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 87492eeea..c997bad99 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -1300,7 +1300,7 @@ int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){ #ifdef VERBOSE cout << "\nEntering Acquisition Finished with status " ; #endif - QString status = QString(slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str()); + QString status = QString(slsDetectorDefs::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str()); #ifdef VERBOSE cout << status.toAscii().constData() << " and progress " << currentProgress << endl; #endif diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp index 616d2ed4d..486a86bd0 100644 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -222,7 +222,7 @@ void qTabAdvanced::SetupWidgetWindow(){ #endif // jungfrau - if (detType == slsReceiverDefs::JUNGFRAU) { + if (detType == slsDetectorDefs::JUNGFRAU) { lblNumStoragecells->setEnabled(true); spinNumStoragecells->setEnabled(true); spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); @@ -327,7 +327,7 @@ void qTabAdvanced::Initialization(){ connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(setROI())); } - if(detType == slsReceiverDefs::JUNGFRAU) { + if(detType == slsDetectorDefs::JUNGFRAU) { connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); } else if (detType == slsDetectorDefs::EIGER) { //Exposure Time @@ -1581,14 +1581,14 @@ void qTabAdvanced::Refresh(){ updateAllTrimbitsFromServer(); // storage cells - if (detType == slsReceiverDefs::JUNGFRAU) { + if (detType == slsDetectorDefs::JUNGFRAU) { disconnect(spinNumStoragecells,SIGNAL(valueChanged(int)),this, SLOT(SetNumStoragecells(int))); spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); connect(spinNumStoragecells,SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); } // sub exptime and sub period - else if (detType == slsReceiverDefs::EIGER) { + else if (detType == slsDetectorDefs::EIGER) { disconnect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); disconnect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubExposureTime())); disconnect(spinSubPeriod,SIGNAL(valueChanged(double)), this, SLOT(SetSubPeriod())); diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp index 1f38edb5e..afea98b82 100644 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -878,19 +878,19 @@ void qTabDataOutput::SetupFileFormat(){ //To be able to index items on a combo box QStandardItemModel* model = qobject_cast(comboFileFormat->model()); - QModelIndex index[slsReceiverDefs::NUM_FILE_FORMATS]; - QStandardItem* item[slsReceiverDefs::NUM_FILE_FORMATS]; + QModelIndex index[slsDetectorDefs::NUM_FILE_FORMATS]; + QStandardItem* item[slsDetectorDefs::NUM_FILE_FORMATS]; if (model) { - for(int i=0;iindex(i, comboFileFormat->modelColumn(), comboFileFormat->rootModelIndex()); item[i] = model->itemFromIndex(index[i]); } //Enabling/Disabling depending on the detector type switch(detType){ case slsDetectorDefs::MYTHEN: - item[(int)slsReceiverDefs::BINARY]->setEnabled(false); - item[(int)slsReceiverDefs::ASCII]->setEnabled(true); - item[(int)slsReceiverDefs::HDF5]->setEnabled(false); + item[(int)slsDetectorDefs::BINARY]->setEnabled(false); + item[(int)slsDetectorDefs::ASCII]->setEnabled(true); + item[(int)slsDetectorDefs::HDF5]->setEnabled(false); break; case slsDetectorDefs::EIGER: case slsDetectorDefs::MOENCH: @@ -898,9 +898,9 @@ void qTabDataOutput::SetupFileFormat(){ case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAUCTB: - item[(int)slsReceiverDefs::BINARY]->setEnabled(true); - item[(int)slsReceiverDefs::ASCII]->setEnabled(false); - item[(int)slsReceiverDefs::HDF5]->setEnabled(true); + item[(int)slsDetectorDefs::BINARY]->setEnabled(true); + item[(int)slsDetectorDefs::ASCII]->setEnabled(false); + item[(int)slsDetectorDefs::HDF5]->setEnabled(true); break; default: cout << "Unknown detector type " << endl; @@ -938,7 +938,7 @@ void qTabDataOutput::SetFileFormat(int format){ #endif 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()) { qDefs::Message(qDefs::WARNING,"Could not set file format.","qTabDataOutput::SetFileFormat"); comboFileFormat->setCurrentIndex((int)ret); diff --git a/slsDetectorGui/src/qTabDebugging.cpp b/slsDetectorGui/src/qTabDebugging.cpp index 46b861052..66fe8ff4c 100644 --- a/slsDetectorGui/src/qTabDebugging.cpp +++ b/slsDetectorGui/src/qTabDebugging.cpp @@ -165,7 +165,7 @@ void qTabDebugging::UpdateStatus(){ det = myDet->getSlsDetector(comboDetector->currentIndex()); qDefs::checkErrorMessage(myDet,"qTabDebugging::UpdateStatus"); 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()); qDefs::checkErrorMessage(det,"qTabDebugging::UpdateStatus"); diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp index 8f60f659b..af10d1fd6 100644 --- a/slsDetectorGui/src/qTabDeveloper.cpp +++ b/slsDetectorGui/src/qTabDeveloper.cpp @@ -165,8 +165,8 @@ void qTabDeveloper::SetupWidgetWindow() { break; default: - cout << "ERROR: Unknown detector type: " + myDet->slsDetectorBase::getDetectorType(detType) << endl; - qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorBase::getDetectorType(detType),"qTabDeveloper::SetupWidgetWindow"); + cout << "ERROR: Unknown detector type: " + myDet->slsDetectorDefs::getDetectorType(detType) << endl; + qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorDefs::getDetectorType(detType),"qTabDeveloper::SetupWidgetWindow"); exit(-1); break; } @@ -493,8 +493,8 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index){ } break; default: - cout << "Unknown detector type:" + myDet->slsDetectorBase::getDetectorType(detType) << endl; - qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorBase::getDetectorType(detType),"qTabDeveloper::getSLSIndex"); + cout << "Unknown detector type:" + myDet->slsDetectorDefs::getDetectorType(detType) << endl; + qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorDefs::getDetectorType(detType),"qTabDeveloper::getSLSIndex"); qDefs::checkErrorMessage(myDet,"qTabDeveloper::getSLSIndex"); exit(-1); break; diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index caa3995c9..c142577c9 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -634,7 +634,7 @@ void qTabMeasurement::SetTimingMode(int mode){ spinNumTriggers->setValue(1); spinNumFrames->setValue(1); 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) success = true; break; @@ -713,7 +713,7 @@ void qTabMeasurement::SetTimingMode(int mode){ "Number of Frames \t: 1\nNumber of Triggers \t: 1","qTabMeasurement::SetTimingMode"); spinNumFrames->setValue(1); spinNumTriggers->setValue(1); - if (detType == slsReceiverDefs::JUNGFRAU) + if (detType == slsDetectorDefs::JUNGFRAU) myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, 0); comboTimingMode->setCurrentIndex((int)None); return; diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index aa3849f4e..c2e226052 100644 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -38,7 +38,7 @@ void qTabSettings::SetupWidgetWindow(){ detType=myDet->getDetectorsType(); // Settings - if (detType != slsReceiverDefs::JUNGFRAUCTB) { + if (detType != slsDetectorDefs::JUNGFRAUCTB) { SetupDetectorSettings(); } else comboSettings->setEnabled(false); @@ -210,7 +210,7 @@ void qTabSettings::SetupDetectorSettings(){ void qTabSettings::Initialization(){ // Settings - if (detType != slsReceiverDefs::JUNGFRAUCTB) + if (detType != slsDetectorDefs::JUNGFRAUCTB) connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); // Number of Modules connect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); @@ -238,7 +238,7 @@ void qTabSettings::setSettings(int index){ else{ slsDetectorDefs::detectorSettings sett = myDet->setSettings((slsDetectorDefs::detectorSettings)index); #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 //threshold @@ -322,7 +322,7 @@ void qTabSettings::Refresh(){ cout << endl << "**Updating Settings Tab" << endl; #endif - if (detType != slsReceiverDefs::JUNGFRAUCTB) + if (detType != slsDetectorDefs::JUNGFRAUCTB) disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); disconnect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); @@ -342,7 +342,7 @@ void qTabSettings::Refresh(){ GetDynamicRange(); // Settings - if (detType != slsReceiverDefs::JUNGFRAUCTB) { + if (detType != slsDetectorDefs::JUNGFRAUCTB) { #ifdef VERBOSE cout << "Getting settings" << endl; #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(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index 8686bf2e3..f12cce7bd 100644 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -46,7 +46,6 @@ set(PUBLICHEADERS ../slsSupportLib/include/container_utils.h sharedMemory/SharedMemory.h slsDetector/slsDetector.h - slsDetector/slsDetectorBase.h slsDetector/slsDetectorUsers.h slsDetector/detectorData.h multiSlsDetector/multiSlsDetector.h diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index 104107a22..ad1e26037 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -17,7 +17,7 @@ LIBZMQDIR = ../slsSupportLib/include 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 -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 diff --git a/slsDetectorSoftware/doxy.config b/slsDetectorSoftware/doxy.config index cfe37d367..a527dc28c 100644 --- a/slsDetectorSoftware/doxy.config +++ b/slsDetectorSoftware/doxy.config @@ -88,14 +88,12 @@ INPUT = ../slsSupportLib/include/communication_funcs.h \ ../slsSupportLib/include/genericSocket.h \ ../slsSupportLib/include/logger.h \ ../slsSupportLib/include/MySocketTCP.h \ - ../slsSupportLib/include/sls_receiver_defs.h \ ../slsSupportLib/include/sls_receiver_funcs.h \ ../slsSupportLib/include/utilities.h \ ../slsSupportLib/include/ZmqSocket.h \ multiSlsDetector/multiSlsDetectorClient.h \ multiSlsDetector/multiSlsDetectorCommand.h \ multiSlsDetector/multiSlsDetector.h \ - slsDetector/slsDetectorBase.h \ slsDetector/slsDetectorCommand.h \ slsDetector/slsDetector.h \ slsDetector/slsDetectorUsers.h \ diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index f5c9dc5b9..1a71ee8c2 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -2766,7 +2766,7 @@ int multiSlsDetector::setReceiverFramesPerFile(int f, int detPos) { } -slsReceiverDefs::frameDiscardPolicy multiSlsDetector::setReceiverFramesDiscardPolicy( +slsDetectorDefs::frameDiscardPolicy multiSlsDetector::setReceiverFramesDiscardPolicy( frameDiscardPolicy f, int detPos) { // single 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 if (detPos >= 0) { 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 if (detPos >= 0) { return detectors[detPos]->setFileFormat(f); diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index e68070142..1ac67ecb5 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -7,7 +7,8 @@ * @author Anna Bergamaschi */ -#include "slsDetectorBase.h" +#include "sls_detector_defs.h" +#include "error_defs.h" class slsDetector; class SharedMemory; @@ -24,7 +25,7 @@ class detectorData; #define SHORT_STRING_LENGTH 50 #define DATE_LENGTH 30 -class multiSlsDetector : public slsDetectorBase { +class multiSlsDetector : public virtual slsDetectorDefs, public virtual errorDefs { private: @@ -294,7 +295,7 @@ public: void addMultipleDetectors(const char* name); - using slsDetectorBase::getDetectorType; + using slsDetectorDefs::getDetectorType; /** * 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 diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 4ae39fe43..c8ae5af4e 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -7,6 +7,7 @@ #include "versionAPI.h" #include "slsDetectorCommand.h" #include "utilities.h" +#include "MySocketTCP.h" #include @@ -183,9 +184,7 @@ int slsDetector::checkVersionCompatibility(portType t) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { // data port if (connectData() == OK){ - // ignoring retval - int64_t retval = -1; - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); if (ret==FAIL){ setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); 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; SharedMemory* shm = 0; @@ -3628,7 +3627,7 @@ std::string slsDetector::setReceiver(std::string receiverIP) { if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ #ifdef VERBOSE std::cout << "Setting up receiver with" << std::endl; - std::cout << "detector type:" << slsDetectorBase::getDetectorType( + std::cout << "detector type:" << slsDetectorDefs::getDetectorType( thisDetector->myDetectorType) << std::endl; std::cout << "detector id:" << detId << std::endl; std::cout << "detector hostname:" << thisDetector->hostname << std::endl; @@ -5972,25 +5971,18 @@ std::string slsDetector::getReceiverLastClientIP() { int slsDetector::exitReceiver() { - - int retval; - int fnum=F_EXIT_RECEIVER; - + int fnum = F_EXIT_RECEIVER; + int ret = FAIL; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (dataSocket) { - dataSocket->Connect(); - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); + if (connectData() == OK){ + ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); disconnectData(); } } - if (retval!=OK) { - std::cout<< std::endl; - std::cout<< "Shutting down the receiver" << std::endl; - std::cout<< std::endl; + if (ret == OK) { + std::cout << std::endl << "Shutting down the receiver" << std::endl << std::endl; } - return retval; - + return ret; } 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 ret = FAIL; int retval = -1; @@ -6367,7 +6359,7 @@ int slsDetector::setReceiverPartialFramesPadding(int f) { return thisDetector->receiver_framePadding; } -slsReceiverDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { +slsDetectorDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { if (f == GET_FILE_FORMAT) return getFileFormat(); @@ -6397,7 +6389,7 @@ slsReceiverDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { -slsReceiverDefs::fileFormat slsDetector::getFileFormat() { +slsDetectorDefs::fileFormat slsDetector::getFileFormat() { return thisDetector->receiver_fileFormatType; } diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index d280c6682..13f7ef752 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -9,12 +9,14 @@ * @author Anna Bergamaschi */ -#include "slsDetectorBase.h" -#include "MySocketTCP.h" +#include "sls_detector_defs.h" +#include "error_defs.h" +#include "math.h" class multiSlsDetector; class SharedMemory; class ClientInterface; +class MySocketTCP; #define SLS_SHMVERSION 0x181005 #define NCHIPSMAX 10 @@ -38,7 +40,7 @@ typedef struct detParameterList { } detParameterList; -class slsDetector : public slsDetectorBase { +class slsDetector : public virtual slsDetectorDefs, public virtual errorDefs { private: /** @@ -388,7 +390,7 @@ public: */ void disconnectStop(); - using slsDetectorBase::getDetectorType; + using slsDetectorDefs::getDetectorType; /** * Get detector type by connecting to the detector without creating an object diff --git a/slsDetectorSoftware/slsDetector/slsDetectorBase.h b/slsDetectorSoftware/slsDetector/slsDetectorBase.h deleted file mode 100644 index 88a7dbee1..000000000 --- a/slsDetectorSoftware/slsDetector/slsDetectorBase.h +++ /dev/null @@ -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.
- In case you need to embed the detector control e.g in the beamline control software, compile these classes using -
- make package -
- and link the shared library created to your software slsDetectorSoftware/bin/libSlsDetector.so -
- The software can also be installed (with super-user rights)
- make install -
-
- 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 - -/** - -@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 diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp index 3f7a694ae..d0198f96d 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp @@ -94,11 +94,11 @@ int64_t slsDetectorUsers::getReceiverSoftwareVersion(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) { - return (myDetector->checkVersionCompatibility(slsDetectorDefs::DATA_PORT, detPos) == slsReceiverDefs::OK); + return (myDetector->checkVersionCompatibility(slsDetectorDefs::DATA_PORT, detPos) == slsDetectorDefs::OK); } int slsDetectorUsers::startMeasurement(){ diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h index f177833c2..0c6a8e25d 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h @@ -127,7 +127,7 @@ public: /** * Gets detector type * @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); diff --git a/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/server_funcs.c b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/server_funcs.c index acf839458..436aa28c8 100644 --- a/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/server_funcs.c +++ b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/server_funcs.c @@ -1,5 +1,4 @@ #include "sls_detector_defs.h" -#include "sls_receiver_defs.h" #include "server_funcs.h" #include "server_defs.h" #include "firmware_funcs.h" diff --git a/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h index 262b9f71c..6b0a7ca03 100644 --- a/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h @@ -2,7 +2,7 @@ #ifndef 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 diff --git a/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h index 7722bbe7b..6b3b6057d 100755 --- a/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h +++ b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h @@ -1,7 +1,7 @@ #ifndef SERVER_FUNCS_H #define SERVER_FUNCS_H -#include "sls_receiver_defs.h" +#include "sls_detector_defs.h" #include // initialization functions diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt index 0c1b359d2..f59d16e84 100644 --- a/slsReceiverSoftware/CMakeLists.txt +++ b/slsReceiverSoftware/CMakeLists.txt @@ -56,7 +56,7 @@ add_library(slsReceiverShared SHARED ) set(PUBLICHEADERS - ../slsSupportLib/include/sls_receiver_defs.h + ../slsSupportLib/include/sls_detector_defs.h ../slsSupportLib/include/ansi.h ../slsSupportLib/include/sls_receiver_funcs.h ../slsSupportLib/include/MySocketTCP.h diff --git a/slsReceiverSoftware/Makefile b/slsReceiverSoftware/Makefile index cf6f3f960..83052353a 100644 --- a/slsReceiverSoftware/Makefile +++ b/slsReceiverSoftware/Makefile @@ -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 -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) diff --git a/slsReceiverSoftware/gitInfo.txt b/slsReceiverSoftware/gitInfo.txt index 2ca9c2b3a..5bc0b7c85 100644 --- a/slsReceiverSoftware/gitInfo.txt +++ b/slsReceiverSoftware/gitInfo.txt @@ -6,4 +6,4 @@ Revision: 840 Branch: refactor Last Changed Author: Dhanya_Thattil 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 diff --git a/slsReceiverSoftware/include/BinaryFile.h b/slsReceiverSoftware/include/BinaryFile.h index 9cb585396..98f7d2a22 100644 --- a/slsReceiverSoftware/include/BinaryFile.h +++ b/slsReceiverSoftware/include/BinaryFile.h @@ -14,7 +14,7 @@ #include -class BinaryFile : private virtual slsReceiverDefs, public File, public BinaryFileStatic { +class BinaryFile : private virtual slsDetectorDefs, public File, public BinaryFileStatic { public: /** diff --git a/slsReceiverSoftware/include/DataProcessor.h b/slsReceiverSoftware/include/DataProcessor.h index 6b7692430..6e26f427d 100644 --- a/slsReceiverSoftware/include/DataProcessor.h +++ b/slsReceiverSoftware/include/DataProcessor.h @@ -18,7 +18,7 @@ class DataStreamer; #include -class DataProcessor : private virtual slsReceiverDefs, public ThreadObject { +class DataProcessor : private virtual slsDetectorDefs, public ThreadObject { public: /** diff --git a/slsReceiverSoftware/include/DataStreamer.h b/slsReceiverSoftware/include/DataStreamer.h index d939f203b..834b95f08 100644 --- a/slsReceiverSoftware/include/DataStreamer.h +++ b/slsReceiverSoftware/include/DataStreamer.h @@ -16,7 +16,7 @@ class ZmqSocket; #include -class DataStreamer : private virtual slsReceiverDefs, public ThreadObject { +class DataStreamer : private virtual slsDetectorDefs, public ThreadObject { public: /** diff --git a/slsReceiverSoftware/include/Fifo.h b/slsReceiverSoftware/include/Fifo.h index 5fad6a3cc..082357168 100644 --- a/slsReceiverSoftware/include/Fifo.h +++ b/slsReceiverSoftware/include/Fifo.h @@ -9,12 +9,12 @@ *@short constructs the fifo structure */ -#include "sls_receiver_defs.h" +#include "sls_detector_defs.h" #include "logger.h" #include "circularFifo.h" -class Fifo : private virtual slsReceiverDefs { +class Fifo : private virtual slsDetectorDefs { public: /** diff --git a/slsReceiverSoftware/include/File.h b/slsReceiverSoftware/include/File.h index cb403c2b1..afe1a9aba 100644 --- a/slsReceiverSoftware/include/File.h +++ b/slsReceiverSoftware/include/File.h @@ -8,13 +8,13 @@ *@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 -class File : private virtual slsReceiverDefs { +class File : private virtual slsDetectorDefs { public: /** diff --git a/slsReceiverSoftware/include/GeneralData.h b/slsReceiverSoftware/include/GeneralData.h index c0161e118..8d70e8602 100644 --- a/slsReceiverSoftware/include/GeneralData.h +++ b/slsReceiverSoftware/include/GeneralData.h @@ -7,7 +7,7 @@ *@short abstract for setting/getting properties of detector data */ -#include "sls_receiver_defs.h" +#include "sls_detector_defs.h" #include "receiver_defs.h" #include //ceil @@ -19,7 +19,7 @@ class GeneralData { public: /** DetectorType */ - slsReceiverDefs::detectorType myDetectorType; + slsDetectorDefs::detectorType myDetectorType; /** Number of Pixels in x axis */ uint32_t nPixelsX; @@ -92,7 +92,7 @@ public: /** Cosntructor */ GeneralData(): - myDetectorType(slsReceiverDefs::GENERIC), + myDetectorType(slsDetectorDefs::GENERIC), nPixelsX(0), nPixelsY(0), emptyHeader(0), @@ -160,7 +160,7 @@ public: * Set ROI * @param i ROI */ - virtual void SetROI(std::vector i) { + virtual void SetROI(std::vector i) { 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 * @returns adc configured */ - virtual const int GetAdcConfigured(int index, std::vector* i) const{ + virtual const int GetAdcConfigured(int index, std::vector* i) const{ cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); return 0; }; @@ -216,7 +216,7 @@ public: */ virtual void Print() const { 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 Y: " << nPixelsY; FILE_LOG(logDEBUG) << "Empty Header: " << emptyHeader; @@ -253,7 +253,7 @@ private: /** Constructor */ GotthardData(){ - myDetectorType = slsReceiverDefs::GOTTHARD; + myDetectorType = slsDetectorDefs::GOTTHARD; nPixelsX = 1280; nPixelsY = 1; headerSizeinPacket = 4; @@ -265,7 +265,7 @@ private: frameIndexOffset = 1; packetIndexMask = 1; 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; }; @@ -323,7 +323,7 @@ private: * Set ROI * @param i ROI */ - virtual void SetROI(std::vector i) { + virtual void SetROI(std::vector i) { // all adcs if(!i.size()) { nPixelsX = 1280; @@ -335,7 +335,7 @@ private: frameIndexOffset = 1; packetIndexMask = 1; 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; nPixelsXComplete = 0; nPixelsYComplete = 0; @@ -353,7 +353,7 @@ private: frameIndexOffset = 0; packetIndexMask = 0; 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; nPixelsXComplete = 1280; nPixelsYComplete = 1; @@ -367,7 +367,7 @@ private: * @param i pointer to a vector of ROI * @returns adc configured */ - virtual const int GetAdcConfigured(int index, std::vector* i) const{ + virtual const int GetAdcConfigured(int index, std::vector* i) const{ int adc = -1; // single adc if(i->size()) { @@ -407,7 +407,7 @@ class PropixData : public GeneralData { /** Constructor */ PropixData(){ - myDetectorType = slsReceiverDefs::PROPIX; + myDetectorType = slsDetectorDefs::PROPIX; nPixelsX = 22; nPixelsY = 22; headerSizeinPacket = 4; @@ -419,7 +419,7 @@ class PropixData : public GeneralData { frameIndexOffset = 1; packetIndexMask = 1; 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; }; }; @@ -434,7 +434,7 @@ class Moench02Data : public GeneralData { /** Constructor */ Moench02Data(){ - myDetectorType = slsReceiverDefs::MOENCH; + myDetectorType = slsDetectorDefs::MOENCH; nPixelsX = 160; nPixelsY = 160; headerSizeinPacket = 4; @@ -446,7 +446,7 @@ class Moench02Data : public GeneralData { frameIndexOffset = 8; packetIndexMask = 0xFF; 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; }; @@ -466,7 +466,7 @@ class Moench03Data : public GeneralData { /** Constructor */ Moench03Data(){ - myDetectorType = slsReceiverDefs::MOENCH; + myDetectorType = slsDetectorDefs::MOENCH; nPixelsX = 400; nPixelsY = 400; headerSizeinPacket = 22; @@ -478,7 +478,7 @@ class Moench03Data : public GeneralData { frameIndexOffset = (6+8); packetIndexMask = 0xFFFFFFFF; 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; }; }; @@ -506,7 +506,7 @@ private: /** Constructor */ JCTBData(){ - myDetectorType = slsReceiverDefs::JUNGFRAUCTB; + myDetectorType = slsDetectorDefs::JUNGFRAUCTB; nPixelsX = 400; nPixelsY = 400; headerSizeinPacket = 22; @@ -516,7 +516,7 @@ private: imageSize = nPixelsX * nPixelsY * 2; frameIndexMask = 0xFFFFFF; 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; }; @@ -578,17 +578,17 @@ class JungfrauData : public GeneralData { /** Constructor */ JungfrauData(){ - myDetectorType = slsReceiverDefs::JUNGFRAU; + myDetectorType = slsDetectorDefs::JUNGFRAU; nPixelsX = (256*4); nPixelsY = 512; emptyHeader = 6; - headerSizeinPacket = emptyHeader + sizeof(slsReceiverDefs::sls_detector_header); + headerSizeinPacket = emptyHeader + sizeof(slsDetectorDefs::sls_detector_header); dataSize = 8192; packetSize = headerSizeinPacket + dataSize; packetsPerFrame = 128; imageSize = dataSize*packetsPerFrame; 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; standardheader = true; defaultUdpSocketBufferSize = (2000 * 1024 * 1024); @@ -603,16 +603,16 @@ class EigerData : public GeneralData { /** Constructor */ EigerData(){ - myDetectorType = slsReceiverDefs::EIGER; + myDetectorType = slsDetectorDefs::EIGER; nPixelsX = (256*2); nPixelsY = 256; - headerSizeinPacket = sizeof(slsReceiverDefs::sls_detector_header); + headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header); dataSize = 1024; packetSize = headerSizeinPacket + dataSize; packetsPerFrame = 256; imageSize = dataSize*packetsPerFrame; 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; threadsPerReceiver = 2; headerPacketSize = 40; diff --git a/slsReceiverSoftware/include/HDF5File.h b/slsReceiverSoftware/include/HDF5File.h index ff5146e50..dcd1e7760 100644 --- a/slsReceiverSoftware/include/HDF5File.h +++ b/slsReceiverSoftware/include/HDF5File.h @@ -19,7 +19,7 @@ #endif -class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileStatic { +class HDF5File : private virtual slsDetectorDefs, public File, public HDF5FileStatic { public: /** diff --git a/slsReceiverSoftware/include/HDF5FileStatic.h b/slsReceiverSoftware/include/HDF5FileStatic.h index 1fff667da..38e304c6d 100644 --- a/slsReceiverSoftware/include/HDF5FileStatic.h +++ b/slsReceiverSoftware/include/HDF5FileStatic.h @@ -13,7 +13,7 @@ #ifndef H5_NO_NAMESPACE using namespace H5; #endif -#include "sls_receiver_defs.h" +#include "sls_detector_defs.h" #include "logger.h" #include @@ -24,7 +24,7 @@ using namespace H5; #include #include //memset -class HDF5FileStatic: public virtual slsReceiverDefs { +class HDF5FileStatic: public virtual slsDetectorDefs { public: diff --git a/slsReceiverSoftware/include/Listener.h b/slsReceiverSoftware/include/Listener.h index f05260be2..da8280a1c 100644 --- a/slsReceiverSoftware/include/Listener.h +++ b/slsReceiverSoftware/include/Listener.h @@ -15,7 +15,7 @@ class GeneralData; class Fifo; class genericSocket; -class Listener : private virtual slsReceiverDefs, public ThreadObject { +class Listener : private virtual slsDetectorDefs, public ThreadObject { public: /** diff --git a/slsReceiverSoftware/include/ThreadObject.h b/slsReceiverSoftware/include/ThreadObject.h index 5b5639cea..932dc2630 100644 --- a/slsReceiverSoftware/include/ThreadObject.h +++ b/slsReceiverSoftware/include/ThreadObject.h @@ -7,14 +7,14 @@ *@short creates/destroys a thread */ -#include "sls_receiver_defs.h" +#include "sls_detector_defs.h" #include "logger.h" #include #include #include -class ThreadObject : private virtual slsReceiverDefs { +class ThreadObject : private virtual slsDetectorDefs { public: /** diff --git a/slsReceiverSoftware/include/circularFifo.h b/slsReceiverSoftware/include/circularFifo.h index f0b4eeb34..569561424 100644 --- a/slsReceiverSoftware/include/circularFifo.h +++ b/slsReceiverSoftware/include/circularFifo.h @@ -7,7 +7,6 @@ * modified by the sls detetor group * */ -//#include "sls_receiver_defs.h" #include #include #include diff --git a/slsReceiverSoftware/include/receiver_defs.h b/slsReceiverSoftware/include/receiver_defs.h index 7d34bef05..5f623e16f 100755 --- a/slsReceiverSoftware/include/receiver_defs.h +++ b/slsReceiverSoftware/include/receiver_defs.h @@ -1,6 +1,6 @@ #pragma once -#include "sls_receiver_defs.h" +#include "sls_detector_defs.h" #include #define MAX_DIMENSIONS 2 diff --git a/slsReceiverSoftware/include/slsReceiver.h b/slsReceiverSoftware/include/slsReceiver.h index b8bcb52f1..9e9ca9780 100644 --- a/slsReceiverSoftware/include/slsReceiver.h +++ b/slsReceiverSoftware/include/slsReceiver.h @@ -8,14 +8,14 @@ class slsReceiverTCPIPInterface; -#include "sls_receiver_defs.h" +#include "sls_detector_defs.h" /** *@short creates the UDP and TCP class objects */ -class slsReceiver : private virtual slsReceiverDefs { +class slsReceiver : private virtual slsDetectorDefs { public: /** diff --git a/slsReceiverSoftware/include/slsReceiverImplementation.h b/slsReceiverSoftware/include/slsReceiverImplementation.h index 590b9e341..b57176962 100644 --- a/slsReceiverSoftware/include/slsReceiverImplementation.h +++ b/slsReceiverSoftware/include/slsReceiverImplementation.h @@ -6,7 +6,7 @@ /** * @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 "logger.h" @@ -19,7 +19,7 @@ class Fifo; #include #include -class slsReceiverImplementation: private virtual slsReceiverDefs { +class slsReceiverImplementation: private virtual slsDetectorDefs { public: @@ -346,7 +346,7 @@ class slsReceiverImplementation: private virtual slsReceiverDefs { * Set File Format * @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)) diff --git a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h index 0da880981..b6189eecb 100644 --- a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h +++ b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h @@ -5,7 +5,7 @@ ***********************************************/ -#include "sls_receiver_defs.h" +#include "sls_detector_defs.h" #include "receiver_defs.h" class MySocketTCP; @@ -18,7 +18,7 @@ class slsReceiverImplementation; *@short interface between receiver and client */ -class slsReceiverTCPIPInterface : private virtual slsReceiverDefs { +class slsReceiverTCPIPInterface : private virtual slsDetectorDefs { public: diff --git a/slsReceiverSoftware/src/BinaryFile.cpp b/slsReceiverSoftware/src/BinaryFile.cpp index 16072fd72..639c70328 100644 --- a/slsReceiverSoftware/src/BinaryFile.cpp +++ b/slsReceiverSoftware/src/BinaryFile.cpp @@ -37,7 +37,7 @@ void BinaryFile::PrintMembers() { FILE_LOG(logINFO) << "Number of Frames in File: " << numFramesInFile; } -slsReceiverDefs::fileFormat BinaryFile::GetFileType() { +slsDetectorDefs::fileFormat BinaryFile::GetFileType() { return BINARY; } diff --git a/slsReceiverSoftware/src/HDF5File.cpp b/slsReceiverSoftware/src/HDF5File.cpp index 597c1bd6e..f6a4ffe75 100644 --- a/slsReceiverSoftware/src/HDF5File.cpp +++ b/slsReceiverSoftware/src/HDF5File.cpp @@ -116,7 +116,7 @@ void HDF5File::SetNumberofPixels(uint32_t nx, uint32_t ny) { } -slsReceiverDefs::fileFormat HDF5File::GetFileType() { +slsDetectorDefs::fileFormat HDF5File::GetFileType() { return HDF5; } diff --git a/slsReceiverSoftware/src/main.cpp b/slsReceiverSoftware/src/main.cpp index 2b2166d83..500c01748 100644 --- a/slsReceiverSoftware/src/main.cpp +++ b/slsReceiverSoftware/src/main.cpp @@ -1,7 +1,7 @@ /* A simple server in the internet domain using TCP The port number is passed as an argument */ -#include "sls_receiver_defs.h" +#include "sls_detector_defs.h" #include "slsReceiverUsers.h" #include @@ -40,8 +40,8 @@ void AcquisitionFinished(uint64_t frames, void*p){ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){ - slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata; - slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader; + slsDetectorDefs::sls_receiver_header* header = (slsDetectorDefs::sls_receiver_header*)metadata; + slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader; PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row, "#### %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); - if(ret==slsReceiverDefs::FAIL){ + if(ret==slsDetectorDefs::FAIL){ delete receiver; cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); exit(EXIT_FAILURE); @@ -140,7 +140,7 @@ int main(int argc, char *argv[]) { //start tcp server thread - if (receiver->start() == slsReceiverDefs::FAIL){ + if (receiver->start() == slsDetectorDefs::FAIL){ delete receiver; cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); exit(EXIT_FAILURE); diff --git a/slsReceiverSoftware/src/slsReceiverImplementation.cpp b/slsReceiverSoftware/src/slsReceiverImplementation.cpp index 5e21127e5..1dfc40f7d 100644 --- a/slsReceiverSoftware/src/slsReceiverImplementation.cpp +++ b/slsReceiverSoftware/src/slsReceiverImplementation.cpp @@ -169,7 +169,7 @@ bool slsReceiverImplementation::getGapPixelsEnable() const { } /***file parameters***/ -slsReceiverDefs::fileFormat slsReceiverImplementation::getFileFormat() const{ +slsDetectorDefs::fileFormat slsReceiverImplementation::getFileFormat() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return fileFormatType; } @@ -211,7 +211,7 @@ uint32_t slsReceiverImplementation::getFramesPerFile() const{ return framesPerFile; } -slsReceiverDefs::frameDiscardPolicy slsReceiverImplementation::getFrameDiscardPolicy() const{ +slsDetectorDefs::frameDiscardPolicy slsReceiverImplementation::getFrameDiscardPolicy() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return frameDiscardMode; } @@ -305,7 +305,7 @@ char *slsReceiverImplementation::getEthernetInterface() const{ /***acquisition parameters***/ -std::vector slsReceiverImplementation::getROI() const{ +std::vector slsReceiverImplementation::getROI() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return roi; } @@ -370,7 +370,7 @@ uint32_t slsReceiverImplementation::getFifoDepth() const{ } /***receiver status***/ -slsReceiverDefs::runStatus slsReceiverImplementation::getStatus() const{ +slsDetectorDefs::runStatus slsReceiverImplementation::getStatus() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return status;} @@ -615,7 +615,7 @@ int slsReceiverImplementation::setUDPSocketBufferSize(const uint32_t s) { /***acquisition parameters***/ -int slsReceiverImplementation::setROI(const std::vector i) { +int slsReceiverImplementation::setROI(const std::vector i) { if (myDetectorType != GOTTHARD) { cprintf(RED, "Error: Can not set ROI for this detector\n"); return FAIL; diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 52a18c0e1..01fecab75 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -69,10 +69,6 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn): strcpy(mess,"dummy message"); function_table(); -#ifdef VERYVERBOSE - FILE_LOG(logINFO) << "Function table assigned."; -#endif - } @@ -147,35 +143,16 @@ void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){ void slsReceiverTCPIPInterface::startTCPServer(){ cprintf(BLUE,"Created [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber << std::endl; + int ret = OK; -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG5) << "Starting Receiver TCP Server"; -#endif - int v=OK; - - while(1) { -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG5); -#endif -#ifdef VERY_VERBOSE - FILE_LOG(logDEBUG5) << "Waiting for client call"; -#endif + while(true) { if(mySock->Connect() >= 0){ -#ifdef VERY_VERBOSE - FILE_LOG(logDEBUG5) << "Conenction accepted"; -#endif - v = decode_function(); -#ifdef VERY_VERBOSE - FILE_LOG(logDEBUG5) << "function executed"; -#endif + ret = decode_function(); mySock->Disconnect(); -#ifdef VERY_VERBOSE - FILE_LOG(logDEBUG5) << "connection closed"; -#endif } //if tcp command was to exit server - if(v==GOODBYE){ + if(ret == GOODBYE){ FILE_LOG(logINFO) << "Shutting down UDP Socket"; if(receiverBase){ receiverBase->shutDownUDPSockets(); @@ -188,7 +165,7 @@ void slsReceiverTCPIPInterface::startTCPServer(){ //if user entered exit if(killTCPServerThread) { - if (v != GOODBYE) { + if (ret != GOODBYE) { if(receiverBase){ receiverBase->shutDownUDPSockets(); } @@ -196,7 +173,6 @@ void slsReceiverTCPIPInterface::startTCPServer(){ cprintf(BLUE,"Exiting [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); pthread_exit(NULL); } - } } @@ -306,14 +282,12 @@ int slsReceiverTCPIPInterface::function_table(){ flist[F_RECEIVER_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_padding_enable; flist[F_RECEIVER_DEACTIVATED_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable; - -#ifdef VERYVERBOSE for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) { - FILE_LOG(logINFO) << "function fnum: " << i << " (" << getFunctionName((enum recFuncs)i) << ") located at " << (unsigned int)flist[i]; + FILE_LOG(logDEBUG1) << "function fnum: " << i << " (" << + getFunctionName((enum recFuncs)i) << ") located at " << flist[i]; } -#endif - return OK; + return OK; } @@ -321,9 +295,7 @@ int slsReceiverTCPIPInterface::function_table(){ int slsReceiverTCPIPInterface::decode_function(){ ret = FAIL; -#ifdef VERYVERBOSE - cprintf(RESET,"\n"); -#endif + FILE_LOG(logDEBUG1) << "waiting to receive data"; int n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum)); if (n <= 0) { @@ -347,7 +319,8 @@ int slsReceiverTCPIPInterface::decode_function(){ ret=(this->*flist[fnum])(); } if (ret == FAIL) { - FILE_LOG(logERROR) << "Failed to execute function = " << fnum << " (" << getFunctionName((enum recFuncs)fnum) << ")"; + FILE_LOG(logERROR) << "Failed to execute function = " << fnum << " (" + << getFunctionName((enum recFuncs)fnum) << ")"; } return ret; } @@ -376,13 +349,15 @@ void slsReceiverTCPIPInterface::receiverlocked() { void slsReceiverTCPIPInterface::receiverNotIdle() { ret = FAIL; - sprintf(mess,"Can not execute %s when receiver is not idle\n", getFunctionName((enum recFuncs)fnum)); + sprintf(mess,"Can not execute %s when receiver is not idle\n", + getFunctionName((enum recFuncs)fnum)); FILE_LOG(logERROR) << mess; } void slsReceiverTCPIPInterface::functionNotImplemented() { ret = FAIL; - sprintf(mess, "Function (%s) is not implemented for this detector\n",getFunctionName((enum recFuncs)fnum)); + sprintf(mess, "Function (%s) is not implemented for this detector\n", + getFunctionName((enum recFuncs)fnum)); FILE_LOG(logERROR) << mess; } @@ -399,11 +374,8 @@ int slsReceiverTCPIPInterface::M_nofunc(){printf("111 \n"); strcpy(mess,"Unrecognized Function. Please do not proceed.\n"); FILE_LOG(logERROR) << mess; - // send ok / fail - mySock->SendDataOnly(&ret,sizeof(ret)); - // send return argument - mySock->SendDataOnly(mess,sizeof(mess)); - // return ok / fail + clientInterface->Server_SendResult(false, ret, NULL, 0, mess); + return ret; } @@ -421,10 +393,6 @@ int slsReceiverTCPIPInterface::exec_command() { if (mySock->ReceiveDataOnly(cmd,MAX_STR_LENGTH) < 0) return printSocketReadError(); - // execute action -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG5) << "executing command " << cmd; -#endif if (mySock->differentClients && lockStatus) receiverlocked(); else { @@ -439,23 +407,20 @@ int slsReceiverTCPIPInterface::exec_command() { } } - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,MAX_STR_LENGTH); + clientInterface->Server_SendResult(false, ret, NULL, 0, mess); - // return ok/fail return ret; } int slsReceiverTCPIPInterface::exit_server() { + cprintf(RED,"Closing receiver server\n"); + + ret = OK; + clientInterface->Server_SendResult(false, ret, NULL, 0); + ret = GOODBYE; - strcpy(mess,"closing server"); - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(mess,sizeof(mess)); - cprintf(RED,"%s\n",mess); return ret; } @@ -472,24 +437,19 @@ int slsReceiverTCPIPInterface::lock_receiver() { // execute action if (lock >= 0) { - if (!lockStatus || (!strcmp(mySock->lastClientIP,mySock->thisClientIP)) || (!strcmp(mySock->lastClientIP,"none"))) { + if (!lockStatus || // if it was unlocked, anyone can lock + (!strcmp(mySock->lastClientIP,mySock->thisClientIP)) || // if it was locked, need same ip + (!strcmp(mySock->lastClientIP,"none"))) //if it was locked, must be by "none" + { lockStatus = lock; strcpy(mySock->lastClientIP,mySock->thisClientIP); } else receiverlocked(); } - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &lockStatus,sizeof(lockStatus), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - else - mySock->SendDataOnly(&lockStatus,sizeof(lockStatus)); - - // return ok/fail return ret; } @@ -497,11 +457,8 @@ int slsReceiverTCPIPInterface::lock_receiver() { int slsReceiverTCPIPInterface::get_last_client_ip() { ret = OK; - - if (mySock->differentClients) - ret = FORCE_UPDATE; - - clientInterface->Server_SendResult(ret,mySock->lastClientIP, INET_ADDRSTRLEN); + clientInterface->Server_SendResult(mySock->differentClients, + ret,mySock->lastClientIP, sizeof(mySock->lastClientIP)); return ret; } @@ -553,24 +510,16 @@ int slsReceiverTCPIPInterface::set_port() { } } - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &p_number,sizeof(p_number), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - else { - mySock->SendDataOnly(&p_number,sizeof(p_number)); - if(ret != FAIL){ - mySock->Disconnect(); - delete mySock; - mySock = mySocket; - clientInterface->SetSocket(mySock); - } + if(ret != FAIL){ + mySock->Disconnect(); + delete mySock; + mySock = mySocket; + clientInterface->SetSocket(mySock); } - // return ok/fail return ret; } @@ -579,17 +528,14 @@ int slsReceiverTCPIPInterface::set_port() { int slsReceiverTCPIPInterface::update_client() { ret = OK; memset(mess, 0, sizeof(mess)); + if (receiverBase == NULL) invalidReceiverObject(); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - //fail and force_update - if (ret != OK){ - mySock->SendDataOnly(mess,sizeof(mess)); - // return ok/fail + clientInterface->Server_SendResult(false, ret, NULL, 0, mess); + + if (ret == FAIL) return ret; - } // update return send_update(); @@ -607,9 +553,7 @@ int slsReceiverTCPIPInterface::send_update() { n += mySock->SendDataOnly(mySock->lastClientIP,sizeof(mySock->lastClientIP)); // filepath -#ifdef SLS_RECEIVER_UDP_FUNCTIONS path = receiverBase->getFilePath(); -#endif if (path == NULL) n += mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH); else { @@ -618,9 +562,7 @@ int slsReceiverTCPIPInterface::send_update() { } // filename -#ifdef SLS_RECEIVER_UDP_FUNCTIONS path = receiverBase->getFileName(); -#endif if(path == NULL) n += mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH); else { @@ -629,103 +571,71 @@ int slsReceiverTCPIPInterface::send_update() { } // index -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=receiverBase->getFileIndex(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); //file format -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getFileFormat(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); //frames per file -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getFramesPerFile(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); //frame discard policy -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getFrameDiscardPolicy(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); //frame padding -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getFramePaddingEnable(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); // file write enable -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getFileWriteEnable(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); // file overwrite enable -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getOverwriteEnable(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); // gap pixels -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getGapPixelsEnable(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); // streaming frequency -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getStreamingFrequency(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); // streaming port -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getStreamingPort(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); // streaming source ip -#ifdef SLS_RECEIVER_UDP_FUNCTIONS path = receiverBase->getStreamingSourceIP(); -#endif mySock->SendDataOnly(path,MAX_STR_LENGTH); if (path != NULL) delete[] path; // additional json header -#ifdef SLS_RECEIVER_UDP_FUNCTIONS path = receiverBase->getAdditionalJsonHeader(); -#endif mySock->SendDataOnly(path,MAX_STR_LENGTH); if (path != NULL) delete[] path; // data streaming enable -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getDataStreamEnable(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); // activate -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getActivate(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); // deactivated padding enable -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getDeactivatedPadding(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); // silent mode -#ifdef SLS_RECEIVER_UDP_FUNCTIONS ind=(int)receiverBase->getSilentMode(); -#endif n += mySock->SendDataOnly(&ind,sizeof(ind)); if (!lockStatus) @@ -740,10 +650,8 @@ int slsReceiverTCPIPInterface::get_id(){ ret = OK; int64_t retval = getReceiverVersion(); - if(mySock->differentClients) - ret = FORCE_UPDATE; - - clientInterface->Server_SendResult(ret, &retval, sizeof(retval)); + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval)); return ret; } @@ -763,7 +671,6 @@ int slsReceiverTCPIPInterface::set_detector_type(){ // execute action if (dr == GET_DETECTOR_TYPE) retval = myDetectorType; -#ifdef SLS_RECEIVER_UDP_FUNCTIONS else if (mySock->differentClients && lockStatus) receiverlocked(); else if ((receiverBase) && (receiverBase->getStatus() != IDLE)) @@ -800,22 +707,13 @@ int slsReceiverTCPIPInterface::set_detector_type(){ retval = myDetectorType; } } -#endif // client has started updating receiver, update ip if (!lockStatus) strcpy(mySock->lastClientIP,mySock->thisClientIP); + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -827,17 +725,12 @@ int slsReceiverTCPIPInterface::set_detector_hostname() { char hostname[MAX_STR_LENGTH]; memset(hostname, 0, sizeof(hostname)); char* retval = NULL; - char defaultVal[MAX_STR_LENGTH]; - memset(defaultVal, 0, sizeof(defaultVal)); - // receive arguments if (mySock->ReceiveDataOnly(hostname,MAX_STR_LENGTH) < 0 ) return printSocketReadError(); // execute action - // only a set, not a get -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (mySock->differentClients && lockStatus) receiverlocked(); else if (receiverBase == NULL) @@ -847,26 +740,19 @@ int slsReceiverTCPIPInterface::set_detector_hostname() { else { receiverBase->setDetectorHostname(hostname); retval = receiverBase->getDetectorHostname(); - if(retval == NULL) + if(retval == NULL) { ret = FAIL; + cprintf(RED, "Could not set hostname to %s\n", hostname); + FILE_LOG(logERROR) << mess; + } } -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, retval, (retval == NULL) ? 0 : MAX_STR_LENGTH, mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - if(retval == NULL) - mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH); - else { - mySock->SendDataOnly(retval,MAX_STR_LENGTH); + if(retval != NULL) delete[] retval; - } - // return ok/fail return ret; } @@ -894,10 +780,7 @@ int slsReceiverTCPIPInterface::set_roi() { if (myDetectorType != GOTTHARD) functionNotImplemented(); - // execute action - // only a set, not a get else { -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (mySock->differentClients && lockStatus) receiverlocked(); else if (receiverBase == NULL) @@ -906,21 +789,14 @@ int slsReceiverTCPIPInterface::set_roi() { receiverNotIdle(); else { ret = receiverBase->setROI(roiLimits); - //retval = receiverBase->getROI(); } -#endif } - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); + clientInterface->Server_SendResult(mySock->differentClients, + ret, NULL, 0, mess); roiLimits.clear(); - // return ok/fail return ret; } @@ -939,8 +815,6 @@ int slsReceiverTCPIPInterface::setup_udp(){ return printSocketReadError(); // execute action - // only a set, not a get -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (mySock->differentClients && lockStatus) receiverlocked(); else if (receiverBase == NULL) @@ -992,18 +866,10 @@ int slsReceiverTCPIPInterface::setup_udp(){ } } } -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(retval,MAX_STR_LENGTH); - - // return ok/fail return ret; } @@ -1020,7 +886,6 @@ int slsReceiverTCPIPInterface::set_timer() { return printSocketReadError(); // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -1106,21 +971,11 @@ int slsReceiverTCPIPInterface::set_timer() { FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE - FILE_LOG(logDEBUG1) << getTimerType(index[0]) << ":" << retval; -#endif + FILE_LOG(logDEBUG1) << slsDetectorDefs::getTimerType((timerIndex)(index[0])) << ":" << retval; - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -1158,7 +1013,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range() { FILE_LOG(logERROR) << mess; } -#ifdef SLS_RECEIVER_UDP_FUNCTIONS + if (ret == OK){ if (receiverBase == NULL) invalidReceiverObject(); @@ -1186,21 +1041,11 @@ int slsReceiverTCPIPInterface::set_dynamic_range() { } } } -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "dynamic range: " << retval; -#endif -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -1216,8 +1061,6 @@ int slsReceiverTCPIPInterface::set_streaming_frequency(){ if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -1243,18 +1086,10 @@ int slsReceiverTCPIPInterface::set_streaming_frequency(){ FILE_LOG(logERROR) << mess; } } -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -1262,23 +1097,19 @@ int slsReceiverTCPIPInterface::set_streaming_frequency(){ int slsReceiverTCPIPInterface::get_status(){ ret = OK; + memset(mess, 0, sizeof(mess)); enum runStatus retval = ERROR; - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else retval = receiverBase->getStatus(); -#endif if (ret == OK && mySock->differentClients) ret = FORCE_UPDATE; - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(&retval,sizeof(retval)); + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // return ok/fail return ret; } @@ -1288,19 +1119,10 @@ int slsReceiverTCPIPInterface::start_receiver(){ ret = OK; memset(mess, 0, sizeof(mess)); - // execute action - // only a set, not a get -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else if (mySock->differentClients && lockStatus) receiverlocked(); - /* - else if(!strlen(receiverBase->getFilePath())){ - strcpy(mess,SET_RECEIVER_ERR_MESSAGE"); - ret = FAIL; - } - */ else { enum runStatus s = receiverBase->getStatus(); if (s != IDLE) { @@ -1315,17 +1137,10 @@ int slsReceiverTCPIPInterface::start_receiver(){ } } } -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, NULL, 0, mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - - // return ok/fail return ret; @@ -1338,9 +1153,6 @@ int slsReceiverTCPIPInterface::stop_receiver(){ memset(mess, 0, sizeof(mess)); enum runStatus s = ERROR; - // execute action - // only a set, not a get -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else if (mySock->differentClients && lockStatus) @@ -1357,17 +1169,10 @@ int slsReceiverTCPIPInterface::stop_receiver(){ FILE_LOG(logERROR) << mess; } } -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, NULL, 0, mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - - // return ok/fail return ret; } @@ -1382,15 +1187,11 @@ int slsReceiverTCPIPInterface::set_file_dir() { char fPath[MAX_STR_LENGTH]; memset(fPath, 0, sizeof(fPath)); char* retval=NULL; - char defaultVal[MAX_STR_LENGTH]; - memset(defaultVal, 0, sizeof(defaultVal)); // receive arguments if (mySock->ReceiveDataOnly(fPath,MAX_STR_LENGTH) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -1412,27 +1213,15 @@ int slsReceiverTCPIPInterface::set_file_dir() { FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE if (retval != NULL) FILE_LOG(logDEBUG1) << "file path:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, retval, (retval == NULL) ? 0 : MAX_STR_LENGTH, mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - if(retval == NULL) - mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH); - else{ - mySock->SendDataOnly(retval,MAX_STR_LENGTH); + if(retval != NULL) delete[] retval; - } - // return ok/fail return ret; } @@ -1444,15 +1233,11 @@ int slsReceiverTCPIPInterface::set_file_name() { char fName[MAX_STR_LENGTH]; memset(fName, 0, sizeof(fName)); char* retval = NULL; - char defaultVal[MAX_STR_LENGTH]; - memset(defaultVal, 0, sizeof(defaultVal)); // receive arguments if (mySock->ReceiveDataOnly(fName,MAX_STR_LENGTH) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -1474,26 +1259,14 @@ int slsReceiverTCPIPInterface::set_file_name() { FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "file name:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, retval, (retval == NULL) ? 0 : MAX_STR_LENGTH, mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - if(retval == NULL) - mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH); - else{ - mySock->SendDataOnly(retval,MAX_STR_LENGTH); + if(retval != NULL) delete[] retval; - } - // return ok/fail return ret; } @@ -1509,8 +1282,6 @@ int slsReceiverTCPIPInterface::set_file_index() { if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -1532,21 +1303,11 @@ int slsReceiverTCPIPInterface::set_file_index() { FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "file index:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval,sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -1557,24 +1318,17 @@ int slsReceiverTCPIPInterface::set_file_index() { int slsReceiverTCPIPInterface::get_frame_index(){ ret = OK; + memset(mess, 0, sizeof(mess)); int retval = -1; - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else retval=receiverBase->getAcquisitionIndex(); -#endif - if (mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval,sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -1582,23 +1336,16 @@ int slsReceiverTCPIPInterface::get_frame_index(){ int slsReceiverTCPIPInterface::get_frames_caught(){ ret = OK; + memset(mess, 0, sizeof(mess)); int retval = -1; - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else retval=receiverBase->getTotalFramesCaught(); -#endif - if (mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval,sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -1608,9 +1355,6 @@ int slsReceiverTCPIPInterface::reset_frames_caught(){ ret = OK; memset(mess, 0, sizeof(mess)); - // execute action - // only a set, not a get -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else if (mySock->differentClients && lockStatus) @@ -1619,17 +1363,10 @@ int slsReceiverTCPIPInterface::reset_frames_caught(){ receiverNotIdle(); else receiverBase->resetAcquisitionCount(); -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, NULL, 0, mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - - // return ok/fail return ret; } @@ -1645,8 +1382,6 @@ int slsReceiverTCPIPInterface::enable_file_write(){ if (mySock->ReceiveDataOnly(&enable,sizeof(enable)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -1668,21 +1403,11 @@ int slsReceiverTCPIPInterface::enable_file_write(){ FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "file write enable:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -1700,8 +1425,6 @@ int slsReceiverTCPIPInterface::enable_overwrite() { if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -1723,21 +1446,12 @@ int slsReceiverTCPIPInterface::enable_overwrite() { FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE + FILE_LOG(logDEBUG1) << "file overwrite enable:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -1756,10 +1470,6 @@ int slsReceiverTCPIPInterface::enable_tengiga() { if (myDetectorType != EIGER) functionNotImplemented(); - // execute action - - -#ifdef SLS_RECEIVER_UDP_FUNCTIONS else { if (receiverBase == NULL) invalidReceiverObject(); @@ -1783,21 +1493,11 @@ int slsReceiverTCPIPInterface::enable_tengiga() { } } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "10Gbe:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -1814,8 +1514,6 @@ int slsReceiverTCPIPInterface::set_fifo_depth() { if (mySock->ReceiveDataOnly(&value,sizeof(value)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -1841,21 +1539,12 @@ int slsReceiverTCPIPInterface::set_fifo_depth() { FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE + FILE_LOG(logDEBUG1) << "fifo depth:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -1874,8 +1563,6 @@ int slsReceiverTCPIPInterface::set_activate() { if (myDetectorType != EIGER) functionNotImplemented(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS else { if (receiverBase == NULL) invalidReceiverObject(); @@ -1899,21 +1586,11 @@ int slsReceiverTCPIPInterface::set_activate() { } } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "Activate: " << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -1929,8 +1606,6 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(){ if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -1952,21 +1627,11 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(){ FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "data streaming enable:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -1982,8 +1647,6 @@ int slsReceiverTCPIPInterface::set_streaming_timer(){ if(mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2005,21 +1668,11 @@ int slsReceiverTCPIPInterface::set_streaming_timer(){ FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "Streaming timer:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2038,8 +1691,6 @@ int slsReceiverTCPIPInterface::set_flipped_data(){ if (myDetectorType != EIGER) functionNotImplemented(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS else { if (receiverBase == NULL) invalidReceiverObject(); @@ -2063,21 +1714,11 @@ int slsReceiverTCPIPInterface::set_flipped_data(){ } } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "Flipped Data:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2094,8 +1735,6 @@ int slsReceiverTCPIPInterface::set_file_format() { if (mySock->ReceiveDataOnly(&f,sizeof(f)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2117,21 +1756,11 @@ int slsReceiverTCPIPInterface::set_file_format() { FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "File Format: " << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2147,8 +1776,6 @@ int slsReceiverTCPIPInterface::set_detector_posid() { if (mySock->ReceiveDataOnly(&arg,sizeof(arg)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2170,21 +1797,11 @@ int slsReceiverTCPIPInterface::set_detector_posid() { FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "Position Id:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2203,8 +1820,6 @@ int slsReceiverTCPIPInterface::set_multi_detector_size() { if (mySock->ReceiveDataOnly(arg,sizeof(arg)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2227,21 +1842,11 @@ int slsReceiverTCPIPInterface::set_multi_detector_size() { retval *= temp[i]; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "Multi Detector Size:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2258,8 +1863,6 @@ int slsReceiverTCPIPInterface::set_streaming_port() { if (mySock->ReceiveDataOnly(&port,sizeof(port)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2276,21 +1879,11 @@ int slsReceiverTCPIPInterface::set_streaming_port() { //get retval=receiverBase->getStreamingPort(); } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "streaming port:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2309,8 +1902,6 @@ int slsReceiverTCPIPInterface::set_streaming_source_ip() { if (mySock->ReceiveDataOnly(arg,MAX_STR_LENGTH) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2320,28 +1911,20 @@ int slsReceiverTCPIPInterface::set_streaming_source_ip() { else if (receiverBase->getStatus() != IDLE) receiverNotIdle(); else { - receiverBase->setStreamingSourceIP(arg); + receiverBase->setStreamingSourceIP(arg); } //get retval = receiverBase->getStreamingSourceIP(); } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "streaming source ip:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, retval, (retval == NULL) ? 0 : MAX_STR_LENGTH, mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(retval,MAX_STR_LENGTH); - delete[] retval; + if(retval != NULL) + delete[] retval; - // return ok/fail return ret; } @@ -2361,8 +1944,6 @@ int slsReceiverTCPIPInterface::set_silent_mode() { if (mySock->ReceiveDataOnly(&value,sizeof(value)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2379,21 +1960,11 @@ int slsReceiverTCPIPInterface::set_silent_mode() { //get retval = (int)receiverBase->getSilentMode(); // no check required } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "silent mode:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2412,9 +1983,6 @@ int slsReceiverTCPIPInterface::enable_gap_pixels() { if (mySock->ReceiveDataOnly(&enable,sizeof(enable)) < 0 ) return printSocketReadError(); - - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2439,21 +2007,11 @@ int slsReceiverTCPIPInterface::enable_gap_pixels() { FILE_LOG(logERROR) << "Warning: " << mess; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "Gap Pixels Enable: " << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2464,9 +2022,6 @@ int slsReceiverTCPIPInterface::restream_stop(){ ret = OK; memset(mess, 0, sizeof(mess)); - // execute action - // only a set, not a get -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else if (mySock->differentClients && lockStatus) @@ -2484,17 +2039,10 @@ int slsReceiverTCPIPInterface::restream_stop(){ FILE_LOG(logERROR) << mess; } } -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, NULL, 0, mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - - // return ok/fail return ret; } @@ -2511,8 +2059,6 @@ int slsReceiverTCPIPInterface::set_additional_json_header() { if (mySock->ReceiveDataOnly(arg,MAX_STR_LENGTH) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2528,23 +2074,15 @@ int slsReceiverTCPIPInterface::set_additional_json_header() { //get retval = receiverBase->getAdditionalJsonHeader(); } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "additional json header:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, retval, MAX_STR_LENGTH, mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(retval,MAX_STR_LENGTH); - delete[] retval; + if (retval != NULL) + delete[] retval; - // return ok/fail - return ret; + return ret; } @@ -2559,8 +2097,6 @@ int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() { if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2586,21 +2122,11 @@ int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() { FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2608,23 +2134,16 @@ int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() { int slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size(){ ret = OK; + memset(mess, 0, sizeof(mess)); int retval = -1; - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else retval = receiverBase->getActualUDPSocketBufferSize(); -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2640,8 +2159,6 @@ int slsReceiverTCPIPInterface::set_frames_per_file() { if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2663,21 +2180,11 @@ int slsReceiverTCPIPInterface::set_frames_per_file() { FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "frames per file:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2690,7 +2197,6 @@ int slsReceiverTCPIPInterface::check_version_compatibility() { ret = OK; memset(mess, 0, sizeof(mess)); int64_t arg = -1; - int64_t retval = -1; // receive arguments if (mySock->ReceiveDataOnly(&arg,sizeof(arg)) < 0 ) @@ -2727,16 +2233,9 @@ int slsReceiverTCPIPInterface::check_version_compatibility() { } else FILE_LOG(logINFO) << "Compatibility with Client: Successful"; - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, NULL, 0, mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); // sending crap (because of thisReceiver interface) - - // return ok/fail return ret; } @@ -2753,8 +2252,6 @@ int slsReceiverTCPIPInterface::set_discard_policy() { if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2776,21 +2273,11 @@ int slsReceiverTCPIPInterface::set_discard_policy() { FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "frame discard policy:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2807,8 +2294,6 @@ int slsReceiverTCPIPInterface::set_padding_enable() { if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 ) return printSocketReadError(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS if (receiverBase == NULL) invalidReceiverObject(); else { @@ -2831,21 +2316,11 @@ int slsReceiverTCPIPInterface::set_padding_enable() { FILE_LOG(logERROR) << mess; } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "Frame Padding Enable:" << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } @@ -2865,8 +2340,6 @@ int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() { if (myDetectorType != EIGER) functionNotImplemented(); - // execute action -#ifdef SLS_RECEIVER_UDP_FUNCTIONS else { if (receiverBase == NULL) invalidReceiverObject(); @@ -2890,20 +2363,10 @@ int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() { } } } -#endif -#ifdef VERYVERBOSE FILE_LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval; -#endif - if (ret == OK && mySock->differentClients) - ret = FORCE_UPDATE; + clientInterface->Server_SendResult(mySock->differentClients, + ret, &retval, sizeof(retval), mess); - // send answer - mySock->SendDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) - mySock->SendDataOnly(mess,sizeof(mess)); - mySock->SendDataOnly(&retval,sizeof(retval)); - - // return ok/fail return ret; } diff --git a/slsReceiverSoftware/src/slsReceiverUsers.cpp b/slsReceiverSoftware/src/slsReceiverUsers.cpp index f65751dbb..f2c2c359d 100644 --- a/slsReceiverSoftware/src/slsReceiverUsers.cpp +++ b/slsReceiverSoftware/src/slsReceiverUsers.cpp @@ -6,9 +6,9 @@ slsReceiverUsers::slsReceiverUsers(int argc, char *argv[], int &success) { try { slsReceiver* r = new slsReceiver(argc, argv); receiver = r; - success = slsReceiverDefs::OK; + success = slsDetectorDefs::OK; } catch (...) { - success = slsReceiverDefs::FAIL; + success = slsDetectorDefs::FAIL; } } diff --git a/slsSupportLib/include/ClientInterface.cpp b/slsSupportLib/include/ClientInterface.cpp index ce7f8e4f9..cc7834eff 100644 --- a/slsSupportLib/include/ClientInterface.cpp +++ b/slsSupportLib/include/ClientInterface.cpp @@ -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)); + 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); } diff --git a/slsSupportLib/include/ClientInterface.h b/slsSupportLib/include/ClientInterface.h index 19bb644a9..f5b72f172 100644 --- a/slsSupportLib/include/ClientInterface.h +++ b/slsSupportLib/include/ClientInterface.h @@ -1,7 +1,7 @@ #pragma once -#include "sls_receiver_defs.h" +#include "sls_detector_defs.h" #include "MySocketTCP.h" @@ -10,7 +10,7 @@ */ // 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: @@ -39,12 +39,14 @@ public: 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 retval pointer to 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 @@ -54,7 +56,7 @@ public: * @param mess message * @returns FAIL if unrecognized function found in message, else OK */ - int Client_GetMesage(char* mess=0); + int Client_GetMesage(char* mess = 0); /** * Send Arguments to server and get result back diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index 876da5437..0e5bdfcb7 100755 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -1,5 +1,11 @@ -#ifndef SLS_DETECTOR_DEFS_H -#define SLS_DETECTOR_DEFS_H +#pragma once +/************************************************ + * @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__ @@ -7,10 +13,29 @@ #define __cplusplus #endif -//#include -#include "sls_receiver_defs.h" +#include +#ifdef __cplusplus +#include +#include +#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 */ #define MAX_ROIS 100 @@ -20,390 +45,847 @@ /** maximum unit size of program sent to detector */ #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_IP "129.129.202.46" - -/** - \file sls_detector_defs.h -This file contains all the basic definitions common to the slsDetector class -and to the server programs running on the detector +/** 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 - * @author Anna Bergamaschi - * @version 0.1alpha (any string) - * @see slsDetector - -*/ +#define DEFAULT_STREAMING_TIMER_IN_MS 200 -/** get flag form most functions */ -#define GET_FLAG -1 +typedef char mystring[MAX_STR_LENGTH]; #ifdef __cplusplus - -/** @short class containing all the structures, constants and enum definitions */ -class slsDetectorDefs: public virtual slsReceiverDefs{ - public: - - slsDetectorDefs(){}; - +class slsDetectorDefs { +public: + slsDetectorDefs(){}; #endif - -/** - @short structure for a detector module - - should not be used by unexperienced users - - \see :: moduleRegisterBit ::chipRegisterBit :channelRegisterBit - - @li reg is the module register (e.g. dynamic range? see moduleRegisterBit) - @li dacs is the pointer to the array of dac values (in V) - @li adcs is the pointer to the array of adc values (in V) - @li chipregs is the pointer to the array of chip registers - @li chanregs is the pointer to the array of channel registers - @li gain is the module gain - @li offset is the module offset -*/ -typedef struct { - int serialnumber; /**< is the module serial number */ - int nchan; /**< is the number of channels on the module*/ - int nchip; /**< is the number of chips on the module */ - int ndac; /**< is the number of dacs on the module */ - int nadc; /**< is the number of adcs on the module */ - int reg; /**< is the module register (e.g. dynamic range?) - \see moduleRegisterBit */ - int *dacs; /**< is the pointer to the array of the dac values (in V) */ - int *adcs; /**< is the pointer to the array of the adc values (in V) FLAT_FIELD_CORRECTION*/ - int *chipregs; /**< is the pointer to the array of the chip registers - \see ::chipRegisterBit */ - int *chanregs; /**< is the pointer to the array of the channel registers - \see ::channelRegisterBit */ - double gain; /**< is the module gain (V/keV) */ - double offset; /**< is the module offset (V) */ -} sls_detector_module; + /** + 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 */ + }; -/** - network parameters -*/ - -enum networkParameter { - DETECTOR_MAC, /**< detector MAC */ - DETECTOR_IP, /**< detector IP */ - RECEIVER_HOSTNAME, /**< receiver IP/hostname */ - RECEIVER_UDP_IP, /**< receiever UDP IP */ - RECEIVER_UDP_PORT, /**< receiever UDP Port */ - RECEIVER_UDP_MAC, /**< receiever UDP MAC */ - RECEIVER_UDP_PORT2, /**< receiever UDP Port of second half module for eiger */ - DETECTOR_TXN_DELAY_LEFT, /**< transmission delay on the (left) port for next frame */ - DETECTOR_TXN_DELAY_RIGHT, /**< transmission delay on the right port for next frame */ - DETECTOR_TXN_DELAY_FRAME, /**< transmission delay of a whole frame for all the ports */ - FLOW_CONTROL_10G, /**< flow control for 10GbE */ - FLOW_CONTROL_WR_PTR, /**< memory write pointer for flow control */ - FLOW_CONTROL_RD_PTR, /**< memory read pointer for flow control */ - RECEIVER_STREAMING_PORT, /**< receiever streaming TCP(ZMQ) port */ - CLIENT_STREAMING_PORT, /**< client streaming TCP(ZMQ) port */ - RECEIVER_STREAMING_SRC_IP,/**< receiever streaming TCP(ZMQ) ip */ - CLIENT_STREAMING_SRC_IP, /**< client streaming TCP(ZMQ) ip */ - ADDITIONAL_JSON_HEADER, /**< additional json header (ZMQ) */ - RECEIVER_UDP_SCKT_BUF_SIZE, /**< UDP socket buffer size */ - RECEIVER_REAL_UDP_SCKT_BUF_SIZE /**< real UDP socket buffer size */ -}; - -/** - type of action performed (for text client) -*/ -enum {GET_ACTION, PUT_ACTION, READOUT_ACTION, HELP_ACTION}; - -/** online flags enum \sa setOnline*/ -enum {GET_ONLINE_FLAG=-1, /**< returns wether the detector is in online or offline state */ - OFFLINE_FLAG=0, /**< detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!) */ - ONLINE_FLAG =1/**< detector in online state (i.e. communication to the detector updating the local structure) */ -}; - -/** - flags to get (or set) the size of the detector -*/ -enum numberOf { - MAXMODX, /***/ - M_vIbias, /**< mythen 3 >*/ - M_vIinSh, /**< mythen 3 >*/ - M_VdcSh, /**< mythen 3 >*/ - M_Vth2, /**< mythen 3 >*/ - M_VPL, /**< mythen 3 >*/ - M_Vth3, /**< mythen 3 >*/ - M_casSh, /**< mythen 3 >*/ - M_cas, /**< mythen 3 >*/ - M_vIbiasSh, /**< mythen 3 >*/ - M_vIcin, /**< mythen 3 >*/ - M_vIpreOut, /**< mythen 3 >*/ - V_POWER_A = 100, /**new chiptest board */ - V_POWER_B = 101, /**new chiptest board */ - V_POWER_C = 102, /**new chiptest board */ - V_POWER_D = 103, /**new chiptest board */ - V_POWER_IO =104, /**new chiptest board */ - V_POWER_CHIP=105 ,/**new chiptest board */ - I_POWER_A=106 , /**new chiptest board */ - I_POWER_B=107 , /**new chiptest board */ - I_POWER_C=108 , /**new chiptest board */ - I_POWER_D=109 , /**new chiptest board */ - I_POWER_IO=110 , /**new chiptest board */ - V_LIMIT=111 /**new chiptest board */ -}; - -/** - detector settings indexes -*/ -enum detectorSettings{ - GET_SETTINGS=-1, /**< return current detector settings */ - STANDARD, /**< standard settings */ - FAST, /**< fast settings */ - HIGHGAIN, /**< highgain settings */ - DYNAMICGAIN, /**< dynamic gain settings */ - LOWGAIN, /**< low gain settings */ - MEDIUMGAIN, /**< medium gain settings */ - VERYHIGHGAIN, /**< very high gain settings */ - LOWNOISE, /**< low noise settings */ - DYNAMICHG0, /**< dynamic high gain 0 */ - FIXGAIN1, /**< fix gain 1 */ - FIXGAIN2, /**< fix gain 2 */ - FORCESWITCHG1, /**< force switch gain 1 */ - FORCESWITCHG2, /**< force switch gain 2 */ - VERYLOWGAIN, /**< very low gain settings */ - UNDEFINED=200, /**< undefined or custom settings */ - UNINITIALIZED /**< uninitialiazed (status at startup) */ -}; + /** + 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 */ + }; -#define TRIMBITMASK 0x3f + /** + @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 + */ -/** - important speed parameters -*/ -enum speedVariable { - CLOCK_DIVIDER, /**< readout clock divider */ - PHASE_SHIFT, /**< adds phase shift */ - OVERSAMPLING, /**< oversampling for analog detectors */ - ADC_CLOCK, /**< adc clock divider */ - ADC_PHASE, /**< adc clock phase */ - ADC_PIPELINE, /**< adc pipeline */ - DBIT_CLOCK, /**< adc clock divider */ - DBIT_PHASE, /**< adc clock phase */ - DBIT_PIPELINE /**< adc pipeline */ -}; + 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; - -/** - readout flags -*/ -enum readOutFlags { - GET_READOUT_FLAGS=-1, /**< return readout flags */ - NORMAL_READOUT=0, /**< no flag */ - STORE_IN_RAM=0x1, /**< data are stored in ram and sent only after end of acquisition for faster frame rate */ - READ_HITS=0x2, /**< return only the number of the channel which counted ate least one */ - ZERO_COMPRESSION=0x4,/**< returned data are 0-compressed */ - PUMP_PROBE_MODE=0x8,/** 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 + + should not be used by unexperienced users + + \see :: moduleRegisterBit ::chipRegisterBit :channelRegisterBit + + @li reg is the module register (e.g. dynamic range? see moduleRegisterBit) + @li dacs is the pointer to the array of dac values (in V) + @li adcs is the pointer to the array of adc values (in V) + @li chipregs is the pointer to the array of chip registers + @li chanregs is the pointer to the array of channel registers + @li gain is the module gain + @li offset is the module offset + */ + typedef struct { + int serialnumber; /**< is the module serial number */ + int nchan; /**< is the number of channels on the module*/ + int nchip; /**< is the number of chips on the module */ + int ndac; /**< is the number of dacs on the module */ + int nadc; /**< is the number of adcs on the module */ + int reg; /**< is the module register (e.g. dynamic range?) + \see moduleRegisterBit */ + int *dacs; /**< is the pointer to the array of the dac values (in V) */ + int *adcs; /**< is the pointer to the array of the adc values (in V) FLAT_FIELD_CORRECTION*/ + int *chipregs; /**< is the pointer to the array of the chip registers + \see ::chipRegisterBit */ + int *chanregs; /**< is the pointer to the array of the channel registers + \see ::channelRegisterBit */ + double gain; /**< is the module gain (V/keV) */ + double offset; /**< is the module offset (V) */ + } sls_detector_module; + + + /** + network parameters + */ + + enum networkParameter { + DETECTOR_MAC, /**< detector MAC */ + DETECTOR_IP, /**< detector IP */ + RECEIVER_HOSTNAME, /**< receiver IP/hostname */ + RECEIVER_UDP_IP, /**< receiever UDP IP */ + RECEIVER_UDP_PORT, /**< receiever UDP Port */ + RECEIVER_UDP_MAC, /**< receiever UDP MAC */ + RECEIVER_UDP_PORT2, /**< receiever UDP Port of second half module for eiger */ + DETECTOR_TXN_DELAY_LEFT, /**< transmission delay on the (left) port for next frame */ + DETECTOR_TXN_DELAY_RIGHT, /**< transmission delay on the right port for next frame */ + DETECTOR_TXN_DELAY_FRAME, /**< transmission delay of a whole frame for all the ports */ + FLOW_CONTROL_10G, /**< flow control for 10GbE */ + FLOW_CONTROL_WR_PTR, /**< memory write pointer for flow control */ + FLOW_CONTROL_RD_PTR, /**< memory read pointer for flow control */ + RECEIVER_STREAMING_PORT, /**< receiever streaming TCP(ZMQ) port */ + CLIENT_STREAMING_PORT, /**< client streaming TCP(ZMQ) port */ + RECEIVER_STREAMING_SRC_IP,/**< receiever streaming TCP(ZMQ) ip */ + CLIENT_STREAMING_SRC_IP, /**< client streaming TCP(ZMQ) ip */ + ADDITIONAL_JSON_HEADER, /**< additional json header (ZMQ) */ + RECEIVER_UDP_SCKT_BUF_SIZE, /**< UDP socket buffer size */ + RECEIVER_REAL_UDP_SCKT_BUF_SIZE /**< real UDP socket buffer size */ + }; + + /** + type of action performed (for text client) + */ + enum {GET_ACTION, PUT_ACTION, READOUT_ACTION, HELP_ACTION}; + + /** online flags enum \sa setOnline*/ + enum {GET_ONLINE_FLAG=-1, /**< returns wether the detector is in online or offline state */ + OFFLINE_FLAG=0, /**< detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!) */ + ONLINE_FLAG =1/**< detector in online state (i.e. communication to the detector updating the local structure) */ + }; + + /** + flags to get (or set) the size of the detector + */ + enum numberOf { + MAXMODX, /***/ + M_vIbias, /**< mythen 3 >*/ + M_vIinSh, /**< mythen 3 >*/ + M_VdcSh, /**< mythen 3 >*/ + M_Vth2, /**< mythen 3 >*/ + M_VPL, /**< mythen 3 >*/ + M_Vth3, /**< mythen 3 >*/ + M_casSh, /**< mythen 3 >*/ + M_cas, /**< mythen 3 >*/ + M_vIbiasSh, /**< mythen 3 >*/ + M_vIcin, /**< mythen 3 >*/ + M_vIpreOut, /**< mythen 3 >*/ + V_POWER_A = 100, /**new chiptest board */ + V_POWER_B = 101, /**new chiptest board */ + V_POWER_C = 102, /**new chiptest board */ + V_POWER_D = 103, /**new chiptest board */ + V_POWER_IO =104, /**new chiptest board */ + V_POWER_CHIP=105 ,/**new chiptest board */ + I_POWER_A=106 , /**new chiptest board */ + I_POWER_B=107 , /**new chiptest board */ + I_POWER_C=108 , /**new chiptest board */ + I_POWER_D=109 , /**new chiptest board */ + I_POWER_IO=110 , /**new chiptest board */ + V_LIMIT=111 /**new chiptest board */ + }; + + /** + detector settings indexes + */ + enum detectorSettings{ + GET_SETTINGS=-1, /**< return current detector settings */ + STANDARD, /**< standard settings */ + FAST, /**< fast settings */ + HIGHGAIN, /**< highgain settings */ + DYNAMICGAIN, /**< dynamic gain settings */ + LOWGAIN, /**< low gain settings */ + MEDIUMGAIN, /**< medium gain settings */ + VERYHIGHGAIN, /**< very high gain settings */ + LOWNOISE, /**< low noise settings */ + DYNAMICHG0, /**< dynamic high gain 0 */ + FIXGAIN1, /**< fix gain 1 */ + FIXGAIN2, /**< fix gain 2 */ + FORCESWITCHG1, /**< force switch gain 1 */ + FORCESWITCHG2, /**< force switch gain 2 */ + VERYLOWGAIN, /**< very low gain settings */ + UNDEFINED=200, /**< undefined or custom settings */ + UNINITIALIZED /**< uninitialiazed (status at startup) */ + }; + + + #define TRIMBITMASK 0x3f + + + /** + important speed parameters + */ + enum speedVariable { + CLOCK_DIVIDER, /**< readout clock divider */ + PHASE_SHIFT, /**< adds phase shift */ + OVERSAMPLING, /**< oversampling for analog detectors */ + ADC_CLOCK, /**< adc clock divider */ + ADC_PHASE, /**< adc clock phase */ + ADC_PIPELINE, /**< adc pipeline */ + DBIT_CLOCK, /**< adc clock divider */ + DBIT_PHASE, /**< adc clock phase */ + DBIT_PIPELINE /**< adc pipeline */ + }; + + + /** + readout flags + */ + enum readOutFlags { + GET_READOUT_FLAGS=-1, /**< return readout flags */ + NORMAL_READOUT=0, /**< no flag */ + STORE_IN_RAM=0x1, /**< data are stored in ram and sent only after end of acquisition for faster frame rate */ + READ_HITS=0x2, /**< return only the number of the channel which counted ate least one */ + ZERO_COMPRESSION=0x4,/**< returned data are 0-compressed */ + PUMP_PROBE_MODE=0x8,/** -#ifdef __cplusplus -#include -#include -#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, /** 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 -; diff --git a/slsSupportLib/include/utilities.cpp b/slsSupportLib/include/utilities.cpp index 39110e5ac..d3ebe74b2 100644 --- a/slsSupportLib/include/utilities.cpp +++ b/slsSupportLib/include/utilities.cpp @@ -13,7 +13,7 @@ int read_config_file(std::string fname, int *tcpip_port_no, std::ifstream infile; std::string sLine,sargname, sargvalue; int iline = 0; - int success = slsReceiverDefs::OK; + int success = slsDetectorDefs::OK; 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); } catch(...) { 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()){ getline(infile,sLine); iline++; @@ -58,7 +58,7 @@ int read_config_file(std::string fname, int *tcpip_port_no, cprintf(RESET, "dataport: %d\n" , *tcpip_port_no); else{ 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) { if (data==NULL) - return slsReceiverDefs::FAIL; + return slsDetectorDefs::FAIL; for (int ichan=0; ichan #include