Python Library State Machine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <!DOCTYPE html>
  2. <html class="writer-html4" lang="en" >
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Welcome to state_machine’s documentation! &mdash; state_machine documentation</title>
  7. <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <!--[if lt IE 9]>
  10. <script src="_static/js/html5shiv.min.js"></script>
  11. <![endif]-->
  12. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  13. <script type="text/javascript" src="_static/jquery.js"></script>
  14. <script type="text/javascript" src="_static/underscore.js"></script>
  15. <script type="text/javascript" src="_static/doctools.js"></script>
  16. <script type="text/javascript" src="_static/language_data.js"></script>
  17. <script type="text/javascript" src="_static/js/theme.js"></script>
  18. <link rel="index" title="Index" href="genindex.html" />
  19. <link rel="search" title="Search" href="search.html" />
  20. </head>
  21. <body class="wy-body-for-nav">
  22. <div class="wy-grid-for-nav">
  23. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  24. <div class="wy-side-scroll">
  25. <div class="wy-side-nav-search" >
  26. <a href="#" class="icon icon-home" alt="Documentation Home"> state_machine
  27. </a>
  28. <div role="search">
  29. <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
  30. <input type="text" name="q" placeholder="Search docs" />
  31. <input type="hidden" name="check_keywords" value="yes" />
  32. <input type="hidden" name="area" value="default" />
  33. </form>
  34. </div>
  35. </div>
  36. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  37. <!-- Local TOC -->
  38. <div class="local-toc"><ul>
  39. <li><a class="reference internal" href="#">Welcome to state_machine’s documentation!</a><ul>
  40. <li><a class="reference internal" href="#state-machine-state-machine">state_machine (State Machine)</a></li>
  41. </ul>
  42. </li>
  43. <li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
  44. </ul>
  45. </div>
  46. </div>
  47. </div>
  48. </nav>
  49. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  50. <nav class="wy-nav-top" aria-label="top navigation">
  51. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  52. <a href="#">state_machine</a>
  53. </nav>
  54. <div class="wy-nav-content">
  55. <div class="rst-content">
  56. <div role="navigation" aria-label="breadcrumbs navigation">
  57. <ul class="wy-breadcrumbs">
  58. <li><a href="#" class="icon icon-home"></a> &raquo;</li>
  59. <li>Welcome to state_machine’s documentation!</li>
  60. <li class="wy-breadcrumbs-aside">
  61. <a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
  62. </li>
  63. </ul>
  64. <hr/>
  65. </div>
  66. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  67. <div itemprop="articleBody">
  68. <div class="section" id="module-state_machine">
  69. <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>
  70. <div class="section" id="state-machine-state-machine">
  71. <h2>state_machine (State Machine)<a class="headerlink" href="#state-machine-state-machine" title="Permalink to this headline">¶</a></h2>
  72. <p><strong>Author:</strong></p>
  73. <ul class="simple">
  74. <li>Dirk Alders &lt;<a class="reference external" href="mailto:sudo-dirk&#37;&#52;&#48;mount-mockery&#46;de">sudo-dirk<span>&#64;</span>mount-mockery<span>&#46;</span>de</a>&gt;</li>
  75. </ul>
  76. <p><strong>Description:</strong></p>
  77. <blockquote>
  78. <div>This Module helps implementing state machines.</div></blockquote>
  79. <p><strong>Submodules:</strong></p>
  80. <ul class="simple">
  81. <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>
  82. </ul>
  83. <p><strong>Unittest:</strong></p>
  84. <blockquote>
  85. <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>
  86. <p><strong>Module Documentation:</strong></p>
  87. <dl class="class">
  88. <dt id="state_machine.state_machine">
  89. <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>
  90. <dd><table class="docutils field-list" frame="void" rules="none">
  91. <col class="field-name" />
  92. <col class="field-body" />
  93. <tbody valign="top">
  94. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  95. <li><strong>default_state</strong> – The default state which is set on initialisation.</li>
  96. <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>
  97. </ul>
  98. </td>
  99. </tr>
  100. </tbody>
  101. </table>
  102. <div class="admonition note">
  103. <p class="first admonition-title">Note</p>
  104. <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>
  105. </div>
  106. <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>.
  107. 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
  108. including the following information: (condition-method (str), transition-time (number), target_state (str)).</p>
  109. <div class="admonition note">
  110. <p class="first admonition-title">Note</p>
  111. <p class="last">The condition-method needs to be implemented as part of the new class.</p>
  112. </div>
  113. <div class="admonition note">
  114. <p class="first admonition-title">Note</p>
  115. <p class="last">It is usefull to define the states as variables of this class.</p>
  116. </div>
  117. <p><strong>Example:</strong></p>
  118. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="ch">#!/usr/bin/env python</span>
  119. <span class="c1"># -*- coding: UTF-8 -*-</span>
  120. <span class="kn">import</span> <span class="nn">logging</span>
  121. <span class="kn">import</span> <span class="nn">os</span>
  122. <span class="kn">import</span> <span class="nn">sys</span>
  123. <span class="kn">import</span> <span class="nn">report</span>
  124. <span class="kn">import</span> <span class="nn">state_machine</span>
  125. <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">&#39;__example__&#39;</span><span class="p">)</span>
  126. <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">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;__example__&#39;</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
  127. <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>
  128. <span class="n">LOG_PREFIX</span> <span class="o">=</span> <span class="s1">&#39;TraficLights:&#39;</span>
  129. <span class="n">STATE_RED</span> <span class="o">=</span> <span class="s1">&#39;state_red&#39;</span>
  130. <span class="n">STATE_GREEN</span> <span class="o">=</span> <span class="s1">&#39;state_green&#39;</span>
  131. <span class="n">CONDITION_TRUE</span> <span class="o">=</span> <span class="s1">&#39;condition_true&#39;</span>
  132. <span class="n">CONDITION_PEDASTRIAN_REQUEST</span> <span class="o">=</span> <span class="s1">&#39;condition_pedastrian_request&#39;</span>
  133. <span class="n">TRANSITIONS</span> <span class="o">=</span> <span class="p">{</span>
  134. <span class="n">STATE_RED</span><span class="p">:</span> <span class="p">(</span>
  135. <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>
  136. <span class="p">),</span>
  137. <span class="n">STATE_GREEN</span><span class="p">:</span> <span class="p">(</span>
  138. <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>
  139. <span class="p">)</span>
  140. <span class="p">}</span>
  141. <span class="k">def</span> <span class="nf">condition_true</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  142. <span class="k">return</span> <span class="kc">True</span>
  143. <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>
  144. <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">&#39;</span><span class="si">%s</span><span class="s1"> Pedestrian gave state change request.&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_PREFIX</span><span class="p">)</span>
  145. <span class="bp">self</span><span class="o">.</span><span class="n">pedastrian_request</span> <span class="o">=</span> <span class="kc">True</span>
  146. <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>
  147. <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">pedastrian_request</span>
  148. <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>
  149. <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">&#39;Callback information: Traffic light had been changed to green caused by pedastrian request&#39;</span><span class="p">)</span>
  150. <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>
  151. <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">&gt;</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>
  152. <span class="n">sm</span><span class="o">.</span><span class="n">set_padestrian_request</span><span class="p">()</span>
  153. <span class="n">sm</span><span class="o">.</span><span class="n">work</span><span class="p">()</span>
  154. </pre></div>
  155. </div>
  156. <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">&#39;__init__&#39;</span><span class="p">):</span> <span class="kc">None</span> <span class="o">-&gt;</span> <span class="s1">&#39;state_red&#39;</span>
  157. <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>
  158. <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">&#39;condition_pedastrian_request&#39;</span><span class="p">):</span> <span class="s1">&#39;state_red&#39;</span> <span class="o">-&gt;</span> <span class="s1">&#39;state_green&#39;</span>
  159. <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>
  160. <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">&#39;condition_true&#39;</span><span class="p">):</span> <span class="s1">&#39;state_green&#39;</span> <span class="o">-&gt;</span> <span class="s1">&#39;state_red&#39;</span>
  161. </pre></div>
  162. </div>
  163. <dl class="method">
  164. <dt id="state_machine.state_machine.last_transition_condition">
  165. <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>
  166. <dd><table class="docutils field-list" frame="void" rules="none">
  167. <col class="field-name" />
  168. <col class="field-body" />
  169. <tbody valign="top">
  170. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The last transition condition.</td>
  171. </tr>
  172. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  173. </tr>
  174. </tbody>
  175. </table>
  176. <p>This method returns the last transition condition.</p>
  177. </dd></dl>
  178. <dl class="method">
  179. <dt id="state_machine.state_machine.last_transition_condition_was">
  180. <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>
  181. <dd><table class="docutils field-list" frame="void" rules="none">
  182. <col class="field-name" />
  183. <col class="field-body" />
  184. <tbody valign="top">
  185. <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>
  186. </tr>
  187. <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>
  188. </tr>
  189. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  190. </tr>
  191. </tbody>
  192. </table>
  193. <p>This methods returns the boolean information if the last transition condition is equivalent to the given condition.</p>
  194. </dd></dl>
  195. <dl class="method">
  196. <dt id="state_machine.state_machine.previous_state">
  197. <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>
  198. <dd><table class="docutils field-list" frame="void" rules="none">
  199. <col class="field-name" />
  200. <col class="field-body" />
  201. <tbody valign="top">
  202. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The previous state.</td>
  203. </tr>
  204. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  205. </tr>
  206. </tbody>
  207. </table>
  208. <p>This method returns the previous state of the state machine.</p>
  209. </dd></dl>
  210. <dl class="method">
  211. <dt id="state_machine.state_machine.previous_state_duration">
  212. <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>
  213. <dd><table class="docutils field-list" frame="void" rules="none">
  214. <col class="field-name" />
  215. <col class="field-body" />
  216. <tbody valign="top">
  217. <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>
  218. </tr>
  219. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">float</td>
  220. </tr>
  221. </tbody>
  222. </table>
  223. <p>This method returns the time how long the previous state was active.</p>
  224. </dd></dl>
  225. <dl class="method">
  226. <dt id="state_machine.state_machine.previous_state_was">
  227. <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>
  228. <dd><table class="docutils field-list" frame="void" rules="none">
  229. <col class="field-name" />
  230. <col class="field-body" />
  231. <tbody valign="top">
  232. <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>
  233. </tr>
  234. <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>
  235. </tr>
  236. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  237. </tr>
  238. </tbody>
  239. </table>
  240. <p>This methods returns the boolean information if the state machine was previously in the given state.</p>
  241. </dd></dl>
  242. <dl class="method">
  243. <dt id="state_machine.state_machine.register_state_change_callback">
  244. <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>
  245. <dd><table class="docutils field-list" frame="void" rules="none">
  246. <col class="field-name" />
  247. <col class="field-body" />
  248. <tbody valign="top">
  249. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  250. <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>
  251. <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>
  252. <li><strong>callback</strong> – The callback to be executed.</li>
  253. </ul>
  254. </td>
  255. </tr>
  256. </tbody>
  257. </table>
  258. <div class="admonition note">
  259. <p class="first admonition-title">Note</p>
  260. <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>
  261. </div>
  262. <p>This methods allows to register callbacks which will be executed on state changes.</p>
  263. </dd></dl>
  264. <dl class="method">
  265. <dt id="state_machine.state_machine.this_state">
  266. <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>
  267. <dd><table class="docutils field-list" frame="void" rules="none">
  268. <col class="field-name" />
  269. <col class="field-body" />
  270. <tbody valign="top">
  271. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The current state.</td>
  272. </tr>
  273. </tbody>
  274. </table>
  275. <p>This method returns the current state of the state machine.</p>
  276. </dd></dl>
  277. <dl class="method">
  278. <dt id="state_machine.state_machine.this_state_duration">
  279. <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>
  280. <dd><table class="docutils field-list" frame="void" rules="none">
  281. <col class="field-name" />
  282. <col class="field-body" />
  283. <tbody valign="top">
  284. <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>
  285. </tr>
  286. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">float</td>
  287. </tr>
  288. </tbody>
  289. </table>
  290. <p>This method returns the time how long the current state is active.</p>
  291. </dd></dl>
  292. <dl class="method">
  293. <dt id="state_machine.state_machine.this_state_is">
  294. <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>
  295. <dd><table class="docutils field-list" frame="void" rules="none">
  296. <col class="field-name" />
  297. <col class="field-body" />
  298. <tbody valign="top">
  299. <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>
  300. </tr>
  301. <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>
  302. </tr>
  303. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  304. </tr>
  305. </tbody>
  306. </table>
  307. <p>This methods returns the boolean information if the state machine is currently in the given state.</p>
  308. </dd></dl>
  309. <dl class="method">
  310. <dt id="state_machine.state_machine.work">
  311. <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>
  312. <dd><p>This Method needs to be executed cyclicly to enable the state machine.</p>
  313. </dd></dl>
  314. </dd></dl>
  315. </div>
  316. <div class="toctree-wrapper compound">
  317. </div>
  318. </div>
  319. <div class="section" id="indices-and-tables">
  320. <h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
  321. <ul class="simple">
  322. <li><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></li>
  323. <li><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></li>
  324. <li><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></li>
  325. </ul>
  326. </div>
  327. </div>
  328. </div>
  329. <footer>
  330. <hr/>
  331. <div role="contentinfo">
  332. <p>
  333. &copy; Copyright 2021, Dirk Alders
  334. </p>
  335. </div>
  336. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
  337. <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
  338. provided by <a href="https://readthedocs.org">Read the Docs</a>.
  339. </footer>
  340. </div>
  341. </div>
  342. </section>
  343. </div>
  344. <script type="text/javascript">
  345. jQuery(function () {
  346. SphinxRtdTheme.Navigation.enable(true);
  347. });
  348. </script>
  349. </body>
  350. </html>