diff --git a/manual/docs/html/slsDetectorUsersDocs/annotated.html b/manual/docs/html/slsDetectorUsersDocs/annotated.html index c0b34a75e..7a8b23cf9 100644 --- a/manual/docs/html/slsDetectorUsersDocs/annotated.html +++ b/manual/docs/html/slsDetectorUsersDocs/annotated.html @@ -63,7 +63,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/classdetectorData-members.html b/manual/docs/html/slsDetectorUsersDocs/classdetectorData-members.html index 9326ff34c..b08f2c8ad 100644 --- a/manual/docs/html/slsDetectorUsersDocs/classdetectorData-members.html +++ b/manual/docs/html/slsDetectorUsersDocs/classdetectorData-members.html @@ -68,7 +68,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/classdetectorData.html b/manual/docs/html/slsDetectorUsersDocs/classdetectorData.html index 3c4b1f1d5..4096ea366 100644 --- a/manual/docs/html/slsDetectorUsersDocs/classdetectorData.html +++ b/manual/docs/html/slsDetectorUsersDocs/classdetectorData.html @@ -309,7 +309,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/classes.html b/manual/docs/html/slsDetectorUsersDocs/classes.html index db6b2a530..702ff7d5a 100644 --- a/manual/docs/html/slsDetectorUsersDocs/classes.html +++ b/manual/docs/html/slsDetectorUsersDocs/classes.html @@ -63,7 +63,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/classslsDetectorUsers-members.html b/manual/docs/html/slsDetectorUsersDocs/classslsDetectorUsers-members.html index 0952ed000..cab44147b 100644 --- a/manual/docs/html/slsDetectorUsersDocs/classslsDetectorUsers-members.html +++ b/manual/docs/html/slsDetectorUsersDocs/classslsDetectorUsers-members.html @@ -128,7 +128,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/classslsDetectorUsers.html b/manual/docs/html/slsDetectorUsersDocs/classslsDetectorUsers.html index 637fa2177..dada4a79d 100644 --- a/manual/docs/html/slsDetectorUsersDocs/classslsDetectorUsers.html +++ b/manual/docs/html/slsDetectorUsersDocs/classslsDetectorUsers.html @@ -2199,7 +2199,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/classslsReceiverUsers-members.html b/manual/docs/html/slsDetectorUsersDocs/classslsReceiverUsers-members.html index c263db6a6..84f543ded 100644 --- a/manual/docs/html/slsDetectorUsersDocs/classslsReceiverUsers-members.html +++ b/manual/docs/html/slsDetectorUsersDocs/classslsReceiverUsers-members.html @@ -68,7 +68,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/classslsReceiverUsers.html b/manual/docs/html/slsDetectorUsersDocs/classslsReceiverUsers.html index 3a2f63702..e6f2b7a21 100644 --- a/manual/docs/html/slsDetectorUsersDocs/classslsReceiverUsers.html +++ b/manual/docs/html/slsDetectorUsersDocs/classslsReceiverUsers.html @@ -325,7 +325,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/detectorData_8h.html b/manual/docs/html/slsDetectorUsersDocs/detectorData_8h.html index 060f58370..265034ae2 100644 --- a/manual/docs/html/slsDetectorUsersDocs/detectorData_8h.html +++ b/manual/docs/html/slsDetectorUsersDocs/detectorData_8h.html @@ -67,7 +67,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/detectorData_8h_source.html b/manual/docs/html/slsDetectorUsersDocs/detectorData_8h_source.html index 1fb581eb0..bd4daff6a 100644 --- a/manual/docs/html/slsDetectorUsersDocs/detectorData_8h_source.html +++ b/manual/docs/html/slsDetectorUsersDocs/detectorData_8h_source.html @@ -80,7 +80,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/files.html b/manual/docs/html/slsDetectorUsersDocs/files.html index 372023850..db4fe7c4d 100644 --- a/manual/docs/html/slsDetectorUsersDocs/files.html +++ b/manual/docs/html/slsDetectorUsersDocs/files.html @@ -65,7 +65,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/functions.html b/manual/docs/html/slsDetectorUsersDocs/functions.html index 517e056a4..fc2a4c95a 100644 --- a/manual/docs/html/slsDetectorUsersDocs/functions.html +++ b/manual/docs/html/slsDetectorUsersDocs/functions.html @@ -384,7 +384,7 @@ Here is a list of all class members with links to the classes they belong to: -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/functions_func.html b/manual/docs/html/slsDetectorUsersDocs/functions_func.html index e5b49c509..778afa2a2 100644 --- a/manual/docs/html/slsDetectorUsersDocs/functions_func.html +++ b/manual/docs/html/slsDetectorUsersDocs/functions_func.html @@ -350,7 +350,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/functions_vars.html b/manual/docs/html/slsDetectorUsersDocs/functions_vars.html index b48255b0f..a7d65ddeb 100644 --- a/manual/docs/html/slsDetectorUsersDocs/functions_vars.html +++ b/manual/docs/html/slsDetectorUsersDocs/functions_vars.html @@ -91,7 +91,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/globals.html b/manual/docs/html/slsDetectorUsersDocs/globals.html index 421f75d16..6896a85ca 100644 --- a/manual/docs/html/slsDetectorUsersDocs/globals.html +++ b/manual/docs/html/slsDetectorUsersDocs/globals.html @@ -108,7 +108,7 @@ Here is a list of all file members with links to the files they belong to:
    -
    Generated on 24 Aug 2017 by  +
    Generated on 25 Aug 2017 by  doxygen 1.6.1
    diff --git a/manual/docs/html/slsDetectorUsersDocs/globals_defs.html b/manual/docs/html/slsDetectorUsersDocs/globals_defs.html index d34505585..f56efcc2e 100644 --- a/manual/docs/html/slsDetectorUsersDocs/globals_defs.html +++ b/manual/docs/html/slsDetectorUsersDocs/globals_defs.html @@ -77,7 +77,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
    Generated on 24 Aug 2017 by  +
    Generated on 25 Aug 2017 by  doxygen 1.6.1
    diff --git a/manual/docs/html/slsDetectorUsersDocs/globals_func.html b/manual/docs/html/slsDetectorUsersDocs/globals_func.html index f84c2991c..3e3eec5b4 100644 --- a/manual/docs/html/slsDetectorUsersDocs/globals_func.html +++ b/manual/docs/html/slsDetectorUsersDocs/globals_func.html @@ -90,7 +90,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
    Generated on 24 Aug 2017 by  +
    Generated on 25 Aug 2017 by  doxygen 1.6.1
    diff --git a/manual/docs/html/slsDetectorUsersDocs/globals_vars.html b/manual/docs/html/slsDetectorUsersDocs/globals_vars.html index 94c25d663..e6fce0580 100644 --- a/manual/docs/html/slsDetectorUsersDocs/globals_vars.html +++ b/manual/docs/html/slsDetectorUsersDocs/globals_vars.html @@ -77,7 +77,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
    Generated on 24 Aug 2017 by  +
    Generated on 25 Aug 2017 by  doxygen 1.6.1
    diff --git a/manual/docs/html/slsDetectorUsersDocs/index.html b/manual/docs/html/slsDetectorUsersDocs/index.html index 010ae01ed..4003524b8 100644 --- a/manual/docs/html/slsDetectorUsersDocs/index.html +++ b/manual/docs/html/slsDetectorUsersDocs/index.html @@ -79,7 +79,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
    Generated on 24 Aug 2017 by  +
    Generated on 25 Aug 2017 by  doxygen 1.6.1
    diff --git a/manual/docs/html/slsDetectorUsersDocs/mainClient_8cpp.html b/manual/docs/html/slsDetectorUsersDocs/mainClient_8cpp.html index 5bd425b95..3addd8929 100644 --- a/manual/docs/html/slsDetectorUsersDocs/mainClient_8cpp.html +++ b/manual/docs/html/slsDetectorUsersDocs/mainClient_8cpp.html @@ -43,9 +43,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    -

    mainClient.cpp File Reference

    #include <iostream>
    -#include "slsDetectorUsers.h"
    +

    mainClient.cpp File Reference

    #include "slsDetectorUsers.h"
    #include "detectorData.h"
    +#include <iostream>
    #include <cstdlib>

    Go to the source code of this file.

    @@ -56,8 +56,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

    Detailed Description

    This file is an example of how to implement the slsDetectorUsers class You can compile it linking it to the slsDetector library

    -

    gcc mainClient.cpp -L lib -l SlsDetector -lm -pthread

    -

    where lib is the location of libSlsDetector.so gcc mainClient.cpp -L . -l SlsDetector -lm -pthread -o users

    +

    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 ]

    Definition in file mainClient.cpp.


    Function Documentation

    @@ -97,9 +99,19 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    -

    Definition of the data callback which simply prints out the number of points received and teh frame number

    +

    Data Call back function defined

    +
    Parameters:
    + + + + + +
    pData pointer to data structure received from the call back
    iframe frame number of data passed
    isubframe sub frame number of data passed ( only valid for EIGER in 32 bit mode)
    pArg pointer to object
    +
    +
    +
    Returns:
    integer that is currently ignored
    -

    Definition at line 20 of file mainClient.cpp.

    +

    Definition at line 32 of file mainClient.cpp.

    @@ -127,19 +139,49 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    -

    example of a main program using the slsDetectorUsers class

    +

    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)
      • +
      +
    • +
    -

    if specified, argv[3] is used as detector ID (default is 0)

    -

    slsDetectorUsers is instantiated

    -

    if specified, argv[1] is used as detector config file (necessary at least the first time it is called to properly configure advanced settings in the shared memory)

    -

    registering data callback

    -

    checking detector status and exiting if not idle

    -

    load detector settings

    -

    start measurement

    -

    returning when acquisition is finished or data are avilable

    +

      +
    • if specified, set ID from argv[3]
    • +
    + +
      +
    • if specified, load configuration file (necessary at least the first time it is called to properly configure advanced settings in the shared memory)
    • +
    +
      +
    • registering data callback
    • +
    +
      +
    • if receiver exists, enable data streaming from receiver to get the data
    • +
    +
      +
    • ensuring detector status is idle before starting acquisition. exiting if not idle
    • +
    +
      +
    • if provided, load detector settings
    • +
    +
      +
    • start measurement
    • +
    +
      +
    • returning when acquisition is finished or data are avilable
    • +
    +

    -

    Definition at line 27 of file mainClient.cpp.

    +

    Definition at line 46 of file mainClient.cpp.

    @@ -158,7 +200,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
    Generated on 24 Aug 2017 by  +
    Generated on 25 Aug 2017 by  doxygen 1.6.1
    diff --git a/manual/docs/html/slsDetectorUsersDocs/mainClient_8cpp_source.html b/manual/docs/html/slsDetectorUsersDocs/mainClient_8cpp_source.html index df818934b..6f3e78e9d 100644 --- a/manual/docs/html/slsDetectorUsersDocs/mainClient_8cpp_source.html +++ b/manual/docs/html/slsDetectorUsersDocs/mainClient_8cpp_source.html @@ -42,59 +42,56 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

