Files
slsDetectorPackage/pygettingstarted.html
2026-01-12 17:25:47 +00:00

443 lines
31 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./">
<head>
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Getting Started &mdash; slsDetectorPackage 0.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=b86133f3" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=9edc463e" />
<link rel="stylesheet" type="text/css" href="_static/css/extra.css?v=2be88464" />
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=fd6eb6e6"></script>
<script src="_static/sphinx_highlight.js?v=6ffebe34"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Detector" href="pydetector.html" />
<link rel="prev" title="Examples" href="examples.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home">
slsDetectorPackage 0.0.0
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Installation:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="dependencies.html">Dependencies</a></li>
<li class="toctree-l1"><a class="reference internal" href="consuming.html">Consuming slsDetectorPackage</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">how to</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="softwarearchitecture.html">Software Architecture</a></li>
<li class="toctree-l1"><a class="reference internal" href="configcommands.html">Setup Commands</a></li>
<li class="toctree-l1"><a class="reference internal" href="quick_start_guide.html">Quick Start Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="dataformat.html">Detector Image Size and Format</a></li>
<li class="toctree-l1"><a class="reference internal" href="multidet.html">Using multiple detectors</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">C++ API</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="detector.html">Detector</a></li>
<li class="toctree-l1"><a class="reference internal" href="result.html">Result</a></li>
<li class="toctree-l1"><a class="reference internal" href="receiver_api.html">Receiver</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Python API</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Getting Started</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#which-python">Which Python?</a></li>
<li class="toctree-l2"><a class="reference internal" href="#building-from-source">Building from Source</a></li>
<li class="toctree-l2"><a class="reference internal" href="#pythonpath">PYTHONPATH</a></li>
<li class="toctree-l2"><a class="reference internal" href="#which-detector-class-should-i-use">Which detector class should I use?</a></li>
<li class="toctree-l2"><a class="reference internal" href="#hey-there-seems-to-be-two-apis">Hey, there seems to be two APIs?</a></li>
<li class="toctree-l2"><a class="reference internal" href="#accessing-individual-modules">Accessing individual modules</a></li>
<li class="toctree-l2"><a class="reference internal" href="#finding-functions">Finding functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="#finding-out-what-the-function-does">Finding out what the function does</a></li>
<li class="toctree-l2"><a class="reference internal" href="#where-are-the-enums">Where are the ENUMs?</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pydetector.html">Detector</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyenums.html">Enums</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyexamples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyPatternGenerator.html">PatternGenerator</a></li>
<li class="toctree-l1"><a class="reference internal" href="pattern.html">Pattern</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Command line</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="commandline.html">Command line interface</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Developer</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="container_utils.html">ContainerUtils</a></li>
<li class="toctree-l1"><a class="reference internal" href="type_traits.html">TypeTraits</a></li>
<li class="toctree-l1"><a class="reference internal" href="ToString.html">ToString</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Firmware</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="firmware.html">Firmware Upgrade</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Detector Server</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="servers.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="serverupgrade.html">Upgrade</a></li>
<li class="toctree-l1"><a class="reference internal" href="virtualserver.html">Simulators</a></li>
<li class="toctree-l1"><a class="reference internal" href="serverdefaults.html">Default Values</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Detector UDP Header</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="udpheader.html">Format</a></li>
<li class="toctree-l1"><a class="reference internal" href="udpconfig.html">Config file</a></li>
<li class="toctree-l1"><a class="reference internal" href="udpdetspec.html">Detector Specific Fields</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Receiver</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="slsreceiver.html">In-built Receiver</a></li>
<li class="toctree-l1"><a class="reference internal" href="receivers.html">Custom Receiver</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Receiver Files</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="fileformat.html">File format</a></li>
<li class="toctree-l1"><a class="reference internal" href="slsreceiverheaderformat.html">SLS Receiver Header Format</a></li>
<li class="toctree-l1"><a class="reference internal" href="dataformat.html">Detector Image Size and Format</a></li>
<li class="toctree-l1"><a class="reference internal" href="masterfileattributes.html">Master File Attributes</a></li>
<li class="toctree-l1"><a class="reference internal" href="binaryfileformat.html">Binary File Format</a></li>
<li class="toctree-l1"><a class="reference internal" href="hdf5fileformat.html">HDF5 File Format</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Receiver ZMQ Stream</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="zmqjsonheaderformat.html">ZMQ: Json Header Format</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Troubleshooting</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="troubleshooting.html">Troubleshooting</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">slsDetectorPackage 0.0.0</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Getting Started</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/pygettingstarted.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="getting-started">
<h1>Getting Started<a class="headerlink" href="#getting-started" title="Link to this heading"></a></h1>
<section id="which-python">
<h2>Which Python?<a class="headerlink" href="#which-python" title="Link to this heading"></a></h2>
<p>We require at least Python 3.8 and strongly recommended that you dont use the system
Python installation. The examples in this documentation uses <a class="reference external" href="https://docs.conda.io/en/latest/miniconda.html">conda</a> since it provides good support
also for non Python packages but there are also other alternatives like, pyenv.</p>
<p>Using something like conda also allows you to quickly switch beteen different Python
environments.</p>
</section>
<section id="building-from-source">
<h2>Building from Source<a class="headerlink" href="#building-from-source" title="Link to this heading"></a></h2>
<p>If you are not installing slsdet binaries from conda, but instead building from
source, please refer to <a class="reference internal" href="installation.html#installation"><span class="std std-ref">the installation section</span></a> for details.</p>
<p>Dont forget to compile with the option SLS_USE_PYTHON=ON to enable the Python
bindings or if you use the cmk.sh script -p.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Ensure that the sls det python lib compiled is for the expected python version.
For example, build/bin/_slsdet.cpython-39-x86_64-linux-gnu.so for Python v3.9.x</p>
</div>
</section>
<section id="pythonpath">
<h2>PYTHONPATH<a class="headerlink" href="#pythonpath" title="Link to this heading"></a></h2>
<p>If you install slsdet binaries using conda everything is set up and you can
directly start using the Python bindings. However, if you build
from source you need to tell Python where to find slsdet to use it. This
can be done by adding your build/bin directory to PYTHONPATH.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nb">export</span><span class="w"> </span><span class="nv">PYTHONPATH</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>/path/to/your/build/bin:<span class="nv">$PYTHONPATH</span>
</pre></div>
</div>
</section>
<section id="which-detector-class-should-i-use">
<h2>Which detector class should I use?<a class="headerlink" href="#which-detector-class-should-i-use" title="Link to this heading"></a></h2>
<p>We provide a generic class called Detector and detector specific
versions like, Eiger, Jungfrau etc. The most or all functionality
is there in the base class except the convenient access to dacs
and temperatures.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">slsdet</span><span class="w"> </span><span class="kn">import</span> <span class="n">Detector</span><span class="p">,</span> <span class="n">Eiger</span>
<span class="n">d</span> <span class="o">=</span> <span class="n">Detector</span><span class="p">()</span>
<span class="n">e</span> <span class="o">=</span> <span class="n">Eiger</span><span class="p">()</span>
<span class="c1"># Both classes can be used to control an Eiger detector</span>
<span class="n">d</span><span class="o">.</span><span class="n">exptime</span> <span class="o">=</span> <span class="mf">0.5</span>
<span class="n">e</span><span class="o">.</span><span class="n">period</span> <span class="o">=</span> <span class="mi">1</span>
<span class="c1"># But Eiger gives a simpler interface to the dacs</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">e</span><span class="o">.</span><span class="n">dacs</span>
<span class="o">==========</span> <span class="n">DACS</span> <span class="o">=========</span>
<span class="n">vsvp</span> <span class="p">:</span> <span class="mi">0</span>
<span class="n">vtrim</span> <span class="p">:</span> <span class="mi">2480</span>
<span class="n">vrpreamp</span> <span class="p">:</span> <span class="mi">3300</span>
<span class="n">vrshaper</span> <span class="p">:</span> <span class="mi">1400</span>
<span class="n">vsvn</span> <span class="p">:</span> <span class="mi">4000</span>
<span class="n">vtgstv</span> <span class="p">:</span> <span class="mi">2556</span>
<span class="n">vcmp_ll</span> <span class="p">:</span> <span class="mi">1000</span>
<span class="n">vcmp_lr</span> <span class="p">:</span> <span class="mi">1000</span>
<span class="n">vcal</span> <span class="p">:</span> <span class="mi">0</span>
<span class="n">vcmp_rl</span> <span class="p">:</span> <span class="mi">1000</span>
<span class="n">rxb_rb</span> <span class="p">:</span> <span class="mi">1100</span>
<span class="n">rxb_lb</span> <span class="p">:</span> <span class="mi">1100</span>
<span class="n">vcmp_rr</span> <span class="p">:</span> <span class="mi">1000</span>
<span class="n">vcp</span> <span class="p">:</span> <span class="mi">1000</span>
<span class="n">vcn</span> <span class="p">:</span> <span class="mi">2000</span>
<span class="n">vishaper</span> <span class="p">:</span> <span class="mi">1550</span>
<span class="n">iodelay</span> <span class="p">:</span> <span class="mi">650</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Depending on user feedback we might move some detector specific
functionality to the specialized classes.</p>
</div>
</section>
<section id="hey-there-seems-to-be-two-apis">
<h2>Hey, there seems to be two APIs?<a class="headerlink" href="#hey-there-seems-to-be-two-apis" title="Link to this heading"></a></h2>
<p>To make the Python API approachable, both if you come from the command line
or are using the C++ API, we provide two interfaces to the detector.
One is property based and tries to stay as close to the command line syntax
as is possible, and the other one directly maps the C++ API found in Detector.h.
There is also an underlying design reason for the two APIs since we auto
generate the bindings to the C++ code using a mix of pybind11 and clang-tools.
The property based API covers most of the functionality but in some cases
you have to reach for the C++ like interface.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">d</span> <span class="o">=</span> <span class="n">Detector</span><span class="p">()</span>
<span class="c1"># C++ like API</span>
<span class="n">d</span><span class="o">.</span><span class="n">setExptime</span><span class="p">(</span><span class="mf">0.1</span><span class="p">)</span>
<span class="c1"># or a bit more pythonic</span>
<span class="n">d</span><span class="o">.</span><span class="n">exptime</span> <span class="o">=</span> <span class="mf">0.1</span>
</pre></div>
</div>
<p>The c++ style API offers more control over access to individual modules
in a large detector.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># Set exposure time for module 1, 5 and 7</span>
<span class="n">d</span><span class="o">.</span><span class="n">setExptime</span><span class="p">(</span><span class="mf">0.1</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">7</span><span class="p">])</span>
</pre></div>
</div>
</section>
<section id="accessing-individual-modules">
<span id="py-module-index-label"></span><h2>Accessing individual modules<a class="headerlink" href="#accessing-individual-modules" title="Link to this heading"></a></h2>
<p>Using the C++ like API you can access individual modules in a large detector
by passing in the module index as an argument to the function.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># Read the UDP destination port for all modules</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">d</span><span class="o">.</span><span class="n">getDestinationUDPPort</span><span class="p">()</span>
<span class="p">[</span><span class="mi">50001</span><span class="p">,</span> <span class="mi">50002</span><span class="p">,</span> <span class="mi">50003</span><span class="p">]</span>
<span class="c1"># Read it for module 0 and 1</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">d</span><span class="o">.</span><span class="n">getDestinationUDPPort</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])</span>
<span class="p">[</span><span class="mi">50001</span><span class="p">,</span> <span class="mi">50002</span><span class="p">]</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">d</span><span class="o">.</span><span class="n">setDestinationUDPPort</span><span class="p">(</span><span class="mi">50010</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">d</span><span class="o">.</span><span class="n">getDestinationUDPPort</span><span class="p">()</span>
<span class="p">[</span><span class="mi">50001</span><span class="p">,</span> <span class="mi">50010</span><span class="p">,</span> <span class="mi">50003</span><span class="p">]</span>
</pre></div>
</div>
<p>From the more pythonic API there is no way to read from only one module but you can read
and then use list slicing to get the values for the modules you are interested in.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">udp_dstport</span>
<span class="go">[50001, 50010, 50003]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">udp_dstport</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="go">50001</span>
<span class="go">#For some but not all properties you can also pass in a dictionary with module index as key</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ip</span> <span class="o">=</span> <span class="n">IpAddr</span><span class="p">(</span><span class="s1">&#39;127.0.0.1&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">udp_dstip</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">:</span><span class="n">ip</span><span class="p">}</span>
</pre></div>
</div>
</section>
<section id="finding-functions">
<h2>Finding functions<a class="headerlink" href="#finding-functions" title="Link to this heading"></a></h2>
<p>To find out which properties and methods that a Python object have you
can use dir()</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span><span class="w"> </span><span class="nn">slsdet</span><span class="w"> </span><span class="kn">import</span> <span class="n">Detector</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">Detector</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">dir</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
<span class="go">[&#39;__class__&#39;, &#39;__delattr__&#39;, &#39;__dict__&#39;, &#39;__dir__&#39;, &#39;__doc__&#39;,</span>
<span class="go">&#39;__eq__&#39;, &#39;__format__&#39;, &#39;__ge__&#39;, &#39;__getattribute__&#39;, &#39;__gt__&#39;,</span>
<span class="go">&#39;__hash__&#39;, &#39;__init__&#39;, &#39;__init_subclass__&#39;, &#39;__le__&#39;, &#39;__len__&#39;,</span>
<span class="go">&#39;__lt__&#39;, &#39;__module__&#39;, &#39;__ne__&#39;, &#39;__new__&#39;, &#39;__reduce__&#39;,</span>
<span class="go">&#39;__reduce_ex__&#39;, &#39;__repr__&#39;, &#39;__setattr__&#39;, &#39;__sizeof__&#39;,</span>
<span class="go">&#39;__str__&#39;, &#39;__subclasshook__&#39;, &#39;_adc_register&#39;, &#39;_frozen&#39;,</span>
<span class="go">&#39;_register&#39;, &#39;acquire&#39;, &#39;adcclk&#39;, &#39;adcphase&#39;, &#39;adcpipeline&#39;,</span>
<span class="go">&#39;adcreg&#39;, &#39;asamples&#39;, &#39;auto_comp_disable&#39;, &#39;clearAcquiringFlag&#39;,</span>
<span class="go">&#39;clearBit&#39;, &#39;clearROI&#39;, &#39;client_version&#39;, &#39;config&#39;,</span>
<span class="go">&#39;counters&#39;, &#39;daclist&#39;, &#39;dacvalues&#39;, &#39;dbitclk&#39;, &#39;dbitphase&#39; ...</span>
</pre></div>
</div>
<p>Since the list for Detector is rather long its an good idea to filter it.
The following example gives you properties and methods containing time in
their name.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="p">[</span><span class="n">item</span> <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="nb">dir</span><span class="p">(</span><span class="n">d</span><span class="p">)</span> <span class="k">if</span> <span class="s1">&#39;time&#39;</span> <span class="ow">in</span> <span class="n">item</span><span class="p">]</span>
<span class="go">[&#39;compdisabletime&#39;, &#39;exptime&#39;, &#39;exptimel&#39;, &#39;frametime&#39;, &#39;getExptime&#39;,</span>
<span class="go">&#39;getExptimeForAllGates&#39;, &#39;getExptimeLeft&#39;, &#39;getSubExptime&#39;, &#39;patwaittime&#39;,</span>
<span class="go">&#39;patwaittime0&#39;, &#39;patwaittime1&#39;, &#39;patwaittime2&#39;, &#39;runtime&#39;, &#39;setExptime&#39;,</span>
<span class="go">&#39;setSubExptime&#39;, &#39;subdeadtime&#39;, &#39;subexptime&#39;]</span>
</pre></div>
</div>
<p>The above method works on any Python object but for convenience we also
included two functions to find names. View prints the names one per line
while find returns a list of names.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">slsdet.lookup</span><span class="w"> </span><span class="kn">import</span> <span class="n">view</span><span class="p">,</span> <span class="n">find</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">view</span><span class="p">(</span><span class="s1">&#39;exptime&#39;</span><span class="p">)</span>
<span class="n">exptime</span>
<span class="n">exptimel</span>
<span class="n">getExptime</span>
<span class="n">getExptimeForAllGates</span>
<span class="n">getExptimeLeft</span>
<span class="n">getSubExptime</span>
<span class="n">setExptime</span>
<span class="n">setSubExptime</span>
<span class="n">subexptime</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">find</span><span class="p">(</span><span class="s1">&#39;exptime&#39;</span><span class="p">)</span>
<span class="p">[</span><span class="s1">&#39;exptime&#39;</span><span class="p">,</span> <span class="s1">&#39;getExptime&#39;</span><span class="p">,</span> <span class="s1">&#39;getExptimeForAllGates&#39;</span><span class="p">,</span> <span class="s1">&#39;getExptimeLeft&#39;</span><span class="p">,</span>
<span class="s1">&#39;getSubExptime&#39;</span><span class="p">,</span> <span class="s1">&#39;setExptime&#39;</span><span class="p">,</span> <span class="s1">&#39;setSubExptime&#39;</span><span class="p">,</span> <span class="s1">&#39;subexptime&#39;</span><span class="p">]</span>
</pre></div>
</div>
</section>
<section id="finding-out-what-the-function-does">
<h2>Finding out what the function does<a class="headerlink" href="#finding-out-what-the-function-does" title="Link to this heading"></a></h2>
<p>To access the documentation of a function directly from the Python prompt use help().</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">Detector</span><span class="o">.</span><span class="n">period</span><span class="p">)</span>
<span class="go">Help on property:</span>
<span class="go"> Period between frames, accepts either a value in seconds or datetime.timedelta</span>
<span class="go"> Note</span>
<span class="go"> -----</span>
<span class="go"> :getter: always returns in seconds. To get in DurationWrapper, use getPeriod</span>
<span class="go"> Example</span>
<span class="go"> -----------</span>
<span class="go"> &gt;&gt;&gt; # setting directly in seconds</span>
<span class="go"> &gt;&gt;&gt; d.period = 1.05</span>
<span class="go"> &gt;&gt;&gt;</span>
<span class="go"> &gt;&gt;&gt; # setting directly in seconds</span>
<span class="go"> &gt;&gt;&gt; d.period = 5e-07</span>
<span class="go"> &gt;&gt;&gt;</span>
<span class="go"> &gt;&gt;&gt; # using timedelta (up to microseconds precision)</span>
<span class="go"> &gt;&gt;&gt; from datatime import timedelta</span>
<span class="go"> &gt;&gt;&gt; d.period = timedelta(seconds = 1, microseconds = 3)</span>
<span class="go"> &gt;&gt;&gt;</span>
<span class="go"> &gt;&gt;&gt; # using DurationWrapper to set in seconds</span>
<span class="go"> &gt;&gt;&gt; from slsdet import DurationWrapper</span>
<span class="go"> &gt;&gt;&gt; d.period = DurationWrapper(1.2)</span>
<span class="go"> &gt;&gt;&gt;</span>
<span class="go"> &gt;&gt;&gt; # using DurationWrapper to set in ns</span>
<span class="go"> &gt;&gt;&gt; t = DurationWrapper()</span>
<span class="go"> &gt;&gt;&gt; t.set_count(500)</span>
<span class="go"> &gt;&gt;&gt; d.period = t</span>
<span class="go"> &gt;&gt;&gt;</span>
<span class="go"> &gt;&gt;&gt; # to get in seconds</span>
<span class="go"> &gt;&gt;&gt; d.period</span>
<span class="go"> 181.23</span>
<span class="go"> &gt;&gt;&gt;</span>
<span class="go"> &gt;&gt;&gt; d.getExptime()</span>
<span class="go"> [sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]</span>
</pre></div>
</div>
</section>
<section id="where-are-the-enums">
<h2>Where are the ENUMs?<a class="headerlink" href="#where-are-the-enums" title="Link to this heading"></a></h2>
<p>To set some of the detector settings like file format you have
to pass in an enum.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">setFileFormat</span><span class="p">(</span><span class="n">fileFormat</span><span class="o">.</span><span class="n">BINARY</span><span class="p">)</span>
</pre></div>
</div>
<p>The enums can be found in slsdet.enums</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">slsdet</span>
<span class="o">&gt;&gt;&gt;</span> <span class="p">[</span><span class="n">e</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">dir</span><span class="p">(</span><span class="n">slsdet</span><span class="o">.</span><span class="n">enums</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">e</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">)]</span>
<span class="p">[</span><span class="s1">&#39;M3_GainCaps&#39;</span><span class="p">,</span> <span class="s1">&#39;burstMode&#39;</span><span class="p">,</span> <span class="s1">&#39;clockIndex&#39;</span><span class="p">,</span> <span class="s1">&#39;cls&#39;</span><span class="p">,</span> <span class="s1">&#39;dacIndex&#39;</span><span class="p">,</span> <span class="s1">&#39;detectorSettings&#39;</span><span class="p">,</span>
<span class="s1">&#39;detectorType&#39;</span><span class="p">,</span> <span class="s1">&#39;dimension&#39;</span><span class="p">,</span> <span class="s1">&#39;externalSignalFlag&#39;</span><span class="p">,</span> <span class="s1">&#39;fileFormat&#39;</span><span class="p">,</span>
<span class="s1">&#39;frameDiscardPolicy&#39;</span><span class="p">,</span> <span class="s1">&#39;gainMode&#39;</span><span class="p">,</span> <span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="s1">&#39;polarity&#39;</span><span class="p">,</span> <span class="s1">&#39;portPosition&#39;</span><span class="p">,</span>
<span class="s1">&#39;readoutMode&#39;</span><span class="p">,</span> <span class="s1">&#39;runStatus&#39;</span><span class="p">,</span> <span class="s1">&#39;speedLevel&#39;</span><span class="p">,</span> <span class="s1">&#39;streamingInterface&#39;</span><span class="p">,</span> <span class="s1">&#39;timingMode&#39;</span><span class="p">,</span>
<span class="s1">&#39;timingSourceType&#39;</span><span class="p">,</span> <span class="s1">&#39;vetoAlgorithm&#39;</span><span class="p">]</span>
<span class="c1"># Even though importing using * is not recommended one could</span>
<span class="c1"># get all the enums like this:</span>
<span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span><span class="w"> </span><span class="nn">slsdet.enums</span><span class="w"> </span><span class="kn">import</span> <span class="o">*</span>
</pre></div>
</div>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="examples.html" class="btn btn-neutral float-left" title="Examples" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="pydetector.html" class="btn btn-neutral float-right" title="Detector" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2020, PSD Detector Group.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>