craftbeerpi4-pione/docs/step.html
2019-01-05 23:27:29 +01:00

526 lines
No EOL
20 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>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Brewing Step &mdash; CraftBeerPi 4.0 documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Kettle" href="kettle_controller.html" />
<link rel="prev" title="Sensor" href="sensor.html" />
<script src="_static/js/modernizr.min.js"></script>
</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"> CraftBeerPi
</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">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="install.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="core.html">Core</a></li>
<li class="toctree-l1"><a class="reference internal" href="actor.html">Actor</a></li>
<li class="toctree-l1"><a class="reference internal" href="sensor.html">Sensor</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Brewing Step</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#stepcontroller">StepController</a></li>
<li class="toctree-l2"><a class="reference internal" href="#cbpisimplestep">CBPiSimpleStep</a></li>
<li class="toctree-l2"><a class="reference internal" href="#custom-step">Custom Step</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="kettle_controller.html">Kettle</a></li>
<li class="toctree-l1"><a class="reference internal" href="properties.html">Properties</a></li>
<li class="toctree-l1"><a class="reference internal" href="standards.html">Standard &amp; Guidelines</a></li>
</ul>
</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="index.html">CraftBeerPi</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="index.html">Docs</a> &raquo;</li>
<li>Brewing Step</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/step.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="brewing-step">
<h1>Brewing Step<a class="headerlink" href="#brewing-step" title="Permalink to this headline"></a></h1>
<div class="section" id="stepcontroller">
<h2>StepController<a class="headerlink" href="#stepcontroller" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="cbpi.controller.step_controller.StepController">
<em class="property">class </em><code class="descclassname">cbpi.controller.step_controller.</code><code class="descname">StepController</code><span class="sig-paren">(</span><em>cbpi</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.step_controller.StepController" title="Permalink to this definition"></a></dt>
<dd><p>The Step Controller. This controller is responsible to start and stop the brewing steps.</p>
<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">Undoc-members:</th><td class="field-body"></td>
</tr>
<tr class="field-even field"><th class="field-name" colspan="2">Show-inheritance:</th></tr>
<tr class="field-even field"><td>&#160;</td><td class="field-body"></td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="cbpi.controller.step_controller.StepController.handle_action">
<code class="descname">handle_action</code><span class="sig-paren">(</span><em>action</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.step_controller.StepController.handle_action" title="Permalink to this definition"></a></dt>
<dd><p>Event Handler for “step/action”.
It invokes the provided method name on the current step</p>
<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 simple">
<li><strong>action</strong> the method name which will be invoked</li>
<li><strong>kwargs</strong> </li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">None</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="cbpi.controller.step_controller.StepController.handle_reset">
<code class="descname">handle_reset</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.step_controller.StepController.handle_reset" title="Permalink to this definition"></a></dt>
<dd><p>Event Handler for “step/reset”.
Resets the current step</p>
<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>kwargs</strong> </td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="cbpi.controller.step_controller.StepController.init">
<code class="descname">init</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.step_controller.StepController.init" title="Permalink to this definition"></a></dt>
<dd><p>Initializer of the the Step Controller.
:return:</p>
</dd></dl>
<dl class="method">
<dt id="cbpi.controller.step_controller.StepController.next">
<code class="descname">next</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.step_controller.StepController.next" title="Permalink to this definition"></a></dt>
<dd><p>Event Handler for “step/next”.
It start the next step</p>
<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>kwargs</strong> </td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="cbpi.controller.step_controller.StepController.start">
<code class="descname">start</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.step_controller.StepController.start" title="Permalink to this definition"></a></dt>
<dd><p>Start the first step</p>
<p>:return:None</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="cbpisimplestep">
<h2>CBPiSimpleStep<a class="headerlink" href="#cbpisimplestep" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="cbpi.api.CBPiSimpleStep">
<em class="property">class </em><code class="descclassname">cbpi.api.</code><code class="descname">CBPiSimpleStep</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSimpleStep" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<dl class="method">
<dt id="cbpi.api.CBPiSimpleStep.is_dirty">
<code class="descname">is_dirty</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSimpleStep.is_dirty" title="Permalink to this definition"></a></dt>
<dd><p>Check if a managed variable has a new value</p>
<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">True if at least one managed variable has a new value assigend. Otherwise False</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="cbpi.api.CBPiSimpleStep.managed_fields">
<code class="descname">managed_fields</code><em class="property"> = []</em><a class="headerlink" href="#cbpi.api.CBPiSimpleStep.managed_fields" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="cbpi.api.CBPiSimpleStep.next">
<code class="descname">next</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSimpleStep.next" title="Permalink to this definition"></a></dt>
<dd><p>Request to stop the the step</p>
<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">None</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="cbpi.api.CBPiSimpleStep.reset">
<code class="descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSimpleStep.reset" title="Permalink to this definition"></a></dt>
<dd><p>Reset the step. This method needs to be overwritten by the custom step implementation</p>
<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">None</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="cbpi.api.CBPiSimpleStep.reset_dirty">
<code class="descname">reset_dirty</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSimpleStep.reset_dirty" title="Permalink to this definition"></a></dt>
<dd><p>Reset the dirty flag</p>
<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"></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="cbpi.api.CBPiSimpleStep.run">
<code class="descname">run</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSimpleStep.run" title="Permalink to this definition"></a></dt>
<dd><p>This method in running in the background. It invokes the run_cycle method in the configured interval
It checks if a managed variable was modified in the last exection cycle. If yes, the method will persisit the new value of the
managed property</p>
<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">None</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="cbpi.api.CBPiSimpleStep.run_cycle">
<code class="descname">run_cycle</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSimpleStep.run_cycle" title="Permalink to this definition"></a></dt>
<dd><p>This method is executed in the defined interval.
That the place to put your step logic.
The method need to be overwritten in the Ccstom step implementaion</p>
<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">None</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="cbpi.api.CBPiSimpleStep.running">
<code class="descname">running</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSimpleStep.running" title="Permalink to this definition"></a></dt>
<dd><p>Method checks if the step should continue running.
The method will return False if the step is requested to stop or the next step should start</p>
<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">True if the step is running. Otherwise False.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="cbpi.api.CBPiSimpleStep.stop">
<code class="descname">stop</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSimpleStep.stop" title="Permalink to this definition"></a></dt>
<dd><p>Request to stop the step</p>
<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">None</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="custom-step">
<h2>Custom Step<a class="headerlink" href="#custom-step" title="Permalink to this headline"></a></h2>
<p>This is an example of a custom step. The Step class need to extend Simple step. In addtion at least the run_cycle method needs to be overwritten</p>
<div class="literal-block-wrapper docutils container" id="id1">
<div class="code-block-caption"><span class="caption-text">__init__.py</span><a class="headerlink" href="#id1" title="Permalink to this code"></a></div>
<div class="highlight-python notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">asyncio</span>
<span class="kn">from</span> <span class="nn">cbpi.api</span> <span class="kn">import</span> <span class="o">*</span>
<span class="k">class</span> <span class="nc">CustomStepCBPi</span><span class="p">(</span><span class="n">CBPiSimpleStep</span><span class="p">):</span>
<span class="n">name</span> <span class="o">=</span> <span class="n">Property</span><span class="o">.</span><span class="n">Number</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s2">&quot;Test&quot;</span><span class="p">)</span>
<span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
<span class="nd">@action</span><span class="p">(</span><span class="n">key</span><span class="o">=</span><span class="s2">&quot;name&quot;</span><span class="p">,</span> <span class="n">parameters</span><span class="o">=</span><span class="bp">None</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="o">=</span><span class="s2">&quot;WOOHOO&quot;</span>
<span class="n">async</span> <span class="k">def</span> <span class="nf">run_cycle</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">print</span><span class="p">(</span><span class="s2">&quot;RUN&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">i</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">i</span> <span class="o">==</span> <span class="mi">5</span><span class="p">:</span>
<span class="c1"># print(&quot;NEXT&quot;)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">next</span><span class="p">()</span>
<span class="c1">#self.cbpi.notify(key=&quot;step&quot;, message=&quot;HELLO FROM STEP&quot;)</span>
<span class="k">def</span> <span class="nf">setup</span><span class="p">(</span><span class="n">cbpi</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;</span>
<span class="sd"> This method is called by the server during startup </span>
<span class="sd"> Here you need to register your plugins at the server</span>
<span class="sd"> :param cbpi: the cbpi core </span>
<span class="sd"> :return: </span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">cbpi</span><span class="o">.</span><span class="n">plugin</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="s2">&quot;CustomStepCBPi&quot;</span><span class="p">,</span> <span class="n">CustomStepCBPi</span><span class="p">)</span>
</pre></div>
</td></tr></table></div>
</div>
<p>config.yaml</p>
<div class="highlight-yaml notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="l l-Scalar l-Scalar-Plain">name</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">DummyStep</span>
<span class="l l-Scalar l-Scalar-Plain">version</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">4</span>
</pre></div>
</td></tr></table></div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="kettle_controller.html" class="btn btn-neutral float-right" title="Kettle" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="sensor.html" class="btn btn-neutral" title="Sensor" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Manuel Fritsch
</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" 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/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>