123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486 |
-
-
- <!DOCTYPE html>
- <html class="writer-html4" lang="en" >
- <head>
- <meta charset="utf-8">
-
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
-
- <title>Welcome to state_machine’s documentation! — state_machine documentation</title>
-
-
-
- <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
- <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-
-
-
-
-
-
-
- <!--[if lt IE 9]>
- <script src="_static/js/html5shiv.min.js"></script>
- <![endif]-->
-
-
- <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
- <script type="text/javascript" src="_static/jquery.js"></script>
- <script type="text/javascript" src="_static/underscore.js"></script>
- <script type="text/javascript" src="_static/doctools.js"></script>
- <script type="text/javascript" src="_static/language_data.js"></script>
-
- <script type="text/javascript" src="_static/js/theme.js"></script>
-
-
- <link rel="index" title="Index" href="genindex.html" />
- <link rel="search" title="Search" href="search.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="#" class="icon icon-home" alt="Documentation Home"> state_machine
-
-
-
- </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" />
- <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="main navigation">
-
-
-
-
-
-
- <!-- Local TOC -->
- <div class="local-toc"><ul>
- <li><a class="reference internal" href="#">Welcome to state_machine’s documentation!</a><ul>
- <li><a class="reference internal" href="#state-machine-state-machine">state_machine (State Machine)</a></li>
- </ul>
- </li>
- <li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
- </ul>
- </div>
-
-
- </div>
-
- </div>
- </nav>
-
- <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
-
-
- <nav class="wy-nav-top" aria-label="top navigation">
-
- <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
- <a href="#">state_machine</a>
-
- </nav>
-
-
- <div class="wy-nav-content">
-
- <div class="rst-content">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <div role="navigation" aria-label="breadcrumbs navigation">
-
- <ul class="wy-breadcrumbs">
-
- <li><a href="#" class="icon icon-home"></a> »</li>
-
- <li>Welcome to state_machine’s documentation!</li>
-
-
- <li class="wy-breadcrumbs-aside">
-
-
- <a href="_sources/index.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">
-
- <div class="section" id="module-state_machine">
- <span id="welcome-to-state-machine-s-documentation"></span><h1>Welcome to state_machine’s documentation!<a class="headerlink" href="#module-state_machine" title="Permalink to this headline">¶</a></h1>
- <div class="section" id="state-machine-state-machine">
- <h2>state_machine (State Machine)<a class="headerlink" href="#state-machine-state-machine" title="Permalink to this headline">¶</a></h2>
- <p><strong>Author:</strong></p>
- <ul class="simple">
- <li>Dirk Alders <<a class="reference external" href="mailto:sudo-dirk%40mount-mockery.de">sudo-dirk<span>@</span>mount-mockery<span>.</span>de</a>></li>
- </ul>
- <p><strong>Description:</strong></p>
- <blockquote>
- <div>This Module helps implementing state machines.</div></blockquote>
- <p><strong>Submodules:</strong></p>
- <ul class="simple">
- <li><a class="reference internal" href="#state_machine.state_machine" title="state_machine.state_machine"><code class="xref py py-class docutils literal notranslate"><span class="pre">state_machine.state_machine</span></code></a></li>
- </ul>
- <p><strong>Unittest:</strong></p>
- <blockquote>
- <div>See also the <a class="reference download internal" download="" href="_downloads/e2fbca9180ad234c517493570f525e69/unittest.pdf"><code class="xref download docutils literal notranslate"><span class="pre">unittest</span></code></a> documentation.</div></blockquote>
- <p><strong>Module Documentation:</strong></p>
- <dl class="class">
- <dt id="state_machine.state_machine">
- <em class="property">class </em><code class="descclassname">state_machine.</code><code class="descname">state_machine</code><span class="sig-paren">(</span><em>default_state</em>, <em>log_lvl</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#state_machine.state_machine" title="Permalink to this definition">¶</a></dt>
- <dd><table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
- <li><strong>default_state</strong> – The default state which is set on initialisation.</li>
- <li><strong>log_lvl</strong> – The log level, this Module logs to (see Loging-Levels of Module <code class="xref py py-mod docutils literal notranslate"><span class="pre">logging</span></code>)</li>
- </ul>
- </td>
- </tr>
- </tbody>
- </table>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">Additional keyword parameters well be stored as varibles of the instance (e.g. to give variables or methods for transition condition calculation).</p>
- </div>
- <p>A state machine class can be created by deriving it from this class. The transitions are defined by overriding the variable <cite>TRANSITIONS</cite>.
- This Variable is a dictionary, where the key is the start-state and the content is a tuple or list of transitions. Each transition is a tuple or list
- including the following information: (condition-method (str), transition-time (number), target_state (str)).</p>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">The condition-method needs to be implemented as part of the new class.</p>
- </div>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">It is usefull to define the states as variables of this class.</p>
- </div>
- <p><strong>Example:</strong></p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="ch">#!/usr/bin/env python</span>
- <span class="c1"># -*- coding: UTF-8 -*-</span>
-
- <span class="kn">import</span> <span class="nn">logging</span>
- <span class="kn">import</span> <span class="nn">os</span>
- <span class="kn">import</span> <span class="nn">sys</span>
-
- <span class="kn">import</span> <span class="nn">report</span>
- <span class="kn">import</span> <span class="nn">state_machine</span>
-
- <span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s1">'__example__'</span><span class="p">)</span>
- <span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="n">state_machine</span><span class="o">.</span><span class="n">logger_name</span><span class="p">,</span> <span class="s1">'DEBUG'</span><span class="p">),</span> <span class="p">(</span><span class="s1">'__example__'</span><span class="p">,</span> <span class="s1">'DEBUG'</span><span class="p">),</span> <span class="p">])</span>
-
-
- <span class="k">class</span> <span class="nc">trafic_lights</span><span class="p">(</span><span class="n">state_machine</span><span class="o">.</span><span class="n">state_machine</span><span class="p">):</span>
- <span class="n">LOG_PREFIX</span> <span class="o">=</span> <span class="s1">'TraficLights:'</span>
-
- <span class="n">STATE_RED</span> <span class="o">=</span> <span class="s1">'state_red'</span>
- <span class="n">STATE_GREEN</span> <span class="o">=</span> <span class="s1">'state_green'</span>
-
- <span class="n">CONDITION_TRUE</span> <span class="o">=</span> <span class="s1">'condition_true'</span>
- <span class="n">CONDITION_PEDASTRIAN_REQUEST</span> <span class="o">=</span> <span class="s1">'condition_pedastrian_request'</span>
-
- <span class="n">TRANSITIONS</span> <span class="o">=</span> <span class="p">{</span>
- <span class="n">STATE_RED</span><span class="p">:</span> <span class="p">(</span>
- <span class="p">(</span><span class="n">CONDITION_PEDASTRIAN_REQUEST</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">STATE_GREEN</span><span class="p">),</span>
- <span class="p">),</span>
- <span class="n">STATE_GREEN</span><span class="p">:</span> <span class="p">(</span>
- <span class="p">(</span><span class="n">CONDITION_TRUE</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="n">STATE_RED</span><span class="p">),</span>
- <span class="p">)</span>
- <span class="p">}</span>
-
- <span class="k">def</span> <span class="nf">condition_true</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
- <span class="k">return</span> <span class="kc">True</span>
-
- <span class="k">def</span> <span class="nf">set_padestrian_request</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
- <span class="n">logger</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__log_lvl__</span><span class="p">,</span> <span class="s1">'</span><span class="si">%s</span><span class="s1"> Pedestrian gave state change request.'</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_PREFIX</span><span class="p">)</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">pedastrian_request</span> <span class="o">=</span> <span class="kc">True</span>
-
- <span class="k">def</span> <span class="nf">condition_pedastrian_request</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
- <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">pedastrian_request</span>
-
-
- <span class="n">sm</span> <span class="o">=</span> <span class="n">trafic_lights</span><span class="p">(</span><span class="n">trafic_lights</span><span class="o">.</span><span class="n">STATE_RED</span><span class="p">,</span> <span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">,</span> <span class="n">pedastrian_request</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
- <span class="n">sm</span><span class="o">.</span><span class="n">register_state_change_callback</span><span class="p">(</span><span class="n">sm</span><span class="o">.</span><span class="n">STATE_GREEN</span><span class="p">,</span> <span class="n">sm</span><span class="o">.</span><span class="n">CONDITION_PEDASTRIAN_REQUEST</span><span class="p">,</span> <span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">,</span> <span class="s1">'Callback information: Traffic light had been changed to green caused by pedastrian request'</span><span class="p">)</span>
- <span class="k">while</span> <span class="ow">not</span> <span class="n">sm</span><span class="o">.</span><span class="n">previous_state_was</span><span class="p">(</span><span class="n">sm</span><span class="o">.</span><span class="n">STATE_GREEN</span><span class="p">):</span>
- <span class="k">if</span> <span class="n">sm</span><span class="o">.</span><span class="n">this_state_is</span><span class="p">(</span><span class="n">sm</span><span class="o">.</span><span class="n">STATE_RED</span><span class="p">)</span> <span class="ow">and</span> <span class="n">sm</span><span class="o">.</span><span class="n">this_state_duration</span><span class="p">()</span> <span class="o">></span> <span class="mf">0.2</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">sm</span><span class="o">.</span><span class="n">condition_pedastrian_request</span><span class="p">():</span>
- <span class="n">sm</span><span class="o">.</span><span class="n">set_padestrian_request</span><span class="p">()</span>
- <span class="n">sm</span><span class="o">.</span><span class="n">work</span><span class="p">()</span>
- </pre></div>
- </div>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">07</span><span class="p">:</span><span class="mi">09</span><span class="p">:</span><span class="mi">32</span><span class="p">,</span><span class="mi">803</span><span class="p">:</span> <span class="n">STATE_MACHINE</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">TraficLights</span><span class="p">:</span> <span class="n">State</span> <span class="n">change</span> <span class="p">(</span><span class="s1">'__init__'</span><span class="p">):</span> <span class="kc">None</span> <span class="o">-></span> <span class="s1">'state_red'</span>
- <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">07</span><span class="p">:</span><span class="mi">09</span><span class="p">:</span><span class="mi">33</span><span class="p">,</span><span class="mi">003</span><span class="p">:</span> <span class="n">__example__</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">TraficLights</span><span class="p">:</span> <span class="n">Pedestrian</span> <span class="n">gave</span> <span class="n">state</span> <span class="n">change</span> <span class="n">request</span><span class="o">.</span>
- <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">07</span><span class="p">:</span><span class="mi">09</span><span class="p">:</span><span class="mi">34</span><span class="p">,</span><span class="mi">003</span><span class="p">:</span> <span class="n">STATE_MACHINE</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">TraficLights</span><span class="p">:</span> <span class="n">State</span> <span class="n">change</span> <span class="p">(</span><span class="s1">'condition_pedastrian_request'</span><span class="p">):</span> <span class="s1">'state_red'</span> <span class="o">-></span> <span class="s1">'state_green'</span>
- <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">07</span><span class="p">:</span><span class="mi">09</span><span class="p">:</span><span class="mi">34</span><span class="p">,</span><span class="mi">004</span><span class="p">:</span> <span class="n">__example__</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Callback</span> <span class="n">information</span><span class="p">:</span> <span class="n">Traffic</span> <span class="n">light</span> <span class="n">had</span> <span class="n">been</span> <span class="n">changed</span> <span class="n">to</span> <span class="n">green</span> <span class="n">caused</span> <span class="n">by</span> <span class="n">pedastrian</span> <span class="n">request</span>
- <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">07</span><span class="p">:</span><span class="mi">09</span><span class="p">:</span><span class="mi">37</span><span class="p">,</span><span class="mi">004</span><span class="p">:</span> <span class="n">STATE_MACHINE</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">TraficLights</span><span class="p">:</span> <span class="n">State</span> <span class="n">change</span> <span class="p">(</span><span class="s1">'condition_true'</span><span class="p">):</span> <span class="s1">'state_green'</span> <span class="o">-></span> <span class="s1">'state_red'</span>
- </pre></div>
- </div>
- <dl class="method">
- <dt id="state_machine.state_machine.last_transition_condition">
- <code class="descname">last_transition_condition</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#state_machine.state_machine.last_transition_condition" title="Permalink to this definition">¶</a></dt>
- <dd><table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The last transition condition.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
- </tr>
- </tbody>
- </table>
- <p>This method returns the last transition condition.</p>
- </dd></dl>
-
- <dl class="method">
- <dt id="state_machine.state_machine.last_transition_condition_was">
- <code class="descname">last_transition_condition_was</code><span class="sig-paren">(</span><em>condition</em><span class="sig-paren">)</span><a class="headerlink" href="#state_machine.state_machine.last_transition_condition_was" title="Permalink to this definition">¶</a></dt>
- <dd><table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>condition</strong> (<em>str</em>) – The condition to be checked</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">True if the given condition was the last transition condition, else False.</td>
- </tr>
- <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
- </tr>
- </tbody>
- </table>
- <p>This methods returns the boolean information if the last transition condition is equivalent to the given condition.</p>
- </dd></dl>
-
- <dl class="method">
- <dt id="state_machine.state_machine.previous_state">
- <code class="descname">previous_state</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#state_machine.state_machine.previous_state" title="Permalink to this definition">¶</a></dt>
- <dd><table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The previous state.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
- </tr>
- </tbody>
- </table>
- <p>This method returns the previous state of the state machine.</p>
- </dd></dl>
-
- <dl class="method">
- <dt id="state_machine.state_machine.previous_state_duration">
- <code class="descname">previous_state_duration</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#state_machine.state_machine.previous_state_duration" title="Permalink to this definition">¶</a></dt>
- <dd><table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The time how long the previous state was active.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">float</td>
- </tr>
- </tbody>
- </table>
- <p>This method returns the time how long the previous state was active.</p>
- </dd></dl>
-
- <dl class="method">
- <dt id="state_machine.state_machine.previous_state_was">
- <code class="descname">previous_state_was</code><span class="sig-paren">(</span><em>state</em><span class="sig-paren">)</span><a class="headerlink" href="#state_machine.state_machine.previous_state_was" title="Permalink to this definition">¶</a></dt>
- <dd><table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>state</strong> (<em>str</em>) – The state to be checked</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">True if the given state was previously active, else False.</td>
- </tr>
- <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
- </tr>
- </tbody>
- </table>
- <p>This methods returns the boolean information if the state machine was previously in the given state.</p>
- </dd></dl>
-
- <dl class="method">
- <dt id="state_machine.state_machine.register_state_change_callback">
- <code class="descname">register_state_change_callback</code><span class="sig-paren">(</span><em>state</em>, <em>condition</em>, <em>callback</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#state_machine.state_machine.register_state_change_callback" title="Permalink to this definition">¶</a></dt>
- <dd><table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
- <li><strong>state</strong> (<em>str</em>) – The target state. The callback will be executed, if the state machine changes to this state. None means all states.</li>
- <li><strong>condition</strong> (<em>str</em>) – The transition condition. The callback will be executed, if this condition is responsible for the state change. None means all conditions.</li>
- <li><strong>callback</strong> – The callback to be executed.</li>
- </ul>
- </td>
- </tr>
- </tbody>
- </table>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">Additional arguments and keyword parameters are supported. These arguments and parameters will be used as arguments and parameters for the callback execution.</p>
- </div>
- <p>This methods allows to register callbacks which will be executed on state changes.</p>
- </dd></dl>
-
- <dl class="method">
- <dt id="state_machine.state_machine.this_state">
- <code class="descname">this_state</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#state_machine.state_machine.this_state" title="Permalink to this definition">¶</a></dt>
- <dd><table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The current state.</td>
- </tr>
- </tbody>
- </table>
- <p>This method returns the current state of the state machine.</p>
- </dd></dl>
-
- <dl class="method">
- <dt id="state_machine.state_machine.this_state_duration">
- <code class="descname">this_state_duration</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#state_machine.state_machine.this_state_duration" title="Permalink to this definition">¶</a></dt>
- <dd><table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The time how long the current state is active.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">float</td>
- </tr>
- </tbody>
- </table>
- <p>This method returns the time how long the current state is active.</p>
- </dd></dl>
-
- <dl class="method">
- <dt id="state_machine.state_machine.this_state_is">
- <code class="descname">this_state_is</code><span class="sig-paren">(</span><em>state</em><span class="sig-paren">)</span><a class="headerlink" href="#state_machine.state_machine.this_state_is" title="Permalink to this definition">¶</a></dt>
- <dd><table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>state</strong> (<em>str</em>) – The state to be checked</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">True if the given state is currently active, else False.</td>
- </tr>
- <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
- </tr>
- </tbody>
- </table>
- <p>This methods returns the boolean information if the state machine is currently in the given state.</p>
- </dd></dl>
-
- <dl class="method">
- <dt id="state_machine.state_machine.work">
- <code class="descname">work</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#state_machine.state_machine.work" title="Permalink to this definition">¶</a></dt>
- <dd><p>This Method needs to be executed cyclicly to enable the state machine.</p>
- </dd></dl>
-
- </dd></dl>
-
- </div>
- <div class="toctree-wrapper compound">
- </div>
- </div>
- <div class="section" id="indices-and-tables">
- <h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
- <ul class="simple">
- <li><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></li>
- <li><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></li>
- <li><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></li>
- </ul>
- </div>
-
-
- </div>
-
- </div>
- <footer>
-
-
- <hr/>
-
- <div role="contentinfo">
- <p>
-
- © Copyright 2021, Dirk Alders
-
- </p>
- </div>
-
-
-
- Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
-
- <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
-
- provided by <a href="https://readthedocs.org">Read the Docs</a>.
-
- </footer>
-
- </div>
- </div>
-
- </section>
-
- </div>
-
-
- <script type="text/javascript">
- jQuery(function () {
- SphinxRtdTheme.Navigation.enable(true);
- });
- </script>
-
-
-
-
-
-
- </body>
- </html>
|