diff --git a/manual/manual-api/CMakeLists.txt b/manual/manual-api/CMakeLists.txt deleted file mode 100755 index 57cea1a04..000000000 --- a/manual/manual-api/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -set(SOURCES - mainReceiver.cpp -) - -include_directories( - ../../slsSupportLib/include - ../../slsReceiverSoftware/include - ../../build/bin - ../../slsdetectorSoftware/slsDetector -) - -add_executable(slsMultiReceiver - ${SOURCES} -) - -target_link_libraries(slsMultiReceiver - slsReceiverShared - pthread - ${ZeroMQ_LIBRARIES} - rt -) - -if (HDF5_FOUND) - target_link_libraries(slsMultiReceiver ${HDF5_LIBRARIES}) -endif () - - -set_target_properties(slsMultiReceiver PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin -) - -install(TARGETS slsMultiReceiver DESTINATION bin) diff --git a/manual/manual-api/Makefile b/manual/manual-api/Makefile deleted file mode 100755 index ee5550398..000000000 --- a/manual/manual-api/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -PKGDIR = ../.. -LIBDIR = $(PKGDIR)/bin -INCLUDES = -I . -I$(PKGDIR)/slsSupportLib/include -I$(LIBDIR) -I$(PKGDIR)/slsDetectorSoftware/slsDetector -I$(PKGDIR)/slsReceiversoftware/include -SRC_DET = mainClient.cpp -SRC_REC = mainReceiver.cpp -ZMQLIBDIR = $(PKGDIR)/slsSupportLib/include -LDFLAG_DET = -I. -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsDetector -L/usr/lib64/ -pthread -lrt -L$(ZMQLIBDIR) -Wl,-rpath=$(ZMQLIBDIR) -lzmq -LDFLAG_REC = -I. -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsReceiver -L/usr/lib64/ -pthread -lrt -L$(ZMQLIBDIR) -Wl,-rpath=$(ZMQLIBDIR) -lzmq -DESTDIR ?= ../docs - -HDF5 ?= no -HDF5_DIR ?= /opt/hdf5v1.10.0 - -ifeq ($(HDF5),yes) - LDFLAG_REC += -L$(HDF5_DIR)/lib -Wl,-rpath=$(HDF5_DIR)/lib -lhdf5 -lhdf5_cpp -lsz -lz -DHDF5C -endif - -all: docs detUser slsMultiReceiver -#all: docs - -docs: createdocs docspdf docshtml removedocs - -createdocs: slsDetectorUsers.doxy mainClient.cpp mainReceiver.cpp - doxygen slsDetectorUsers.doxy - -docspdf: - cd slsDetectorUsersDocs/latex && make - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - $(shell test -d $(DESTDIR)/pdf || mkdir -p $(DESTDIR)/pdf) - mv slsDetectorUsersDocs/latex/refman.pdf $(DESTDIR)/pdf/slsDetectorUsersDocs.pdf - -docshtml: - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - $(shell test -d $(DESTDIR)/html || mkdir -p $(DESTDIR)/html) - $(shell test -d $(DESTDIR)/html/slsDetectorUsersDocs && rm -r $(DESTDIR)/html/slsDetectorUsersDocs) - mv slsDetectorUsersDocs/html $(DESTDIR)/html/slsDetectorUsersDocs - -removedocs: - rm -rf slsDetectorUsersDocs; - -detUser:$(SRC_DET) - echo "creating client" - mkdir -p bin - g++ -o bin/detUser $(SRC_DET) $(INCLUDES) $(LDFLAG_DET) -lm -lstdc++ - -slsMultiReceiver:$(SRC_REC) - echo "creating receiver" - echo $LDFLAG_REC - mkdir -p bin - g++ -o bin/slsMultiReceiver $(SRC_REC) $(INCLUDES) $(LDFLAG_REC) -lm -lstdc++ - cp bin/slsMultiReceiver $(LIBDIR) - -clean: - echo "cleaning for manual-api" - rm -rf bin/detUser bin/slsMultiReceiver bin/detReceiver slsDetectorUsersDocs - rm -rf slsDetectorUsersDocs - rm -rf $(DESTDIR)/html/slsDetectorUsersDocs - rm -rf $(DESTDIR)/pdf/slsDetectorUsersDocs.pdf - rm -rf $(LIBDIR)/slsMultiReceiver - - - diff --git a/manual/manual-api/mainClient.cpp b/manual/manual-api/mainClient.cpp deleted file mode 100755 index 93b80f8ae..000000000 --- a/manual/manual-api/mainClient.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/** -\file mainClient.cpp - -This file is an example of how to implement the slsDetectorUsers class -You can compile it linking it to the slsDetector library - -g++ mainClient.cpp -L lib -lSlsDetector -L/usr/lib64/ -L lib2 -lzmq -pthread -lrt -lm -lstdc++ - -where, - -lib is the location of libSlsDetector.so - -lib2 is the location of the libzmq.a. -[ libzmq.a is required only when using data call backs and enabling data streaming from receiver to client. -It is linked in manual/manual-api from slsReceiverSoftware/include ] - - */ - -#include "slsDetectorUsers.h" -#include "detectorData.h" -#include -#include - -/** - * Data Call back function defined - * @param pData pointer to data structure received from the call back - * @param iframe frame number of data passed - * @param isubframe sub frame number of data passed ( only valid for EIGER in 32 bit mode) - * @param pArg pointer to object - * \returns integer that is currently ignored - */ -int dataCallback(detectorData *pData, int iframe, int isubframe, void *pArg) -{ - std::cout << " DataCallback:" - << "\n nx : " << pData->npoints - << "\n ny : " << pData->npy - << "\n Frame number : " << iframe << std::endl; -} - - -/** - * Example of a main program using the slsDetectorUsers class - * - * - Arguments are optional - * - argv[1] : Configuration File - * - argv[2] : Measurement Setup File - * - argv[3] : Detector Id (default is zero) - */ -int main(int argc, char **argv) { - /** - if specified, set ID from argv[3] */ - int id=0; - if (argc>=4) - id=atoi(argv[3]); - - - /** - slsDetectorUsers Object is instantiated with appropriate ID */ - int ret = 1; - slsDetectorUsers *pDetector = new slsDetectorUsers (ret, id); - if (ret == 1) { - std::cout << "Error: Could not instantiate slsDetectorUsers" << std::endl; - return EXIT_FAILURE; - } - - - /** - if specified, load configuration file (necessary at least the first time it is called to properly configure advanced settings in the shared memory) */ - if (argc>=2){ - pDetector->readConfigurationFile(argv[1]); - std::cout << "Detector configured" << std::endl; - } - - /** - set detector in shared memory online (in case no config file was used) */ - pDetector->setOnline(1); - - /** - set receiver in shared memory online (in case no config file was used) */ - pDetector->setReceiverOnline(1); - - /** - registering data callback */ - pDetector->registerDataCallback(&dataCallback, NULL); - - - /** - ensuring detector status is idle before starting acquisition. exiting if not idle */ - int status = pDetector->getDetectorStatus(); - if (status != 0){ - std::cout << "Detector not ready: " << slsDetectorUsers::runStatusType(status) << std::endl; - return 1; - } - - /** - if provided, load detector settings */ - if (argc>=3){ - pDetector->retrieveDetectorSetup(argv[2]); - std::cout << "Detector measurement set-up done" << std::endl; - } - - - /** - start measurement */ - pDetector->startMeasurement(); - std::cout << "measurement finished" << std::endl; - - /** - returning when acquisition is finished or data are avilable */ - - /** - delete slsDetectorUsers object */ - delete pDetector; - - return 0; -} - diff --git a/manual/manual-api/mainReceiver.cpp b/manual/manual-api/mainReceiver.cpp deleted file mode 100755 index 7762079e5..000000000 --- a/manual/manual-api/mainReceiver.cpp +++ /dev/null @@ -1,306 +0,0 @@ -/** - \file mainReceiver.cpp - -This file is an example of how to implement the slsReceiverUsers class -You can compile it linking it to the slsReceiver library - -g++ mainReceiver.cpp -L lib -lSlsReceiver -L/usr/lib64/ -L lib2 -lzmq -pthread -lrt -lm -lstdc++ - -where, - -lib is the location of lSlsReceiver.so - -lib2 is the location of the libzmq.a. -[ libzmq.a is required only when using data call backs and enabling data streaming from receiver to client. -It is linked in manual/manual-api from slsReceiverSoftware/include ] - - */ - -#include "sls_detector_defs.h" -#include "slsReceiverUsers.h" - -#include //SIGINT -#include //system -#include -#include -//#include "utilities.h" -//#include "logger.h" -#include -#include -#include //wait -#include //wait -#include //tid -#include //usleep -using namespace std; - - -/** Define Colors to print data call back in different colors for different recievers */ -#define PRINT_IN_COLOR(c,f, ...) printf ("\033[%dm" f RESET, 30 + c+1, ##__VA_ARGS__) - - -/** Variable is true to continue running, set to false upon interrupt */ -bool keeprunning; - -/** - * Control+C Interrupt Handler - * Sets the variable keeprunning to false, to let all the processes know to exit properly - */ -void sigInterruptHandler(int p){ - keeprunning = false; -} - -/** - * prints usage of this example program - */ -void printHelp() { - cprintf(RESET, "Usage:\n" - "./slsMultiReceiver(detReceiver) [start_tcp_port] [num_receivers] [1 for call back, 0 for none]\n\n"); - exit(EXIT_FAILURE); -} - -/** - * Start Acquisition Call back - * slsReceiver writes data if file write enabled. - * Users get data to write using call back if registerCallBackRawDataReady is registered. - * @param filepath file path - * @param filename file name - * @param fileindex file index - * @param datasize data size in bytes - * @param p pointer to object - * \returns ignored - */ -int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*p){ - cprintf(BLUE, "#### StartAcq: filepath:%s filename:%s fileindex:%llu datasize:%u ####\n", - filepath, filename, (long long unsigned int)fileindex, datasize); - - cprintf(BLUE, "--StartAcq: returning 0\n"); - return 0; -} - -/** - * Acquisition Finished Call back - * @param frames Number of frames caught - * @param p pointer to object - */ -void AcquisitionFinished(uint64_t frames, void*p){ - cprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",(long long unsigned int)frames); -} - - -/** - * Get Receiver Data Call back - * Prints in different colors(for each receiver process) the different headers for each image call back. - * @param metadata sls_receiver_header metadata - * @param datapointer pointer to data - * @param datasize data size in bytes. - * @param p pointer to object - */ -void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){ - slsDetectorDefs::sls_receiver_header* header = (slsDetectorDefs::sls_receiver_header*)metadata; - slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader; - - PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row, - "#### %d GetData: ####\n" - "frameNumber: %lu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %lu" - "\t\ttimestamp: %lu\t\tmodId: %u\t\t" - "row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u" - "\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u" - //"\t\tpacketsMask:%s" - "\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", - detectorHeader.row, (long unsigned int)detectorHeader.frameNumber, - detectorHeader.expLength, detectorHeader.packetNumber, (long unsigned int)detectorHeader.bunchId, - (long unsigned int)detectorHeader.timestamp, detectorHeader.modId, - detectorHeader.row, detectorHeader.column, detectorHeader.reserved, - detectorHeader.debug, detectorHeader.roundRNumber, - detectorHeader.detType, detectorHeader.version, - //header->packetsMask.to_string().c_str(), - ((uint8_t)(*((uint8_t*)(datapointer)))), datasize); -} - - - -/** - * Get Receiver Data Call back (modified) - * Prints in different colors(for each receiver process) the different headers for each image call back. - * @param metadata sls_receiver_header metadata - * @param datapointer pointer to data - * @param datasize data size in bytes. - * @param revDatasize new data size in bytes after the callback. - * This will be the size written/streamed. (only smaller value is allowed). - * @param p pointer to object - */ -void GetData(char* metadata, char* datapointer, uint32_t &revDatasize, void* p){ - slsDetectorDefs::sls_receiver_header* header = (slsDetectorDefs::sls_receiver_header*)metadata; - slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader; - - PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row, - "#### %d GetData: ####\n" - "frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu" - "\t\ttimestamp: %llu\t\tmodId: %u\t\t" - "row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u" - "\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u" - //"\t\tpacketsMask:%s" - "\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", - detectorHeader.row, (long long unsigned int)detectorHeader.frameNumber, - detectorHeader.expLength, detectorHeader.packetNumber, (long long unsigned int)detectorHeader.bunchId, - (long long unsigned int)detectorHeader.timestamp, detectorHeader.modId, - detectorHeader.row, detectorHeader.column, detectorHeader.reserved, - detectorHeader.debug, detectorHeader.roundRNumber, - detectorHeader.detType, detectorHeader.version, - //header->packetsMask.to_string().c_str(), - ((uint8_t)(*((uint8_t*)(datapointer)))), revDatasize); - - // if data is modified, eg ROI and size is reduced - revDatasize = 26000; -} - - - - -/** - * Example of main program using the slsReceiverUsers class - * - * - Defines in file for: - * - Default Number of receivers is 1 - * - Default Start TCP port is 1954 - */ -int main(int argc, char *argv[]) { - - /** - set default values */ - int numReceivers = 1; - int startTCPPort = 1954; - int withCallback = 0; - keeprunning = true; - - /** - get number of receivers and start tcp port from command line arguments */ - if ( (argc != 4) || (!sscanf(argv[1],"%d", &startTCPPort)) || (!sscanf(argv[2],"%d", &numReceivers)) || (!sscanf(argv[3],"%d", &withCallback)) ) - printHelp(); - cprintf(BLUE,"Parent Process Created [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); - cprintf(RESET, "Number of Receivers: %d\n", numReceivers); - cprintf(RESET, "Start TCP Port: %d\n", startTCPPort); - cprintf(RESET, "Callback Enable: %d\n", withCallback); - - - - /** - Catch signal SIGINT to close files and call destructors properly */ - struct sigaction sa; - sa.sa_flags=0; // no flags - sa.sa_handler=sigInterruptHandler; // handler function - sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler - if (sigaction(SIGINT, &sa, nullptr) == -1) { - cprintf(RED, "Could not set handler function for SIGINT\n"); - } - - /** - Ignore SIG_PIPE, prevents global signal handler, handle locally, - instead of a server crashing due to client crash when writing, it just gives error */ - struct sigaction asa; - asa.sa_flags=0; // no flags - asa.sa_handler=SIG_IGN; // handler function - sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler - if (sigaction(SIGPIPE, &asa, nullptr) == -1) { - cprintf(RED, "Could not set handler function for SIGPIPE\n"); - } - - - /** - loop over number of receivers */ - for (int i = 0; i < numReceivers; ++i) { - - /** - fork process to create child process */ - pid_t pid = fork(); - - /** - if fork failed, raise SIGINT and properly destroy all child processes */ - if (pid < 0) { - cprintf(RED,"fork() failed. Killing all the receiver objects\n"); - raise(SIGINT); - } - - /** - if child process */ - else if (pid == 0) { - cprintf(BLUE,"Child process %d [ Tid: %ld ]\n", i, (long)syscall(SYS_gettid)); - - char temp[10]; - sprintf(temp,"%d",startTCPPort + i); - char* args[] = {(char*)"ignored", (char*)"--rx_tcpport", temp}; - int ret = slsDetectorDefs::OK; - /** - create slsReceiverUsers object with appropriate arguments */ - slsReceiverUsers *receiver = new slsReceiverUsers(3, args, ret); - if(ret==slsDetectorDefs::FAIL){ - delete receiver; - exit(EXIT_FAILURE); - } - - - /** - register callbacks. remember to set file write enable to 0 (using the client) - if we should not write files and you will write data using the callbacks */ - if (withCallback) { - - /** - Call back for start acquisition */ - cprintf(BLUE, "Registering StartAcq()\n"); - receiver->registerCallBackStartAcquisition(StartAcq, nullptr); - - /** - Call back for acquisition finished */ - cprintf(BLUE, "Registering AcquisitionFinished()\n"); - receiver->registerCallBackAcquisitionFinished(AcquisitionFinished, nullptr); - - /* - Call back for raw data */ - cprintf(BLUE, "Registering GetData() \n"); - if (withCallback == 1) receiver->registerCallBackRawDataReady(GetData,nullptr); - else if (withCallback == 2) receiver->registerCallBackRawDataModifyReady(GetData,nullptr); - } - - - - /** - start tcp server thread */ - if (receiver->start() == slsDetectorDefs::FAIL){ - delete receiver; - cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); - exit(EXIT_FAILURE); - } - - /** - as long as keeprunning is true (changes with Ctrl+C) */ - while(keeprunning) - pause(); - /** - interrupt caught, delete slsReceiverUsers object and exit */ - delete receiver; - cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); - exit(EXIT_SUCCESS); - break; - } - } - - /** - Parent process ignores SIGINT (exits only when all child process exits) */ - sa.sa_flags=0; // no flags - sa.sa_handler=SIG_IGN; // handler function - sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler - if (sigaction(SIGINT, &sa, nullptr) == -1) { - cprintf(RED, "Could not set handler function for SIGINT\n"); - } - - - /** - Print Ready and Instructions how to exit */ - cout << "Ready ... " << endl; - cprintf(RESET, "\n[ Press \'Ctrl+c\' to exit ]\n"); - - /** - Parent process waits for all child processes to exit */ - for(;;) { - pid_t childPid = waitpid (-1, nullptr, 0); - - // no child closed - if (childPid == -1) { - if (errno == ECHILD) { - cprintf(GREEN,"All Child Processes have been closed\n"); - break; - } else { - cprintf(RED, "Unexpected error from waitpid(): (%s)\n",strerror(errno)); - break; - } - } - - //child closed - cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long int) childPid); - } - - cout << "Goodbye!" << endl; - return 0; -} - diff --git a/manual/manual-api/slsDetectorUsers.doxy b/manual/manual-api/slsDetectorUsers.doxy deleted file mode 100755 index 936d20ce2..000000000 --- a/manual/manual-api/slsDetectorUsers.doxy +++ /dev/null @@ -1,91 +0,0 @@ -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - - - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = YES - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -INTERNAL_DOCS = NO - -SHOW_INCLUDE_FILES = YES - -SHOW_FILES = YES - -SHOW_NAMESPACES = NO - -COMPACT_LATEX = YES - -PAPER_TYPE = a4 - -PDF_HYPERLINKS = YES - -USE_PDFLATEX = YES - -LATEX_HIDE_INDICES = YES - -SOURCE_BROWSER = YES - -PREDEFINED = __cplusplus - -INPUT = ../../slsDetectorSoftware/slsDetector/slsDetectorUsers.h \ - ../../slDetectorSoftware/slsDetectorAnalysis/detectorData.h \ - ../../slsReceiverSoftware/include/slsReceiverUsers.h \ - mainClient.cpp \ - mainReceiver.cpp - -OUTPUT_DIRECTORY = slsDetectorUsersDocs