|
@@ -0,0 +1,724 @@
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+<!DOCTYPE html>
|
|
4
|
+<html class="writer-html4" lang="en" >
|
|
5
|
+<head>
|
|
6
|
+ <meta charset="utf-8">
|
|
7
|
+
|
|
8
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9
|
+
|
|
10
|
+ <title>Welcome to helpers’s documentation! — helpers documentation</title>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+ <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
|
|
15
|
+ <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+ <!--[if lt IE 9]>
|
|
24
|
+ <script src="_static/js/html5shiv.min.js"></script>
|
|
25
|
+ <![endif]-->
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+ <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
|
29
|
+ <script type="text/javascript" src="_static/jquery.js"></script>
|
|
30
|
+ <script type="text/javascript" src="_static/underscore.js"></script>
|
|
31
|
+ <script type="text/javascript" src="_static/doctools.js"></script>
|
|
32
|
+ <script type="text/javascript" src="_static/language_data.js"></script>
|
|
33
|
+
|
|
34
|
+ <script type="text/javascript" src="_static/js/theme.js"></script>
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+ <link rel="index" title="Index" href="genindex.html" />
|
|
38
|
+ <link rel="search" title="Search" href="search.html" />
|
|
39
|
+</head>
|
|
40
|
+
|
|
41
|
+<body class="wy-body-for-nav">
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+ <div class="wy-grid-for-nav">
|
|
45
|
+
|
|
46
|
+ <nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
|
47
|
+ <div class="wy-side-scroll">
|
|
48
|
+ <div class="wy-side-nav-search" >
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+ <a href="#" class="icon icon-home" alt="Documentation Home"> helpers
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+ </a>
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+<div role="search">
|
|
65
|
+ <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
|
|
66
|
+ <input type="text" name="q" placeholder="Search docs" />
|
|
67
|
+ <input type="hidden" name="check_keywords" value="yes" />
|
|
68
|
+ <input type="hidden" name="area" value="default" />
|
|
69
|
+ </form>
|
|
70
|
+</div>
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+ </div>
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+ <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+ <!-- Local TOC -->
|
|
84
|
+ <div class="local-toc"><ul>
|
|
85
|
+<li><a class="reference internal" href="#">Welcome to helpers’s documentation!</a><ul>
|
|
86
|
+<li><a class="reference internal" href="#helpers-helpers">helpers (Helpers)</a></li>
|
|
87
|
+</ul>
|
|
88
|
+</li>
|
|
89
|
+<li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
|
|
90
|
+</ul>
|
|
91
|
+</div>
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+ </div>
|
|
95
|
+
|
|
96
|
+ </div>
|
|
97
|
+ </nav>
|
|
98
|
+
|
|
99
|
+ <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+ <nav class="wy-nav-top" aria-label="top navigation">
|
|
103
|
+
|
|
104
|
+ <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
105
|
+ <a href="#">helpers</a>
|
|
106
|
+
|
|
107
|
+ </nav>
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+ <div class="wy-nav-content">
|
|
111
|
+
|
|
112
|
+ <div class="rst-content">
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+<div role="navigation" aria-label="breadcrumbs navigation">
|
|
131
|
+
|
|
132
|
+ <ul class="wy-breadcrumbs">
|
|
133
|
+
|
|
134
|
+ <li><a href="#" class="icon icon-home"></a> »</li>
|
|
135
|
+
|
|
136
|
+ <li>Welcome to helpers’s documentation!</li>
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+ <li class="wy-breadcrumbs-aside">
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+ <a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+ </li>
|
|
146
|
+
|
|
147
|
+ </ul>
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+ <hr/>
|
|
151
|
+</div>
|
|
152
|
+ <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
|
153
|
+ <div itemprop="articleBody">
|
|
154
|
+
|
|
155
|
+ <div class="section" id="module-helpers">
|
|
156
|
+<span id="welcome-to-helpers-s-documentation"></span><h1>Welcome to helpers’s documentation!<a class="headerlink" href="#module-helpers" title="Permalink to this headline">¶</a></h1>
|
|
157
|
+<div class="section" id="helpers-helpers">
|
|
158
|
+<h2>helpers (Helpers)<a class="headerlink" href="#helpers-helpers" title="Permalink to this headline">¶</a></h2>
|
|
159
|
+<p><strong>Author:</strong></p>
|
|
160
|
+<ul class="simple">
|
|
161
|
+<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>
|
|
162
|
+</ul>
|
|
163
|
+<p><strong>Description:</strong></p>
|
|
164
|
+<blockquote>
|
|
165
|
+<div>This module supports functions and classes which don’t have an own Module (yet).</div></blockquote>
|
|
166
|
+<p><strong>Submodules:</strong></p>
|
|
167
|
+<ul class="simple">
|
|
168
|
+<li><a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a></li>
|
|
169
|
+<li><a class="reference internal" href="#helpers.continues_statistic_multivalue" title="helpers.continues_statistic_multivalue"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic_multivalue</span></code></a></li>
|
|
170
|
+<li><a class="reference internal" href="#helpers.direct_socket_client" title="helpers.direct_socket_client"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_client</span></code></a></li>
|
|
171
|
+<li><a class="reference internal" href="#helpers.direct_socket_server" title="helpers.direct_socket_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_server</span></code></a></li>
|
|
172
|
+<li><a class="reference internal" href="#helpers.ringbuffer" title="helpers.ringbuffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.ringbuffer</span></code></a></li>
|
|
173
|
+</ul>
|
|
174
|
+<p><strong>Unittest:</strong></p>
|
|
175
|
+<blockquote>
|
|
176
|
+<div>See also the <a class="reference download internal" download="" href="_downloads/fc87e95cc505cb0c7a476506dac46609/unittest.pdf"><code class="xref download docutils literal notranslate"><span class="pre">unittest</span></code></a> documentation.</div></blockquote>
|
|
177
|
+<p><strong>Module Documentation:</strong></p>
|
|
178
|
+<dl class="class">
|
|
179
|
+<dt id="helpers.continues_statistic">
|
|
180
|
+<em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">continues_statistic</code><span class="sig-paren">(</span><em>mean=None</em>, <em>min_val=None</em>, <em>max_val=None</em>, <em>quantifier=0</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.continues_statistic" title="Permalink to this definition">¶</a></dt>
|
|
181
|
+<dd><p>This class stores a statistic for a stream of values. The statistic includes: mean, min, max, quantifier.</p>
|
|
182
|
+<div class="admonition note">
|
|
183
|
+<p class="first admonition-title">Note</p>
|
|
184
|
+<p class="last">You can use the mathematic operators “+, +=” to add a value to the statistic.</p>
|
|
185
|
+</div>
|
|
186
|
+<table class="docutils field-list" frame="void" rules="none">
|
|
187
|
+<col class="field-name" />
|
|
188
|
+<col class="field-body" />
|
|
189
|
+<tbody valign="top">
|
|
190
|
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
|
|
191
|
+<li><strong>mean</strong> (<em>numeric</em>) – The mean start value, the start value or None.</li>
|
|
192
|
+<li><strong>min_val</strong> (<em>numeric</em>) – The min start value or None</li>
|
|
193
|
+<li><strong>max_val</strong> (<em>numeric</em>) – The max start value or None</li>
|
|
194
|
+<li><strong>quantifier</strong> (<em>int</em>) – The quantifier start value or 0</li>
|
|
195
|
+</ul>
|
|
196
|
+</td>
|
|
197
|
+</tr>
|
|
198
|
+</tbody>
|
|
199
|
+</table>
|
|
200
|
+<div class="admonition note">
|
|
201
|
+<p class="first admonition-title">Note</p>
|
|
202
|
+<p>You are able to initialise this class in the following ways:</p>
|
|
203
|
+<ul class="last simple">
|
|
204
|
+<li>Without arguments to get an empty instance</li>
|
|
205
|
+<li>With one single value to get an starting instance</li>
|
|
206
|
+<li>With mean, min_val, max_val, quantifier to initialise an existing statistic</li>
|
|
207
|
+</ul>
|
|
208
|
+</div>
|
|
209
|
+<p><strong>Example:</strong></p>
|
|
210
|
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
|
|
211
|
+<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">'../..'</span><span class="p">)</span>
|
|
212
|
+
|
|
213
|
+<span class="kn">import</span> <span class="nn">helpers</span>
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+<span class="n">cs</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic</span><span class="p">()</span>
|
|
217
|
+<span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">4</span><span class="p">):</span>
|
|
218
|
+ <span class="n">cs</span> <span class="o">+=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic</span><span class="p">(</span><span class="n">val</span><span class="p">)</span>
|
|
219
|
+ <span class="nb">print</span><span class="p">(</span><span class="n">cs</span><span class="p">)</span>
|
|
220
|
+</pre></div>
|
|
221
|
+</div>
|
|
222
|
+<p>Will result to the following output:</p>
|
|
223
|
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mean</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">1</span>
|
|
224
|
+<span class="n">mean</span><span class="o">=</span><span class="mf">2.0</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">2</span>
|
|
225
|
+<span class="n">mean</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">3</span>
|
|
226
|
+<span class="n">mean</span><span class="o">=</span><span class="mf">3.25</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">4</span>
|
|
227
|
+</pre></div>
|
|
228
|
+</div>
|
|
229
|
+<dl class="attribute">
|
|
230
|
+<dt id="helpers.continues_statistic.max">
|
|
231
|
+<code class="descname">max</code><a class="headerlink" href="#helpers.continues_statistic.max" title="Permalink to this definition">¶</a></dt>
|
|
232
|
+<dd><p>The current max value.</p>
|
|
233
|
+</dd></dl>
|
|
234
|
+
|
|
235
|
+<dl class="attribute">
|
|
236
|
+<dt id="helpers.continues_statistic.mean">
|
|
237
|
+<code class="descname">mean</code><a class="headerlink" href="#helpers.continues_statistic.mean" title="Permalink to this definition">¶</a></dt>
|
|
238
|
+<dd><p>The current mean value.</p>
|
|
239
|
+</dd></dl>
|
|
240
|
+
|
|
241
|
+<dl class="attribute">
|
|
242
|
+<dt id="helpers.continues_statistic.min">
|
|
243
|
+<code class="descname">min</code><a class="headerlink" href="#helpers.continues_statistic.min" title="Permalink to this definition">¶</a></dt>
|
|
244
|
+<dd><p>The current min value.</p>
|
|
245
|
+</dd></dl>
|
|
246
|
+
|
|
247
|
+<dl class="method">
|
|
248
|
+<dt id="helpers.continues_statistic.pop">
|
|
249
|
+<code class="descname">pop</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.continues_statistic.pop" title="Permalink to this definition">¶</a></dt>
|
|
250
|
+<dd><p>This pops out the current statistic data and returns these as an instance of <a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a>.</p>
|
|
251
|
+<table class="docutils field-list" frame="void" rules="none">
|
|
252
|
+<col class="field-name" />
|
|
253
|
+<col class="field-body" />
|
|
254
|
+<tbody valign="top">
|
|
255
|
+<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The current statistic or None, if no value is available.</td>
|
|
256
|
+</tr>
|
|
257
|
+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a> or None</td>
|
|
258
|
+</tr>
|
|
259
|
+</tbody>
|
|
260
|
+</table>
|
|
261
|
+</dd></dl>
|
|
262
|
+
|
|
263
|
+<dl class="attribute">
|
|
264
|
+<dt id="helpers.continues_statistic.quantifier">
|
|
265
|
+<code class="descname">quantifier</code><a class="headerlink" href="#helpers.continues_statistic.quantifier" title="Permalink to this definition">¶</a></dt>
|
|
266
|
+<dd><p>The current quantifier (number of values for continues statistic).</p>
|
|
267
|
+</dd></dl>
|
|
268
|
+
|
|
269
|
+</dd></dl>
|
|
270
|
+
|
|
271
|
+<dl class="class">
|
|
272
|
+<dt id="helpers.continues_statistic_multivalue">
|
|
273
|
+<em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">continues_statistic_multivalue</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.continues_statistic_multivalue" title="Permalink to this definition">¶</a></dt>
|
|
274
|
+<dd><p>This class stores multiple statistics of stream values. The statistic of each value is stored as <a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a>.</p>
|
|
275
|
+<div class="admonition note">
|
|
276
|
+<p class="first admonition-title">Note</p>
|
|
277
|
+<p class="last">You can use the mathematic operators “+, +=” to add instances.</p>
|
|
278
|
+</div>
|
|
279
|
+<div class="admonition note">
|
|
280
|
+<p class="first admonition-title">Note</p>
|
|
281
|
+<p>You are able to initialise this class in the following ways:</p>
|
|
282
|
+<ul class="last simple">
|
|
283
|
+<li>Without arguments to get an empty instance</li>
|
|
284
|
+<li>With a keword argument(s) which will be passed to <a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">continues_statistic</span></code></a></li>
|
|
285
|
+<li>With a dict equivalent of <a class="reference internal" href="#helpers.continues_statistic_multivalue" title="helpers.continues_statistic_multivalue"><code class="xref py py-class docutils literal notranslate"><span class="pre">continues_statistic_multivalue</span></code></a> to initialise an existing statistic</li>
|
|
286
|
+</ul>
|
|
287
|
+</div>
|
|
288
|
+<p><strong>Example:</strong></p>
|
|
289
|
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
|
|
290
|
+<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">'../..'</span><span class="p">)</span>
|
|
291
|
+
|
|
292
|
+<span class="kn">import</span> <span class="nn">helpers</span>
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+<span class="n">csm</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic_multivalue</span><span class="p">()</span>
|
|
296
|
+<span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
297
|
+<span class="n">csm</span> <span class="o">+=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic_multivalue</span><span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="p">{</span><span class="s1">'mean'</span><span class="p">:</span> <span class="mf">3.1</span><span class="p">,</span> <span class="s1">'min_val'</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">'max_val'</span><span class="p">:</span> <span class="mf">3.5</span><span class="p">,</span> <span class="s1">'quantifier'</span><span class="p">:</span> <span class="mi">305</span><span class="p">})</span>
|
|
298
|
+<span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
299
|
+<span class="n">csm</span> <span class="o">+=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic_multivalue</span><span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="p">{</span><span class="s1">'mean'</span><span class="p">:</span> <span class="mf">17.1</span><span class="p">,</span> <span class="s1">'min_val'</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">,</span> <span class="s1">'max_val'</span><span class="p">:</span> <span class="mf">19.3</span><span class="p">,</span> <span class="s1">'quantifier'</span><span class="p">:</span> <span class="mi">27</span><span class="p">})</span>
|
|
300
|
+<span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
301
|
+<span class="nb">print</span><span class="p">(</span><span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic_multivalue</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="n">csm</span><span class="p">)),</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
302
|
+<span class="nb">print</span><span class="p">(</span><span class="s1">'pop out b:'</span><span class="p">,</span> <span class="n">csm</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">'b'</span><span class="p">),</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
303
|
+<span class="nb">print</span><span class="p">(</span><span class="s1">'pop out b:'</span><span class="p">,</span> <span class="n">csm</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">'b'</span><span class="p">),</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
304
|
+<span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
305
|
+<span class="nb">print</span><span class="p">(</span><span class="s1">'pop out all:</span><span class="se">\n</span><span class="si">%s</span><span class="s1">'</span> <span class="o">%</span> <span class="n">csm</span><span class="o">.</span><span class="n">pop</span><span class="p">(),</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
306
|
+<span class="nb">print</span><span class="p">(</span><span class="s1">'pop out all:</span><span class="se">\n</span><span class="si">%s</span><span class="s1">'</span> <span class="o">%</span> <span class="n">csm</span><span class="o">.</span><span class="n">pop</span><span class="p">(),</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
307
|
+<span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
308
|
+</pre></div>
|
|
309
|
+</div>
|
|
310
|
+<p>Will result to the following output:</p>
|
|
311
|
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span>
|
|
312
|
+<span class="o">--------------------------------------------------------------</span>
|
|
313
|
+<span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">3.5</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">305</span>
|
|
314
|
+<span class="o">--------------------------------------------------------------</span>
|
|
315
|
+<span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">17.1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">13.1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">19.3</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">27</span>
|
|
316
|
+<span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.103954248366013</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">306</span>
|
|
317
|
+<span class="o">--------------------------------------------------------------</span>
|
|
318
|
+<span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">17.1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">13.1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">19.3</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">27</span>
|
|
319
|
+<span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.103954248366013</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">306</span>
|
|
320
|
+<span class="o">--------------------------------------------------------------</span>
|
|
321
|
+<span class="n">pop</span> <span class="n">out</span> <span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">17.1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">13.1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">19.3</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">27</span>
|
|
322
|
+<span class="o">--------------------------------------------------------------</span>
|
|
323
|
+<span class="n">pop</span> <span class="n">out</span> <span class="n">b</span><span class="p">:</span> <span class="kc">None</span>
|
|
324
|
+<span class="o">--------------------------------------------------------------</span>
|
|
325
|
+<span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">0</span>
|
|
326
|
+<span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.103954248366013</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">306</span>
|
|
327
|
+<span class="o">--------------------------------------------------------------</span>
|
|
328
|
+<span class="n">pop</span> <span class="n">out</span> <span class="nb">all</span><span class="p">:</span>
|
|
329
|
+<span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">0</span>
|
|
330
|
+<span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.103954248366013</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">306</span>
|
|
331
|
+<span class="o">--------------------------------------------------------------</span>
|
|
332
|
+<span class="n">pop</span> <span class="n">out</span> <span class="nb">all</span><span class="p">:</span>
|
|
333
|
+<span class="kc">None</span>
|
|
334
|
+<span class="o">--------------------------------------------------------------</span>
|
|
335
|
+<span class="o">-</span>
|
|
336
|
+<span class="o">--------------------------------------------------------------</span>
|
|
337
|
+</pre></div>
|
|
338
|
+</div>
|
|
339
|
+<dl class="method">
|
|
340
|
+<dt id="helpers.continues_statistic_multivalue.pop">
|
|
341
|
+<code class="descname">pop</code><span class="sig-paren">(</span><em>key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.continues_statistic_multivalue.pop" title="Permalink to this definition">¶</a></dt>
|
|
342
|
+<dd><p>This pops out the current statistic data for a given key and returns these as an instance of <a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a>.</p>
|
|
343
|
+<p>If no key is given it pops out the current statistic data and returns these as an instance of <code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic_multiple</span></code>.</p>
|
|
344
|
+<table class="docutils field-list" frame="void" rules="none">
|
|
345
|
+<col class="field-name" />
|
|
346
|
+<col class="field-body" />
|
|
347
|
+<tbody valign="top">
|
|
348
|
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>key</strong> (<em>str</em><em> or </em><em>NoneType</em>) – The key to get data for</td>
|
|
349
|
+</tr>
|
|
350
|
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The current statistic or None, if no value is available.</td>
|
|
351
|
+</tr>
|
|
352
|
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a> or None</td>
|
|
353
|
+</tr>
|
|
354
|
+</tbody>
|
|
355
|
+</table>
|
|
356
|
+</dd></dl>
|
|
357
|
+
|
|
358
|
+</dd></dl>
|
|
359
|
+
|
|
360
|
+<dl class="class">
|
|
361
|
+<dt id="helpers.direct_socket_base">
|
|
362
|
+<em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">direct_socket_base</code><span class="sig-paren">(</span><em>max_len=None</em>, <em>virtual_rate_bps=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base" title="Permalink to this definition">¶</a></dt>
|
|
363
|
+<dd><p>This is the base class for other classes in this module.</p>
|
|
364
|
+<dl class="method">
|
|
365
|
+<dt id="helpers.direct_socket_base.disconnect">
|
|
366
|
+<code class="descname">disconnect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.disconnect" title="Permalink to this definition">¶</a></dt>
|
|
367
|
+<dd><p>Method to disconnect client and server.</p>
|
|
368
|
+</dd></dl>
|
|
369
|
+
|
|
370
|
+<dl class="method">
|
|
371
|
+<dt id="helpers.direct_socket_base.init_channel_name">
|
|
372
|
+<code class="descname">init_channel_name</code><span class="sig-paren">(</span><em>channel_name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.init_channel_name" title="Permalink to this definition">¶</a></dt>
|
|
373
|
+<dd><p>With this Method, the channel name for logging can be changed.</p>
|
|
374
|
+<table class="docutils field-list" frame="void" rules="none">
|
|
375
|
+<col class="field-name" />
|
|
376
|
+<col class="field-body" />
|
|
377
|
+<tbody valign="top">
|
|
378
|
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>channel_name</strong> (<em>str</em>) – The name for the logging channel</td>
|
|
379
|
+</tr>
|
|
380
|
+</tbody>
|
|
381
|
+</table>
|
|
382
|
+</dd></dl>
|
|
383
|
+
|
|
384
|
+<dl class="method">
|
|
385
|
+<dt id="helpers.direct_socket_base.is_connected">
|
|
386
|
+<code class="descname">is_connected</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.is_connected" title="Permalink to this definition">¶</a></dt>
|
|
387
|
+<dd><p>With this Method the connection status can be identified.</p>
|
|
388
|
+<table class="docutils field-list" frame="void" rules="none">
|
|
389
|
+<col class="field-name" />
|
|
390
|
+<col class="field-body" />
|
|
391
|
+<tbody valign="top">
|
|
392
|
+<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True, if a connection is established, otherwise False.</td>
|
|
393
|
+</tr>
|
|
394
|
+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
|
|
395
|
+</tr>
|
|
396
|
+</tbody>
|
|
397
|
+</table>
|
|
398
|
+</dd></dl>
|
|
399
|
+
|
|
400
|
+<dl class="method">
|
|
401
|
+<dt id="helpers.direct_socket_base.receive">
|
|
402
|
+<code class="descname">receive</code><span class="sig-paren">(</span><em>timeout=1.0</em>, <em>num=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.receive" title="Permalink to this definition">¶</a></dt>
|
|
403
|
+<dd><p>This method returns received data.</p>
|
|
404
|
+<table class="docutils field-list" frame="void" rules="none">
|
|
405
|
+<col class="field-name" />
|
|
406
|
+<col class="field-body" />
|
|
407
|
+<tbody valign="top">
|
|
408
|
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
|
|
409
|
+<li><strong>timeout</strong> (<em>float</em>) – The timeout for receiving data (at least after the timeout the method returns data or None).</li>
|
|
410
|
+<li><strong>num</strong> (<em>int</em><em> or </em><em>None</em>) – the number of bytes to receive (use None to get all available data).</li>
|
|
411
|
+</ul>
|
|
412
|
+</td>
|
|
413
|
+</tr>
|
|
414
|
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The received data.</p>
|
|
415
|
+</td>
|
|
416
|
+</tr>
|
|
417
|
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bytes</p>
|
|
418
|
+</td>
|
|
419
|
+</tr>
|
|
420
|
+</tbody>
|
|
421
|
+</table>
|
|
422
|
+</dd></dl>
|
|
423
|
+
|
|
424
|
+<dl class="method">
|
|
425
|
+<dt id="helpers.direct_socket_base.register_callback">
|
|
426
|
+<code class="descname">register_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.register_callback" title="Permalink to this definition">¶</a></dt>
|
|
427
|
+<dd><p>This method stores the callback which is executed, if data is available. You need to execute <a class="reference internal" href="#helpers.direct_socket_base.receive" title="helpers.direct_socket_base.receive"><code class="xref py py-func docutils literal notranslate"><span class="pre">receive()</span></code></a> of this instance
|
|
428
|
+given as first argument.</p>
|
|
429
|
+<table class="docutils field-list" frame="void" rules="none">
|
|
430
|
+<col class="field-name" />
|
|
431
|
+<col class="field-body" />
|
|
432
|
+<tbody valign="top">
|
|
433
|
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – The callback which will be executed, when data is available.</td>
|
|
434
|
+</tr>
|
|
435
|
+</tbody>
|
|
436
|
+</table>
|
|
437
|
+</dd></dl>
|
|
438
|
+
|
|
439
|
+<dl class="method">
|
|
440
|
+<dt id="helpers.direct_socket_base.register_connect_callback">
|
|
441
|
+<code class="descname">register_connect_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.register_connect_callback" title="Permalink to this definition">¶</a></dt>
|
|
442
|
+<dd><p>This method stores the callback which is executed, if a connection is established.</p>
|
|
443
|
+<table class="docutils field-list" frame="void" rules="none">
|
|
444
|
+<col class="field-name" />
|
|
445
|
+<col class="field-body" />
|
|
446
|
+<tbody valign="top">
|
|
447
|
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – The callback which will be executed, when a connection is established.</td>
|
|
448
|
+</tr>
|
|
449
|
+</tbody>
|
|
450
|
+</table>
|
|
451
|
+</dd></dl>
|
|
452
|
+
|
|
453
|
+<dl class="method">
|
|
454
|
+<dt id="helpers.direct_socket_base.register_disconnect_callback">
|
|
455
|
+<code class="descname">register_disconnect_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.register_disconnect_callback" title="Permalink to this definition">¶</a></dt>
|
|
456
|
+<dd><p>This method stores the callback which is executed, after the connection is lost.</p>
|
|
457
|
+<table class="docutils field-list" frame="void" rules="none">
|
|
458
|
+<col class="field-name" />
|
|
459
|
+<col class="field-body" />
|
|
460
|
+<tbody valign="top">
|
|
461
|
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – The callback which will be executed, after the connection is lost.</td>
|
|
462
|
+</tr>
|
|
463
|
+</tbody>
|
|
464
|
+</table>
|
|
465
|
+</dd></dl>
|
|
466
|
+
|
|
467
|
+<dl class="method">
|
|
468
|
+<dt id="helpers.direct_socket_base.send">
|
|
469
|
+<code class="descname">send</code><span class="sig-paren">(</span><em>data</em>, <em>timeout=1.0</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.send" title="Permalink to this definition">¶</a></dt>
|
|
470
|
+<dd><p>This method sends data via the initiated communication channel.</p>
|
|
471
|
+<table class="docutils field-list" frame="void" rules="none">
|
|
472
|
+<col class="field-name" />
|
|
473
|
+<col class="field-body" />
|
|
474
|
+<tbody valign="top">
|
|
475
|
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
|
|
476
|
+<li><strong>data</strong> (<em>bytes</em>) – The data to be send over the communication channel.</li>
|
|
477
|
+<li><strong>timeout</strong> (<em>float</em>) – The timeout for sending data (e.g. time to establish new connection).</li>
|
|
478
|
+<li><strong>log_lvl</strong> (<em>int</em>) – The log level to log outgoing TX-data</li>
|
|
479
|
+</ul>
|
|
480
|
+</td>
|
|
481
|
+</tr>
|
|
482
|
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">True if data had been sent, otherwise False.</p>
|
|
483
|
+</td>
|
|
484
|
+</tr>
|
|
485
|
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
|
|
486
|
+</td>
|
|
487
|
+</tr>
|
|
488
|
+</tbody>
|
|
489
|
+</table>
|
|
490
|
+</dd></dl>
|
|
491
|
+
|
|
492
|
+</dd></dl>
|
|
493
|
+
|
|
494
|
+<dl class="class">
|
|
495
|
+<dt id="helpers.direct_socket_client">
|
|
496
|
+<em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">direct_socket_client</code><span class="sig-paren">(</span><em>max_len=None</em>, <em>virtual_rate_bps=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_client" title="Permalink to this definition">¶</a></dt>
|
|
497
|
+<dd><p>Class to create a direct client socket. See also parent <a class="reference internal" href="#helpers.direct_socket_base" title="helpers.direct_socket_base"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_base</span></code></a>.</p>
|
|
498
|
+<p><strong>Example:</strong></p>
|
|
499
|
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
|
|
500
|
+<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">'../..'</span><span class="p">)</span>
|
|
501
|
+
|
|
502
|
+<span class="kn">import</span> <span class="nn">report</span>
|
|
503
|
+<span class="kn">import</span> <span class="nn">helpers</span>
|
|
504
|
+<span class="kn">import</span> <span class="nn">time</span>
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+<span class="k">def</span> <span class="nf">mirror_callback</span><span class="p">(</span><span class="n">sock</span><span class="p">):</span>
|
|
508
|
+ <span class="n">sock</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">sock</span><span class="o">.</span><span class="n">receive</span><span class="p">())</span>
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+<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="s1">'root'</span><span class="p">,</span> <span class="s1">'DEBUG'</span><span class="p">),</span> <span class="p">])</span>
|
|
512
|
+<span class="n">s</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">direct_socket_server</span><span class="p">(</span><span class="n">virtual_rate_bps</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
|
|
513
|
+<span class="n">s</span><span class="o">.</span><span class="n">init_channel_name</span><span class="p">(</span><span class="s1">'example_server'</span><span class="p">)</span>
|
|
514
|
+<span class="n">s</span><span class="o">.</span><span class="n">register_callback</span><span class="p">(</span><span class="n">mirror_callback</span><span class="p">)</span>
|
|
515
|
+<span class="n">c</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">direct_socket_client</span><span class="p">(</span><span class="n">max_len</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">virtual_rate_bps</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
|
|
516
|
+<span class="n">c</span><span class="o">.</span><span class="n">init_channel_name</span><span class="p">(</span><span class="s1">'example_client'</span><span class="p">)</span>
|
|
517
|
+<span class="n">c</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
|
|
518
|
+<span class="n">c</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="sa">b</span><span class="s1">'abc'</span><span class="p">)</span>
|
|
519
|
+<span class="nb">print</span><span class="p">(</span><span class="s1">'The Client received: </span><span class="si">%s</span><span class="s1">'</span> <span class="o">%</span> <span class="nb">repr</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">receive</span><span class="p">()))</span>
|
|
520
|
+</pre></div>
|
|
521
|
+</div>
|
|
522
|
+<p>Will result to the following output:</p>
|
|
523
|
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
|
|
524
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Waiting</span> <span class="k">for</span> <span class="n">incomming</span> <span class="n">connection</span>
|
|
525
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
|
|
526
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span>
|
|
527
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
|
|
528
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span>
|
|
529
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
|
|
530
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-></span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
|
|
531
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">321</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">RX</span> <span class="o"><-</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
|
|
532
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">322</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-></span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
|
|
533
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">322</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-></span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
|
|
534
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">523</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">RX</span> <span class="o"><-</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
|
|
535
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">723</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">RX</span> <span class="o"><-</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
|
|
536
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">723</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-></span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
|
|
537
|
+<span class="n">The</span> <span class="n">Client</span> <span class="n">received</span><span class="p">:</span> <span class="sa">b</span><span class="s1">'ab'</span>
|
|
538
|
+</pre></div>
|
|
539
|
+</div>
|
|
540
|
+<dl class="method">
|
|
541
|
+<dt id="helpers.direct_socket_client.connect">
|
|
542
|
+<code class="descname">connect</code><span class="sig-paren">(</span><em>remote_socket</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_client.connect" title="Permalink to this definition">¶</a></dt>
|
|
543
|
+<dd><p>Method to create a connection between this client and a <a class="reference internal" href="#helpers.direct_socket_server" title="helpers.direct_socket_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_server</span></code></a> instance.</p>
|
|
544
|
+<table class="docutils field-list" frame="void" rules="none">
|
|
545
|
+<col class="field-name" />
|
|
546
|
+<col class="field-body" />
|
|
547
|
+<tbody valign="top">
|
|
548
|
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>remote_socket</strong> (<a class="reference internal" href="#helpers.direct_socket_server" title="helpers.direct_socket_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_server</span></code></a>) – The remote socket to connect to.</td>
|
|
549
|
+</tr>
|
|
550
|
+</tbody>
|
|
551
|
+</table>
|
|
552
|
+</dd></dl>
|
|
553
|
+
|
|
554
|
+<dl class="method">
|
|
555
|
+<dt id="helpers.direct_socket_client.reconnect">
|
|
556
|
+<code class="descname">reconnect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_client.reconnect" title="Permalink to this definition">¶</a></dt>
|
|
557
|
+<dd><p>Method to do a reconnect.</p>
|
|
558
|
+<div class="admonition note">
|
|
559
|
+<p class="first admonition-title">Note</p>
|
|
560
|
+<p class="last">The <code class="xref py py-const docutils literal notranslate"><span class="pre">remote_socket</span></code> of the prefious <a class="reference internal" href="#helpers.direct_socket_client.connect" title="helpers.direct_socket_client.connect"><code class="xref py py-func docutils literal notranslate"><span class="pre">connect()</span></code></a> call will be used.</p>
|
|
561
|
+</div>
|
|
562
|
+</dd></dl>
|
|
563
|
+
|
|
564
|
+</dd></dl>
|
|
565
|
+
|
|
566
|
+<dl class="class">
|
|
567
|
+<dt id="helpers.direct_socket_server">
|
|
568
|
+<em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">direct_socket_server</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_server" title="Permalink to this definition">¶</a></dt>
|
|
569
|
+<dd><p>Class to create a direct server socket. See also parent <a class="reference internal" href="#helpers.direct_socket_base" title="helpers.direct_socket_base"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_base</span></code></a>.</p>
|
|
570
|
+<p><strong>Example:</strong></p>
|
|
571
|
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
|
|
572
|
+<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">'../..'</span><span class="p">)</span>
|
|
573
|
+
|
|
574
|
+<span class="kn">import</span> <span class="nn">report</span>
|
|
575
|
+<span class="kn">import</span> <span class="nn">helpers</span>
|
|
576
|
+<span class="kn">import</span> <span class="nn">time</span>
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+<span class="k">def</span> <span class="nf">mirror_callback</span><span class="p">(</span><span class="n">sock</span><span class="p">):</span>
|
|
580
|
+ <span class="n">sock</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">sock</span><span class="o">.</span><span class="n">receive</span><span class="p">())</span>
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+<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="s1">'root'</span><span class="p">,</span> <span class="s1">'DEBUG'</span><span class="p">),</span> <span class="p">])</span>
|
|
584
|
+<span class="n">s</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">direct_socket_server</span><span class="p">(</span><span class="n">virtual_rate_bps</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
|
|
585
|
+<span class="n">s</span><span class="o">.</span><span class="n">init_channel_name</span><span class="p">(</span><span class="s1">'example_server'</span><span class="p">)</span>
|
|
586
|
+<span class="n">s</span><span class="o">.</span><span class="n">register_callback</span><span class="p">(</span><span class="n">mirror_callback</span><span class="p">)</span>
|
|
587
|
+<span class="n">c</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">direct_socket_client</span><span class="p">(</span><span class="n">max_len</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">virtual_rate_bps</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
|
|
588
|
+<span class="n">c</span><span class="o">.</span><span class="n">init_channel_name</span><span class="p">(</span><span class="s1">'example_client'</span><span class="p">)</span>
|
|
589
|
+<span class="n">c</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
|
|
590
|
+<span class="n">c</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="sa">b</span><span class="s1">'abc'</span><span class="p">)</span>
|
|
591
|
+<span class="nb">print</span><span class="p">(</span><span class="s1">'The Client received: </span><span class="si">%s</span><span class="s1">'</span> <span class="o">%</span> <span class="nb">repr</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">receive</span><span class="p">()))</span>
|
|
592
|
+</pre></div>
|
|
593
|
+</div>
|
|
594
|
+<p>Will result to the following output:</p>
|
|
595
|
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
|
|
596
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Waiting</span> <span class="k">for</span> <span class="n">incomming</span> <span class="n">connection</span>
|
|
597
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
|
|
598
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span>
|
|
599
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
|
|
600
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span>
|
|
601
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
|
|
602
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-></span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
|
|
603
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">321</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">RX</span> <span class="o"><-</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
|
|
604
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">322</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-></span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
|
|
605
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">322</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-></span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
|
|
606
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">523</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">RX</span> <span class="o"><-</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
|
|
607
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">723</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">RX</span> <span class="o"><-</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
|
|
608
|
+<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">723</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-></span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
|
|
609
|
+<span class="n">The</span> <span class="n">Client</span> <span class="n">received</span><span class="p">:</span> <span class="sa">b</span><span class="s1">'ab'</span>
|
|
610
|
+</pre></div>
|
|
611
|
+</div>
|
|
612
|
+</dd></dl>
|
|
613
|
+
|
|
614
|
+<dl class="class">
|
|
615
|
+<dt id="helpers.ringbuffer">
|
|
616
|
+<em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">ringbuffer</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.ringbuffer" title="Permalink to this definition">¶</a></dt>
|
|
617
|
+<dd><p>Class for a list with a limited number of elements.</p>
|
|
618
|
+<div class="admonition note">
|
|
619
|
+<p class="first admonition-title">Note</p>
|
|
620
|
+<p class="last">On adding Objects, the list will be reduced to the maximum length by deleting entries starting from index 0.</p>
|
|
621
|
+</div>
|
|
622
|
+<p><strong>Example:</strong></p>
|
|
623
|
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
|
|
624
|
+<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">'../..'</span><span class="p">)</span>
|
|
625
|
+
|
|
626
|
+<span class="kn">import</span> <span class="nn">helpers</span>
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+<span class="n">rb</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">ringbuffer</span><span class="p">(</span><span class="n">length</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
|
|
630
|
+<span class="nb">print</span><span class="p">(</span><span class="n">rb</span><span class="p">,</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
631
|
+<span class="n">rb</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
|
|
632
|
+<span class="nb">print</span><span class="p">(</span><span class="n">rb</span><span class="p">,</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
633
|
+<span class="n">rb</span><span class="o">.</span><span class="n">extend</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">))</span>
|
|
634
|
+<span class="nb">print</span><span class="p">(</span><span class="n">rb</span><span class="p">,</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
635
|
+<span class="n">rb</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">17</span><span class="p">)</span>
|
|
636
|
+<span class="nb">print</span><span class="p">(</span><span class="n">rb</span><span class="p">,</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------'</span><span class="p">)</span>
|
|
637
|
+</pre></div>
|
|
638
|
+</div>
|
|
639
|
+<p>Will result to the following output:</p>
|
|
640
|
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[]</span>
|
|
641
|
+<span class="o">--------------------------------------------------------------</span>
|
|
642
|
+<span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
|
643
|
+<span class="o">--------------------------------------------------------------</span>
|
|
644
|
+<span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">]</span>
|
|
645
|
+<span class="o">--------------------------------------------------------------</span>
|
|
646
|
+<span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">17</span><span class="p">]</span>
|
|
647
|
+<span class="o">--------------------------------------------------------------</span>
|
|
648
|
+</pre></div>
|
|
649
|
+</div>
|
|
650
|
+<dl class="method">
|
|
651
|
+<dt id="helpers.ringbuffer.append">
|
|
652
|
+<code class="descname">append</code><span class="sig-paren">(</span><em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.ringbuffer.append" title="Permalink to this definition">¶</a></dt>
|
|
653
|
+<dd><p>Append object to the end of the list.</p>
|
|
654
|
+</dd></dl>
|
|
655
|
+
|
|
656
|
+<dl class="method">
|
|
657
|
+<dt id="helpers.ringbuffer.extend">
|
|
658
|
+<code class="descname">extend</code><span class="sig-paren">(</span><em>iterable</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.ringbuffer.extend" title="Permalink to this definition">¶</a></dt>
|
|
659
|
+<dd><p>Extend list by appending elements from the iterable.</p>
|
|
660
|
+</dd></dl>
|
|
661
|
+
|
|
662
|
+</dd></dl>
|
|
663
|
+
|
|
664
|
+</div>
|
|
665
|
+<div class="toctree-wrapper compound">
|
|
666
|
+</div>
|
|
667
|
+</div>
|
|
668
|
+<div class="section" id="indices-and-tables">
|
|
669
|
+<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
|
|
670
|
+<ul class="simple">
|
|
671
|
+<li><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></li>
|
|
672
|
+<li><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></li>
|
|
673
|
+<li><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></li>
|
|
674
|
+</ul>
|
|
675
|
+</div>
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+ </div>
|
|
679
|
+
|
|
680
|
+ </div>
|
|
681
|
+ <footer>
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+ <hr/>
|
|
685
|
+
|
|
686
|
+ <div role="contentinfo">
|
|
687
|
+ <p>
|
|
688
|
+
|
|
689
|
+ © Copyright 2021, Dirk Alders
|
|
690
|
+
|
|
691
|
+ </p>
|
|
692
|
+ </div>
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+ Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
|
|
697
|
+
|
|
698
|
+ <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
|
|
699
|
+
|
|
700
|
+ provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
701
|
+
|
|
702
|
+</footer>
|
|
703
|
+
|
|
704
|
+ </div>
|
|
705
|
+ </div>
|
|
706
|
+
|
|
707
|
+ </section>
|
|
708
|
+
|
|
709
|
+ </div>
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+ <script type="text/javascript">
|
|
713
|
+ jQuery(function () {
|
|
714
|
+ SphinxRtdTheme.Navigation.enable(true);
|
|
715
|
+ });
|
|
716
|
+ </script>
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+</body>
|
|
724
|
+</html>
|