mainClient.cpp

Go to the documentation of this file.
00001 
-00014 #include <iostream>  
-00015 #include "slsDetectorUsers.h"
-00016 #include "detectorData.h"
-00017 #include <cstdlib>
-00018 
-00020 int dataCallback(detectorData *pData, int iframe, int isubframe, void *pArg)
-00021 {
-00022   std::cout  << "dataCallback: " << pData->npoints  << " "  << pData->npy  << "Frame number: " << iframe << std::endl; 
-00023 }
-00024 
-00025 
-00027 int main(int argc,  char **argv) {
-00028   int id=0;
-00030   if (argc>=4)
-00031     id=atoi(argv[3]);
-00032   
-00033 
-00034 
-00036   slsDetectorUsers *pDetector = new  slsDetectorUsers (id); 
+00019 #include "slsDetectorUsers.h"
+00020 #include "detectorData.h"
+00021 #include <iostream>
+00022 #include <cstdlib>
+00023 
+00032 int dataCallback(detectorData *pData, int iframe, int isubframe, void *pArg)
+00033 {
+00034         std::cout  << "dataCallback: " << pData->npoints  << " "  << pData->npy  << "Frame number: " << iframe << std::endl;
+00035 }
+00036 
 00037 
-00038   
-00040   if (argc>=2){
-00041     pDetector->readConfigurationFile(argv[1]);
-00042     cout<<"Detector configured" << endl;
-00043   }
-00045     pDetector->registerDataCallback(&dataCallback, NULL);
-00046     pDetector->enableDataStreamingFromReceiver(1);
-00047 
-00049    int status = pDetector->getDetectorStatus(); 
-00050     if (status  !=  0){
-00051       std::cout << "Detector not ready: " << slsDetectorUsers::runStatusType(status) << std::endl; 
-00052       return 1; 
-00053     }
-00054 
-00056     if (argc>=3){
-00057         pDetector->retrieveDetectorSetup(argv[2]);
-00058         cout<<"Detector measurement set-up done" << endl;
-00059     }
-00061      pDetector->startMeasurement(); 
-00062      cout<<"started measurement"<<endl;
-00063      
-00064     /* while (1) {
-00065        usleep(100000); 
-00066        status = pDetector->getDetectorStatus(); 
-00067         if (status  == 0 || status == 1|| status == 3)
-00068           break; 
-00069      }*/
-00070      cout<<"measurement finished"<<endl;
-00074      delete pDetector; 
-00075      
-00076      return 0; 
-00077 }
-00078 
+00046 int main(int argc,  char **argv) {
+00048         int id=0;
+00049         if (argc>=4)
+00050                 id=atoi(argv[3]);
+00051 
+00052 
+00054         slsDetectorUsers *pDetector = new  slsDetectorUsers (id);
+00055 
+00056 
+00058         if (argc>=2){
+00059                 pDetector->readConfigurationFile(argv[1]);
+00060                 std::cout << "Detector configured" << std::endl;
+00061         }
+00062 
+00063 
+00065         pDetector->registerDataCallback(&dataCallback, NULL);
+00067         pDetector->enableDataStreamingFromReceiver(1);
+00068 
+00069 
+00071         int status = pDetector->getDetectorStatus();
+00072         if (status  !=  0){
+00073                 std::cout << "Detector not ready: " << slsDetectorUsers::runStatusType(status) << std::endl;
+00074                 return 1;
+00075         }
+00076 
+00078         if (argc>=3){
+00079                 pDetector->retrieveDetectorSetup(argv[2]);
+00080                 std::cout << "Detector measurement set-up done" << std::endl;
+00081         }
+00082 
+00083 
+00085         pDetector->startMeasurement();
+00086         std::cout << "measurement finished" << std::endl;
+00087 
+00091         delete pDetector;
+00092 
+00093         return 0;
+00094 }
+00095 
 
