updated users documentation

This commit is contained in:
Dhanya Maliakal 2017-08-25 15:42:56 +02:00
parent 891e76af0a
commit ce0aa98b3f
32 changed files with 586 additions and 398 deletions

View File

@ -63,7 +63,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -68,7 +68,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -309,7 +309,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -63,7 +63,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -128,7 +128,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -2199,7 +2199,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -68,7 +68,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -325,7 +325,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -67,7 +67,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -80,7 +80,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -65,7 +65,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -384,7 +384,7 @@ Here is a list of all class members with links to the classes they belong to:
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -350,7 +350,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -91,7 +91,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -108,7 +108,7 @@ Here is a list of all file members with links to the files they belong to:<ul>
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -77,7 +77,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -90,7 +90,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -77,7 +77,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -79,7 +79,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -43,9 +43,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</div> </div>
</div> </div>
<div class="contents"> <div class="contents">
<h1>mainClient.cpp File Reference</h1><code>#include &lt;iostream&gt;</code><br/> <h1>mainClient.cpp File Reference</h1><code>#include &quot;<a class="el" href="slsDetectorUsers_8h_source.html">slsDetectorUsers.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="slsDetectorUsers_8h_source.html">slsDetectorUsers.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="detectorData_8h_source.html">detectorData.h</a>&quot;</code><br/> <code>#include &quot;<a class="el" href="detectorData_8h_source.html">detectorData.h</a>&quot;</code><br/>
<code>#include &lt;iostream&gt;</code><br/>
<code>#include &lt;cstdlib&gt;</code><br/> <code>#include &lt;cstdlib&gt;</code><br/>
<p><a href="mainClient_8cpp_source.html">Go to the source code of this file.</a></p> <p><a href="mainClient_8cpp_source.html">Go to the source code of this file.</a></p>
@ -56,8 +56,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
<hr/><a name="_details"></a><h2>Detailed Description</h2> <hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>This file is an example of how to implement the <a class="el" href="classslsDetectorUsers.html" title="Class for detector functionalitiesto embed the detector controls in the users custom...">slsDetectorUsers</a> class You can compile it linking it to the slsDetector library</p> <p>This file is an example of how to implement the <a class="el" href="classslsDetectorUsers.html" title="Class for detector functionalitiesto embed the detector controls in the users custom...">slsDetectorUsers</a> class You can compile it linking it to the slsDetector library</p>
<p>gcc <a class="el" href="mainClient_8cpp.html">mainClient.cpp</a> -L lib -l SlsDetector -lm -pthread</p> <p>g++ <a class="el" href="mainClient_8cpp.html">mainClient.cpp</a> -L lib -lSlsDetector -L/usr/lib64/ -L lib2 -lzmq -pthread -lrt -lm -lstdc++</p>
<p>where lib is the location of libSlsDetector.so gcc <a class="el" href="mainClient_8cpp.html">mainClient.cpp</a> -L . -l SlsDetector -lm -pthread -o users </p> <p>where,</p>
<p>lib is the location of libSlsDetector.so</p>
<p>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 ] </p>
<p>Definition in file <a class="el" href="mainClient_8cpp_source.html">mainClient.cpp</a>.</p> <p>Definition in file <a class="el" href="mainClient_8cpp_source.html">mainClient.cpp</a>.</p>
<hr/><h2>Function Documentation</h2> <hr/><h2>Function Documentation</h2>
@ -97,9 +99,19 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Definition of the data callback which simply prints out the number of points received and teh frame number </p> <p>Data Call back function defined </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>pData</em>&nbsp;</td><td>pointer to data structure received from the call back </td></tr>
<tr><td valign="top"></td><td valign="top"><em>iframe</em>&nbsp;</td><td>frame number of data passed </td></tr>
<tr><td valign="top"></td><td valign="top"><em>isubframe</em>&nbsp;</td><td>sub frame number of data passed ( only valid for EIGER in 32 bit mode) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>pArg</em>&nbsp;</td><td>pointer to object </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>integer that is currently ignored </dd></dl>
<p>Definition at line <a class="el" href="mainClient_8cpp_source.html#l00020">20</a> of file <a class="el" href="mainClient_8cpp_source.html">mainClient.cpp</a>.</p> <p>Definition at line <a class="el" href="mainClient_8cpp_source.html#l00032">32</a> of file <a class="el" href="mainClient_8cpp_source.html">mainClient.cpp</a>.</p>
</div> </div>
</div> </div>
@ -127,19 +139,49 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>example of a main program using the <a class="el" href="classslsDetectorUsers.html" title="Class for detector functionalitiesto embed the detector controls in the users custom...">slsDetectorUsers</a> class </p> <p>Example of a main program using the <a class="el" href="classslsDetectorUsers.html" title="Class for detector functionalitiesto embed the detector controls in the users custom...">slsDetectorUsers</a> class</p>
<ul>
<li>Arguments are optional<ul>
<li>argv[1] : Configuration File</li>
<li>argv[2] : Measurement Setup File</li>
<li>argv[3] : Detector Id (default is zero) </li>
</ul>
</li>
</ul>
<p><p>if specified, argv[3] is used as detector ID (default is 0)</p> <p><ul>
<p><a class="el" href="classslsDetectorUsers.html" title="Class for detector functionalitiesto embed the detector controls in the users custom...">slsDetectorUsers</a> is instantiated</p> <li>if specified, set ID from argv[3]</li>
<p>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)</p> </ul>
<p>registering data callback</p> <ul>
<p>checking detector status and exiting if not idle</p> <li><a class="el" href="classslsDetectorUsers.html" title="Class for detector functionalitiesto embed the detector controls in the users custom...">slsDetectorUsers</a> Object is instantiated with appropriate ID</li>
<p>load detector settings</p> </ul>
<p>start measurement</p> <ul>
<p>returning when acquisition is finished or data are avilable </p> <li>if specified, load configuration file (necessary at least the first time it is called to properly configure advanced settings in the shared memory)</li>
</ul>
<ul>
<li>registering data callback</li>
</ul>
<ul>
<li>if receiver exists, enable data streaming from receiver to get the data</li>
</ul>
<ul>
<li>ensuring detector status is idle before starting acquisition. exiting if not idle</li>
</ul>
<ul>
<li>if provided, load detector settings</li>
</ul>
<ul>
<li>start measurement</li>
</ul>
<ul>
<li>returning when acquisition is finished or data are avilable</li>
</ul>
<ul>
<li>delete <a class="el" href="classslsDetectorUsers.html" title="Class for detector functionalitiesto embed the detector controls in the users custom...">slsDetectorUsers</a> object </li>
</ul>
</p> </p>
<p>Definition at line <a class="el" href="mainClient_8cpp_source.html#l00027">27</a> of file <a class="el" href="mainClient_8cpp_source.html">mainClient.cpp</a>.</p> <p>Definition at line <a class="el" href="mainClient_8cpp_source.html#l00046">46</a> of file <a class="el" href="mainClient_8cpp_source.html">mainClient.cpp</a>.</p>
</div> </div>
</div> </div>
@ -158,7 +200,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -42,59 +42,56 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</ul> </ul>
</div> </div>
<h1>mainClient.cpp</h1><a href="mainClient_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <h1>mainClient.cpp</h1><a href="mainClient_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;iostream&gt;</span> <a name="l00019"></a>00019 <span class="preprocessor">#include &quot;<a class="code" href="slsDetectorUsers_8h.html">slsDetectorUsers.h</a>&quot;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &quot;<a class="code" href="slsDetectorUsers_8h.html">slsDetectorUsers.h</a>&quot;</span> <a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="detectorData_8h.html">detectorData.h</a>&quot;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &quot;<a class="code" href="detectorData_8h.html">detectorData.h</a>&quot;</span> <a name="l00021"></a>00021 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;cstdlib&gt;</span> <a name="l00022"></a>00022 <span class="preprocessor">#include &lt;cstdlib&gt;</span>
<a name="l00018"></a>00018 <a name="l00023"></a>00023
<a name="l00020"></a><a class="code" href="mainClient_8cpp.html#abba369ecba2066d66cc8b3b74460e778">00020</a> <span class="keywordtype">int</span> <a class="code" href="mainClient_8cpp.html#abba369ecba2066d66cc8b3b74460e778">dataCallback</a>(<a class="code" href="classdetectorData.html" title="data structure to hold the detector data after postprocessing (e.g. to plot, store...">detectorData</a> *pData, <span class="keywordtype">int</span> iframe, <span class="keywordtype">int</span> isubframe, <span class="keywordtype">void</span> *pArg) <a name="l00032"></a><a class="code" href="mainClient_8cpp.html#abba369ecba2066d66cc8b3b74460e778">00032</a> <span class="keywordtype">int</span> <a class="code" href="mainClient_8cpp.html#abba369ecba2066d66cc8b3b74460e778">dataCallback</a>(<a class="code" href="classdetectorData.html" title="data structure to hold the detector data after postprocessing (e.g. to plot, store...">detectorData</a> *pData, <span class="keywordtype">int</span> iframe, <span class="keywordtype">int</span> isubframe, <span class="keywordtype">void</span> *pArg)
<a name="l00021"></a>00021 { <a name="l00033"></a>00033 {
<a name="l00022"></a>00022 std::cout &lt;&lt; <span class="stringliteral">&quot;dataCallback: &quot;</span> &lt;&lt; pData-&gt;<a class="code" href="classdetectorData.html#a50aabf6f2c40587f8e915cf4913a2cfe" title="number of points">npoints</a> &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; pData-&gt;<a class="code" href="classdetectorData.html#ac289d259e7fd9445a9c04976a82cb324" title="dimensions in y coordinate">npy</a> &lt;&lt; <span class="stringliteral">&quot;Frame number: &quot;</span> &lt;&lt; iframe &lt;&lt; std::endl; <a name="l00034"></a>00034 std::cout &lt;&lt; <span class="stringliteral">&quot;dataCallback: &quot;</span> &lt;&lt; pData-&gt;<a class="code" href="classdetectorData.html#a50aabf6f2c40587f8e915cf4913a2cfe" title="number of points">npoints</a> &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; pData-&gt;<a class="code" href="classdetectorData.html#ac289d259e7fd9445a9c04976a82cb324" title="dimensions in y coordinate">npy</a> &lt;&lt; <span class="stringliteral">&quot;Frame number: &quot;</span> &lt;&lt; iframe &lt;&lt; std::endl;
<a name="l00023"></a>00023 } <a name="l00035"></a>00035 }
<a name="l00024"></a>00024 <a name="l00036"></a>00036
<a name="l00025"></a>00025
<a name="l00027"></a><a class="code" href="mainClient_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627">00027</a> <span class="keywordtype">int</span> <a class="code" href="mainClient_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) {
<a name="l00028"></a>00028 <span class="keywordtype">int</span> <span class="keywordtype">id</span>=0;
<a name="l00030"></a>00030 <span class="keywordflow">if</span> (argc&gt;=4)
<a name="l00031"></a>00031 <span class="keywordtype">id</span>=atoi(argv[3]);
<a name="l00032"></a>00032
<a name="l00033"></a>00033
<a name="l00034"></a>00034
<a name="l00036"></a>00036 <a class="code" href="classslsDetectorUsers.html" title="Class for detector functionalitiesto embed the detector controls in the users custom...">slsDetectorUsers</a> *pDetector = <span class="keyword">new</span> <a class="code" href="classslsDetectorUsers.html" title="Class for detector functionalitiesto embed the detector controls in the users custom...">slsDetectorUsers</a> (<span class="keywordtype">id</span>);
<a name="l00037"></a>00037 <a name="l00037"></a>00037
<a name="l00038"></a>00038 <a name="l00046"></a><a class="code" href="mainClient_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627">00046</a> <span class="keywordtype">int</span> <a class="code" href="mainClient_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) {
<a name="l00040"></a>00040 <span class="keywordflow">if</span> (argc&gt;=2){ <a name="l00048"></a>00048 <span class="keywordtype">int</span> <span class="keywordtype">id</span>=0;
<a name="l00041"></a>00041 pDetector-&gt;<a class="code" href="classslsDetectorUsers.html#a8aeda7c2cbc270c7f8756761823e8d95" title="Reads the configuration file -- will contain all the informations needed for the...">readConfigurationFile</a>(argv[1]); <a name="l00049"></a>00049 <span class="keywordflow">if</span> (argc&gt;=4)
<a name="l00042"></a>00042 cout&lt;&lt;<span class="stringliteral">&quot;Detector configured&quot;</span> &lt;&lt; endl; <a name="l00050"></a>00050 <span class="keywordtype">id</span>=atoi(argv[3]);
<a name="l00043"></a>00043 } <a name="l00051"></a>00051
<a name="l00045"></a>00045 pDetector-&gt;<a class="code" href="classslsDetectorUsers.html#add821d94da9b03fe500d27e4433c01f5" title="register calbback for accessing detector final data">registerDataCallback</a>(&amp;<a class="code" href="mainClient_8cpp.html#abba369ecba2066d66cc8b3b74460e778">dataCallback</a>, NULL); <a name="l00052"></a>00052
<a name="l00046"></a>00046 pDetector-&gt;<a class="code" href="classslsDetectorUsers.html#a5c85f5c94b585a1915307fa7f4bc46f6">enableDataStreamingFromReceiver</a>(1); <a name="l00054"></a>00054 <a class="code" href="classslsDetectorUsers.html" title="Class for detector functionalitiesto embed the detector controls in the users custom...">slsDetectorUsers</a> *pDetector = <span class="keyword">new</span> <a class="code" href="classslsDetectorUsers.html" title="Class for detector functionalitiesto embed the detector controls in the users custom...">slsDetectorUsers</a> (<span class="keywordtype">id</span>);
<a name="l00047"></a>00047 <a name="l00055"></a>00055
<a name="l00049"></a>00049 <span class="keywordtype">int</span> status = pDetector-&gt;<a class="code" href="classslsDetectorUsers.html#ac7d0254e38b8fe783204f691a4ee05b2" title="get run status">getDetectorStatus</a>(); <a name="l00056"></a>00056
<a name="l00050"></a>00050 <span class="keywordflow">if</span> (status != 0){ <a name="l00058"></a>00058 <span class="keywordflow">if</span> (argc&gt;=2){
<a name="l00051"></a>00051 std::cout &lt;&lt; <span class="stringliteral">&quot;Detector not ready: &quot;</span> &lt;&lt; <a class="code" href="classslsDetectorUsers.html#a2c073513ae3ac53f3e040bc2911b6ee2" title="returns string from run status index">slsDetectorUsers::runStatusType</a>(status) &lt;&lt; std::endl; <a name="l00059"></a>00059 pDetector-&gt;<a class="code" href="classslsDetectorUsers.html#a8aeda7c2cbc270c7f8756761823e8d95" title="Reads the configuration file -- will contain all the informations needed for the...">readConfigurationFile</a>(argv[1]);
<a name="l00052"></a>00052 <span class="keywordflow">return</span> 1; <a name="l00060"></a>00060 std::cout &lt;&lt; <span class="stringliteral">&quot;Detector configured&quot;</span> &lt;&lt; std::endl;
<a name="l00053"></a>00053 } <a name="l00061"></a>00061 }
<a name="l00054"></a>00054 <a name="l00062"></a>00062
<a name="l00056"></a>00056 <span class="keywordflow">if</span> (argc&gt;=3){
<a name="l00057"></a>00057 pDetector-&gt;<a class="code" href="classslsDetectorUsers.html#a8769c8ea5020b43dc3557c86f9e4159b" title="Loads the detector setup from file.">retrieveDetectorSetup</a>(argv[2]);
<a name="l00058"></a>00058 cout&lt;&lt;<span class="stringliteral">&quot;Detector measurement set-up done&quot;</span> &lt;&lt; endl;
<a name="l00059"></a>00059 }
<a name="l00061"></a>00061 pDetector-&gt;<a class="code" href="classslsDetectorUsers.html#aa34810bb0e872fdf929ebe62d8582bd3" title="start measurement and acquires">startMeasurement</a>();
<a name="l00062"></a>00062 cout&lt;&lt;<span class="stringliteral">&quot;started measurement&quot;</span>&lt;&lt;endl;
<a name="l00063"></a>00063 <a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="comment">/* while (1) {</span> <a name="l00065"></a>00065 pDetector-&gt;<a class="code" href="classslsDetectorUsers.html#add821d94da9b03fe500d27e4433c01f5" title="register calbback for accessing detector final data">registerDataCallback</a>(&amp;<a class="code" href="mainClient_8cpp.html#abba369ecba2066d66cc8b3b74460e778">dataCallback</a>, NULL);
<a name="l00065"></a>00065 <span class="comment"> usleep(100000); </span> <a name="l00067"></a>00067 pDetector-&gt;<a class="code" href="classslsDetectorUsers.html#a5c85f5c94b585a1915307fa7f4bc46f6">enableDataStreamingFromReceiver</a>(1);
<a name="l00066"></a>00066 <span class="comment"> status = pDetector-&gt;getDetectorStatus(); </span> <a name="l00068"></a>00068
<a name="l00067"></a>00067 <span class="comment"> if (status == 0 || status == 1|| status == 3)</span> <a name="l00069"></a>00069
<a name="l00068"></a>00068 <span class="comment"> break; </span> <a name="l00071"></a>00071 <span class="keywordtype">int</span> status = pDetector-&gt;<a class="code" href="classslsDetectorUsers.html#ac7d0254e38b8fe783204f691a4ee05b2" title="get run status">getDetectorStatus</a>();
<a name="l00069"></a>00069 <span class="comment"> }*/</span> <a name="l00072"></a>00072 <span class="keywordflow">if</span> (status != 0){
<a name="l00070"></a>00070 cout&lt;&lt;<span class="stringliteral">&quot;measurement finished&quot;</span>&lt;&lt;endl; <a name="l00073"></a>00073 std::cout &lt;&lt; <span class="stringliteral">&quot;Detector not ready: &quot;</span> &lt;&lt; <a class="code" href="classslsDetectorUsers.html#a2c073513ae3ac53f3e040bc2911b6ee2" title="returns string from run status index">slsDetectorUsers::runStatusType</a>(status) &lt;&lt; std::endl;
<a name="l00074"></a>00074 <span class="keyword">delete</span> pDetector; <a name="l00074"></a>00074 <span class="keywordflow">return</span> 1;
<a name="l00075"></a>00075 <a name="l00075"></a>00075 }
<a name="l00076"></a>00076 <span class="keywordflow">return</span> 0; <a name="l00076"></a>00076
<a name="l00077"></a>00077 } <a name="l00078"></a>00078 <span class="keywordflow">if</span> (argc&gt;=3){
<a name="l00078"></a>00078 <a name="l00079"></a>00079 pDetector-&gt;<a class="code" href="classslsDetectorUsers.html#a8769c8ea5020b43dc3557c86f9e4159b" title="Loads the detector setup from file.">retrieveDetectorSetup</a>(argv[2]);
<a name="l00080"></a>00080 std::cout &lt;&lt; <span class="stringliteral">&quot;Detector measurement set-up done&quot;</span> &lt;&lt; std::endl;
<a name="l00081"></a>00081 }
<a name="l00082"></a>00082
<a name="l00083"></a>00083
<a name="l00085"></a>00085 pDetector-&gt;<a class="code" href="classslsDetectorUsers.html#aa34810bb0e872fdf929ebe62d8582bd3" title="start measurement and acquires">startMeasurement</a>();
<a name="l00086"></a>00086 std::cout &lt;&lt; <span class="stringliteral">&quot;measurement finished&quot;</span> &lt;&lt; std::endl;
<a name="l00087"></a>00087
<a name="l00091"></a>00091 <span class="keyword">delete</span> pDetector;
<a name="l00092"></a>00092
<a name="l00093"></a>00093 <span class="keywordflow">return</span> 0;
<a name="l00094"></a>00094 }
<a name="l00095"></a>00095
</pre></div></div> </pre></div></div>
<!--- window showing the filter options --> <!--- window showing the filter options -->
<div id="MSearchSelectWindow" <div id="MSearchSelectWindow"
@ -110,7 +107,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -71,6 +71,14 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<tr><td class="memItemLeft" align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="mainReceiver_8cpp.html#a0d26a166bb416ff34512de6fe9e098bd">keeprunning</a></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="mainReceiver_8cpp.html#a0d26a166bb416ff34512de6fe9e098bd">keeprunning</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">numrunning</a></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">numrunning</a></td></tr>
</table> </table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>This file is an example of how to implement the <a class="el" href="classslsReceiverUsers.html" title="Class for implementing the SLS data receiver in the users application. Callbacks...">slsReceiverUsers</a> class You can compile it linking it to the slsReceiver library</p>
<p>g++ <a class="el" href="mainReceiver_8cpp.html">mainReceiver.cpp</a> -L lib -lSlsReceiver -L/usr/lib64/ -L lib2 -lzmq -pthread -lrt -lm -lstdc++</p>
<p>where,</p>
<p>lib is the location of lSlsReceiver.so</p>
<p>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 ] </p>
<p>Definition in file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
<hr/><h2>Define Documentation</h2> <hr/><h2>Define Documentation</h2>
<a class="anchor" id="aa55605484e783ee738b6f4e7b251cbee"></a><!-- doxytag: member="mainReceiver.cpp::NUM_RECEIVERS" ref="aa55605484e783ee738b6f4e7b251cbee" args="" --> <a class="anchor" id="aa55605484e783ee738b6f4e7b251cbee"></a><!-- doxytag: member="mainReceiver.cpp::NUM_RECEIVERS" ref="aa55605484e783ee738b6f4e7b251cbee" args="" -->
<div class="memitem"> <div class="memitem">
@ -83,7 +91,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00021">21</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p> <p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00034">34</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
</div> </div>
</div> </div>
@ -112,8 +120,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Define Colors to print data call back in different colors for different recievers </p>
<p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00023">23</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p> <p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00038">38</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
</div> </div>
</div> </div>
@ -127,8 +136,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Define TCP Port of First Receiver, others are incremented by 1 </p>
<p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00022">22</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p> <p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00036">36</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
</div> </div>
</div> </div>
@ -157,8 +167,16 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Acquisition Finished Call back </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>frames</em>&nbsp;</td><td>Number of frames caught </td></tr>
<tr><td valign="top"></td><td valign="top"><em>p</em>&nbsp;</td><td>pointer to object </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00052">52</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p> <p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00093">93</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
</div> </div>
</div> </div>
@ -270,8 +288,30 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Get Receiver Data Call back Prints in different colors(for each receiver process) the different headers for each image call back. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>frameNumber</em>&nbsp;</td><td>frame number </td></tr>
<tr><td valign="top"></td><td valign="top"><em>expLength</em>&nbsp;</td><td>real time exposure length (in 100ns) or sub frame number (Eiger 32 bit mode only) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>packetNumber</em>&nbsp;</td><td>number of packets caught for this frame </td></tr>
<tr><td valign="top"></td><td valign="top"><em>bunchId</em>&nbsp;</td><td>bunch id from beamline </td></tr>
<tr><td valign="top"></td><td valign="top"><em>timestamp</em>&nbsp;</td><td>time stamp in 10MHz clock (not implemented for most) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>modId</em>&nbsp;</td><td>module id (not implemented for most) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>xCoord</em>&nbsp;</td><td>x coordinates (detector id in 1D) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>yCoord</em>&nbsp;</td><td>y coordinates (not implemented) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>zCoord</em>&nbsp;</td><td>z coordinates (not implemented) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>debug</em>&nbsp;</td><td>debug values if any </td></tr>
<tr><td valign="top"></td><td valign="top"><em>roundRNumber</em>&nbsp;</td><td>(not implemented) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>detType</em>&nbsp;</td><td>detector type see :: detectorType </td></tr>
<tr><td valign="top"></td><td valign="top"><em>version</em>&nbsp;</td><td>version of standard header (structure format) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>datapointer</em>&nbsp;</td><td>pointer to data </td></tr>
<tr><td valign="top"></td><td valign="top"><em>datasize</em>&nbsp;</td><td>data size in bytes </td></tr>
<tr><td valign="top"></td><td valign="top"><em>p</em>&nbsp;</td><td>pointer to object </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00057">57</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p> <p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00117">117</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
</div> </div>
</div> </div>
@ -299,14 +339,69 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Example of main program using the <a class="el" href="classslsReceiverUsers.html" title="Class for implementing the SLS data receiver in the users application. Callbacks...">slsReceiverUsers</a> class</p>
<ul>
<li>Defines in file for:<ul>
<li>Default Number of receivers is 1</li>
<li>Default Start TCP port is 1954 </li>
</ul>
</li>
</ul>
<p><p>Call back for start acquisition callback arguments are filepath filename fileindex datasize</p> <p><ul>
<p>return value is insignificant at the moment we write depending on file write enable users get data to write depending on call backs registered</p> <li>set default values: child process pid values to -1, keeprunning to true, numrunning to 0</li>
<p>Call back for acquisition finished callback argument is total frames caught</p> </ul>
<p>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</p> <ul>
<li>Catch signal SIGINT to close files and call destructors properly</li>
</ul>
<ul>
<li>wait for all the SIGCHILD signals and decrease numrunningeach time a child process exits</li>
</ul>
<ul>
<li>loop over number of receivers</li>
</ul>
<ul>
<li>fork process to create child process</li>
</ul>
<ul>
<li>if fork failed, raise SIGINT and kill all receiver objects</li>
</ul>
<ul>
<li>if child process</li>
</ul>
<ul>
<li>create <a class="el" href="classslsReceiverUsers.html" title="Class for implementing the SLS data receiver in the users application. Callbacks...">slsReceiverUsers</a> object with appropriate arguments (START_TCP_PORT incrementing by 1</li>
</ul>
<ul>
<li>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</li>
</ul>
<ul>
<li>Call back for start acquisition</li>
</ul>
<ul>
<li>Call back for acquisition finished</li>
</ul>
<ul>
<li>start tcp server thread</li>
</ul>
<ul>
<li>as long as keeprunning is true, usleep for a second</li>
</ul>
<ul>
<li>interrupt caught, delete <a class="el" href="classslsReceiverUsers.html" title="Class for implementing the SLS data receiver in the users application. Callbacks...">slsReceiverUsers</a> object and exit</li>
</ul>
<ul>
<li>parent process, increment number of running processes</li>
</ul>
<ul>
<li>Print Ready and Instructions how to exit</li>
</ul>
<ul>
<li>Parent process waits for all child processes to exit by sleeping till numrunning is 0 </li>
</ul>
</p> </p>
<p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00074">74</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p> <p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00140">140</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
</div> </div>
</div> </div>
@ -325,8 +420,15 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Child Exit Signal Interrupt Handler When a child process exits, this function is called, blocks until all child processes exit &amp; decreases the variable indicating number of running processes </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>sig</em>&nbsp;</td><td>signal enum </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00032">32</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p> <p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00055">55</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
</div> </div>
</div> </div>
@ -345,8 +447,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Control+C Interrupt Handler Sets the variable keeprunning to false, to let all the processes know to exit properly </p>
<p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00039">39</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p> <p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00065">65</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
</div> </div>
</div> </div>
@ -392,8 +495,20 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Start Acquisition Call back slsReceiver writes data if file write enabled. Users get data to write using call back if registerCallBackRawDataReady is registered. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>filepath</em>&nbsp;</td><td>file path </td></tr>
<tr><td valign="top"></td><td valign="top"><em>filename</em>&nbsp;</td><td>file name </td></tr>
<tr><td valign="top"></td><td valign="top"><em>fileindex</em>&nbsp;</td><td>file index </td></tr>
<tr><td valign="top"></td><td valign="top"><em>datasize</em>&nbsp;</td><td>data size in bytes </td></tr>
<tr><td valign="top"></td><td valign="top"><em>p</em>&nbsp;</td><td>pointer to object </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>ignored </dd></dl>
<p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00043">43</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p> <p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00080">80</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
</div> </div>
</div> </div>
@ -409,7 +524,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00026">26</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p> <p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00041">41</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
</div> </div>
</div> </div>
@ -423,8 +538,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Variable is true to continue running, set to false upon interrupt </p>
<p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00027">27</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p> <p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00043">43</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
</div> </div>
</div> </div>
@ -438,8 +554,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</table> </table>
</div> </div>
<div class="memdoc"> <div class="memdoc">
<p>Variable indicating number of child processes running </p>
<p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00028">28</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p> <p>Definition at line <a class="el" href="mainReceiver_8cpp_source.html#l00045">45</a> of file <a class="el" href="mainReceiver_8cpp_source.html">mainReceiver.cpp</a>.</p>
</div> </div>
</div> </div>
@ -458,7 +575,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -41,175 +41,154 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li> <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul> </ul>
</div> </div>
<h1>mainReceiver.cpp</h1><a href="mainReceiver_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* A simple server in the internet domain using TCP</span> <h1>mainReceiver.cpp</h1><a href="mainReceiver_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00002"></a>00002 <span class="comment"> The port number is passed as an argument */</span> <a name="l00019"></a>00019 <span class="preprocessor">#include &quot;sls_receiver_defs.h&quot;</span>
<a name="l00003"></a>00003 <a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="slsReceiverUsers_8h.html">slsReceiverUsers.h</a>&quot;</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;sls_receiver_defs.h&quot;</span> <a name="l00021"></a>00021
<a name="l00005"></a>00005 <span class="preprocessor">#include &quot;<a class="code" href="slsReceiverUsers_8h.html">slsReceiverUsers.h</a>&quot;</span> <a name="l00022"></a>00022 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00006"></a>00006 <a name="l00023"></a>00023 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &lt;iostream&gt;</span> <a name="l00024"></a>00024 <span class="preprocessor">#include &lt;signal.h&gt;</span> <span class="comment">//SIGINT</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &lt;string.h&gt;</span> <a name="l00025"></a>00025 <span class="preprocessor">#include &lt;cstdlib&gt;</span> <span class="comment">//system</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &lt;signal.h&gt;</span> <span class="comment">//SIGINT</span> <a name="l00026"></a>00026 <span class="comment">//#include &quot;utilities.h&quot;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;cstdlib&gt;</span> <span class="comment">//system</span> <a name="l00027"></a>00027 <span class="comment">//#include &quot;logger.h&quot;</span>
<a name="l00011"></a>00011 <a name="l00028"></a>00028 <span class="preprocessor">#include &lt;sys/types.h&gt;</span> <span class="comment">//wait</span>
<a name="l00012"></a>00012 <span class="comment">//#include &quot;utilities.h&quot;</span> <a name="l00029"></a>00029 <span class="preprocessor">#include &lt;sys/wait.h&gt;</span> <span class="comment">//wait</span>
<a name="l00013"></a>00013 <span class="comment">//#include &quot;logger.h&quot;</span> <a name="l00030"></a>00030 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00014"></a>00014 <a name="l00031"></a>00031 <span class="keyword">using namespace </span>std;
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;sys/types.h&gt;</span> <span class="comment">//wait</span> <a name="l00032"></a>00032
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;sys/wait.h&gt;</span> <span class="comment">//wait</span> <a name="l00033"></a>00033 <span class="comment">/* Define Number of receivers */</span>
<a name="l00017"></a>00017 <a name="l00034"></a><a class="code" href="mainReceiver_8cpp.html#aa55605484e783ee738b6f4e7b251cbee">00034</a> <span class="preprocessor">#define NUM_RECEIVERS 1</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;string&gt;</span> <a name="l00035"></a>00035 <span class="preprocessor"></span>
<a name="l00019"></a>00019 <span class="keyword">using namespace </span>std; <a name="l00036"></a><a class="code" href="mainReceiver_8cpp.html#a2a4a8ad299b56605e3ee1ebb0950ac5c">00036</a> <span class="preprocessor">#define START_TCP_PORT 1954</span>
<a name="l00020"></a>00020 <a name="l00037"></a>00037 <span class="preprocessor"></span>
<a name="l00021"></a><a class="code" href="mainReceiver_8cpp.html#aa55605484e783ee738b6f4e7b251cbee">00021</a> <span class="preprocessor">#define NUM_RECEIVERS 1</span> <a name="l00038"></a><a class="code" href="mainReceiver_8cpp.html#aeac6a4b86729a7e07100fb58600d6481">00038</a> <span class="preprocessor">#define PRINT_IN_COLOR(c,f, ...) printf (&quot;\033[%dm&quot; f RESET, 30 + c+1, ##__VA_ARGS__)</span>
<a name="l00022"></a><a class="code" href="mainReceiver_8cpp.html#a2a4a8ad299b56605e3ee1ebb0950ac5c">00022</a> <span class="preprocessor"></span><span class="preprocessor">#define START_TCP_PORT 1954</span> <a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00023"></a><a class="code" href="mainReceiver_8cpp.html#aeac6a4b86729a7e07100fb58600d6481">00023</a> <span class="preprocessor"></span><span class="preprocessor">#define PRINT_IN_COLOR(c,f, ...) printf (&quot;\033[%dm&quot; f RESET, 30 + c+1, ##__VA_ARGS__)</span> <a name="l00040"></a>00040 <span class="comment">/* List of process IDs of all child receiver processes */</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span> <a name="l00041"></a><a class="code" href="mainReceiver_8cpp.html#adbe4cfbc29a961cebc69041b896c7304">00041</a> pid_t <a class="code" href="mainReceiver_8cpp.html#adbe4cfbc29a961cebc69041b896c7304">childPid</a>[<a class="code" href="mainReceiver_8cpp.html#aa55605484e783ee738b6f4e7b251cbee">NUM_RECEIVERS</a>];
<a name="l00025"></a>00025 <a name="l00043"></a><a class="code" href="mainReceiver_8cpp.html#a0d26a166bb416ff34512de6fe9e098bd">00043</a> <span class="keywordtype">bool</span> <a class="code" href="mainReceiver_8cpp.html#a0d26a166bb416ff34512de6fe9e098bd">keeprunning</a>;
<a name="l00026"></a><a class="code" href="mainReceiver_8cpp.html#adbe4cfbc29a961cebc69041b896c7304">00026</a> pid_t <a class="code" href="mainReceiver_8cpp.html#adbe4cfbc29a961cebc69041b896c7304">childPid</a>[<a class="code" href="mainReceiver_8cpp.html#aa55605484e783ee738b6f4e7b251cbee">NUM_RECEIVERS</a>]; <a name="l00045"></a><a class="code" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">00045</a> <span class="keywordtype">int</span> <a class="code" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">numrunning</a>;
<a name="l00027"></a><a class="code" href="mainReceiver_8cpp.html#a0d26a166bb416ff34512de6fe9e098bd">00027</a> <span class="keywordtype">bool</span> <a class="code" href="mainReceiver_8cpp.html#a0d26a166bb416ff34512de6fe9e098bd">keeprunning</a>;
<a name="l00028"></a><a class="code" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">00028</a> <span class="keywordtype">int</span> <a class="code" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">numrunning</a>;
<a name="l00029"></a>00029
<a name="l00030"></a>00030
<a name="l00031"></a>00031
<a name="l00032"></a><a class="code" href="mainReceiver_8cpp.html#acdb2aab1ff93ceea5eb097337a200008">00032</a> <span class="keywordtype">void</span> <a class="code" href="mainReceiver_8cpp.html#acdb2aab1ff93ceea5eb097337a200008">sigChildExitedHandler</a>(<span class="keywordtype">int</span> sig) {
<a name="l00033"></a>00033 pid_t pid = wait(NULL);
<a name="l00034"></a>00034 bprintf(GRAY, <span class="stringliteral">&quot;\nChild Process Pid %d exited.\n&quot;</span>, pid);
<a name="l00035"></a>00035 <a class="code" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">numrunning</a>--;
<a name="l00036"></a>00036 }
<a name="l00037"></a>00037
<a name="l00038"></a>00038
<a name="l00039"></a><a class="code" href="mainReceiver_8cpp.html#ac72dad9b593583bd4bf508a979c00f70">00039</a> <span class="keywordtype">void</span> <a class="code" href="mainReceiver_8cpp.html#ac72dad9b593583bd4bf508a979c00f70">sigInterruptHandler</a>(<span class="keywordtype">int</span> p){
<a name="l00040"></a>00040 <a class="code" href="mainReceiver_8cpp.html#a0d26a166bb416ff34512de6fe9e098bd">keeprunning</a> = <span class="keyword">false</span>;
<a name="l00041"></a>00041 }
<a name="l00042"></a>00042
<a name="l00043"></a><a class="code" href="mainReceiver_8cpp.html#a1ec49915ff49957985ebfe6ccc5cd1b3">00043</a> <span class="keywordtype">int</span> <a class="code" href="mainReceiver_8cpp.html#a1ec49915ff49957985ebfe6ccc5cd1b3">StartAcq</a>(<span class="keywordtype">char</span>* filepath, <span class="keywordtype">char</span>* filename, uint64_t fileindex, uint32_t datasize, <span class="keywordtype">void</span>*p){
<a name="l00044"></a>00044 bprintf(BLUE, <span class="stringliteral">&quot;#### StartAcq: filepath:%s filename:%s fileindex:%llu datasize:%u ####\n&quot;</span>,
<a name="l00045"></a>00045 filepath, filename, fileindex, datasize);
<a name="l00046"></a>00046 <a name="l00046"></a>00046
<a name="l00047"></a>00047 bprintf(BLUE, <span class="stringliteral">&quot;--StartAcq: returning 0\n&quot;</span>); <a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="keywordflow">return</span> 0; <a name="l00055"></a><a class="code" href="mainReceiver_8cpp.html#acdb2aab1ff93ceea5eb097337a200008">00055</a> <span class="keywordtype">void</span> <a class="code" href="mainReceiver_8cpp.html#acdb2aab1ff93ceea5eb097337a200008">sigChildExitedHandler</a>(<span class="keywordtype">int</span> sig) {
<a name="l00049"></a>00049 } <a name="l00056"></a>00056 pid_t pid = wait(NULL);
<a name="l00050"></a>00050 <a name="l00057"></a>00057 bprintf(GRAY, <span class="stringliteral">&quot;\nChild Process Pid %d exited.\n&quot;</span>, pid);
<a name="l00051"></a>00051 <a name="l00058"></a>00058 <a class="code" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">numrunning</a>--;
<a name="l00052"></a><a class="code" href="mainReceiver_8cpp.html#a013a16dd72eca4216a42196c4d9c0335">00052</a> <span class="keywordtype">void</span> <a class="code" href="mainReceiver_8cpp.html#a013a16dd72eca4216a42196c4d9c0335">AcquisitionFinished</a>(uint64_t frames, <span class="keywordtype">void</span>*p){ <a name="l00059"></a>00059 }
<a name="l00053"></a>00053 bprintf(BLUE, <span class="stringliteral">&quot;#### AcquisitionFinished: frames:%llu ####\n&quot;</span>,frames);
<a name="l00054"></a>00054 }
<a name="l00055"></a>00055
<a name="l00056"></a>00056
<a name="l00057"></a><a class="code" href="mainReceiver_8cpp.html#a68d89c0f64de361efc31ae21513b86cb">00057</a> <span class="keywordtype">void</span> <a class="code" href="mainReceiver_8cpp.html#a68d89c0f64de361efc31ae21513b86cb">GetData</a>(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp,
<a name="l00058"></a>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,
<a name="l00059"></a>00059 <span class="keywordtype">char</span>* datapointer, uint32_t datasize, <span class="keywordtype">void</span>* p){
<a name="l00060"></a>00060 <a name="l00060"></a>00060
<a name="l00061"></a>00061 <a class="code" href="mainReceiver_8cpp.html#aeac6a4b86729a7e07100fb58600d6481">PRINT_IN_COLOR</a> (xCoord, <a name="l00065"></a><a class="code" href="mainReceiver_8cpp.html#ac72dad9b593583bd4bf508a979c00f70">00065</a> <span class="keywordtype">void</span> <a class="code" href="mainReceiver_8cpp.html#ac72dad9b593583bd4bf508a979c00f70">sigInterruptHandler</a>(<span class="keywordtype">int</span> p){
<a name="l00062"></a>00062 <span class="stringliteral">&quot;#### %d GetData: ####\n&quot;</span> <a name="l00066"></a>00066 <a class="code" href="mainReceiver_8cpp.html#a0d26a166bb416ff34512de6fe9e098bd">keeprunning</a> = <span class="keyword">false</span>;
<a name="l00063"></a>00063 <span class="stringliteral">&quot;frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu\t\ttimestamp: %llu\t\tmodId: %u\t\t&quot;</span> <a name="l00067"></a>00067 }
<a name="l00064"></a>00064 <span class="stringliteral">&quot;xCoord: %u\t\tyCoord: %u\t\tzCoord: %u\t\tdebug: %u\t\troundRNumber: %u\t\tdetType: %u\t\t&quot;</span> <a name="l00068"></a>00068
<a name="l00065"></a>00065 <span class="stringliteral">&quot;version: %u\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n&quot;</span>, <a name="l00080"></a><a class="code" href="mainReceiver_8cpp.html#a1ec49915ff49957985ebfe6ccc5cd1b3">00080</a> <span class="keywordtype">int</span> <a class="code" href="mainReceiver_8cpp.html#a1ec49915ff49957985ebfe6ccc5cd1b3">StartAcq</a>(<span class="keywordtype">char</span>* filepath, <span class="keywordtype">char</span>* filename, uint64_t fileindex, uint32_t datasize, <span class="keywordtype">void</span>*p){
<a name="l00066"></a>00066 xCoord, frameNumber, expLength, packetNumber, bunchId, timestamp, modId, <a name="l00081"></a>00081 bprintf(BLUE, <span class="stringliteral">&quot;#### StartAcq: filepath:%s filename:%s fileindex:%llu datasize:%u ####\n&quot;</span>,
<a name="l00067"></a>00067 xCoord, yCoord, zCoord, debug, roundRNumber, detType, version, <a name="l00082"></a>00082 filepath, filename, fileindex, datasize);
<a name="l00068"></a>00068 ((uint8_t)(*((uint8_t*)(datapointer)))), datasize); <a name="l00083"></a>00083
<a name="l00069"></a>00069 <a name="l00084"></a>00084 bprintf(BLUE, <span class="stringliteral">&quot;--StartAcq: returning 0\n&quot;</span>);
<a name="l00070"></a>00070 } <a name="l00085"></a>00085 <span class="keywordflow">return</span> 0;
<a name="l00071"></a>00071 <a name="l00086"></a>00086 }
<a name="l00072"></a>00072 <a name="l00087"></a>00087
<a name="l00073"></a>00073 <a name="l00093"></a><a class="code" href="mainReceiver_8cpp.html#a013a16dd72eca4216a42196c4d9c0335">00093</a> <span class="keywordtype">void</span> <a class="code" href="mainReceiver_8cpp.html#a013a16dd72eca4216a42196c4d9c0335">AcquisitionFinished</a>(uint64_t frames, <span class="keywordtype">void</span>*p){
<a name="l00074"></a><a class="code" href="mainReceiver_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97">00074</a> <span class="keywordtype">int</span> <a class="code" href="mainClient_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) { <a name="l00094"></a>00094 bprintf(BLUE, <span class="stringliteral">&quot;#### AcquisitionFinished: frames:%llu ####\n&quot;</span>,frames);
<a name="l00075"></a>00075 <a name="l00095"></a>00095 }
<a name="l00076"></a>00076 <span class="comment">// set default child process pid values</span> <a name="l00096"></a>00096
<a name="l00077"></a>00077 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="mainReceiver_8cpp.html#aa55605484e783ee738b6f4e7b251cbee">NUM_RECEIVERS</a>; ++i) <a name="l00117"></a><a class="code" href="mainReceiver_8cpp.html#a68d89c0f64de361efc31ae21513b86cb">00117</a> <span class="keywordtype">void</span> <a class="code" href="mainReceiver_8cpp.html#a68d89c0f64de361efc31ae21513b86cb">GetData</a>(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp,
<a name="l00078"></a>00078 <a class="code" href="mainReceiver_8cpp.html#adbe4cfbc29a961cebc69041b896c7304">childPid</a>[i] = -1; <a name="l00118"></a>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,
<a name="l00079"></a>00079 <a name="l00119"></a>00119 <span class="keywordtype">char</span>* datapointer, uint32_t datasize, <span class="keywordtype">void</span>* p){
<a name="l00080"></a>00080 <a class="code" href="mainReceiver_8cpp.html#a0d26a166bb416ff34512de6fe9e098bd">keeprunning</a> = <span class="keyword">true</span>; <a name="l00120"></a>00120
<a name="l00081"></a>00081 <a class="code" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">numrunning</a> = 0; <a name="l00121"></a>00121 <a class="code" href="mainReceiver_8cpp.html#aeac6a4b86729a7e07100fb58600d6481">PRINT_IN_COLOR</a> (xCoord,
<a name="l00082"></a>00082 <a name="l00122"></a>00122 <span class="stringliteral">&quot;#### %d GetData: ####\n&quot;</span>
<a name="l00083"></a>00083 <span class="comment">// Catch signal SIGINT to close files and call destructors properly</span> <a name="l00123"></a>00123 <span class="stringliteral">&quot;frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu\t\ttimestamp: %llu\t\tmodId: %u\t\t&quot;</span>
<a name="l00084"></a>00084 <span class="keyword">struct </span>sigaction sa; <a name="l00124"></a>00124 <span class="stringliteral">&quot;xCoord: %u\t\tyCoord: %u\t\tzCoord: %u\t\tdebug: %u\t\troundRNumber: %u\t\tdetType: %u\t\t&quot;</span>
<a name="l00085"></a>00085 sa.sa_flags=0; <span class="comment">// no flags</span> <a name="l00125"></a>00125 <span class="stringliteral">&quot;version: %u\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n&quot;</span>,
<a name="l00086"></a>00086 sa.sa_handler=<a class="code" href="mainReceiver_8cpp.html#ac72dad9b593583bd4bf508a979c00f70">sigInterruptHandler</a>; <span class="comment">// handler function</span> <a name="l00126"></a>00126 xCoord, frameNumber, expLength, packetNumber, bunchId, timestamp, modId,
<a name="l00087"></a>00087 sigemptyset(&amp;sa.sa_mask); <span class="comment">// dont block additional signals during invocation of handler</span> <a name="l00127"></a>00127 xCoord, yCoord, zCoord, debug, roundRNumber, detType, version,
<a name="l00088"></a>00088 <span class="keywordflow">if</span> (sigaction(SIGINT, &amp;sa, NULL) == -1) { <a name="l00128"></a>00128 ((uint8_t)(*((uint8_t*)(datapointer)))), datasize);
<a name="l00089"></a>00089 bprintf(RED, <span class="stringliteral">&quot;Could not set handler function for SIGINT\n&quot;</span>); <a name="l00129"></a>00129
<a name="l00090"></a>00090 } <a name="l00130"></a>00130 }
<a name="l00091"></a>00091
<a name="l00092"></a>00092 <span class="comment">// wait for all the SIGCHILD signals</span>
<a name="l00093"></a>00093 <span class="keyword">struct </span>sigaction asa;
<a name="l00094"></a>00094 asa.sa_flags=0; <span class="comment">// no flags</span>
<a name="l00095"></a>00095 asa.sa_handler=<a class="code" href="mainReceiver_8cpp.html#acdb2aab1ff93ceea5eb097337a200008">sigChildExitedHandler</a>; <span class="comment">// handler function</span>
<a name="l00096"></a>00096 sigemptyset(&amp;asa.sa_mask); <span class="comment">// dont block additional signals during invocation of handler</span>
<a name="l00097"></a>00097 <span class="keywordflow">if</span> (sigaction(SIGCHLD, &amp;asa, NULL) == -1) {
<a name="l00098"></a>00098 bprintf(RED, <span class="stringliteral">&quot;Could not set handler function for SICHILD\n&quot;</span>);
<a name="l00099"></a>00099 }
<a name="l00100"></a>00100
<a name="l00101"></a>00101
<a name="l00102"></a>00102 <span class="keywordtype">int</span> narg= 3;
<a name="l00103"></a>00103
<a name="l00104"></a>00104 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; NUM_RECEIVERS; ++i) {
<a name="l00105"></a>00105
<a name="l00106"></a>00106 <a class="code" href="mainReceiver_8cpp.html#adbe4cfbc29a961cebc69041b896c7304">childPid</a>[i] = fork();
<a name="l00107"></a>00107
<a name="l00108"></a>00108 <span class="comment">// fork failed</span>
<a name="l00109"></a>00109 <span class="keywordflow">if</span> (<a class="code" href="mainReceiver_8cpp.html#adbe4cfbc29a961cebc69041b896c7304">childPid</a>[i] &lt; 0) {
<a name="l00110"></a>00110 bprintf(RED,<span class="stringliteral">&quot;fork() failed. Killing all the receiver objects\n&quot;</span>);
<a name="l00111"></a>00111 <span class="keyword">raise</span>(SIGINT);
<a name="l00112"></a>00112 }
<a name="l00113"></a>00113
<a name="l00114"></a>00114 <span class="comment">// child process</span>
<a name="l00115"></a>00115 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="mainReceiver_8cpp.html#adbe4cfbc29a961cebc69041b896c7304">childPid</a>[i] == 0) {
<a name="l00116"></a>00116 bprintf(BLUE,<span class="stringliteral">&quot;Starting Receiver %d with pid %ld\n&quot;</span>, i, (<span class="keywordtype">long</span>)getpid());
<a name="l00117"></a>00117
<a name="l00118"></a>00118 <span class="keywordtype">char</span> temp[10];
<a name="l00119"></a>00119 sprintf(temp,<span class="stringliteral">&quot;%d&quot;</span>,<a class="code" href="mainReceiver_8cpp.html#a2a4a8ad299b56605e3ee1ebb0950ac5c">START_TCP_PORT</a> + i);
<a name="l00120"></a>00120 <span class="keywordtype">char</span>* args[] = {(<span class="keywordtype">char</span>*)<span class="stringliteral">&quot;ignored&quot;</span>, (<span class="keywordtype">char</span>*)<span class="stringliteral">&quot;--rx_tcpport&quot;</span>, temp};
<a name="l00121"></a>00121 <span class="keywordtype">int</span> ret = slsReceiverDefs::OK;
<a name="l00122"></a>00122 <a class="code" href="classslsReceiverUsers.html" title="Class for implementing the SLS data receiver in the users application. Callbacks...">slsReceiverUsers</a> *receiver = <span class="keyword">new</span> <a class="code" href="classslsReceiverUsers.html" title="Class for implementing the SLS data receiver in the users application. Callbacks...">slsReceiverUsers</a>(narg, args, ret);
<a name="l00123"></a>00123 <span class="keywordflow">if</span>(ret==slsReceiverDefs::FAIL){
<a name="l00124"></a>00124 <span class="keyword">delete</span> receiver;
<a name="l00125"></a>00125 exit(EXIT_FAILURE);
<a name="l00126"></a>00126 }
<a name="l00127"></a>00127
<a name="l00128"></a>00128 <span class="comment">//register callbacks</span>
<a name="l00129"></a>00129 <span class="comment">//remember to set file write enable to 0 (using the client) if we should not write files and</span>
<a name="l00130"></a>00130 <span class="comment">//you will write data using the callbacks</span>
<a name="l00131"></a>00131 <a name="l00131"></a>00131
<a name="l00144"></a>00144 bprintf(BLUE, <span class="stringliteral">&quot;Registering StartAcq()\n&quot;</span>); <a name="l00132"></a>00132
<a name="l00145"></a>00145 receiver-&gt;<a class="code" href="classslsReceiverUsers.html#a5ffca5973503b62cefb4a5e3b8f89dfb">registerCallBackStartAcquisition</a>(<a class="code" href="mainReceiver_8cpp.html#a1ec49915ff49957985ebfe6ccc5cd1b3">StartAcq</a>, NULL); <a name="l00140"></a><a class="code" href="mainReceiver_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97">00140</a> <span class="keywordtype">int</span> <a class="code" href="mainClient_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) {
<a name="l00146"></a>00146 <a name="l00141"></a>00141
<a name="l00152"></a>00152 bprintf(BLUE, <span class="stringliteral">&quot;Registering AcquisitionFinished()\n&quot;</span>); <a name="l00143"></a>00143 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="mainReceiver_8cpp.html#aa55605484e783ee738b6f4e7b251cbee">NUM_RECEIVERS</a>; ++i)
<a name="l00153"></a>00153 receiver-&gt;<a class="code" href="classslsReceiverUsers.html#adacc5da9dd812d62936ac456a73c0738">registerCallBackAcquisitionFinished</a>(<a class="code" href="mainReceiver_8cpp.html#a013a16dd72eca4216a42196c4d9c0335">AcquisitionFinished</a>, NULL); <a name="l00144"></a>00144 <a class="code" href="mainReceiver_8cpp.html#adbe4cfbc29a961cebc69041b896c7304">childPid</a>[i] = -1;
<a name="l00154"></a>00154 <a name="l00145"></a>00145 <a class="code" href="mainReceiver_8cpp.html#a0d26a166bb416ff34512de6fe9e098bd">keeprunning</a> = <span class="keyword">true</span>;
<a name="l00174"></a>00174 bprintf(BLUE, <span class="stringliteral">&quot;Registering GetData() \n&quot;</span>); <a name="l00146"></a>00146 <a class="code" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">numrunning</a> = 0;
<a name="l00175"></a>00175 receiver-&gt;<a class="code" href="classslsReceiverUsers.html#af3d6773f9da090a236bb8e2e6124ed49">registerCallBackRawDataReady</a>(<a class="code" href="mainReceiver_8cpp.html#a68d89c0f64de361efc31ae21513b86cb">GetData</a>,NULL); <a name="l00147"></a>00147
<a name="l00176"></a>00176 <a name="l00149"></a>00149 <span class="keyword">struct </span>sigaction sa;
<a name="l00177"></a>00177 <a name="l00150"></a>00150 sa.sa_flags=0; <span class="comment">// no flags</span>
<a name="l00178"></a>00178 <span class="comment">//start tcp server thread</span> <a name="l00151"></a>00151 sa.sa_handler=<a class="code" href="mainReceiver_8cpp.html#ac72dad9b593583bd4bf508a979c00f70">sigInterruptHandler</a>; <span class="comment">// handler function</span>
<a name="l00179"></a>00179 <span class="keywordflow">if</span> (receiver-&gt;<a class="code" href="classslsReceiverUsers.html#aef40b4987367b8a0116bcb66534dd7b7">start</a>() == slsReceiverDefs::FAIL){ <a name="l00152"></a>00152 sigemptyset(&amp;sa.sa_mask); <span class="comment">// dont block additional signals during invocation of handler</span>
<a name="l00180"></a>00180 <span class="keyword">delete</span> receiver; <a name="l00153"></a>00153 <span class="keywordflow">if</span> (sigaction(SIGINT, &amp;sa, NULL) == -1) {
<a name="l00181"></a>00181 exit(EXIT_FAILURE); <a name="l00154"></a>00154 bprintf(RED, <span class="stringliteral">&quot;Could not set handler function for SIGINT\n&quot;</span>);
<a name="l00182"></a>00182 } <a name="l00155"></a>00155 }
<a name="l00183"></a>00183 <a name="l00156"></a>00156
<a name="l00184"></a>00184 <span class="keywordflow">while</span>(<a class="code" href="mainReceiver_8cpp.html#a0d26a166bb416ff34512de6fe9e098bd">keeprunning</a>) <a name="l00158"></a>00158 <span class="keyword">struct </span>sigaction asa;
<a name="l00185"></a>00185 usleep(1 * 1000 * 1000); <a name="l00159"></a>00159 asa.sa_flags=0; <span class="comment">// no flags</span>
<a name="l00186"></a>00186 <span class="keyword">delete</span> receiver; <a name="l00160"></a>00160 asa.sa_handler=<a class="code" href="mainReceiver_8cpp.html#acdb2aab1ff93ceea5eb097337a200008">sigChildExitedHandler</a>; <span class="comment">// handler function</span>
<a name="l00187"></a>00187 exit(EXIT_SUCCESS); <a name="l00161"></a>00161 sigemptyset(&amp;asa.sa_mask); <span class="comment">// dont block additional signals during invocation of handler</span>
<a name="l00188"></a>00188 } <a name="l00162"></a>00162 <span class="keywordflow">if</span> (sigaction(SIGCHLD, &amp;asa, NULL) == -1) {
<a name="l00189"></a>00189 <a name="l00163"></a>00163 bprintf(RED, <span class="stringliteral">&quot;Could not set handler function for SICHILD\n&quot;</span>);
<a name="l00190"></a>00190 <span class="comment">// parent process</span> <a name="l00164"></a>00164 }
<a name="l00191"></a>00191 <span class="keywordflow">else</span> <a name="l00165"></a>00165
<a name="l00192"></a>00192 <a class="code" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">numrunning</a>++; <a name="l00166"></a>00166
<a name="l00193"></a>00193 <a name="l00168"></a>00168 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; NUM_RECEIVERS; ++i) {
<a name="l00194"></a>00194 } <a name="l00169"></a>00169
<a name="l00195"></a>00195 <a name="l00171"></a>00171 <a class="code" href="mainReceiver_8cpp.html#adbe4cfbc29a961cebc69041b896c7304">childPid</a>[i] = fork();
<a name="l00196"></a>00196 cout &lt;&lt; <span class="stringliteral">&quot;Ready ... &quot;</span> &lt;&lt; endl; <a name="l00172"></a>00172
<a name="l00197"></a>00197 bprintf(GRAY, <span class="stringliteral">&quot;\n[ Press \&apos;Ctrl+c\&apos; to exit ]\n&quot;</span>); <a name="l00174"></a>00174 <span class="keywordflow">if</span> (<a class="code" href="mainReceiver_8cpp.html#adbe4cfbc29a961cebc69041b896c7304">childPid</a>[i] &lt; 0) {
<a name="l00198"></a>00198 <a name="l00175"></a>00175 bprintf(RED,<span class="stringliteral">&quot;fork() failed. Killing all the receiver objects\n&quot;</span>);
<a name="l00199"></a>00199 <span class="comment">// wait for all child processes to exit</span> <a name="l00176"></a>00176 <span class="keyword">raise</span>(SIGINT);
<a name="l00200"></a>00200 <span class="keywordflow">while</span>(<a class="code" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">numrunning</a>) <a name="l00177"></a>00177 }
<a name="l00201"></a>00201 usleep(1 * 1000 * 1000); <a name="l00178"></a>00178
<a name="l00202"></a>00202 cout &lt;&lt; <span class="stringliteral">&quot;Goodbye!&quot;</span> &lt;&lt; endl; <a name="l00180"></a>00180 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="mainReceiver_8cpp.html#adbe4cfbc29a961cebc69041b896c7304">childPid</a>[i] == 0) {
<a name="l00203"></a>00203 <span class="keywordflow">return</span> 0; <a name="l00181"></a>00181 bprintf(BLUE,<span class="stringliteral">&quot;Starting Receiver %d with pid %ld\n&quot;</span>, i, (<span class="keywordtype">long</span>)getpid());
<a name="l00204"></a>00204 } <a name="l00182"></a>00182
<a name="l00183"></a>00183 <span class="keywordtype">char</span> temp[10];
<a name="l00184"></a>00184 sprintf(temp,<span class="stringliteral">&quot;%d&quot;</span>,<a class="code" href="mainReceiver_8cpp.html#a2a4a8ad299b56605e3ee1ebb0950ac5c">START_TCP_PORT</a> + i);
<a name="l00185"></a>00185 <span class="keywordtype">char</span>* args[] = {(<span class="keywordtype">char</span>*)<span class="stringliteral">&quot;ignored&quot;</span>, (<span class="keywordtype">char</span>*)<span class="stringliteral">&quot;--rx_tcpport&quot;</span>, temp};
<a name="l00186"></a>00186 <span class="keywordtype">int</span> ret = slsReceiverDefs::OK;
<a name="l00189"></a>00189 <a class="code" href="classslsReceiverUsers.html" title="Class for implementing the SLS data receiver in the users application. Callbacks...">slsReceiverUsers</a> *receiver = <span class="keyword">new</span> <a class="code" href="classslsReceiverUsers.html" title="Class for implementing the SLS data receiver in the users application. Callbacks...">slsReceiverUsers</a>(3, args, ret);
<a name="l00190"></a>00190 <span class="keywordflow">if</span>(ret==slsReceiverDefs::FAIL){
<a name="l00191"></a>00191 <span class="keyword">delete</span> receiver;
<a name="l00192"></a>00192 exit(EXIT_FAILURE);
<a name="l00193"></a>00193 }
<a name="l00194"></a>00194
<a name="l00199"></a>00199 bprintf(BLUE, <span class="stringliteral">&quot;Registering StartAcq()\n&quot;</span>);
<a name="l00200"></a>00200 receiver-&gt;<a class="code" href="classslsReceiverUsers.html#a5ffca5973503b62cefb4a5e3b8f89dfb">registerCallBackStartAcquisition</a>(<a class="code" href="mainReceiver_8cpp.html#a1ec49915ff49957985ebfe6ccc5cd1b3">StartAcq</a>, NULL);
<a name="l00201"></a>00201
<a name="l00203"></a>00203 bprintf(BLUE, <span class="stringliteral">&quot;Registering AcquisitionFinished()\n&quot;</span>);
<a name="l00204"></a>00204 receiver-&gt;<a class="code" href="classslsReceiverUsers.html#adacc5da9dd812d62936ac456a73c0738">registerCallBackAcquisitionFinished</a>(<a class="code" href="mainReceiver_8cpp.html#a013a16dd72eca4216a42196c4d9c0335">AcquisitionFinished</a>, NULL);
<a name="l00205"></a>00205 <a name="l00205"></a>00205
<a name="l00206"></a>00206 <span class="comment">/* - Call back for raw data */</span>
<a name="l00207"></a>00207 bprintf(BLUE, <span class="stringliteral">&quot;Registering GetData() \n&quot;</span>);
<a name="l00208"></a>00208 receiver-&gt;<a class="code" href="classslsReceiverUsers.html#af3d6773f9da090a236bb8e2e6124ed49">registerCallBackRawDataReady</a>(<a class="code" href="mainReceiver_8cpp.html#a68d89c0f64de361efc31ae21513b86cb">GetData</a>,NULL);
<a name="l00209"></a>00209
<a name="l00210"></a>00210
<a name="l00212"></a>00212 <span class="keywordflow">if</span> (receiver-&gt;<a class="code" href="classslsReceiverUsers.html#aef40b4987367b8a0116bcb66534dd7b7">start</a>() == slsReceiverDefs::FAIL){
<a name="l00213"></a>00213 <span class="keyword">delete</span> receiver;
<a name="l00214"></a>00214 exit(EXIT_FAILURE);
<a name="l00215"></a>00215 }
<a name="l00216"></a>00216
<a name="l00218"></a>00218 <span class="keywordflow">while</span>(<a class="code" href="mainReceiver_8cpp.html#a0d26a166bb416ff34512de6fe9e098bd">keeprunning</a>)
<a name="l00219"></a>00219 usleep(1 * 1000 * 1000);
<a name="l00221"></a>00221 <span class="keyword">delete</span> receiver;
<a name="l00222"></a>00222 exit(EXIT_SUCCESS);
<a name="l00223"></a>00223 }
<a name="l00224"></a>00224
<a name="l00226"></a>00226 <span class="keywordflow">else</span>
<a name="l00227"></a>00227 <a class="code" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">numrunning</a>++;
<a name="l00228"></a>00228
<a name="l00229"></a>00229 }
<a name="l00230"></a>00230
<a name="l00232"></a>00232 cout &lt;&lt; <span class="stringliteral">&quot;Ready ... &quot;</span> &lt;&lt; endl;
<a name="l00233"></a>00233 bprintf(GRAY, <span class="stringliteral">&quot;\n[ Press \&apos;Ctrl+c\&apos; to exit ]\n&quot;</span>);
<a name="l00234"></a>00234
<a name="l00236"></a>00236 <span class="keywordflow">while</span>(<a class="code" href="mainReceiver_8cpp.html#a9a5e6d0743c685444bb74ecfbb0e78c4">numrunning</a>)
<a name="l00237"></a>00237 usleep(1 * 1000 * 1000);
<a name="l00238"></a>00238 cout &lt;&lt; <span class="stringliteral">&quot;Goodbye!&quot;</span> &lt;&lt; endl;
<a name="l00239"></a>00239 <span class="keywordflow">return</span> 0;
<a name="l00240"></a>00240 }
<a name="l00241"></a>00241
</pre></div></div> </pre></div></div>
<!--- window showing the filter options --> <!--- window showing the filter options -->
<div id="MSearchSelectWindow" <div id="MSearchSelectWindow"
@ -225,7 +204,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -67,7 +67,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -290,7 +290,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -67,7 +67,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

