From b5c35ddeacff28c5aa49f98e73da78ce980df135 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 5 Oct 2018 15:28:25 +0200 Subject: [PATCH] slsdetector and users updated to reflect new signatures, not yet compiled --- commonFiles/error_defs.h | 8 +- commonFiles/sls_detector_defs.h | 6 +- commonFiles/sls_receiver_funcs.h | 4 +- slsDetectorSoftware/CMakeLists.txt | 8 - slsDetectorSoftware/Makefile | 12 +- slsDetectorSoftware/doxy.config | 7 - .../multiSlsDetector/multiSlsDetector.cpp | 283 +++- .../multiSlsDetector/multiSlsDetector.h | 234 ++- .../slsDetector/slsDetector.cpp | 661 +++------ slsDetectorSoftware/slsDetector/slsDetector.h | 207 +-- .../slsDetector/slsDetectorBase.h | 1226 +--------------- .../slsDetector/slsDetectorCommand.cpp | 39 +- .../slsDetector/slsDetectorCommand.h | 2 - .../slsDetector/slsDetectorUsers.cpp | 620 ++++---- .../slsDetector/slsDetectorUsers.h | 1306 ++++++++++------- .../slsDetectorClient/CMakeLists.txt | 3 - .../slsDetectorClient/Makefile | 2 +- 17 files changed, 1748 insertions(+), 2880 deletions(-) diff --git a/commonFiles/error_defs.h b/commonFiles/error_defs.h index 341020887..6b521689c 100644 --- a/commonFiles/error_defs.h +++ b/commonFiles/error_defs.h @@ -58,7 +58,7 @@ // 0x000000FFFFFFFFFFULL #define COULDNOT_SET_NETWORK_PARAMETER 0x0000000000000001ULL #define COULDNOT_SET_ROI 0x0000000000000002ULL -#define RECEIVER_READ_FREQUENCY 0x0000000000000004ULL +#define RECEIVER_STREAMING_FREQUENCY 0x0000000000000004ULL #define SETTINGS_NOT_SET 0x0000000000000008ULL #define SETTINGS_FILE_NOT_OPEN 0x0000000000000010ULL #define DETECTOR_TIMER_VALUE_NOT_SET 0x0000000000000020ULL @@ -81,7 +81,7 @@ #define DATA_STREAMING 0x0000000000400000ULL #define RESET_ERROR 0x0000000000800000ULL #define POWER_CHIP 0x0000000001000000ULL -#define RECEIVER_READ_TIMER 0x0000000002000000ULL +#define RECEIVER_STREAMING_TIMER 0x0000000002000000ULL #define RECEIVER_ACQ_TIME_NOT_SET 0x0000000004000000ULL #define RECEIVER_FLIPPED_DATA_NOT_SET 0x0000000008000000ULL #define THRESHOLD_NOT_SET 0x0000000010000000ULL @@ -179,7 +179,7 @@ public: if(slsErrorMask&COULDNOT_SET_ROI) retval.append("Could not set the exact region of interest. Verify ROI set by detector.\n"); - if(slsErrorMask&RECEIVER_READ_FREQUENCY) + if(slsErrorMask&RECEIVER_STREAMING_FREQUENCY) retval.append("Could not set receiver read frequency.\n"); if(slsErrorMask&SETTINGS_NOT_SET) @@ -254,7 +254,7 @@ public: if(slsErrorMask&POWER_CHIP) retval.append("Could not power on/off/get the chip\n"); - if(slsErrorMask&RECEIVER_READ_TIMER) + if(slsErrorMask&RECEIVER_STREAMING_TIMER) retval.append("Could not set receiver read timer\n"); if(slsErrorMask&RECEIVER_FLIPPED_DATA_NOT_SET) diff --git a/commonFiles/sls_detector_defs.h b/commonFiles/sls_detector_defs.h index 430117bad..a6f21665a 100755 --- a/commonFiles/sls_detector_defs.h +++ b/commonFiles/sls_detector_defs.h @@ -22,8 +22,6 @@ typedef char mystring[MAX_STR_LENGTH]; -typedef int dacs_t; - #define DEFAULT_DET_MAC "00:aa:bb:cc:dd:ee" #define DEFAULT_DET_IP "129.129.202.46" @@ -80,8 +78,8 @@ typedef struct { int nadc; /**< is the number of adcs on the module */ int reg; /**< is the module register (e.g. dynamic range?) \see moduleRegisterBit */ - dacs_t *dacs; /**< is the pointer to the array of the dac values (in V) */ - dacs_t *adcs; /**< is the pointer to the array of the adc values (in V) FLAT_FIELD_CORRECTION*/ + 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 diff --git a/commonFiles/sls_receiver_funcs.h b/commonFiles/sls_receiver_funcs.h index a380e44b7..8376f8afe 100644 --- a/commonFiles/sls_receiver_funcs.h +++ b/commonFiles/sls_receiver_funcs.h @@ -28,7 +28,7 @@ enum recFuncs{ //Acquisition setup functions F_SET_RECEIVER_TIMER, /**< set/get timer value */ F_SET_RECEIVER_DYNAMIC_RANGE, /**< set/get detector dynamic range */ - F_READ_RECEIVER_FREQUENCY, /**< sets the frequency of receiver sending frames to gui */ + F_RECEIVER_STREAMING_FREQUENCY, /**< sets the frequency of receiver sending frames to gui */ // Acquisition functions F_GET_RECEIVER_STATUS, /**< gets the status of receiver listening mode */ @@ -51,7 +51,7 @@ enum recFuncs{ F_RECEIVER_ACTIVATE, /** < activate/deactivate readout */ F_STREAM_DATA_FROM_RECEIVER, /**< stream data from receiver to client */ - F_READ_RECEIVER_TIMER, /** < sets the timer between each data stream in receiver */ + F_RECEIVER_STREAMING_TIMER, /** < sets the timer between each data stream in receiver */ F_SET_FLIPPED_DATA_RECEIVER, /** < sets the enable to flip data across x/y axis (bottom/top) */ F_SET_RECEIVER_FILE_FORMAT, /** < sets the receiver file format */ diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index 9fb82c08b..f24ce55c4 100644 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -5,9 +5,6 @@ set(SOURCES slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp slsReceiverInterface/receiverInterface.cpp - threadFiles/CondVar.cpp - threadFiles/Mutex.cpp - threadFiles/ThreadPool.cpp ../commonFiles/utilities.cpp ) @@ -20,11 +17,6 @@ multiSlsDetector sharedMemory slsDetector slsReceiverInterface -threadFiles -) - -add_definitions( - -DDACS_INT ) add_library(slsDetectorStatic STATIC diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index b8ac5ffb7..870614aea 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -9,15 +9,15 @@ CFLAGS= -g -DC_ONLY -fPIC DFLAGS= -g -DDACS_INT -INCLUDES?= -I../commonFiles -IslsDetector -I../slsReceiverSoftware/MySocketTCP -ImultiSlsDetector -IslsReceiverInterface -I../slsReceiverSoftware/include -IthreadFiles -IsharedMemory -I$(ASM) +INCLUDES?= -I../commonFiles -IslsDetector -ImultiSlsDetector -IslsReceiverInterface -IsharedMemory -I$(ASM) #EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -Wl,-R/usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -lca -lCom LIBZMQDIR = ../commonFiles LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq -SRC_CLNT= slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsReceiverInterface/receiverInterface.cpp slsDetector/slsDetectorUsers.cpp threadFiles/CondVar.cpp threadFiles/Mutex.cpp threadFiles/ThreadPool.cpp sharedMemory/SharedMemory.cpp ../commonFiles/utilities.cpp#../slsReceiverSoftware/MySocketTCP/MySocketTCP.cpp -DEPSINCLUDES = ../commonFiles/sls_receiver_defs.h ../commonFiles/sls_receiver_funcs.h ../commonFiles/ansi.h ../commonFiles/sls_detector_defs.h ../commonFiles/sls_detector_funcs.h ../commonFiles/error_defs.h slsDetector/slsDetectorBase.h slsDetector/detectorData.h threadFiles/Global.h threadFiles/Task.h sharedMemory/SharedMemory.h ../commonFiles/sls_receiver_exceptions.h ../commonFiles/versionAPI.h ../commonFiles/utilities.h +SRC_CLNT= slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsReceiverInterface/receiverInterface.cpp slsDetector/slsDetectorUsers.cpp sharedMemory/SharedMemory.cpp ../commonFiles/utilities.cpp#../slsReceiverSoftware/MySocketTCP/MySocketTCP.cpp +DEPSINCLUDES = ../commonFiles/sls_receiver_defs.h ../commonFiles/sls_receiver_funcs.h ../commonFiles/ansi.h ../commonFiles/sls_detector_defs.h ../commonFiles/sls_detector_funcs.h ../commonFiles/error_defs.h slsDetector/slsDetectorBase.h slsDetector/detectorData.h sharedMemory/SharedMemory.h ../commonFiles/sls_receiver_exceptions.h ../commonFiles/versionAPI.h ../commonFiles/utilities.h @@ -36,12 +36,6 @@ OBJS = $(SRC_CLNT:%.cpp=%.o) all: package $(SRC_CLNT) -mythenVirtualServer: $(SRC_MYTHEN_SVC) - cd mythenDetectorServer && make -f Makefile.virtual DESTDIR=$(DESTDIR) - -gotthardVirtualServer: $(SRC_MYTHEN_SVC) - cd gotthardDetectorServer && make -f Makefile.virtual DESTDIR=$(DESTDIR) - %.o : %.cpp %.h $(DEPSINCLUDES) Makefile $(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -pthread -lrt $(LIBZMQ) $(FLAGS) diff --git a/slsDetectorSoftware/doxy.config b/slsDetectorSoftware/doxy.config index ce0c700f7..b7546c379 100644 --- a/slsDetectorSoftware/doxy.config +++ b/slsDetectorSoftware/doxy.config @@ -101,13 +101,6 @@ INPUT = ../commonfiles/communication_funcs.h \ slsDetector/slsDetectorUsers.h \ slsDetector/detectorData.h \ slsReceiverInterface/receiverInterface.h \ - threadFiles/CondVar.h \ - threadFiles/Global.h \ - threadFiles/Multi.h \ - threadFiles/Mutex.h \ - threadFiles/Single.h \ - threadFiles/Task.h \ - threadFiles/ThreadPool.h \ ../slsReceiverSoftware/include/BinaryFile.h \ ../slsReceiverSoftware/include/BinaryFileStatic.h \ ../slsReceiverSoftware/include/circularFifo.h \ diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 115d399a4..3e67c5456 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -486,7 +486,7 @@ void multiSlsDetector::initializeMembers(bool verify) { // get objects from single det shared memory (open) for (int i = 0; i < thisMultiDetector->numberOfDetectors; i++) { try { - slsDetector* sdet = new slsDetector(detId, i, verify, this); + slsDetector* sdet = new slsDetector(detId, i, verify); detectors.push_back(sdet); } catch (...) { // clear detectors list @@ -620,7 +620,7 @@ void multiSlsDetector::addSlsDetector (std::string s) { int pos = (int)detectors.size(); - slsDetector* sdet = new slsDetector(type, detId, pos, false, this); + slsDetector* sdet = new slsDetector(type, detId, pos, false); detectors.push_back(sdet); thisMultiDetector->numberOfDetectors = detectors.size(); @@ -724,13 +724,13 @@ int multiSlsDetector::setMaxNumberOfChannelsPerDetector(dimension d,int i) { } -int multiSlsDetector::getDetectorOffset(dimension d, int pos) { - return detectors[pos]->getDetectorOffset(d); +int multiSlsDetector::getDetectorOffset(dimension d, int detPos) { + return detectors[detPos]->getDetectorOffset(d); } -void multiSlsDetector::setDetectorOffset(dimension d, int off, int pos) { - detectors[pos]->setDetectorOffset(d, off); +void multiSlsDetector::setDetectorOffset(dimension d, int off, int detPos) { + detectors[detPos]->setDetectorOffset(d, off); } @@ -871,6 +871,10 @@ void multiSlsDetector::updateOffsets() { thisMultiDetector->numberOfChannelInclGapPixels[Y] << std::endl << std::endl; #endif + + serialCall(&slsDetector::updateMultiSize, + thisMultiDetector->numberOfDetector[0], + thisMultiDetector->numberOfDetector[1]); } @@ -1215,43 +1219,6 @@ std::string multiSlsDetector::setSettingsDir(std::string s, int detPos) { } -std::string multiSlsDetector::getCalDir(int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->getCalDir(); - } - - // multi - auto r = serialCall(&slsDetector::getCalDir); - return sls::concatenateIfDifferent(r); -} - - -std::string multiSlsDetector::setCalDir(std::string s, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setCalDir(s); - } - - // multi - size_t p1 = 0; - size_t p2 = s.find('+', p1); - int id = 0; - while (p2 != std::string::npos) { - detectors[id]->setCalDir(s.substr(p1, p2 - p1)); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - ++id; - s = s.substr(p2 + 1); - p2 = s.find('+'); - if (id >= (int)detectors.size()) - break; - } - - return getCalDir(); -} - - int multiSlsDetector::loadSettingsFile(std::string fname, int detPos) { // single if (detPos >= 0) { @@ -1275,30 +1242,6 @@ int multiSlsDetector::saveSettingsFile(std::string fname, int detPos) { } -int multiSlsDetector::loadCalibrationFile(std::string fname, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->loadCalibrationFile(fname); - } - - // multi - auto r = parallelCall(&slsDetector::loadCalibrationFile, fname); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; -} - -int multiSlsDetector::saveCalibrationFile(std::string fname, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->saveCalibrationFile(fname); - } - - // multi - auto r = parallelCall(&slsDetector::saveCalibrationFile, fname); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; -} - - - slsDetectorDefs::runStatus multiSlsDetector::getRunStatus(int detPos) { // single if (detPos >= 0) { @@ -1442,11 +1385,11 @@ int multiSlsDetector::readAll(int detPos) { int multiSlsDetector::configureMAC(int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->configureMAC(); + return detectors[detPos]->configureMAC(getNumberOfDetectors(Y)); } // multi - auto r = parallelCall(&slsDetector::configureMAC); + auto r = parallelCall(&slsDetector::configureMAC, getNumberOfDetectors(Y)); return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; } @@ -1501,6 +1444,122 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int detPos) { } +double multiSlsDetector::setExposureTime(double t, bool inseconds, int detPos){ + if(!inseconds) + return setTimer(ACQUISITION_TIME, (int64_t)t, detPos); + + // + 0.5 to round for precision lost from converting double to int64_t + int64_t tms = (int64_t)(t * (1E+9) + 0.5); + if (t < 0) tms = -1; + tms = setTimer(ACQUISITION_TIME, tms, detPos); + if (tms < 0) + return -1; + return ((1E-9) * (double)tms); +} + + +double multiSlsDetector::setExposurePeriod(double t, bool inseconds, int detPos){ + if(!inseconds) + return setTimer(FRAME_PERIOD, (int64_t)t, detPos); + + // + 0.5 to round for precision lost from converting double to int64_t + int64_t tms = (int64_t)(t * (1E+9) + 0.5); + if (t < 0) tms = -1; + tms = setTimer(FRAME_PERIOD, tms, detPos); + if (tms < 0) + return -1; + return ((1E-9) * (double)tms); +} + + +double multiSlsDetector::setDelayAfterTrigger(double t, bool inseconds, int detPos){ + if(!inseconds) + return setTimer(DELAY_AFTER_TRIGGER, (int64_t)t, detPos); + + // + 0.5 to round for precision lost from converting double to int64_t + int64_t tms = (int64_t)(t * (1E+9) + 0.5); + if (t < 0) tms = -1; + tms = setTimer(DELAY_AFTER_TRIGGER, tms, detPos); + if (tms < 0) + return -1; + return ((1E-9) * (double)tms); +} + + +double multiSlsDetector::setSubFrameExposureTime(double t, bool inseconds, int detPos){ + if(!inseconds) + return setTimer(SUBFRAME_ACQUISITION_TIME, (int64_t)t, detPos); + else { + // + 0.5 to round for precision lost from converting double to int64_t + int64_t tms = (int64_t)(t * (1E+9) + 0.5); + if (t < 0) tms = -1; + tms = setTimer(SUBFRAME_ACQUISITION_TIME, tms, detPos); + if (tms < 0) + return -1; + return ((1E-9) * (double)tms); + } +} + + +double multiSlsDetector::setSubFrameExposureDeadTime(double t, bool inseconds, int detPos){ + if(!inseconds) + return setTimer(SUBFRAME_DEADTIME, (int64_t)t, detPos); + else { + // + 0.5 to round for precision lost from converting double to int64_t + int64_t tms = (int64_t)(t * (1E+9) + 0.5); + if (t < 0) tms = -1; + tms = setTimer(SUBFRAME_DEADTIME, tms, detPos); + if (tms < 0) + return -1; + return ((1E-9) * (double)tms); + } +} + + +int64_t multiSlsDetector::setNumberOfFrames(int64_t t, int detPos){ + return setTimer(FRAME_NUMBER, t, detPos); +} + + +int64_t multiSlsDetector::setNumberOfCycles(int64_t t, int detPos){ + return setTimer(CYCLES_NUMBER, t, detPos); +} + + +int64_t multiSlsDetector::setNumberOfGates(int64_t t, int detPos){ + return setTimer(GATES_NUMBER, t, detPos); +} + + +int64_t multiSlsDetector::setNumberOfStorageCells(int64_t t, int detPos) { + return setTimer(STORAGE_CELL_NUMBER, t, detPos); +} + + +double multiSlsDetector::getMeasuredPeriod(bool inseconds, int detPos){ + if(!inseconds) + return getTimeLeft(MEASURED_PERIOD, detPos); + else { + int64_t tms = getTimeLeft(MEASURED_PERIOD, detPos); + if (tms < 0) + return -1; + return ((1E-9) * (double)tms); + } +} + + +double multiSlsDetector::getMeasuredSubFramePeriod(bool inseconds, int detPos){ + if(!inseconds) + return getTimeLeft(MEASURED_SUBPERIOD, detPos); + else { + int64_t tms = getTimeLeft(MEASURED_SUBPERIOD, detPos); + if (tms < 0) + return -1; + return ((1E-9) * (double)tms); + } +} + + int64_t multiSlsDetector::getTimeLeft(timerIndex index, int detPos) { // single if (detPos >= 0) { @@ -1585,7 +1644,7 @@ int multiSlsDetector::getDataBytes(int detPos) { } -dacs_t multiSlsDetector::setDAC(dacs_t val, dacIndex idac, int mV, int detPos) { +int multiSlsDetector::setDAC(int val, dacIndex idac, int mV, int detPos) { // single if (detPos >= 0) { return detectors[detPos]->setDAC(val, idac, mV); @@ -1597,7 +1656,7 @@ dacs_t multiSlsDetector::setDAC(dacs_t val, dacIndex idac, int mV, int detPos) { return sls::minusOneIfDifferent(r); // ignore slave values for hv (-999) - dacs_t firstValue = r.front(); + int firstValue = r.front(); for (const auto& value : r) { if ((value != -999) && (value != firstValue)) return -1; @@ -1607,7 +1666,7 @@ dacs_t multiSlsDetector::setDAC(dacs_t val, dacIndex idac, int mV, int detPos) { } -dacs_t multiSlsDetector::getADC(dacIndex idac, int detPos) { +int multiSlsDetector::getADC(dacIndex idac, int detPos) { // single if (detPos >= 0) { return detectors[detPos]->getADC(val, idac); @@ -1733,6 +1792,7 @@ uint32_t multiSlsDetector::clearBit(uint32_t addr, int n, int detPos) { } + std::string multiSlsDetector::setNetworkParameter(networkParameter p, std::string s, int detPos) { // single if (detPos >= 0) { @@ -1789,6 +1849,71 @@ std::string multiSlsDetector::getNetworkParameter(networkParameter p, int detPos } +int multiSlsDetector::setReceiverDataStreamingOutPort(int i, int detPos) { + if (i >= 0) { + std::string s = to_string(i); + int prev_streaming = enableDataStreamingFromReceiver(-1, detPos); + setNetworkParameter(RECEIVER_STREAMING_PORT, s, detPos); + if (prev_streaming) { + enableDataStreamingFromReceiver(0, detPos); + enableDataStreamingFromReceiver(1, detPos); + } + } + return stoi(getNetworkParameter(RECEIVER_STREAMING_PORT, detPos)); +} + + +int multiSlsDetector::setClientDataStreamingInPort(int i, int detPos) { + if (i >= 0) { + std::string s = to_string(i); + int prev_streaming = enableDataStreamingToClient(); + setNetworkParameter(CLIENT_STREAMING_PORT, s, detPos); + if (prev_streaming) { + enableDataStreamingToClient(0); + enableDataStreamingToClient(1); + } + } + return stoi(getNetworkParameter(CLIENT_STREAMING_PORT, detPos)); +} + + +std::string multiSlsDetector::setReceiverDataStreamingOutIP(std::string ip, int detPos) { + if (ip.length()) { + int prev_streaming = enableDataStreamingFromReceiver(-1, detPos); + setNetworkParameter(RECEIVER_STREAMING_SRC_IP, ip, detPos); + if (prev_streaming) { + enableDataStreamingFromReceiver(0, detPos); + enableDataStreamingFromReceiver(1, detPos); + } + } + return getNetworkParameter(RECEIVER_STREAMING_SRC_IP, detPos); +} + + +std::string multiSlsDetector::setClientDataStreamingInIP(std::string ip, int detPos) { + if (ip.length()) { + int prev_streaming = enableDataStreamingToClient(-1); + setNetworkParameter(CLIENT_STREAMING_SRC_IP, ip, detPos); + if (prev_streaming) { + enableDataStreamingToClient(0); + enableDataStreamingToClient(1); + } + } + return getNetworkParameter(CLIENT_STREAMING_SRC_IP, detPos); +} + + +int multiSlsDetector::setFlowControl10G(int enable, int detPos) { + std::string s; + if (i != -1) { + s = to_string((enable >= 1) ? 1 : 0); + s = setNetworkParameter(FLOW_CONTROL_10G, s); + } else + s = getNetworkParameter(FLOW_CONTROL_10G); + return stoi(s); +} + + int multiSlsDetector::digitalTest(digitalTestMode mode, int ival, int detPos) { // single if (detPos >= 0) { @@ -3234,31 +3359,31 @@ int multiSlsDetector::overwriteFile(int enable, int detPos) { } -int multiSlsDetector::setReadReceiverFrequency(int freq, int detPos) { +int multiSlsDetector::setReceiverStreamingFrequency(int freq, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->setReadReceiverFrequency(freq); + return detectors[detPos]->setReceiverStreamingFrequency(freq); } // multi - auto r = parallelCall(&slsDetector::setReadReceiverFrequency, freq); + auto r = parallelCall(&slsDetector::setReceiverStreamingFrequency, freq); return sls::minusOneIfDifferent(r); } -int multiSlsDetector::setReceiverReadTimer(int time_in_ms, int detPos) { +int multiSlsDetector::setReceiverStreamingTimer(int time_in_ms, int detPos) { // single if (detPos >= 0) { - return detectors[detPos]->setReceiverReadTimer(time_in_ms); + return detectors[detPos]->setReceiverStreamingTimer(time_in_ms); } // multi - auto r = parallelCall(&slsDetector::setReceiverReadTimer, time_in_ms); + auto r = parallelCall(&slsDetector::setReceiverStreamingTimer, time_in_ms); return sls::minusOneIfDifferent(r); } -int multiSlsDetector::enableDataStreamingToClient(int enable, int detPos) { +int multiSlsDetector::enableDataStreamingToClient(int enable) { if (enable >= 0) { //destroy data threads if (!enable) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 639a49af3..2b2c32111 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -308,9 +308,7 @@ public: std::string sgetDetectorsType(int detPos = -1); /** - * Just to overload getDetectorType from users - * Concatenates string types of all sls detectors or - * returns the detector type of the first sls detector + * Gets Detector type (concatenates if different) * @param detPos -1 for all detectors in list or specific detector position * @returns detector type of sls detector in position pos, if -1, concatenates */ @@ -336,7 +334,6 @@ public: */ void getNumberOfDetectors(int& nx, int& ny); - /** * Returns the total number of channels of all sls detectors from shared memory * @param detPos -1 for all detectors in list or specific detector position @@ -385,16 +382,18 @@ public: /** * Get Detector offset from shared memory in dimension d * @param d dimension d + * @param detPos -1 for all detectors in list or specific detector position * @returns offset in dimension d, -1 if pos is not an actual position in list */ - int getDetectorOffset(dimension d); + int getDetectorOffset(dimension d, int detPos = -1); /** * Set Detector offset in shared memory in dimension d * @param d dimension d * @param off offset for detector + * @param detPos -1 for all detectors in list or specific detector position */ - void setDetectorOffset(dimension d, int off); + void setDetectorOffset(dimension d, int off, int detPos = -1); /** * Updates the channel offsets in X and Y dimension for all the sls detectors @@ -522,21 +521,6 @@ public: */ std::string setSettingsDir(std::string s, int detPos = -1); - /** - * Returns the calibration files directory \sa sharedSlsDetector - * @param detPos -1 for all detectors in list or specific detector position - * @returns the calibration files directory - */ - std::string getCalDir(int detPos = -1); - - /** - * Sets the calibration files directory \sa sharedSlsDetector ( - * @param s the calibration files directory - * @param detPos -1 for all detectors in list or specific detector position - * @returns the calibration files directory - */ - std::string setCalDir(std::string s, int detPos = -1); - /** * Loads the modules settings/trimbits reading from a specific file * file name extension is automatically generated. @@ -555,24 +539,6 @@ public: */ int saveSettingsFile(std::string fname, int detPos = -1); - /** - * Loads the modules calibration data reading from a specific file (Mythen) - * file name extension is automatically generated. - * @param fname specific calibration file - * @param detPos -1 for all detectors in list or specific detector position - * returns OK or FAIL - */ - int loadCalibrationFile(std::string fname, int detPos = -1); - - /** - * Saves the modules calibration data to a specific file (Mythen) - * file name extension is automatically generated. - * @param fname specific calibration file - * @param detPos -1 for all detectors in list or specific detector position - * returns OK or FAIL - */ - int saveCalibrationFile(std::string fname, int detPos = -1); - /** * Get Detector run status * @param detPos -1 for all detectors in list or specific detector position @@ -645,6 +611,103 @@ public: */ int64_t setTimer(timerIndex index, int64_t t=-1, int detPos = -1); + /** + * Set/get exposure time + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns exposure time in ns, or s if specified + */ + double setExposureTime(double t = -1, bool inseconds = false, int detPos = -1); + + /** + * Set/get exposure period + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns exposure period in ns, or s if specified + */ + double setExposurePeriod(double t = -1, bool inseconds = false, int detPos = -1); + + /** + * Set/get delay after trigger (Gotthard, Jungfrau(not for this release)) + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns delay after trigger in ns, or s if specified + */ + double setDelayAfterTrigger(double t = -1, bool inseconds = false, int detPos = -1); + + /** + * (Advanced users) + * Set/get sub frame exposure time (Eiger in 32 bit mode) + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns sub frame exposure time in ns, or s if specified + */ + double setSubFrameExposureTime(double t = -1, bool inseconds = false, int detPos = -1); + + /** + * (Advanced users) + * Set/get sub frame dead time (Eiger in 32 bit mode) + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns sub frame dead time in ns, or s if specified + */ + double setSubFrameDeadTime(double t = -1, bool inseconds = false, int detPos = -1); + + /** + * Set/get number of frames + * @param t number of frames (-1 gets) + * @param detPos -1 for all detectors in list or specific detector position + * @returns number of frames + */ + int64_t setNumberOfFrames(int64_t t = -1, int detPos = -1); + + /** + * Set/get number of cycles + * @param t number of cycles (-1 gets) + * @param detPos -1 for all detectors in list or specific detector position + * @returns number of cycles + */ + int64_t setNumberOfCycles(int64_t t = -1, int detPos = -1); + + /** + * Set/get number of gates (none of the detectors at the moment) + * @param t number of gates (-1 gets) + * @param detPos -1 for all detectors in list or specific detector position + * @returns number of gates + */ + int64_t setNumberOfGates(int64_t t = -1, int detPos = -1); + + /** + * Set/get number of additional storage cells (Jungfrau) + * @param t number of additional storage cells. Default is 0. (-1 gets) + * @param detPos -1 for all detectors in list or specific detector position + * @returns number of additional storage cells + */ + int64_t setNumberOfStorageCells(int64_t t = -1, int detPos = -1); + + /** + * Get measured period between previous two frames (EIGER) + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns sub frame dead time in ns, or s if specified + */ + double getMeasuredPeriod(bool inseconds = false, int detPos = -1); + + /** + * Get sub period between previous two sub frames in 32 bit mode (EIGER) + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns sub frame dead time in ns, or s if specified + */ + double getMeasuredSubFramePeriod(bool inseconds = false, int detPos = -1); + /** * Set/get timer value left in acquisition (not all implemented for all detectors) * @param index timer index @@ -688,7 +751,7 @@ public: * @param detPos -1 for all detectors in list or specific detector position * @returns current DAC value */ - dacs_t setDAC(dacs_t val, dacIndex index , int mV, int detPos = -1); + int setDAC(int val, dacIndex index , int mV, int detPos = -1); /** * Get adc value @@ -696,7 +759,7 @@ public: * @param detPos -1 for all detectors in list or specific detector position * @returns current adc value (temperature for eiger and jungfrau in millidegrees) */ - dacs_t getADC(dacIndex index, int detPos = -1); + int getADC(dacIndex index, int detPos = -1); /** * Set/get timing mode @@ -758,6 +821,21 @@ public: */ uint32_t clearBit(uint32_t addr, int n, int detPos = -1); + /** + * Set up Receiver and update it from shm + * @param s hostname + * @param detPos -1 for all detectors in list or specific detector position + * @returns hostname + */ + std::string setReceiverHostname(std::string s, int detPos = -1); + + /** + * Get receiver hostname + * @param detPos -1 for all detectors in list or specific detector position + * @returns hostname + */ + std::string getReceiverHostname(int detPos = -1); + /** * Set network parameter * @param p network parameter type @@ -775,6 +853,54 @@ public: */ std::string getNetworkParameter(networkParameter p, int detPos = -1); + /** + * (advanced users) + * Set/Get receiver streaming out ZMQ port and restarts receiver sockets + * @param i sets, -1 gets + * If detPos is -1(multi module), port calculated (increments) for all the individual detectors using i + * @param detPos -1 for all detectors in list or specific detector position + * @returns receiver streaming out ZMQ port (if multiple, of first receiver socket) + */ + int setReceiverDataStreamingOutPort(int i = -1, int detPos = -1); + + /** + * (advanced users) + * Set/Get client streaming in ZMQ port and restarts client sockets + * @param i sets, -1 gets + * If detPos is -1(multi module), port calculated (increments) for all the individual detectors using i + * @param detPos -1 for all detectors in list or specific detector position + * @returns receiver streaming out ZMQ port (if multiple, of first receiver socket) + */ + int setClientDataStreamingInPort(int i = -1, int detPos = -1); + + /** + * (advanced users) + * Set/Get receiver streaming out ZMQ IP and restarts receiver sockets + * @param i sets, empty string gets + * By default, it is the IP of receiver hostname + * @param detPos -1 for all detectors in list or specific detector position + * @returns receiver streaming out ZMQ IP + */ + std::string setReceiverDataStreamingOutIP(std::string ip="", int detPos = -1); + + /** + * (advanced users) + * Set/Get client streaming in ZMQ IP and restarts client sockets + * @param i sets, empty string gets + * By default, it is the IP of receiver hostname + * @param detPos -1 for all detectors in list or specific detector position + * @returns client streaming in ZMQ IP + */ + std::string setClientDataStreamingInIP(std::string ip="", int detPos = -1); + + /** + * Set 10GbE Flow Control (Eiger) + * @param enable 1 to set, 0 to unset, -1 gets + * @param detPos -1 for all detectors in list or specific detector position + * @returns 10GbE flow Control + */ + int setFlowControl10G(int enable = -1, int detPos = -1); + /** * Execute a digital test (Gotthard) * @param mode testmode type @@ -1257,33 +1383,31 @@ public: int overwriteFile(int enable=-1, int detPos = -1); /** - * Sets the read receiver frequency - * if data required from receiver randomly readRxrFrequency=0, - * else every nth frame to be sent to gui/callback - * @param freq is the receiver read frequency. Value 0 is 200 ms timer (other - * frames not sent), 1 is every frame, 2 is every second frame etc. + * (previously setReadReceiverFrequency) + * Sets the receiver streaming frequency + * @param freq nth frame streamed out, if 0, streamed out at a timer of 200 ms * @param detPos -1 for all detectors in list or specific detector position - * @returns read receiver frequency + * @returns receiver streaming frequency */ - int setReadReceiverFrequency(int freq=-1, int detPos = -1); + int setReceiverStreamingFrequency(int freq = -1, int detPos = -1); /** - * Sets the read receiver timer - * if data required from receiver randomly readRxrFrequency=0, - * then the timer between each data stream is set with time_in_ms + * (previously setReceiverReadTimer) + * Sets the receiver streaming timer + * If receiver streaming frequency is 0, then this timer between each + * data stream is set. Default is 200 ms. * @param time_in_ms timer between frames * @param detPos -1 for all detectors in list or specific detector position - * @returns read receiver timer + * @returns receiver streaming timer in ms */ - int setReceiverReadTimer(int time_in_ms=500, int detPos = -1); + int setReceiverStreamingTimer(int time_in_ms=500, int detPos = -1); /** * Enable data streaming to client * @param enable 0 to disable, 1 to enable, -1 to get the value - * @param detPos -1 for all detectors in list or specific detector position * @returns data streaming to client enable */ - int enableDataStreamingToClient(int enable=-1, int detPos = -1); + int enableDataStreamingToClient(int enable=-1); /** * Enable or disable streaming data from receiver to client diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 944795714..1afc34189 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -24,12 +24,11 @@ using namespace std; #define DEFAULT_HOSTNAME "localhost" -slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify, multiSlsDetector* m) +slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify) : slsDetectorUtils(), detId(id), sharedMemory(0), thisDetector(0), - multiDet(m), thisReceiver(0), controlSocket(0), stopSocket(0), @@ -59,12 +58,11 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify, mu initializeDetectorStructurePointers(); } -slsDetector::slsDetector(int multiId, int id, bool verify, multiSlsDetector* m) +slsDetector::slsDetector(int multiId, int id, bool verify) : slsDetectorUtils(), detId(id), sharedMemory(0), thisDetector(0), - multiDet(m), thisReceiver(0), controlSocket(0), stopSocket(0), @@ -108,20 +106,6 @@ slsDetector::~slsDetector() { } -void slsDetector::setAcquiringFlag(bool b) { - multiDet->setAcquiringFlag(b); -} - -bool slsDetector::getAcquiringFlag() { - return multiDet->getAcquiringFlag(); -} - - -bool slsDetector::isAcquireReady() { - return multiDet->isAcquireReady(); -} - - int slsDetector::checkVersionCompatibility(portType t) { int fnum = F_CHECK_VERSION; if (t == DATA_PORT) @@ -140,7 +124,7 @@ int slsDetector::checkVersionCompatibility(portType t) { case GOTTHARD: arg = APIGOTTHARD; break; default: std::cout<< "Check version compatibility is not implemented for this " - "detector" << std::endl; + "detector" << std::endl; setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); return FAIL; } @@ -160,7 +144,7 @@ int slsDetector::checkVersionCompatibility(portType t) { cprintf(RED, "Detector returned error: (Control Server) %s", mess); if(strstr(mess,"Unrecognized Function")!=NULL) std::cout << "The detector server is too old to get API version. " - "Please update detector server!" << std::endl; + "Please update detector server!" << std::endl; setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); thisDetector->detectorControlAPIVersion = 0; } else { @@ -181,7 +165,7 @@ int slsDetector::checkVersionCompatibility(portType t) { cprintf(RED, "Detector returned error: (Stop Server) %s", mess); if(strstr(mess,"Unrecognized Function")!=NULL) std::cout << "The detector server is too old to get API " - "version. Please update detector server!" << std::endl; + "version. Please update detector server!" << std::endl; setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); thisDetector->detectorStopAPIVersion = 0; } else { @@ -210,7 +194,7 @@ int slsDetector::checkVersionCompatibility(portType t) { setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); if(strstr(mess,"Unrecognized Function")!=NULL) std::cout << "The receiver software is too old to get API " - "version. Please update receiver software!" << std::endl; + "version. Please update receiver software!" << std::endl; thisDetector->receiverAPIVersion = 0; } else { thisDetector->receiverAPIVersion = arg; @@ -226,7 +210,7 @@ int slsDetector::checkVersionCompatibility(portType t) { -int64_t slsDetector::getId( idMode mode, int imod) { +int64_t slsDetector::getId( idMode mode) { int64_t retval=-1; int fnum=F_GET_ID,fnum2 = F_GET_RECEIVER_ID; @@ -274,7 +258,7 @@ int64_t slsDetector::getId( idMode mode, int imod) { } else { #ifdef VERBOSE std::cout<< "Id "<< mode <<" is " << hex <hostname); } -void slsDetector::addMultipleDetectors(const char* name) { - cprintf(RED, "Error: Add Multiple Detectors should not be called at this level\n"); -} + /* * pre: sharedMemory=0, thisDetector = 0 @@ -435,13 +414,13 @@ int slsDetector::calculateSharedMemorySize(detectorType type) { * size of shared structure + * ffcoefficents+fferrors+modules+dacs+adcs+chips+chans+gain+offset */ int sz = sizeof(sharedSlsDetector) + - 2 * nch * nc * sizeof(double) + - sizeof(sls_detector_module) + - sizeof(int) * nc + - sizeof(dacs_t) * nd + - sizeof(int) * nch * nc + - sizeof(int) * ng + - sizeof(int) * no; + 2 * nch * nc * sizeof(double) + + sizeof(sls_detector_module) + + sizeof(int) * nc + + sizeof(int) * nd + + sizeof(int) * nch * nc + + sizeof(int) * ng + + sizeof(int) * no; #ifdef VERBOSE std::cout<<"Size of shared memory is " << sz << std::endl; #endif @@ -455,20 +434,19 @@ void slsDetector::initializeDetectorStructure(detectorType type) { thisDetector->stoppedFlag = 0; strncpy(thisDetector->hostname, DEFAULT_HOSTNAME, MAX_STR_LENGTH-1); thisDetector->hostname[MAX_STR_LENGTH-1] = 0; + thisDetector->myDetectorType = type; thisDetector->offset[X] = 0; thisDetector->offset[Y] = 0; + thisDetector->multiSize[X] = 0; + thisDetector->multiSize[Y] = 0; thisDetector->controlPort = DEFAULT_PORTNO; thisDetector->stopPort = DEFAULT_PORTNO + 1; - thisDetector->myDetectorType = type; strncpy(thisDetector->settingsDir, getenv("HOME"), MAX_STR_LENGTH-1); thisDetector->settingsDir[MAX_STR_LENGTH-1] = 0; - strncpy(thisDetector->calDir, getenv("HOME"), MAX_STR_LENGTH-1); - thisDetector->calDir[MAX_STR_LENGTH-1] = 0; thisDetector->nTrimEn = 0; for(int i = 0; i < MAX_TRIMEN; ++i) thisDetector->trimEnergies[i] = 0; thisDetector->threadedProcessing = 1; - thisDetector->tDead = 0; thisDetector->nROI = 0; memset(thisDetector->roiLimits, 0, MAX_ROIS * sizeof(ROI)); thisDetector->roFlags = NORMAL_READOUT; @@ -588,9 +566,9 @@ void slsDetector::initializeDetectorStructure(detectorType type) { thisDetector->dacoff = thisDetector->modoff + sizeof(sls_detector_module); thisDetector->adcoff = thisDetector->dacoff + - sizeof(dacs_t) * thisDetector->nDacs; + sizeof(int) * thisDetector->nDacs; thisDetector->chipoff = thisDetector->adcoff + - sizeof(dacs_t) * thisDetector->nAdcs; + sizeof(int) * thisDetector->nAdcs; thisDetector->chanoff = thisDetector->chipoff + sizeof(int) * thisDetector->nChips; thisDetector->gainoff = thisDetector->chanoff + @@ -606,8 +584,8 @@ void slsDetector::initializeMembers() { // assign addresses char *goff = (char*)thisDetector; detectorModules = (sls_detector_module*)(goff + thisDetector->modoff); - dacs = (dacs_t*)(goff + thisDetector->dacoff); - adcs = (dacs_t*)(goff + thisDetector->adcoff); + dacs = (int*)(goff + thisDetector->dacoff); + adcs = (int*)(goff + thisDetector->adcoff); chipregs = (int*)(goff + thisDetector->chipoff); chanregs = (int*)(goff + thisDetector->chanoff); gain = (int*)(goff + thisDetector->gainoff); @@ -617,12 +595,6 @@ void slsDetector::initializeMembers() { thisReceiver = 0; } thisReceiver = new receiverInterface(dataSocket); - - //postProcessing - threadedProcessing = &thisDetector->threadedProcessing; - fdata = NULL; - thisData = NULL; - } @@ -670,7 +642,6 @@ void slsDetector::initializeDetectorStructurePointers() { for (int i = 0; i < thisDetector->nOffset; ++i) { *(offset + i) = 0; } - } @@ -692,8 +663,8 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType ty } catch(...) { return NULL; } - dacs_t *dacs=new dacs_t[nd]; - dacs_t *adcs=new dacs_t[na]; + int *dacs=new int[nd]; + int *adcs=new int[na]; int *chipregs=new int[nc]; int *chanregs=new int[nch*nc]; @@ -793,8 +764,8 @@ int slsDetector::sendModule(sls_detector_module *myMod) { ts+=controlSocket->SendDataOnly(&(myMod->offset), sizeof(myMod->offset)); // actual data to the pointers - ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(dacs_t)*(myMod->ndac)); - ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(dacs_t)*(myMod->nadc)); + ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(int)*(myMod->ndac)); + ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(int)*(myMod->nadc)); if(thisDetector->myDetectorType != JUNGFRAU){ ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip)); ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan)); @@ -805,8 +776,8 @@ int slsDetector::sendModule(sls_detector_module *myMod) { int slsDetector::receiveModule(sls_detector_module* myMod) { - dacs_t *dacptr=myMod->dacs; - dacs_t *adcptr=myMod->adcs; + int *dacptr=myMod->dacs; + int *adcptr=myMod->adcs; int *chipptr=myMod->chipregs; int *chanptr=myMod->chanregs; int ts=0; @@ -830,11 +801,11 @@ int slsDetector::receiveModule(sls_detector_module* myMod) { std::cout<< "received module of size "<< ts << " register " << myMod->reg << std::endl; #endif - ts+=controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(dacs_t)*(myMod->ndac)); + ts+=controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(int)*(myMod->ndac)); #ifdef VERBOSE std::cout<< "received dacs of size "<< ts << std::endl; #endif - ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(dacs_t)*(myMod->nadc)); + ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(int)*(myMod->nadc)); #ifdef VERBOSE std::cout<< "received adc of size "<< ts << std::endl; #endif @@ -1025,12 +996,12 @@ int slsDetector::setDetectorType(string const stype) { } -slsDetectorDefs::detectorType slsDetector::getDetectorsType(int pos) { +slsDetectorDefs::detectorType slsDetector::getDetectorsType() { return thisDetector->myDetectorType; } -string slsDetector::sgetDetectorsType(int pos) { - return getDetectorType(getDetectorsType(pos)); +string slsDetector::sgetDetectorsType() { + return getDetectorType(getDetectorsType()); } @@ -1066,12 +1037,12 @@ int slsDetector::getTotalNumberOfChannels() { thisDetector->dataBytesInclGapPixels = thisDetector->dataBytes; } else { #ifdef VERBOSE -cout << "det type is "<< thisDetector->myDetectorType << endl; -cout << "Total number of channels is "<< thisDetector->nChans*thisDetector->nChips* - << " data bytes is " << thisDetector->dataBytes << endl; -// excluding gap pixels + cout << "det type is "<< thisDetector->myDetectorType << endl; + cout << "Total number of channels is "<< thisDetector->nChans*thisDetector->nChips* + << " data bytes is " << thisDetector->dataBytes << endl; + // excluding gap pixels #endif -; + ; } return thisDetector->nChans*thisDetector->nChips; } @@ -1114,6 +1085,12 @@ void slsDetector::setDetectorOffset(dimension d, int off) { thisDetector->offset[d] = off; } +void slsDetector::updateMultiSize(int detx, int dety) { + thisDetector->multiSize[0] = detx; + thisDetector->multiSize[1] = dety; +} + + int slsDetector::setOnline(int off) { int old=thisDetector->onlineFlag; if (off!=GET_ONLINE_FLAG) { @@ -1746,9 +1723,6 @@ int slsDetector::updateDetector() { int slsDetector::readConfigurationFile(string const fname) { - - - string ans; string str; ifstream infile; @@ -1783,9 +1757,6 @@ int slsDetector::readConfigurationFile(string const fname) { int slsDetector::readConfigurationFile(ifstream &infile) { - - - slsDetectorCommand *cmd=new slsDetectorCommand(this); string ans; @@ -1893,7 +1864,6 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id) { names[nvar++] = "port"; names[nvar++] = "stopport"; names[nvar++] = "settingsdir"; - names[nvar++] = "caldir"; names[nvar++] = "ffdir"; names[nvar++] = "outdir"; names[nvar++] = "lock"; @@ -1936,7 +1906,7 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id) { default: std::cout << "detector type " << getDetectorType(thisDetector->myDetectorType) << " not implemented in " - "writing config file" << std::endl; + "writing config file" << std::endl; nvar = 0; break; } @@ -1963,14 +1933,14 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id) { outfile << id << ":"; outfile << args[0] << " " << cmd->executeLine(1,args,GET_ACTION) - << std::endl; + << std::endl; } } else { strcpy(args[0],names[iv].c_str()); if (id>=0) outfile << id << ":"; outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) - << std::endl; + << std::endl; } } @@ -1984,32 +1954,31 @@ string slsDetector::getSettingsFile() { string s(thisDetector->settingsFile); if (s.length()>6) { if (s.substr(s.length()-6,3)==string(".sn") && s.substr(s.length()-3)!=string("xxx") ) - return s.substr(0,s.length()-6); + return s.substr(0,s.length()-6); } return string(thisDetector->settingsFile); } -int slsDetector::writeSettingsFile(string fname, int imod, int iodelay, int tau) { +int slsDetector::writeSettingsFile(string fname, int iodelay, int tau) { - return writeSettingsFile(fname, detectorModules[imod], iodelay, tau); + return writeSettingsFile(fname, detectorModules, iodelay, tau); } -slsDetectorDefs::detectorSettings slsDetector::getSettings(int imod) { +slsDetectorDefs::detectorSettings slsDetector::getSettings() { - return sendSettingsOnly(GET_SETTINGS, imod); + return sendSettingsOnly(GET_SETTINGS); } -slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings isettings, - int imod) { +slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings isettings) { #ifdef VERBOSE std::cout<< "slsDetector setSettings " << isettings << std::endl; #endif if (isettings == -1) - return getSettings(imod); + return getSettings(); detectorType detType = thisDetector->myDetectorType; switch (detType) { @@ -2047,23 +2016,21 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise -slsDetectorDefs::detectorSettings slsDetector::sendSettingsOnly(detectorSettings isettings, - int imod) { +slsDetectorDefs::detectorSettings slsDetector::sendSettingsOnly(detectorSettings isettings) { int fnum = F_SET_SETTINGS; int ret = FAIL; char mess[MAX_STR_LENGTH]; memset(mess, 0, MAX_STR_LENGTH); int retval = -1; - int arg[2]; - arg[0] = isettings; - arg[1] = imod; + int arg; + arg = isettings; #ifdef VERBOSE - std::cout<< "Setting settings of module " << arg[1] << " to " << arg[0] << std::endl; + std::cout<< "Setting settings to " << arg << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); + controlSocket->SendDataOnly(&arg,sizeof(arg)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); @@ -2086,7 +2053,7 @@ slsDetectorDefs::detectorSettings slsDetector::sendSettingsOnly(detectorSettings -int slsDetector::getThresholdEnergy(int imod) { +int slsDetector::getThresholdEnergy() { int fnum= F_GET_THRESHOLD_ENERGY; int retval; @@ -2099,7 +2066,6 @@ int slsDetector::getThresholdEnergy(int imod) { if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&imod,sizeof(imod)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { std::cout<< "Detector returned error: "<< std::endl; @@ -2117,7 +2083,7 @@ int slsDetector::getThresholdEnergy(int imod) { return thisDetector->currentThresholdEV; } -int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isettings, int tb) { +int slsDetector::setThresholdEnergy(int e_eV, detectorSettings isettings, int tb) { //currently only for eiger if (thisDetector->myDetectorType == EIGER) { @@ -2136,7 +2102,6 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&e_eV,sizeof(e_eV)); - controlSocket->SendDataOnly(&imod,sizeof(imod)); controlSocket->SendDataOnly(&isettings,sizeof(isettings)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { @@ -2331,18 +2296,8 @@ string slsDetector::getSettingsDir() { string slsDetector::setSettingsDir(string s) { sprintf(thisDetector->settingsDir, s.c_str()); return thisDetector->settingsDir; } -string slsDetector::getCalDir() { - return thisDetector->calDir; -} -string slsDetector::setCalDir(string s) { - sprintf(thisDetector->calDir, s.c_str()); return thisDetector->calDir; -} - - - - -int slsDetector::loadSettingsFile(string fname, int imod) { +int slsDetector::loadSettingsFile(string fname) { sls_detector_module *myMod=NULL; @@ -2379,7 +2334,7 @@ int slsDetector::loadSettingsFile(string fname, int imod) { } -int slsDetector::saveSettingsFile(string fname, int imod) { +int slsDetector::saveSettingsFile(string fname) { sls_detector_module *myMod=NULL; int ret=FAIL; @@ -2402,7 +2357,7 @@ int slsDetector::saveSettingsFile(string fname, int imod) { if ((myMod=getModule(0))) { if(thisDetector->myDetectorType == EIGER){ - iodelay = (int)setDAC((dacs_t)-1,IO_DELAY,0,-1); + iodelay = (int)setDAC((int)-1,IO_DELAY,0,-1); tau = (int64_t)getRateCorrectionTau(); } ret=writeSettingsFile(fn, *myMod, iodelay, tau); @@ -2414,103 +2369,6 @@ int slsDetector::saveSettingsFile(string fname, int imod) { - -int slsDetector::loadCalibrationFile(string fname, int imod) { - - if(thisDetector->myDetectorType == EIGER) { - std::cout << "Not required for this detector!" << std::endl; - return FAIL; - } - - sls_detector_module *myMod=NULL; - string fn=fname; - - int* gainval=0; int* offsetval=0; - if(thisDetector->nGain){ - gainval=new int[thisDetector->nGain]; - for(int i=0;inGain;++i) - gainval[i] = -1; - } - if(thisDetector->nOffset){ - offsetval=new int[thisDetector->nOffset]; - for(int i=0;inOffset;++i) - offsetval[i] = -1; - } - - fn=fname; - ostringstream ostfn; - ostfn << fname ; - switch (thisDetector->myDetectorType) { - case EIGER: - if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) { - ostfn << "." << setfill('0') << setw(3) << dec << - getId(DETECTOR_SERIAL_NUMBER); - } - break; - default: - printf("Unknown detector!\n"); - return FAIL; - } - fn=ostfn.str(); - if((myMod=getModule(0))){ - //extra gain and offset - if(thisDetector->nGain){ - if(readCalibrationFile(fn, gainval, offsetval)==FAIL) - return FAIL; - } //normal gain and offset inside sls_detector_module - else{ - if(readCalibrationFile(fn,myMod->gain, myMod->offset)==FAIL) - return FAIL; - } - setModule(*myMod,-1,-1,-1,gainval,offsetval); - - deleteModule(myMod); - if(gainval) delete[]gainval; - if(offsetval) delete[] offsetval; - } else - return FAIL; - - return OK; -} - - -int slsDetector::saveCalibrationFile(string fname, int imod) { - - - sls_detector_module *myMod=NULL; - int ret=FAIL; - - string fn=fname; - ostringstream ostfn; - ostfn << fname; - switch (thisDetector->myDetectorType) { - case EIGER: - ostfn << ".sn" << setfill('0') << setw(3) << dec << - getId(DETECTOR_SERIAL_NUMBER); - break; - default: - printf("Unknown detector!\n"); - return FAIL; - break; - } - fn=ostfn.str(); - if ((myMod=getModule(0))) { - //extra gain and offset - if(thisDetector->nGain) - ret=writeCalibrationFile(fn,gain, offset); - //normal gain and offset inside sls_detector_module - else - ret=writeCalibrationFile(fn,myMod->gain, myMod->offset); - - deleteModule(myMod); - }else - return FAIL; - - return ret; -} - - - slsDetectorDefs::runStatus slsDetector::getRunStatus() { int fnum=F_GET_RUN_STATUS; int ret=FAIL; @@ -2694,10 +2552,10 @@ int slsDetector::startAndReadAll() { std::cout<< "Detector returned: " << mess << std::endl; } else { ; - #ifdef VERBOSE +#ifdef VERBOSE std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl; - #endif +#endif } disconnectControl(); } @@ -2751,10 +2609,10 @@ int slsDetector::readAll() { std::cout<< "Detector returned: " << mess << std::endl; } else { ; - #ifdef VERBOSE +#ifdef VERBOSE std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl; - #endif +#endif } disconnectControl(); } @@ -2765,7 +2623,7 @@ int slsDetector::readAll() { -int slsDetector::configureMAC() { +int slsDetector::configureMAC(int ndety) { int i; int ret=FAIL; int fnum=F_CONFIGURE_MAC; @@ -2781,7 +2639,7 @@ int slsDetector::configureMAC() { if (thisDetector->myDetectorType == JUNGFRAU || thisDetector->myDetectorType == EIGER) { sendpos = true; - int max = multiDet->getNumberOfDetectors(Y); + int max = ndety; pos[0] = (detId % max); // row pos[1] = (detId / max) * ((thisDetector->myDetectorType == EIGER) ? 2 : 1);// col for horiz. udp ports @@ -2975,7 +2833,7 @@ int slsDetector::configureMAC() { -int64_t slsDetector::setTimer(timerIndex index, int64_t t, int imod) { +int64_t slsDetector::setTimer(timerIndex index, int64_t t) { int fnum=F_SET_TIMER,fnum2=F_SET_RECEIVER_TIMER; @@ -3049,7 +2907,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t, int imod) { ((index == ACQUISITION_TIME) && (thisDetector->dynamicRange == 16))) - && (t>=0) && getRateCorrection(r)){ + && (t>=0) && getRateCorrection(r)){ setRateCorrection(r); } } @@ -3079,8 +2937,8 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t, int imod) { args[1] = thisDetector->timerValue[FRAME_NUMBER] * ((thisDetector->timerValue[CYCLES_NUMBER] > 0) ? (thisDetector->timerValue[CYCLES_NUMBER]) : 1) * - ((thisDetector->timerValue[STORAGE_CELL_NUMBER] > 0) - ? (thisDetector->timerValue[STORAGE_CELL_NUMBER])+1 : 1); + ((thisDetector->timerValue[STORAGE_CELL_NUMBER] > 0) + ? (thisDetector->timerValue[STORAGE_CELL_NUMBER])+1 : 1); #ifdef VERBOSE std::cout << "Setting/Getting " << timername << " " << index <<" to/from receiver " << args[1] << std::endl; @@ -3131,7 +2989,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t, int imod) { -int64_t slsDetector::getTimeLeft(timerIndex index, int imod) { +int64_t slsDetector::getTimeLeft(timerIndex index) { int fnum=F_GET_TIME_LEFT; @@ -3256,10 +3114,10 @@ int slsDetector::setDynamicRange(int n) { (thisDetector->nChip[X] * thisDetector->nChan[X] + thisDetector->gappixels * thisDetector->nGappixels[X]) * - (thisDetector->nChip[Y] * - thisDetector->nChan[Y] + thisDetector->gappixels * - thisDetector->nGappixels[Y]) * - retval/8; + (thisDetector->nChip[Y] * + thisDetector->nChan[Y] + thisDetector->gappixels * + thisDetector->nGappixels[Y]) * + retval/8; if (thisDetector->myDetectorType==JUNGFRAUCTB) { getTotalNumberOfChannels(); } @@ -3312,30 +3170,28 @@ int slsDetector::getDataBytesInclGapPixels() { } -dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int mV, int imod) { +int slsDetector::setDAC(int val, dacIndex index, int mV) { - dacs_t retval[2]; + int retval[2]; retval[0] = -1; retval[1] = -1; int fnum=F_SET_DAC; int ret=FAIL; char mess[MAX_STR_LENGTH]=""; - int arg[3]; + int arg[2]; if ( (index==HV_NEW) &&(thisDetector->myDetectorType == GOTTHARD)) index=HV_POT; arg[0]=index; - arg[1]=imod; - arg[2]=mV; + arg[1]=mV; #ifdef VERBOSE std::cout<< std::endl; - std::cout<< "Setting DAC "<< index << " of module " << imod << " to " << - val << std::endl; + std::cout<< "Setting DAC "<< index << " to " << val << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ @@ -3367,8 +3223,7 @@ dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int mV, int imod) { << std::endl; #endif if (ret==FAIL) { - std::cout<< "Set dac " << index << " of module " << imod << " to " << - val << " failed." << std::endl; + std::cout<< "Set dac " << index << " to " << val << " failed." << std::endl; } if(mV) return retval[1]; @@ -3379,32 +3234,31 @@ dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int mV, int imod) { -dacs_t slsDetector::getADC(dacIndex index, int imod) { +int slsDetector::getADC(dacIndex index) { - dacs_t retval; + int retval; int fnum=F_GET_ADC; int ret=FAIL; char mess[MAX_STR_LENGTH]=""; - int arg[2]; - arg[0]=index; - arg[1]=imod; + int arg; + arg=index; #ifdef VERBOSE std::cout<< std::endl; - std::cout<< "Getting ADC "<< index << " of module " << imod << std::endl; + std::cout<< "Getting ADC "<< index << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectStop() == OK){ stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->SendDataOnly(arg,sizeof(arg)); + stopSocket->SendDataOnly(&arg,sizeof(arg)); stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) { stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); if (adcs) { - *(adcs+index+imod*thisDetector->nAdcs)=retval; + *(adcs+index)=retval; } } else { stopSocket->ReceiveDataOnly(mess,sizeof(mess)); @@ -3944,7 +3798,7 @@ string slsDetector::setDetectorIP(string detectorIP) { -string slsDetector::setReceiver(string receiverIP) { +string slsDetector::setReceiverHostname(string receiverIP) { if(receiverIP == "none") { memset(thisDetector->receiver_hostname, 0, MAX_STR_LENGTH); @@ -3978,7 +3832,7 @@ string slsDetector::setReceiver(string receiverIP) { std::cout << "write enable:" << thisDetector->receiver_fileWriteEnable << endl; std::cout << "overwrite enable:" << thisDetector->receiver_overWriteEnable << endl; std::cout << "frame index needed:" << ((thisDetector->timerValue[FRAME_NUMBER] - *thisDetector->timerValue[CYCLES_NUMBER])>1) << endl; + *thisDetector->timerValue[CYCLES_NUMBER])>1) << endl; std::cout << "frame period:" << thisDetector->timerValue[FRAME_PERIOD] << endl; std::cout << "frame number:" << thisDetector->timerValue[FRAME_NUMBER] << endl; std::cout << "sub exp time:" << thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME] @@ -4041,7 +3895,7 @@ string slsDetector::setReceiver(string receiverIP) { enableGapPixels(thisDetector->gappixels); // data streaming - setReadReceiverFrequency(thisDetector->receiver_read_freq); + setReceiverStreamingFrequency(thisDetector->receiver_read_freq); setReceiverStreamingPort(getReceiverStreamingPort()); setReceiverStreamingIP(getReceiverStreamingIP()); setAdditionalJsonHeader(getAdditionalJsonHeader()); @@ -4156,15 +4010,7 @@ string slsDetector::setClientStreamingPort(string port) { int numsockets = (thisDetector->myDetectorType == EIGER) ? 2:1; int arg = 0; - //multi command, calculate individual ports - size_t found = port.find("multi"); - if(found != string::npos) { - port.erase(found,5); - sscanf(port.c_str(),"%d",&defaultport); - arg = defaultport + (detId * numsockets); - } - else - sscanf(port.c_str(),"%d",&arg); + sscanf(port.c_str(),"%d",&arg); thisDetector->zmqport = arg; return getClientStreamingPort(); @@ -4178,15 +4024,7 @@ string slsDetector::setReceiverStreamingPort(string port) { int numsockets = (thisDetector->myDetectorType == EIGER) ? 2:1; int arg = 0; - //multi command, calculate individual ports - size_t found = port.find("multi"); - if(found != string::npos) { - port.erase(found,5); - sscanf(port.c_str(),"%d",&defaultport); - arg = defaultport + (detId * numsockets); - } - else - sscanf(port.c_str(),"%d",&arg); + sscanf(port.c_str(),"%d",&arg); thisDetector->receiver_zmqport = arg; @@ -4488,7 +4326,7 @@ int slsDetector::setUDPConnection() { -int slsDetector::digitalTest( digitalTestMode mode, int imod) { +int slsDetector::digitalTest( digitalTestMode mode) { int retval; @@ -4505,8 +4343,6 @@ int slsDetector::digitalTest( digitalTestMode mode, int imod) { if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&mode,sizeof(mode)); - if ((mode==CHIP_TEST)|| (mode==DIGITAL_BIT_TEST)) - controlSocket->SendDataOnly(&imod,sizeof(imod)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); @@ -4982,17 +4818,17 @@ int slsDetector::setDeactivatedRxrPaddingMode(int padding) { if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ #ifdef VERBOSE - std::cout << "Deactivated Receiver Padding Enable: " << arg << std::endl; + std::cout << "Deactivated Receiver Padding Enable: " << arg << std::endl; #endif - if (connectData() == OK){ - ret=thisReceiver->sendInt(fnum,retval,arg); - disconnectData(); - } - if(ret==FAIL) - setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE)); - else - thisDetector->receiver_deactivatedPaddingEnable = retval; + if (connectData() == OK){ + ret=thisReceiver->sendInt(fnum,retval,arg); + disconnectData(); } + if(ret==FAIL) + setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE)); + else + thisDetector->receiver_deactivatedPaddingEnable = retval; + } return thisDetector->receiver_deactivatedPaddingEnable; } @@ -5054,7 +4890,7 @@ int slsDetector::setFlippedData(dimension d, int value) { -int slsDetector::setAllTrimbits(int val, int imod) { +int slsDetector::setAllTrimbits(int val) { int fnum=F_SET_ALL_TRIMBITS; int retval; char mess[MAX_STR_LENGTH]=""; @@ -5127,10 +4963,10 @@ int slsDetector::enableGapPixels(int val) { (thisDetector->nChip[X] * thisDetector->nChan[X] + thisDetector->gappixels * thisDetector->nGappixels[X]) * - (thisDetector->nChip[Y] * - thisDetector->nChan[Y] + thisDetector->gappixels * - thisDetector->nGappixels[Y]) * - thisDetector->dynamicRange/8; + (thisDetector->nChip[Y] * + thisDetector->nChan[Y] + thisDetector->gappixels * + thisDetector->nGappixels[Y]) * + thisDetector->dynamicRange/8; // set data bytes for other detector ( for future use) if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels(); @@ -5261,32 +5097,29 @@ int slsDetector::pulseChip(int n) { -int slsDetector::setThresholdTemperature(int val, int imod) { +int slsDetector::setThresholdTemperature(int val) { int retval = -1; int fnum = F_THRESHOLD_TEMP; int ret = FAIL; char mess[MAX_STR_LENGTH] = ""; - int arg[2]; - arg[0]=val; - arg[1]=imod; + int arg=val; #ifdef VERBOSE std::cout<< std::endl; - std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " - << imod << std::endl; + std::cout<< "Setting/Getting Threshold Temperature to "<< val << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectStop() == OK){ stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->SendDataOnly(arg,sizeof(arg)); + stopSocket->SendDataOnly(&arg,sizeof(arg)); stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) { stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); #ifdef VERBOSE -std::cout<< "Threshold Temperature returned "<< retval << std::endl; + std::cout<< "Threshold Temperature returned "<< retval << std::endl; #endif } else { stopSocket->ReceiveDataOnly(mess,sizeof(mess)); @@ -5302,32 +5135,29 @@ std::cout<< "Threshold Temperature returned "<< retval << std::endl; -int slsDetector::setTemperatureControl(int val, int imod) { +int slsDetector::setTemperatureControl(int val) { int retval = -1; int fnum = F_TEMP_CONTROL; int ret = FAIL; char mess[MAX_STR_LENGTH] = ""; - int arg[2]; - arg[0]=val; - arg[1]=imod; + int arg=val; #ifdef VERBOSE std::cout<< std::endl; - std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " - << imod << std::endl; + std::cout<< "Setting/Getting Threshold Temperature to "<< val << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectStop() == OK){ stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->SendDataOnly(arg,sizeof(arg)); + stopSocket->SendDataOnly(&arg,sizeof(arg)); stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) { stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); #ifdef VERBOSE -std::cout<< "Threshold Temperature returned "<< retval << std::endl; + std::cout<< "Threshold Temperature returned "<< retval << std::endl; #endif } else { stopSocket->ReceiveDataOnly(mess,sizeof(mess)); @@ -5344,32 +5174,29 @@ std::cout<< "Threshold Temperature returned "<< retval << std::endl; -int slsDetector::setTemperatureEvent(int val, int imod) { +int slsDetector::setTemperatureEvent(int val) { int retval = -1; int fnum = F_TEMP_EVENT; int ret = FAIL; char mess[MAX_STR_LENGTH] = ""; - int arg[2]; - arg[0]=val; - arg[1]=imod; + int arg=val; #ifdef VERBOSE std::cout<< std::endl; - std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " - << imod << std::endl; + std::cout<< "Setting/Getting Threshold Temperature to "<< val << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectStop() == OK){ stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->SendDataOnly(arg,sizeof(arg)); + stopSocket->SendDataOnly(&arg,sizeof(arg)); stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) { stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); #ifdef VERBOSE -std::cout<< "Threshold Temperature returned "<< retval << std::endl; + std::cout<< "Threshold Temperature returned "<< retval << std::endl; #endif } else { stopSocket->ReceiveDataOnly(mess,sizeof(mess)); @@ -5787,8 +5614,6 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int ret=FAIL; char mess[MAX_STR_LENGTH]=""; - int imod=0; - #ifdef VERBOSE std::cout << "slsDetector set module " << std::endl; @@ -5834,61 +5659,60 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, if (ret!=FAIL) { if (detectorModules) { - if(tb) { - (detectorModules)->nchan=module.nchan; - (detectorModules)->nchip=module.nchip; - } - (detectorModules)->ndac=module.ndac; - (detectorModules)->nadc=module.nadc; - if(tb) { - thisDetector->nChips=module.nchip; - thisDetector->nChans=module.nchan/module.nchip; - } - thisDetector->nDacs=module.ndac; - thisDetector->nAdcs=module.nadc; + if(tb) { + (detectorModules)->nchan=module.nchan; + (detectorModules)->nchip=module.nchip; + } + (detectorModules)->ndac=module.ndac; + (detectorModules)->nadc=module.nadc; + if(tb) { + thisDetector->nChips=module.nchip; + thisDetector->nChans=module.nchan/module.nchip; + } + thisDetector->nDacs=module.ndac; + thisDetector->nAdcs=module.nadc; - if(thisDetector->myDetectorType != JUNGFRAU){ - if(tb) { - for (int ichip=0; ichipnChips; ++ichip) { - if (chipregs) - chipregs[ichip+thisDetector->nChips*imod]= - module.chipregs[ichip]; + if(thisDetector->myDetectorType != JUNGFRAU){ + if(tb) { + for (int ichip=0; ichipnChips; ++ichip) { + if (chipregs) + chipregs[ichip]= + module.chipregs[ichip]; - if (chanregs) { - for (int i=0; inChans; ++i) { - chanregs[i+ichip* - thisDetector->nChans+ - thisDetector->nChips*thisDetector->nChans* - imod]=module.chanregs[ichip*thisDetector->nChans+i]; - } + if (chanregs) { + for (int i=0; inChans; ++i) { + chanregs[i+ichip* + thisDetector->nChans]= + module.chanregs[ichip*thisDetector->nChans+i]; } } } - if (adcs) { - for (int i=0; inAdcs; ++i) - adcs[i+imod*thisDetector->nAdcs]=module.adcs[i]; - } } - - if (dacs) { - for (int i=0; inDacs; ++i) - dacs[i+imod*thisDetector->nDacs]=module.dacs[i]; + if (adcs) { + for (int i=0; inAdcs; ++i) + adcs[i]=module.adcs[i]; } + } - (detectorModules)->gain=module.gain; - (detectorModules)->offset=module.offset; - (detectorModules)->serialnumber=module.serialnumber; - (detectorModules)->reg=module.reg; + if (dacs) { + for (int i=0; inDacs; ++i) + dacs[i]=module.dacs[i]; + } + + (detectorModules)->gain=module.gain; + (detectorModules)->offset=module.offset; + (detectorModules)->serialnumber=module.serialnumber; + (detectorModules)->reg=module.reg; } if ((thisDetector->nGain) && (gainval) && (gain)) { for (int i=0; inGain; ++i) - gain[i+imod*thisDetector->nGain]=gainval[i]; + gain[i]=gainval[i]; } if ((thisDetector->nOffset) && (offsetval) && (offset)) { for (int i=0; inOffset; ++i) - offset[i+imod*thisDetector->nOffset]=offsetval[i]; + offset[i]=offsetval[i]; } if (e_eV != -1) @@ -5907,7 +5731,7 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, -slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod) { +slsDetectorDefs::sls_detector_module *slsDetector::getModule() { #ifdef VERBOSE std::cout << "slsDetector get module " << std::endl; @@ -5957,46 +5781,45 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod) { if (ret!=FAIL) { if (detectorModules) { - (detectorModules)->nchan=myMod->nchan; - (detectorModules)->nchip=myMod->nchip; - (detectorModules)->ndac=myMod->ndac; - (detectorModules)->nadc=myMod->nadc; - thisDetector->nChips=myMod->nchip; - thisDetector->nChans=myMod->nchan/myMod->nchip; - thisDetector->nDacs=myMod->ndac; - thisDetector->nAdcs=myMod->nadc; + (detectorModules)->nchan=myMod->nchan; + (detectorModules)->nchip=myMod->nchip; + (detectorModules)->ndac=myMod->ndac; + (detectorModules)->nadc=myMod->nadc; + thisDetector->nChips=myMod->nchip; + thisDetector->nChans=myMod->nchan/myMod->nchip; + thisDetector->nDacs=myMod->ndac; + thisDetector->nAdcs=myMod->nadc; - if(thisDetector->myDetectorType != JUNGFRAU){ - for (int ichip=0; ichipnChips; ++ichip) { - if (chipregs) - chipregs[ichip+thisDetector->nChips*imod]= - myMod->chipregs[ichip]; + if(thisDetector->myDetectorType != JUNGFRAU){ + for (int ichip=0; ichipnChips; ++ichip) { + if (chipregs) + chipregs[ichip]= + myMod->chipregs[ichip]; - if (chanregs) { - for (int i=0; inChans; ++i) { - chanregs[i+ichip*thisDetector->nChans+ - thisDetector->nChips*thisDetector->nChans*imod]= - myMod->chanregs[ichip*thisDetector->nChans+i]; - } + if (chanregs) { + for (int i=0; inChans; ++i) { + chanregs[i+ichip*thisDetector->nChans]= + myMod->chanregs[ichip*thisDetector->nChans+i]; } } - - if (adcs) { - for (int i=0; inAdcs; ++i) - adcs[i+imod*thisDetector->nAdcs]=myMod->adcs[i]; - } } - if (dacs) { - for (int i=0; inDacs; ++i) { - dacs[i+imod*thisDetector->nDacs]=myMod->dacs[i]; - //cprintf(BLUE,"dac%d:%d\n",i, myMod->dacs[i]); - } + if (adcs) { + for (int i=0; inAdcs; ++i) + adcs[i]=myMod->adcs[i]; } - (detectorModules)->gain=myMod->gain; - (detectorModules)->offset=myMod->offset; - (detectorModules)->serialnumber=myMod->serialnumber; - (detectorModules)->reg=myMod->reg; + } + + if (dacs) { + for (int i=0; inDacs; ++i) { + dacs[i]=myMod->dacs[i]; + //cprintf(BLUE,"dac%d:%d\n",i, myMod->dacs[i]); + } + } + (detectorModules)->gain=myMod->gain; + (detectorModules)->offset=myMod->offset; + (detectorModules)->serialnumber=myMod->serialnumber; + (detectorModules)->reg=myMod->reg; } @@ -6133,7 +5956,7 @@ int slsDetector::getRateCorrection() { int slsDetector::printReceiverConfiguration() { std::cout << std::endl - << "#Detector " << idet << ":" << std::endl; + << "#Detector " << idet << ":" << std::endl; std::cout << "Detector IP:\t\t" << getNetworkParameter(DETECTOR_IP) << std::endl; std::cout << "Detector MAC:\t\t" << getNetworkParameter(DETECTOR_MAC) << std::endl; @@ -6493,19 +6316,15 @@ void slsDetector::sendMultiDetectorSize() { int fnum=F_SEND_RECEIVER_MULTIDETSIZE; int ret = FAIL; int retval = -1; - int arg[2]; - - pthread_mutex_lock(&ms); - multiDet->getNumberOfDetectors(arg[0],arg[1]); - pthread_mutex_unlock(&ms); if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ #ifdef VERBOSE - std::cout << "Sending multi detector size to Receiver (" << arg[0] << "," - << arg[1] << ")" << std::endl; + std::cout << "Sending multi detector size to Receiver (" << + thisDetector->multiSize[0] << "," + << thisDetector->multiSize[1] << ")" << std::endl; #endif if (connectData() == OK){ - ret=thisReceiver->sendIntArray(fnum,retval,arg); + ret=thisReceiver->sendIntArray(fnum,retval,thisDetector->multiSize); disconnectData(); } if((ret==FAIL)){ @@ -6732,20 +6551,20 @@ slsReceiverDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { int arg = -1; int retval = -1; - arg = (int)f; + arg = (int)f; #ifdef VERBOSE - std::cout << "Sending file format to receiver " << arg << std::endl; + std::cout << "Sending file format to receiver " << arg << std::endl; #endif - if (connectData() == OK){ - ret=thisReceiver->sendInt(fnum,retval,arg); - disconnectData(); - } - if (ret == FAIL) - setErrorMask((getErrorMask())|(RECEIVER_FILE_FORMAT)); - else - thisDetector->receiver_fileFormatType = (fileFormat)retval; - if(ret==FORCE_UPDATE) - updateReceiver(); + if (connectData() == OK){ + ret=thisReceiver->sendInt(fnum,retval,arg); + disconnectData(); + } + if (ret == FAIL) + setErrorMask((getErrorMask())|(RECEIVER_FILE_FORMAT)); + else + thisDetector->receiver_fileFormatType = (fileFormat)retval; + if(ret==FORCE_UPDATE) + updateReceiver(); return getFileFormat(); } @@ -6772,18 +6591,18 @@ int slsDetector::setFileIndex(int i) { #ifdef VERBOSE - std::cout << "Sending file index to receiver " << arg << std::endl; + std::cout << "Sending file index to receiver " << arg << std::endl; #endif - if (connectData() == OK){ - ret=thisReceiver->sendInt(fnum,retval,arg); - disconnectData(); - } - if (ret == FAIL) - setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else - thisDetector->receiver_fileIndex = retval; - if(ret==FORCE_UPDATE) - updateReceiver(); + if (connectData() == OK){ + ret=thisReceiver->sendInt(fnum,retval,arg); + disconnectData(); + } + if (ret == FAIL) + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + else + thisDetector->receiver_fileIndex = retval; + if(ret==FORCE_UPDATE) + updateReceiver(); return getFileIndex(); @@ -7033,12 +6852,12 @@ int slsDetector::overwriteFile(int enable) { -int slsDetector::setReadReceiverFrequency(int freq) { +int slsDetector::setReceiverStreamingFrequency(int freq) { if (freq >= 0) { thisDetector->receiver_read_freq = freq; - int fnum=F_READ_RECEIVER_FREQUENCY; + int fnum=F_RECEIVER_STREAMING_FREQUENCY; int ret = FAIL; int retval=-1; int arg = freq; @@ -7054,7 +6873,7 @@ int slsDetector::setReadReceiverFrequency(int freq) { if((ret == FAIL) || (retval != freq)) { cout << "could not set receiver read frequency to " << freq <<" Returned:" << retval << endl; - setErrorMask((getErrorMask())|(RECEIVER_READ_FREQUENCY)); + setErrorMask((getErrorMask())|(RECEIVER_STREAMING_FREQUENCY)); } if(ret==FORCE_UPDATE) @@ -7067,8 +6886,8 @@ int slsDetector::setReadReceiverFrequency(int freq) { -int slsDetector::setReceiverReadTimer(int time_in_ms) { - int fnum=F_READ_RECEIVER_TIMER; +int slsDetector::setReceiverStreamingTimer(int time_in_ms) { + int fnum=F_RECEIVER_STREAMING_TIMER; int ret = FAIL; int arg = time_in_ms; int retval = -1; @@ -7088,7 +6907,7 @@ int slsDetector::setReceiverReadTimer(int time_in_ms) { if ((time_in_ms > 0) && (retval != time_in_ms)){ cout << "could not set receiver read timer to " << time_in_ms <<" Returned:" << retval << endl; - setErrorMask((getErrorMask())|(RECEIVER_READ_TIMER)); + setErrorMask((getErrorMask())|(RECEIVER_STREAMING_TIMER)); } return retval; } @@ -7600,7 +7419,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( //Copy other dacs int dacs_to_copy[] = {SVP,VTR,SVN,VTGSTV,RXB_RB,RXB_LB,VCN,VIS}; - int num_dacs_to_copy = sizeof(dacs_to_copy) / sizeof(dacs_to_copy[0]); + int num_dacs_toint= sizeof(dacs_to_copy) / sizeof(dacs_to_copy[0]); for (int i = 0; i < num_dacs_to_copy; ++i) { if(a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) { deleteModule(myMod); @@ -7612,9 +7431,9 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( //Copy irrelevant dacs (without failing): CAL if (a->dacs[CAL] != b->dacs[CAL]) { - printf("Warning: DAC CAL differs in both energies (%d, %d)! ", - a->dacs[CAL], b->dacs[CAL]); - printf("Taking first: %d\n", a->dacs[CAL]); + printf("Warning: DAC CAL differs in both energies (%d, %d)! ", + a->dacs[CAL], b->dacs[CAL]); + printf("Taking first: %d\n", a->dacs[CAL]); } myMod->dacs[CAL] = a->dacs[CAL]; @@ -7709,7 +7528,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string case EIGER: infile.open(myfname.c_str(),std::ifstream::binary); if (infile.is_open()) { - infile.read((char*) myMod->dacs,sizeof(dacs_t)*(myMod->ndac)); + infile.read((char*) myMod->dacs,sizeof(int)*(myMod->ndac)); infile.read((char*)&iodelay,sizeof(iodelay)); infile.read((char*)&tau,sizeof(tau)); #ifdef VERBOSE @@ -7855,7 +7674,7 @@ int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod, std::cout << "iodelay: " << iodelay << std::endl; std::cout << "tau: " << tau << std::endl; #endif - outfile.write((char*)mod.dacs, sizeof(dacs_t)*(mod.ndac)); + outfile.write((char*)mod.dacs, sizeof(int)*(mod.ndac)); outfile.write(reinterpret_cast(&iodelay), sizeof(iodelay)); outfile.write(reinterpret_cast(&tau), sizeof(tau)); outfile.write((char*)mod.chanregs, sizeof(int)*(mod.nchan)); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 2b0af7ab9..44ce1ca0e 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -16,7 +16,7 @@ class multiSlsDetector; class SharedMemory; class receiverInterface; -#define SLS_SHMVERSION 0x181002 +#define SLS_SHMVERSION 0x181005 #define NCHIPSMAX 10 #define NCHANSMAX 65536 #define NDACSMAX 16 @@ -63,6 +63,9 @@ private: * before starting the communication */ char hostname[MAX_STR_LENGTH]; + /** detector type \ see :: detectorType*/ + detectorType myDetectorType; + /** END OF FIXED PATTERN -----------------------------------------------*/ @@ -71,21 +74,18 @@ private: /** Detector offset in the X & Y direction in the multi detector structure */ int offset[2]; + /** Number of detectors in multi list in x dir and y dir */ + int multiSize[2]; + /** is the port used for control functions */ int controlPort; /** is the port used to stop the acquisition */ int stopPort; - /** detector type \ see :: detectorType*/ - detectorType myDetectorType; - /** path of the trimbits/settings files */ char settingsDir[MAX_STR_LENGTH]; - /** path of the calibration files */ - char calDir[MAX_STR_LENGTH]; - /** number of energies at which the detector has been trimmed */ int nTrimEn; @@ -126,9 +126,6 @@ private: * (i.e. if data are processed in a separate thread) */ int threadedProcessing; - /** dead time (in ns) for rate corrections */ - double tDead; - /** number of rois defined */ int nROI; @@ -289,51 +286,28 @@ private: public: - - //FIXME: all pos or id arguments needed only for same multi signature - /** * Constructor called when creating new shared memory * @param type detector type * @param multiId multi detector shared memory id * @param id sls detector id (position in detectors list) * @param verify true to verify if shared memory version matches existing one - * @param m multiSlsDetector reference */ - slsDetector(detectorType type, int multiId = 0, int id = 0, bool verify = true, multiSlsDetector* m = NULL); + slsDetector(detectorType type, int multiId = 0, int id = 0, bool verify = true); /** * Constructor called when opening existing shared memory * @param multiId multi detector shared memory id * @param id sls detector id (position in detectors list) * @param verify true to verify if shared memory version matches existing one - * @param m multiSlsDetector reference */ - slsDetector(int multiId = 0, int id = 0, bool verify = true, multiSlsDetector* m = NULL); + slsDetector(int multiId = 0, int id = 0, bool verify = true); /** * Destructor */ virtual ~slsDetector(); - /** - * Set acquiring flag in shared memory - * @param b acquiring flag - */ - void setAcquiringFlag(bool b=false); - - /** - * Get acquiring flag from shared memory - * @returns acquiring flag - */ - bool getAcquiringFlag(); - - /** - * Check if acquiring flag is set, set error if set - * @returns FAIL if not ready, OK if ready - */ - bool isAcquireReady(); - /** * Check version compatibility with detector/receiver software * (if hostname/rx_hostname has been set/ sockets created) @@ -345,10 +319,9 @@ public: /** * Get ID or version numbers * @param mode version type - * @param imod module number in entire module list (gets decoded) (-1 for all) * @returns Id or version number of that type */ - int64_t getId(idMode mode, int imod=0); + int64_t getId(idMode mode); /** * Free shared memory without creating objects @@ -368,13 +341,6 @@ public: */ void freeSharedMemory(); - /** - * Get user details of shared memory - * Should only be called from multi detector level - * @returns string with user details - */ - std::string getUserDetails(); - /** * Sets the hostname of all sls detectors in shared memory * Connects to them to set up online flag @@ -389,14 +355,6 @@ public: */ std::string getHostname(int pos = -1); - /** - * Appends detectors to the end of the list in shared memory - * Connects to them to set up online flag - * Should only be called from multi detector level - * @param name concatenated hostname of the sls detectors to be appended to the list - */ - void addMultipleDetectors(const char* name); - /** * Connect to the control port * @returns OK, FAIL or undefined @@ -456,17 +414,15 @@ public: /** * Get Detector type from shared memory variable - * @param pos insignificant * @returns detector type from shared memory variable */ - detectorType getDetectorsType(int pos = -1); + detectorType getDetectorsType(); /** * Gets string version of detector type from shared memory variable - * @param pos insignificant * @returns string version of detector type from shared memory variable */ - std::string sgetDetectorsType(int pos=-1); + std::string sgetDetectorsType(); /** * Just to overload getDetectorType from users @@ -537,6 +493,13 @@ public: */ void setDetectorOffset(dimension d, int off); + /** + * Set Detector offset in shared memory in dimension d + * @param detx number of detectors in X dir in multi list + * @param dety number of detectors in Y dir in multi list + */ + void updateMultiSize(int detx, int dety); + /** * Checks if the detector is online and sets the online flag * @param online if GET_ONLINE_FLAG, only returns shared memory online flag, @@ -564,7 +527,6 @@ public: */ int setTCPSocket(std::string const name="", int const control_port=-1, int const stop_port=-1); - /** * Set/Gets TCP Port of detector or receiver * @param t port type @@ -670,23 +632,21 @@ public: std::string getSettingsFile(); /** - * Writes a trim/settings file for module number imod, + * Writes a trim/settings file for module number * the values will be read from the current detector structure * @param fname name of the file to be written - * @param imod module number * @param iodelay io delay (detector specific) * @param tau tau (detector specific) * @returns OK or FAIL if the file could not be written * \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int) */ - int writeSettingsFile(std::string fname, int imod, int iodelay, int tau); + int writeSettingsFile(std::string fname, int iodelay, int tau); /** * Get detector settings - * @param imod module number (-1 all) * @returns current settings */ - detectorSettings getSettings(int imod=-1); + detectorSettings getSettings(); /** * Load detector settings from the settings file picked from the trimdir/settingsdir @@ -694,39 +654,35 @@ public: * For Eiger, one must use threshold * Gotthard, Propix, Jungfrau and Moench only sends the settings enum to the detector * @param isettings settings - * @param imod module number (-1 all) * @returns current settings */ - detectorSettings setSettings(detectorSettings isettings, int imod=-1); + detectorSettings setSettings(detectorSettings isettings); /** * Send detector settings only (set only for Jungfrau, Gotthard, Moench, get for all) * Only the settings enum is sent to the detector, where it will * initialize al the dacs already hard coded in the detector server * @param isettings settings - * @param imod module number (-1 all) * @returns current settings */ - detectorSettings sendSettingsOnly(detectorSettings isettings, int imod=-1); + detectorSettings sendSettingsOnly(detectorSettings isettings); /** * Get threshold energy (Mythen and Eiger) - * @param imod module number (-1 all) - * @returns current threshold value for imod in ev (-1 failed) + * @returns current threshold value in ev (-1 failed) */ - int getThresholdEnergy(int imod=-1); + int getThresholdEnergy(); /** * Set threshold energy (Mythen and Eiger) * For Eiger, calls setThresholdEneryAndSettings * @param e_eV threshold in eV - * @param imod module number (-1 all) * @param isettings ev. change settings * @param tb 1 to include trimbits, 0 to exclude - * @returns current threshold value for imod in ev (-1 failed) + * @returns current threshold value in ev (-1 failed) */ - int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS, int tb=1); + int setThresholdEnergy(int e_eV, detectorSettings isettings=GET_SETTINGS, int tb=1); /** * Set threshold energy and settings (Eiger only) @@ -750,55 +706,21 @@ public: */ std::string setSettingsDir(std::string s); - /** - * Returns the calibration files directory \sa sharedSlsDetector (Mythen) - * @returns the calibration files directory - */ - std::string getCalDir(); - - /** - * Sets the calibration files directory \sa sharedSlsDetector (Mythen) - * @param s the calibration files directory - * @returns the calibration files directory - */ - std::string setCalDir(std::string s); - /** * Loads the modules settings/trimbits reading from a specific file * file name extension is automatically generated. * @param fname specific settings/trimbits file - * @param imod module index of the entire list, - * from which will be calculated the detector index and the module index (-1 for all) * returns OK or FAIL */ - int loadSettingsFile(std::string fname, int imod=-1); + int loadSettingsFile(std::string fname); /** * Saves the modules settings/trimbits to a specific file * file name extension is automatically generated. * @param fname specific settings/trimbits file - * @param imod module number (-1 for all) * returns OK or FAIL */ - int saveSettingsFile(std::string fname, int imod=-1); - - /** - * Loads the modules calibration data reading from a specific file (Mythen) - * file name extension is automatically generated. - * @param fname specific calibration file - * @param imod module number (-1 for all) - * returns OK or FAIL - */ - int loadCalibrationFile(std::string fname, int imod=-1); - - /** - * Saves the modules calibration data to a specific file (Mythen) - * file name extension is automatically generated. - * @param fname specific calibration file - * @param imod module number (-1 for all) - * returns OK or FAIL - */ - int saveCalibrationFile(std::string fname, int imod=-1); + int saveSettingsFile(std::string fname); /** * Get run status of the detector @@ -849,28 +771,27 @@ public: int readAll(); /** - * Configures in detector the destination for UDP packets (Not Mythen) + * Configures in detector the destination for UDP packets + * @param ndety number of detectors in y dir * @returns OK or FAIL */ - int configureMAC(); + int configureMAC(int ndety); /** * Set/get timer value (not all implemented for all detectors) * @param index timer index * @param t time in ns or number of...(e.g. frames, gates, probes) - * \param imod module number (pointless in slsDetector) * @returns timer set value in ns or number of...(e.g. frames, gates, probes) */ - int64_t setTimer(timerIndex index, int64_t t=-1, int imod = -1); + int64_t setTimer(timerIndex index, int64_t t=-1); /** * Set/get timer value left in acquisition (not all implemented for all detectors) * @param index timer index * @param t time in ns or number of...(e.g. frames, gates, probes) - * @param imod module number * @returns timer set value in ns or number of...(e.g. frames, gates, probes) */ - int64_t getTimeLeft(timerIndex index, int imod = -1); + int64_t getTimeLeft(timerIndex index); /** * Set speed @@ -906,18 +827,16 @@ public: * @param val value (in V) * @param index DAC index * @param mV 0 in dac units or 1 in mV - * @param imod module number (if -1 all modules) * @returns current DAC value */ - dacs_t setDAC(dacs_t val, dacIndex index , int mV, int imod=-1); + int setDAC(int val, dacIndex index , int mV); /** * Get adc value * @param index adc(DAC) index - * @param imod module number (if -1 all modules) * @returns current adc value (temperature for eiger and jungfrau in millidegrees) */ - dacs_t getADC(dacIndex index, int imod=0); + int getADC(dacIndex index); /** * Set/get timing mode @@ -1137,10 +1056,9 @@ public: /** * Execute a digital test (Gotthard, Mythen) * @param mode testmode type - * @param imod module index (-1 for all) * @returns result of test */ - int digitalTest(digitalTestMode mode, int imod=0); + int digitalTest(digitalTestMode mode); /** * Load dark or gain image to detector (Gotthard) @@ -1260,10 +1178,9 @@ public: /** * Sets all the trimbits to a particular value (Eiger) * @param val trimbit value - * @param imod module number, -1 means all modules * @returns OK or FAIL */ - int setAllTrimbits(int val, int imod=-1); + int setAllTrimbits(int val); /** * Enable gap pixels, only for Eiger and for 8,16 and 32 bit mode. (Eiger) @@ -1318,26 +1235,23 @@ public: /** * Set/gets threshold temperature (Jungfrau) * @param val value in millidegrees, -1 gets - * @param imod module number, -1 is all * @returns threshold temperature in millidegrees */ - int setThresholdTemperature(int val=-1, int imod=-1); + int setThresholdTemperature(int val=-1); /** * Enables/disables temperature control (Jungfrau) * @param val value, -1 gets - * @param imod module number, -1 is all * @returns temperature control enable */ - int setTemperatureControl(int val=-1, int imod=-1); + int setTemperatureControl(int val=-1); /** * Resets/ gets over-temperature event (Jungfrau) * @param val value, -1 gets - * @param imod module number, -1 is all * @returns over-temperature event */ - int setTemperatureEvent(int val=-1, int imod=-1); + int setTemperatureEvent(int val=-1); /** * Set storage cell that stores first acquisition of the series (Jungfrau) @@ -1403,10 +1317,9 @@ public: /** * Get module structure from detector (all detectors) - * @param imod module number * @returns pointer to module structure (which has been created and must then be deleted) */ - sls_detector_module *getModule(int imod); + sls_detector_module *getModule(); /** * Calibrate Pedestal (ChipTestBoard) @@ -1506,6 +1419,8 @@ public: /** * Send the multi detector size to the detector + * @param detx number of detectors in x dir + * @param dety number of detectors in y dir */ void sendMultiDetectorSize(); @@ -1658,23 +1573,23 @@ public: int overwriteFile(int enable=-1); /** - * Sets the read receiver frequency - * if data required from receiver randomly readRxrFrequency=0, - * else every nth frame to be sent to gui/callback - * @param freq is the receiver read frequency. Value 0 is 200 ms timer (other - * frames not sent), 1 is every frame, 2 is every second frame etc. - * @returns read receiver frequency + * (previously setReadReceiverFrequency) + * Sets the receiver streaming frequency + * @param freq nth frame streamed out, if 0, streamed out at a timer of 200 ms + * @param detPos -1 for all detectors in list or specific detector position + * @returns receiver streaming frequency */ - int setReadReceiverFrequency(int freq=-1); + int setReceiverStreamingFrequency(int freq=-1); /** - * Sets the read receiver timer - * if data required from receiver randomly readRxrFrequency=0, - * then the timer between each data stream is set with time_in_ms + * (previously setReceiverReadTimer) + * Sets the receiver streaming timer + * If receiver streaming frequency is 0, then this timer between each + * data stream is set. Default is 200 ms. * @param time_in_ms timer between frames - * @returns read receiver timer + * @returns receiver streaming timer in ms */ - int setReceiverReadTimer(int time_in_ms=500); + int setReceiverStreamingTimer(int time_in_ms=500); /** * Enable data streaming to client @@ -1996,9 +1911,7 @@ private: /** Shared memory structure */ sharedSlsDetector *thisDetector; - /** multiSlsDetector referece */ - multiSlsDetector *multiDet; - + /** receiver interface */ receiverInterface *thisReceiver; /** socket for control commands */ @@ -2014,10 +1927,10 @@ private: sls_detector_module *detectorModules; /** pointer to dac valuse in shared memory */ - dacs_t *dacs; + int *dacs; /** pointer to adc valuse in shared memory */ - dacs_t *adcs; + int *adcs; /** pointer to chip registers in shared memory */ int *chipregs; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorBase.h b/slsDetectorSoftware/slsDetector/slsDetectorBase.h index 033fa1683..88a7dbee1 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorBase.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorBase.h @@ -74,1232 +74,8 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef /** virtual destructor */ virtual ~slsDetectorBase(){}; - - /** returns the detector type - \param pos position in the multi detector structure (is -1 returns type of detector with id -1) - \returns type - */ - virtual detectorType getDetectorsType(int pos=-1)=0; - - std::string getDetectorDeveloper(){return std::string("PSI");}; - // protected: - - /** - Writes the configuration file -- will contain all the informations needed for the configuration (e.g. for a PSI detector caldir, settingsdir, angconv, badchannels etc.) - \param fname file name - \returns OK or FAIL - */ - virtual int writeConfigurationFile(std::string const fname)=0; - - - /** - Loads dark image or gain image to the detector - \param index can be DARK_IMAGE or GAIN_IMAGE - \param fname file name to load data from - \returns OK or FAIL - */ - virtual int loadImageToDetector(imageType index,std::string const fname)=0; - - /** - \returns total number of channels - */ - virtual int getTotalNumberOfChannels()=0; - - /** - \returns total number of channels for each dimension - */ - virtual int getTotalNumberOfChannels(dimension d)=0; - - - - virtual void incrementProgress()=0; - virtual void setCurrentProgress(int i=0)=0; - virtual double getCurrentProgress()=0; - virtual int setTotalProgress()=0; - - - - /** - set rate correction - \param t dead time in ns - if 0 disable correction, if >0 set dead time to t, if <0 set deadtime to default dead time for current settings - \returns 0 if rate correction disabled, >0 otherwise - */ - virtual int setRateCorrection(double t=0)=0; - - /** - get rate correction - \param t reference for dead time - \returns 0 if rate correction disabled, >0 otherwise - */ - virtual int getRateCorrection(double &t)=0; - /** - get rate correction - \returns 0 if rate correction disabled, >0 otherwise - */ - virtual int getRateCorrection()=0; - - /** - set/get dynamic range - \param i dynamic range (-1 get) - \returns current dynamic range - */ - virtual int setDynamicRange(int i=-1)=0; - - - /** Locks/Unlocks the connection to the server - /param lock sets (1), usets (0), gets (-1) the lock - /returns lock status of the server - */ - virtual int lockServer(int i=-1)=0; - - - - /** performs a complete acquisition including scansand data processing - moves the detector to next position
- starts and reads the detector
- reads the IC (if required)
- reads the encoder (iof required for angualr conversion)
- processes the data (flat field, rate, angular conversion and merging ::processData()) - \param delflag 0 leaves the data in the final data queue (default is 1) - \returns OK or FAIL depending on if it already started - */ - virtual int acquire(int delflag=1)=0; - - int startMeasurement(){acquire(0); return OK;}; - - - /** - get detector ids/versions for module=0 - \param mode which id/version has to be read - \param imod module number for module serial number - \returns id - */ - virtual int64_t getId(idMode mode, int imod=0)=0; - int64_t getDetectorFirmwareVersion(){return getId(DETECTOR_FIRMWARE_VERSION,-1);}; - int64_t getDetectorSerialNumber(){return getId(DETECTOR_SERIAL_NUMBER,-1);}; - int64_t getDetectorSoftwareVersion(){return getId(DETECTOR_SOFTWARE_VERSION,-1);}; - int64_t getThisSoftwareVersion(){return getId(THIS_SOFTWARE_VERSION,-1);}; - - /** - start detector acquisition - \returns OK/FAIL - */ - virtual int startAcquisition()=0; - /** - stop detector acquisition - \returns OK/FAIL - */ - virtual int stopAcquisition()=0; - int stopMeasurement(){return stopAcquisition();}; - - /** - set/get timer value - \param index timer index - \param t time in ns or number of...(e.g. frames, gates) - \param imod module number - \returns timer set value in ns or number of...(e.g. frames, gates) - */ - virtual int64_t setTimer(timerIndex index, int64_t t=-1, int imod = -1)=0; - int64_t setExposureTime(int64_t t=-1, int imod = -1){return setTimer(ACQUISITION_TIME,t,imod);}; - int64_t setSubFrameExposureTime(int64_t t=-1, int imod = -1){return setTimer(SUBFRAME_ACQUISITION_TIME,t,imod);}; - int64_t setSubFrameDeadTime(int64_t t=-1, int imod = -1){return setTimer(SUBFRAME_DEADTIME,t,imod);}; - int64_t setExposurePeriod(int64_t t=-1, int imod = -1){return setTimer(FRAME_PERIOD,t,imod);}; - int64_t setDelayAfterTrigger(int64_t t=-1, int imod = -1){return setTimer(DELAY_AFTER_TRIGGER,t,imod);}; - int64_t setNumberOfGates(int64_t t=-1, int imod = -1){return setTimer(GATES_NUMBER,t,imod);}; - int64_t setNumberOfFrames(int64_t t=-1, int imod = -1){return setTimer(FRAME_NUMBER,t,imod);}; - int64_t setNumberOfCycles(int64_t t=-1, int imod = -1){return setTimer(CYCLES_NUMBER,t,imod);}; - - - /** sets/gets the value of important readout speed parameters - \param sp is the parameter to be set/get - \param value is the value to be set, if -1 get value - \returns current value for the specified parameter - \sa speedVariable - */ - virtual int setSpeed(speedVariable sp, int value=-1)=0; - int setClockDivider(int s=-1){return setSpeed(CLOCK_DIVIDER,s);}; - - /** - set/get readout flags - \param flag readout flag to be set - \returns current flag - */ - virtual int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS)=0; - void setParallelMode(int value){ \ - if(value>=0){ \ - switch(value){ \ - case 0: setReadOutFlags(NONPARALLEL);break; \ - case 1: setReadOutFlags(PARALLEL);break; \ - default: setReadOutFlags(SAFE);break; \ - } \ - } \ - }; - - void setOverflowMode(int value){ \ - if(value>=0){ \ - switch(value){ \ - case 1: setReadOutFlags(SHOW_OVERFLOW);break; \ - case 0: setReadOutFlags(NOOVERFLOW);break; \ - } \ - } \ - }; - - /** - get readout mode of detector (eiger specific) - \returns 0 for nonparallel, 1 for parallel, 2 for safe - */ - int getParallelMode(){ \ - int ret = setReadOutFlags(); \ - if (ret&NONPARALLEL) return 0; \ - if (ret&PARALLEL) return 1; \ - if (ret&SAFE) return 2; \ - return -1; \ - } - - - /** - get readout overflow mode of detector (eiger specific) - \returns 1 for show overflow, 0 for do not show overflow - */ - int getOverflowMode(){ \ - int ret = setReadOutFlags(); \ - if (ret&SHOW_OVERFLOW) return 1; \ - if (ret&NOOVERFLOW) return 0; \ - return -1; \ - } \ - - /** - set/ get high voltage - \param val high voltage (>0 sets, 0 unsets, -1 gets) - \returns high voltage - */ - int setHighVoltage(int val){return setDAC(val, HV_NEW, 0, -1);} \ - - /** - set dacs value - \param val value - \param index DAC index - \param mV 0 in dac units or 1 in mV - \param imod module number (if -1 alla modules) - \returns current DAC value - */ - virtual dacs_t setDAC(dacs_t val, dacIndex index , int mV, int imod=-1)=0; - int setDACValue(int val, int index , int imod=-1) { return (int)setDAC((dacs_t)val,(dacIndex)index,0,imod);}; - - /** - gets ADC value - \param index ADC index - \param imod module number - \returns current ADC value - */ - virtual dacs_t getADC(dacIndex index, int imod=-1)=0; - int getADCValue(int index, int imod=-1){return (int)getADC((dacIndex)index, imod);}; - - /** - @short get run status - \returns status mask - */ - virtual runStatus getRunStatus()=0; - int getDetectorStatus() {return (int)getRunStatus();}; - - - /** @short sets the onlineFlag - \param online can be: -1 returns wether the detector is in online (1) or offline (0) state; 0 detector in offline state; 1 detector in online state - \returns 0 (offline) or 1 (online) - */ - virtual int setOnline(int const online=-1)=0; - - /** - * Activates/Deactivates the detector (Eiger only) - * @param enable active (1) or inactive (0), -1 gets - * @returns 0 (inactive) or 1 (active)for activate mode - */ - virtual int activate(int const enable=-1)=0; - - /** - * Set deactivated Receiver padding mode (Eiger only) - * @param padding padding option for deactivated receiver. Can be 1 (padding), 0 (no padding), -1 (gets) - * @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for padding option - */ - virtual int setDeactivatedRxrPaddingMode(int padding=-1)=0; - - /** - @short set detector settings - \param isettings settings index (-1 gets) - \returns current settings - */ - virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1)=0; - int setSettings(int isettings){return (int)setSettings((detectorSettings)isettings,-1);}; - - virtual detectorSettings getSettings(int imod=-1)=0; - /** - get threshold energy - \param imod module number (-1 all) - \returns current threshold value for imod in ev (-1 failed) - */ - virtual int getThresholdEnergy(int imod)=0; - int getThresholdEnergy(){return getThresholdEnergy(-1);}; - - /** - set/get the external communication mode - - obsolete \sa setExternalSignalFlags - \param pol value to be set \sa externalCommunicationMode - \returns current external communication mode - */ - virtual externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE)=0; - int setTimingMode(int i=-1){return slsDetectorUsers::getTimingMode( externalCommunicationType( setExternalCommunicationMode(externalCommunicationType( slsDetectorUsers::getTimingMode(i) ) ) ) );}; - - virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS, int tb=1)=0; - int setThresholdEnergy(int e_eV){return setThresholdEnergy(e_eV,-1);}; - int setThresholdEnergy(int e_ev, int tb, int isettings, int id){return setThresholdEnergy(e_ev, id, (detectorSettings)isettings, tb);} - - - /** - Prints receiver configuration - \returns OK or FAIL - */ - virtual int printReceiverConfiguration()=0; - - /** - Reads the configuration file fname - \param fname file name - \returns OK or FAIL - */ - virtual int readConfigurationFile(std::string const fname)=0; - - virtual int dumpDetectorSetup(std::string const fname, int level){return 0;}; - int dumpDetectorSetup(std::string const fname){return dumpDetectorSetup(fname,0);}; - virtual int retrieveDetectorSetup(std::string const fname, int level){return 0;}; - int retrieveDetectorSetup(std::string const fname){return retrieveDetectorSetup(fname,0);}; - /** - @short - \returns the default output file index - */ - virtual int getFileIndex()=0; - - /** - @short sets the default output file index - \param i file index - \returns the default output file index - */ - virtual int setFileIndex(int i)=0; - - /** - @short increments file index - \returns the file index - */ - virtual int incrementFileIndex()=0; - - - //receiver - /** - calls setReceiverTCPSocket if online and sets the flag - */ - virtual int setReceiverOnline(int const online=GET_ONLINE_FLAG)=0; - - /** Starts the listening mode of receiver - \returns OK or FAIL - */ - virtual int startReceiver()=0; - - /** Stops the listening mode of receiver - \returns OK or FAIL - */ - virtual int stopReceiver()=0; - - /** gets the status of the listening mode of receiver - \returns status - */ - virtual runStatus getReceiverStatus()=0; - - /** gets the number of frames caught by receiver - \returns number of frames caught by receiver - */ - virtual int getFramesCaughtByReceiver()=0; - - /** gets the number of frames caught by any one receiver (to avoid using threadpool) - \returns number of frames caught by any one receiver (master receiver if exists) - */ - virtual int getFramesCaughtByAnyReceiver()=0; - - /** - \returns current frame index of receiver - */ - virtual int getReceiverCurrentFrameIndex()=0; - - /** Locks/Unlocks the connection to the receiver - /param lock sets (1), usets (0), gets (-1) the lock - /returns lock status of the receiver - */ - virtual int lockReceiver(int lock=-1)=0; - - - /** Reads frames from receiver through a constant socket - */ -virtual void readFrameFromReceiver()=0; - - -/** - * Enable data streaming to client - * @param enable 0 to disable, 1 to enable, -1 to get the value - * @returns data streaming to client enable - */ -virtual int enableDataStreamingToClient(int enable=-1)=0; - -/** Enable or disable streaming data from receiver to client - * @param enable 0 to disable 1 to enable -1 to only get the value - * @returns data streaming from receiver enable -*/ -virtual int enableDataStreamingFromReceiver(int enable=-1)=0; - - /** Sets the read receiver frequency - if data required from receiver randomly readRxrFrequency=0, - else every nth frame to be sent to gui - @param freq is the receiver read frequency - /returns read receiver frequency - */ - virtual int setReadReceiverFrequency(int freq=-1)=0; - - - int enableCountRateCorrection(int i=-1) {if (i>0) setRateCorrection(-1); else if (i==0) setRateCorrection(0); return getRateCorrection();}; - - /** - * Set/Get receiver streaming out ZMQ port - * For multi modules, it calculates (increments) and sets the ports - * @param i sets, -1 gets - * @returns receiver streaming out ZMQ port - */ - int setReceiverDataStreamingOutPort(int i) { \ - if (i >= 0) { \ - std::ostringstream ss; ss << i; std::string s = ss.str(); \ - int prev_streaming = enableDataStreamingFromReceiver(); \ - setNetworkParameter(RECEIVER_STREAMING_PORT, s); \ - if (prev_streaming) { \ - enableDataStreamingFromReceiver(0); \ - enableDataStreamingFromReceiver(1);}} \ - return atoi(getNetworkParameter(RECEIVER_STREAMING_PORT).c_str());}; \ - - /** - * Set/Get client streaming in ZMQ port - * For multi modules, it calculates (increments) and sets the ports - * @param i sets, -1 gets - * @returns client streaming in ZMQ port - */ - int setClientDataStreamingInPort(int i){ \ - if (i >= 0) { \ - std::ostringstream ss; ss << i; std::string s = ss.str(); \ - int prev_streaming = enableDataStreamingToClient(); \ - setNetworkParameter(CLIENT_STREAMING_PORT, s); \ - if (prev_streaming) { \ - enableDataStreamingToClient(0); \ - enableDataStreamingToClient(1);}} \ - return atoi(getNetworkParameter(CLIENT_STREAMING_PORT).c_str());}; \ - - /** - * Set/Get receiver streaming out ZMQ port - * For multi modules, it calculates (increments) and sets the ports - * @param i sets, -1 gets - * @returns receiver streaming out ZMQ port - */ - std::string setReceiverDataStreamingOutIP(std::string ip) { \ - if (ip.length()) { \ - int prev_streaming = enableDataStreamingFromReceiver(); \ - setNetworkParameter(RECEIVER_STREAMING_SRC_IP, ip); \ - if (prev_streaming) { \ - enableDataStreamingFromReceiver(0); \ - enableDataStreamingFromReceiver(1);}} \ - return getNetworkParameter(RECEIVER_STREAMING_SRC_IP);}; \ - - /** - * Set/Get client streaming in ZMQ port - * For multi modules, it calculates (increments) and sets the ports - * @param i sets, -1 gets - * @returns client streaming in ZMQ port - */ - std::string setClientDataStreamingInIP(std::string ip){ \ - if (ip.length()) { \ - int prev_streaming = enableDataStreamingToClient(); \ - setNetworkParameter(CLIENT_STREAMING_SRC_IP, ip); \ - if (prev_streaming) { \ - enableDataStreamingToClient(0); \ - enableDataStreamingToClient(1);}} \ - return getNetworkParameter(CLIENT_STREAMING_SRC_IP);}; \ - - - int setFlowControl10G(int i = -1) { - std::string sret=""; - if (i != -1) { - std::ostringstream o; - o << ((i >= 1) ? 1 : 0); - std::string sval = o.str(); - sret = setNetworkParameter(FLOW_CONTROL_10G, sval); - } else - sret = getNetworkParameter(FLOW_CONTROL_10G); - - return atoi(sret.c_str()); - } - - - /** - * Set acquiring flag in shared memory - * @param b acquiring flag - */ - virtual void setAcquiringFlag(bool b=false) = 0; - - /** - * Get acquiring flag from shared memory - * @returns acquiring flag - */ - virtual bool getAcquiringFlag() = 0; - - /** - * Check if acquiring flag is set, set error if set - * @returns FAIL if not ready, OK if ready - */ - virtual bool isAcquireReady() = 0; - - /** - * Check version compatibility with detector/receiver software - * (if hostname/rx_hostname has been set/ sockets created) - * @param p port type control port or receiver port - * @returns FAIL for incompatibility, OK for compatibility - */ - virtual int checkVersionCompatibility(portType t) = 0; - - /** - * Free shared memory and delete shared memory structure - */ - virtual void freeSharedMemory() = 0; - - /** - * Get user details of shared memory - * Should only be called from multi detector level - * @returns string with user details - */ - virtual std::string getUserDetails() = 0; - - /** - * Sets the hostname of all sls detectors in shared memory - * Connects to them to set up online flag - * @param name concatenated hostname of all the sls detectors - */ - virtual void setHostname(const char* name)=0; - - /** - * Gets the hostname of detector at particular position - * or concatenated hostnames of all the sls detectors - * @param pos position of detector in array, -1 for all detectors - * @returns concatenated hostnames of all detectors or hostname of specific one - */ - virtual std::string getHostname(int pos=-1)=0; - - /** - * Appends detectors to the end of the list in shared memory - * Connects to them to set up online flag - * @param name concatenated hostname of the sls detectors to be appended to the list - */ - virtual void addMultipleDetectors(const char* name)=0; - - - using slsDetectorBase::getDetectorsType; - /** - * Concatenates string types of all sls detectors or - * returns the detector type of the first sls detector - * @param pos position of sls detector in array, if -1, returns first detector type - * @returns detector type of sls detector in position pos, if -1, concatenates - */ - virtual std::string sgetDetectorsType(int pos=-1)=0; - - /** - * Returns the number of detectors in the multidetector structure - * @returns number of detectors - */ - virtual int getNumberOfDetectors(){return 1;}; - - /** - * Returns the total number of channels of all sls detectors from shared memory - * @returns the total number of channels of all sls detectors - */ - virtual int getTotalNumberOfChannels()=0; - - /** - * Returns the total number of channels of all sls detectors in dimension d - * from shared memory - * @param d dimension d - * @returns the total number of channels of all sls detectors in dimension d - */ - virtual int getTotalNumberOfChannels(dimension d)=0; - - /** - * Returns the maximum number of channels of all sls detectors in each dimension d - * from shared memory. multi detector shared memory variable to calculate - * offsets for each sls detector - * @param d dimension d - * @returns the maximum number of channels of all sls detectors in dimension d - */ - virtual int getMaxNumberOfChannelsPerDetector(dimension d){return -1;}; - - /** - * Sets the maximum number of channels of all sls detectors in each dimension d - * from shared memory, multi detector shared memory variable to calculate - * offsets for each sls detector - * @param d dimension d - * @param i maximum number of channels for multi structure in dimension d - * @returns the maximum number of channels of all sls detectors in dimension d - */ - virtual int setMaxNumberOfChannelsPerDetector(dimension d,int i){return -1;}; - - /** - * Checks if each of the detectors are online/offline - * @returns empty string if they are all online, - * else returns concatenation of strings of all detectors that are offline - */ - virtual std::string checkOnline()=0; - - /** - * Set/Gets TCP Port of detector or receiver - * @param t port type - * @param num port number (-1 gets) - * @returns port number - */ - virtual int setPort(portType t, int num=-1)=0; - - /** - * Get last client IP saved on detector server - * @returns last client IP saved on detector server - */ - virtual std::string getLastClientIP()=0; - - /** - * Exit detector server - * @returns OK or FAIL - */ - virtual int exitServer()=0; - - /** - * Write current configuration to a file - * @param fname configuration file name - * @returns OK or FAIL - */ - virtual int writeConfigurationFile(std::string const fname)=0; - - /** - * Returns the trimfile or settings file name (Useless??) - * @returns the trimfile or settings file name - */ - virtual std::string getSettingsFile()=0; - - /** - * Set threshold energy (Mythen and Eiger) - * @param e_eV threshold in eV - * @param imod module number (-1 all) - * @param isettings ev. change settings - * @param tb 1 to include trimbits, 0 to exclude - * @returns current threshold value for imod in ev (-1 failed) - */ - virtual int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS,int tb=1)=0; - - /** - * Returns the detector trimbit/settings directory \sa sharedSlsDetector - * @returns the trimbit/settings directory - */ - virtual std::string getSettingsDir()=0; - - /** - * Sets the detector trimbit/settings directory \sa sharedSlsDetector - * @param s trimbits/settings directory - * @returns the trimbit/settings directory - */ - virtual std::string setSettingsDir(std::string s)=0; - - /** - * Returns the calibration files directory \sa sharedSlsDetector (Mythen) - * @returns the calibration files directory - */ - virtual std::string getCalDir()=0; - - /** - * Sets the calibration files directory \sa sharedSlsDetector (Mythen) - * @param s the calibration files directory - * @returns the calibration files directory - */ - virtual std::string setCalDir(std::string s)=0; - - /** - * Loads the modules settings/trimbits reading from a specific file - * file name extension is automatically generated. - * @param fname specific settings/trimbits file - * @param imod module number (-1 for all) - * returns OK or FAIL - */ - virtual int loadSettingsFile(std::string fname, int imod=-1)=0; - - /** - * Saves the modules settings/trimbits to a specific file - * file name extension is automatically generated. - * @param fname specific settings/trimbits file - * @param imod module number (-1 for all) - * returns OK or FAIL - */ - virtual int saveSettingsFile(std::string fname, int imod=-1)=0; - - /** - * Give an internal software trigger to the detector (Eiger only) - * @return OK or FAIL - */ - virtual int sendSoftwareTrigger()=0; - - /** - * Start detector acquisition and read all data (Blocking until end of acquisition) - * @returns OK or FAIL - */ - virtual int startAndReadAll()=0; - - /** - * Requests and receives all data from the detector (Eiger store in ram) - * @returns OK or FAIL - */ - virtual int readAll()=0; - - /** - * Configures in detector the destination for UDP packets (Not Mythen) - * @returns OK or FAIL - */ - virtual int configureMAC()=0; - - /** - * Set/get timer value left in acquisition (not all implemented for all detectors) - * @param index timer index - * @param t time in ns or number of...(e.g. frames, gates, probes) - * @param imod module number - * @returns timer set value in ns or number of...(e.g. frames, gates, probes) - */ - virtual int64_t getTimeLeft(timerIndex index, int imod = -1)=0; - - /** - * Set speed - * @param sp speed type (clkdivider option for Jungfrau and Eiger, others for Mythen/Gotthard) - * @param value (clkdivider 0,1,2 for full, half and quarter speed). Other values check manual - * @returns value of speed set - */ - virtual int setSpeed(speedVariable sp, int value=-1)=0; - - /** - * Set/get dacs value - * @param val value (in V) - * @param index DAC index - * @param mV 0 in dac units or 1 in mV - * @param imod module number (if -1 all modules) - * @returns current DAC value - */ - virtual dacs_t setDAC(dacs_t val, dacIndex index , int mV, int imod=-1)=0; - - /** - * Get adc value - * @param index adc(DAC) index - * @param imod module number (if -1 all modules) - * @returns current adc value (temperature for eiger and jungfrau in millidegrees) - */ - virtual dacs_t getADC(dacIndex index, int imod=-1)=0; - - /** - * Set/get external signal flags (to specify triggerinrising edge etc) (Gotthard, Mythen) - * @param pol external signal flag (-1 gets) - * @param signalindex singal index (0 - 3) - * @returns current timing mode - */ - virtual externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0)=0; - - /** - * Set/get readout flags (Eiger, Mythen) - * @param flag readout flag (Eiger options: parallel, nonparallel, safe etc.) (-1 gets) - * @returns readout flag - */ - virtual int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS)=0; - - /** - * Write in a register. For Advanced users - * @param addr address of register - * @param val value to write into register - * @returns value read after writing - */ - virtual uint32_t writeRegister(uint32_t addr, uint32_t val)=0; - - /** - * Read from a register. For Advanced users - * @param addr address of register - * @returns value read from register - */ - virtual uint32_t readRegister(uint32_t addr)=0; - - /** - * Set bit in a register. For Advanced users - * @param addr address of register - * @param n nth bit - * @returns value read from register - */ - virtual uint32_t setBit(uint32_t addr, int n)=0; - - /** - * Clear bit in a register. For Advanced users - * @param addr address of register - * @param n nth bit - * @returns value read from register - */ - virtual uint32_t clearBit(uint32_t addr, int n)=0; - - /** - * Set network parameter - * @param p network parameter type - * @param s network parameter value - * @returns network parameter value set (from getNetworkParameter) - */ - virtual std::string setNetworkParameter(networkParameter p, std::string s)=0; - - /** - * Get network parameter - * @param p network parameter type - * @returns network parameter value set (from getNetworkParameter) - */ - virtual std::string getNetworkParameter(networkParameter)=0; - - /** - * Execute a digital test (Gotthard, Mythen) - * @param mode testmode type - * @param imod module index (-1 for all) - * @returns result of test - */ - virtual int digitalTest(digitalTestMode mode, int imod=0)=0; - - /** - * Load dark or gain image to detector (Gotthard) - * @param index image type - * @param fname file name from which to load image - * @returns OK or FAIL - */ - virtual int loadImageToDetector(imageType index,std::string const fname)=0; - - /** - * Writes the counter memory block from the detector (Gotthard) - * @param fname file name to load data from - * @param startACQ is 1 to start acquisition after reading counter - * @returns OK or FAIL - */ - virtual int writeCounterBlockFile(std::string const fname,int startACQ=0)=0; - - /** - * Resets counter in detector (Gotthard) - * @param startACQ is 1 to start acquisition after resetting counter - * @returns OK or FAIL - */ - virtual int resetCounterBlock(int startACQ=0)=0; - - /** - * Set/get counter bit in detector (Gotthard) - * @param i is -1 to get, 0 to reset and any other value to set the counter bit - * @returns the counter bit in detector - */ - virtual int setCounterBit(int i = -1)=0; - - /** - * Set ROI (Gotthard) - * At the moment only one set allowed - * @param n number of rois - * @param roiLimits array of roi - * @returns OK or FAIL - */ - virtual int setROI(int n=-1,ROI roiLimits[]=NULL)=0; - - /** - * Get ROI from each detector and convert it to the multi detector scale (Gotthard) - * @param n number of rois - * @returns OK or FAIL - */ - virtual ROI* getROI(int &n)=0; - - /** - * Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert users - * @param addr address of adc register - * @param val value - * @returns return value (mostly -1 as it can't read adc register) - */ - virtual int writeAdcRegister(int addr, int val)=0; - - /** - * Returns the enable if data will be flipped across x or y axis (Eiger) - * @param d axis across which data is flipped - * @returns 1 for flipped, else 0 - */ - virtual int getFlippedData(dimension d=X)=0; - - /** - * Sets the enable which determines if - * data will be flipped across x or y axis (Eiger) - * @param d axis across which data is flipped - * @param value 0 or 1 to reset/set or -1 to get value - * @returns enable flipped data across x or y axis - */ - virtual int setFlippedData(dimension d=X, int value=-1)=0; - - /** - * Sets all the trimbits to a particular value (Eiger) - * @param val trimbit value - * @param imod module number, -1 means all modules - * @returns OK or FAIL - */ - virtual int setAllTrimbits(int val, int imod=-1)=0; - - /** - * Enable gap pixels, only for Eiger and for 8,16 and 32 bit mode. (Eiger) - * 4 bit mode gap pixels only in gui call back - * @param val 1 sets, 0 unsets, -1 gets - * @returns gap pixel enable or -1 for error - */ - virtual int enableGapPixels(int val=-1)=0; - - /** - * Sets the number of trim energies and their value (Eiger) - * \sa sharedSlsDetector - * @param nen number of energies - * @param en array of energies - * @returns number of trim energies - */ - virtual int setTrimEn(int nen, int *en=NULL)=0; - - /** - * Returns the number of trim energies and their value (Eiger) - * \sa sharedSlsDetector - * @param en array of energies - * @returns number of trim energies - */ - virtual int getTrimEn(int *en=NULL)=0; - - /** - * Pulse Pixel (Eiger) - * @param n is number of times to pulse - * @param x is x coordinate - * @param y is y coordinate - * @returns OK or FAIL - */ - virtual int pulsePixel(int n=0,int x=0,int y=0)=0; - - /** - * Pulse Pixel and move by a relative value (Eiger) - * @param n is number of times to pulse - * @param x is relative x value - * @param y is relative y value - * @returns OK or FAIL - */ - virtual int pulsePixelNMove(int n=0,int x=0,int y=0)=0; - - /** - * Pulse Chip (Eiger) - * @param n is number of times to pulse - * @returns OK or FAIL - */ - virtual int pulseChip(int n=0)=0; - - /** - * Set/gets threshold temperature (Jungfrau) - * @param val value in millidegrees, -1 gets - * @param imod module number, -1 is all - * @returns threshold temperature in millidegrees - */ - virtual int setThresholdTemperature(int val=-1, int imod=-1)=0; - - /** - * Enables/disables temperature control (Jungfrau) - * @param val value, -1 gets - * @param imod module number, -1 is all - * @returns temperature control enable - */ - virtual int setTemperatureControl(int val=-1, int imod=-1)=0; - - /** - * Resets/ gets over-temperature event (Jungfrau) - * @param val value, -1 gets - * @param imod module number, -1 is all - * @returns over-temperature event - */ - virtual int setTemperatureEvent(int val=-1, int imod=-1)=0; - - /** - * Set storage cell that stores first acquisition of the series (Jungfrau) - * @param value storage cell index. Value can be 0 to 15. (-1 gets) - * @returns the storage cell that stores the first acquisition of the series - */ - virtual int setStoragecellStart(int pos=-1)=0; - - /** - * Programs FPGA with pof file (Jungfrau) - * @param fname file name - * @returns OK or FAIL - */ - virtual int programFPGA(std::string fname)=0; - - /** - * Resets FPGA (Jungfrau) - * @returns OK or FAIL - */ - virtual int resetFPGA()=0; - - /** - * Power on/off Chip (Jungfrau) - * @param ival on is 1, off is 0, -1 to get - * @returns OK or FAIL - */ - virtual int powerChip(int ival= -1)=0; - - /** - * Automatic comparator disable (Jungfrau) - * @param ival on is 1, off is 0, -1 to get - * @returns OK or FAIL - */ - virtual int setAutoComparatorDisableMode(int ival= -1)=0; - - /** - * Calibrate Pedestal (ChipTestBoard) - * Starts acquisition, calibrates pedestal and writes to fpga - * @param frames number of frames - * @returns number of frames - */ - virtual int calibratePedestal(int frames = 0)=0; - - /** - * Get rate correction tau (Mythen, Eiger) - * @returns 0 if rate correction disabled, otherwise the tau used for the correction - */ - virtual double getRateCorrectionTau()=0; - - /** - * Checks if the receiver is really online - * @returns empty string if all online, else concatenates hostnames of all - * detectors that are offline - */ - virtual std::string checkReceiverOnline()=0; - - /** - * Locks/Unlocks the connection to the receiver - * @param lock sets (1), usets (0), gets (-1) the lock - * @returns lock status of the receiver - */ - virtual int lockReceiver(int lock=-1)=0; - - /** - * Returns the IP of the last client connecting to the receiver - * @returns IP of last client connecting to receiver - */ - virtual std::string getReceiverLastClientIP()=0; - - /** - * Turns off the receiver server! - * @returns OK or FAIL - */ - virtual int exitReceiver()=0; - - /** - * Returns output file directory - * @returns output file directory - */ - virtual std::string getFilePath()=0; - - /** - * Sets up the file directory - * @param s file directory - * @returns file dir - */ - virtual std::string setFilePath(std::string s)=0; - - /** - * Returns file name prefix - * @returns file name prefix - */ - virtual std::string getFileName()=0; - - /** - * Sets up the file name prefix - * @param s file name prefix - * @returns file name prefix - */ - virtual std::string setFileName(std::string s)=0; - - /** - * Sets the max frames per file in receiver - * @param f max frames per file - * @returns max frames per file in receiver - */ - virtual int setReceiverFramesPerFile(int f=-1)=0; - - /** - * Sets the frames discard policy in receiver - * @param f frames discard policy - * @returns frames discard policy set in receiver - */ - virtual frameDiscardPolicy setReceiverFramesDiscardPolicy(frameDiscardPolicy f = GET_FRAME_DISCARD_POLICY)=0; - - /** - * Sets the partial frames padding enable in receiver - * @param f partial frames padding enable - * @returns partial frames padding enable in receiver - */ - virtual int setReceiverPartialFramesPadding(int f = -1)=0; - - /** - * Returns file format - * @returns file name - */ - virtual fileFormat getFileFormat()=0; - - /** - * Sets up the file format - * @param f file format - * @returns file format - */ - virtual fileFormat setFileFormat(fileFormat f)=0; - - /** - * Gets the number of frames caught by receiver - * @returns number of frames caught by receiver - */ - virtual int getFramesCaughtByReceiver()=0; - - /** - * Gets the number of frames caught by any one receiver (to avoid using threadpool) - * @returns number of frames caught by any one receiver (master receiver if exists) - */ - virtual int getFramesCaughtByAnyReceiver()=0; - - /** - * Gets the current frame index of receiver - * @returns current frame index of receiver - */ - virtual int getReceiverCurrentFrameIndex()=0; - - /** - * Resets framescaught in receiver - * Use this when using startAcquisition instead of acquire - * @returns OK or FAIL - */ - virtual int resetFramesCaught()=0; - - /** - * Create Receiving Data Sockets - * @param destroy is true to destroy all the sockets - * @returns OK or FAIL - */ - virtual int createReceivingDataSockets(const bool destroy = false){return -1;}; - - /** - * Reads frames from receiver through a constant socket - * Called during acquire() when call back registered or when using gui - */ - virtual void readFrameFromReceiver(){}; - - /** - * Sets/Gets receiver file write enable - * @param enable 1 or 0 to set/reset file write enable - * @returns file write enable - */ - virtual int enableWriteToFile(int enable=-1)=0; - - /** - * Sets/Gets file overwrite enable - * @param enable 1 or 0 to set/reset file overwrite enable - * @returns file overwrite enable - */ - virtual int overwriteFile(int enable=-1)=0; - - /** - * Sets the read receiver frequency - * if data required from receiver randomly readRxrFrequency=0, - * else every nth frame to be sent to gui/callback - * @param freq is the receiver read frequency. Value 0 is 200 ms timer (other - * frames not sent), 1 is every frame, 2 is every second frame etc. - * @returns read receiver frequency - */ - virtual int setReadReceiverFrequency(int freq=-1)=0; - - /** - * Enable data streaming to client - * @param enable 0 to disable, 1 to enable, -1 to get the value - * @returns data streaming to client enable - */ - virtual int enableDataStreamingToClient(int enable=-1)=0; - - /** - * Enable or disable streaming data from receiver to client - * @param enable 0 to disable 1 to enable -1 to only get the value - * @returns data streaming from receiver enable - */ - virtual int enableDataStreamingFromReceiver(int enable=-1)=0; - - /** - * Enable/disable or 10Gbe - * @param i is -1 to get, 0 to disable and 1 to enable - * @returns if 10Gbe is enabled - */ - virtual int enableTenGigabitEthernet(int i = -1)=0; - - /** - * Set/get receiver fifo depth - * @param i is -1 to get, any other value to set the fifo deph - * @returns the receiver fifo depth - */ - virtual int setReceiverFifoDepth(int i = -1)=0; - - /** - * Set/get receiver silent mode - * @param i is -1 to get, 0 unsets silent mode, 1 sets silent mode - * @returns the receiver silent mode enable - */ - virtual int setReceiverSilentMode(int i = -1)=0; - - /** - * Opens pattern file and sends pattern to CTB - * @param fname pattern file to open - * @returns OK/FAIL - */ - virtual int setCTBPattern(std::string fname)=0; - - /** - * Writes a pattern word to the CTB - * @param addr address of the word, -1 is I/O control register, - * -2 is clk control register - * @param word 64bit word to be written, -1 gets - * @returns actual value - */ - virtual uint64_t setCTBWord(int addr,uint64_t word=-1)=0; - - /** - * Sets the pattern or loop limits in the CTB - * @param level -1 complete pattern, 0,1,2, loop level - * @param start start address if >=0 - * @param stop stop address if >=0 - * @param n number of loops (if level >=0) - * @returns OK/FAIL - */ - virtual int setCTBPatLoops(int level,int &start, int &stop, int &n)=0; - - /** - * Sets the wait address in the CTB - * @param level 0,1,2, wait level - * @param addr wait address, -1 gets - * @returns actual value - */ - virtual int setCTBPatWaitAddr(int level, int addr=-1)=0; - - /** - * Sets the wait time in the CTB - * @param level 0,1,2, wait level - * @param t wait time, -1 gets - * @returns actual value - */ - virtual int setCTBPatWaitTime(int level, uint64_t t=-1)=0; - - - /** returns detector type std::string from detector type index + /** returns detector type std::string from detector type index \param t std::string can be Eiger, Gotthard, Jungfrau, Unknown \returns EIGER, GOTTHARD, JUNGFRAU, GENERIC */ diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 092ccab80..8bf54c955 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -852,13 +852,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettingsDir; ++i; - /*! \page settings - - caldir [dir] Sets/gets the directory where the calibration files are located. \c Returns \c (string) dir - */ - descrToFuncMap[i].m_pFuncName="caldir"; //OK - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdCalDir; - ++i; - /*! \page settings - trimen [n e0 e1...e(n-1)] Sets/gets the number of energies n at which the detector has default trim file and their values in eV (int). \c Returns \c (int int...) n e0 e1...e(n-1) */ @@ -2476,32 +2469,6 @@ string slsDetectorCommand::helpSettingsDir(int action){ -string slsDetectorCommand::cmdCalDir(int narg, char *args[], int action, int detPos){ - - if (action==HELP_ACTION) { - return helpCalDir(action); - } - if (action==PUT_ACTION) { - myDet->setCalDir(string(args[1]), detPos); - } - if ( (myDet->getCalDir(detPos)).empty() ) - return string("undefined"); - return myDet->getCalDir(detPos); -} - - - -string slsDetectorCommand::helpCalDir(int action){ - ostringstream os; - if (action==GET_ACTION || action==HELP_ACTION) - os << string("caldir \t gets the directory where the calibration files are located\n"); - if (action==PUT_ACTION || action==HELP_ACTION) - os << string("caldir dir \t sets the directory where the calibration files are located\n"); - return os.str(); -} - - - string slsDetectorCommand::cmdTrimEn(int narg, char *args[], int action, int detPos){ int ival; int ip; @@ -3890,7 +3857,7 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action, int detPos return helpDAC(action); dacIndex dac; - dacs_t val=-1; + int val=-1; char answer[1000]; int mode=0; @@ -5047,9 +5014,9 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action, int d if (!sscanf(args[1],"%d",&ival)) return string("Could not scan read frequency mode ")+string(args[1]); if(ival>=0) - myDet->setReadReceiverFrequency(ival, detPos); + myDet->setReceiverStreamingFrequency(ival, detPos); } - sprintf(answer,"%d",myDet->setReadReceiverFrequency(-1, detPos)); + sprintf(answer,"%d",myDet->setReceiverStreamingFrequency(-1, detPos)); return string(answer); } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h index 39b8fe3fd..aa9c34c93 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h @@ -46,7 +46,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs { static std::string helpUser(int action); static std::string helpExitServer(int action); static std::string helpSettingsDir(int action); - static std::string helpCalDir(int action); static std::string helpTrimEn(int action); static std::string helpOutDir(int action); static std::string helpFileName(int action); @@ -109,7 +108,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs { std::string cmdHelp(int narg, char *args[], int action, int detPos = -1); std::string cmdExitServer(int narg, char *args[], int action, int detPos = -1); std::string cmdSettingsDir(int narg, char *args[], int action, int detPos = -1); - std::string cmdCalDir(int narg, char *args[], int action, int detPos = -1); std::string cmdTrimEn(int narg, char *args[], int action, int detPos = -1); std::string cmdOutDir(int narg, char *args[], int action, int detPos = -1); std::string cmdFileName(int narg, char *args[], int action, int detPos = -1); diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp index 0b16a636e..321aea561 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp @@ -18,265 +18,373 @@ slsDetectorUsers::slsDetectorUsers(int& ret, int id) : myDetector(0), myCmd(0){ } - slsDetectorUsers::~slsDetectorUsers() { - if (myDetector) - delete myDetector; + if (myDetector) + delete myDetector; } -string slsDetectorUsers::getDetectorDeveloper(){ - return myDetector->getDetectorDeveloper(); -} - -int slsDetectorUsers::setOnline(int const online){ - return myDetector->setOnline(online); -} - -int slsDetectorUsers::setReceiverOnline(int const online){ - return myDetector->setReceiverOnline(online); -} - -void slsDetectorUsers::startMeasurement(){ - myDetector->acquire(0); -} - -int slsDetectorUsers::stopMeasurement(){ - return myDetector->stopAcquisition(); -} - -int slsDetectorUsers::getDetectorStatus(){ - return (int)myDetector->getRunStatus(); -} - -string slsDetectorUsers::getFilePath(){ - return myDetector->getFilePath(); -} - -string slsDetectorUsers::setFilePath(string s){ - return myDetector->setFilePath(s); -} - -string slsDetectorUsers::getFileName(){ - return myDetector->getFileName(); -} - -string slsDetectorUsers::setFileName(string s){ - return myDetector->setFileName(s); -} - -int slsDetectorUsers::getFileIndex(){ - return (int)myDetector->getFileIndex(); -} - -int slsDetectorUsers::setFileIndex(int i){ - return (int)myDetector->setFileIndex(i); -} - -int slsDetectorUsers::enableCountRateCorrection(int i){ - return myDetector->enableCountRateCorrection(i); -} - -int slsDetectorUsers::enableWriteToFile(int i){ - return myDetector->enableWriteToFile(i); -} - -int slsDetectorUsers::getDetectorSize(int &x0, int &y0, int &nx, int &ny){ - y0=0; - x0=0; - nx=myDetector->getTotalNumberOfChannels(slsDetectorDefs::X); - ny=myDetector->getTotalNumberOfChannels(slsDetectorDefs::Y); - return nx*ny; +int slsDetectorUsers::getNumberOfDetectors() { + return myDetector->getNumberOfDetectors(); } int slsDetectorUsers::getMaximumDetectorSize(int &nx, int &ny){ - nx=myDetector->getMaxNumberOfChannelsPerDetector(slsDetectorDefs::X); - ny=myDetector->getMaxNumberOfChannelsPerDetector(slsDetectorDefs::Y); - return nx*ny; + nx=myDetector->getMaxNumberOfChannelsPerDetector(slsDetectorDefs::X); + ny=myDetector->getMaxNumberOfChannelsPerDetector(slsDetectorDefs::Y); + return nx*ny; } -int slsDetectorUsers::setBitDepth(int i){ - return myDetector->setDynamicRange(i); +int slsDetectorUsers::getDetectorSize(int &x, int &y, int &nx, int &ny, int detPos){ + if (detPos < 0) { + x = 0; + y = 0; + } else { + x = myDetector->getDetectorOffset(slsDetectorDefs::X, detPos); + y = myDetector->getDetectorOffset(slsDetectorDefs::Y, detPos); + } + nx=myDetector->getTotalNumberOfChannels(slsDetectorDefs::X, detPos); + ny=myDetector->getTotalNumberOfChannels(slsDetectorDefs::Y, detPos); + return nx*ny; } -int slsDetectorUsers::setSettings(int isettings){ - return myDetector->slsDetectorBase::setSettings(isettings); +string slsDetectorUsers::getDetectorType(int detPos){ + return myDetector->sgetDetectorsType(detPos); +} +int slsDetectorUsers::setOnline(int const online, int detPos){ + return myDetector->setOnline(online, detPos); } -int slsDetectorUsers::getThresholdEnergy(){ - return myDetector->getThresholdEnergy(-1); -} - -int slsDetectorUsers::setThresholdEnergy(int e_eV){ - return myDetector->setThresholdEnergy(e_eV); -} - -int slsDetectorUsers::setThresholdEnergy(int e_ev, int tb, int isettings, int id) { - return myDetector->slsDetectorBase::setThresholdEnergy(e_ev, tb, isettings, id); -} - -double slsDetectorUsers::setExposureTime(double t, bool inseconds, int imod){ - if(!inseconds) - return myDetector->setExposureTime((int64_t)t,imod); - - // + 0.5 to round for precision lost from converting double to int64_t - int64_t tms = (int64_t)(t * (1E+9) + 0.5); - if (t < 0) tms = -1; - tms = myDetector->setExposureTime(tms,imod); - if (tms < 0) - return -1; - return ((1E-9) * (double)tms); -} - -double slsDetectorUsers::setExposurePeriod(double t, bool inseconds, int imod){ - if(!inseconds) - return myDetector->setExposurePeriod((int64_t)t,imod); - - // + 0.5 to round for precision lost from converting double to int64_t - int64_t tms = (int64_t)(t * (1E+9) + 0.5); - if (t < 0) tms = -1; - tms = myDetector->setExposurePeriod(tms,imod); - if (tms < 0) - return -1; - return ((1E-9) * (double)tms); -} - -double slsDetectorUsers::setDelayAfterTrigger(double t, bool inseconds, int imod){ - if(!inseconds) - return myDetector->setDelayAfterTrigger((int64_t)t,imod); - - // + 0.5 to round for precision lost from converting double to int64_t - int64_t tms = (int64_t)(t * (1E+9) + 0.5); - if (t < 0) tms = -1; - tms = myDetector->setDelayAfterTrigger(tms,imod); - if (tms < 0) - return -1; - return ((1E-9) * (double)tms); -} - -int64_t slsDetectorUsers::setNumberOfGates(int64_t t, int imod){ - return myDetector->setNumberOfGates(t,imod); -} - -int64_t slsDetectorUsers::setNumberOfFrames(int64_t t, int imod){ - return myDetector->setNumberOfFrames(t,imod); -} - -int64_t slsDetectorUsers::setNumberOfCycles(int64_t t, int imod){ - return myDetector->setNumberOfCycles(t,imod); -} - -int slsDetectorUsers::setTimingMode(int pol){ - return myDetector->setTimingMode(pol); +int slsDetectorUsers::setReceiverOnline(int const online, int detPos){ + return myDetector->setReceiverOnline(online, detPos); } int slsDetectorUsers::readConfigurationFile(string const fname){ - return myDetector->readConfigurationFile(fname); -} + return myDetector->readConfigurationFile(fname); +} -int slsDetectorUsers::dumpDetectorSetup(string const fname){ - return myDetector->dumpDetectorSetup(fname); -} +int slsDetectorUsers::writeConfigurationFile(string const fname){ + return myDetector->writeConfigurationFile(fname); +} int slsDetectorUsers::retrieveDetectorSetup(string const fname){ - return myDetector->retrieveDetectorSetup(fname); + return myDetector->retrieveDetectorSetup(fname); } -string slsDetectorUsers::getDetectorType(){ - return myDetector->sgetDetectorsType(); +int slsDetectorUsers::dumpDetectorSetup(string const fname){ + return myDetector->dumpDetectorSetup(fname); } -int slsDetectorUsers::setReceiverMode(int n){ - return myDetector->setReadReceiverFrequency(n); +int64_t slsDetectorUsers::getDetectorFirmwareVersion(int detPos){ + return myDetector->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION); } -int slsDetectorUsers::enableDataStreamingFromReceiver(int i){ - return myDetector->enableDataStreamingFromReceiver(i); +int64_t slsDetectorUsers::getDetectorSerialNumber(int detPos){ + return myDetector->getId(slsDetectorDefs::DETECTOR_SERIAL_NUMBER, detPos); +} + +int64_t slsDetectorUsers::getDetectorSoftwareVersion(int detPos){ + return myDetector->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION, detPos); +} + +int64_t slsDetectorUsers::getClientSoftwareVersion(int detPos){ + return myDetector->getId(slsDetectorDefs::THIS_SOFTWARE_VERSION, detPos); +} + +int64_t slsDetectorUsers::getReceiverSoftwareVersion(int detPos){ + return myDetector->getId(slsDetectorDefs::RECEIVER_VERSION, detPos); +} + +bool isDetectorVersionCompatible(int detPos) { + return (myDetector->checkVersionCompatibility(slsDetectorDefs::CONTROL_PORT, detPos) == OK); +} + +bool isReceiverVersionCompatible(int detPos) { + return (myDetector->checkVersionCompatibility(slsDetectorDefs::DATA_PORT, detPos) == OK); +} + +int slsDetectorUsers::startMeasurement(){ + return myDetector->acquire(); +} + +int slsDetectorUsers::stopMeasurement(int detPos){ + return myDetector->stopAcquisition(detPos); +} + +int slsDetectorUsers::getDetectorStatus(int detPos){ + return (int)myDetector->getRunStatus(detPos); +} + +int slsDetectorUsers::startAcquisition(int detPos) { + return myDetector->startAcquisition(detPos); +} + +int slsDetectorUsers::stopAcquisition(int detPos) { + return myDetector->stopAcquisition(detPos); +} + +int slsDetectorUsers::sendSoftwareTrigger(int detPos) { + return myDetector->sendSoftwareTrigger(detPos); +} + +int slsDetectorUsers::enableCountRateCorrection(int i, int detPos){ + if (i == 0) + myDetector->setRateCorrection(0, detPos); + else + myDetector->setRateCorrection(-1, detPos); + + return myDetector->getRateCorrection(detPos); +} + +int slsDetectorUsers::setBitDepth(int i, int detPos){ + return myDetector->setDynamicRange(i, detPos); +} + +int slsDetectorUsers::setSettings(int isettings, int detPos){ + return myDetector->slsDetectorBase::setSettings(isettings, detPos); +} + +int slsDetectorUsers::getThresholdEnergy(int detPos){ + return myDetector->getThresholdEnergy(detPos); +} + +int slsDetectorUsers::setThresholdEnergy(int e_eV){ + return myDetector->setThresholdEnergy(e_eV); +} + +int slsDetectorUsers::setThresholdEnergy(int e_ev, int tb, int isettings, int detPos) { + return myDetector->setThresholdEnergy(e_ev, tb, + (isettings == -1) ? slsDetectorDefs::GET_SETTINGS : isettings, + detPos); +} + +double slsDetectorUsers::setExposureTime(double t, bool inseconds, int detPos){ + return myDetector->setExposureTime(t, inseconds, detPos); +} + +double slsDetectorUsers::setExposurePeriod(double t, bool inseconds, int detPos){ + return myDetector->setExposurePeriod(t, inseconds, detPos); +} + +double slsDetectorUsers::setDelayAfterTrigger(double t, bool inseconds, int detPos){ + return myDetector->setDelayAfterTrigger(t, inseconds, detPos); +} + +double slsDetectorUsers::setSubFrameExposureTime(double t, bool inseconds, int detPos){ + return myDetector->setSubFrameExposureTime(t, inseconds, detPos); +} + +double slsDetectorUsers::setSubFrameExposureDeadTime(double t, bool inseconds, int detPos){ + return myDetector->setSubFrameExposureDeadTime(t, inseconds, detPos); +} + +int64_t slsDetectorUsers::setNumberOfFrames(int64_t t, int detPos){ + return myDetector->setNumberOfFrames(t, detPos); +} + +int64_t slsDetectorUsers::setNumberOfCycles(int64_t t, int detPos){ + return myDetector->setNumberOfCycles(t, detPos); +} + +int64_t slsDetectorUsers::setNumberOfGates(int64_t t, int detPos){ + return myDetector->setNumberOfGates(t, detPos); +} + +int64_t slsDetectorUsers::setNumberOfStorageCells(int64_t t, int detPos) { + return myDetector->setNumberOfStorageCells(t, detPos); +} + +double slsDetectorUsers::getMeasuredPeriod(bool inseconds, int detPos) { + return myDetector->getMeasuredPeriod(inseconds, detPos); +} + +double slsDetectorUsers::getMeasuredSubFramePeriod(bool inseconds, int detPos) { + return myDetector->getMeasuredSubFramePeriod(inseconds, detPos); +} + +int slsDetectorUsers::setTimingMode(int pol, int detPos){ + return myDetector->setExternalCommunicationMode(slsDetectorDefs::externalCommunicationMode(pol), detPos); +} + +int slsDetectorUsers::setClockDivider(int value, int detPos) { + return myDetector->setSpeed(slsDetectorDefs::CLOCK_DIVIDER, value, detPos); +} + +int slsDetectorUsers::setParallelMode(int value, int detPos) { + if(value >= 0) + myDetector->setReadOutFlags(slsDetectorDefs::readOutFlags(value), detPos); + return myDetector->setReadOutFlags(-1, detPos); +} + +int slsDetectorUsers::setOverflowMode(int value, int detPos) { + if(value >= 0) { + if (value == 1) + myDetector->setReadOutFlags(slsDetectorDefs::SHOW_OVERFLOW, detPos); + else + myDetector->setReadOutFlags(slsDetectorDefs::NOOVERFLOW, detPos); + } + int ret = myDetector->setReadOutFlags(-1, detPos); + if (ret == -1) + return -1; + return ((ret & slsDetectorDefs::SHOW_OVERFLOW) ? 1 : 0); +} + +int slsDetectorUsers::setAllTrimbits(int val, int detPos) { + return myDetector->setAllTrimbits(val, detPos); +} + +int slsDetectorUsers::setDAC(int val, int index , int detPos) { + return myDetector->setDAC(val, dacsIndex(index), 0, detPos); +} + +int slsDetectorUsers::getADC(int index, int detPos) { + return myDetector->getADC(dacsIndex(index),detPos); +} + +int slsDetectorUsers::setTenGigabitEthernet(int i, int detPos) { + return myDetector->enableTenGigabitEthernet(i, detPos); +} + +int slsDetectorUsers::setStoragecellStart(int pos) { + return myDetector->setStoragecellStart(pos); +} + +int slsDetectorUsers::setHighVoltage(int i, int detPos) { + return myDetector->setDAC(i, slsDetectorDefs::HV_NEW, 0, detPos); +} + +int slsDetectorUsers::setFlowControl10G(int i, int detPos) { + return myDetector->setFlowControl10G(i, detPos); +} + + +/************************************************************************ + + RECEIVER FUNCTIONS + + *********************************************************************/ + + +int slsDetectorUsers::startReceiver(int detPos) { + return myDetector->startReceiver(detPos); +} + +int slsDetectorUsers::stopReceiver(int detPos) { + return myDetector->stopReceiver(detPos); +} + +int slsDetectorUsers::setReceiverSilentMode(int i, int detPos) { + return myDetector->setReceiverSilentMode(i, detPos); +} + +int slsDetectorUsers::resetFramesCaughtInReceiver(int detPos) { + return myDetector->resetFramesCaught(detPos); +} + +int slsDetectorUsers::setReceiverFifoDepth(int i, int detPos) { + return myDetector->setReceiverFifoDepth(i, detPos); +} + +string slsDetectorUsers::getFilePath(int detPos){ + return myDetector->getFilePath(detPos); +} + +string slsDetectorUsers::setFilePath(string s, int detPos){ + return myDetector->setFilePath(s, detPos); +} + +string slsDetectorUsers::getFileName(int detPos){ + return myDetector->getFileName(detPos); +} + +string slsDetectorUsers::setFileName(string s, int detPos){ + return myDetector->setFileName(s, detPos); +} + +int slsDetectorUsers::getFileIndex(int detPos){ + return (int)myDetector->getFileIndex(detPos); +} + +int slsDetectorUsers::setFileIndex(int i, int detPos){ + return (int)myDetector->setFileIndex(i, detPos); +} + +int slsDetectorUsers::enableWriteToFile(int enable, int detPos){ + return myDetector->enableWriteToFile(enable, detPos); +} + +int slsDetectorUsers::enableOverwriteFile(int enable, int detPos){ + return myDetector->overwriteFile(enable, detPos); +} + +int slsDetectorUsers::setReceiverStreamingFrequency(int freq, int detPos){ + return myDetector->setReceiverStreamingFrequency(freq, detPos); +} + +int slsDetectorUsers::setReceiverStreamingTimer(int time_in_ms, int detPos){ + return myDetector->setReceiverStreamingTimer(time_in_ms, detPos); } int slsDetectorUsers::enableDataStreamingToClient(int i){ return myDetector->enableDataStreamingToClient(i); } -int slsDetectorUsers::setReceiverDataStreamingOutPort(int i){ - return myDetector->setReceiverDataStreamingOutPort(i); +int slsDetectorUsers::enableDataStreamingFromReceiver(int i, int detPos){ + return myDetector->enableDataStreamingFromReceiver(i, detPos); } -int slsDetectorUsers::setClientDataStreamingInPort(int i){ - return myDetector->setClientDataStreamingInPort(i); +int slsDetectorUsers::setReceiverDataStreamingOutPort(int i, int detPos){ + return myDetector->setReceiverDataStreamingOutPort(i, detPos); } -string slsDetectorUsers::setReceiverDataStreamingOutIP(string ip){ - return myDetector->setReceiverDataStreamingOutIP(ip); +int slsDetectorUsers::setClientDataStreamingInPort(int i, int detPos){ + return myDetector->setClientDataStreamingInPort(i, detPos); } -string slsDetectorUsers::setClientDataStreamingInIP(string ip){ - return myDetector->setClientDataStreamingInIP(ip); +string slsDetectorUsers::setReceiverDataStreamingOutIP(string ip, int detPos){ + return myDetector->setReceiverDataStreamingOutIP(ip, detPos); } -int64_t slsDetectorUsers::getDetectorFirmwareVersion(){ - return myDetector->getDetectorFirmwareVersion(); +string slsDetectorUsers::setClientDataStreamingInIP(string ip, int detPos){ + return myDetector->setClientDataStreamingInIP(ip, detPos); } -int64_t slsDetectorUsers::getDetectorSerialNumber(){ - return myDetector->getDetectorSerialNumber(); +int slsDetectorUsers::enableGapPixels(int enable, int detPos) { + return myDetector->enableGapPixels(enable, detPos); } -int64_t slsDetectorUsers::getDetectorSoftwareVersion(){ - return myDetector->getDetectorSoftwareVersion(); +int slsDetectorUsers::setReceiverFramesDiscardPolicy(int f, int detPos) { + return myDetector->setReceiverFramesDiscardPolicy(slsDetectorDefs::frameDiscardPolicy(f), detPos); } -int64_t slsDetectorUsers::getThisSoftwareVersion(){ - return myDetector->getThisSoftwareVersion(); +int slsDetectorUsers::setReceiverPartialFramesPadding(int f, int detPos) { + return myDetector->setReceiverPartialFramesPadding(f, detPos); } -int slsDetectorUsers::enableGapPixels(int enable) { - return myDetector->enableGapPixels(enable); +int slsDetectorUsers::setReceiverFramesPerFile(int f, int detPos) { + return myDetector->setReceiverFramesPerFile(f, detPos); } -std::string slsDetectorUsers::setReceiverFramesDiscardPolicy(std::string f) { - return myDetector->getReceiverFrameDiscardPolicy( - myDetector->setReceiverFramesDiscardPolicy( - myDetector->getReceiverFrameDiscardPolicy(f))); + + +/************************************************************************ + + CALLBACKS & COMMAND LINE PARSING + + *********************************************************************/ + +void slsDetectorUsers::registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg) { + myDetector->registerDataCallback(userCallback,pArg); } -int slsDetectorUsers::setReceiverPartialFramesPadding(int f) { - return myDetector->setReceiverPartialFramesPadding(f); +void slsDetectorUsers::registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg) { + myDetector->registerAcquisitionFinishedCallback(func,pArg); } -int slsDetectorUsers::setReceiverFramesPerFile(int f) { - return myDetector->setReceiverFramesPerFile(f); +void slsDetectorUsers::registerMeasurementFinishedCallback(int( *func)(int,int, void*), void *pArg) { + myDetector->registerMeasurementFinishedCallback(func,pArg); } -int slsDetectorUsers::sendSoftwareTrigger() { - return myDetector->sendSoftwareTrigger(); -} - -double slsDetectorUsers::getMeasuredPeriod(bool inseconds, int imod) { - if(!inseconds) - return myDetector->getTimeLeft(slsReceiverDefs::MEASURED_PERIOD, imod); - - int64_t tms = myDetector->getTimeLeft(slsReceiverDefs::MEASURED_PERIOD, imod); - if (tms < 0) - return -1; - return ((1E-9) * (double)tms); -} - -double slsDetectorUsers::getMeasuredSubFramePeriod(bool inseconds, int imod) { - if(!inseconds) - return myDetector->getTimeLeft(slsReceiverDefs::MEASURED_SUBPERIOD, imod); - - int64_t tms = myDetector->getTimeLeft(slsReceiverDefs::MEASURED_SUBPERIOD, imod); - if (tms < 0) - return -1; - return ((1E-9) * (double)tms); -} - -void slsDetectorUsers::registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg){ - myDetector->registerDataCallback(userCallback,pArg); -} - -void slsDetectorUsers::registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg){ - myDetector->registerAcquisitionFinishedCallback(func,pArg); +void slsDetectorUsers::registerProgressCallback(int( *func)(double,void*), void *pArg) { + myDetector->registerProgressCallback(func,pArg); } string slsDetectorUsers::putCommand(int narg, char *args[], int pos){ @@ -292,114 +400,12 @@ string slsDetectorUsers::getCommand(int narg, char *args[], int pos){ } -int slsDetectorUsers::setClockDivider(int value) { - return myDetector->setClockDivider(value); -} -int slsDetectorUsers::setParallelMode(int value) { - if(value >= 0) - myDetector->setParallelMode(value); - return myDetector->getParallelMode(); -} -int slsDetectorUsers::setOverflowMode(int value) { - if(value >= 0) - myDetector->setOverflowMode(value); - return myDetector->getOverflowMode(); -} -int slsDetectorUsers::setAllTrimbits(int val, int id) { - return myDetector->setAllTrimbits(val, id); -} -int slsDetectorUsers::setDAC(string dac, int val, int id) { - int dacindex = myDetector->getDACIndex(dac); - if(dacindex == -1) return -9999; - return myDetector->setDACValue(val, dacindex, id); -} -int slsDetectorUsers::getADC(string adc, int id) { - int adcindex = myDetector->getADCIndex(adc); - if(adcindex == -1) return -9999; - return myDetector->getADCValue(adcindex, id); -} -int slsDetectorUsers::startReceiver() { - return myDetector->startReceiver(); -} -int slsDetectorUsers::stopReceiver() { - return myDetector->stopReceiver(); -} -int slsDetectorUsers::startAcquisition() { - return myDetector->startAcquisition(); -} -int slsDetectorUsers::stopAcquisition() { - return myDetector->stopAcquisition(); -} - -int slsDetectorUsers::setReceiverSilentMode(int i) { - return myDetector->setReceiverSilentMode(i); -} - -int slsDetectorUsers::setHighVoltage(int i) { - return myDetector->setHighVoltage(i); -} - -int slsDetectorUsers::resetFramesCaughtInReceiver() { - return myDetector->resetFramesCaught(); -} - -int slsDetectorUsers::setReceiverFifoDepth(int i) { - return myDetector->setReceiverFifoDepth(i); -} - -int slsDetectorUsers::setFlowControl10G(int i) { - return myDetector->setFlowControl10G(i); -} - -int slsDetectorUsers::setTenGigabitEthernet(int i) { - return myDetector->enableTenGigabitEthernet(i); -} - -int slsDetectorUsers::getNumberOfDetectors() { - return myDetector->getNumberOfDetectors(); -} - -double slsDetectorUsers::setSubFrameExposureTime(double t, bool inseconds, int imod){ - if(!inseconds) - return myDetector->setSubFrameExposureTime((int64_t)t,imod); - else { - // + 0.5 to round for precision lost from converting double to int64_t - int64_t tms = (int64_t)(t * (1E+9) + 0.5); - if (t < 0) tms = -1; - tms = myDetector->setSubFrameExposureTime(tms,imod); - if (tms < 0) - return -1; - return ((1E-9) * (double)tms); - } -} - -double slsDetectorUsers::setSubFrameExposureDeadTime(double t, bool inseconds, int imod){ - if(!inseconds) - return myDetector->setSubFrameDeadTime((int64_t)t,imod); - else { - // + 0.5 to round for precision lost from converting double to int64_t - int64_t tms = (int64_t)(t * (1E+9) + 0.5); - if (t < 0) tms = -1; - tms = myDetector->setSubFrameDeadTime(tms,imod); - if (tms < 0) - return -1; - return ((1E-9) * (double)tms); - } -} - -int64_t slsDetectorUsers::setNumberOfStorageCells(int64_t t, int imod) { - return myDetector->setTimer(slsReceiverDefs::STORAGE_CELL_NUMBER, t, imod); -} - -int slsDetectorUsers::setStoragecellStart(int pos) { - return myDetector->setStoragecellStart(pos); -} diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h index 1ca5e633b..f45319f72 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h @@ -29,17 +29,17 @@ class multiSlsDetectorCommand; \mainpage