-
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp.html b/manual/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp.html index 42e986e6b..404f70ea1 100644 --- a/manual/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp.html +++ b/manual/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp.html @@ -71,6 +71,14 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); bool keeprunning int numrunning +

Detailed Description

+

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 ]

+ +

Definition in file mainReceiver.cpp.


Define Documentation

@@ -83,7 +91,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
-

Definition at line 21 of file mainReceiver.cpp.

+

Definition at line 34 of file mainReceiver.cpp.

@@ -112,8 +120,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
+

Define Colors to print data call back in different colors for different recievers

-

Definition at line 23 of file mainReceiver.cpp.

+

Definition at line 38 of file mainReceiver.cpp.

@@ -127,8 +136,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
+

Define TCP Port of First Receiver, others are incremented by 1

-

Definition at line 22 of file mainReceiver.cpp.

+

Definition at line 36 of file mainReceiver.cpp.

@@ -157,8 +167,16 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
+

Acquisition Finished Call back

+
Parameters:
+ + + +
frames Number of frames caught
p pointer to object
+
+
-

Definition at line 52 of file mainReceiver.cpp.

+

Definition at line 93 of file mainReceiver.cpp.

@@ -270,8 +288,30 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
+

Get Receiver Data Call back Prints in different colors(for each receiver process) the different headers for each image call back.

+
Parameters:
+ + + + + + + + + + + + + + + + + +
frameNumber frame number
expLength real time exposure length (in 100ns) or sub frame number (Eiger 32 bit mode only)
packetNumber number of packets caught for this frame
bunchId bunch id from beamline
timestamp time stamp in 10MHz clock (not implemented for most)
modId module id (not implemented for most)
xCoord x coordinates (detector id in 1D)
yCoord y coordinates (not implemented)
zCoord z coordinates (not implemented)
debug debug values if any
roundRNumber (not implemented)
detType detector type see :: detectorType
version version of standard header (structure format)
datapointer pointer to data
datasize data size in bytes
p pointer to object
+
+
-

Definition at line 57 of file mainReceiver.cpp.

+

Definition at line 117 of file mainReceiver.cpp.

@@ -299,14 +339,69 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
+

Example of main program using the slsReceiverUsers class

+
    +
  • Defines in file for:
      +
    • Default Number of receivers is 1
    • +
    • Default Start TCP port is 1954
    • +
    +
  • +
-

Call back for start acquisition callback arguments are filepath filename fileindex datasize

-

return value is insignificant at the moment we write depending on file write enable users get data to write depending on call backs registered

-

Call back for acquisition finished callback argument is total frames caught

-

Call back for raw data args to raw data ready callback are frameNumber is the frame number expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) packetNumber is the packet number bunchId is the bunch id from beamline timestamp is the time stamp with 10 MHz clock modId is the unique module id (unique even for left, right, top, bottom) xCoord is the x coordinate in the complete detector system yCoord is the y coordinate in the complete detector system zCoord is the z coordinate in the complete detector system debug is for debugging purposes roundRNumber is the round robin set number detType is the detector type see :: detectorType version is the version number of this structure format dataPointer is the pointer to the data dataSize in bytes is the size of the data in bytes