View File

@ -93,7 +93,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe> </iframe>
</div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 24 Aug 2017 by&nbsp; <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Aug 2017 by&nbsp;
<a href="http://www.doxygen.org/index.html"> <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body> </body>

Binary file not shown.

Binary file not shown.

View File

@ -4,75 +4,92 @@
This file is an example of how to implement the slsDetectorUsers class This file is an example of how to implement the slsDetectorUsers class
You can compile it linking it to the slsDetector library 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 where,
gcc mainClient.cpp -L . -l SlsDetector -lm -pthread -o users
*/ 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 <iostream>
#include "slsDetectorUsers.h" #include "slsDetectorUsers.h"
#include "detectorData.h" #include "detectorData.h"
#include <iostream>
#include <cstdlib> #include <cstdlib>
/** 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) 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 main(int argc, char **argv) {
int id=0; /** - if specified, set ID from argv[3] */
/** if specified, argv[3] is used as detector ID (default is 0)*/ int id=0;
if (argc>=4) if (argc>=4)
id=atoi(argv[3]); id=atoi(argv[3]);
/** - slsDetectorUsers Object is instantiated with appropriate ID */
/** slsDetectorUsers is instantiated */ slsDetectorUsers *pDetector = new slsDetectorUsers (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 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){ if (argc>=2){
pDetector->readConfigurationFile(argv[1]); pDetector->readConfigurationFile(argv[1]);
cout<<"Detector configured" << endl; std::cout << "Detector configured" << std::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;
}
/** load detector settings */
if (argc>=3){
pDetector->retrieveDetectorSetup(argv[2]);
cout<<"Detector measurement set-up done" << endl;
}
/** start measurement */
pDetector->startMeasurement();
cout<<"started measurement"<<endl;
/* while (1) {
usleep(100000);
status = pDetector->getDetectorStatus();
if (status == 0 || status == 1|| status == 3)
break;
}*/
cout<<"measurement finished"<<endl;
/** returning when acquisition is finished or data are avilable */
delete pDetector; /** - registering data callback */
pDetector->registerDataCallback(&dataCallback, NULL);
/** - if receiver exists, enable data streaming from receiver to get the data */
pDetector->enableDataStreamingFromReceiver(1);
return 0;
/** - 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;
} }

View File

@ -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 "sls_receiver_defs.h"
#include "slsReceiverUsers.h" #include "slsReceiverUsers.h"
@ -8,52 +23,97 @@
#include <string.h> #include <string.h>
#include <signal.h> //SIGINT #include <signal.h> //SIGINT
#include <cstdlib> //system #include <cstdlib> //system
//#include "utilities.h" //#include "utilities.h"
//#include "logger.h" //#include "logger.h"
#include <sys/types.h> //wait #include <sys/types.h> //wait
#include <sys/wait.h> //wait #include <sys/wait.h> //wait
#include <string> #include <string>
using namespace std; using namespace std;
/* Define Number of receivers */
#define NUM_RECEIVERS 1 #define NUM_RECEIVERS 1
/** Define TCP Port of First Receiver, others are incremented by 1 */
#define START_TCP_PORT 1954 #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__) #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]; pid_t childPid[NUM_RECEIVERS];
/** Variable is true to continue running, set to false upon interrupt */
bool keeprunning; bool keeprunning;
/** Variable indicating number of child processes running */
int numrunning; 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) { void sigChildExitedHandler(int sig) {
pid_t pid = wait(NULL); pid_t pid = wait(NULL);
bprintf(GRAY, "\nChild Process Pid %d exited.\n", pid); bprintf(GRAY, "\nChild Process Pid %d exited.\n", pid);
numrunning--; numrunning--;
} }
/**
* Control+C Interrupt Handler
* Sets the variable keeprunning to false, to let all the processes know to exit properly
*/
void sigInterruptHandler(int p){ void sigInterruptHandler(int p){
keeprunning = false; 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){ 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", bprintf(BLUE, "#### StartAcq: filepath:%s filename:%s fileindex:%llu datasize:%u ####\n",
filepath, filename, fileindex, datasize); filepath, filename, fileindex, datasize);
bprintf(BLUE, "--StartAcq: returning 0\n"); bprintf(BLUE, "--StartAcq: returning 0\n");
return 0; return 0;
} }
/**
* Acquisition Finished Call back
* @param frames Number of frames caught
* @param p pointer to object
*/
void AcquisitionFinished(uint64_t frames, void*p){ 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, 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, 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){ 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[]) { 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) for (int i = 0; i < NUM_RECEIVERS; ++i)
childPid[i] = -1; childPid[i] = -1;
keeprunning = true; keeprunning = true;
numrunning = 0; 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; struct sigaction sa;
sa.sa_flags=0; // no flags sa.sa_flags=0; // no flags
sa.sa_handler=sigInterruptHandler; // handler function 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"); 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; struct sigaction asa;
asa.sa_flags=0; // no flags asa.sa_flags=0; // no flags
asa.sa_handler=sigChildExitedHandler; // handler function 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) { for (int i = 0; i < NUM_RECEIVERS; ++i) {
/** - fork process to create child process */
childPid[i] = fork(); childPid[i] = fork();
// fork failed /** - if fork failed, raise SIGINT and kill all receiver objects */
if (childPid[i] < 0) { if (childPid[i] < 0) {
bprintf(RED,"fork() failed. Killing all the receiver objects\n"); bprintf(RED,"fork() failed. Killing all the receiver objects\n");
raise(SIGINT); raise(SIGINT);
} }
// child process /** - if child process */
else if (childPid[i] == 0) { else if (childPid[i] == 0) {
bprintf(BLUE,"Starting Receiver %d with pid %ld\n", i, (long)getpid()); 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); sprintf(temp,"%d",START_TCP_PORT + i);
char* args[] = {(char*)"ignored", (char*)"--rx_tcpport", temp}; char* args[] = {(char*)"ignored", (char*)"--rx_tcpport", temp};
int ret = slsReceiverDefs::OK; 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){ if(ret==slsReceiverDefs::FAIL){
delete receiver; delete receiver;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
//register callbacks /** - register callbacks. remember to set file write enable to 0 (using the client)
//remember to set file write enable to 0 (using the client) if we should not write files and if we should not write files and you will write data using the callbacks */
//you will write data using the callbacks
/** /** - Call back for start acquisition */
* 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
*/
bprintf(BLUE, "Registering StartAcq()\n"); bprintf(BLUE, "Registering StartAcq()\n");
receiver->registerCallBackStartAcquisition(StartAcq, NULL); receiver->registerCallBackStartAcquisition(StartAcq, NULL);
/** /** - Call back for acquisition finished */
* Call back for acquisition finished
* callback argument is
* total frames caught
*/
bprintf(BLUE, "Registering AcquisitionFinished()\n"); bprintf(BLUE, "Registering AcquisitionFinished()\n");
receiver->registerCallBackAcquisitionFinished(AcquisitionFinished, NULL); receiver->registerCallBackAcquisitionFinished(AcquisitionFinished, NULL);
/** /* - Call back for raw data */
* 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
*/
bprintf(BLUE, "Registering GetData() \n"); bprintf(BLUE, "Registering GetData() \n");
receiver->registerCallBackRawDataReady(GetData,NULL); receiver->registerCallBackRawDataReady(GetData,NULL);
//start tcp server thread /** - start tcp server thread */
if (receiver->start() == slsReceiverDefs::FAIL){ if (receiver->start() == slsReceiverDefs::FAIL){
delete receiver; delete receiver;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/** - as long as keeprunning is true, usleep for a second */
while(keeprunning) while(keeprunning)
usleep(1 * 1000 * 1000); usleep(1 * 1000 * 1000);
/** - interrupt caught, delete slsReceiverUsers object and exit */
delete receiver; delete receiver;
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
// parent process /** - parent process, increment number of running processes */
else else
numrunning++; numrunning++;
} }
/** - Print Ready and Instructions how to exit */
cout << "Ready ... " << endl; cout << "Ready ... " << endl;
bprintf(GRAY, "\n[ Press \'Ctrl+c\' to exit ]\n"); 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) while(numrunning)
usleep(1 * 1000 * 1000); usleep(1 * 1000 * 1000);
cout << "Goodbye!" << endl; cout << "Goodbye!" << endl;