API for SLS detectors data acquisition


-*/ + */ /** \mainpage - +

API for SLS detectors data acquisition


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 - + 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 @@ -55,693 +55,859 @@ slsReceiverUsers is a class to receive the data for detectors with external data detectorData is a structure containing the data and additional information which is used to return the data e.g. to the GUI for displaying them. - + You can find examples of how this classes can be instatiated in mainClient.cpp and mainReceiver.cpp +Different values from different detectors will give a -1 (return value is integer), a concatenation of all values (return value is a string) or a FAIL (return value is OK or FAIL) + \authors Anna Bergamaschi, Dhanya Thattil @version 3.0

Currently supported detectors

-\li GOTTHARD controls -\li GOTTHARD data receiver +\li GOTTHARD \li EIGER \li JUNGFRAU -*/ + */ /** @short The slsDetectorUsers class is a minimal interface class which should be instantiated by the users in their acquisition software (EPICS, spec etc.). More advanced configuration functions are not implemented and can be written in a configuration or parameters file that can be read/written. Class for detector functionalities to embed the detector controls in the users custom interface e.g. EPICS, Lima etc. -*/ + */ class slsDetectorUsers - { +{ - public: +public: - /** @short default constructor - * @param ret address of return value. It will be set to 0 for success, else 1 for failure - * @param id multi detector id - * in creating multidetector object - */ - slsDetectorUsers(int& ret, int id=0); - - /** @short virtual destructor */ - virtual ~slsDetectorUsers(); + /** + * Constructor + * @param ret address of return value. 0 for success or 1 for failure + * @param id multi detector id + */ + slsDetectorUsers(int& ret, int id = 0); - /** - @short useful to define subset of working functions - \returns "PSI" or "Dectris" - */ - std::string getDetectorDeveloper(); + /** + * Destructor + */ + virtual ~slsDetectorUsers(); - /** @short sets the onlineFlag - \param online can be: -1 returns wether the detector is in online (1) or offline (0) state; 0 detector in offline state; 1 detector in online state - \returns 0 (offline) or 1 (online) - */ - int setOnline(int const online=-1); + /** + * Returns the number of detectors in the multidetector structure + * @returns number of detectors + */ + int getNumberOfDetectors(); - /** @short sets the receivers onlineFlag - \param online can be: -1 returns wether the receiver is in online (1) or offline (0) state; 0 receiver in offline state; 1 receiver in online state - \returns 0 (offline) or 1 (online) - */ - int setReceiverOnline(int const online=-1); + /** + * Returns the maximum number of channels of all detectors + * (provided by user in config file using detsizechan command) + * Offsets are calculated according to these dimensions + * @param nx number of channels in horizontal + * @param ny number of channels in vertical + * @returns the maximum number of channels of all detectors + */ + int getMaximumDetectorSize(int &nx, int &ny); + /** + * Returns the size and offsets of detector/multi detector + * @param x horizontal position origin in channel number + * @param y vertical position origin in channel number + * @param nx number of channels in horiziontal + * @param ny number of channels in vertical + * @param detPos -1 for all detectors in list or specific detector position + * @returns the total number of channels of all sls detectors + */ + int getDetectorSize(int &x, int &y, int &nx, int &ny, int detPos = -1); - /** - @short start measurement and acquires - \returns OK/FAIL - */ - void startMeasurement(); + /** + * Gets detector type + * @param detPos -1 for all detectors in list or specific detector position + * @returns detector type (EIGER, JUNGFRAU, GOTTHARD) slsReceiverDefs + */ + std::string getDetectorType(int detPos = -1); - /** - @short stop measurement - \returns OK/FAIL - */ - int stopMeasurement(); - - /** - @short get run status - \returns status mask - */ - int getDetectorStatus(); + /** + * Sets/Checks the detectors in multi detector list to online/offline + * Must be called before communicating with detector + * @param online 1 to set detector online, 0 to set it offline, -1 to get + * @param detPos -1 for all detectors in list or specific detector position + * @returns (1)online/(0)offline status + */ + int setOnline(int const online = -1, int detPos = -1); - /** - @short returns the default output files path - */ - std::string getFilePath(); + /** + * Sets/Checks the receivers in multi detector list to online/offline + * Must be called before communicating with receiver + * @param online 1 to set receiver online, 0 to set it receiver, -1 to get + * @param detPos -1 for all detectors in list or specific detector position + * @returns (1)online/(0)offline status + */ + int setReceiverOnline(int const online = GET_ONLINE_FLAG, int detPos = -1); - /** - @short sets the default output files path - \param s file path - \returns file path - */ - std::string setFilePath(std::string s); + /** + * Load configuration from a configuration File (for one time detector setup) + * @param fname configuration file name + * @return OK or FAIL + */ + int readConfigurationFile(std::string const fname); - /** - @short - \returns the default output files root name - */ - std::string getFileName(); + /** + * Write current configuration to a file (for one time detector setup) + * @param fname configuration file name + * @returns OK or FAIL + */ + int writeConfigurationFile(std::string const fname); - /** - @short sets the default output files path - \param s file name - \returns the default output files root name - - */ - std::string setFileName(std::string s); - - /** - @short - \returns the default output file index - */ - int getFileIndex(); - - /** - @short sets the default output file index - \param i file index - \returns the default output file index - */ - int setFileIndex(int i); + /** + * Loads the detector setup from file (current measurement setup) + * @param fname file to read from + * @returns OK or FAIL + */ + int retrieveDetectorSetup(std::string const fname); - /** - @short enable/disable count rate corrections - \param i 0 disables, 1 enables with default values, -1 gets - \returns 0 if count corrections disabled, 1 if enabled - */ - int enableCountRateCorrection(int i=-1); + /** + * Saves the detector setup to file (currentmeasurement setup) + * @param fname file to write to + * @returns OK or FAIL + */ + int dumpDetectorSetup(std::string const fname); - /**Enable write file function included*/ + /** + * Get detector firmware version + * @param detPos -1 for all detectors in list or specific detector position + * @returns detector firmware version + */ + int64_t getDetectorFirmwareVersion(int detPos = -1); - int enableWriteToFile(int i=-1); + /** + * Get detector serial number or MAC + * @param detPos -1 for all detectors in list or specific detector position + * @returns detector serial number or MAC + */ + int64_t getDetectorSerialNumber(int detPos = -1); + /** + * Get on-board detector server software version + * @param detPos -1 for all detectors in list or specific detector position + * @returns on-board detector server software version + */ + int64_t getDetectorSoftwareVersion(int detPos = -1); - /** - @short gets detector size - \param x0 horizontal position origin in channel number - \param y0 vertical position origin in channel number - \param nx number of channels in horiziontal - \param ny number of channels in vertical - \returns OK/FAIL - */ - int getDetectorSize(int &x0, int &y0, int &nx, int &ny); - /** - @short gets the maximum detector size - \param nx number of channels in horiziontal - \param ny number of channels in vertical - \returns OK/FAIL - */ - int getMaximumDetectorSize(int &nx, int &ny); + /** + * (previously getThisSoftwareVersion) + * Get client software version + * @param detPos -1 for all detectors in list or specific detector position + * @returns client software version + */ + int64_t getClientSoftwareVersion(int detPos = -1); + /** + * Get receiver software version + * @param detPos -1 for all detectors in list or specific detector position + * @returns receiver software version + */ + int64_t getReceiverSoftwareVersion(int detPos = -1); - /** - @short set/get dynamic range - \param i dynamic range (-1 get) - \returns current dynamic range - */ - int setBitDepth(int i=-1); + /** + * Check Detector Version Compatibility + * @param detPos -1 for all detectors in list or specific detector position + * @returns true if compatibile, else false + */ + bool isDetectorVersionCompatible(int detPos = -1); + /** + * Check Receiver Version Compatibility + * @param detPos -1 for all detectors in list or specific detector position + * @returns true if compatibile, else false + */ + bool isReceiverVersionCompatible(int detPos = -1); - - /** - @short set detector settings - \param isettings settings index (-1 gets) - \returns current settings - */ - int setSettings(int isettings=-1); - - /** - @short get threshold energy - \returns current threshold value for imod in ev (-1 failed) - */ - int getThresholdEnergy(); + /** + * Performs a complete acquisition + * resets frames caught in receiver, starts receiver, starts detector, + * blocks till detector finished acquisition, stop receiver, increments file index, + * loops for measurements, calls required call backs. + * @returns OK or FAIL depending on if it already started + */ + int startMeasurement(); + /** + * Stop detector acquisition + * @param detPos -1 for all detectors in list or specific detector position + * @returns OK or FAIL + */ + int stopMeasurement(int detPos = -1); - /** - @short set threshold energy - \param e_eV threshold in eV - \returns current threshold value for imod in ev (-1 failed) - */ - int setThresholdEnergy(int e_eV); + /** + * Get Detector run status + * @param detPos -1 for all detectors in list or specific detector position + * @returns status + */ + int getDetectorStatus(int detPos = -1); - /** - @short set threshold energy with choice to load trimbits (eiger only) - \param e_ev threshold in ev - \param tb 1 loads trimbits, 0 does not load trimbits - \param isettings settings index (-1 uses current setting) - \param id module index (-1 for all) - \returns current threshold value in ev (-1 failed) - */ - int setThresholdEnergy(int e_ev, int tb, int isettings = -1, int id = -1); + /** + * (Advanced user, included in startMeasurement) + * Start detector acquisition (Non blocking) + * @param detPos -1 for all detectors in list or specific detector position + * @returns OK or FAIL if even one does not start properly + */ + int startAcquisition(int detPos = -1); + /** + * Stop detector acquisition (Same as stopMeasurement) + * @param detPos -1 for all detectors in list or specific detector position + * @returns OK or FAIL + */ + int stopAcquisition(int detPos = -1); - /** - @short set/get exposure time value - \param t time in sn (-1 gets) - \param inseconds true if the value is in s, else ns - \param imod module number (-1 for all) - \returns timer set value in ns, or s if specified - */ + /** + * (Only in non blocking acquire mode) + * Give an internal software trigger to the detector (Eiger) + * @param detPos -1 for all detectors in list or specific detector position + * @return OK or FAIL + */ + int sendSoftwareTrigger(int detPos = -1); - double setExposureTime(double t=-1, bool inseconds=false, int imod = -1); + /** + * Set Rate correction ( Eiger) + * @param t (1) enable rate correction to default dead time, + * (0) disable rate correction, (-1) gets + * @param detPos -1 for all detectors in list or specific detector position + * @returns rate correction tau + */ + int enableCountRateCorrection(int i = -1, int detPos = -1); - /** - @short set/get exposure period - \param t time in ns (-1 gets) - \param inseconds true if the value is in s, else ns - \param imod module number (-1 for all) - \returns timer set value in ns, or s if specified - */ - double setExposurePeriod(double t=-1, bool inseconds=false, int imod = -1); + /** + * Set/get dynamic range + * @param i dynamic range (-1 get) + * Options: Eiger(4, 8, 16, 32), Jungfrau(16), Gotthard(16) + * Background operation: + * (Eiger: If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to 1) + * @param detPos -1 for all detectors in list or specific detector position + * @returns current dynamic range + */ + int setBitDepth(int i = -1, int detPos = -1); - /** - @short set/get delay after trigger - \param t time in ns (-1 gets) - \param inseconds true if the value is in s, else ns - \param imod module number (-1 for all) - \returns timer set value in ns, or s if specified - */ - double setDelayAfterTrigger(double t=-1, bool inseconds=false, int imod = -1); + /** + * Set detector settings + * (Eiger only stores in shared memory. A get will overwrite this. One must use set threshold energy) + * @param isettings settings (-1 gets) + * Options: (slsDetectorDefs::detectorSettings) + * Eiger (STANDARD, HIGHGAIN, LOWGAIN, VERYHIGHGAIN, VERYLOWGAIN) + * Jungfrau (DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2) + * Gotthard (DYNAMICGAIN, HIGHGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN) + * @param detPos -1 for all detectors in list or specific detector position + * @returns current settings (can also return UNDEFINED, UNINITIALIZED) + */ + int setSettings(int isettings = -1, int detPos = -1); - /** - @short set/get number of gates - \param t number of gates (-1 gets) - \param imod module number (-1 for all) - \returns number of gates - */ - int64_t setNumberOfGates(int64_t t=-1, int imod = -1); - - /** - @short set/get number of frames i.e. number of exposure per trigger - \param t number of frames (-1 gets) - \param imod module number (-1 for all) - \returns number of frames - */ - int64_t setNumberOfFrames(int64_t t=-1, int imod = -1); + /** + * Get threshold energy (Eiger) + * @param detPos -1 for all detectors in list or specific detector position + * @returns current threshold value + */ + int getThresholdEnergy(int detPos = -1); - /** - @short set/get number of cycles i.e. number of triggers - \param t number of frames (-1 gets) - \param imod module number (-1 for all) - \returns number of frames - */ - int64_t setNumberOfCycles(int64_t t=-1, int imod = -1); + /** + * Set threshold energy (Eiger) + * @param e_eV threshold in eV + * @param tb 1 to load trimbits, 0 to exclude trimbits + * @param isettings settings (-1 current settings) + * @param detPos -1 for all detectors in list or specific detector position + * @returns current threshold value + */ + int setThresholdEnergy(int e_ev, int tb = 1, int isettings = -1, int detPos = -1); - /** - @short set/get the external communication mode - \param pol value to be set \sa getTimingMode - \returns current external communication mode - */ - int setTimingMode(int pol=-1); + /** + * Set/get exposure time + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns exposure time in ns, or s if specified + */ + double setExposureTime(double t = -1, bool inseconds = false, int detPos = -1); - /** - @short Reads the configuration file -- will contain all the informations needed for the configuration (e.g. for a PSI detector caldir, settingsdir, angconv, badchannels, hostname etc.) - \param fname file name - \returns OK or FAIL - */ - int readConfigurationFile(std::string const fname); + /** + * Set/get exposure period + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns exposure period in ns, or s if specified + */ + double setExposurePeriod(double t = -1, bool inseconds = false, int detPos = -1); + /** + * Set/get delay after trigger (Gotthard, Jungfrau(not for this release)) + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns delay after trigger in ns, or s if specified + */ + double setDelayAfterTrigger(double t = -1, bool inseconds = false, int detPos = -1); - /** - @short Reads the parameters from the detector and writes them to file - \param fname file to write to - \returns OK or FAIL - - */ - int dumpDetectorSetup(std::string const fname); - /** - @short Loads the detector setup from file - \param fname file to read from - \returns OK or FAIL - - */ - int retrieveDetectorSetup(std::string const fname); + /** + * (Advanced users) + * Set/get sub frame exposure time (Eiger in 32 bit mode) + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns sub frame exposure time in ns, or s if specified + */ + double setSubFrameExposureTime(double t = -1, bool inseconds = false, int detPos = -1); - /** - @short useful for data plotting etc. - \returns Mythen, Eiger, Gotthard etc. - */ - std::string getDetectorType(); + /** + * (Advanced users) + * Set/get sub frame dead time (Eiger in 32 bit mode) + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns sub frame dead time in ns, or s if specified + */ + double setSubFrameDeadTime(double t = -1, bool inseconds = false, int detPos = -1); - /** - @short sets the mode by which gui requests data from receiver - \param n is 0 for random requests for fast acquisitions and greater than 0 for nth read requests - \returns the mode set in the receiver - */ - int setReceiverMode(int n=-1); + /** + * Set/get number of frames + * @param t number of frames (-1 gets) + * @param detPos -1 for all detectors in list or specific detector position + * @returns number of frames + */ + int64_t setNumberOfFrames(int64_t t = -1, int detPos = -1); - /** - @short register calbback for accessing detector final data, also enables data streaming in client and receiver (if receiver exists) - \param userCallback function for plotting/analyzing the data. Its arguments are the data structure d and the frame number f, s is for subframe number for eiger for 32 bit mode - \param pArg argument - */ + /** + * Set/get number of cycles + * @param t number of cycles (-1 gets) + * @param detPos -1 for all detectors in list or specific detector position + * @returns number of cycles + */ + int64_t setNumberOfCycles(int64_t t = -1, int detPos = -1); - void registerDataCallback(int( *userCallback)(detectorData* d, int f, int s, void*), void *pArg); + /** + * Set/get number of gates (none of the detectors at the moment) + * @param t number of gates (-1 gets) + * @param detPos -1 for all detectors in list or specific detector position + * @returns number of gates + */ + int64_t setNumberOfGates(int64_t t = -1, int detPos = -1); + + /** + * Set/get number of additional storage cells (Jungfrau) + * @param t number of additional storage cells. Default is 0. (-1 gets) + * @param detPos -1 for all detectors in list or specific detector position + * @returns number of additional storage cells + */ + int64_t setNumberOfStorageCells(int64_t t = -1, int detPos = -1); + + /** + * Get measured period between previous two frames (EIGER) + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns sub frame dead time in ns, or s if specified + */ + double getMeasuredPeriod(bool inseconds = false, int detPos = -1); + + /** + * Get sub period between previous two sub frames in 32 bit mode (EIGER) + * @param t time (-1 gets) + * @param inseconds true if the value is in s, else ns + * @param detPos -1 for all detectors in list or specific detector position + * @returns sub frame dead time in ns, or s if specified + */ + double getMeasuredSubFramePeriod(bool inseconds = false, int detPos = -1); + + /** + * Set/get timing mode + * @param pol timing mode (-1 gets) + * Options (slsDetectorDefs::externalCommunicationMode) + * (Eiger: AUTO_TIMING, TRIGGER_EXPOSURE, BURST_TRIGGER, GATE_FIX_NUMBER) + * (Jungfrau: AUTO_TIMING, TRIGGER_EXPOSURE) + * (Gotthard: AUTO_TIMING, TRIGGER_EXPOSURE) + * @param detPos -1 for all detectors in list or specific detector position + * @returns current timing mode + */ + int setTimingMode(int pol = -1, int detPos = -1); + + /** + * Sets clock speed of the detector (Eiger, Jungfrau) + * (Jungfrau also writes adcphase to recommended default) + * (Eiger: 0(full speed not for 32 bit mode), 1 (half speed), 2(quarter speed)) + * (Jungfrau: 0(full speed not implemented), 1(half speed), 2(quarter speed)) + * @param detPos -1 for all detectors in list or specific detector position + * @returns clock speed + */ + int setClockDivider(int value, int detPos = -1); + + /** + * Set parallel readout mode (Eiger) + * @param value readout mode (-1 gets) + * Options: slsDetectorDefs::readOutFlags + * (PARALLEL, NONPARALLEL (Default), SAFE) + * @param detPos -1 for all detectors in list or specific detector position + * @returns mode register, + * result must be ANDED with PARALLEL/NONPARALLEL/SAFE to get mode + */ + int setParallelMode(int value, int detPos = -1); + + /** + * Set overflow readout mode (Eiger in 32 bit) + * @param value readout mode (-1 gets) + * Options: 1(SHOW_OVERFLOW), 0(NOOVERFLOW) (Default) + * @param detPos -1 for all detectors in list or specific detector position + * @returns 1 if overflow mode else 0 + */ + int setOverflowMode(int value, int detPos = -1); + + /** + * (Advanced user) + * Sets all the trimbits to a particular value (Eiger) + * @param val trimbit value + * @param detPos -1 for all detectors in list or specific detector position + * @returns OK or FAIL + */ + int setAllTrimbits(int val, int detPos = -1); + + /** + * (Advanced user) + * Set/get dacs value + * @param val value (in V) (-1 gets) + * @param index DAC index + * Options: slsDetectorDefs::dacIndex + * (Eiger: E_SvP up to IO_DELAY, THRESHOLD, HV_NEW) + * (Jungfrau: 0-7) + * (Gotthard: G_VREF_DS up to G_IB_TESTC, HV_NEW) + * @param detPos -1 for all detectors in list or specific detector position + * @returns current DAC value + */ + dacs_t setDAC(int val, int index , int detPos = -1); + + /** + * Get adc value + * @param index adc(DAC) index + * Options: slsDetectorDefs::dacIndex + * (Eiger: TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT upto TEMPERATURE_FPGA3) + * (Jungfrau: TEMPERATURE_FPGA) + * (Gotthard: TEMPERATURE_ADC, TEMPERATURE_FPGA) + * @param detPos -1 for all detectors in list or specific detector position + * @returns current adc value (temperature for eiger and jungfrau in millidegrees) + */ + dacs_t getADC(int index, int detPos = -1); + + /** + * Enable/disable or 10Gbe (Eiger) + * @param i is -1 to get, 0 to disable and 1 to enable + * @param detPos -1 for all detectors in list or specific detector position + * @returns if 10Gbe is enabled + */ + int setTenGigabitEthernet(int i = -1, int detPos = -1); + + /** + * Set storage cell that stores first acquisition of the series (Jungfrau) + * @param value storage cell index. Value can be 0 to 15. (-1 gets) + * @param detPos -1 for all detectors in list or specific detector position + * @returns the storage cell that stores the first acquisition of the series + */ + int setStoragecellStart(int pos=-1, int detPos = -1); + + /** + * set high voltage (Gotthard, Jungfrau, Eiger) + * @param i > 0 sets, 0 unsets, (-1 gets) + * (Eiger: ) + * (Jungfrau: ) + * (Gotthard: ) + * @returns high voltage + */ + int setHighVoltage(int i = -1, int detPos = -1); + + /** + * Set 10GbE Flow Control (Eiger) + * @param enable 1 to set, 0 to unset, -1 gets + * @param detPos -1 for all detectors in list or specific detector position + * @returns 10GbE flow Control + */ + int setFlowControl10G(int enable = -1, int detPos = -1); - /** Enable or disable streaming data from receiver (creates transmitting sockets) - * @param i 0 to disable 1 to enable -1 to only get the value - * @returns data streaming from receiver enable - */ - int enableDataStreamingFromReceiver(int i=-1); - /** - * Enable data streaming to client (creates receiving sockets) - * @param i 0 to disable, 1 to enable, -1 to get the value - * @returns data streaming to client enable - */ - int enableDataStreamingToClient(int i=-1); + /************************************************************************ - /** (for expert users) - * Set/Get receiver streaming out ZMQ port - * For multi modules, it calculates (increments), sets the ports and restarts the sockets - * @param i sets, -1 gets - * @returns receiver streaming out ZMQ port (if multiple, of first receiver socket) - */ - int setReceiverDataStreamingOutPort(int i=-1); + RECEIVER FUNCTIONS - /** (for expert users) - * Set/Get client streaming in ZMQ port - * For multi modules, it calculates (increments), sets the ports and restarts the sockets - * @param i sets, -1 gets - * @returns client streaming in ZMQ port (if multiple, of first client socket) - */ - int setClientDataStreamingInPort(int i=-1); + *********************************************************************/ - /** (for expert users) - * Set/Get receiver streaming out ZMQ IP - * By default, it is the IP of receiver hostname - * @param ip sets, empty std::string gets - * @returns receiver streaming out ZMQ IP - */ - std::string setReceiverDataStreamingOutIP(std::string ip=""); + /** + * (Advanced user, included in startMeasurement) + * Receiver starts listening to packets + * @param detPos -1 for all detectors in list or specific detector position + * @returns OK or FAIL + */ + int startReceiver(int detPos = -1); - /** (for expert users) - * Set/Get client streaming in ZMQ IP - * By default, it is the IP of receiver hostname - * @param ip sets, empty std::string gets - * @returns client streaming in ZMQ IP - */ - std::string setClientDataStreamingInIP(std::string ip=""); + /** + * (Advanced user, included in startMeasurement) + * Stops the listening mode of receiver + * @param detPos -1 for all detectors in list or specific detector position + * @returns OK or FAIL + */ + int stopReceiver(int detPos = -1); - /** - get get Detector Firmware Version - \returns id - */ - int64_t getDetectorFirmwareVersion(); + /** + * Set/get receiver silent mode + * @param i is -1 to get, 0 unsets silent mode, 1 sets silent mode + * @param detPos -1 for all detectors in list or specific detector position + * @returns the receiver silent mode enable + */ + int setReceiverSilentMode(int i = -1, int detPos = -1); - /** - get get Detector Serial Number - \returns id - */ - int64_t getDetectorSerialNumber(); + /** + * (Advanced user, included in startMeasurement) + * Resets framescaught in receiver + * Use this when using startAcquisition instead of acquire + * @param detPos -1 for all detectors in list or specific detector position + * @returns OK or FAIL + */ + int resetFramesCaughtInReceiver(int detPos = -1); - /** - get get Detector Software Version - \returns id - */ - int64_t getDetectorSoftwareVersion(); + /** + * (Advanced user) + * Set/get receiver fifo depth + * @param i is -1 to get, any other value to set the fifo deph + * @param detPos -1 for all detectors in list or specific detector position + * @returns the receiver fifo depth + */ + int setReceiverFifoDepth(int i = -1, int detPos = -1); - /** - get this Software Version - \returns id - */ - int64_t getThisSoftwareVersion(); + /** + * Returns output file directory + * @param detPos -1 for all detectors in list or specific detector position + * @returns output file directory + */ + std::string getFilePath(int detPos = -1); - /** - * Enable gap pixels, only for Eiger and for 8,16 and 32 bit mode. - * 4 bit mode gap pixels only in gui call back (registerDataCallback) - * @param enable 1 sets, 0 unsets, -1 gets - * @return gap pixel enable or -1 for error - */ - int enableGapPixels(int enable=-1); + /** + * Sets up the file directory + * @param detPos -1 for all detectors in list or specific detector position + * @param s file directory + * @returns file dir + */ + std::string setFilePath(std::string s, int detPos = -1); - /** - * Sets the frames discard policy in receiver - * frame discard policy options: - * @param f nodiscard (default),discardempty, discardpartial (fastest), get to get the value - * @returns f nodiscard (default),discardempty, discardpartial (fastest) - */ - std::string setReceiverFramesDiscardPolicy(std::string f="get"); + /** + * Returns file name prefix + * @param detPos -1 for all detectors in list or specific detector position + * @returns file name prefix + */ + std::string getFileName(int detPos = -1); - /** - * Sets the frame padding in receiver - * @param f 0 does not partial frames, 1 pads partial frames (-1 gets) - * @returns partial frames padding enable - */ - int setReceiverPartialFramesPadding(int f = -1); + /** + * Sets up the file name prefix + * @param detPos -1 for all detectors in list or specific detector position + * @param s file name prefix + * @returns file name prefix + */ + std::string setFileName(std::string s, int detPos = -1); - /** - * Sets the frames per file in receiver - * @param f frames per file, 0 is infinite ie. every frame in same file (-1 gets) - * @returns frames per file - */ - int setReceiverFramesPerFile(int f = -1); + /** + * Returns file index + * @param detPos -1 for all detectors in list or specific detector position + * @returns file index + */ + int getFileIndex(int detPos = -1); - /** - * Sends a software internal trigger (EIGER only) - * @returns 0 for success, 1 for fail - */ - int sendSoftwareTrigger(); + /** + * Sets up the file index + * @param i file index + * @param detPos -1 for all detectors in list or specific detector position + * @returns file index + */ + int setFileIndex(int i, int detPos = -1); - /** - * get measured period between previous two frames(EIGER only) - * @param inseconds true if the value is in s, else ns - * @param imod module number (-1 for all) - * @returns measured period - */ - double getMeasuredPeriod(bool inseconds=false, int imod = -1); + /** + * Sets/Gets receiver file write enable + * @param enable 1 or 0 to set/reset file write enable + * @param detPos -1 for all detectors in list or specific detector position + * @returns file write enable + */ + int enableWriteToFile(int enable = -1, int detPos = -1); - /** - * get measured sub period between previous two sub frames in 32 bit mode (EIGER only) - * @param inseconds true if the value is in s, else ns - * @param imod module number (-1 for all) - * @returns measured sub period - */ - double getMeasuredSubFramePeriod(bool inseconds=false, int imod = -1); + /** + * Sets/Gets file overwrite enable + * @param enable 1 or 0 to set/reset file overwrite enable + * @param detPos -1 for all detectors in list or specific detector position + * @returns file overwrite enable + */ + int enableOverwriteFile(int enable = -1, int detPos = -1); - /** - @short register calbback for accessing detector final data - \param func function to be called at the end of the acquisition. gets detector status and progress index as arguments - \param pArg argument - */ - void registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg); - - /** + /** + * (previously setReceiverMode) + * Sets the receiver streaming frequency + * @param freq nth frame streamed out, if 0, streamed out at a timer of 200 ms + * frames in between are not streamed + * @param detPos -1 for all detectors in list or specific detector position + * @returns receiver streaming frequency + */ + int setReceiverStreamingFrequency(int freq = -1, int detPos = -1); + + /** + * Sets the receiver streaming timer + * If receiver streaming frequency is 0, then this timer between each + * data stream is set. Default is 200 ms. + * @param time_in_ms timer between frames + * @param detPos -1 for all detectors in list or specific detector position + * @returns receiver streaming timer in ms + */ + int setReceiverStreamingTimer(int time_in_ms=500, int detPos = -1); + + /** + * Enable data streaming to client (data call back in client processing thread) + * @param enable 0 to disable, 1 to enable, -1 to get the value + * @returns data streaming to client enable + */ + int enableDataStreamingToClient(int enable=-1); + + /** + * Enable or disable streaming data from receiver (starts streaming threads) + * @param enable 0 to disable 1 to enable -1 to only get the value + * @param detPos -1 for all detectors in list or specific detector position + * @returns data streaming from receiver enable + */ + int enableDataStreamingFromReceiver(int enable=-1, int detPos = -1); + + /** + * (advanced users) + * Set/Get receiver streaming out ZMQ port and restarts receiver sockets + * @param i sets, -1 gets + * If detPos is -1(multi module), port calculated (increments) for all the individual detectors using i + * @param detPos -1 for all detectors in list or specific detector position + * @returns receiver streaming out ZMQ port (if multiple, of first receiver socket) + */ + int setReceiverDataStreamingOutPort(int i = -1, int detPos = -1); + + /** + * (advanced users) + * Set/Get client streaming in ZMQ port and restarts client sockets + * @param i sets, -1 gets + * If detPos is -1(multi module), port calculated (increments) for all the individual detectors using i + * @param detPos -1 for all detectors in list or specific detector position + * @returns receiver streaming out ZMQ port (if multiple, of first receiver socket) + */ + int setClientDataStreamingInPort(int i = -1, int detPos = -1); + + /** + * (advanced users) + * Set/Get receiver streaming out ZMQ IP and restarts receiver sockets + * @param i sets, empty string gets + * By default, it is the IP of receiver hostname + * @param detPos -1 for all detectors in list or specific detector position + * @returns receiver streaming out ZMQ IP + */ + std::string setReceiverDataStreamingOutIP(std::string ip="", int detPos = -1); + + /** + * (advanced users) + * Set/Get client streaming in ZMQ IP and restarts client sockets + * @param i sets, empty string gets + * By default, it is the IP of receiver hostname + * @param detPos -1 for all detectors in list or specific detector position + * @returns client streaming in ZMQ IP + */ + std::string setClientDataStreamingInIP(std::string ip="", int detPos = -1); + + /** + * Enable gap pixels in receiver (Eiger for 8,16 and 32 bit mode) + * 4 bit mode gap pixels only in data call back in client + * @param val 1 sets, 0 unsets, -1 gets + * @param detPos -1 for all detectors in list or specific detector position + * @returns gap pixel enable + */ + int enableGapPixels(int val=-1, int detPos = -1); + + /** + * Sets the frame discard policy in receiver + * @param f frame discard policy (-1 gets) + * Options: (slsDetectorDefs::frameDiscardPolicy) + * (NO_DISCARD (default), DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES (fastest)) + * @param detPos -1 for all detectors in list or specific detector position + * @returns current frame discard policy + */ + int setReceiverFramesDiscardPolicy(int f = -1, int detPos = -1); + + /** + * Sets the frame padding in receiver + * @param f 0 does not partial frames, 1 pads partial frames (-1 gets) + * @param detPos -1 for all detectors in list or specific detector position + * @returns partial frames padding enable + */ + int setReceiverPartialFramesPadding(int f = -1, int detPos = -1); + + /** + * Sets the frames per file in receiver + * @param f frames per file, 0 is infinite ie. every frame in same file (-1 gets) + * @param detPos -1 for all detectors in list or specific detector position + * @returns frames per file + */ + int setReceiverFramesPerFile(int f = -1, int detPos = -1); + + + + /************************************************************************ + + CALLBACKS & COMMAND LINE PARSING + + *********************************************************************/ + + /** + * register calbback for accessing detector final data in client, + * also enables data streaming in client and receiver + * @param userCallback function for plotting/analyzing the data. + * Its arguments are + * the data structure d and the frame number f, + * s is for subframe number for eiger for 32 bit mode + * @param pArg argument + */ + + void registerDataCallback(int( *userCallback)(detectorData* d, int f, int s, void*), void *pArg); + + /** + * register callback for accessing acquisition final data in client, + * @param func function to be called at the end of the acquisition. + * gets detector status and progress index as arguments + * @param pArg argument + */ + void registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg); + + /** + * register callback for accessing measurement final data in client, + * @param func function to be called at the end of the acquisition. + * gets detector status and progress index as arguments + * @param pArg argument + */ + void registerMeasurementFinishedCallback(int( *func)(int,int, void*), void *pArg); + + /** + * register callback for accessing detector progress in client, + * @param func function to be called at the end of the acquisition. + * gets detector status and progress index as arguments + * @param pArg argument + */ + void registerProgressCallback(int( *func)(double,void*), void *pArg); + + /** @short sets parameters in command interface http://www.psi.ch/detectors/UsersSupportEN/slsDetectorClientHowTo.pdf \param narg value to be set \param args value to be set \param pos position of detector in multislsdetector list \returns answer std::string - */ - std::string putCommand(int narg, char *args[], int pos=-1); + */ + std::string putCommand(int narg, char *args[], int pos=-1); - /** + /** @short gets parameters in command interface http://www.psi.ch/detectors/UsersSupportEN/slsDetectorClientHowTo.pdf \param narg value to be set \param args value to be set \param pos position of detector in multislsdetector list \returns answer std::string - */ - std::string getCommand(int narg, char *args[], int pos=-1); - - /************************************************************************ - - ADVANCED FUNCTIONS - - *********************************************************************/ - /** - @short sets clock divider of detector - \param value value to be set (-1 gets) - \returns speed of detector - */ - int setClockDivider(int value); - - /** - @short sets parallel mode - \param value 0 for non parallel, 1 for parallel, 2 for safe mode (-1 gets) - \returns gets parallel mode - */ - int setParallelMode(int value); - - /** - * @short show saturated for overflow in subframes in 32 bit mode (eiger only) - * \param value 0 for do not show saturatd, 1 for show saturated (-1 gets) - * \returns overflow mode enable in 32 bit mode - */ - int setOverflowMode(int value); - - /** - @short sets all trimbits to value (only available for eiger) - \param val value to be set (-1 gets) - \param id module index (-1 for all) - \returns value set - */ - int setAllTrimbits(int val, int id = -1); - - /** - @short set dac value - \param dac dac as std::string. can be vcmp_ll, vcmp_lr, vcmp_rl, vcmp_rr, vthreshold, vrf, vrs, vtr, vcall, vcp. others not supported - \param val value to be set (-1 gets) - \param id module index (-1 for all) - \returns dac value or -1 (if id=-1 & dac value is different for all modules) or -9999 if dac std::string does not match - */ - int setDAC(std::string dac, int val, int id = -1); - - /** - @short get adc value - \param adc adc as std::string. can be temp_fpga, temp_fpgaext, temp_10ge, temp_dcdc, temp_sodl, temp_sodr, temp_fpgafl, temp_fpgafr. others not supported - \param id module index (-1 for all) - \returns adc value in millidegree Celsius or -1 (if id=-1 & adc value is different for all modules) or -9999 if adc std::string does not match - */ - int getADC(std::string adc, int id = -1); - - /** - @short start receiver listening mode - \returns returns OK or FAIL - */ - int startReceiver(); - - /** - @short stop receiver listening mode - \returns returns OK or FAIL - */ - int stopReceiver(); - - /** - start detector real time acquisition in non blocking mode - does not include scans, scripts, incrementing file index, s - tarting/stopping receiver, resetting frames caught in receiver - \returns OK if all detectors are properly started, FAIL otherwise - */ - int startAcquisition(); - - /** - stop detector real time acquisition - \returns OK if all detectors are properly started, FAIL otherwise - */ - int stopAcquisition(); - - /** - * set receiver in silent mode - * @param i 1 sets, 0 unsets (-1 gets) - * @returns silent mode of receiver - */ - int setReceiverSilentMode(int i); - - /** - * set high voltage - * @param i > 0 sets, 0 unsets, (-1 gets) - * @returns high voltage - */ - int setHighVoltage(int i); - - /** - * reset frames caught in receiver - * should be called before startReceiver() - * @returns OK or FAIL - */ - int resetFramesCaughtInReceiver(); - - /** - * set receiver fifo depth - * @param i number of images in fifo depth (-1 gets) - * @returns receiver fifo depth - */ - int setReceiverFifoDepth(int i = -1); - - /** - * set flow control for 10Gbe (Eiger only) - * @param i 1 sets, 0 unsets (-1 gets) - * @return flow control enable for 10 Gbe - */ - int setFlowControl10G(int i = -1); - - /** - * enable/disable 10GbE (Eiger only) - * @param i 1 sets, 0 unsets (-1 gets) - * @return 10GbE enable - */ - int setTenGigabitEthernet(int i = -1); - - /** - * returns total number of detectors - * @returns the total number of detectors - */ - int getNumberOfDetectors(); - - /** - * Set sub frame exposure time (only for Eiger) - * @param t sub frame exposure time (-1 gets) - * @param inseconds true if the value is in s, else ns - * @param imod module number (-1 for all) - * @returns sub frame exposure time in ns, or s if specified - */ - double setSubFrameExposureTime(double t=-1, bool inseconds=false, int imod = -1); - - /** - * Set sub frame dead time (only for Eiger) - * Very advanced feature. Meant to be a constant in config file by an expert for each individual module - * @param t sub frame dead time (-1 gets) - * @param inseconds true if the value is in s, else ns - * @param imod module number (-1 for all) - * @returns sub frame dead time in ns, or s if specified - */ - double setSubFrameExposureDeadTime(double t=-1, bool inseconds=false, int imod = -1); - - /** - * set/get number of additional storage cells (Jungfrau) - * @param t number of additional storage cells. Default is 0. (-1 gets) - * @param imod module number (-1 for all) - * @returns number of additional storage cells - */ - int64_t setNumberOfStorageCells(int64_t t=-1, int imod = -1); - - /** - * Set storage cell that stores first acquisition of the series (Jungfrau) - * @param pos storage cell index. Value can be 0 to 15. Default is 15. (-1 gets) - * @returns the storage cell that stores the first acquisition of the series */ - int setStoragecellStart(int pos=-1); + std::string getCommand(int narg, char *args[], int pos=-1); - /************************************************************************ + + + /************************************************************************ STATIC FUNCTIONS - *********************************************************************/ + *********************************************************************/ - /** @short returns std::string from run status index + /** @short returns std::string from run status index \param s run status index \returns std::string error, waiting, running, data, finished or unknown when wrong index - */ - static std::string runStatusType(int s){ \ - switch (s) { \ - case 0: return std::string("idle"); \ - case 1: return std::string("error"); \ - case 2: return std::string("waiting"); \ - case 3: return std::string("finished"); \ - case 4: return std::string("data"); \ - case 5: return std::string("running"); \ - default: return std::string("unknown"); \ - }}; + */ + static std::string runStatusType(int s){ \ + switch (s) { \ + case 0: return std::string("idle"); \ + case 1: return std::string("error"); \ + case 2: return std::string("waiting"); \ + case 3: return std::string("finished"); \ + case 4: return std::string("data"); \ + case 5: return std::string("running"); \ + default: return std::string("unknown"); \ + }}; - /** @short returns detector settings std::string from index + /** @short returns detector settings std::string from index \param s can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain \returns setting index (-1 unknown std::string) - */ + */ - static int getDetectorSettings(std::string s){ \ - if (s=="standard") return 0; \ - if (s=="fast") return 1; \ - if (s=="highgain") return 2; \ - if (s=="dynamicgain") return 3; \ - if (s=="lowgain") return 4; \ - if (s=="mediumgain") return 5; \ - if (s=="veryhighgain") return 6; \ - return -1; }; + static int getDetectorSettings(std::string s){ \ + if (s=="standard") return 0; \ + if (s=="fast") return 1; \ + if (s=="highgain") return 2; \ + if (s=="dynamicgain") return 3; \ + if (s=="lowgain") return 4; \ + if (s=="mediumgain") return 5; \ + if (s=="veryhighgain") return 6; \ + return -1; }; - /** @short returns detector settings std::string from index + /** @short returns detector settings std::string from index \param s settings index \returns standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, undefined when wrong index - */ - static std::string getDetectorSettings(int s){\ - switch(s) { \ - case 0: return std::string("standard");\ - case 1: return std::string("fast");\ - case 2: return std::string("highgain");\ - case 3: return std::string("dynamicgain"); \ - case 4: return std::string("lowgain"); \ - case 5: return std::string("mediumgain"); \ - case 6: return std::string("veryhighgain"); \ - default: return std::string("undefined"); \ - }}; + */ + static std::string getDetectorSettings(int s){\ + switch(s) { \ + case 0: return std::string("standard");\ + case 1: return std::string("fast");\ + case 2: return std::string("highgain");\ + case 3: return std::string("dynamicgain"); \ + case 4: return std::string("lowgain"); \ + case 5: return std::string("mediumgain"); \ + case 6: return std::string("veryhighgain"); \ + default: return std::string("undefined"); \ + }}; - /** + /** @short returns external communication mode std::string from index \param f index for communication mode \returns auto, trigger, ro_trigger, gating, triggered_gating, unknown when wrong mode - */ + */ - static std::string getTimingMode(int f){ \ - switch(f) { \ - case 0: return std::string( "auto"); \ - case 1: return std::string("trigger"); \ - case 2: return std::string("ro_trigger"); \ - case 3: return std::string("gating"); \ - case 4: return std::string("triggered_gating"); \ - case 5: return std::string("burst_trigger"); \ - default: return std::string( "unknown"); \ - } }; + static std::string getTimingMode(int f){ \ + switch(f) { \ + case 0: return std::string( "auto"); \ + case 1: return std::string("trigger"); \ + case 2: return std::string("ro_trigger"); \ + case 3: return std::string("gating"); \ + case 4: return std::string("triggered_gating"); \ + case 5: return std::string("burst_trigger"); \ + default: return std::string( "unknown"); \ + } }; - /** + /** @short returns external communication mode std::string from index \param s index for communication mode \returns auto, trigger, ro_trigger, gating, triggered_gating, unknown when wrong mode - */ + */ - static int getTimingMode(std::string s){ \ - if (s== "auto") return 0; \ - if (s== "trigger") return 1; \ - if (s== "ro_trigger") return 2; \ - if (s== "gating") return 3; \ - if (s== "triggered_gating") return 4; \ - return -1; }; + static int getTimingMode(std::string s){ \ + if (s== "auto") return 0; \ + if (s== "trigger") return 1; \ + if (s== "ro_trigger") return 2; \ + if (s== "gating") return 3; \ + if (s== "triggered_gating") return 4; \ + return -1; }; - private: - multiSlsDetector *myDetector; - multiSlsDetectorCommand *myCmd; - }; +private: + multiSlsDetector *myDetector; + multiSlsDetectorCommand *myCmd; +}; #endif diff --git a/slsDetectorSoftware/slsDetectorClient/CMakeLists.txt b/slsDetectorSoftware/slsDetectorClient/CMakeLists.txt index 92296d9c3..6e9de0de3 100644 --- a/slsDetectorSoftware/slsDetectorClient/CMakeLists.txt +++ b/slsDetectorSoftware/slsDetectorClient/CMakeLists.txt @@ -6,10 +6,7 @@ include_directories( ../../commonfiles ../multiSlsDetector ../slsDetector - ../slsDetectorAnalysis ../slsReceiverInterface - ../usersFunctions - ../MySocketTCP ) add_executable(sls_detector_get diff --git a/slsDetectorSoftware/slsDetectorClient/Makefile b/slsDetectorSoftware/slsDetectorClient/Makefile index 51cb747fa..b278fe3ad 100644 --- a/slsDetectorSoftware/slsDetectorClient/Makefile +++ b/slsDetectorSoftware/slsDetectorClient/Makefile @@ -4,7 +4,7 @@ CFLAGS= -DC_ONLY #FLAGS=-DVERBOSE #ASM=$(shell echo "/lib/modules/`uname -r`/build/include") -INCLUDES?= -I../../commonfiles -I../slsDetector -I ../MySocketTCP -I../usersFunctions -I../multiSlsDetector -I../slsDetectorAnalysis -I../slsReceiverInterface -I ../../slsReceiverSoftware/include -I$(shell echo "/lib/modules/`uname -r`/build/include") +INCLUDES?= -I../../commonfiles -I../slsDetector -I../multiSlsDetector -I../slsReceiverInterface -I$(shell echo "/lib/modules/`uname -r`/build/include") DESTDIR ?= ../../bin BIN=$(DESTDIR) LIBS?= -L$(DESTDIR) -lSlsDetector