+

    +
  • set default values: child process pid values to -1, keeprunning to true, numrunning to 0
  • +
+
    +
  • Catch signal SIGINT to close files and call destructors properly
  • +
+
    +
  • wait for all the SIGCHILD signals and decrease numrunningeach time a child process exits
  • +
+
    +
  • loop over number of receivers
  • +
+
    +
  • fork process to create child process
  • +
+
    +
  • if fork failed, raise SIGINT and kill all receiver objects
  • +
+
    +
  • if child process
  • +
+
    +
  • create slsReceiverUsers object with appropriate arguments (START_TCP_PORT incrementing by 1
  • +
+
    +
  • 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
  • +
+
    +
  • Call back for start acquisition
  • +
+
    +
  • Call back for acquisition finished
  • +
+
    +
  • start tcp server thread
  • +
+
    +
  • as long as keeprunning is true, usleep for a second
  • +
+ +
    +
  • parent process, increment number of running processes
  • +
+
    +
  • Print Ready and Instructions how to exit
  • +
+
    +
  • Parent process waits for all child processes to exit by sleeping till numrunning is 0
  • +

-

Definition at line 74 of file mainReceiver.cpp.

+

Definition at line 140 of file mainReceiver.cpp.

@@ -325,8 +420,15 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
+

Child Exit Signal Interrupt Handler When a child process exits, this function is called, blocks until all child processes exit & decreases the variable indicating number of running processes

+
Parameters:
+ + +
sig signal enum
+
+
-

Definition at line 32 of file mainReceiver.cpp.

+

Definition at line 55 of file mainReceiver.cpp.

@@ -345,8 +447,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
+

Control+C Interrupt Handler Sets the variable keeprunning to false, to let all the processes know to exit properly

-

Definition at line 39 of file mainReceiver.cpp.

+

Definition at line 65 of file mainReceiver.cpp.

@@ -392,8 +495,20 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
+

Start Acquisition Call back slsReceiver writes data if file write enabled. Users get data to write using call back if registerCallBackRawDataReady is registered.

+
Parameters:
+ + + + + + +
filepath file path
filename file name
fileindex file index
datasize data size in bytes
p pointer to object
+
+
+
Returns:
ignored
-

Definition at line 43 of file mainReceiver.cpp.

+

Definition at line 80 of file mainReceiver.cpp.

@@ -409,7 +524,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
-

Definition at line 26 of file mainReceiver.cpp.

+

Definition at line 41 of file mainReceiver.cpp.

@@ -423,8 +538,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
+

Variable is true to continue running, set to false upon interrupt

-

Definition at line 27 of file mainReceiver.cpp.

+

Definition at line 43 of file mainReceiver.cpp.

@@ -438,8 +554,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
+

Variable indicating number of child processes running

-

Definition at line 28 of file mainReceiver.cpp.

+

Definition at line 45 of file mainReceiver.cpp.

@@ -458,7 +575,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
Generated on 24 Aug 2017 by  +
Generated on 25 Aug 2017 by  doxygen 1.6.1
diff --git a/manual/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp_source.html b/manual/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp_source.html index 012a40f2b..1fb253592 100644 --- a/manual/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp_source.html +++ b/manual/docs/html/slsDetectorUsersDocs/mainReceiver_8cpp_source.html @@ -41,175 +41,154 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
  • File Members
  • -

    mainReceiver.cpp

    Go to the documentation of this file.
    00001 /* A simple server in the internet domain using TCP
    -00002    The port number is passed as an argument */
    -00003 
    -00004 #include "sls_receiver_defs.h"
    -00005 #include "slsReceiverUsers.h"
    -00006 
    -00007 #include <iostream>
    -00008 #include <string.h>
    -00009 #include <signal.h>     //SIGINT
    -00010 #include <cstdlib>              //system
    -00011 
    -00012 //#include "utilities.h"
    -00013 //#include "logger.h"
    -00014 
    -00015 #include <sys/types.h>  //wait
    -00016 #include <sys/wait.h>   //wait
    -00017 
    -00018 #include <string>
    -00019 using namespace std;
    -00020 
    -00021 #define NUM_RECEIVERS   1
    -00022 #define START_TCP_PORT  1954
    -00023 #define PRINT_IN_COLOR(c,f, ...)        printf ("\033[%dm" f RESET, 30 + c+1, ##__VA_ARGS__)
    -00024 
    -00025 
    -00026 pid_t childPid[NUM_RECEIVERS];
    -00027 bool keeprunning;
    -00028 int numrunning;
    -00029 
    -00030 
    -00031 
    -00032 void sigChildExitedHandler(int sig) {
    -00033   pid_t pid = wait(NULL);
    -00034   bprintf(GRAY, "\nChild Process Pid %d exited.\n", pid);
    -00035   numrunning--;
    -00036 }
    -00037 
    -00038 
    -00039 void sigInterruptHandler(int p){
    -00040         keeprunning = false;
    -00041 }
    -00042 
    -00043 int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*p){
    -00044   bprintf(BLUE, "#### StartAcq:  filepath:%s  filename:%s fileindex:%llu  datasize:%u ####\n",
    -00045          filepath, filename, fileindex, datasize);
    +

    mainReceiver.cpp

    Go to the documentation of this file.
    00001 
    +00019 #include "sls_receiver_defs.h"
    +00020 #include "slsReceiverUsers.h"
    +00021 
    +00022 #include <iostream>
    +00023 #include <string.h>
    +00024 #include <signal.h>     //SIGINT
    +00025 #include <cstdlib>              //system
    +00026 //#include "utilities.h"
    +00027 //#include "logger.h"
    +00028 #include <sys/types.h>  //wait
    +00029 #include <sys/wait.h>   //wait
    +00030 #include <string>
    +00031 using namespace std;
    +00032 
    +00033 /* Define Number of receivers */
    +00034 #define NUM_RECEIVERS   1
    +00035 
    +00036 #define START_TCP_PORT  1954
    +00037 
    +00038 #define PRINT_IN_COLOR(c,f, ...)        printf ("\033[%dm" f RESET, 30 + c+1, ##__VA_ARGS__)
    +00039 
    +00040 /* List of process IDs of all child receiver processes */
    +00041 pid_t childPid[NUM_RECEIVERS];
    +00043 bool keeprunning;
    +00045 int numrunning;
     00046 
    -00047   bprintf(BLUE, "--StartAcq: returning 0\n");
    -00048   return 0;
    -00049 }
    -00050 
    -00051 
    -00052 void AcquisitionFinished(uint64_t frames, void*p){
    -00053   bprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",frames);
    -00054 }
    -00055 
    -00056 
    -00057 void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp,
    -00058                 uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version,
    -00059                 char* datapointer, uint32_t datasize, void* p){
    +00047 
    +00055 void sigChildExitedHandler(int sig) {
    +00056         pid_t pid = wait(NULL);
    +00057         bprintf(GRAY, "\nChild Process Pid %d exited.\n", pid);
    +00058         numrunning--;
    +00059 }
     00060 
    -00061         PRINT_IN_COLOR (xCoord,
    -00062                         "#### %d GetData: ####\n"
    -00063                         "frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu\t\ttimestamp: %llu\t\tmodId: %u\t\t"
    -00064                         "xCoord: %u\t\tyCoord: %u\t\tzCoord: %u\t\tdebug: %u\t\troundRNumber: %u\t\tdetType: %u\t\t"
    -00065                         "version: %u\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
    -00066                         xCoord, frameNumber, expLength, packetNumber, bunchId, timestamp, modId,
    -00067                         xCoord, yCoord, zCoord, debug, roundRNumber, detType, version,
    -00068                         ((uint8_t)(*((uint8_t*)(datapointer)))), datasize);
    -00069 
    -00070 }
    -00071 
    -00072 
    -00073 
    -00074 int main(int argc, char *argv[]) {
    -00075 
    -00076         // set default child process pid values
    -00077         for (int i = 0; i < NUM_RECEIVERS; ++i)
    -00078                 childPid[i] = -1;
    -00079 
    -00080         keeprunning = true;
    -00081         numrunning = 0;
    -00082 
    -00083         // Catch signal SIGINT to close files and call destructors properly
    -00084         struct sigaction sa;
    -00085         sa.sa_flags=0;                                                  // no flags
    -00086         sa.sa_handler=sigInterruptHandler;              // handler function
    -00087         sigemptyset(&sa.sa_mask);                               // dont block additional signals during invocation of handler
    -00088         if (sigaction(SIGINT, &sa, NULL) == -1) {
    -00089                 bprintf(RED, "Could not set handler function for SIGINT\n");
    -00090         }
    -00091 
    -00092         // wait for all the SIGCHILD signals
    -00093         struct sigaction asa;
    -00094         asa.sa_flags=0;                                                 // no flags
    -00095         asa.sa_handler=sigChildExitedHandler;   // handler function
    -00096         sigemptyset(&asa.sa_mask);                              // dont block additional signals during invocation of handler
    -00097         if (sigaction(SIGCHLD, &asa, NULL) == -1) {
    -00098                 bprintf(RED, "Could not set handler function for SICHILD\n");
    -00099         }
    -00100 
    -00101 
    -00102         int narg= 3;
    -00103 
    -00104         for (int i = 0; i < NUM_RECEIVERS; ++i) {
    -00105 
    -00106                 childPid[i] = fork();
    -00107 
    -00108                 // fork failed
    -00109                 if (childPid[i] < 0) {
    -00110                         bprintf(RED,"fork() failed. Killing all the receiver objects\n");
    -00111                         raise(SIGINT);
    -00112                 }
    -00113 
    -00114                 // child process
    -00115                 else if (childPid[i] == 0) {
    -00116                         bprintf(BLUE,"Starting Receiver %d with pid %ld\n", i, (long)getpid());
    -00117 
    -00118                         char temp[10];
    -00119                         sprintf(temp,"%d",START_TCP_PORT + i);
    -00120                         char* args[] = {(char*)"ignored", (char*)"--rx_tcpport", temp};
    -00121                         int ret = slsReceiverDefs::OK;
    -00122                         slsReceiverUsers *receiver = new slsReceiverUsers(narg, args, ret);
    -00123                         if(ret==slsReceiverDefs::FAIL){
    -00124                                 delete receiver;
    -00125                                 exit(EXIT_FAILURE);
    -00126                         }
    -00127 
    -00128                         //register callbacks
    -00129                         //remember to set file write enable to 0 (using the client) if we should not write files and
    -00130                         //you will write data using the callbacks
    +00065 void sigInterruptHandler(int p){
    +00066         keeprunning = false;
    +00067 }
    +00068 
    +00080 int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*p){
    +00081         bprintf(BLUE, "#### StartAcq:  filepath:%s  filename:%s fileindex:%llu  datasize:%u ####\n",
    +00082                         filepath, filename, fileindex, datasize);
    +00083 
    +00084         bprintf(BLUE, "--StartAcq: returning 0\n");
    +00085         return 0;
    +00086 }
    +00087 
    +00093 void AcquisitionFinished(uint64_t frames, void*p){
    +00094         bprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",frames);
    +00095 }
    +00096 
    +00117 void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp,
    +00118                 uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version,
    +00119                 char* datapointer, uint32_t datasize, void* p){
    +00120 
    +00121         PRINT_IN_COLOR (xCoord,
    +00122                         "#### %d GetData: ####\n"
    +00123                         "frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu\t\ttimestamp: %llu\t\tmodId: %u\t\t"
    +00124                         "xCoord: %u\t\tyCoord: %u\t\tzCoord: %u\t\tdebug: %u\t\troundRNumber: %u\t\tdetType: %u\t\t"
    +00125                         "version: %u\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
    +00126                         xCoord, frameNumber, expLength, packetNumber, bunchId, timestamp, modId,
    +00127                         xCoord, yCoord, zCoord, debug, roundRNumber, detType, version,
    +00128                         ((uint8_t)(*((uint8_t*)(datapointer)))), datasize);
    +00129 
    +00130 }
     00131 
    -00144                         bprintf(BLUE, "Registering      StartAcq()\n");
    -00145                         receiver->registerCallBackStartAcquisition(StartAcq, NULL);
    -00146 
    -00152                         bprintf(BLUE, "Registering      AcquisitionFinished()\n");
    -00153                         receiver->registerCallBackAcquisitionFinished(AcquisitionFinished, NULL);
    -00154 
    -00174                         bprintf(BLUE, "Registering     GetData() \n");
    -00175                         receiver->registerCallBackRawDataReady(GetData,NULL);
    -00176 
    -00177 
    -00178                         //start tcp server thread
    -00179                         if (receiver->start() == slsReceiverDefs::FAIL){
    -00180                                 delete receiver;
    -00181                                 exit(EXIT_FAILURE);
    -00182                         }
    -00183 
    -00184                         while(keeprunning)
    -00185                                 usleep(1 * 1000 * 1000);
    -00186                         delete receiver;
    -00187                         exit(EXIT_SUCCESS);
    -00188                 }
    -00189 
    -00190                 // parent process
    -00191                 else
    -00192                         numrunning++;
    -00193 
    -00194         }
    -00195 
    -00196         cout << "Ready ... " << endl;
    -00197         bprintf(GRAY, "\n[ Press \'Ctrl+c\' to exit ]\n");
    -00198 
    -00199         // wait for all child processes to exit
    -00200         while(numrunning)
    -00201                 usleep(1 * 1000 * 1000);
    -00202         cout << "Goodbye!" << endl;
    -00203         return 0;
    -00204 }
    +00132 
    +00140 int main(int argc, char *argv[]) {
    +00141 
    +00143         for (int i = 0; i < NUM_RECEIVERS; ++i)
    +00144                 childPid[i] = -1;
    +00145         keeprunning = true;
    +00146         numrunning = 0;
    +00147 
    +00149         struct sigaction sa;
    +00150         sa.sa_flags=0;                                                  // no flags
    +00151         sa.sa_handler=sigInterruptHandler;              // handler function
    +00152         sigemptyset(&sa.sa_mask);                               // dont block additional signals during invocation of handler
    +00153         if (sigaction(SIGINT, &sa, NULL) == -1) {
    +00154                 bprintf(RED, "Could not set handler function for SIGINT\n");
    +00155         }
    +00156 
    +00158         struct sigaction asa;
    +00159         asa.sa_flags=0;                                                 // no flags
    +00160         asa.sa_handler=sigChildExitedHandler;   // handler function
    +00161         sigemptyset(&asa.sa_mask);                              // dont block additional signals during invocation of handler
    +00162         if (sigaction(SIGCHLD, &asa, NULL) == -1) {
    +00163                 bprintf(RED, "Could not set handler function for SICHILD\n");
    +00164         }
    +00165 
    +00166 
    +00168         for (int i = 0; i < NUM_RECEIVERS; ++i) {
    +00169 
    +00171                 childPid[i] = fork();
    +00172 
    +00174                 if (childPid[i] < 0) {
    +00175                         bprintf(RED,"fork() failed. Killing all the receiver objects\n");
    +00176                         raise(SIGINT);
    +00177                 }
    +00178 
    +00180                 else if (childPid[i] == 0) {
    +00181                         bprintf(BLUE,"Starting Receiver %d with pid %ld\n", i, (long)getpid());
    +00182 
    +00183                         char temp[10];
    +00184                         sprintf(temp,"%d",START_TCP_PORT + i);
    +00185                         char* args[] = {(char*)"ignored", (char*)"--rx_tcpport", temp};
    +00186                         int ret = slsReceiverDefs::OK;
    +00189                         slsReceiverUsers *receiver = new slsReceiverUsers(3, args, ret);
    +00190                         if(ret==slsReceiverDefs::FAIL){
    +00191                                 delete receiver;
    +00192                                 exit(EXIT_FAILURE);
    +00193                         }
    +00194 
    +00199                         bprintf(BLUE, "Registering      StartAcq()\n");
    +00200                         receiver->registerCallBackStartAcquisition(StartAcq, NULL);
    +00201 
    +00203                         bprintf(BLUE, "Registering      AcquisitionFinished()\n");
    +00204                         receiver->registerCallBackAcquisitionFinished(AcquisitionFinished, NULL);
     00205 
    +00206                         /*      - Call back for raw data */
    +00207                         bprintf(BLUE, "Registering     GetData() \n");
    +00208                         receiver->registerCallBackRawDataReady(GetData,NULL);
    +00209 
    +00210 
    +00212                         if (receiver->start() == slsReceiverDefs::FAIL){
    +00213                                 delete receiver;
    +00214                                 exit(EXIT_FAILURE);
    +00215                         }
    +00216 
    +00218                         while(keeprunning)
    +00219                                 usleep(1 * 1000 * 1000);
    +00221                         delete receiver;
    +00222                         exit(EXIT_SUCCESS);
    +00223                 }
    +00224 
    +00226                 else
    +00227                         numrunning++;
    +00228 
    +00229         }
    +00230 
    +00232         cout << "Ready ... " << endl;
    +00233         bprintf(GRAY, "\n[ Press \'Ctrl+c\' to exit ]\n");
    +00234 
    +00236         while(numrunning)
    +00237                 usleep(1 * 1000 * 1000);
    +00238         cout << "Goodbye!" << endl;
    +00239         return 0;
    +00240 }
    +00241 
     
    -
    Generated on 24 Aug 2017 by  +
    Generated on 25 Aug 2017 by  doxygen 1.6.1
    diff --git a/manual/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h.html b/manual/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h.html index 18727cab7..22c666731 100644 --- a/manual/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h.html +++ b/manual/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h.html @@ -67,7 +67,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
    Generated on 24 Aug 2017 by  +
    Generated on 25 Aug 2017 by  doxygen 1.6.1
    diff --git a/manual/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h_source.html b/manual/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h_source.html index 1288f178d..143ad4af7 100644 --- a/manual/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h_source.html +++ b/manual/docs/html/slsDetectorUsersDocs/slsDetectorUsers_8h_source.html @@ -290,7 +290,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
    Generated on 24 Aug 2017 by  +
    Generated on 25 Aug 2017 by  doxygen 1.6.1
    diff --git a/manual/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h.html b/manual/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h.html index 0d2cc569f..35d2e0117 100644 --- a/manual/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h.html +++ b/manual/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h.html @@ -67,7 +67,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
    Generated on 24 Aug 2017 by  +
    Generated on 25 Aug 2017 by  doxygen 1.6.1
    diff --git a/manual/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h_source.html b/manual/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h_source.html index c225fec34..96e847b59 100644 --- a/manual/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h_source.html +++ b/manual/docs/html/slsDetectorUsersDocs/slsReceiverUsers_8h_source.html @@ -93,7 +93,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); -
    Generated on 24 Aug 2017 by  +
    Generated on 25 Aug 2017 by  doxygen 1.6.1
    diff --git a/manual/docs/pdf/slsDetectorUsersDocs.pdf b/manual/docs/pdf/slsDetectorUsersDocs.pdf index d60b06cea..da24449fe 100644 Binary files a/manual/docs/pdf/slsDetectorUsersDocs.pdf and b/manual/docs/pdf/slsDetectorUsersDocs.pdf differ diff --git a/manual/manual-api/detReceiver b/manual/manual-api/detReceiver index 7d4c3c69e..6aabca4cc 100755 Binary files a/manual/manual-api/detReceiver and b/manual/manual-api/detReceiver differ diff --git a/manual/manual-api/detUser b/manual/manual-api/detUser index 280e1a4bb..09b9b5571 100755 Binary files a/manual/manual-api/detUser and b/manual/manual-api/detUser differ diff --git a/manual/manual-api/mainClient.cpp b/manual/manual-api/mainClient.cpp index 70d75199a..2927eb1d1 100644 --- a/manual/manual-api/mainClient.cpp +++ b/manual/manual-api/mainClient.cpp @@ -4,75 +4,92 @@ This file is an example of how to implement the slsDetectorUsers class You can compile it linking it to the slsDetector library -gcc mainClient.cpp -L lib -l SlsDetector -lm -pthread +g++ mainClient.cpp -L lib -lSlsDetector -L/usr/lib64/ -L lib2 -lzmq -pthread -lrt -lm -lstdc++ -where lib is the location of libSlsDetector.so -gcc mainClient.cpp -L . -l SlsDetector -lm -pthread -o users +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 #include "slsDetectorUsers.h" #include "detectorData.h" +#include #include -/** Definition of the data callback which simply prints out the number of points received and teh frame number */ +/** + * 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: " << pData->npoints << " " << pData->npy << "Frame number: " << iframe << std::endl; + std::cout << "dataCallback: " << pData->npoints << " " << pData->npy << "Frame number: " << iframe << std::endl; } -/**example of a main program using the slsDetectorUsers class */ +/** + * 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) { - int id=0; - /** if specified, argv[3] is used as detector ID (default is 0)*/ - if (argc>=4) - id=atoi(argv[3]); - + /** - if specified, set ID from argv[3] */ + int id=0; + if (argc>=4) + id=atoi(argv[3]); - /** slsDetectorUsers is instantiated */ - slsDetectorUsers *pDetector = new slsDetectorUsers (id); + /** - slsDetectorUsers Object is instantiated with appropriate ID */ + slsDetectorUsers *pDetector = new slsDetectorUsers (id); - - /** if specified, argv[1] is used as detector config 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]); - cout<<"Detector configured" << endl; - } - /** registering data callback */ - pDetector->registerDataCallback(&dataCallback, NULL); - pDetector->enableDataStreamingFromReceiver(1); - /** checking detector status and exiting if not idle */ - int status = pDetector->getDetectorStatus(); - if (status != 0){ - std::cout << "Detector not ready: " << slsDetectorUsers::runStatusType(status) << std::endl; - return 1; - } + /** - 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; + } - /** load detector settings */ - if (argc>=3){ - pDetector->retrieveDetectorSetup(argv[2]); - cout<<"Detector measurement set-up done" << endl; - } - /** start measurement */ - pDetector->startMeasurement(); - cout<<"started measurement"<getDetectorStatus(); - if (status == 0 || status == 1|| status == 3) - break; - }*/ - cout<<"measurement finished"<registerDataCallback(&dataCallback, NULL); + /** - if receiver exists, enable data streaming from receiver to get the data */ + pDetector->enableDataStreamingFromReceiver(1); + + + /** - 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 index 70217f90d..1ebb23b19 100644 --- a/manual/manual-api/mainReceiver.cpp +++ b/manual/manual-api/mainReceiver.cpp @@ -1,5 +1,20 @@ -/* A simple server in the internet domain using TCP - The port number is passed as an argument */ +/** + \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_receiver_defs.h" #include "slsReceiverUsers.h" @@ -8,52 +23,97 @@ #include #include //SIGINT #include //system - //#include "utilities.h" //#include "logger.h" - #include //wait #include //wait - #include using namespace std; +/* Define Number of receivers */ #define NUM_RECEIVERS 1 +/** Define TCP Port of First Receiver, others are incremented by 1 */ #define START_TCP_PORT 1954 +/** 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__) - +/* List of process IDs of all child receiver processes */ pid_t childPid[NUM_RECEIVERS]; +/** Variable is true to continue running, set to false upon interrupt */ bool keeprunning; +/** Variable indicating number of child processes running */ int numrunning; - +/** + * Child Exit Signal Interrupt Handler + * When a child process exits, this function is called, + * blocks until all child processes exit & + * decreases the variable indicating number of running processes + * @param sig signal enum + */ void sigChildExitedHandler(int sig) { - pid_t pid = wait(NULL); - bprintf(GRAY, "\nChild Process Pid %d exited.\n", pid); - numrunning--; + pid_t pid = wait(NULL); + bprintf(GRAY, "\nChild Process Pid %d exited.\n", pid); + numrunning--; } - +/** + * 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; } +/** + * 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){ - bprintf(BLUE, "#### StartAcq: filepath:%s filename:%s fileindex:%llu datasize:%u ####\n", - filepath, filename, fileindex, datasize); + bprintf(BLUE, "#### StartAcq: filepath:%s filename:%s fileindex:%llu datasize:%u ####\n", + filepath, filename, fileindex, datasize); - bprintf(BLUE, "--StartAcq: returning 0\n"); - return 0; + bprintf(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){ - bprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",frames); + bprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",frames); } - +/** + * Get Receiver Data Call back + * Prints in different colors(for each receiver process) the different headers for each image call back. + * @param frameNumber frame number + * @param expLength real time exposure length (in 100ns) or sub frame number (Eiger 32 bit mode only) + * @param packetNumber number of packets caught for this frame + * @param bunchId bunch id from beamline + * @param timestamp time stamp in 10MHz clock (not implemented for most) + * @param modId module id (not implemented for most) + * @param xCoord x coordinates (detector id in 1D) + * @param yCoord y coordinates (not implemented) + * @param zCoord z coordinates (not implemented) + * @param debug debug values if any + * @param roundRNumber (not implemented) + * @param detType detector type see :: detectorType + * @param version version of standard header (structure format) + * @param datapointer pointer to data + * @param datasize data size in bytes + * @param p pointer to object + */ void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, char* datapointer, uint32_t datasize, void* p){ @@ -70,17 +130,22 @@ void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, ui } - +/** + * 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 child process pid values + /** - set default values: child process pid values to -1, keeprunning to true, numrunning to 0 */ for (int i = 0; i < NUM_RECEIVERS; ++i) childPid[i] = -1; - keeprunning = true; numrunning = 0; - // Catch signal SIGINT to close files and call destructors properly + /** - 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 @@ -89,7 +154,7 @@ int main(int argc, char *argv[]) { bprintf(RED, "Could not set handler function for SIGINT\n"); } - // wait for all the SIGCHILD signals + /** - wait for all the SIGCHILD signals and decrease numrunningeach time a child process exits*/ struct sigaction asa; asa.sa_flags=0; // no flags asa.sa_handler=sigChildExitedHandler; // handler function @@ -99,19 +164,19 @@ int main(int argc, char *argv[]) { } - int narg= 3; - + /** - loop over number of receivers */ for (int i = 0; i < NUM_RECEIVERS; ++i) { + /** - fork process to create child process */ childPid[i] = fork(); - // fork failed + /** - if fork failed, raise SIGINT and kill all receiver objects */ if (childPid[i] < 0) { bprintf(RED,"fork() failed. Killing all the receiver objects\n"); raise(SIGINT); } - // child process + /** - if child process */ else if (childPid[i] == 0) { bprintf(BLUE,"Starting Receiver %d with pid %ld\n", i, (long)getpid()); @@ -119,84 +184,55 @@ int main(int argc, char *argv[]) { sprintf(temp,"%d",START_TCP_PORT + i); char* args[] = {(char*)"ignored", (char*)"--rx_tcpport", temp}; int ret = slsReceiverDefs::OK; - slsReceiverUsers *receiver = new slsReceiverUsers(narg, args, ret); + /** - create slsReceiverUsers object with appropriate arguments + (START_TCP_PORT incrementing by 1 */ + slsReceiverUsers *receiver = new slsReceiverUsers(3, args, ret); if(ret==slsReceiverDefs::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 + /** - 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 */ - /** - * Call back for start acquisition - * callback arguments are - * filepath - * filename - * fileindex - * datasize - * - * return value is insignificant at the moment - * we write depending on file write enable - * users get data to write depending on call backs registered - */ + /** - Call back for start acquisition */ bprintf(BLUE, "Registering StartAcq()\n"); receiver->registerCallBackStartAcquisition(StartAcq, NULL); - /** - * Call back for acquisition finished - * callback argument is - * total frames caught - */ + /** - Call back for acquisition finished */ bprintf(BLUE, "Registering AcquisitionFinished()\n"); receiver->registerCallBackAcquisitionFinished(AcquisitionFinished, NULL); - /** - * Call back for raw data - * args to raw data ready callback are - * frameNumber is the frame number - * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) - * packetNumber is the packet number - * bunchId is the bunch id from beamline - * timestamp is the time stamp with 10 MHz clock - * modId is the unique module id (unique even for left, right, top, bottom) - * xCoord is the x coordinate in the complete detector system - * yCoord is the y coordinate in the complete detector system - * zCoord is the z coordinate in the complete detector system - * debug is for debugging purposes - * roundRNumber is the round robin set number - * detType is the detector type see :: detectorType - * version is the version number of this structure format - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes - */ + /* - Call back for raw data */ bprintf(BLUE, "Registering GetData() \n"); receiver->registerCallBackRawDataReady(GetData,NULL); - //start tcp server thread + /** - start tcp server thread */ if (receiver->start() == slsReceiverDefs::FAIL){ delete receiver; exit(EXIT_FAILURE); } + /** - as long as keeprunning is true, usleep for a second */ while(keeprunning) usleep(1 * 1000 * 1000); + /** - interrupt caught, delete slsReceiverUsers object and exit */ delete receiver; exit(EXIT_SUCCESS); } - // parent process + /** - parent process, increment number of running processes */ else numrunning++; } + /** - Print Ready and Instructions how to exit */ cout << "Ready ... " << endl; bprintf(GRAY, "\n[ Press \'Ctrl+c\' to exit ]\n"); - // wait for all child processes to exit + /** - Parent process waits for all child processes to exit by sleeping till numrunning is 0 */ while(numrunning) usleep(1 * 1000 * 1000); cout << "Goodbye!" << endl;